private void CSEDItem_Click(object CommandBarControl, ref bool Handled, ref bool CancelDefault) { try { SelectFileInfo selectFileInfo = this.GetSelectFileInfo(); if (selectFileInfo == null) { return; } if (!selectFileInfo.IsExistsCodeConfig()) { return; } string itemPathEntityName = selectFileInfo.GetItemPathEntityName(); string text = Path.Combine(selectFileInfo.ProjectPath, "DataEntity"); if (!Directory.Exists(text)) { selectFileInfo.Project.ProjectItems.AddFolder("DataEntity", "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}"); } string path = Path.Combine(text, itemPathEntityName + ".cs"); string path2 = Path.Combine(selectFileInfo.ProjectPath, "DataAccess"); if (!Directory.Exists(path2)) { selectFileInfo.Project.ProjectItems.AddFolder("DataAccess", "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}"); } string path3 = Path.Combine(selectFileInfo.ProjectPath, "DataAccess", "Da" + itemPathEntityName + ".cs"); TableRuleSchema tableRuleSchema = this.CreateItemTableRuleSchema(selectFileInfo); if (tableRuleSchema == null) { Handled = true; return; } string text2 = tableRuleSchema.ToDataEntity(selectFileInfo.ProjectName); DialogResult dialogResult = MessageBox.Show("确定要更新" + tableRuleSchema.EntityName + "实体层吗?此更新不可恢复!", "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { File.WriteAllText(path, text2, Encoding.UTF8); } else { Common.ShowCodeForm(text2); } text2 = tableRuleSchema.ToSqlDaRule(selectFileInfo.ProjectName); dialogResult = MessageBox.Show("确定要更新" + tableRuleSchema.EntityName + "数据访问层吗?此更新不可恢复!", "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { File.WriteAllText(path3, text2, Encoding.UTF8); } else { Common.ShowCodeForm(text2); } } catch (Exception ex) { MessageBox.Show("更新代码出现异常,异常错误:" + ex.ToString()); return; } Handled = true; }
private void CSItem_Click(object CommandBarControl, ref bool Handled, ref bool CancelDefault) { try { SelectFileInfo selectFileInfo = this.GetSelectFileInfo(); if (selectFileInfo == null) { return; } if (!selectFileInfo.IsExistsCodeConfig()) { return; } TableRuleSchema tableRuleSchema = this.CreateItemTableRuleSchema(selectFileInfo); if (tableRuleSchema == null) { Handled = true; return; } string text = ""; if (selectFileInfo.ProjectItemPath.IndexOf("DataEntity") > 0) { text = tableRuleSchema.ToDataEntity(selectFileInfo.ProjectName); } else if (selectFileInfo.ProjectItemPath.IndexOf("DataAccess") > 0) { text = tableRuleSchema.ToSqlDaRule(selectFileInfo.ProjectName); } else if (selectFileInfo.ProjectItemPath.IndexOf("Business") > 0) { text = tableRuleSchema.ToSqlBizRule(selectFileInfo.ProjectName); } DialogResult dialogResult = MessageBox.Show("确定要更新" + selectFileInfo.ItemFileName + "文件吗?此更新不可恢复!", "", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { File.WriteAllText(selectFileInfo.ProjectItemPath, text, Encoding.UTF8); MessageBox.Show("更新成功"); } else { Common.ShowCodeForm(text); } } catch (Exception ex) { MessageBox.Show("更新代码出现异常,异常错误:" + ex.ToString()); return; } Handled = true; }