コード例 #1
0
        private bool GenerateClassFile(TableModel table)
        {
            if (table == null) return false;
            if (table.TableName == "__MigrationHistory") return false;
            var item = _directory.ProjectItems.FindByName(table.TableName);
            if (item != null) return false;
            if (string.IsNullOrWhiteSpace(table.TablePK))
            {
                AddError(string.Format("{0} 表中没有自增、命名以 ID 结尾的Guid列。", table.TableName));
                return false;
            }
            if (table.Columns == null || table.Columns.Count == 0)
            {
                AddError(string.Format("{0} 表中没有列。", table.TableName));
                return false;
            }

            BuildEntity(table);
            BuildRepository(table);
            if (IsMVC)
            {
                BuildValidationModel(table);
                BuildViewModels(table);
                BuildControllers(table);
            }

            return true;
        }
コード例 #2
0
ファイル: EasyUIBuild.cs プロジェクト: iraychen/LCLFramework
        private string GenerateEasyUITreeTable(TableModel tm)
        {
            var list = tm.Columns;
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("<div class=\"easyui-layout\" fit=\"true\" id=\"tb\"> ");
            builder.AppendLine("    <div data-options=\"region:'west',title:'" + tm.TableNameRemark + "'\" style=\"width: 200px;\"> ");
            builder.AppendLine("        <ul id=\"uitree_" + tm.TableName.ToLower() + "\" class=\"easyui-tree\"></ul> ");
            builder.AppendLine("    </div> ");
            builder.AppendLine("    <div data-options=\"region:'center',title:'" + tm.TableNameRemark + "'\" style=\"padding: 5px; overflow-y: hidden;\"> ");
            builder.AppendLine("        <div style=\"background: #efefef; width: 100%; border-bottom: #99bbe8 1px solid;\"> ");
            builder.AppendLine("            <a id=\"btnAdd" + tm.TableName.ToLower() + "\" href=\"javascript:;\" plain=\"true\" class=\"easyui-linkbutton\" icon=\"icon-add\">新增下级</a>&nbsp; ");
            builder.AppendLine("            <a id=\"btnDel" + tm.TableName.ToLower() + "\" href=\"javascript:;\" plain=\"true\" class=\"easyui-linkbutton\" icon=\"icon-remove\">删除</a>&nbsp; ");
            builder.AppendLine("            <a id=\"butSave" + tm.TableName.ToLower() + "\" href=\"javascript:;\" plain=\"true\" class=\"easyui-linkbutton\" icon=\"icon-save\">保存</a>&nbsp; ");
            builder.AppendLine("        </div> ");
            builder.Append(GenerateEasyUIFrom(tm));
            builder.AppendLine("    </div> ");
            builder.AppendLine("</div> ");
            builder.AppendLine("@section scripts{ ");
            builder.AppendLine("    <script> ");
            builder.AppendLine(GenerateEasyUITreeTableJs(tm));
            builder.AppendLine("    </script> ");
            builder.AppendLine("} ");

            return builder.ToString();
        }
コード例 #3
0
ファイル: BuildBase.cs プロジェクト: jack-tmac/LCLFramework
        // Entity or WCF
        public virtual string BuildEntity(string path, TableModel tableModel, System.Windows.Forms.ProgressBar progressBar)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.ComponentModel; ");
            builder.AppendLine("using MinGuiLuo.ORM; ");
            builder.AppendLine("using System.Runtime.Serialization;");
            builder.AppendLine("namespace " + Utils.NameSpace);
            builder.AppendLine("{ ");
            builder.AppendLine("    /// <summary> ");
            builder.AppendLine("    /// 实体类" + tableModel.TableNameRemark + " 。(属性说明自动提取数据库字段的描述信息) ");
            builder.AppendLine("    /// </summary> ");
            builder.AppendLine("    [Serializable]");
            builder.AppendLine("    public partial class " + tableModel.TableName + ":AggregateRoot");
            builder.AppendLine("    { ");
            int num = 0;
            if (progressBar != null)
                progressBar.Maximum = tableModel.Columns.Count;
            foreach (TableColumn column in tableModel.Columns)
            {
                num++;
                if (progressBar != null)
                    progressBar.Value = num;
                builder.AppendLine("        public " + column.ColumnType + " " + column.ColumnName + " { get; set; } ");
            }
            builder.AppendLine("        public static string ConnectionString = \"" + Utils.dbName + "\"; ");
            builder.AppendLine("        protected override string ConnectionStringSettingName{ get { return ConnectionString; }} ");

            builder.AppendLine("    } ");
            builder.AppendLine("} ");
            if (path != null && path.Length > 0)
            {
                string folder = path + @"\Entities";
                Utils.FolderCheck(folder);
                string filename = folder + @"\" + tableModel.TableName + ".cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
            return builder.ToString();
        }
コード例 #4
0
        private void BuildValidationModel(TableModel table)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.ComponentModel.DataAnnotations; ");
            builder.AppendLine("using System.Linq; ");
            builder.AppendLine("using System.Text; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace " + this.DomainName + " ");
            builder.AppendLine("{ ");
            builder.AppendLine("    [Serializable] ");
            builder.AppendLine("    [MetadataType(typeof(" + table.TableName + "MD))]  ");
            builder.AppendLine("    public partial class " + table.TableName + "  ");
            builder.AppendLine("    {  ");
            builder.AppendLine("        public class " + table.TableName + "MD  ");
            builder.AppendLine("        {  ");
            foreach (var item in table.Columns)
            {
                if (item.ColumnName != "ID"
                    && item.ColumnName != "AddDate"
                    && item.ColumnName != "UpdateDate"
                    && item.ColumnName != "IsDelete"
                    && !item.ColumnName.Contains("_"))
                {
                    builder.AppendLine("            [Display(Name = \"" + item.ColumnRemark + "\")]  ");
                    builder.AppendLine("            public " + item.ColumnType + " " + item.ColumnName + " { get; set; }  ");
                }
            }
            builder.AppendLine("        }  ");
            builder.AppendLine("    }  ");
            builder.AppendLine(" ");
            builder.AppendLine("} ");

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(ValidationModel.get_FileNames(1)), table.TableName) + ".cs";
            if (!File.Exists(file))
            {
                File.WriteAllText(file, builder.ToString());
                ValidationModel.ProjectItems.AddFromFile(file);
            }
        }
コード例 #5
0
        private void BuildRepository(TableModel table)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("/*******************************************************   ");
            builder.AppendLine("*    ");
            builder.AppendLine("* 作者:罗敏贵   ");
            builder.AppendLine("* 说明:   ");
            builder.AppendLine("* 运行环境:.NET 4.5.0   ");
            builder.AppendLine("* 版本号:1.0.0   ");
            builder.AppendLine("*    ");
            builder.AppendLine("* 历史记录:   ");
            builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now + "  ");
            builder.AppendLine("*    ");
            builder.AppendLine("*******************************************************/   ");
            builder.AppendLine("using LCL;   ");
            builder.AppendLine("using LCL.Repositories;   ");
            builder.AppendLine("using LCL.Repositories.EntityFramework; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace " + this.DomainName + " ");
            builder.AppendLine("{   ");
            builder.AppendLine("    public interface I" + table.TableName + "Repository : IRepository<" + table.TableName + ">   ");
            builder.AppendLine("    {   ");
            builder.AppendLine("   ");
            builder.AppendLine("    }   ");
            builder.AppendLine("    public class " + table.TableName + "Repository : EntityFrameworkRepository<" + table.TableName + ">, I" + table.TableName + "Repository   ");
            builder.AppendLine("    {   ");
            builder.AppendLine("        public " + table.TableName + "Repository(IRepositoryContext context) : base(context) ");
            builder.AppendLine("        {    ");
            builder.AppendLine("           ");
            builder.AppendLine("        }   ");
            builder.AppendLine("    }   ");
            builder.AppendLine("}   ");

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(RepoDirectory.get_FileNames(1)), table.TableName) + ".cs";
            if (!File.Exists(file))
            {
                File.WriteAllText(file, builder.ToString());
                RepoDirectory.ProjectItems.AddFromFile(file);
            }
        }
コード例 #6
0
        private void BuildRepository(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("/*******************************************************  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 作者:罗敏贵  ");
                builder.AppendLine("* 说明: " + tableInfo + " ");
                builder.AppendLine("* 运行环境:.NET 4.5.0  ");
                builder.AppendLine("* 版本号:1.0.0  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 历史记录:  ");
                builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now.ToLongDateString() + " ");
                builder.AppendLine("*   ");
                builder.AppendLine("*******************************************************/  ");
                builder.AppendLine("using LCL.Repositories;  ");
                builder.AppendLine("using LCL.Repositories.EntityFramework;  ");
                builder.AppendLine("using System;  ");
                builder.AppendLine("using System.Collections.Generic;  ");
                builder.AppendLine("using System.Linq;  ");
                builder.AppendLine("using System.Text;  ");
                builder.AppendLine("using System.Threading.Tasks;  ");
                builder.AppendLine("  ");
                builder.AppendLine("namespace " + Utils.NameSpace + "  ");
                builder.AppendLine("{  ");
                builder.AppendLine("    /// <summary> ");
                builder.AppendLine("    /// " + tableInfo + " ");
                builder.AppendLine("    /// </summary> ");
                builder.AppendLine("    public interface I" + tablename + "Repository : IRepository<" + tablename + ">  ");
                builder.AppendLine("    {  ");
                if (tm.IsTree)
                {
                    builder.AppendLine("    string GetByName(Guid guid);");
                }
                builder.AppendLine("    }  ");
                builder.AppendLine("    /// <summary> ");
                builder.AppendLine("    /// " + tableInfo + " ");
                builder.AppendLine("    /// </summary> ");
                builder.AppendLine("    public class " + tablename + "Repository : EntityFrameworkRepository<" + tablename + ">, I" + tablename + "Repository  ");
                builder.AppendLine("    {  ");
                builder.AppendLine("        public " + tablename + "Repository(IRepositoryContext context)  ");
                builder.AppendLine("            : base(context)  ");
                builder.AppendLine("        {   ");
                builder.AppendLine("          ");
                builder.AppendLine("        }  ");
                if (tm.IsTree)
                {
                    builder.AppendLine("        public string GetByName(Guid guid) ");
                    builder.AppendLine("        { ");
                    builder.AppendLine("            try ");
                    builder.AppendLine("            { ");
                    builder.AppendLine("                var model = this.GetByKey(guid); ");
                    builder.AppendLine("                return model.Name; ");
                    builder.AppendLine("            } ");
                    builder.AppendLine("            catch (Exception) ");
                    builder.AppendLine("            { ");
                    builder.AppendLine("                return \"保密\"; ");
                    builder.AppendLine("            } ");
                    builder.AppendLine("        } ");
                }
                builder.AppendLine("    }  ");
                builder.AppendLine("}  ");

                if (path.Length > 0)
                {
                    string folder = path + @"\LCL\Library\Repository\";
                    Utils.FolderCheck(folder);
                    string filename = folder + @"\" + tablename + "Repository.cs";
                    Utils.CreateFiles(filename, builder.ToString());
                }
            }
        }
コード例 #7
0
        public string Library(string path, TableModel tableModel, System.Windows.Forms.ProgressBar progressBar)
        {
            //Entity
            BuildEntity(path, tableModel, progressBar);
            //Repository
            new RepositoryBuild().BuildRepository(path);
            //ValidationModel
            new ValidationModelBuild().GenerateValidationModel(path);
            //ViewModels
            new MVCViewModelBuild().GenerateEntityViewsModeel(path);
            //EFContexts
            List<TableModel> tablenames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);
            this.BuildDbContext(path, tablenames);
            //BundleActivator
            new ServiceLocatorBuild().BuildServiceLocator(path);
            //MVC UI
            new MVCUIBuild().GenerateBootstrapAdminViews(path);

            return "";
        }
コード例 #8
0
        //TODO:必填项,重复项
        private void WinFrmEditPage(string path, TableModel tableModel, List<TableColumn> ShowFields, List<TableColumn> CheckFields, List<TableColumn> CheckFepeat)
        {
            //Edit页面
            #region {tablename}FrmEdit.cs
            string className = tableModel.TableName;
            string tableinfo = tableModel.TableNameRemark;
            StringBuilder newControl = new StringBuilder();
            StringBuilder newControl1 = new StringBuilder();
            StringBuilder newControl2 = new StringBuilder();
            StringBuilder tableLayoutPanel1 = new StringBuilder();
            StringBuilder RowStyles = new StringBuilder();
            StringBuilder CheckInput = new StringBuilder();
            StringBuilder SetInfo = new StringBuilder();
            StringBuilder DisplayData = new StringBuilder();
            int num = 0;
            foreach (TableColumn item in ShowFields)
            {
                num++;
                string proStr = item.ColumnType;
                string property = item.ColumnName;
                string propertyinfo = item.ColumnRemark;
                if (propertyinfo.Length == 0) propertyinfo = property;

                if (property.ToLower().Equals("adddate") || property.ToLower().Equals("isdeleted")) continue;

                #region {tablename}FrmEdit.Designer.cs
                //创建控件
                newControl2.AppendLine("            private System.Windows.Forms.Label lbl" + property + "; ");
                newControl2.AppendLine("            private System.Windows.Forms.TextBox txt" + property + "; ");
                newControl.AppendLine("             this.lbl" + property + " = new System.Windows.Forms.Label(); ");
                newControl.AppendLine("             this.txt" + property + " = new System.Windows.Forms.TextBox(); ");
                //初始化控件
                newControl1.AppendLine("            //  ");
                newControl1.AppendLine("            // lbl" + property + "");
                newControl1.AppendLine("            //  ");
                newControl1.AppendLine("            this.lbl" + property + ".Dock = System.Windows.Forms.DockStyle.Fill; ");
                newControl1.AppendLine("            this.lbl" + property + ".Name = \"lbl" + property + "\"; ");
                newControl1.AppendLine("            this.lbl" + property + ".Text =  \"" + propertyinfo + "\"; ");
                newControl1.AppendLine("            this.lbl" + property + ".TabIndex = " + num + "; ");
                newControl1.AppendLine("            this.lbl" + property + ".TextAlign = System.Drawing.ContentAlignment.MiddleLeft; ");
                newControl1.AppendLine("            //  ");
                newControl1.AppendLine("            // txt" + property + "");
                newControl1.AppendLine("            //  ");
                newControl1.AppendLine("            this.txt" + property + ".Dock = System.Windows.Forms.DockStyle.Fill; ");
                newControl1.AppendLine("            this.txt" + property + ".Name = \"txt" + property + "\"; ");
                newControl1.AppendLine("            this.txt" + property + ".TabIndex = " + num + "; ");
                newControl1.AppendLine("            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F));");
                //表格控件初始化
                tableLayoutPanel1.AppendLine("     this.tableLayoutPanel1.Controls.Add(this.lbl" + property + "); ");
                tableLayoutPanel1.AppendLine("     this.tableLayoutPanel1.Controls.Add(this.txt" + property + "); ");
                #endregion

                #region {tablename}FrmEdit.cs

                CheckInput.AppendLine("            if (this.txt" + property + ".Text.Trim().Length == 0) ");
                CheckInput.AppendLine("            { ");
                CheckInput.AppendLine("                msgList.AppendLine(\"" + propertyinfo + "不能为空。\"); ");
                CheckInput.AppendLine("                this.txt" + property + ".Focus(); ");
                CheckInput.AppendLine("                result = false; ");
                CheckInput.AppendLine("            } ");

                if (item.ColumnName.ToLower().Equals("id") || item.ColumnName.ToLower().Equals("isdeleted") || item.ColumnName.ToLower().Equals("adddate"))
                {
                    DisplayData.AppendLine("         txt" + property + ".Enabled = false; txt" + property + ".BackColor = System.Drawing.SystemColors.Menu;");
                    DisplayData.AppendLine("         txt" + property + ".Text = TypeConversion.GetObjTranNull<String>(info." + property + "); ");
                }
                else
                {
                    DisplayData.AppendLine("         txt" + property + ".Text = TypeConversion.GetObjTranNull<String>(info." + property + "); ");
                }

                SetInfo.AppendLine("             info." + property + " =TypeConversion.GetObjTranNull<" + proStr + ">(txt" + property + ".Text); ");
                #endregion
            }

            StringBuilder builder = new StringBuilder();
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.Text; ");
            builder.AppendLine("using System.Data; ");
            builder.AppendLine("using System.Drawing; ");
            builder.AppendLine("using System.Windows.Forms; ");
            builder.AppendLine("using System.ComponentModel; ");
            builder.AppendLine("using System.Collections.Generic; ");
            builder.AppendLine("using MinGuiLuo;");
            builder.AppendLine("using MinGuiLuo.ORM; ");
            builder.AppendLine("using MinGuiLuo.Logging;");
            builder.AppendLine("using MinGuiLuo.Module.WinFrom.Forms; ");
            builder.AppendLine("namespace " + Utils.NameSpaceUI);
            builder.AppendLine("{ ");
            builder.AppendLine("    public partial class " + className + "FrmEdit : BaseEditForm ");
            builder.AppendLine("    { ");
            builder.AppendLine("        public " + className + "FrmEdit() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            InitializeComponent(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("                 ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 实现控件输入检查的函数 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        /// <returns></returns> ");
            builder.AppendLine("        public override bool CheckInput() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            bool result = true;//默认是可以通过 ");
            builder.AppendLine("            #region MyRegion ");
            builder.AppendLine("            System.Text.StringBuilder msgList = new System.Text.StringBuilder(); ");
            builder.AppendLine(CheckInput.ToString());
            builder.AppendLine("            if (!result && msgList.Length > 2) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                MessageBoxForm.ShowMessage(msgList.ToString()); ");
            builder.AppendLine("            } ");
            builder.AppendLine("            #endregion ");
            builder.AppendLine("            return result; ");
            builder.AppendLine("        } ");
            builder.AppendLine(" ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 数据显示的函数 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        public override void DisplayData() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            if (ID>0) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                #region 显示客户信息 ");
            builder.AppendLine("                " + className + " info =BLLFactory<" + className + ">.Instance().FindByID(ID); ");
            builder.AppendLine("                if (info != null) ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    " + DisplayData.ToString());
            builder.AppendLine("                }  ");
            builder.AppendLine("                #endregion ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine(" ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 编辑或者保存状态下取值函数 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        /// <param name=\"info\"></param> ");
            builder.AppendLine("        private void SetInfo(" + className + " info) ");
            builder.AppendLine("        { ");
            builder.AppendLine("         " + SetInfo.ToString());
            builder.AppendLine("         } ");
            builder.AppendLine("          ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 新增状态下的数据保存 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        /// <returns></returns> ");
            builder.AppendLine("        public override bool SaveAddNew() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            " + className + " info = new " + className + "(); ");
            builder.AppendLine("            SetInfo(info); ");
            builder.AppendLine(" ");
            builder.AppendLine("            try ");
            builder.AppendLine("            { ");
            builder.AppendLine("                #region 新增数据 ");
            builder.AppendLine("                bool succeed = BLLFactory<" + className + ">.Instance().AddEntity(info);");
            builder.AppendLine("                if (succeed) ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    //可添加其他关联操作 ");
            builder.AppendLine("                    return true; ");
            builder.AppendLine("                } ");
            builder.AppendLine("                #endregion ");
            builder.AppendLine("            } ");
            builder.AppendLine("            catch (Exception ex) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                LogUtil.LogError(ex);  ");
            builder.AppendLine("            } ");
            builder.AppendLine("            return false; ");
            builder.AppendLine("        }                  ");
            builder.AppendLine(" ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 编辑状态下的数据保存 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        /// <returns></returns> ");
            builder.AppendLine("        public override bool SaveUpdated() ");
            builder.AppendLine("        { ");
            builder.AppendLine("			//检查不同ID是否还有其他相同关键字的记录 ");
            builder.AppendLine("            " + className + " info =BLLFactory<" + className + ">.Instance().FindByID(ID);");
            builder.AppendLine("            if (info != null) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                SetInfo(info); ");
            builder.AppendLine("                try ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    #region 更新数据 ");
            builder.AppendLine("                    bool succeed = BLLFactory<" + className + ">.Instance().UpdateEntity(info);");
            builder.AppendLine("                    if (succeed)");
            builder.AppendLine("                    { ");
            builder.AppendLine("                        //可添加其他关联操作 ");
            builder.AppendLine("                        return true; ");
            builder.AppendLine("                    } ");
            builder.AppendLine("                    #endregion ");
            builder.AppendLine("                } ");
            builder.AppendLine("                catch (Exception ex) ");
            builder.AppendLine("                { ");
            builder.AppendLine("                   LogUtil.LogError(ex);  ");
            builder.AppendLine("                } ");
            builder.AppendLine("            } ");
            builder.AppendLine("           return false; ");
            builder.AppendLine("        } ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");
            if (path.Length > 0)
            {
                string folder = path + @"\WinFromBuild\" + Utils.NameSpace;
                Utils.FolderCheck(folder);
                string filename = folder + @"\" + className + "FrmEdit.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
            #endregion

            #region {tablename}FrmEdit.Designer.cs
            int ShowFieldsCount = ShowFields.Count;
            int rowsstyles = ShowFieldsCount / 2;
            if (rowsstyles == 1) rowsstyles = 2;
            builder = new StringBuilder();
            builder.AppendLine("namespace " + Utils.NameSpaceUI);
            builder.AppendLine("{ ");
            builder.AppendLine("    partial class " + className + "FrmEdit");
            builder.AppendLine("    { ");
            builder.AppendLine("        private System.ComponentModel.IContainer components = null; ");
            builder.AppendLine("        protected override void Dispose(bool disposing) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            if (disposing && (components != null)) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                components.Dispose(); ");
            builder.AppendLine("            } ");
            builder.AppendLine("            base.Dispose(disposing); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        #region Windows Form Designer generated code ");
            builder.AppendLine("        private void InitializeComponent() ");
            builder.AppendLine("        { ");
            builder.AppendLine("             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); ");
            builder.AppendLine(newControl.ToString());
            builder.AppendLine("            this.tableLayoutPanel1.SuspendLayout(); ");
            builder.AppendLine("            this.SuspendLayout(); ");
            builder.AppendLine("            // tableLayoutPanel1 ");
            builder.AppendLine("            //  ");
            builder.AppendLine("            this.tableLayoutPanel1.AutoScroll = true; ");
            builder.AppendLine("			this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; ");
            builder.AppendLine("            this.tableLayoutPanel1.ColumnCount = 2; ");
            builder.AppendLine("            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F)); ");
            builder.AppendLine("            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 80F)); ");
            builder.AppendLine(tableLayoutPanel1.ToString());
            builder.AppendLine("            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;");
            builder.AppendLine("            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); ");
            builder.AppendLine("            this.tableLayoutPanel1.Name = \"tableLayoutPanel1\"; ");
            builder.AppendLine("            this.tableLayoutPanel1.RowCount = " + (ShowFieldsCount + 1) + "; ");
            for (int i = 0; i < ShowFields.Count; i++)
            {
                builder.AppendLine("        this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); ");
            }
            int tlpHeight = ShowFieldsCount * 21 + 21;
            int frmHeight = tlpHeight + 26 + 26 + 26 + 30;
            builder.AppendLine("            this.tableLayoutPanel1.Size = new System.Drawing.Size(419, " + tlpHeight + "); ");
            builder.AppendLine("            this.tableLayoutPanel1.TabIndex = 6; ");
            builder.AppendLine(newControl1.ToString());
            builder.AppendLine("            //  ");
            builder.AppendLine("            // " + className + "FrmEdit ");
            builder.AppendLine("            //  ");
            builder.AppendLine("            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); ");
            builder.AppendLine("            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ");
            builder.AppendLine("            this.ClientSize = new System.Drawing.Size(479, " + frmHeight + "); ");
            builder.AppendLine("            this.Controls.Add(this.tableLayoutPanel1); ");
            builder.AppendLine("            this.Name = \"" + className + "FrmEdit\"; ");
            builder.AppendLine("            this.Text = \"" + className + "\"; ");
            builder.AppendLine("            this.Controls.SetChildIndex(this.tableLayoutPanel1, 0); ");
            builder.AppendLine("            this.tableLayoutPanel1.ResumeLayout(false); ");
            builder.AppendLine("            this.tableLayoutPanel1.PerformLayout(); ");
            builder.AppendLine("            this.ResumeLayout(false); ");
            builder.AppendLine("            this.PerformLayout(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        #endregion             ");
            builder.AppendLine("        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;             ");
            builder.AppendLine(newControl2.ToString());
            builder.AppendLine("    } ");
            builder.AppendLine("}             ");
            if (path.Length > 0)
            {
                string folder = path + @"\WinFromBuild\" + Utils.NameSpace;
                Utils.FolderCheck(folder);
                string filename = folder + @"\" + className + "FrmEdit.Designer.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
            #endregion
        }
コード例 #9
0
        public string Library(string path, TableModel tableModel, System.Windows.Forms.ProgressBar progressBar)
        {
            //Entity
            BuildEntity(path, tableModel, progressBar);
            //列表页面
            WinFrmListPage(path, tableModel, tableModel.Columns, tableModel.Columns, null);
            //Edit页面
            WinFrmEditPage(path, tableModel, tableModel.Columns, tableModel.Columns, tableModel.Columns);

            return "";
        }
コード例 #10
0
ファイル: EasyUIBuild.cs プロジェクト: iraychen/LCLFramework
        private string GenerateEasyUITreeTableJs(TableModel tm)
        {
            var list = tm.Columns;
            StringBuilder builder = new StringBuilder();
            StringBuilder builder1 = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            StringBuilder builder3 = new StringBuilder();
            StringBuilder builder4 = new StringBuilder();
            foreach (var item in list)
            {
                builder1.AppendLine(" $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(node." + item.ColumnName + "); ");
                builder2.AppendLine(" $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(''); ");
                builder3.AppendLine("var " + item.ColumnName + "= $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(); ");
                builder4.Append("" + item.ColumnName + ": " + item.ColumnName + ",");
            }
            if (builder4.Length > 1)
                builder4.Remove(builder4.Length - 1, 1);

            builder.AppendLine("        var root = \"@(Url.BundlePContent(\"UIShell.RbacManagementPlugin\", \"" + tm.TableName + "\"))/\"; ");
            builder.AppendLine("        var added = true; ");
            builder.AppendLine("        var dicType; ");
            builder.AppendLine("        var LCL_" + tm.TableName.ToLower() + " = { ");
            builder.AppendLine("            showTree: function () { ");
            builder.AppendLine("                $('#uitree_" + tm.TableName.ToLower() + "').tree({ ");
            builder.AppendLine("                    url: root + 'AjaxEasyUITree_" + tm.TableName + "', ");
            builder.AppendLine("                    lines: true, ");
            builder.AppendLine("                    onClick: function (node) { ");
            builder.AppendLine("                        added = false; ");
            builder.AppendLine("                        var cc = node.id; ");
            builder.AppendLine("                        dicType = cc; ");
            builder.AppendLine("                        $('#parentid').val(node.parentId); ");
            builder.AppendLine("                        $('#parentname').val(node.parentName); ");
            builder.AppendLine(" ");
            builder.AppendLine(builder1.ToString());
            builder.AppendLine(" ");
            builder.AppendLine(" ");
            builder.AppendLine("                    } ");
            builder.AppendLine("                }); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            reload: function () { ");
            builder.AppendLine("                $('#uitree_" + tm.TableName.ToLower() + "').tree('reload'); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            getSelected: function () { ");
            builder.AppendLine("                return $('#uitree_" + tm.TableName.ToLower() + "').tree('getSelected'); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            add: function () { ");
            builder.AppendLine("                var node = LCL_" + tm.TableName.ToLower() + ".getSelected(); ");
            builder.AppendLine("                if (node) { ");
            builder.AppendLine("                    //新增下级 ");
            builder.AppendLine("                    added = true; ");
            builder.AppendLine("                    $('#parentid').val(node.id); ");
            builder.AppendLine("                    $('#parentname').val(node.text); ");
            builder.AppendLine(" ");
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(" ");
            builder.AppendLine(" ");
            builder.AppendLine("                } ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            save: function () { ");
            builder.AppendLine(builder3.ToString());
            builder.AppendLine(" ");
            builder.AppendLine("                if (added) { ");
            builder.AppendLine("                    $.post(root + 'AjaxAdd', ");
            builder.AppendLine("                        { " + builder4.ToString() + " }, function (data) { ");
            builder.AppendLine("                            $.messager.alert('系统消息', data.Message); ");
            builder.AppendLine("                            //重新加载当前页 ");
            builder.AppendLine("                            LCL_" + tm.TableName.ToLower() + ".reload(); ");
            builder.AppendLine("                        }, \"json\"); ");
            builder.AppendLine("                } else { ");
            builder.AppendLine("                    $.post(root + 'AjaxEdit', ");
            builder.AppendLine("                        { " + builder4.ToString() + " }, function (data) { ");
            builder.AppendLine("                            $.messager.alert('系统消息', data.Message); ");
            builder.AppendLine("                            //重新加载当前页 ");
            builder.AppendLine("                            LCL_" + tm.TableName.ToLower() + ".reload(); ");
            builder.AppendLine("                        }, \"json\"); ");
            builder.AppendLine("                } ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            del: function () { ");
            builder.AppendLine("                var node = LCL_" + tm.TableName.ToLower() + ".getSelected(); ");
            builder.AppendLine("                if (node) { ");
            builder.AppendLine("                    $.messager.confirm('确认', '确认要删除选中记录吗?', function (y) { ");
            builder.AppendLine("                        if (y) { ");
            builder.AppendLine("                            //提交 ");
            builder.AppendLine("                            $.post(root + 'AjaxDelete/', node.id, ");
            builder.AppendLine("                            function (msg) { ");
            builder.AppendLine("                                if (msg.Success) { ");
            builder.AppendLine("                                    $.messager.alert('提示', msg.Message, 'info', function () { ");
            builder.AppendLine("                                        //重新加载当前页 ");
            builder.AppendLine("                                        $('#grid_" + tm.TableName.ToLower() + "').datagrid('reload'); ");
            builder.AppendLine("                                    }); ");
            builder.AppendLine("                                } else { ");
            builder.AppendLine("                                    $.messager.alert('提示', msg.Message, 'info') ");
            builder.AppendLine("                                } ");
            builder.AppendLine("                            }, \"json\"); ");
            builder.AppendLine("                        } ");
            builder.AppendLine("                    }); ");
            builder.AppendLine("                } ");
            builder.AppendLine("                else { ");
            builder.AppendLine("                    alert('请选择'); ");
            builder.AppendLine("                } ");
            builder.AppendLine("                return false; ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine("        $(document).ready(function () { ");
            builder.AppendLine("            LCL_" + tm.TableName.ToLower() + ".showTree(); ");
            builder.AppendLine("            $('#btnAdd" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".add(); }); ");
            builder.AppendLine("            $('#btnSave" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".save(); }); ");
            builder.AppendLine("            $('#btnDel" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".del(); }); ");
            builder.AppendLine("        }); ");

            return builder.ToString();
        }
コード例 #11
0
ファイル: EasyUIBuild.cs プロジェクト: iraychen/LCLFramework
        private string GenerateEasyUIFrom(TableModel tm)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("<table class=\"tb_searchbar\"> ");
            builder.AppendLine(" <tbody> ");
            var list = tm.Columns;
            StringBuilder crto = new StringBuilder();
            for (int i = 0; i < list.Count; i++)
            {
                var item = list[i];
                string isnull = "", validatebox = "";
                if (item.Isnullable && item.MaxLength > 0)
                {
                    isnull = "<span style=\"color:red;\">*</span>";
                    validatebox = " data-options=\"required:true\" class=\"easyui-validatebox\" ";
                }

                if (cols.Contains(item.ColumnName))
                {
                    crto.AppendLine("<input type='hidden' id='" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "' name='" + tm.TableName.ToLower() + "_Entity" + item.ColumnName + "' value='' />");
                }
                else
                {
                    if (item.ColumnName.Contains("_"))
                    {
                        builder.AppendLine("                <tr> ");
                        builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                        builder.AppendLine("                    <td> ");
                        builder.AppendLine("<select id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" class='easyui-combotree' data-options='url:\"AjaxEasyUITree\"' style='width: 120px; height: 28px;' tabindex=\"" + i + "\" " + validatebox + "></select>");
                        builder.AppendLine("                    </td> ");
                        builder.AppendLine("                </tr> ");
                    }
                    else
                    {
                        switch (item.ColumnType.ToLower())
                        {
                            case "bool":
                                builder.AppendLine("                <tr> ");
                                builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                                builder.AppendLine("                    <td> ");
                                builder.AppendLine("                        <input type=\"radio\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "1\" name=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" value=\"true\" checked tabindex=\"" + i + "\" />是");
                                builder.AppendLine("                        <input type=\"radio\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "2\" name=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" value=\"false\" tabindex=\"" + i + "\" />否");
                                builder.AppendLine("                    </td> ");
                                builder.AppendLine("                </tr> ");
                                break;
                            default:
                                builder.AppendLine("                <tr> ");
                                builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                                builder.AppendLine("                    <td> ");
                                builder.AppendLine("                        <input type=\"text\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" name=\"" + tm.TableName.ToLower() + "_Entity" + item.ColumnName + "\" value=\"  \" style=\"width:310px\" " + validatebox + " maxlength=\"" + item.MaxLength + "\" tabindex=\"" + i + "\" /> ");
                                builder.AppendLine("                    </td> ");
                                builder.AppendLine("                </tr> ");
                                break;
                        }
                    }
                }
            }
            builder.AppendLine("<tr><td  colspan='1'>" + crto.ToString() + "<td></tr>");
            builder.AppendLine(" </tbody> ");
            builder.AppendLine("</table> ");
            return builder.ToString();
        }
コード例 #12
0
ファイル: EasyUIBuild.cs プロジェクト: iraychen/LCLFramework
 private string GenerateEasyUITable(TableModel tm)
 {
     var list = tm.Columns;
     StringBuilder builder = new StringBuilder();
     builder.AppendLine("<div class=\"easyui-layout\" fit=\"true\" id=\"tb\"> ");
     builder.AppendLine("    <div data-options=\"region:'north'\" style=\"padding: 1px; height:70px;\"> ");
     builder.AppendLine("        <!-------------------------------搜索框-----------------------------------> ");
     builder.AppendLine("        <fieldset> ");
     builder.AppendLine("            <legend id=\"search_title\">信息查询</legend> ");
     builder.AppendLine("            <form id=\"ffSearch" + tm.TableName.ToLower() + "\" method=\"post\"> ");
     builder.AppendLine("                <div id=\"toolbar\" style=\"margin-bottom:5px\"> ");
     builder.AppendLine("                    <label for=\"Keyword\" id=\"search_key\">搜:</label> ");
     builder.AppendLine("                    <input type=\"text\" name=\"Keyword\" id=\"Keyword\" class=\"easyui-textbox\" style=\"width: 220px; height: 25px; text-align: center;\" placeholder=\"请输入\" /> ");
     builder.AppendLine("                    &nbsp; ");
     builder.AppendLine("                    <a id=\"btnSearch" + tm.TableName.ToLower() + "\" href=\"javascript:void(0)\" class=\"easyui-linkbutton\" iconcls=\"icon-search\">查询</a>&nbsp; ");
     builder.AppendLine("                </div> ");
     builder.AppendLine("            </form> ");
     builder.AppendLine("        </fieldset> ");
     builder.AppendLine("    </div> ");
     builder.AppendLine("    <div data-options=\"region:'center'\"> ");
     builder.AppendLine("        <!-------------------------------详细信息展示表格-----------------------------------> ");
     builder.AppendLine("        <table id=\"grid_" + tm.TableName.ToLower() + "\" title=\"" + tm.TableNameRemark + "\" toolbar=\"#tbar_" + tm.TableName.ToLower() + "\" data-options=\"iconCls:'icon-view'\" fit=\"true\"></table> ");
     builder.AppendLine("   <!--   弹出框       --> ");
     builder.AppendLine("        <div id=\"win_" + tm.TableName.ToLower() + "\"  style=\"padding: 5px;background: #fafafa;\" >  ");
     builder.AppendLine("            <div class=\"easyui-layout\" fit=\"true\"> ");
     builder.AppendLine("               <form id=\"ff" + tm.TableName.ToLower() + "\" method=\"post\" ajax=\"true\">");
     builder.AppendLine(GenerateEasyUIFrom(tm));
     builder.AppendLine("               </form>");
     builder.AppendLine("            </div> ");
     builder.AppendLine("        </div> ");
     builder.AppendLine("    </div> ");
     builder.AppendLine("</div> ");
     builder.AppendLine("@section scripts{ ");
     builder.AppendLine("  <script src=\"/Plugins/UIShell.RbacManagementPlugin/ViewScript/" + tm.TableName.ToLower() + ".cshtml.LanguageResource.js\" type=\"text/javascript\"></script> ");
     builder.AppendLine("  <script src=\"/Plugins/UIShell.RbacManagementPlugin/ViewScript/" + tm.TableName.ToLower() + ".cshtml.js\" type=\"text/javascript\"></script> ");
     builder.AppendLine("} ");
     return builder.ToString();
 }
コード例 #13
0
        private void BuildDbContext(string path)
        {
            StringBuilder     builder    = new StringBuilder();
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            builder.AppendLine("using System.Data.Entity; ");
            builder.AppendLine("using System.Data.Entity.ModelConfiguration.Conventions; ");
            builder.AppendLine("using System.Linq; ");

            builder.AppendLine("namespace " + Utils.NameSpace);
            builder.AppendLine("{ ");
            builder.AppendLine("    /// <summary> ");
            builder.AppendLine("    /// 数据上下文 Db" + Utils.dbName + "Context ");
            builder.AppendLine("    /// </summary> ");
            builder.AppendLine("    public class Db" + Utils.dbName + "Context : DbContext ");
            builder.AppendLine("    { ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 构造函数 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        public Db" + Utils.dbName + "Context() ");
            builder.AppendLine("            : base(\"" + Utils.dbName + "\") ");
            builder.AppendLine("        { ");
            builder.AppendLine("        } ");
            builder.AppendLine("#region 属性 ");
            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;

                builder.AppendLine("        /// <summary> ");
                builder.AppendLine("        /// " + tableInfo + " ");
                builder.AppendLine("        /// </summary> ");
                builder.AppendLine("        public DbSet<" + tablename + "> " + Utils.GetCapFirstName(tablename) + " { get; set; } ");
            }
            builder.AppendLine("#endregion ");
            builder.AppendLine("    } ");

            builder.AppendLine(" /// <summary> ");
            builder.AppendLine("    /// 数据库初始化操作类 ");
            builder.AppendLine("    /// </summary> ");
            builder.AppendLine("    public static class DatabaseInitializer ");
            builder.AppendLine("    { ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 数据库初始化 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        public static void Initialize() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            Database.SetInitializer(new SampleData()); ");
            builder.AppendLine("            using (var db = new Db" + Utils.dbName + "Context()) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                db.Database.Initialize(false); ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine("    } ");

            builder.AppendLine("    /// <summary> ");
            builder.AppendLine("    /// 数据库初始化策略 ");
            builder.AppendLine("    /// </summary> ");
            builder.AppendLine("    public class SampleData : CreateDatabaseIfNotExists<Db" + Utils.dbName + "> ");
            builder.AppendLine("    { ");
            builder.AppendLine("        protected override void Seed(Db" + Utils.dbName + " context) ");
            builder.AppendLine("        { ");
            builder.AppendLine(" ");
            builder.AppendLine("            //MonitoringArea org = context.Set<MonitoringArea>().Add(new MonitoringArea { PID = 0, Name = \"江西\", X = 0, Y = 0, ImagePath = \"\" }); ");
            builder.AppendLine("            //context.SaveChanges(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("    } ");

            builder.AppendLine("} ");
            if (path.Length > 0)
            {
                string folder = path + @"\LCL\Library\EFContexts\";
                Utils.FolderCheck(folder);
                string filename = folder + @"\EFContext.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
        }
コード例 #14
0
        private void BuildSpecification(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel    tm        = tableNames[i];
                string        tablename = tm.TableName;
                string        tableInfo = tm.TableNameRemark;
                StringBuilder builder   = new StringBuilder();
                builder.AppendLine("/*******************************************************  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 作者:罗敏贵  ");
                builder.AppendLine("* 说明: " + tableInfo + " ");
                builder.AppendLine("* 运行环境:.NET 4.5.0  ");
                builder.AppendLine("* 版本号:1.0.0  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 历史记录:  ");
                builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now.ToLongDateString() + " ");
                builder.AppendLine("*   ");
                builder.AppendLine("*******************************************************/  ");
                builder.AppendLine("using System; ");
                builder.AppendLine("using LCL.Specifications; ");
                builder.AppendLine("using System.Linq.Expressions; ");
                builder.AppendLine(" ");
                builder.AppendLine("namespace " + Utils.NameSpace + " ");
                builder.AppendLine("{ ");
                builder.AppendLine("     /// <summary> ");
                builder.AppendLine("    ///  根据关键字进行查询 ");
                builder.AppendLine("    /// </summary> ");
                builder.AppendLine("    public class Key" + tablename + "Specification : Specification<" + tablename + "> ");
                builder.AppendLine("    { ");
                builder.AppendLine("        string _keyword = \"\"; ");
                builder.AppendLine("        string _fieldName = \"\"; ");
                builder.AppendLine("        public Key" + tablename + "Specification(string keyword, string fieldName) ");
                builder.AppendLine("        { ");
                builder.AppendLine("            _keyword = keyword; ");
                builder.AppendLine("            _fieldName = fieldName; ");
                builder.AppendLine("        } ");
                builder.AppendLine("        public override Expression<Func<" + tablename + ", bool>> GetExpression() ");
                builder.AppendLine("        { ");
                builder.AppendLine("            Expression<Func<" + tablename + ", bool>> spec = null; ");
                builder.AppendLine("            switch (_fieldName) ");
                builder.AppendLine("            { ");
                foreach (TableColumn column in tm.Columns)
                {
                    builder.AppendLine("                case \"" + column.ColumnName + "\": // " + column.ColumnRemark + "");
                    switch (column.ColumnType.ToLower())
                    {
                    case "string":
                        builder.AppendLine("                    spec = c => c." + column.ColumnName + ".IndexOf(_keyword) != 0; ");
                        break;

                    case "int":
                        builder.AppendLine("                    spec = c => c." + column.ColumnName + "==Convert.ToInt32( _keyword); ");
                        break;

                    case "bool":
                        builder.AppendLine("                    spec = c => c." + column.ColumnName + "==Convert.ToBoolean( _keyword); ");
                        break;

                    case "guid":
                        builder.AppendLine("                    spec = c => c." + column.ColumnName + "== Guid.Parse(_keyword); ");
                        break;

                    case "datetime":
                        builder.AppendLine("                    spec = c => c." + column.ColumnName + "==Convert.ToDateTime( _keyword); ");
                        break;
                    }
                    builder.AppendLine("                    break; ");
                }
                builder.AppendLine("            } ");
                builder.AppendLine("            return spec; ");
                builder.AppendLine("        } ");
                builder.AppendLine("    } ");
                builder.AppendLine("} ");

                if (path.Length > 0)
                {
                    string folder = path + @"\LCL\Library\Specifications\";
                    Utils.FolderCheck(folder);
                    string filename = folder + @"\Key" + tablename + "Specification.cs";
                    Utils.CreateFiles(filename, builder.ToString());
                }
            }
        }
コード例 #15
0
        private void BuildLCLPlugin(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);
            StringBuilder     builder    = new StringBuilder();

            builder.AppendLine("using LCL; ");
            builder.AppendLine("using LCL.ComponentModel; ");
            builder.AppendLine("using LCL.Repositories; ");
            builder.AppendLine("using LCL.Repositories.EntityFramework; ");
            builder.AppendLine("using System.Data.Entity; ");
            builder.AppendLine("using System.Diagnostics; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace " + Utils.NameSpace + " ");
            builder.AppendLine("{ ");
            builder.AppendLine("    public class PluginActivator : LCLPlugin ");
            builder.AppendLine("    { ");
            builder.AppendLine("        public override void Initialize(IApp app) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            app.ModuleOperations += app_ModuleOperations; ");
            builder.AppendLine("            app.AllPluginsIntialized += app_AllPluginsIntialized; ");
            builder.AppendLine("        } ");
            builder.AppendLine("        void app_ModuleOperations(object sender, AppInitEventArgs e) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            ");

            builder.AppendLine("               CommonModel.Modules.AddRoot(new MvcModuleMeta ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    Label = \"" + Utils.dbName + "\", ");
            builder.AppendLine("                    Image = \".icon-application\", ");
            builder.AppendLine("                    Bundle = this, ");
            builder.AppendLine("                    Children = ");
            builder.AppendLine("                    { ");
            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;

                builder.AppendLine("                        new MvcModuleMeta{ Image = \".icon-application\",  Label = \"" + tableInfo + "\", CustomUI=\"/" + Utils.NameSpace + "/" + tablename + "/Index\",UIFromType=typeof(" + tablename + "Controller)}, ");
            }
            builder.AppendLine("                    } ");
            builder.AppendLine("                }); ");

            builder.AppendLine("        } ");
            builder.AppendLine("        void app_AllPluginsIntialized(object sender, System.EventArgs e) ");
            builder.AppendLine("        { ");
            builder.AppendLine(" ");
            StringBuilder ben = new StringBuilder();
            StringBuilder end = new StringBuilder();

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;
                if (tablename != "__MigrationHistory" && tablename != "sysdiagrams")
                {
                    //ben.AppendLine("ServiceLocator.Instance.Register<IRepository<" + tablename + ">, EntityFrameworkRepository<" + tablename + ">>();");

                    end.AppendLine("ServiceLocator.Instance.Register<I" + tablename + "Repository, " + tablename + "Repository>();");
                }
            }

            builder.AppendLine(" #region 默认仓库 ");
            //builder.AppendLine(ben.ToString());
            builder.AppendLine(" #endregion");
            builder.AppendLine(" #region 扩展仓库 ");
            builder.AppendLine(end.ToString());
            builder.AppendLine(" #endregion");

            builder.AppendLine("        } ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");

            if (path.Length > 0)
            {
                string folder = path + @"\LCL\Library\";
                Utils.FolderCheck(folder);
                string filename = folder + @"\BundleActivator.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
        }
コード例 #16
0
        private void BuildViewModels(TableModel table)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("using System.Collections.Generic; ");
            builder.AppendLine("using " + this.DomainName + "; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace LCL.MvcExtensions ");
            builder.AppendLine("{ ");
            builder.AppendLine("   public class " + table.TableName + "AddOrEditViewModel : AddOrEditViewModel<" + table.TableName + "> ");
            builder.AppendLine("    { ");
            builder.AppendLine("        ");
            builder.AppendLine("    } ");

            builder.AppendLine("   public class " + table.TableName + "PagedListViewModel : PagedListViewModel<" + table.TableName + "> ");
            builder.AppendLine("    { ");
            builder.AppendLine("        public " + table.TableName + "PagedListViewModel(int currentPageNum, int pageSize, List<" + table.TableName + "> allModels) ");
            builder.AppendLine("            : base(currentPageNum, pageSize, allModels) ");
            builder.AppendLine("        { ");
            builder.AppendLine(" ");
            builder.AppendLine("        } ");
            builder.AppendLine("    } ");
            builder.AppendLine(" ");
            builder.AppendLine("} ");

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(ViewModels.get_FileNames(1)), table.TableName) + ".cs";
            if (!File.Exists(file))
            {
                File.WriteAllText(file, builder.ToString());
                ViewModels.ProjectItems.AddFromFile(file);
            }
        }
コード例 #17
0
        private void BuildControllers(TableModel table)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("/******************************************************* ");
            builder.AppendLine("*  ");
            builder.AppendLine("* 作者:罗敏贵 ");
            builder.AppendLine("* 说明: " + table.TableNameRemark);
            builder.AppendLine("* 运行环境:.NET 4.5.0 ");
            builder.AppendLine("* 版本号:1.0.0 ");
            builder.AppendLine("*  ");
            builder.AppendLine("* 历史记录: ");
            builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now.ToLongDateString());
            builder.AppendLine("*  ");
            builder.AppendLine("*******************************************************/ ");
            builder.AppendLine("using LCL.MvcExtensions; ");
            builder.AppendLine("using LCL.Repositories;");
            builder.AppendLine("using LCL;");
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.Collections.Generic; ");
            builder.AppendLine("using System.Linq; ");
            builder.AppendLine("using System.Web; ");
            builder.AppendLine("using System.Web.Mvc; ");
            builder.AppendLine("using UIShell.RbacPermissionService; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace " + this.DomainName + ".Controllers ");
            builder.AppendLine("{ ");
            builder.AppendLine("    public class " + table.TableName + "Controller : RbacController<" + table.TableName + "> ");
            builder.AppendLine("    { ");
            var list = table.Columns.Where(e => e.ColumnName.Contains("_"));
            StringBuilder ddl = new StringBuilder();
            StringBuilder crto = new StringBuilder();
            foreach (var item in list)
            {
                crto.AppendLine("       ddl" + item.ColumnName.Remove(item.ColumnName.Length - 3) + "(Guid.Empty); ");

                ddl.AppendLine("        public void ddl" + item.ColumnName.Remove(item.ColumnName.Length - 3) + "(Guid dtId) ");
                ddl.AppendLine("        { ");
                ddl.AppendLine("            var repo = RF.FindRepo<" + item.ColumnName.Remove(item.ColumnName.Length - 3) + ">(); ");
                ddl.AppendLine("            var list = repo.FindAll(); ");
                ddl.AppendLine(" ");
                ddl.AppendLine("            List<SelectListItem> selitem = new List<SelectListItem>(); ");
                ddl.AppendLine("            if (list.Count() > 0) ");
                ddl.AppendLine("            { ");
                if (table.IsTree)
                {
                    ddl.AppendLine("                var roots = list.Where(e => e.ParentId == Guid.Empty); ");
                    ddl.AppendLine("                foreach (var item in roots) ");
                    ddl.AppendLine("                { ");
                    ddl.AppendLine("                    selitem.Add(new SelectListItem { Text = item.Name, Value = item.ID.ToString() }); ");
                    ddl.AppendLine("                    var child = list.Where(p => p.ParentId == item.ID); ");
                    ddl.AppendLine("                    foreach (var item1 in child) ");
                    ddl.AppendLine("                    { ");
                    ddl.AppendLine("                        if (dtId == item1.ID) ");
                    ddl.AppendLine("                        { ");
                    ddl.AppendLine("                            selitem.Add(new SelectListItem { Text = \"----\" + item1.Name, Value = item1.ID.ToString(), Selected = true }); ");
                    ddl.AppendLine("                            this.ViewData[\"selected\"] = item1.ID.ToString(); ");
                    ddl.AppendLine("                        } ");
                    ddl.AppendLine("                        else ");
                    ddl.AppendLine("                        { ");
                    ddl.AppendLine("                            selitem.Add(new SelectListItem { Text = \"----\" + item1.Name, Value = item1.ID.ToString() }); ");
                    ddl.AppendLine("                        } ");
                    ddl.AppendLine("                    } ");
                    ddl.AppendLine("                } ");
                    ddl.AppendLine("            } ");
                }
                else
                {
                    ddl.AppendLine("                var roots = list; ");
                    ddl.AppendLine("                foreach (var item in roots) ");
                    ddl.AppendLine("                { ");
                    ddl.AppendLine("                    selitem.Add(new SelectListItem { Text = item.Name, Value = item.ID.ToString() }); ");
                    ddl.AppendLine("                } ");
                    ddl.AppendLine("            } ");
                }
                ddl.AppendLine("            selitem.Insert(0, new SelectListItem { Text = \"==" + item.ColumnRemark + "==\", Value = \"-1\" }); ");
                ddl.AppendLine("            ViewData[\"ddl" + table.TableName + "\"] = selitem; ");
                ddl.AppendLine("        } ");
            }
            builder.AppendLine("        public " + table.TableName + "Controller() ");
            builder.AppendLine("        { ");
            builder.AppendLine(crto.ToString());
            builder.AppendLine("        } ");
            builder.AppendLine(ddl.ToString());
            builder.AppendLine(" ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(Controllers.get_FileNames(1)), table.TableName) + "Controller.cs";
            if (!File.Exists(file))
            {
                File.WriteAllText(file, builder.ToString());
                Controllers.ProjectItems.AddFromFile(file);
            }
        }
コード例 #18
0
        public string Library(string path, TableModel tableModel, System.Windows.Forms.ProgressBar progressBar)
        {
            //Entity
            BuildEntity(path, tableModel, progressBar);
            //Repository
            new RepositoryBuild().BuildRepository(path);
            //ValidationModel
            new ValidationModelBuild().GenerateValidationModel(path);
            //ViewModels

            //EFContexts

            //BundleActivator

            return "";
        }
コード例 #19
0
        private void BuildEntity(TableModel table)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("/*******************************************************   ");
            builder.AppendLine("*    ");
            builder.AppendLine("* 作者:罗敏贵   ");
            builder.AppendLine("* 说明:   ");
            builder.AppendLine("* 运行环境:.NET 4.5.0   ");
            builder.AppendLine("* 版本号:1.0.0   ");
            builder.AppendLine("*    ");
            builder.AppendLine("* 历史记录:   ");
            builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now + "  ");
            builder.AppendLine("*    ");
            builder.AppendLine("*******************************************************/   ");
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.Collections.Generic; ");
            builder.AppendLine("using System.Linq; ");
            builder.AppendLine("using System.Text; ");
            builder.AppendLine("using LCL; ");
            builder.AppendLine(" ");
            builder.AppendLine("namespace " + this.DomainName + " ");
            builder.AppendLine("{ ");
            builder.AppendLine("    /// <summary> ");
            builder.AppendLine("    /// " + table.TableNameRemark + " ");
            builder.AppendLine("    /// </summary> ");
            builder.AppendLine("    public partial class " + table.TableName + " : Entity ");
            builder.AppendLine("    { ");
            builder.AppendLine("        public " + table.TableName + "() ");
            builder.AppendLine("        { ");
            builder.AppendLine("             ");
            builder.AppendLine("        } ");
            foreach (TableColumn column in table.Columns)
            {
                builder.AppendLine("        /// <summary> ");
                builder.AppendLine("        /// " + column.ColumnRemark + " ");
                builder.AppendLine("        /// </summary> ");
                builder.AppendLine("        public " + column.ColumnType + " " + column.ColumnName + " { get; set; } ");
            }
            builder.AppendLine("        ");
            builder.AppendLine(" ");
            builder.AppendLine(" ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");

            //写到文件,并加入到项目中。
            var file = Path.Combine(Path.GetDirectoryName(_directory.get_FileNames(1)), table.TableName) + ".cs";
            if (!File.Exists(file))
            {
                File.WriteAllText(file, builder.ToString());
                _directory.ProjectItems.AddFromFile(file);
            }
        }
コード例 #20
0
        //.cshtml.LanguageResource.js
        private void GenerateEasyUILanguageResource(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;
                if (tablename == "__MigrationHistory" && tablename == "sysdiagrams")
                {
                    continue;
                }

                StringBuilder builder  = new StringBuilder();
                StringBuilder builder1 = new StringBuilder();
                StringBuilder builder2 = new StringBuilder();
                StringBuilder builder3 = new StringBuilder();
                foreach (var item in tm.Columns)
                {
                    builder1.AppendLine("    " + tm.TableName + "_Model_" + item.ColumnName + ": '" + item.ColumnRemark + "', ");
                    builder2.AppendLine("    " + tm.TableName + "_Model_" + item.ColumnName + ": '" + item.ColumnName + "', ");
                    builder3.AppendLine("    $('#ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "').html($.LCLPageModel.Resource.PageLanguageResource." + tm.TableName + "_Model_" + item.ColumnName + "); ");
                }
                if (builder1.Length > 2)
                {
                    builder1.Remove(builder1.Length - 1, 1);
                }

                if (builder2.Length > 2)
                {
                    builder2.Remove(builder2.Length - 1, 1);
                }

                builder.AppendLine("$.LCLPageModel.Resource.InitLanguageResource = function () { ");
                builder.AppendLine("    // 资源初始化 ");
                builder.AppendLine("    $.LCLPageModel.Resource.PageLanguageResource = $.LCLPageModel.Resource.LanguageResourceInfo[pageAttr.LanguageId]; ");
                builder.AppendLine("$('#btnSavewfrout').html($.LCLPageModel.Resource.PageLanguageResource.Page_Command_Save); ");
                builder.AppendLine("$('#btnCancelwfrout').html($.LCLPageModel.Resource.PageLanguageResource.Page_Command_Cancel); ");
                builder.AppendLine("$('#btnSearchwfrout').html($.LCLPageModel.Resource.PageLanguageResource.Page_Command_Search); ");
                builder.AppendLine("$('#search_title').html($.LCLPageModel.Resource.PageLanguageResource.Page_label_Search_title); ");
                builder.AppendLine("$('#search_key').html($.LCLPageModel.Resource.PageLanguageResource.Page_label_Search_key); ");
                builder.AppendLine("$('#grid_wfrout').attr('title', $.LCLPageModel.Resource.PageLanguageResource.Page_title); ");
                builder.AppendLine(builder3.ToString());
                builder.AppendLine("} ");
                builder.AppendLine("//初始化页面中文资源 ");
                builder.AppendLine("$.LCLPageModel.Resource.LanguageResourceInfo['2052'] = { ");
                builder.AppendLine("    Page_title: '" + tableInfo + "', ");
                builder.AppendLine("    Page_Command_Grid_Operate: '操作', ");
                builder.AppendLine("    Page_Command_Add: '添加', ");
                builder.AppendLine("    Page_Command_Edit: '修改', ");
                builder.AppendLine("    Page_Command_Del: '删除', ");
                builder.AppendLine("    Page_Command_Save: '保存', ");
                builder.AppendLine("    Page_Command_Cancel: '取消', ");
                builder.AppendLine("    Page_Command_Search: '查询', ");
                builder.AppendLine("    Page_label_Search_title: '信息查询', ");
                builder.AppendLine("    Page_label_Search_key: '搜', ");
                builder.AppendLine("    LCLMessageBox_AlertTitle: '温馨提示', ");
                builder.AppendLine("    LCLMessageBox_Message1: '请选择一行', ");
                builder.AppendLine("    LCLMessageBox_Message2: '请先勾选要删除的数据', ");
                builder.AppendLine("    LCLMessageBox_Message3: '是否删除选中数据', ");

                builder.AppendLine(builder1.ToString());
                builder.AppendLine("}; ");
                builder.AppendLine("//初始化页面英文资源 ");
                builder.AppendLine("$.LCLPageModel.Resource.LanguageResourceInfo['1033'] = { ");
                builder.AppendLine("    Page_title: '" + tablename + "', ");
                builder.AppendLine("    Page_Command_Grid_Operate: 'Operate', ");
                builder.AppendLine("    Page_Command_Add: 'Add', ");
                builder.AppendLine("    Page_Command_Edit: 'Edit', ");
                builder.AppendLine("    Page_Command_Del: 'Delete', ");
                builder.AppendLine("    Page_Command_Save: 'Save', ");
                builder.AppendLine("    Page_Command_Cancel: 'Cancel', ");
                builder.AppendLine("    Page_Command_Search: 'Search', ");
                builder.AppendLine("    Page_label_Search_title: 'info query', ");
                builder.AppendLine("    Page_label_Search_key: 'key', ");
                builder.AppendLine("    LCLMessageBox_AlertTitle: 'AlertTitle', ");
                builder.AppendLine("    LCLMessageBox_Message1: 'Please select row', ");
                builder.AppendLine("    LCLMessageBox_Message2: 'Please delete data', ");
                builder.AppendLine("    LCLMessageBox_Message3: 'is delete data', ");
                builder.AppendLine(builder2.ToString());
                builder.AppendLine("}; ");

                if (path.Length > 0)
                {
                    string folder = path + @"\LCL\EasyUI\ViewScript\";
                    Utils.FolderCheck(folder);
                    string filename = folder + tablename.ToLower() + ".cshtml.LanguageResource.js";
                    Utils.CreateFiles(filename, builder.ToString());
                }
            }
        }
コード例 #21
0
 public string Library(string path, TableModel tableModel, List<TableColumn> SelectWhere, List<TableColumn> ShowFields, TableModel LeftTree, List<TableColumn> CheckFields, List<TableColumn> CheckFepeat)
 {
     //Entity
     BuildEntity(path, tableModel, null);
     //列表页面
     WinFrmListPage(path, tableModel, SelectWhere, ShowFields, LeftTree);
     //Edit页面
     WinFrmEditPage(path, tableModel, ShowFields, CheckFields, CheckFields);
     return "";
 }
コード例 #22
0
        //.cshtml.js
        private void GenerateEasyUITableJs(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;
                if (tablename == "__MigrationHistory" && tablename == "sysdiagrams")
                {
                    continue;
                }

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("/// <reference path=\"/Content/Code/LCL.JQuery.Base.js\" /> ");
                builder.AppendLine("/// <reference path=\"/Content/Core/LCL.JQuery.Core.js\" /> ");
                builder.AppendLine("/// <reference path=\"/Content/Core/LCL.JQuery.JSON.js\" /> ");
                builder.AppendLine("/// <reference path=\"/Content/Core/LCL.JQuery.Plugins.js\" /> ");
                builder.AppendLine(" ");
                builder.AppendLine("//页面属性PageAttr (该行不允许删除) ");
                builder.AppendLine("var pageAttr = { ");
                builder.AppendLine("    SiteRoot: '', ");
                builder.AppendLine("    LanguageId: '2052', ");
                builder.AppendLine("    JsonServerURL: '', ");
                builder.AppendLine("    Added: true, ");
                builder.AppendLine("    toolbar: '' ");
                builder.AppendLine("}; ");
                builder.AppendLine("//页面入口 ");
                builder.AppendLine("$(document).ready(function () { ");
                builder.AppendLine("    //debugger; ");
                builder.AppendLine("    InitAttribute(); ");
                builder.AppendLine("    InitLanguage(); ");
                builder.AppendLine("    InitControls(); ");
                builder.AppendLine("    InitEvent(); ");
                builder.AppendLine("}); ");
                builder.AppendLine("//初始化页面属性 ");
                builder.AppendLine("function InitAttribute() { ");
                builder.AppendLine("    pageAttr.SiteRoot = $.LCLBase.SiteConfig.GetSiteRoot(); ");
                builder.AppendLine("    pageAttr.LanguageId = $.LCLBase.SiteConfig.GetCurrLanguageID(); ");
                builder.AppendLine("    pageAttr.JsonServerURL = pageAttr.SiteRoot + 'UIShell.RbacManagementPlugin/'; ");
                builder.AppendLine("} ");
                builder.AppendLine("//初始化多语言 ");
                builder.AppendLine("function InitLanguage() { ");
                builder.AppendLine("    $.LCLPageModel.Resource.InitLanguage(); ");
                builder.AppendLine("} ");
                builder.AppendLine("//初始化控件 ");
                builder.AppendLine("function InitControls() { ");
                builder.AppendLine("    InitGrid(); ");
                builder.AppendLine("} ");
                builder.AppendLine("//初始化事件 ");
                builder.AppendLine("function InitEvent() { ");
                builder.AppendLine("    $('#btnAdd" + tm.TableName.ToLower() + "').click(function () { pageFunc_" + tm.TableName.ToLower() + "Add(); }); ");
                builder.AppendLine("    $('#btnDel" + tm.TableName.ToLower() + "').click(function () { pageFunc_" + tm.TableName.ToLower() + "Del(); }); ");
                builder.AppendLine("    $('#btnSearch" + tm.TableName.ToLower() + "').click(function () { pageFunc_SearchData" + tm.TableName.ToLower() + "(); }); ");
                builder.AppendLine("} ");
                builder.AppendLine("function InitGrid() { ");
                builder.AppendLine("    $('#grid_" + tm.TableName.ToLower() + "').datagrid({ ");
                builder.AppendLine("        url: pageAttr.JsonServerURL + '" + tm.TableName + "/AjaxGetByPage', ");
                builder.AppendLine("        iconCls: 'icon-edit', ");
                builder.AppendLine("        pagination: true, ");
                builder.AppendLine("        rownumbers: true, ");
                builder.AppendLine("        fitCloumns: true, ");
                builder.AppendLine("        idField: \"ID\", ");
                builder.AppendLine("        frozenColumns: [[ ");
                builder.AppendLine("          { field: 'ck', checkbox: true } ");
                builder.AppendLine("        ]], ");
                builder.AppendLine("        hideColumn: [[ ");
                builder.AppendLine("           { title: 'ID', field: 'ID' } ");
                builder.AppendLine("        ]], ");
                builder.AppendLine("        columns: [[ ");

                foreach (var item in tm.Columns)
                {
                    if (cols.Contains(item.ColumnName))
                    {
                        builder.AppendLine("                { field: '" + item.ColumnName + "', title: $.LCLPageModel.Resource.PageLanguageResource." + tm.TableName + "_Model_" + item.ColumnName + ", width: 100,hidden:true }, ");
                    }
                    else
                    {
                        builder.AppendLine("                { field: '" + item.ColumnName + "', title: $.LCLPageModel.Resource.PageLanguageResource." + tm.TableName + "_Model_" + item.ColumnName + ", width: 100 }, ");
                        if (item.ColumnType.ToLower() == "bool")
                        {
                            builder.AppendLine("                { ");
                            builder.AppendLine("                    field: '" + item.ColumnName + "', title: $.LCLPageModel.Resource.PageLanguageResource." + tm.TableName + "_Model_" + item.ColumnName + ", width: 100, formatter: function (value, row, index) { ");
                            builder.AppendLine("                        return value ? '<div class=\"icon-true\" style=\"width:16px; height:16px;\" >&nbsp;&nbsp;</div>' : ");
                            builder.AppendLine("                                       '<div class=\"icon-false\" style=\"width:16px; height:16px;\">&nbsp;&nbsp;</div>'; ");
                            builder.AppendLine("                    } ");
                            builder.AppendLine("                }, ");
                        }
                    }
                }
                builder.AppendLine("                { ");
                builder.AppendLine("                    field: 'opt', title: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Grid_Operate, width: 120, align: 'center', ");
                builder.AppendLine("                    formatter: function (value, rec, index) { ");
                builder.AppendLine("                        return '&nbsp;<a href=\"javascript:void(0)\" onclick=\"pageFunc_" + tm.TableName.ToLower() + "Edit(\\'' + rec.ID + '\\')\">' + $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Edit + '</a>&nbsp;' ");
                builder.AppendLine("                             + '&nbsp;<a href=\"javascript:void(0)\" onclick=\"pageFunc_" + tm.TableName.ToLower() + "Del()\">' + $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Del + '</a>&nbsp;'; ");
                builder.AppendLine("                    } ");
                builder.AppendLine("                } ");
                builder.AppendLine("        ]], ");
                builder.AppendLine("        toolbar: grid_" + tm.TableName.ToLower() + "_toolbar(), ");
                builder.AppendLine("        onDblClickRow: function (rowIndex, rowData) { ");
                builder.AppendLine("            $('#grid_wfrout').datagrid('clearSelections').datagrid('clearChecked').datagrid('checkRow', rowIndex); ");
                builder.AppendLine("            pageFunc_" + tm.TableName.ToLower() + "Edit(rowData.ID); ");
                builder.AppendLine("        } ");
                builder.AppendLine("    }); ");
                builder.AppendLine("} ");
                builder.AppendLine("function pageFunc_SearchData" + tm.TableName.ToLower() + "() { ");
                builder.AppendLine("    $(\"#grid_" + tm.TableName.ToLower() + "\").datagrid('load', { ");
                builder.AppendLine("        Name: $('#ui_wfrout_search').find('[name=Keyword]').val() ");
                builder.AppendLine("    }); ");
                builder.AppendLine("    clearSelect('grid_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("} ");
                builder.AppendLine("function pageFunc_" + tm.TableName.ToLower() + "Add() { ");
                builder.AppendLine("    pageAttr.Added = true; ");
                builder.AppendLine("    $('#ff" + tm.TableName.ToLower() + "').form('clear'); ");
                builder.AppendLine("    $('#win_" + tm.TableName.ToLower() + "').dialog({ ");
                builder.AppendLine("        title: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Add, ");
                builder.AppendLine("        width: 500, ");
                builder.AppendLine("        height: 280, ");
                builder.AppendLine("        iconCls: 'icon-add', ");
                builder.AppendLine("        modal: true, ");
                builder.AppendLine("        buttons: [{ ");
                builder.AppendLine("            id: 'btnSave" + tm.TableName.ToLower() + "', ");
                builder.AppendLine("            iconCls: 'icon-ok', ");
                builder.AppendLine("            text: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Save, ");
                builder.AppendLine("            handler: function () { ");
                builder.AppendLine("                pageFunc_" + tm.TableName.ToLower() + "Save(); ");
                builder.AppendLine("            } ");
                builder.AppendLine("        }, { ");
                builder.AppendLine("            id: 'btnCancelwfrout', ");
                builder.AppendLine("            iconCls: 'icon-cancel', ");
                builder.AppendLine("            text: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Cancel, ");
                builder.AppendLine("            handler: function () { ");
                builder.AppendLine("                closeDialog('win_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("            } ");
                builder.AppendLine("        }], ");
                builder.AppendLine("        onLoad: function () { ");
                builder.AppendLine("            $('#" + tm.TableName.ToLower() + "_Entity_Name').focus(); ");
                builder.AppendLine("        } ");
                builder.AppendLine("    }); ");
                builder.AppendLine("} ");
                builder.AppendLine("function pageFunc_" + tm.TableName.ToLower() + "Edit(ID) { ");
                builder.AppendLine("    if (ID != undefined && ID.length > 0) { ");
                builder.AppendLine("        pageAttr.Added = false; ");
                builder.AppendLine("        $('#win_" + tm.TableName.ToLower() + "').dialog({ ");
                builder.AppendLine("            title: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Edit, ");
                builder.AppendLine("            width: 550, ");
                builder.AppendLine("            height: 280, ");
                builder.AppendLine("            iconCls: 'icon-edit', ");
                builder.AppendLine("            modal: true, ");
                builder.AppendLine("            buttons: [{ ");
                builder.AppendLine("                id: \"btnSave" + tm.TableName.ToLower() + "\", ");
                builder.AppendLine("                iconCls: 'icon-ok', ");
                builder.AppendLine("                text: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Save, ");
                builder.AppendLine("                handler: function () { ");
                builder.AppendLine("                    pageFunc_" + tm.TableName.ToLower() + "Save(); ");
                builder.AppendLine("                } ");
                builder.AppendLine("            }, { ");
                builder.AppendLine("                id: 'btnCancel" + tm.TableName.ToLower() + "', ");
                builder.AppendLine("                iconCls: 'icon-cancel', ");
                builder.AppendLine("                text: $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Cancel, ");
                builder.AppendLine("                handler: function () { ");
                builder.AppendLine("                    closeDialog('win_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("                } ");
                builder.AppendLine("            }], ");
                builder.AppendLine("            onClose: function () { ");
                builder.AppendLine("                closeDialog('win_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("            } ");
                builder.AppendLine("        }); ");
                builder.AppendLine("        var ajaxUrl = pageAttr.JsonServerURL + '" + tm.TableName.ToLower() + "/AjaxGetByModel?id=' + $.LCLCore.ValidUI.Trim(ID); ");
                builder.AppendLine("        $.post(ajaxUrl, function (resultData) { ");
                builder.AppendLine("            if (resultData.Success) { ");

                foreach (var item in tm.Columns)
                {
                    builder.AppendLine("                $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(resultData.DataObject." + item.ColumnName + "); ");
                }

                builder.AppendLine("            } ");
                builder.AppendLine("        }, 'json'); ");
                builder.AppendLine(" ");
                builder.AppendLine("    } else { ");
                builder.AppendLine("        $.LCLMessageBox.Alert($.LCLPageModel.Resource.PageLanguageResource.LCLMessageBox_Message1); ");
                builder.AppendLine("    } ");
                builder.AppendLine("} ");
                builder.AppendLine("function pageFunc_" + tm.TableName.ToLower() + "Save() { ");
                builder.AppendLine("    var ajaxUrl = \"\"; ");
                builder.AppendLine("    if (pageAttr.Added) { ");
                builder.AppendLine("        ajaxUrl = pageAttr.JsonServerURL + '" + tm.TableName + "/AjaxAdd'; ");
                builder.AppendLine("    } else { ");
                builder.AppendLine("        ajaxUrl = pageAttr.JsonServerURL + '" + tm.TableName + "/AjaxEdit'; ");
                builder.AppendLine("    } ");
                builder.AppendLine(" ");
                builder.AppendLine("    $('#ff" + tm.TableName.ToLower() + "').form('submit', { ");
                builder.AppendLine("        url: ajaxUrl, ");
                builder.AppendLine("        onSubmit: function (param) { ");
                builder.AppendLine("            $('#btnSave" + tm.TableName.ToLower() + "').linkbutton('disable'); ");
                foreach (var item in tm.Columns)
                {
                    builder.AppendLine("            param." + item.ColumnName + " = $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(); ");
                }
                builder.AppendLine("            if ($(this).form('validate')) ");
                builder.AppendLine("                return true; ");
                builder.AppendLine("            else { ");
                builder.AppendLine("                $('#btnSave" + tm.TableName.ToLower() + "').linkbutton('enable'); ");
                builder.AppendLine("                return false; ");
                builder.AppendLine("            } ");
                builder.AppendLine("        }, ");
                builder.AppendLine("        success: function (data) { ");
                builder.AppendLine("            var resultData = eval('(' + data + ')'); ");
                builder.AppendLine("            if (resultData.Success) { ");
                builder.AppendLine("                flashTable('grid_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("                if (pageAttr.Added) { ");
                builder.AppendLine(" ");
                builder.AppendLine("                } else { ");
                builder.AppendLine("                    closeDialog('win_" + tm.TableName.ToLower() + "'); ");
                builder.AppendLine("                } ");
                builder.AppendLine("            } ");
                builder.AppendLine("            $('#btnSave" + tm.TableName.ToLower() + "').linkbutton('enable'); ");
                builder.AppendLine("            $.LCLMessageBox.Alert(resultData.Message); ");
                builder.AppendLine("        } ");
                builder.AppendLine("    }); ");
                builder.AppendLine("} ");
                builder.AppendLine("function pageFunc_" + tm.TableName.ToLower() + "Del() { ");
                builder.AppendLine("    var rows = $(\"#grid_" + tm.TableName.ToLower() + "\").datagrid(\"getChecked\"); ");
                builder.AppendLine("    if (rows.length < 1) { ");
                builder.AppendLine("        $.LCLMessageBox.Alert($.LCLPageModel.Resource.PageLanguageResource.LCLMessageBox_Message2); ");
                builder.AppendLine("        return; ");
                builder.AppendLine("    } ");
                builder.AppendLine("    var parm; ");
                builder.AppendLine("    $.each(rows, function (i, row) { ");
                builder.AppendLine("        if (i == 0) { ");
                builder.AppendLine("            parm = \"idList=\" + row.ID; ");
                builder.AppendLine("        } else { ");
                builder.AppendLine("            parm += \"&idList=\" + row.ID; ");
                builder.AppendLine("        } ");
                builder.AppendLine("    }); ");
                builder.AppendLine("    $.LCLMessageBox.Confirm($.LCLPageModel.Resource.PageLanguageResource.LCLMessageBox_Message3, function (r) { ");
                builder.AppendLine("        if (r) { ");
                builder.AppendLine("            $.post(pageAttr.JsonServerURL + '" + tm.TableName + "/AjaxDeleteList/', parm, ");
                builder.AppendLine("            function (resultData) { ");
                builder.AppendLine("                if (resultData.Success) { ");
                builder.AppendLine("                    $.LCLMessageBox.Alert(resultData.Message,function () { ");
                builder.AppendLine("                        InitGrid(); ");
                builder.AppendLine("                    }); ");
                builder.AppendLine("                } else { ");
                builder.AppendLine("                    $.LCLMessageBox.Alert(resultData.Message); ");
                builder.AppendLine("                } ");
                builder.AppendLine("            }, \"json\"); ");
                builder.AppendLine("        } ");
                builder.AppendLine("    }); ");
                builder.AppendLine("} ");
                builder.AppendLine("function grid_" + tm.TableName.ToLower() + "_toolbar() { ");
                builder.AppendLine("    var ihtml = '<div id=\"tbar_" + tm.TableName.ToLower() + "\">' ");
                builder.AppendLine("        + '<a id=\"btnAdd" + tm.TableName.ToLower() + "\" href=\"javascript:;\" plain=\"true\" class=\"easyui-linkbutton\" icon=\"icon-add\">' + $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Add + '</a>&nbsp;' ");
                builder.AppendLine("        + '<a id=\"btnDel" + tm.TableName.ToLower() + "\" href=\"javascript:;\" plain=\"true\" class=\"easyui-linkbutton\" icon=\"icon-remove\">' + $.LCLPageModel.Resource.PageLanguageResource.Page_Command_Del + '</a>&nbsp;' ");
                builder.AppendLine("        + '<a href=\"javascript:void(0)\" /></div>' ");
                builder.AppendLine("    return ihtml; ");
                builder.AppendLine("} ");

                if (path.Length > 0)
                {
                    string folder = path + @"\LCL\EasyUI\ViewScript\";
                    Utils.FolderCheck(folder);
                    string filename = folder + tablename.ToLower() + ".cshtml.js";
                    Utils.CreateFiles(filename, builder.ToString());
                }
            }
        }
コード例 #23
0
        //TODO:查询
        private void WinFrmListPage(string path, TableModel tableModel, List<TableColumn> SelectWhere, List<TableColumn> ShowFields, TableModel LeftTree)
        {
            #region {tablename}Frm.cs
            string className = tableModel.TableName;
            string tableinfo = tableModel.TableNameRemark;
            StringBuilder AddColumnAlias = new StringBuilder();
            foreach (TableColumn item in ShowFields)
            {
                AddColumnAlias.AppendLine("//this.entityFrm1.AddColumnAlias(\"" + item.ColumnName + "\", \"" + item.ColumnRemark + "\", false);");
            }
            // 查询

            StringBuilder builder = new StringBuilder();
            builder.AppendLine(" ");
            builder.AppendLine("using System; ");
            builder.AppendLine("using System.Windows.Forms; ");
            builder.AppendLine("using MinGuiLuo.Logging; ");
            builder.AppendLine("using MinGuiLuo.ORM; ");
            builder.AppendLine("using SF.Threading; ");
            builder.AppendLine("using MinGuiLuo.WinFromControls.Forms; ");
            builder.AppendLine("using MinGuiLuo.WinFromControls.Controls; ");
            builder.AppendLine("using MinGuiLuo; ");
            builder.AppendLine("namespace  " + Utils.NameSpaceUI);
            builder.AppendLine("{ ");
            builder.AppendLine("    public partial class " + className + "Frm : DockFrm ");
            builder.AppendLine("    { ");
            builder.AppendLine("        public " + className + "Frm( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            InitializeComponent(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        public void BindData( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            try ");
            builder.AppendLine("            { ");
            if (LeftTree != null)
            {
                builder.AppendLine("             var rf = RF.Create<" + LeftTree.TableName + ">();var treeList = rf.GetAll(); ");
                builder.AppendLine("              if (treeList.Count > 0) ");
                builder.AppendLine("                { ");
                builder.AppendLine("                    foreach (" + LeftTree.TableName + " item in treeList) ");
                builder.AppendLine("                    { ");
                builder.AppendLine("                        TreeNode tn = new TreeNode(); ");
                builder.AppendLine("                        tn.Text = item.Name; ");
                builder.AppendLine("                        tn.Tag = item; ");
                builder.AppendLine("                        this.entityFrm1.TreeView.Nodes.Add(tn); ");
                builder.AppendLine("                    } ");
                builder.AppendLine("                } ");
                builder.AppendLine("             this.entityFrm1.TreeViewVisible = true; ");
                builder.AppendLine("             this.entityFrm1.TreeView.AfterSelect += TreeView_AfterSelect; ");
            }
            else
            {
                builder.AppendLine("                var rflist = RF.Create<" + className + ">(); ");
                builder.AppendLine("                this.entityFrm1.DataGridView.DataSource =rflist.GetAll(); ");
                builder.AppendLine("              " + AddColumnAlias.ToString());
            }
            builder.AppendLine("            } ");
            builder.AppendLine("            catch (Exception ex) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                LogUtil.LogError(ex); ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            if (LeftTree != null)
            {
                builder.AppendLine("        void TreeView_AfterSelect(object sender, TreeViewEventArgs e) ");
                builder.AppendLine("        { ");
                builder.AppendLine("            if (e == null || e.Node == null || e.Node.Tag == null) ");
                builder.AppendLine("                return; ");
                builder.AppendLine("            " + LeftTree.TableName + " tree = (" + LeftTree.TableName + ")e.Node.Tag; ");
                builder.AppendLine("            this.entityFrm1.DataGridView.DataSource = BLLFactory<" + className + ">.Instance().LoadEntities(p => p." + LeftTree.TableName + ".ID == tree.ID); ");
                builder.AppendLine("              " + AddColumnAlias.ToString());
                builder.AppendLine("        } ");
            }
            builder.AppendLine("        private void entityFrm1_AddButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            " + className + "FrmEdit frm = new " + className + "FrmEdit(); ");
            builder.AppendLine("            frm.Text = \"" + tableinfo + " 添加\"; ");
            builder.AppendLine("            if (DialogResult.OK == frm.ShowDialog())");
            builder.AppendLine("            {");
            builder.AppendLine("               BindData();");
            builder.AppendLine("             }");
            builder.AppendLine("        } ");
            builder.AppendLine("        private void entityFrm1_EditButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            DataGridView grid = this.entityFrm1.DataGridView; ");
            builder.AppendLine("            if (grid.SelectedRows.Count == 0) return; ");
            builder.AppendLine("            int ID = 0; ");
            builder.AppendLine("            if (grid.Columns.Contains(\"ColID\")) ");
            builder.AppendLine("                ID = grid.SelectedRows[0].Cells[\"ColID\"].Value.ToString().CastTo<int>(); ");
            builder.AppendLine("            else if (grid.Columns.Contains(\"ID\")) ");
            builder.AppendLine("                ID = grid.SelectedRows[0].Cells[\"ID\"].Value.ToString().CastTo<int>(); ");
            builder.AppendLine("            if (ID > 0) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                " + className + "FrmEdit frm = new " + className + "FrmEdit(); ");
            builder.AppendLine("                frm.Text = \"" + className + " 修改\"; ");
            builder.AppendLine("                frm.ID = ID; ");
            builder.AppendLine("                frm.OnDataSaved += frm_OnDataSaved; ");
            builder.AppendLine("                if (DialogResult.OK == frm.ShowDialog()) ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    BindData(); ");
            builder.AppendLine("                } ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine("        void frm_OnDataSaved(object sender, EventArgs e) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            BindData(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        private void entityFrm1_RefreshButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            BindData(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        private void entityFrm1_DelButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            if (MessageBox.Show(\"您确定删除选定的记录么?\",\"提示\") == DialogResult.No) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                return; ");
            builder.AppendLine("            } ");
            builder.AppendLine("            DataGridView grid = this.entityFrm1.DataGridView; ");
            builder.AppendLine("            if (grid != null) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                bool flg = false; ");
            builder.AppendLine("                foreach (DataGridViewRow row in grid.SelectedRows) ");
            builder.AppendLine("                { ");
            builder.AppendLine("                    int ID = 0; ");
            builder.AppendLine("                    if (grid.Columns.Contains(\"ColID\")) ");
            builder.AppendLine("                        ID = row.Cells[\"ColID\"].Value.ToString().CastTo<int>(); ");
            builder.AppendLine("                    else if (grid.Columns.Contains(\"ID\")) ");
            builder.AppendLine("                        ID = row.Cells[\"ID\"].Value.ToString().CastTo<int>(); ");
            builder.AppendLine("                    if (ID > 0) ");
            builder.AppendLine("                    { ");
            builder.AppendLine("                        BLLFactory<" + className + ">.Instance().DeleteEntity(ID); ");
            builder.AppendLine("                        flg = true; ");
            builder.AppendLine("                    } ");
            builder.AppendLine("                } ");
            builder.AppendLine("                if (flg) ");
            builder.AppendLine("                    BindData(); ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine("        private void entityFrm1_CloseFrmButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            this.Close(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        private void entityFrm1_ExportButtonClick( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            // 正在开发中....");
            builder.AppendLine("        } ");
            builder.AppendLine("        /// <summary> ");
            builder.AppendLine("        /// 编写初始化窗体的实现,可以用于刷新 ");
            builder.AppendLine("        /// </summary> ");
            builder.AppendLine("        public override void FormOnLoad( ) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            BindData(); ");
            builder.AppendLine("        } ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");
            if (path.Length > 0)
            {
                string folder = path + @"\WinFromBuild\" + Utils.NameSpace;
                Utils.FolderCheck(folder);
                string filename = folder + @"\" + className + "Frm.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
            #endregion

            #region {tablename}Frm.Designer.cs
            builder = new StringBuilder();
            builder.AppendLine("namespace " + Utils.NameSpaceUI);
            builder.AppendLine("{ ");
            builder.AppendLine("    partial class " + className + "Frm ");
            builder.AppendLine("    { ");
            builder.AppendLine("        private System.ComponentModel.IContainer components = null; ");
            builder.AppendLine("        protected override void Dispose(bool disposing) ");
            builder.AppendLine("        { ");
            builder.AppendLine("            if (disposing && (components != null)) ");
            builder.AppendLine("            { ");
            builder.AppendLine("                components.Dispose(); ");
            builder.AppendLine("            } ");
            builder.AppendLine("            base.Dispose(disposing); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        #region Windows Form Designer generated code ");
            builder.AppendLine("        private void InitializeComponent() ");
            builder.AppendLine("        { ");
            builder.AppendLine("            this.entityFrm1 = new MinGuiLuo.WinFromControls.Controls.EntityFrm(); ");
            builder.AppendLine("            this.SuspendLayout(); ");
            builder.AppendLine(" ");
            builder.AppendLine("      " + GetGridColumn(className, ShowFields));
            builder.AppendLine("            //  ");
            builder.AppendLine("            // entityFrm1 ");
            builder.AppendLine("            //  ");
            builder.AppendLine("            this.entityFrm1.Dock = System.Windows.Forms.DockStyle.Fill; ");
            builder.AppendLine("            this.entityFrm1.Location = new System.Drawing.Point(0, 0); ");
            builder.AppendLine("            this.entityFrm1.Name = \"entityFrm1\"; ");
            builder.AppendLine("            this.entityFrm1.Size = new System.Drawing.Size(576, 364); ");
            builder.AppendLine("            this.entityFrm1.TabIndex = 0; ");
            builder.AppendLine("            this.entityFrm1.AddButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_AddButtonClick); ");
            builder.AppendLine("            this.entityFrm1.EditButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_EditButtonClick); ");
            builder.AppendLine("            this.entityFrm1.DelButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_DelButtonClick); ");
            builder.AppendLine("            this.entityFrm1.ExportButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_ExportButtonClick); ");
            builder.AppendLine("            this.entityFrm1.RefreshButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_RefreshButtonClick); ");
            builder.AppendLine("            this.entityFrm1.CloseFrmButtonClick += new MinGuiLuo.WinFromControls.Controls.EntityFrm.ButtonClick(this.entityFrm1_CloseFrmButtonClick); ");
            builder.AppendLine("            //  ");
            builder.AppendLine("            // " + className + "Frm ");
            builder.AppendLine("            //  ");
            builder.AppendLine("            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); ");
            builder.AppendLine("            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; ");
            builder.AppendLine("            this.ClientSize = new System.Drawing.Size(576, 364); ");
            builder.AppendLine("            this.Controls.Add(this.entityFrm1); ");
            builder.AppendLine("            this.Font = new System.Drawing.Font(\"宋体\", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); ");
            builder.AppendLine("            this.Name = \"" + className + "Frm\"; ");
            builder.AppendLine("            this.Text = \"" + tableinfo + " \"; ");
            builder.AppendLine("            this.ResumeLayout(false); ");
            builder.AppendLine("        } ");
            builder.AppendLine("        #endregion ");
            builder.AppendLine("        private MinGuiLuo.WinFromControls.Controls.EntityFrm entityFrm1; ");
            builder.AppendLine("    } ");
            builder.AppendLine("} ");
            if (path.Length > 0)
            {
                string folder = path + @"\WinFromBuild\" + Utils.NameSpace;
                Utils.FolderCheck(folder);
                string filename = folder + @"\" + className + "Frm.Designer.cs";
                Utils.CreateFiles(filename, builder.ToString());
            }
            #endregion
        }
コード例 #24
0
        private string GenerateEasyUIFrom(TableModel tm)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("<table class=\"tb_searchbar\"> ");
            builder.AppendLine(" <tbody> ");
            var           list = tm.Columns;
            StringBuilder crto = new StringBuilder();

            for (int i = 0; i < list.Count; i++)
            {
                var    item = list[i];
                string isnull = "", validatebox = "";
                if (item.Isnullable && item.MaxLength > 0)
                {
                    isnull      = "<span style=\"color:red;\">*</span>";
                    validatebox = " data-options=\"required:true\" class=\"easyui-validatebox\" ";
                }

                if (cols.Contains(item.ColumnName))
                {
                    crto.AppendLine("<input type='hidden' id='" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "' name='" + tm.TableName.ToLower() + "_Entity" + item.ColumnName + "' value='' />");
                }
                else
                {
                    if (item.ColumnName.Contains("_"))
                    {
                        builder.AppendLine("                <tr> ");
                        builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                        builder.AppendLine("                    <td> ");
                        builder.AppendLine("<select id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" class='easyui-combotree' data-options='url:\"AjaxEasyUITree\"' style='width: 120px; height: 28px;' tabindex=\"" + i + "\" " + validatebox + "></select>");
                        builder.AppendLine("                    </td> ");
                        builder.AppendLine("                </tr> ");
                    }
                    else
                    {
                        switch (item.ColumnType.ToLower())
                        {
                        case "bool":
                            builder.AppendLine("                <tr> ");
                            builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                            builder.AppendLine("                    <td> ");
                            builder.AppendLine("                        <input type=\"radio\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "1\" name=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" value=\"true\" checked tabindex=\"" + i + "\" />是");
                            builder.AppendLine("                        <input type=\"radio\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "2\" name=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" value=\"false\" tabindex=\"" + i + "\" />否");
                            builder.AppendLine("                    </td> ");
                            builder.AppendLine("                </tr> ");
                            break;

                        default:
                            builder.AppendLine("                <tr> ");
                            builder.AppendLine("                    <td class=\"td_title\"><label style=\"color: black\" id=\"ff_lab_" + tm.TableName.ToLower() + "_" + item.ColumnName.ToLower() + "\">" + item.ColumnRemark + "" + isnull + "</label></td> ");
                            builder.AppendLine("                    <td> ");
                            builder.AppendLine("                        <input type=\"text\" id=\"" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "\" name=\"" + tm.TableName.ToLower() + "_Entity" + item.ColumnName + "\" value=\"  \" style=\"width:310px\" " + validatebox + " maxlength=\"" + item.MaxLength + "\" tabindex=\"" + i + "\" /> ");
                            builder.AppendLine("                    </td> ");
                            builder.AppendLine("                </tr> ");
                            break;
                        }
                    }
                }
            }
            builder.AppendLine("<tr><td  colspan='1'>" + crto.ToString() + "<td></tr>");
            builder.AppendLine(" </tbody> ");
            builder.AppendLine("</table> ");
            return(builder.ToString());
        }
コード例 #25
0
        private string GenerateEasyUITreeTableJs(TableModel tm)
        {
            var           list     = tm.Columns;
            StringBuilder builder  = new StringBuilder();
            StringBuilder builder1 = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            StringBuilder builder3 = new StringBuilder();
            StringBuilder builder4 = new StringBuilder();

            foreach (var item in list)
            {
                builder1.AppendLine(" $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(node." + item.ColumnName + "); ");
                builder2.AppendLine(" $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(''); ");
                builder3.AppendLine("var " + item.ColumnName + "= $('#" + tm.TableName.ToLower() + "_Entity_" + item.ColumnName + "').val(); ");
                builder4.Append("" + item.ColumnName + ": " + item.ColumnName + ",");
            }
            if (builder4.Length > 1)
            {
                builder4.Remove(builder4.Length - 1, 1);
            }

            builder.AppendLine("        var root = \"@(Url.BundlePContent(\"UIShell.RbacManagementPlugin\", \"" + tm.TableName + "\"))/\"; ");
            builder.AppendLine("        var added = true; ");
            builder.AppendLine("        var dicType; ");
            builder.AppendLine("        var LCL_" + tm.TableName.ToLower() + " = { ");
            builder.AppendLine("            showTree: function () { ");
            builder.AppendLine("                $('#uitree_" + tm.TableName.ToLower() + "').tree({ ");
            builder.AppendLine("                    url: root + 'AjaxEasyUITree_" + tm.TableName + "', ");
            builder.AppendLine("                    lines: true, ");
            builder.AppendLine("                    onClick: function (node) { ");
            builder.AppendLine("                        added = false; ");
            builder.AppendLine("                        var cc = node.id; ");
            builder.AppendLine("                        dicType = cc; ");
            builder.AppendLine("                        $('#parentid').val(node.parentId); ");
            builder.AppendLine("                        $('#parentname').val(node.parentName); ");
            builder.AppendLine(" ");
            builder.AppendLine(builder1.ToString());
            builder.AppendLine(" ");
            builder.AppendLine(" ");
            builder.AppendLine("                    } ");
            builder.AppendLine("                }); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            reload: function () { ");
            builder.AppendLine("                $('#uitree_" + tm.TableName.ToLower() + "').tree('reload'); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            getSelected: function () { ");
            builder.AppendLine("                return $('#uitree_" + tm.TableName.ToLower() + "').tree('getSelected'); ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            add: function () { ");
            builder.AppendLine("                var node = LCL_" + tm.TableName.ToLower() + ".getSelected(); ");
            builder.AppendLine("                if (node) { ");
            builder.AppendLine("                    //新增下级 ");
            builder.AppendLine("                    added = true; ");
            builder.AppendLine("                    $('#parentid').val(node.id); ");
            builder.AppendLine("                    $('#parentname').val(node.text); ");
            builder.AppendLine(" ");
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(" ");
            builder.AppendLine(" ");
            builder.AppendLine("                } ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            save: function () { ");
            builder.AppendLine(builder3.ToString());
            builder.AppendLine(" ");
            builder.AppendLine("                if (added) { ");
            builder.AppendLine("                    $.post(root + 'AjaxAdd', ");
            builder.AppendLine("                        { " + builder4.ToString() + " }, function (data) { ");
            builder.AppendLine("                            $.messager.alert('系统消息', data.Message); ");
            builder.AppendLine("                            //重新加载当前页 ");
            builder.AppendLine("                            LCL_" + tm.TableName.ToLower() + ".reload(); ");
            builder.AppendLine("                        }, \"json\"); ");
            builder.AppendLine("                } else { ");
            builder.AppendLine("                    $.post(root + 'AjaxEdit', ");
            builder.AppendLine("                        { " + builder4.ToString() + " }, function (data) { ");
            builder.AppendLine("                            $.messager.alert('系统消息', data.Message); ");
            builder.AppendLine("                            //重新加载当前页 ");
            builder.AppendLine("                            LCL_" + tm.TableName.ToLower() + ".reload(); ");
            builder.AppendLine("                        }, \"json\"); ");
            builder.AppendLine("                } ");
            builder.AppendLine("            }, ");
            builder.AppendLine("            del: function () { ");
            builder.AppendLine("                var node = LCL_" + tm.TableName.ToLower() + ".getSelected(); ");
            builder.AppendLine("                if (node) { ");
            builder.AppendLine("                    $.messager.confirm('确认', '确认要删除选中记录吗?', function (y) { ");
            builder.AppendLine("                        if (y) { ");
            builder.AppendLine("                            //提交 ");
            builder.AppendLine("                            $.post(root + 'AjaxDelete/', node.id, ");
            builder.AppendLine("                            function (msg) { ");
            builder.AppendLine("                                if (msg.Success) { ");
            builder.AppendLine("                                    $.messager.alert('提示', msg.Message, 'info', function () { ");
            builder.AppendLine("                                        //重新加载当前页 ");
            builder.AppendLine("                                        $('#grid_" + tm.TableName.ToLower() + "').datagrid('reload'); ");
            builder.AppendLine("                                    }); ");
            builder.AppendLine("                                } else { ");
            builder.AppendLine("                                    $.messager.alert('提示', msg.Message, 'info') ");
            builder.AppendLine("                                } ");
            builder.AppendLine("                            }, \"json\"); ");
            builder.AppendLine("                        } ");
            builder.AppendLine("                    }); ");
            builder.AppendLine("                } ");
            builder.AppendLine("                else { ");
            builder.AppendLine("                    alert('请选择'); ");
            builder.AppendLine("                } ");
            builder.AppendLine("                return false; ");
            builder.AppendLine("            } ");
            builder.AppendLine("        } ");
            builder.AppendLine("        $(document).ready(function () { ");
            builder.AppendLine("            LCL_" + tm.TableName.ToLower() + ".showTree(); ");
            builder.AppendLine("            $('#btnAdd" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".add(); }); ");
            builder.AppendLine("            $('#btnSave" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".save(); }); ");
            builder.AppendLine("            $('#btnDel" + tm.TableName.ToLower() + "').click(function () { LCL_" + tm.TableName.ToLower() + ".del(); }); ");
            builder.AppendLine("        }); ");

            return(builder.ToString());
        }
コード例 #26
0
        private void BuildEntity(string path)
        {
            List <TableModel> tableNames = BLLFactory.Instance.idb.GetTableModelList(Utils.dbName, true);

            for (int i = 0; i < tableNames.Count; i++)
            {
                TableModel tm        = tableNames[i];
                string     tablename = tm.TableName;
                string     tableInfo = tm.TableNameRemark;

                StringBuilder builder = new StringBuilder();
                builder.AppendLine("/*******************************************************  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 作者:罗敏贵  ");
                builder.AppendLine("* 说明: " + tableInfo + " ");
                builder.AppendLine("* 运行环境:.NET 4.5.0  ");
                builder.AppendLine("* 版本号:1.0.0  ");
                builder.AppendLine("*   ");
                builder.AppendLine("* 历史记录:  ");
                builder.AppendLine("*    创建文件 罗敏贵 " + DateTime.Now.ToLongDateString() + " ");
                builder.AppendLine("*   ");
                builder.AppendLine("*******************************************************/  ");
                builder.AppendLine("using System; ");
                builder.AppendLine("using System.Collections.Generic; ");
                builder.AppendLine("using System.Linq; ");
                builder.AppendLine("using System.Text; ");
                builder.AppendLine("using System.Threading.Tasks; ");
                builder.AppendLine(" ");
                builder.AppendLine("namespace " + Utils.NameSpace + " ");
                builder.AppendLine("{ ");
                builder.AppendLine("    /// <summary> ");
                builder.AppendLine("    /// " + tableInfo + " ");
                builder.AppendLine("    /// </summary> ");
                builder.AppendLine("    public partial class " + tablename + " : BaseModel ");
                builder.AppendLine("    { ");
                builder.AppendLine("        public " + tablename + "() ");
                builder.AppendLine("        { ");
                builder.AppendLine("             ");
                builder.AppendLine("        } ");
                foreach (TableColumn column in tm.Columns)
                {
                    builder.AppendLine("        /// <summary> ");
                    builder.AppendLine("        /// " + column.ColumnRemark + " ");
                    builder.AppendLine("        /// </summary> ");
                    builder.AppendLine("        public " + column.ColumnType + " " + column.ColumnName + " { get; set; } ");
                }
                builder.AppendLine("        ");
                builder.AppendLine(" ");
                builder.AppendLine(" ");
                builder.AppendLine("    } ");
                builder.AppendLine("} ");

                if (path.Length > 0)
                {
                    string folder = path + @"\LCL\Library\Entity\";
                    Utils.FolderCheck(folder);
                    string filename = folder + @"\" + tablename + ".cs";
                    Utils.CreateFiles(filename, builder.ToString());
                }
            }
        }