예제 #1
0
        private string GetController(string dbname, string solutionName, string projectName, MVCPageSetup table)
        {
            var           tableName = table.TableName;
            var           viewName  = table.ViewName;
            var           areaName  = table.Area;
            StringBuilder sb        = new StringBuilder();

            sb.AppendLine(GetMethod_Constructer());
            sb.AppendLine();
            sb.AppendLine(GetMethod_DataSource(dbname, viewName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Detail(dbname, viewName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Insert_Open(viewName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Insert_Commit(dbname, tableName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Update_Open(dbname, viewName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Update_Commit(dbname, tableName));
            sb.AppendLine();
            sb.AppendLine(GetMethod_Delete(dbname, tableName));
            sb.AppendLine();
            var controllerClassContent = sb.ToString();

            sb.Clear();
            sb.AppendLine(string.Format("using {0}.BusinessData;", solutionName));
            sb.AppendLine(string.Format("using {0}.BusinessAccess;", solutionName));
            sb.AppendLine("using Infoline.Web.Utility;");
            sb.AppendLine("using Kendo.Mvc.Extensions;");
            sb.AppendLine("using Kendo.Mvc.UI;");
            sb.AppendLine("using System;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using System.Linq;");
            sb.AppendLine("using System.Web.Mvc;");
            sb.AppendLine("");

            sb.AppendFormat("namespace {0}.Areas.{1}.Controllers\r\n", projectName, areaName);
            sb.AppendLine("{");
            sb.AppendFormat("\tpublic class {0}Controller : Controller\r\n", viewName);
            sb.AppendLine("\t{");
            sb.AppendLine(controllerClassContent);
            sb.AppendLine("\t}");
            sb.AppendLine("}");

            var controllerContent = sb.ToString();

            return(controllerContent);
        }
예제 #2
0
        private Dictionary <string, string> GetViews(SqlConnection con, string solutionName, MVCPageSetup page)
        {
            var result         = new Dictionary <string, string>();
            var objArrRestrict = new string[] { null, null, page.ViewName, null };
            var columns        = con.GetSchema("Columns", objArrRestrict);

            var tableName          = page.TableName;
            var viewName           = page.ViewName;
            var areaName           = page.Area;
            var controllerLocation = string.Format("Areas/{0}/Controllers/{1}Controller.cs", areaName, viewName);
            var indexPageLocation  = string.Format("Areas/{0}/Views/{1}/Index.cshtml", areaName, viewName);
            var deatilPageLocation = string.Format("Areas/{0}/Views/{1}/Detail.cshtml", areaName, viewName);
            var insertPageLocation = string.Format("Areas/{0}/Views/{1}/Insert.cshtml", areaName, viewName);
            var updatePageLocation = string.Format("Areas/{0}/Views/{1}/Update.cshtml", areaName, viewName);

            result.Add(indexPageLocation, GetPageIndex(solutionName, areaName, viewName, columns));
            result.Add(deatilPageLocation, GetPage_Detail(solutionName, viewName, columns));
            result.Add(insertPageLocation, GetPage_Insert(solutionName, viewName, columns));
            result.Add(updatePageLocation, GetPage_Update(solutionName, viewName, columns));

            return(result);
        }