//批量代码生成 private void cmnuItemBatchGenerateAll_Click(object sender, EventArgs e) { if (tvPDObjectView.SelectedNode == null || tvPDObjectView.SelectedNode.Tag == null || string.IsNullOrEmpty(tvPDObjectView.SelectedNode.Tag.ToString()) || tvPDObjectView.SelectedNode.Tag.ToString() != this.TAGTABLES) { MessageBox.Show("请选择“数据表”节点进行代码的批量生成!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var setHelper = new SettingHelper(); setHelper.GetSetting(); if (string.IsNullOrEmpty(setHelper.Output)) { MessageBox.Show("请先设置代码的输出路径!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); var projProperty = new ProjectProperty(); projProperty.ShowDialog(); return; } var overwrite = true; var codeOutPutPath = setHelper.Output; // 设置鼠标繁忙状态,并保留原先的状态 var holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; mainfrm.InvokeSendStatusMessage("准备批量生成代码..."); try { foreach (TreeNode node in this.tvPDObjectView.SelectedNode.Nodes) { tvPDObjectView.SelectedNode = node; var className = node.Text.Split(',')[0].Replace("_", string.Empty); var tableName = node.Text.Split(',')[0]; var description = node.Text.Split(',')[1]; mainfrm.InvokeSendStatusMessage("当前处理对象:" + tableName); if ((!string.IsNullOrEmpty(className)) && (!string.IsNullOrEmpty(this.ProductName))) { className = className.Replace(this.ProductName, string.Empty); } var codeMaker = new PDMCodeMaker(this.xmlDocument, this.CompanyName, this.Project, this.Author, DateTime.Now.Year.ToString(), DateTime.Now.ToString("yyyy-MM-dd"), className, "Manager", tableName, description); overwrite = codeMaker.BuilderTable(codeOutPutPath, overwrite); overwrite = codeMaker.BuilderEntity(codeOutPutPath, overwrite); overwrite = codeMaker.BuilderManager(codeOutPutPath, overwrite); var fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\IService\\" + "I" + className + "Service.cs"; this.GengerateIService(fileName); fileName = codeOutPutPath + "\\" + this.Project + ".BizLogic\\Service\\" + className + "Service.cs"; this.GenerateService(fileName); } } catch (Exception ex) { LogHelper.WriteException(ex); } finally { // 设置鼠标默认状态,原来的光标状态 this.Cursor = holdCursor; mainfrm.InvokeSendStatusMessage("就绪。"); // 打开文件夹 Process.Start(codeOutPutPath); } }
private void miFile_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { #region 快捷菜单-文件 try { switch (e.ClickedItem.Name) { case "miOpenFile": //打开 { TextEditorControl editor = textEditorContent; if (editor != null) { using (OpenFileDialog dialog = new OpenFileDialog()) { dialog.Filter = SharpPadFileFilter; dialog.FilterIndex = 0; if (DialogResult.OK == dialog.ShowDialog()) { editor.LoadFile(dialog.FileName); CheckCurrentViewMode(editor.Document.HighlightingStrategy.Name); if (System.IO.Path.GetExtension(dialog.FileName).ToLower() == ".xml") { if (!(textEditorContent.Document.FoldingManager.FoldingStrategy is XmlFoldingStrategy)) { textEditorContent.Document.FoldingManager.FoldingStrategy = new XmlFoldingStrategy(); } UpdateFolding(); } } } } } break; case "miSave": //保存 { TextEditorControl editor = textEditorContent; if (editor != null) { SaveAs(); } } break; case "miSaveAs": //另存为 SaveAs(); break; } } catch (System.AccessViolationException accEx) { LogHelper.WriteException(accEx); } catch (System.StackOverflowException flowEx) { LogHelper.WriteException(flowEx); } catch (Exception ex) { LogHelper.WriteException(ex); } #endregion }