private void SaveFunctionText() { if (string.IsNullOrEmpty(this.textBox3.Text.Trim())) { MsgBox.Warning("函数描述不可为空....."); return; } if (string.IsNullOrEmpty(this.textBox4.Text.Trim())) { MsgBox.Warning("请选择需新增节点的父亲节点...."); return; } if (string.IsNullOrEmpty(this.textBox5.Text.Trim())) { MsgBox.Warning("请选择需新增节点的父亲节点...."); return; } FunctionRepository _FunctionRepository = new FunctionRepository(); _FunctionRepository.Fun_CLSF = this.textBox2.Text.Trim(); _FunctionRepository.Fun_Id = StringUnitity.GetNewGUID(); _FunctionRepository.Fun_Name = this.textBox1.Text.Trim(); _FunctionRepository.Fun_ParantId = this.textBox4.Text.Trim(); _FunctionRepository.Func_Descpt = this.textBox3.Text.Trim(); FunctionContext _FunctionContext = new FunctionContext(); _FunctionContext.Fun_Id = _FunctionRepository.Fun_Id; _FunctionContext.Fun_Context = this.fastColoredTextBox1.Text; try { _CoreFunctionRepository.AddEntity(_FunctionRepository); if (!string.IsNullOrEmpty(_FunctionContext.Fun_Context)) { _CoreFunctionContext.AddEntity(_FunctionContext); } _LoadTree.CreateFunTree(this.advTree1); this.textBox1.Text = string.Empty; this.textBox2.Text = string.Empty; this.textBox3.Text = string.Empty; this.textBox4.Text = string.Empty; this.textBox5.Text = string.Empty; this.fastColoredTextBox1.Text = string.Empty; MsgBox.Infor("添加函数成功...."); } catch (Exception ex) { _CoreFunctionRepository.DeleteEntity(_FunctionRepository); _CoreFunctionContext.DeleteEntity(_FunctionContext); MsgBox.Warning("添加函数失败:" + ex.Message); } }
private string CreareRazorString(string CTemplet_Context, string _ClassName, string _NameSpace, string _SqlName, List <ColumnInfo> _ColumnInfoList) {//"templateKey" string _GenerdString = Engine.Razor.RunCompile(CTemplet_Context, StringUnitity.GetNewGUID(), null, new { ClassName = _ClassName, //类名 TableName = _ClassName, //表名 Columns = _ColumnInfoList, //表的列信息 NameSpace = _NameSpace, //命名空间 SqlName = _SqlName //数据库类型 }); return(_GenerdString); }
private void simpleButton1_Click(object sender, EventArgs e) { if (_SelectNode == null) { return; } if (CheckProgExist()) { MsgBox.Warning("程序已经存在,请勿重复添加!!!"); return; } if (string.IsNullOrEmpty(this.textBox4.Text.Trim())) { MsgBox.Warning("程序描述不能为空!!!"); return; } ProgList _ProgList = new ProgList(); _ProgList.Prog_Id = StringUnitity.GetNewGUID(); _ProgList.Prog_Assmbly = this.textBox1.Text.Trim(); _ProgList.Prog_CLS = this.textBox3.Text.Trim(); _ProgList.Prog_Descp = this.textBox4.Text.Trim(); _ProgList.Prog_NameSp = this.textBox2.Text.Trim(); _ProgList.Prog_ParantId = _SelectNode.Prog_Id; if (this.checkEdit1.Checked) { _ProgList.Prog_Status = 1; } else { _ProgList.Prog_Status = 9; } _ProgList.Prog_Type = "Application"; try { _CoreProgList.AddEntity(_ProgList); MsgBox.Infor("程序新增完成"); _LoadTree.CreateTree(this.advTree1); } catch (Exception ex) { MsgBox.Warning("程序新增失败:" + ex.Message); } }
private void simpleButton1_Click(object sender, EventArgs e) { CodeTemplet _CodeTemplet = new CodeTemplet(); _CodeTemplet.CTemplet_Id = StringUnitity.GetNewGUID(); _CodeTemplet.CTemplet_Name = this.textBox1.Text.Trim(); _CodeTemplet.CTemplet_Context = this.fastColoredTextBox1.Text; _CodeTemplet.CTemplet_CPrefix = this.textBox3.Text.Trim(); _CodeTemplet.CTemplet_DbType = this.comboBox1.Text; _CodeTemplet.CTemplet_NameSP = this.textBox2.Text.Trim(); try { _CoreCodeTemplet.AddEntity(_CodeTemplet); LoadListBox(); ClearContol(); } catch (Exception ex) { MsgBox.Warning("新增失败,原因:" + ex.Message); } }
private void simpleButton1_Click(object sender, EventArgs e) { _CodeClassPref = string.Empty; _CodeClassName = string.Empty; DevExpress.XtraTreeList.Nodes.TreeListNode __TempNode = _CurrentSelectNode; if (this.comboBox1.SelectedIndex == 0) { MsgBox.Warning("请您先选中生成代码的模板......"); return; } //生成代码 if (string.IsNullOrEmpty(this.textBox2.Text.Trim())) { MsgBox.Warning("请您先选中表或者视图......"); return; } //1.0 获取选中的模板文件的内容 CodeTemplet __CodeTemplet = this.comboBox1.SelectedItem as CodeTemplet; if (null == __CodeTemplet) { MsgBox.Warning("您选中的模板有问题,请前去确认......."); return; } string compText = __CodeTemplet.CTemplet_Context; //数据库节点 DevExpress.XtraTreeList.Nodes.TreeListNode _rootNode = __TempNode.ParentNode.ParentNode; if (_rootNode == null) { MsgBox.Warning("您选中的表或者视图节点数据存在问题,请前去确认......."); return; } DbLoginFor __DbLoginFor = _rootNode.Tag as DbLoginFor; IFrameWorkDb _IFrameWorkDb = null; _IFrameWorkDb = FrameWorkDbFactory.CreateNewFrameWorkDb(__DbLoginFor.ConnString, __DbLoginFor.Db_Type); if (_IFrameWorkDb == null) { MsgBox.Warning("您选中的表或者视图节点数据类型存在问题,请前去确认......."); return; } string _ClassName = this.textBox2.Text.Trim(); string _TableName = this.textBox2.Text.Trim(); string _NameSpace = this.textBox1.Text.Trim(); string _SqlName = __CodeTemplet.CTemplet_DbType; _CodeClassPref = this.textBox3.Text.Trim(); _CodeClassName = this.textBox2.Text.Trim(); Task.Factory.StartNew(new Action(() => { string _tvstring = __TempNode.ParentNode.Tag as string; List <ColumnInfo> _ColumnInfoList = null; if (_tvstring.Trim() == "表") { _ColumnInfoList = _IFrameWorkDb.GetColumsFromTable(_TableName); } else if (_tvstring.Trim() == "视图") { _ColumnInfoList = _IFrameWorkDb.GetColumsFromView(_TableName); } foreach (var item in _ColumnInfoList) { if (CSDBDic.ContainsKey(item.TypeName.Trim().ToUpper())) { item.TypeName = CSDBDic[item.TypeName.ToUpper()]; } } //templateKey string _GenerdString = Engine.Razor.RunCompile(__CodeTemplet.CTemplet_Context, StringUnitity.GetNewGUID(), null, new { ClassName = _ClassName, //类名 TableName = _TableName, //表名 Columns = _ColumnInfoList, //表的列信息 NameSpace = _NameSpace, //命名空间 SqlName = _SqlName //数据库类型 }); this.Invoke(new MethodInvoker(() => { this.fastColoredTextBox1.Text = _GenerdString; })); })); }