private void SaveBtn_Click(object sender, EventArgs e) { try { CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1); codeProjectInfo.ID = this.codeProjectInfo.ID; VerifyMessage verifyMessage = VerifyUtil.Verify(codeProjectInfo); if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } R r = codeProjectInfoBLL.SaveOrUpdateBySelf(codeProjectInfo, null, false); if (r.Successful) { MessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); //更新列表页 if (this.Owner is CodeProjectList) { ((CodeProjectList)this.Owner).LoadData(); } } else { MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadData() { try { if (codeProjectInfo.ID > 0) { List <CodeProjectInfo> lists = codeProjectInfoBLL.SelectList(codeProjectInfo, null, "ID", Common.enums.WhereType.Columns); if (lists != null && lists.Count > 0) { codeProjectInfo = lists[0]; } } else { string templatePath = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoTemPath); codeProjectInfo.TEMPLATE_FOLDER = templatePath; //this.TEMPLATE_FOLDER.Text = templatePath; } this.BtnCreate.Visible = codeProjectInfo.ID > 0; FormHelp.SetControlsByEntity(codeProjectInfo, this.panel1); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 验证 /// </summary> /// <param name="codeProjectInfo"></param> /// <returns></returns> private VerifyMessage VeriyData(CodeProjectInfo codeProjectInfo) { VerifyMessage verifyMessage = new VerifyMessage(); verifyMessage.ExistError = false; string pre = "新增"; string whereCon = $" PRO_NAME='{codeProjectInfo.PRO_NAME}'"; if (codeProjectInfo.ID > 0) { whereCon += $" AND ID !='{codeProjectInfo.ID}' "; pre = "修改"; } List <CodeProjectInfo> lists = SelectList(codeProjectInfo, "PRO_NAME", whereCon, WhereType.SQL); if (lists != null && lists.Count > 0) { verifyMessage.ExistError = true; verifyMessage.ErrorInfo = $"{pre}失败,该项目已存在"; } return(verifyMessage); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Copy_Click(object sender, EventArgs e) { try { CodeProjectInfo codeProject = new CodeProjectInfo(); codeProject.AUTHOR = "admin"; codeProject.PRO_NAME = "项目名称" + Guid.NewGuid().ToString("N"); DataGridViewRowCollection rows = listDataGriddView.Rows; List <CodeProjectInfo> listCopys = new List <CodeProjectInfo>(); int count = listDataGriddView.Rows.Count; //Convert.ToInt16(listDataGriddView.Rows.Count.ToString()); for (int i = 0; i < count; i++) { if ((bool)listDataGriddView.Rows[i].Cells[0].EditedFormattedValue == true) { listCopys.Add(listData[i]); } } if (listCopys == null || listCopys.Count <= 0) { MessageHelper.ShowWarn("未选择复制的项目 按随机的信息生成一个不完整的项目"); } else { if (listCopys.Count > 1) { MessageHelper.ShowWarn("请选择一个而不是多个项目进行复制"); return; } else { codeProject = listCopys[0]; codeProject.ID = 0; codeProject.PRO_NAME = "项目名称" + Guid.NewGuid().ToString("N"); } } R r = projectInfoBLL.SaveOrUpdate(codeProject, null, false, null); if (r.Successful) { MessageHelper.ShowSuccess("复制成功"); } else { MessageHelper.ShowSuccess("复制失败," + r.ResultHint); } LoadData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 生成配置文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnCreate_Click(object sender, EventArgs e) { try { CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1); VerifyMessage verifyMessage = VerifyUtil.Verify(codeProjectInfo); if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Type type = codeProjectInfo.GetType(); System.Reflection.PropertyInfo[] propertyInfos = type.GetProperties(); StringBuilder sbf = new StringBuilder(); for (int i = 0; i < propertyInfos.Length; i++) { if (propertyInfos[i].Name != "ID") { if (propertyInfos[i].Name == "JAVAFODER" || propertyInfos[i].Name == "VIEWFOLDER" || propertyInfos[i].Name == "PRO_SITE") { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\","\\\\")}\r\n"); } else if (propertyInfos[i].Name == "TEMPLATE_FOLDER") { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\", "\\\\")+"\\\\"}\r\n"); } else { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo)}\r\n"); } } } string configPath = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoConfigPath); configPath = Path.Combine(configPath, "basic.properties"); File.WriteAllText(configPath, sbf.ToString()); //调用bat命令 string targetDir = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoPath); Process proc = new Process(); proc.StartInfo.WorkingDirectory = targetDir; proc.StartInfo.FileName = "命令.bat"; proc.StartInfo.Arguments = string.Format("30"); //proc.StartInfo.CreateNoWindow = true; //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//这里设置DOS窗口不显示,经实践可行 proc.Start(); proc.WaitForExit(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 获取顶部信息 /// </summary> public CodeProjectInfo GetTopTextBoxInfo() { CodeProjectInfo codeProjectInfo1 = null; try { codeProjectInfo1 = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1); } catch (Exception ex) { MessageHelper.ShowError(ex); } return(codeProjectInfo1); }
/// <summary> /// 数据加载 /// </summary> public void LoadData() { try { CodeProjectInfo info = new CodeProjectInfo(); pageInfo.PageSize = 100; pageInfo.ParamsSearch = info; pageInfo = projectInfoBLL.SelectPage(pageInfo, null, $" PRO_NAME like '%{this.keyWord.Text}%'", WhereType.SQL); listData = pageInfo.Records; this.listDataGriddView.DataSource = listData; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormCreate(CodeProjectInfo codeProjectInfo) { this.codeProjectInfo = codeProjectInfo; InitializeComponent(); }
private void SaveBtn_Click(object sender, EventArgs e) { try { string temSql = $"select * from CODE_PROJECT_TEMPLATE_CONFIG_INFO where PROJECT_ID ='{codeProjectInfo.ID}'"; DataTable dataTable1 = createBLL.SelectData(temSql); List <CodeProjectTemplateConfigInfo> templateConfigInfos = DbConvert.TableToList <CodeProjectTemplateConfigInfo>(dataTable1); if (string.IsNullOrEmpty(this.tableNames.Text)) { MessageHelper.ShowWarn("表名不能为空,至少选择一个表"); return; } if (string.IsNullOrEmpty(this.TOP_LEVEL.Text)) { MessageHelper.ShowWarn("顶级包名不能为空"); return; } if (templateConfigInfos == null || templateConfigInfos.Count <= 0) { MessageHelper.ShowWarn("未检出到任何模板"); return; } string[] tableArr = this.tableNames.Text.Split(','); List <CsProjectCode> projectCodes = new List <CsProjectCode>(); List <TableFieldInfo> lists = null; CsProjectCode csProjectCode = null; CodeProjectInfo codeProjectInfoEdit = null; if (this.TopLevelControl is AutoCodeConfigForm) { codeProjectInfoEdit = ((AutoCodeConfigForm)this.TopLevelControl).GetTopTextBoxInfo(); } string outFileFolder = "", outFilePath, projectCodePath = ""; Dictionary <string, object> dicKv; StringBuilder sbf = new StringBuilder(); string projectSite = null; for (int i = 0; i < tableArr.Length; i++) { csProjectCode = new CsProjectCode(tableArr[i]) { Author = AUTHOR.Text, TopLevel = TOP_LEVEL.Text, Version = codeProjectInfo.VERSION }; lists = dbBLL.SelectTableFields(codeProjectDbConfigInfo, tableArr[i]); csProjectCode.TableFieldInfos = lists; projectCodes.Add(csProjectCode); dicKv = new Dictionary <string, object>(); dicKv.Add("tableName", csProjectCode.TableName);//表名 if (tablesDicts.ContainsKey(csProjectCode.TableName)) { dicKv.Add("tableComment", tablesDicts[csProjectCode.TableName].TableComment); //表备注 } dicKv.Add("entityName", csProjectCode.EntityName); //实体名 dicKv.Add("projectCode", csProjectCode); //项目表信息 if (codeProjectInfoEdit != null) { dicKv.Add("projectName", codeProjectInfoEdit.PRO_NAME);//项目名称 projectSite = codeProjectInfoEdit.PRO_SITE; } for (int k = 0; k < templateConfigInfos.Count; k++) { projectCodePath = projectSite ?? codeProjectInfo.PRO_SITE; //templateConfigInfos[k].TemplatePath.Replace("{tableName}", ""); outFileFolder = templateConfigInfos[k].TemplatePath.Replace("{projectSite}", projectCodePath).Replace("{tableName}", csProjectCode.EntityName); outFilePath = Path.Combine(outFileFolder, $"{csProjectCode.EntityName}{templateConfigInfos[k].OverlayName}{templateConfigInfos[k].Suffix}"); NvelocityUtil.WriteTemplateByString(outFilePath, templateConfigInfos[k].TemplateContent, dicKv); sbf.Append($"表:{csProjectCode.TableName} ,模板【{templateConfigInfos[k].TemplateName}{templateConfigInfos[k].Suffix}】生成成功\n"); } } MessageHelper.ShowSuccess(sbf.ToString()); //MessageHelper.ShowSuccess("生成完毕"); this.codeFolder.Text = projectCodePath; } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormTemList(CodeProjectInfo codeProjectInfo) { this.codeProjectInfo = codeProjectInfo; InitializeComponent(); }
public AutoCodeConfigForm(CodeProjectInfo codeProjectInfo) { this.codeProjectInfo = codeProjectInfo; InitializeComponent(); }
public FormDbConfig(CodeProjectInfo codeProjectInfo) { this.codeProjectInfo = codeProjectInfo; InitializeComponent(); }
//override public R SaveOrUpdateBySelf(CodeProjectInfo codeProjectInfo, string cols, bool needReturn) { return(SaveOrUpdate(codeProjectInfo, cols, needReturn, VeriyData)); }
public FormTemAdd(CodeProjectInfo codeProjectInfo, int ID) { this.codeProjectInfo = codeProjectInfo; codeProjectTemplateConfigInfo.ID = ID; InitializeComponent(); }