Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_tab">要转化的数据表</param>
        /// <param name="strtemplatefile">使用的模板文件</param>
        /// <param name="savepath">保存文件夹</param>
        private void FoarmatClassByTable(SOTable _tab, string strtemplatefile, string savepath)
        {
            ////模板路径
            //C:\Users\marke\Desktop\Kalman.Studio\Kalman.Studio\src\Kalman.Studio\bin\Debug\T4Template\Asp.Net\Ebboy\Entity\Model.tt
            TableHost host = new TableHost();

            host.Table = _tab;
            //模板路径
            host.TemplateFile = strtemplatefile;
            //要显示的属性列表
            host.ColumnList = _tab.ColumnList;

            Engine engine  = new Engine();
            var    sw      = new Stopwatch();
            var    content = File.ReadAllText(host.TemplateFile);
            //读取模板内容并替换表相关字段、名称内容
            string outputContent = engine.ProcessTemplate(content, host);

            StringBuilder sb = new StringBuilder();

            if (host.ErrorCollection.HasErrors)
            {
                foreach (CompilerError err in host.ErrorCollection)
                {
                    sb.AppendLine(err.ToString());
                }
                outputContent = outputContent + Environment.NewLine + sb.ToString();
            }

            string strsavepath = Path.Combine(savepath, (_tab.Name + CodeTypeHelper.GetExtention(_CodeType)));

            textEditorControl2.Text = outputContent;
            textEditorControl2.SaveFile(strsavepath);
        }
        private void BuildCodeByTableSchema(object item)
        {
            SOTable         table      = item as SOTable;
            List <SOColumn> columnList = table.ColumnList;//可能传入的是从PDObject对象转换过来的SODatabase对象

            if (columnList == null || columnList.Count == 0)
            {
                columnList = DbSchemaHelper.Instance.CurrentSchema.GetTableColumnList(table);
            }

            //生成代码文件
            TableHost host = new TableHost();

            host.Table        = table;
            host.ColumnList   = columnList;
            host.TemplateFile = templateFile;

            foreach (object obj in listBox3.Items)
            {
                string[] ss = obj.ToString().Split('|');

                host.SetValue(ss[0], ss[1].Replace("[<->]", "|"));
            }

            Engine engine = new Engine();

            string fileName  = string.Empty;
            string separator = txtFileNamePrefix.Text.Trim();

            if (separator != "")
            {
                fileName = string.Format("{0}{1}", table.Name.RemovePrefix(separator, 10), host.FileExtention);
            }
            else
            {
                fileName = string.Format("{0}{1}", table.Name, host.FileExtention);
            }

            string outputContent = engine.ProcessTemplate(File.ReadAllText(templateFile), host);
            string outputFile    = Path.Combine(outputPath, fileName);

            StringBuilder sb = new StringBuilder();

            if (host.ErrorCollection.HasErrors)
            {
                foreach (CompilerError err in host.ErrorCollection)
                {
                    sb.AppendLine(err.ToString());
                }
                outputContent = outputContent + Environment.NewLine + sb.ToString();
                outputFile    = outputFile + ".error";
            }

            if (Directory.Exists(outputPath) == false)
            {
                Directory.CreateDirectory(outputPath);
            }
            File.WriteAllText(outputFile, outputContent, Encoding.UTF8);
        }
        void IDisposableToolWindow.DisposeToolWindow()
        {
            ((DockPanel)Content).Children.Clear();
            TableHost.Dispose();
            _fontAndColorProvider.Dispose();

            _integration.AddWatch -= AddWatch;
        }
        private void DoBuild()
        {
            int finish = 0;
            int total  = listBox2.Items.Count;

            //遍历选中的表,一张表对应生成一个代码文件
            foreach (object item in listBox2.Items)
            {
                SOTable table     = item as SOTable;
                string  className = table.Name.RemovePrefix(tablePrefix, prefixLevel).Replace(" ", "");

                List <SOColumn> columnList = table.ColumnList;//可能传入的是从PDObject对象转换过来的SODatabase对象
                if (columnList == null || columnList.Count == 0)
                {
                    columnList = DbSchemaHelper.Instance.CurrentSchema.GetTableColumnList(table);
                }

                //生成代码文件
                TableHost host = new TableHost();
                host.Table        = table;
                host.ColumnList   = columnList;
                host.TemplateFile = templateFile;
                host.SetValue("NameSpace", nameSpace);
                host.SetValue("ClassName", className);
                host.SetValue("TablePrefix", tablePrefix);
                host.SetValue("ColumnPrefix", columnPrefix);
                host.SetValue("PrefixLevel", prefixLevel);

                Engine engine = new Engine();

                string outputContent = engine.ProcessTemplate(File.ReadAllText(templateFile), host);
                //string outputFile = Path.Combine(outputPath,string.Format("{0}.cs", className));
                string outputFile = Path.Combine(outputPath, string.Format("{0}{1}", className, host.FileExtention));

                StringBuilder sb = new StringBuilder();
                if (host.ErrorCollection.HasErrors)
                {
                    foreach (CompilerError err in host.ErrorCollection)
                    {
                        sb.AppendLine(err.ToString());
                    }
                    outputContent = outputContent + Environment.NewLine + sb.ToString();
                    outputFile    = outputFile + ".error";
                }

                if (Directory.Exists(outputPath) == false)
                {
                    Directory.CreateDirectory(outputPath);
                }
                File.WriteAllText(outputFile, outputContent, Encoding.UTF8);

                finish = finish + 1;
                int percent = ConvertUtil.ToInt32(finish * 100 / total, 0);

                backgroundWorker1.ReportProgress(percent, table);
            }//end build code foreach
        }
        public SliceVisualizerControl(IToolWindowIntegration integration)
        {
            _context    = integration.GetSliceVisualizerContext();
            DataContext = _context;
            InitializeComponent();

            var tableFontAndColor = new FontAndColorProvider();

            _table = new SliceVisualizerTable(_context, tableFontAndColor);
            TableHost.Setup(_table);
        }
Esempio n. 6
0
        /// <summary>
        /// 生成一个表
        /// </summary>
        /// <param name="table">表对象</param>
        /// <param name="templateItem">模板列表</param>
        /// <param name="savedFileName">保存到的文件名</param>
        /// <param name="paramData">参数数据</param>
        private String BuildTable(SOTable table, TemplateInfo templateItem, out String savedFileName)
        {
            List <SOColumn> columnList = table.ColumnList;//可能传入的是从PDObject对象转换过来的SODatabase对象

            //生成代码文件
            TableHost host = new TableHost(this.NameRuleConfig, this.TypeMapConfigList, table);

            host.Table        = table;
            host.ColumnList   = columnList;
            host.TemplateFile = templateItem.FilePath;

            // 额外参数追加
            if (this.ParamList != null && this.ParamList.Count > 0)
            {
                foreach (var item in this.ParamList)
                {
                    host.SetValue(item.ParamName, item.ParamValue);
                }
            }

            Engine engine          = new Engine();
            string templateContent = File.ReadAllText(templateItem.FilePath);
            var    outputContent   = engine.ProcessTemplate(templateContent, host);

            savedFileName = Path.Combine(this.SavePath, string.Format("{0}{1}", table.Name, host.FileExtention));
            if (String.IsNullOrWhiteSpace(host.OutputFileName) == false)
            {
                savedFileName = Path.Combine(this.SavePath, host.OutputFileName);
            }

            StringBuilder sb = new StringBuilder();

            if (host.ErrorCollection != null && host.ErrorCollection.HasErrors)
            {
                foreach (CompilerError err in host.ErrorCollection)
                {
                    sb.AppendLine(err.ToString());
                }

                return(sb.ToString());
            }

            if (Directory.Exists(this.SavePath) == false)
            {
                Directory.CreateDirectory(this.SavePath);
            }

            File.WriteAllText(savedFileName, outputContent, host.FileEncoding);

            return(String.Empty);
        }
        public VisualizerControl(IToolWindowIntegration integration, ActivateWindow activateWindow)
        {
            _context = integration.GetVisualizerContext();
            _context.PropertyChanged    += ContextPropertyChanged;
            _context.GroupFetched       += GroupFetched;
            _context.GroupFetching      += SetupDataFetch;
            _context.CellSelectionEvent += CellSelected;
            DataContext = _context;
            InitializeComponent();

            _wavemap = new WavemapImage(HeaderHost.WavemapImage, _context);
            _wavemap.NavigationRequested += NavigateToWave;
            HeaderHost.WavemapSelector.Setup(_context, _wavemap);
            _activateWindow = activateWindow;

            _integration           = integration;
            _integration.AddWatch += AddWatch;
            PropertyChangedEventManager.AddHandler(_context.Options.VisualizerOptions, OptionsChanged, "");
            PropertyChangedEventManager.AddHandler(_context.Options.DebuggerOptions, OptionsChanged, "");
            PropertyChangedEventManager.AddHandler(_context.Options.VisualizerAppearance, OptionsChanged, "");
            PropertyChangedEventManager.AddHandler(_context.Options.VisualizerColumnStyling, VisualizerColumnStylingPropertyChanged, "");

            _fontAndColorProvider = new FontAndColorProvider();
            _fontAndColorProvider.FontAndColorInfoChanged += RefreshDataStyling;
            _table = new VisualizerTable(
                _context.Options,
                _fontAndColorProvider,
                getValidWatches: () => _context?.BreakData?.Watches);
            _table.WatchStateChanged += (newWatchState, invalidatedRows) =>
            {
                _context.Options.DebuggerOptions.Watches.Clear();
                _context.Options.DebuggerOptions.Watches.AddRange(newWatchState);
                if (invalidatedRows != null)
                {
                    foreach (var row in invalidatedRows)
                    {
                        SetRowContentsFromBreakState(row);
                    }
                }
            };
            _table.SetScalingMode(_context.Options.VisualizerAppearance.ScalingMode);
            TableHost.Setup(_table);
            RestoreSavedState();
        }
Esempio n. 8
0
        public void DoBuildCode()
        {
            Config.MainForm.SetStatusText("正在生成代码...");
            textEditorControl1.SaveFile(gbTemplateFile.Text);

            TableHost host = new TableHost();

            host.Table        = this.Table;
            host.TemplateFile = gbTemplateFile.Text;

            List <SOColumn> columnList = new List <SOColumn>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[0].FormattedValue.ToString().ToLower() == "true")
                {
                    SOColumn c = row.DataBoundItem as SOColumn;
                    columnList.Add(c);
                }
            }

            host.ColumnList = columnList;
            Engine engine        = new Engine();
            var    sw            = new Stopwatch();
            var    content       = File.ReadAllText(host.TemplateFile);
            string outputContent = engine.ProcessTemplate(content, host);

            StringBuilder sb = new StringBuilder();

            if (host.ErrorCollection.HasErrors)
            {
                foreach (CompilerError err in host.ErrorCollection)
                {
                    sb.AppendLine(err.ToString());
                }
                outputContent = outputContent + Environment.NewLine + sb.ToString();
            }

            textEditorControl2.Text = outputContent;
            tabControl1.SelectedTab = tabPage2;
            textEditorControl2.Refresh();

            Config.MainForm.SetStatusText();
        }
Esempio n. 9
0
        private void DefaultWireButtonTo(ToolStripButton button, object presenter)
        {
            var method = presenter.GetType().GetMethod(button.Name);

            if (method == null)
            {
                return;
            }

            button.Click += (s, a) => {
                TableHost table     = null;
                var       parameter = method.GetParameters().FirstOrDefault(p => p.Name == "current");
                if (parameter != null)
                {
                    table = GetTableForParameter(parameter);
                }

                int selectedIndex = 0;
                if (table != null)
                {
                    selectedIndex = table.Table.Behavior <IRowSelectionBehavior>().SelectedRowIndex;
                }

                var parameters = BindParameters(((ToolStripButton)s), method);
                if (parameters == null)
                {
                    return;
                }
                method.Invoke(presenter, parameters);

                if (table != null)
                {
                    table.Table.Behavior <IRowSelectionBehavior>().MoveSelectionAt(selectedIndex);
                }
            };
        }
Esempio n. 10
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();


            #line default
            #line hidden
            this.Write("using System;\r\nusing System.ComponentModel;\r\nusing System.ComponentModel.DataAnno" +
                       "tations;\r\n\r\nnamespace ");

            #line 35 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".Core.Domain\r\n{\r\n\t/// <summary>\r\n    /// ");

            #line 38 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n    /// </summary>\r\n\t[Serializable]\r\n\tpublic partial class ");

            #line 41 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" : BaseEntity\r\n\t{\r\n\t\t");

            #line 43 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
            foreach (SOColumn c in list)
            {
            #line default
            #line hidden
                this.Write("/// <summary>\r\n        /// ");

            #line 45 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Comment == "" ? c.Name : c.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
                this.Write("\r\n        /// </summary>\r\n        ");

            #line 47 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Nullable?"":"[Required]"));

            #line default
            #line hidden
                this.Write("\r\n        [DisplayName(\"");

            #line 48 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Comment == "" ? c.Name : c.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
                this.Write("\")]\r\n\t\tpublic ");

            #line 49 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeUtil.DbType2TypeString(c.DataType)));

            #line default
            #line hidden
                this.Write(" ");

            #line 49 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(" { get; set; }\r\n\t\t\r\n\t\t");

            #line 51 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Entity\Model.tt"
            }

            #line default
            #line hidden
            this.Write("\t\t\r\n\t}\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 11
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();

            int    length         = tableName.Length;
            string controllerName = tableName + "Controller";
            string lowerTableName = tableName.Substring(0, 1).ToLower() + tableName.Substring(1, length - 1);
            string serviceName    = "_" + lowerTableName + "Service";


            #line default
            #line hidden
            this.Write("@model ");

            #line 36 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".Core.Domain.");

            #line 36 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@"
@{
    ViewBag.Title = ""Create"";
    Layout = ""~/Views/Shared/_LayoutSubMenu.cshtml"";
}

<div id=""content"" class=""same-hight height100 overflow-auto no-padding"">
    <!-- row -->
     <section id=""sub-menu"" class=""l custom-scroll"">
        <h4>@ViewBag.Title</h4>
        <ul class=""sub-nav-list"">
            <li class=""active"">
                <a href=""#"">@ViewBag.Title</a>
            </li>
			<li class="""">
                <a href=""#"">@ViewBag.Title</a>
            </li>
        </ul>
    </section>
    <!-- end row -->
    <!-- widget grid -->
    <section id=""widget-grid"" class=""r custom-scroll"">
        <!-- row -->
        <div class=""row"">
            <article class=""col-sm-12 col-md-12 col-lg-6"">
                <!-- Widget ID (each widget will need unique ID)-->
                <div class=""jarviswidget"" id=""wid-");

            #line 62 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@"-create""
                     data-widget-editbutton=""false""
                     data-widget-colorbutton=""false""
                     data-widget-togglebutton=""false""
                     data-widget-fullscreenbutton=""false""
                     data-widget-deletebutton=""false"">
                    <!-- widget div-->
                    <div>
                        <!-- widget content -->
                        <div class=""widget-body"">
                            @using (Html.BeginForm(""Create"", """);

            #line 72 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@""", FormMethod.Post, new { @class = ""form-horizontal"" }))
                            {
                                @Html.AntiForgeryToken()
                                <fieldset>
                                    <legend>@ViewBag.Title</legend>
                                    ");

            #line 77 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            foreach (SOColumn c in list)
            {
            #line default
            #line hidden
                this.Write("                                    <div class=\"form-group\">\r\n                   " +
                           "                     <label class=\"col-md-2 control-label\">@Html.LabelFor(model " +
                           "=> model.");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(")</label>\r\n                                        <div class=\"col-md-10\">\r\n     " +
                           "                                       @Html.TextBoxFor(model => model.");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(", new { @class = \"form-control\", @placeholder = \"");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write("\" })\r\n                                            <p class=\"note has-error\">@Html" +
                           ".ValidationMessageFor(model => model.");

            #line 83 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(")</p>\r\n                                        </div>\r\n                          " +
                           "          </div>\r\n                                     ");

            #line 86 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            }

            #line default
            #line hidden
            this.Write(@"                                </fieldset>
                                <fieldset>
                                    <div class=""form-group"">
                                        <div class=""col-md-9 col-md-offset-3"">
                                            <div id=""messages"" class=""has-error"">
                                                <small class=""help-block"" data-bv-validator=""notEmpty"" data-bv-for=""fullName"" data-bv-result=""INVALID"" style="""">@Html.ValidationSummary(true)</small>
                                            </div>
                                        </div>
                                    </div>
                                </fieldset>
                                <div class=""form-actions"">
                                    <div class=""row"">
                                        <div class=""col-md-12"">
                                            @Html.ActionLink(""返回"", ""Index"", """);

            #line 100 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Create.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@""", null, new { @class = ""btn btn-default"" })
                                            <input type=""submit"" value=""保存"" class=""btn btn-primary"" />
                                        </div>
                                    </div>
                                </div>
                            }
                        </div>
                        <!-- end widget content -->
                    </div>
                    <!-- end widget div -->
                </div>
                <!-- end widget -->
            </article>
        </div>
        <!-- end row -->
        <!-- row -->
        <div class=""row"">
            <!-- a blank row to get started -->
            <div class=""col-sm-12"">
                <!-- your contents here -->
            </div>
        </div>
        <!-- end row -->
    </section>
    <!-- end widget grid -->
</div>");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 12
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();

            int    length         = tableName.Length;
            string controllerName = tableName + "Controller";
            string lowerTableName = tableName.Substring(0, 1).ToLower() + tableName.Substring(1, length - 1);
            string serviceName    = "_" + lowerTableName + "Service";


            #line default
            #line hidden
            this.Write("using Ebboy.Core;\r\nusing Ebboy.Core.Domain;\r\nusing Ebboy.Core.PagedList;\r\nusing E" +
                       "bboy.Services.Users;\r\nusing Ebboy.Web.Framework.Controllers;\r\nusing System;\r\nusi" +
                       "ng System.Linq;\r\nusing System.Web.Mvc;\r\n\r\nnamespace ");

            #line 45 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".Controller\r\n{\r\n\t/// <summary>\r\n    /// ");

            #line 48 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n    /// </summary>\r\n\tpublic class ");

            #line 50 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(controllerName));

            #line default
            #line hidden
            this.Write(": UserBaseController\r\n\t{\r\n\t\t#region Fileds\r\n        private readonly ISystemUserS" +
                       "ervice _userService;\r\n        private readonly IWorkContext _workContext;\r\n     " +
                       "   private readonly I");

            #line 55 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service ");

            #line 55 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(";\r\n        #endregion\r\n\r\n        #region Ctor\r\n        public ");

            #line 59 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(controllerName));

            #line default
            #line hidden
            this.Write("(\r\n            ISystemUserService userService,\r\n            IWorkContext workCont" +
                       "ext,\r\n            I");

            #line 62 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service ");

            #line 62 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(lowerTableName));

            #line default
            #line hidden
            this.Write("Service)\r\n        {\r\n            _userService = userService;\r\n            _workCo" +
                       "ntext = workContext;\r\n            ");

            #line 66 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(" = ");

            #line 66 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(lowerTableName));

            #line default
            #line hidden
            this.Write(@"Service;
        }
        #endregion

        #region Action
        /// <summary>
        /// 首页列表
        /// </summary>
        /// <param name=""page""></param>
        /// <returns></returns>
        public ActionResult Index(int page = 1)
        {
            var pageOption = new PageOption() { PageIndex = page < 1 ? 1 : page };

            var list = ");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(".GetAllList();\r\n\r\n            var pageList = new PagedList<");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@">(list, pageOption);

            return View(pageList);
        }

        /// <summary>
        /// 详细
        /// </summary>
        /// <param name=""id""></param>
        /// <returns></returns>
        public ActionResult Details(int id)
        {
            var model = ");

            #line 94 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(@".GetById(id);
            return View(model);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public ActionResult Create()
        {
            return View();
        }

        /// <summary>
        /// 提交添加
        /// </summary>
        /// <param name=""model""></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Create(");

            #line 113 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" model)\r\n        {\r\n            try\r\n            {\r\n                if (!ModelSta" +
                       "te.IsValid)\r\n                {\r\n                    ModelState.AddModelError(\"\"," +
                       " \"实体参数错误!\");\r\n                    return View(model);\r\n                }\r\n\r\n    " +
                       "            ");

            #line 123 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(@".Insert(model);
                //this.Tips(""添加成功!"");
                return RedirectToAction(""Index"");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("""", ex.Message);
                return View(model);
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name=""id""></param>
        /// <returns></returns>
        public ActionResult Edit(int id)
        {
            var model = ");

            #line 141 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(".GetById(id);\r\n            return View(model);\r\n        }\r\n\r\n        /// <summary" +
                       ">\r\n        /// 修改\r\n        /// </summary>\r\n        /// <param name=\"model\"></par" +
                       "am>\r\n        /// <returns></returns>\r\n        [HttpPost]\r\n        public ActionR" +
                       "esult Edit(");

            #line 151 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@" model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("""", ""实体参数错误!"");
                    return View(model);
                }
                var entity = ");

            #line 160 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(".GetById(model.Id);\r\n                ");

            #line 161 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            foreach (SOColumn c in list)
            {
            #line default
            #line hidden
                this.Write("\t\t\t\tentity.");

            #line 163 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(" = model.");

            #line 163 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(";\r\n\t\t\t\t");

            #line 164 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            }

            #line default
            #line hidden
            this.Write("                ");

            #line 165 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(@".Update(entity);
                
                //this.Tips(""修改成功!"");
                return RedirectToAction(""Index"");
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("""", ex.Message);
                return View(model);
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name=""id""></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            var model = ");

            #line 184 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(@".GetById(id);
            return View(model);
        }

        /// <summary>
        /// 提交删除
        /// </summary>
        /// <param name=""id""></param>
        /// <param name=""collection""></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Delete(int id,");

            #line 195 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" model)\r\n        {\r\n            try\r\n            {\r\n                ");

            #line 199 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Controller\Controller.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(serviceName));

            #line default
            #line hidden
            this.Write(@".Delete(id);
                //this.Tips(""删除成功!"");
                return RedirectToAction(""Index"");
            }
            catch (Exception ex)
            {
                this.Tips(ex.Message);
                return RedirectToAction(""Index"");
            }
        }
        #endregion

        #region Utilities
        #endregion
	}
}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 13
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 20 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"

            TableHost       host       = (TableHost)(Host);
            SOTable         table      = host.Table;
            List <SOColumn> colList    = host.ColumnList;
            string          nameSpace  = host.GetString("NameSpace");
            string          className  = host.GetString("ClassName");
            string          authorName = host.GetString("Author");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }


            #line default
            #line hidden
            this.Write("//*******************************************************************************" +
                       "****\r\n// 文件名称:");

            #line 31 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("DAL.cs\r\n// 功能描述:");

            #line 32 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n// 数据表:");

            #line 33 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("\r\n// 作者:");

            #line 34 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(authorName));

            #line default
            #line hidden
            this.Write("\r\n// 日期:");

            #line 35 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToDateTimeString()));

            #line default
            #line hidden
            this.Write("\r\n// 修改记录:\r\n//*******************************************************************" +
                       "****************\r\n\r\nusing System;\r\nusing System.Data;\r\n\r\nnamespace ");

            #line 42 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write("\r\n{\r\n    using MySql.Data.MySqlClient;\r\n    using Xingji.Util;\r\n\r\n    /// <summar" +
                       "y>\r\n    /// ");

            #line 48 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n    /// </summary>\r\n    internal class ");

            #line 50 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("DAL : GameBaseDAL\r\n    {\r\n        #region 属性\r\n\r\n        // 定义表的所有字段(以,  进行分隔)\r\n  " +
                       "      const String columns = @\"");

            #line 55 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => tmp.Name))));

            #line default
            #line hidden
            this.Write("\";\r\n\r\n        // 定义此类所能用到的所有参数名称(以pn = ParameterName开始);双引号内是@+字段名称\r\n");

            #line 58 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        const String pn");

            #line 59 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(" = \"@");

            #line 59 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write("\";\r\n");

            #line 60 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write(@"
        //定义此类所能用到的所有sql语句(以Command结尾,表示为sql命令)
        static String getAllCommand = String.Empty;
        static String replaceCommand = String.Empty;
        static String insertCommand = String.Empty;
        static String updateCommand = String.Empty;
        static String deleteCommand = String.Empty;

        #endregion

        #region 构造函数

        /// <summary>
        /// 初始化此类所能用到的所有sql语句
        /// </summary>
        static ");

            #line 76 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("DAL()\r\n        {\r\n            getAllCommand = String.Format(\"SELECT {0} FROM `");

            #line 78 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("`;\", columns);\r\n            replaceCommand = \"REPLACE INTO `");

            #line 79 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("` SET ");

            #line 79 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("`{0}`=@{0}", tmp.Name)))));

            #line default
            #line hidden
            this.Write(" ;\";\r\n            insertCommand = \"INSERT INTO `");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("` (");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("`{0}`", tmp.Name)))));

            #line default
            #line hidden
            this.Write(") VALUES (");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("@{0}", tmp.Name)))));

            #line default
            #line hidden
            this.Write(");\";\r\n            updateCommand = \"UPDATE `");

            #line 81 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("` SET ");

            #line 81 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Where(tmp => !tmp.PrimaryKey).Select(tmp => String.Format("`{0}`=@{0}", tmp.Name)))));

            #line default
            #line hidden
            this.Write(" WHERE ");

            #line 81 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Where(tmp => tmp.PrimaryKey).Select(tmp => String.Format("`{0}`=@{0}", tmp.Name)))));

            #line default
            #line hidden
            this.Write(";\";\r\n            deleteCommand = \"DELETE FROM `");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("` WHERE ");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Where(tmp => tmp.PrimaryKey).Select(tmp => String.Format("`{0}`=@{0}", tmp.Name)))));

            #line default
            #line hidden
            this.Write(@";"";
        }

        #endregion

        #region 数据操作

        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns>数据列表</returns>
        public static DataTable GetAllList()
        {
            return ExecuteDataTable(getAllCommand);
        }

        /// <summary>
        /// 更新数据
        /// </summary>
");

            #line 101 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 102 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 102 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 103 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("        /// <returns>受影响的行数</returns>\r\n        public static Int32 ReplaceInfo(");

            #line 105 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n            //构造参数\r\n            MySqlParameter[] paramList = new My" +
                       "SqlParameter[]\r\n            {\r\n");

            #line 110 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("                new MySqlParameter(pn");

            #line 111 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(", ");

            #line 111 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("),\r\n");

            #line 112 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("            };\r\n\r\n            return ExecuteNonQuery(replaceCommand, paramList);\r" +
                       "\n        }\r\n\r\n        /// <summary>\r\n        /// 插入数据\r\n        /// </summary>\r\n");

            #line 121 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 122 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 122 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 123 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("        /// <returns>受影响的行数</returns>\r\n        public static Int32 InsertInfo(");

            #line 125 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n            //构造参数\r\n            MySqlParameter[] paramList = new My" +
                       "SqlParameter[]\r\n            {\r\n");

            #line 130 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("                new MySqlParameter(pn");

            #line 131 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(", ");

            #line 131 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("),\r\n");

            #line 132 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("            };\r\n\r\n            return ExecuteNonQuery(insertCommand, paramList);\r\n" +
                       "        }\r\n\r\n        /// <summary>\r\n        /// 更新数据\r\n        /// </summary>\r\n");

            #line 141 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 142 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 142 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 143 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("        /// <returns>受影响的行数</returns>\r\n        public static Int32 UpdateInfo(");

            #line 145 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n            //构造参数\r\n            MySqlParameter[] paramList = new My" +
                       "SqlParameter[]\r\n            {\r\n");

            #line 150 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("                new MySqlParameter(pn");

            #line 151 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(", ");

            #line 151 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("),\r\n");

            #line 152 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("            };\r\n\r\n            return ExecuteNonQuery(updateCommand, paramList);\r\n" +
                       "        }\r\n\r\n        /// <summary>\r\n        /// 删除数据\r\n        /// </summary>\r\n");

            #line 161 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList.Where(tmp => tmp.PrimaryKey))
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 162 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 162 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 163 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("        /// <returns>受影响的行数</returns>\r\n        public static Int32 DeleteInfo(");

            #line 165 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Where(tmp => tmp.PrimaryKey).Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n            //构造参数\r\n            MySqlParameter[] paramList = new My" +
                       "SqlParameter[]\r\n            {\r\n");

            #line 170 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            foreach (SOColumn item in colList.Where(tmp => tmp.PrimaryKey))
            {
            #line default
            #line hidden
                this.Write("                new MySqlParameter(pn");

            #line 171 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(", ");

            #line 171 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("),\r\n");

            #line 172 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\DAL.tt"
            }

            #line default
            #line hidden
            this.Write("            };\r\n\r\n            return ExecuteNonQuery(deleteCommand, paramList);\r\n" +
                       "        }\r\n\r\n        #endregion\r\n    }\r\n}\r\n");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 14
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();


            #line default
            #line hidden
            this.Write("using Ebboy.Core.Domain;\r\nusing System.Linq;\r\n\r\nnamespace ");

            #line 34 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".IServices\r\n{\r\n\t/// <summary>\r\n    /// ");

            #line 37 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n    /// </summary>\r\n\tpublic partial interface I");

            #line 39 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service\r\n\t{\r\n\t\t#region Interface\r\n        /// <summary>\r\n        /// 添加\r\n        " +
                       "/// </summary>\r\n        /// <param name=\"model\"></param>\r\n        void Insert(");

            #line 46 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" model);\r\n        /// <summary>\r\n        /// 修改\r\n        /// </summary>\r\n        " +
                       "/// <param name=\"model\"></param>\r\n        void Update(");

            #line 51 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@" model);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name=""id""></param>
        void Delete(int id);
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name=""id""></param>
        /// <returns></returns>
        ");

            #line 62 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" GetById(int id);\r\n        /// <summary>\r\n        /// 获取所有列表\r\n        /// </summa" +
                       "ry>\r\n        /// <returns></returns>\r\n        IQueryable<");

            #line 67 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\IService.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("> GetAllList();\r\n        #endregion\r\n\t}\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 15
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 20 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"

            TableHost       host                = (TableHost)(Host);
            SOTable         table               = host.Table;
            List <SOColumn> colList             = host.ColumnList;
            int             maxColumnNameLength = colList.Max(tmp => tmp.Name.Length);
            String          className           = String.Format("{0}Model", host.FormatName(table.Name));
            string          nameSpace           = className.FirstLower();

            // 设置输出文件名
            host.OutputFileName = className + ".go";


            #line default
            #line hidden
            this.Write("package ");

            #line 31 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write("\r\n\r\n// 模块名\r\nconst ModuleName = \"");

            #line 34 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("\"\r\n\r\n// 调度日志\r\ntype ");

            #line 37 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write(" struct {\r\n");

            #line 38 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            foreach (SOColumn c in colList)
            {
            #line default
            #line hidden
                this.Write("\r\n        // ");

            #line 40 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Comment == "" ? c.Name : c.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
                this.Write("\r\n        ");

            #line 41 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(" ");

            #line 41 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(host.GetTypeString(c)));

            #line default
            #line hidden
                this.Write(" `gorm:\"Column:");

            #line 41 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden

            #line 41 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.PrimaryKey?";PRIMARY_KEY":""));

            #line default
            #line hidden
                this.Write("\"`\r\n");

            #line 42 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            }

            #line default
            #line hidden
            this.Write("}\r\n\r\n// 表名\r\nfunc (this *");

            #line 46 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write(") TableName() string {\r\n\treturn \"");

            #line 47 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("\"\r\n}\r\n\r\n// 新建调度模型对象\r\nfunc New");

            #line 51 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("() *");

            #line 51 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write(" {\r\n\treturn &");

            #line 52 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("{}\r\n}\r\n\r\n// 新建调度模型对象\r\n");

            #line 56 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("// ");

            #line 57 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write(":");

            #line 57 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("\r\n");

            #line 58 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            }

            #line default
            #line hidden
            this.Write("func New");

            #line 59 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("2(");

            #line 59 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", tmp.Name.FirstLower(), host.GetTypeString(tmp))))));

            #line default
            #line hidden
            this.Write(") *");

            #line 59 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write(" {\r\n\treturn &");

            #line 60 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("{\r\n");

            #line 61 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("\t\t");

            #line 62 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(": ");

            #line 62 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(StringUtil.GetRepeatString(" ", maxColumnNameLength - item.Name.Length)));

            #line default
            #line hidden

            #line 62 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write(",\r\n");

            #line 63 "E:\testcode\csharp\ToolManager\Plugn.CodeGenerate\T4Template\SingleTableHost\Golang\Model\Model.tt"
            }

            #line default
            #line hidden
            this.Write("\t}\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 16
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();


            #line default
            #line hidden
            this.Write("using Ebboy.Core.Data;\r\nusing Ebboy.Core.Domain;\r\nusing System.Linq;\r\n\r\nnamespace" +
                       " ");

            #line 35 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".Services\r\n{\r\n\t/// <summary>\r\n    /// ");

            #line 38 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n    /// </summary>\r\n\tpublic partial class ");

            #line 40 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service: I");

            #line 40 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service\r\n\t{\r\n\t\t#region Fields\r\n        private readonly IRepository<");

            #line 43 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("> _repository;\r\n        #endregion\r\n\r\n        #region Ctor\r\n        public ");

            #line 47 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("Service(IRepository<");

            #line 47 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@"> repository)
        {
            _repository = repository;
        }
        #endregion

        #region Methods
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name=""model""></param>
        public virtual void Insert(");

            #line 58 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" model)\r\n        {\r\n            _repository.Insert(model);\r\n        }\r\n\r\n        " +
                       "/// <summary>\r\n        /// 修改\r\n        /// </summary>\r\n        /// <param name=\"" +
                       "model\"></param>\r\n        public virtual void Update(");

            #line 67 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@" model)
        {
            _repository.Update(model);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name=""model""></param>
        public virtual void Delete(int id)
        {
            _repository.Delete(GetById(id));
        }

        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name=""id""></param>
        /// <returns></returns>
        public virtual ");

            #line 86 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(" GetById(int id)\r\n        {\r\n           return  _repository.GetById(id);\r\n       " +
                       " }\r\n\r\n        /// <summary>\r\n        /// 获取所有信息\r\n        /// </summary>\r\n       " +
                       " /// <returns></returns>\r\n        public virtual IQueryable<");

            #line 95 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\Service\Service.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("> GetAllList()\r\n        {\r\n            return _repository.Table;\r\n        }\r\n    " +
                       "    #endregion\r\n\t}\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 17
0
        private void DoBuild()
        {
            int finish = 0;
            int total  = listBox2.Items.Count;

            //遍历选中的表,一张表对应生成一个代码文件
            foreach (object item in listBox2.Items)
            {
                SOTable table     = item as SOTable;
                string  className = table.Name;
                if (cbDeleteTablePrifix.Checked)
                {
                    className = table.Name.RemovePrefix(tablePrefix, prefixLevel).Replace(" ", "");
                }
                if (cbClassNamePascal.Checked)
                {
                    className = className.InitialToUpperMulti();
                }
                if (cbClassNameRemovePlural.Checked)
                {
                    className = className.EndsWith("s") ? className.TrimEnd('s') : className.Trim();
                }
                if (cbAddSuffix.Checked)
                {
                    className = txtClassPrefix.Text.Trim() + className + txtClassSuffix.Text.Trim();
                }

                templateFile = gbTemplateFile.Text;

                List <SOColumn> columnList = table.ColumnList;//可能传入的是从PDObject对象转换过来的SODatabase对象
                if (columnList == null || columnList.Count == 0)
                {
                    columnList = DbSchemaHelper.Instance.CurrentSchema.GetTableColumnList(table);
                }

                //生成代码文件
                TableHost host = new TableHost();
                host.Table        = table;
                host.ColumnList   = columnList;
                host.TemplateFile = templateFile;
                host.SetValue("NameSpace", nameSpace);
                host.SetValue("ClassName", className);
                host.SetValue("TablePrefix", tablePrefix);
                //host.SetValue("ColumnPrefix", columnPrefix);
                host.SetValue("PrefixLevel", prefixLevel);

                Engine engine          = new Engine();
                string templateContent = string.Empty;
                if (dicTemp.ContainsKey(templateFile))
                {
                    templateContent = dicTemp[templateFile];
                }
                else
                {
                    templateContent = File.ReadAllText(templateFile);
                    dicTemp.Add(templateFile, templateContent);
                }

                var outputContent = engine.ProcessTemplate(templateContent, host);
                //string outputFile = Path.Combine(outputPath, string.Format("{0}.cs", className));
                string outputFile = Path.Combine(outputPath, string.Format("{0}{1}", table.Name, host.FileExtention));
                if (cbClassNameIsFileName.Checked)
                {
                    outputFile = Path.Combine(outputPath, string.Format("{0}{1}", className, host.FileExtention));
                }

                StringBuilder sb = new StringBuilder();
                if (host.ErrorCollection != null && host.ErrorCollection.HasErrors)
                {
                    foreach (CompilerError err in host.ErrorCollection)
                    {
                        sb.AppendLine(err.ToString());
                    }
                    outputContent = outputContent + Environment.NewLine + sb.ToString();
                    outputFile    = outputFile + ".error";
                }

                if (Directory.Exists(outputPath) == false)
                {
                    Directory.CreateDirectory(outputPath);
                }
                File.WriteAllText(outputFile, outputContent, Encoding.UTF8);

                finish = finish + 1;
                int percent = ConvertUtil.ToInt32(finish * 100 / total, 0);

                backgroundWorker1.ReportProgress(percent, table);
            }//end build code foreach
        }
Esempio n. 18
0
        /// <summary>
        /// 生成
        /// </summary>
        private string Generate(string templateFile, string toDic)
        {
            string result = string.Empty;

            try
            {
                //遍历选中的表,一张表对应生成一个代码文件
                foreach (object item in listBox2.Items)
                {
                    SOTable table     = item as SOTable;
                    string  className = table.Name;
                    if (cbDeleteTablePrifix.Checked)
                    {
                        className = table.Name.RemovePrefix(tablePrefix, prefixLevel).Replace(" ", "");
                    }
                    if (cbClassNamePascal.Checked)
                    {
                        className = className.InitialToUpperMulti();
                    }
                    if (cbClassNameRemovePlural.Checked)
                    {
                        className = className.EndsWith("s") ? className.TrimEnd('s') : className.Trim();
                    }
                    if (cbAddSuffix.Checked)
                    {
                        className = txtClassPrefix.Text.Trim() + className + txtClassSuffix.Text.Trim();
                    }

                    List <SOColumn> columnList = table.ColumnList;//可能传入的是从PDObject对象转换过来的SODatabase对象
                    if (columnList == null || columnList.Count == 0)
                    {
                        columnList = DbSchemaHelper.Instance.CurrentSchema.GetTableColumnList(table);
                    }

                    //生成代码文件
                    TableHost host = new TableHost();
                    host.Table        = table;
                    host.ColumnList   = columnList;
                    host.TemplateFile = templateFile;
                    host.SetValue("NameSpace", nameSpace);
                    host.SetValue("ClassName", className);
                    host.SetValue("TablePrefix", tablePrefix);
                    //host.SetValue("ColumnPrefix", columnPrefix);
                    host.SetValue("PrefixLevel", prefixLevel);

                    Engine engine           = new Engine();
                    string templateContent  = string.Empty;
                    var    templateFileInfo = new FileInfo(templateFile);
                    if (dicTemp.ContainsKey(templateFile))
                    {
                        templateContent = dicTemp[templateFile];
                    }
                    else
                    {
                        templateContent = File.ReadAllText(templateFile);
                        dicTemp.Add(templateFile, templateContent);
                    }

                    var outputContent = engine.ProcessTemplate(templateContent, host);
                    var extName       = templateFileInfo.Name.Replace(templateFileInfo.Extension, ""); //模板名称

                    var    fileNameFormat = new StringBuilder("{0}");
                    string outputFile     = string.Empty;

                    if (cbTemplateName.Checked || cbClassNameIsFileName.Checked)
                    {
                        if (cbClassNameIsFileName.Checked && cbTemplateName.Checked)
                        {
                            outputFile = Path.Combine(toDic, string.Format("{0}{1}{2}", className, extName, host.FileExtention)); //类名和模板名作为文件名
                        }
                        else
                        {
                            if (cbClassNameIsFileName.Checked)
                            {
                                outputFile = Path.Combine(toDic, string.Format("{0}{1}", className, host.FileExtention)); //类名作为文件名
                            }
                            else if (cbTemplateName.Checked)
                            {
                                outputFile = Path.Combine(toDic, string.Format("{0}{1}", extName, host.FileExtention)); //模板名作为文件名
                            }
                        }
                    }
                    else
                    {
                        outputFile = Path.Combine(toDic, string.Format("{0}{1}", table.Name, host.FileExtention)); //表名作为文件名
                    }


                    StringBuilder sb = new StringBuilder();
                    if (host.ErrorCollection != null && host.ErrorCollection.HasErrors)
                    {
                        foreach (CompilerError err in host.ErrorCollection)
                        {
                            sb.AppendLine(err.ToString());
                        }
                        outputContent = outputContent + Environment.NewLine + sb.ToString();
                        outputFile    = outputFile + ".error";
                    }

                    if (Directory.Exists(toDic) == false)
                    {
                        Directory.CreateDirectory(toDic);
                    }
                    File.WriteAllText(outputFile, outputContent, Encoding.UTF8);
                    result = table.Name + "生成成功";
                    Config.Console(string.Format("根据模板文件“{0}”生成“{1}”成功!", templateFile, outputFile));
                    percent += 1;

                    backgroundWorkerGenerate.ReportProgress(percent, table.Name);
                }
            }
            catch (Exception ex)
            {
                Config.ConsoleException(ex);
                result = ex.Message;
                this.backgroundWorkerGenerate.CancelAsync(); //中止
            }

            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"

            TableHost       host      = (TableHost)(Host);
            SOTable         table     = host.Table;
            List <SOColumn> list      = host.ColumnList;
            string          nameSpace = host.GetString("NameSpace");
            string          className = host.GetString("ClassName");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }
            string tableName = table.Name.EndsWith("s") ?table.Name.TrimEnd('s') : table.Name.Trim();

            int    length         = tableName.Length;
            string controllerName = tableName + "Controller";
            string lowerTableName = tableName.Substring(0, 1).ToLower() + tableName.Substring(1, length - 1);
            string serviceName    = "_" + lowerTableName + "Service";


            #line default
            #line hidden
            this.Write("@model IPagedList<");

            #line 36 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write(".Core.Domain.");

            #line 36 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@">
@{
    ViewBag.Title = ""Index"";
    Layout = ""~/Views/Shared/_LayoutSubMenu.cshtml"";
}
<div id=""content"" class=""same-hight height100 overflow-auto no-padding"">
    <!-- row -->
     <section id=""sub-menu"" class="" l custom-scroll"">
        <h4>@ViewBag.Title</h4>
        <ul class=""sub-nav-list"">
            <li class=""active"">
                <a href=""#"">@ViewBag.Title</a>
            </li>
        </ul>
    </section>
    <!-- end row -->
    <!-- widget grid -->
    <section id=""widget-grid"" class=""r custom-scroll"">
         <!-- RIBBON -->
        <div id=""ribbon"" class=""no-padding"">
            <!-- breadcrumb -->
            <ol class=""breadcrumb"">
                <li>
                    @ViewBag.Title
                </li>
            </ol>
            <!-- end breadcrumb -->
            <span class=""ribbon-button-alignment pull-right"">
            </span>
        </div>
        <!-- END RIBBON -->
        <!-- row -->
        <div class=""row"">
            <!-- NEW WIDGET START -->
            <article class=""col-xs-12 col-sm-12 col-md-12 col-lg-12"">
                <!-- Widget ID (each widget will need unique ID)-->
                <div class=""jarviswidget"" id=""wid-");

            #line 72 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write("-index\"\r\n                     data-widget-editbutton=\"false\"\r\n                   " +
                       "  data-widget-colorbutton=\"false\"\r\n                     data-widget-togglebutton" +
                       "=\"false\"\r\n                     data-widget-fullscreenbutton=\"false\"\r\n           " +
                       "          data-widget-deletebutton=\"false\">\r\n                    <!-- widget div" +
                       "-->\r\n                    <div>\r\n                        <!-- widget edit box -->" +
                       "\r\n                        <div class=\"jarviswidget-editbox\">\r\n                  " +
                       "          <!-- This area used as dropdown edit box -->\r\n                        " +
                       "    <input class=\"form-control\" type=\"text\">\r\n                        </div>\r\n  " +
                       "                      <!-- end widget edit box -->\r\n                        <!--" +
                       " widget content -->\r\n                        <div class=\"widget-body\">\r\n        " +
                       "                    <div class=\"dt-toolbar bg-color-lightgray padding-top-5\">\r\n " +
                       "                               <div class=\"col-xs-12 col-sm-12\">\r\n\r\n            " +
                       "                        <div id=\"datatable_tabletools_filter\" class=\"dataTables_" +
                       "filter\">\r\n                                        <label class=\"pull-left\">\r\n   " +
                       "                                         <span class=\"input-group-addon width-au" +
                       "to no-bg no-border\">\r\n                                                关键字:\r\n    " +
                       "                                        </span>\r\n                               " +
                       "             <input type=\"search\" class=\"form-control txt_search_key\" placeholde" +
                       "r=\"\"\r\n                                                   aria-controls=\"datatabl" +
                       "e_tabletools\">\r\n                                        </label>\r\n              " +
                       "                          <label class=\"pull-left\">\r\n                           " +
                       "                 <button class=\"btn btn-default margin-left-15 btn_search\">查询</b" +
                       "utton>\r\n                                        </label>\r\n                      " +
                       "              </div>\r\n                                </div>\r\n                  " +
                       "          </div>\r\n                            <div class=\"dt-toolbar\">\r\n        " +
                       "                        <div class=\"col-md-6\">\r\n                                " +
                       "    <a href=\'@Url.Action(\"Create\",\"");

            #line 107 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));

            #line default
            #line hidden
            this.Write(@""")' id=""del"" class=""btn btn-success btn-sm"" data-title=""add"">添加</a>
                                </div>
                                <div class=""col-md-6"">
                                    <div class=""dataTables_length"">
                                        <label>
                                            <select name=""dt_basic_length"" aria-controls=""dt_basic"" class=""form-control"" id=""changeSize"">
                                                <option value=""10"">10</option>
                                                <option value=""20"">20</option>
                                                <option value=""30"">30</option>
                                                <option value=""50"">50</option>
                                                <option value=""100"">100</option>
                                            </select>
                                        </label>
                                    </div>
                                </div>

                            </div>
                            <table id=""datatable_fixed_column"" class=""table table-bordered"">
                                <thead>
                                <tr>
                                    ");

            #line 127 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            foreach (SOColumn c in list)
            {
            #line default
            #line hidden
                this.Write("                                    <th>\r\n                                       " +
                           " @Html.DisplayNameFor(model => model.");

            #line 130 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(")\r\n                                    </th>\r\n                                   " +
                           " ");

            #line 132 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            }

            #line default
            #line hidden
            this.Write(@"                                    <th></th>
                                </tr>
								</thead>
                                <tbody>
                                @foreach (var item in Model)
                                {
                                    <tr>
                                        ");

            #line 140 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            foreach (SOColumn c in list)
            {
            #line default
            #line hidden
                this.Write("                                        <td>\r\n                                   " +
                           "         @Html.DisplayFor(modelItem => item.");

            #line 143 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(")\r\n                                        </td>\r\n                               " +
                           "         ");

            #line 145 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\Asp.Net\Ebboy\View\Index.tt"
            }

            #line default
            #line hidden
            this.Write("                                        <td>\r\n                                   " +
                       "         @Html.ActionLink(\"修改\", \"Edit\", new { id = item.Id }, new { @class = \"bt" +
                       "n btn-primary btn-xs\" })\r\n                                            @Html.Acti" +
                       "onLink(\"详细\", \"Details\", new { id = item.Id }, new { @class = \"btn btn-info btn-x" +
                       "s\" })\r\n                                            @Html.ActionLink(\"删除\", \"Delet" +
                       "e\", new { id = item.Id }, new { @class = \"btn btn-danger btn-xs\" })\r\n           " +
                       "                             </td>\r\n                                    </tr>\r\n " +
                       "                               }\r\n                                 </tbody>\r\n   " +
                       "                         </table>\r\n                            <div class=\"dt-to" +
                       "olbar-footer\">\r\n                                    <div class=\"col-xs-12 col-sm" +
                       "-3\">\r\n                                        <div class=\"dataTables_info\" id=\"d" +
                       "t_basic_info\" role=\"status\" aria-live=\"polite\">第 <span class=\"txt-color-darken\">" +
                       "@Model.CurrentPageIndex</span> /<span class=\"txt-color-darken\">@Model.TotalPageC" +
                       "ount</span>页,共<span class=\"text-primary\">@Model.TotalItemCount</span> 条记录</div>\r" +
                       "\n                                    </div>\r\n                                   " +
                       " <div class=\"col-md-9\">\r\n                                        <div class=\"dat" +
                       "aTables_paginate paging_simple_numbers\" id=\"datatable_tabletools_paginate\">\r\n   " +
                       "                                         @Html.Pager(Model, new PagerOptions\r\n  " +
                       "                          {\r\n                                PageIndexParameterN" +
                       "ame = \"page\",\r\n                                ShowGoButton = false\r\n           " +
                       "                 },\r\n                                                 new { @id " +
                       "= \"bootstrappager\", @class = \"pagination pagination-sm\" })\r\n                    " +
                       "                    </div>\r\n                                    </div>\r\n\r\n\r\n    " +
                       "                            </div>\r\n                        </div>\r\n            " +
                       "            <!-- end widget content -->\r\n                    </div>\r\n           " +
                       "         <!-- end widget div -->\r\n                </div>\r\n                <!-- e" +
                       "nd widget -->\r\n            </article>\r\n            <!-- WIDGET END -->\r\n        " +
                       "</div>\r\n        <!-- end row -->\r\n        <!-- row -->\r\n        <div class=\"row\"" +
                       ">\r\n            <!-- a blank row to get started -->\r\n            <div class=\"col-" +
                       "sm-12\">\r\n                <!-- your contents here -->\r\n            </div>\r\n      " +
                       "  </div>\r\n        <!-- end row -->\r\n    </section>\r\n    <!-- end widget grid -->" +
                       "\r\n</div>\r\n@section scripts{\r\n   @Scripts.Render(\"~/scripts/filter-datatables\")\r\n" +
                       "}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 20
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 21 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"

            TableHost       host       = (TableHost)(Host);
            SOTable         table      = host.Table;
            List <SOColumn> colList    = host.ColumnList;
            string          nameSpace  = host.GetString("NameSpace");
            string          className  = host.GetString("ClassName");
            string          authorName = host.GetString("Author");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }


            #line default
            #line hidden
            this.Write("//*******************************************************************************" +
                       "****\r\n// 文件名称:");

            #line 32 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write(".cs\r\n// 功能描述:");

            #line 33 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n// 数据表:");

            #line 34 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("\r\n// 作者:");

            #line 35 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(authorName));

            #line default
            #line hidden
            this.Write("\r\n// 日期:");

            #line 36 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToDateTimeString()));

            #line default
            #line hidden
            this.Write("\r\n// 修改记录:\r\n//*******************************************************************" +
                       "****************\r\n\r\nusing System;\r\nusing System.Data;\r\n\r\nnamespace ");

            #line 43 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameSpace));

            #line default
            #line hidden
            this.Write("\r\n{\r\n    /// <summary>\r\n    /// 充值日志\r\n    /// </summary>\r\n    public class ");

            #line 48 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("\r\n    {\r\n        #region 属性\r\n");

            #line 51 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn c in colList)
            {
            #line default
            #line hidden
                this.Write("\r\n        /// <summary>\r\n        /// ");

            #line 54 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Comment == "" ? c.Name : c.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
                this.Write("\r\n        /// </summary>\r\n        public ");

            #line 56 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeUtil.DbType2CSharpTypeString(c.DataType)));

            #line default
            #line hidden
                this.Write(" ");

            #line 56 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(c.Name));

            #line default
            #line hidden
                this.Write(" { get; set; }\t\t\r\n");

            #line 57 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n        #endregion\r\n\r\n        #region 构造函数\r\n\r\n        /// <summary>\r\n        //" +
                       "/ 构造函数\r\n        /// </summary>\r\n");

            #line 66 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 67 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 67 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 68 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("        public ");

            #line 69 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("(");

            #line 69 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n");

            #line 71 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("            this.");

            #line 72 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(" = ");

            #line 72 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write(";\r\n");

            #line 73 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("        }\r\n\r\n        /// <summary>\r\n        /// 构造函数\r\n        /// </summary>\r\n   " +
                       "     /// <param name=\"dr\">DataRow</param>\r\n        public ");

            #line 80 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("(DataRow dr)\r\n        {\r\n");

            #line 82 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("            this.");

            #line 83 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(" = Convert.To");

            #line 83 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(TypeUtil.DbType2CSharpTypeString(item.DataType)));

            #line default
            #line hidden
                this.Write("(dr[GamePropertyName.");

            #line 83 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write("]);\r\n");

            #line 84 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("        }\r\n\r\n        #endregion\r\n\r\n        #region 方法\r\n\r\n        /// <summary>\r\n " +
                       "       /// 构造函数\r\n        /// </summary>\r\n");

            #line 94 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("        /// <param name=\"");

            #line 95 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write("\">");

            #line 95 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Comment));

            #line default
            #line hidden
                this.Write("</param>\r\n");

            #line 96 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("        public void ConstructObject(");

            #line 97 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(String.Join(", ", colList.Select(tmp => String.Format("{0} {1}", TypeUtil.DbType2CSharpTypeString(tmp.DataType), tmp.Name.FirstLower())))));

            #line default
            #line hidden
            this.Write(")\r\n        {\r\n");

            #line 99 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            foreach (SOColumn item in colList)
            {
            #line default
            #line hidden
                this.Write("            this.");

            #line 100 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));

            #line default
            #line hidden
                this.Write(" = ");

            #line 100 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name.FirstLower()));

            #line default
            #line hidden
                this.Write(";\r\n");

            #line 101 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\Model.tt"
            }

            #line default
            #line hidden
            this.Write("        }\r\n\r\n        #endregion\r\n    }\r\n}");
            return(this.GenerationEnvironment.ToString());
        }
Esempio n. 21
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            #line 20 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"

            TableHost       host       = (TableHost)(Host);
            SOTable         table      = host.Table;
            List <SOColumn> colList    = host.ColumnList;
            string          nameSpace  = host.GetString("NameSpace");
            string          className  = host.GetString("ClassName");
            string          authorName = host.GetString("Author");
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "Entity";
            }
            if (string.IsNullOrEmpty(className))
            {
                className = table.Name;
            }


            #line default
            #line hidden
            this.Write("//*******************************************************************************" +
                       "****\r\n// 文件名称:");

            #line 31 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(className));

            #line default
            #line hidden
            this.Write("BLL.cs\r\n// 功能描述:");

            #line 32 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Comment == "" ? table.Name : table.Comment.Replace("\r\n", " ")));

            #line default
            #line hidden
            this.Write("\r\n// 数据表:");

            #line 33 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(table.Name));

            #line default
            #line hidden
            this.Write("\r\n// 作者:");

            #line 34 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(authorName));

            #line default
            #line hidden
            this.Write("\r\n// 日期:");

            #line 35 "E:\testCode\CsharpCode\Kalman.Studio\src\Kalman.Studio\T4Template\CSharp\Global\BLL_List.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToDateTimeString()));

            #line default
            #line hidden
            this.Write("\r\n// 修改记录:\r\n//*******************************************************************" +
                       "****************");
            return(this.GenerationEnvironment.ToString());
        }