Anonymous avatar Anonymous committed 10a213b

修改3.5模板,删除service层save方法和修改insert语句

Comments (0)

Files changed (4)

CodeUnion.CodeGenerator/Main.cs

 
         private void Generate_Click(object sender, EventArgs e)
         {
-            IDictionary<string, object> parameters = new Dictionary<string, object>();
-            parameters.Add("database", ConfigurationManager.ConnectionStrings["connectionString"].ProviderName);
-            parameters.Add("namespace", this.Namespace.Text);
-            parameters.Add("nullableType", this.NullableType.Checked ? "?" : "");
-            IList<Table> tables = new List<Table>();
-            foreach (DataGridViewRow row in this.Tables.SelectedRows)
+            if (Tables.SelectedRows.Count>0)
             {
-                tables.Add((Table)row.DataBoundItem);
+                Generate.Enabled = false;
+                IDictionary<string, object> parameters = new Dictionary<string, object>();
+                parameters.Add("database", ConfigurationManager.ConnectionStrings["connectionString"].ProviderName);
+                parameters.Add("namespace", this.Namespace.Text);
+                parameters.Add("nullableType", this.NullableType.Checked ? "?" : "");
+                IList<Table> tables = new List<Table>();
+                foreach (DataGridViewRow row in this.Tables.SelectedRows)
+                {
+                    tables.Add((Table)row.DataBoundItem);
+                }
+                IGeneratorService generatorService = new GeneratorService();
+                generatorService.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
+                generatorService.TemplatePath = Path.Combine(Application.StartupPath, string.Format(@"Templates\{0}", this.Version.SelectedItem));
+                generatorService.OutputPath = Path.Combine(Application.StartupPath, "Outputs");
+                //生成之前清空outputs文件夹
+                DeleteFolder(generatorService.OutputPath);
+
+                generatorService.Generate(tables, parameters);
+                MessageBox.Show("生成成功");
+                Generate.Enabled = true;
             }
-            IGeneratorService generatorService = new GeneratorService();
-            generatorService.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
-            generatorService.TemplatePath = Path.Combine(Application.StartupPath, string.Format(@"Templates\{0}", this.Version.SelectedItem));
-            generatorService.OutputPath = Path.Combine(Application.StartupPath, "Outputs");
-            //生成之前清空outputs文件夹
-            DeleteFolder(generatorService.OutputPath);
-
-            generatorService.Generate(tables, parameters);
-            MessageBox.Show("生成成功");
+            else
+            {
+                MessageBox.Show("请选择数据表");
+            }
         }
 
         /// <summary>

CodeUnion.CodeGenerator/Main.designer.cs

             this.button1.TabIndex = 1;
             this.button1.Text = "button1";
             this.button1.UseVisualStyleBackColor = true;
+            this.button1.Visible = false;
             this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
             // Container

CodeUnion.CodeGenerator/Templates/3.5/ModelDao.xml.vm

 			(
 #foreach ($column in $columns)
 #each
+#if ($column.Alias == "CreateTime")
+				GetDate()#between
+,
+#else
 				$qualifier$column.Alias$qualifier#between
 ,
 #end
+#end
 
 			)
 		</insert>

CodeUnion.CodeGenerator/Templates/3.5/ModelService.cs.vm

             return result;
 		}
 
-		/// <summary>
-		/// 保存$table.Description
-		/// </summary>
-		/// <param name="$table.CamelAlias">$table.Description</param>
-		/// <returns>结果</returns>
-		public bool Save${table.Alias}($table.Alias $table.CamelAlias)
-		{
-			bool result = false;
-            if (Has${table.Alias}($table.CamelAlias.${key.Alias}))
-            {
-				${table.Alias}QP ${table.CamelAlias}Qp = new ${table.Alias}QP();
-#foreach ($column in $allColumns)
-					${table.CamelAlias}Qp.$column.Alias = $table.CamelAlias.$column.Alias;
-#end
-                result = Update${table.Alias}(${table.CamelAlias}Qp);
-            }
-            else
-            {
-                result = ${table.Alias}Dao.Insert${table.Alias}($table.CamelAlias) > 0;
-            }
-            return result;
-		}
 		#endregion
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.