コード例 #1
0
        private void RenderInterface(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace);
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public interface I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " : ICRUD" + _script.Settings.DataOptions.ClassSuffix.Name + "<" + StringFormatter.CleanUpClassName(table.Name) + ">");
            _output.autoTabLn("{");
            _output.tabLevel--;

            _dataStore.Interface(table);

            _output.tabLevel++;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs");
            SaveOutput(CreateFullPath(_script.Settings.DataOptions.DataObjectsNamespace + "\\Interfaces", "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs"), SaveActions.DontOverwrite);
        }
コード例 #2
0
        private void RenderInterface(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public interface I" + StringFormatter.CleanUpClassName(table.Name) + "Service : IService<" + StringFormatter.CleanUpClassName(table.Name) + ">");
            _output.autoTabLn("{");

            // Updated 7/15/2014 - set a custom member for SiteSettings - used by King Wilder
            if (table.Name == "SiteSetting")
            {
                _output.tabLevel++;
                _output.autoTabLn("SiteSetting GetByKey(string key);");
                _output.tabLevel--;
            }

            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    I" + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Interfaces", "I" + StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
        }
        private void RenderConcreteRepositoryClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.DataOptions.DataObjectsNamespace + ".Repositories");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " : RepositoryBase<" + StringFormatter.CleanUpClassName(table.Name) + ">, I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name);
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + "(IUnitOfWork unitOfWork):base(unitOfWork)");
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs");
            SaveOutput(CreateFullPath(_script.Settings.DataOptions.DataObjectsNamespace + "\\Repositories", StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs"), SaveActions.DontOverwrite);
        }
コード例 #4
0
        private void RenderInterface(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            try
            {
                _output.autoTabLn("using System;");
                _output.autoTabLn("using System.Collections.Generic;");
                _output.autoTabLn("using System.Linq;");
                _output.autoTabLn("using System.Text;");
                _output.autoTabLn("");
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
                _output.autoTabLn("{");
                _output.autoTabLn("    public interface I" + StringFormatter.CleanUpClassName(table.Name) + "Service : ICRUDService<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">");
                _output.autoTabLn("    {");
                _output.tabLevel++;
                _output.autoTabLn(_context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " GetById(" + _context.Utility.RenderConcreteMethodParameters(table) + ");");
                _output.autoTabLn("List<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows);");
                _output.autoTabLn("int GetCount();");
                _output.tabLevel--;
                _output.autoTabLn("    }");
                _output.autoTabLn("}");

                _context.FileList.Add("    I" + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
                SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace + "\\Interfaces", "I" + StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
            }
            catch (Exception ex)
            {
                throw new Exception("Error rendering RenderServiceLayerInterface  - " + ex.Message);
            }
        }
コード例 #5
0
        /// <summary>
        /// This simply creates a code-block that will print to the output screen
        /// in MyGeneration that contains the mapped code for the Ninject references.
        /// I will just copy this code and paste it into the Ninject class in my project.
        /// </summary>
        public void Render()
        {
            foreach (string tableName in _script.Tables)
            {
                ITable table = _database.Tables[tableName];
                _output.tabLevel++;
                _output.tabLevel++;
                _output.tabLevel++;

                _output.autoTabLn("kernel.Bind<I" + StringFormatter.CleanUpClassName(table.Name) + "Repository>().To<" + StringFormatter.CleanUpClassName(table.Name) + "Repository>();");

                _output.tabLevel--;
                _output.tabLevel--;
                _output.tabLevel--;
            }

            _output.tabLevel++;
            _output.tabLevel++;
            _output.tabLevel++;

            _output.autoTabLn("kernel.Bind<IAuthRepository>().To<AuthRepository>();");

            _output.tabLevel--;
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #6
0
        public void GetAllWithSortingAndPaging(ITable table)
        {
            string tableName = table.Name;
            string model     = _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName);
            string entity    = _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.ORMFramework.Selected + "." + StringFormatter.CleanUpClassName(tableName);

            _output.tabLevel++;
            _output.tabLevel++;

            _output.autoTabLn("public List<" + model + "> GetAll(string sortExpression, int startRowIndex, int maximumRows)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;

            _output.autoTabLn("IQueryable<" + entity + "> query = context." + StringFormatter.CleanUpClassName(tableName, true) + ".AsQueryable().OrderBy(sortExpression);");
            _output.autoTabLn("query = query.Skip(startRowIndex).Take(maximumRows);");
            _output.autoTabLn("var list = new List<" + model + ">();");
            _output.autoTabLn("foreach (" + entity + " entity in query)");
            _output.tabLevel++;
            _output.autoTabLn("list.Add(entity.ToBusinessObject());");
            _output.tabLevel--;
            _output.autoTabLn("return list;");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #7
0
        public void GetAll(MyMeta.ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// GetAll and map the fields to the entity");
            _output.autoTabLn("/// and add to generic queryable collection.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <returns></returns>");

            _output.autoTabLn("public List<" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + "> GetAll()");
            _output.autoTabLn("{");

            _output.tabLevel++;

            _output.autoTabLn("using (var context = DataContextFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("return context." + StringFormatter.CleanUpClassName(StringFormatter.MakePlural(tableName)) + ".Select(o => " + StringFormatter.CleanUpClassName(tableName) + "Mapper.ToBusinessObject(o)).ToList();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #8
0
        private void RenderDaoInterface(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public interface I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " : ICRUD" + _script.Settings.DataOptions.ClassSuffix.Name + "<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + ">");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + " GetById(" + _context.Utility.RenderConcreteMethodParameters(table) + ");");
            _output.autoTabLn("List<" + _context.Utility.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(table.Name)) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows);");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs");
            SaveOutput(CreateFullPath(_script.Settings.DataOptions.DataObjectsNamespace + "\\Interfaces", "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs"), SaveActions.DontOverwrite);
        }
コード例 #9
0
        public void GetAllWithSortingAndPaging(MyMeta.ITable table)
        {
            string tableName = table.Name;
            string model     = _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName);
            string entity    = _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.ORMFramework.Selected + "." + StringFormatter.CleanUpClassName(tableName);

            _output.tabLevel++;
            _output.tabLevel++;

            _output.autoTabLn("public List<" + model + "> GetAll(string sortExpression, int startRowIndex, int maximumRows)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("using (var context = DataContextFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("IQueryable<" + entity + "> query = context." + StringFormatter.CleanUpClassName(StringFormatter.MakePlural(tableName)) + ";");
            _output.autoTabLn("query = GetListSort(query, sortExpression);");
            _output.autoTabLn("query = query.Skip(startRowIndex).Take(maximumRows);");
            _output.autoTabLn("return query.Select(o => " + StringFormatter.CleanUpClassName(tableName) + "Mapper.ToBusinessObject(o)).ToList();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #10
0
        public void Write()
        {
            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("using System.ComponentModel.DataAnnotations;");
            _output.autoTabLn("using System.ComponentModel;");
            _output.autoTabLn("using System.Web.Mvc;");

            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.BusinessObjects.BusinessObjectsNamespace);
            _output.autoTabLn("{");
            _output.tabLevel++;

            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(_table.Name));
            _output.autoTabLn("{");
            _output.tabLevel++;

            _output.autoTabLn("#region Properties");
            RenderProperties(_table);
            _output.autoTabLn("#endregion");

            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");

            _output.tabLevel--;
            _output.autoTabLn("}");
        }
コード例 #11
0
        private void BuildViewDataClass(MyMeta.ITable table, bool useUIDtos)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using System.Web;");
            _output.autoTabLn("");
            if (useUIDtos)
            {
                _output.autoTabLn("using " + _script.Settings.UI.UINamespace + ".Models;");
            }
            else
            {
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            }
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.UI.UINamespace + ".ViewData");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "ViewData : BaseViewData");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + ((useUIDtos) ? "Model" : "") + " " + StringFormatter.CleanUpClassName(table.Name) + " { get; set; }");
            _output.autoTabLn("public List<" + StringFormatter.CleanUpClassName(table.Name) + ((useUIDtos) ? "Model" : "") + "> " + StringFormatter.CleanUpClassName(table.Name) + "List { get; set; }");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "ViewData.cs");
            SaveOutput(CreateFullPath(_script.Settings.UI.UINamespace + "\\ViewData", StringFormatter.CleanUpClassName(table.Name) + "ViewData.cs"), SaveActions.DontOverwrite);
        }
コード例 #12
0
        public void Render()
        {
            string tableName = _table.Name;

            foreach (IForeignKey key in _table.ForeignKeys)
            {
                output.autoTabLn("[DataMember]");
                if (_script.Tables.Contains(key.ForeignTable.Name))
                {
                    if (key.PrimaryTable.Name == tableName)
                    {
                        output.autoTabLn("public " + StringFormatter.CleanUpClassName(key.ForeignTable.Name) + "Dto[] " + StringFormatter.CleanUpClassName(key.ForeignTable.Name) + "List { get; set; }");
                    }
                }

                if (_script.Tables.Contains(key.PrimaryTable.Name))
                {
                    if (key.PrimaryTable.Name != tableName)
                    {
                        output.autoTabLn("public " + StringFormatter.CleanUpClassName(key.PrimaryTable.Name) + "Dto " + StringFormatter.CleanUpClassName(key.PrimaryTable.Name) + " { get; set; }");
                    }
                }
            }
            output.writeln("");
        }
コード例 #13
0
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Service : " + StringFormatter.CleanUpClassName(table.Name) + "ServiceBase, I" + StringFormatter.CleanUpClassName(table.Name) + "Service");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel++;
            _output.autoTabLn(": base(" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel--;
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace, StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
        }
コード例 #14
0
        public void Update(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Update " + StringFormatter.CleanUpClassName(tableName) + ".  Map  fields to " + StringFormatter.CleanUpClassName(tableName) + " properties.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CleanUpClassName(tableName) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Update(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            GenTable genTable = new GenTable(table, _context);
            string   args     = "";
            string   keys     = "";
            string   types    = "";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args  += genTable.GetPrimaryKeyTypes[i] + " ";
                args  += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys  += StringFormatter.PascalCasing(genTable.GetPrimaryKeyNames[i]) + ",";
                types += genTable.GetPrimaryKeyTypes[i] + ",";
            }
            // trim the trailing ", "
            args  = args.Substring(0, (args.Length - 2));
            keys  = keys.Substring(0, (keys.Length - 1));
            types = types.Substring(0, (types.Length - 1));

            _output.autoTabLn("if (entity.LoadByPrimaryKey(model." + keys + "))");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("entity = model.ToEntity(entity);");
            _output.autoTabLn("entity.Save();");
            _output.autoTabLn("");

            string[] keysSplit  = keys.Split(',');
            string[] argsSplit  = args.Split(',');
            string[] typesSplit = types.Split(',');
            int      counter    = 0;

            foreach (string key in keysSplit)
            {
                _output.autoTabLn("model." + key.Trim() + " = (" + typesSplit[counter] + ")entity." + key.Trim() + ";");
                counter++;
            }

            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.tabLevel--;
        }
コード例 #15
0
        private void RenderInterface(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _commonGenerators.RenderDaoInterface(table);

            _context.FileList.Add("    " + "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs");
            SaveOutput(CreateFullPath(_script.Settings.DataOptions.DataObjectsNamespace + "\\Interfaces", "I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ".cs"), SaveActions.DontOverwrite);
        }
コード例 #16
0
 public void Render(string modelName)
 {
     _output.tabLevel++;
     foreach (string tableName in _script.Tables)
     {
         _output.autoTabLn("AutoMapper.Mapper.CreateMap<" + StringFormatter.CleanUpClassName(tableName) + ", " + StringFormatter.CleanUpClassName(tableName) + modelName + ">();");
         _output.autoTabLn("AutoMapper.Mapper.CreateMap<" + StringFormatter.CleanUpClassName(tableName) + modelName + ", " + StringFormatter.CleanUpClassName(tableName) + ">();");
     }
     _output.tabLevel--;
 }
コード例 #17
0
        private void RenderDataAnnotationsBusinessObjectsClass(ITable table)
        {
            try
            {
                _hdrUtil.WriteClassHeader(_output);

                _output.autoTabLn("using System;");
                _output.autoTabLn("using System.Collections.Generic;");
                _output.autoTabLn("using System.ComponentModel.DataAnnotations;");
                _output.autoTabLn("using System.ComponentModel;");
                _output.autoTabLn("using System.Web.Mvc;");

                _output.autoTabLn("");
                _output.autoTabLn("namespace " + _script.Settings.BusinessObjects.BusinessObjectsNamespace);
                _output.autoTabLn("{");
                _output.tabLevel++;

                _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name));
                _output.autoTabLn("{");
                _output.tabLevel++;

                _output.autoTabLn("#region ctors");
                _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "()");
                _output.autoTabLn("{");
                _output.tabLevel++;

                // Render any collection HashSets in the constructor for foreign key associations.
                BusinessObjectsPropertiesRenderForeignKeyConstructorForDbContext ctor = new BusinessObjectsPropertiesRenderForeignKeyConstructorForDbContext(table, _context);
                ctor.Render();

                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("#endregion");
                _output.autoTabLn("");

                _output.autoTabLn("#region Properties");
                RenderProperties(table);
                _output.autoTabLn("#endregion");

                _output.tabLevel--;
                _output.autoTabLn("}");
                _output.autoTabLn("");

                _output.tabLevel--;
                _output.autoTabLn("}");

                _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + ".cs");
                SaveOutput(CreateFullPath(_script.Settings.BusinessObjects.BusinessObjectsNamespace, StringFormatter.CleanUpClassName(table.Name) + ".cs"), SaveActions.DontOverwrite);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #18
0
        public void GetById(MyMeta.ITable table)
        {
            string args      = string.Empty;
            string keys      = string.Empty;
            string tableName = table.Name;

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// GetById and map the fields to the Model.");
            _output.autoTabLn("/// </summary>");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "\"></param>");
            }

            _output.autoTabLn("/// <returns></returns>");
            _output.autoTab("public " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " GetById(");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
            }
            // trim the trailing ", "
            args = args.Substring(0, (args.Length - 2));
            keys = keys.Substring(0, (keys.Length - 2));
            _output.write(args);
            _output.writeln(")");
            _output.autoTabLn("{");

            _output.tabLevel++;
            _output.autoTabLn("using (var context = DataContextFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("return " + StringFormatter.CleanUpClassName(tableName) + "Mapper.ToBusinessObject(context." + StringFormatter.MakePlural(StringFormatter.CleanUpClassName(tableName)));
            string[] keysSplit = keys.Split(',');
            foreach (string key in keysSplit)
            {
                _output.tabLevel++;
                _output.autoTabLn(".Where(o => o." + _util.CleanUpProperty(key) + " == " + key + ")");
            }
            _output.autoTabLn(".SingleOrDefault());");
            _output.tabLevel--;
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #19
0
        public void Update(ITable table)
        {
            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Update " + StringFormatter.CleanUpClassName(table.Name) + ".  Map  fields to " + StringFormatter.CleanUpClassName(table.Name) + " properties.");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + "\"></param>");
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTabLn("public void Update(" + _context.Utility.BuildModelClassWithNameSpace(table.Name) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("");
            _output.autoTabLn("using (var context = DataObjectFactory.CreateContext())");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("");
            _output.autoTabLn("var entity = context." + StringFormatter.CleanUpClassName(table.Name, true));

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn(".Where(o => o." + genTable.GetPrimaryKeyNames[i] + " == model." + genTable.GetPrimaryKeyNames[i] + ")");
            }

            _output.autoTabLn(".SingleOrDefault();");

            _output.tabLevel--;
            _output.autoTabLn("entity = model.ToEntity(entity);");
            _output.autoTabLn("");
            _output.autoTabLn("try");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("context.SaveChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("catch (OptimisticConcurrencyException)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("context.Refresh(System.Data.Objects.RefreshMode.ClientWins, entity);");
            _output.autoTabLn("context.SaveChanges();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.tabLevel--;
        }
コード例 #20
0
        public void GetById(ITable table)
        {
            string tableName = table.Name;
            string args      = string.Empty;
            string keys      = string.Empty;

            GenTable genTable = new GenTable(table, _context);

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// GetById and map the fields to the Model.");
            _output.autoTabLn("/// </summary>");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("/// <param name=\"" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "\"></param>");
            }
            _output.autoTabLn("/// <returns></returns>");
            _output.autoTab("public " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " GetById(");
            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args += genTable.GetPrimaryKeyTypes[i] + " ";
                args += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
            }
            // trim the trailing ", "
            args = args.Substring(0, (args.Length - 2));
            keys = keys.Substring(0, (keys.Length - 2));
            _output.write(args.Trim());
            _output.writeln(")");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(_util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model = null;");
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                _output.autoTabLn("if (entity.LoadByPrimaryKey(" + StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + "))");
            }
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("model = entity.ToBusinessObject();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.autoTabLn("return model;");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.autoTabLn("");
            _output.tabLevel--;
        }
コード例 #21
0
        /// <summary>
        /// This renders both the Ninject Repository and Service mappings.
        /// </summary>
        public void Render()
        {
            _output.tabLevel++;
            _output.tabLevel++;
            _output.tabLevel++;
            _output.autoTabLn("kernel.Bind<IUnitOfWork>().To<UnitOfWork>().InRequestScope();");
            _output.tabLevel--;
            _output.tabLevel--;
            _output.tabLevel--;

            foreach (string tableName in _script.Tables)
            {
                ITable table = _database.Tables[tableName];
                _output.tabLevel++;
                _output.tabLevel++;
                _output.tabLevel++;

                _output.autoTabLn("kernel.Bind<I" + StringFormatter.CleanUpClassName(table.Name) + "Service>().To<" + StringFormatter.CleanUpClassName(table.Name) + "Service>();");

                _output.tabLevel--;
                _output.tabLevel--;
                _output.tabLevel--;
            }

            _output.autoTabLn("");

            foreach (string tableName in _script.Tables)
            {
                ITable table = _database.Tables[tableName];
                _output.tabLevel++;
                _output.tabLevel++;
                _output.tabLevel++;

                _output.autoTabLn("kernel.Bind<I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ">().To<" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + ">();");

                _output.tabLevel--;
                _output.tabLevel--;
                _output.tabLevel--;
            }
            //_output.tabLevel++;
            //_output.tabLevel++;
            //_output.tabLevel++;

            //_output.autoTabLn("kernel.Bind<IAuthRepository>().To<AuthRepository>();");

            //_output.tabLevel--;
            //_output.tabLevel--;
            //_output.tabLevel--;
        }
コード例 #22
0
 public void Render(string modelName)
 {
     _output.tabLevel--;
     foreach (string tableName in _script.Tables)
     {
         _output.tabLevel++;
         _output.autoTabLn("#region " + StringFormatter.CleanUpClassName(tableName) + " Mappers");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.tabLevel++;
         _output.autoTabLn("public static " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + " ToBusinessObject(this " + _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.DataStore.Selected + "." + StringFormatter.CleanUpClassName(tableName) + " entity)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.DataStore.Selected + "." + StringFormatter.CleanUpClassName(tableName) + ", " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + ">(entity);");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.tabLevel++;
         _output.autoTabLn("public static List<" + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + "> ToBusinessObjects(this List<" + _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.DataStore.Selected + "." + StringFormatter.CleanUpClassName(tableName) + "> entityList)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("var models = new List<" + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + ">();");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.tabLevel++;
         _output.autoTabLn("if (entityList != null && entityList.Count > 0)");
         _output.tabLevel++;
         _output.autoTabLn("entityList.ForEach(b => models.Add(b.ToBusinessObject()));");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.tabLevel++;
         _output.autoTabLn("return models;");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.tabLevel--;
         _output.autoTabLn("");
         _output.tabLevel++;
         _output.autoTabLn("public static " + _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.DataStore.Selected + "." + StringFormatter.CleanUpClassName(tableName) + " ToEntity(this " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + " model)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + _script.Settings.BusinessObjects.BusinessObjectsNamespace + "." + StringFormatter.CleanUpClassName(tableName) + ", " + _script.Settings.DataOptions.DataObjectsNamespace + "." + _script.Settings.DataOptions.DataStore.Selected + "." + StringFormatter.CleanUpClassName(tableName) + ">(model);");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("#endregion");
         _output.tabLevel--;
     }
     _output.tabLevel++;
 }
コード例 #23
0
        public void Render()
        {
            string tableName = _table.Name;

            foreach (IForeignKey key in _table.ForeignKeys)
            {
                if (_script.Tables.Contains(key.ForeignTable.Name))
                {
                    if (key.PrimaryTable.Name == tableName)
                    {
                        _output.autoTabLn(StringFormatter.CleanUpClassName(key.ForeignTable.Name) + "List = new HashSet<" + StringFormatter.CleanUpClassName(key.ForeignTable.Name) + ">();");
                    }
                }
            }
        }
コード例 #24
0
        public void BuildModelClass(ITable table, bool useWebService)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Web.Mvc;");
            _output.autoTabLn("using System.ComponentModel;");
            _output.autoTabLn("using System.ComponentModel.DataAnnotations;");
            _output.autoTabLn("using System.Collections.Generic;");
            _output.autoTabLn("");
            if (useWebService)
            {
                _output.autoTabLn("using " + _script.Settings.UI.UIWcfServiceNamespace + ";");
            }
            else
            {
                _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            }
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.UI.UINamespace + ".Models");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Model");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("");

            Condor.Core.Property prop = null;
            foreach (IColumn c in table.Columns)
            {
                prop = new BusinessObjectsPropertyRenderDataAnnotations(c, _context);
                prop.Render();
            }
            BusinessObjectsPropertiesRenderForeignKey foreignKey = new BusinessObjectsPropertiesRenderForeignKey(table, _context);

            foreignKey.Render();


            _output.autoTabLn("");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Model.cs");
            SaveOutput(CreateFullPath(_script.Settings.UI.UINamespace + "\\Models", StringFormatter.CleanUpClassName(table.Name) + "Model.cs"), SaveActions.DontOverwrite);
        }
コード例 #25
0
 public void Render(string modelName)
 {
     foreach (string tableName in _script.Tables)
     {
         _output.tabLevel++;
         _output.autoTabLn("#region " + StringFormatter.CleanUpClassName(tableName) + " Mappers");
         _output.autoTabLn("");
         _output.autoTabLn("public static " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " ToBusinessObject(this " + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " entity)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + ", " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + ">(entity);");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("");
         _output.autoTabLn("public static List<" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + "> ToBusinessObjects(this " + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + "Collection entityList)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("var models = new List<" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + ">();");
         _output.autoTabLn("");
         _output.autoTabLn("if (entityList != null && entityList.Count > 0)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("foreach (var entity in entityList)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("models.Add(entity.ToBusinessObject());");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("");
         _output.autoTabLn("return models;");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("");
         _output.autoTabLn("public static " + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " ToEntity(this " + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model, " + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " entity)");
         _output.autoTabLn("{");
         _output.tabLevel++;
         _output.autoTabLn("return AutoMapper.Mapper.Map<" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + ", " + _util.BuildEntityClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + ">(model, entity);");
         _output.tabLevel--;
         _output.autoTabLn("}");
         _output.autoTabLn("#endregion");
         _output.autoTabLn("");
         _output.tabLevel--;
     }
 }
コード例 #26
0
        private void RenderConcreteClass(ITable table)
        {
            _hdrUtil.WriteClassHeader(_output);

            _output.autoTabLn("using System;");
            _output.autoTabLn("using System.Linq;");
            _output.autoTabLn("using " + _script.Settings.BusinessObjects.BusinessObjectsNamespace + ";");
            _output.autoTabLn("using " + _script.Settings.DataOptions.DataObjectsNamespace + ".Interfaces;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Generated;");
            _output.autoTabLn("using " + _script.Settings.ServiceLayer.ServiceNamespace + ".Interfaces;");
            _output.autoTabLn("");
            _output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace);
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name) + "Service : ServiceBase<" + StringFormatter.CleanUpClassName(table.Name) + ", I" + StringFormatter.CleanUpClassName(table.Name) + "Dao>, I" + StringFormatter.CleanUpClassName(table.Name) + "Service");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("public " + StringFormatter.CleanUpClassName(table.Name) + "Service(I" + StringFormatter.CleanUpClassName(table.Name) + _script.Settings.DataOptions.ClassSuffix.Name + " " + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel++;
            _output.autoTabLn(": base(" + StringFormatter.CamelCasing(StringFormatter.CleanUpClassName(table.Name)) + _script.Settings.DataOptions.ClassSuffix.Name + ")");
            _output.tabLevel--;
            _output.autoTabLn("{");
            _output.autoTabLn("");
            _output.autoTabLn("}");


            // Updated 7/15/2014 - by King Wilder - write custom code for SiteSetting - used by King Wilder
            if (table.Name == "SiteSetting")
            {
                _output.autoTabLn("public SiteSetting GetByKey(string key)");
                _output.autoTabLn("{");
                _output.tabLevel++;
                _output.autoTabLn("return _dao.Get(s => s.Name == key).SingleOrDefault();");
                _output.tabLevel--;
                _output.autoTabLn("}");
            }


            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");

            _context.FileList.Add("    " + StringFormatter.CleanUpClassName(table.Name) + "Service.cs");
            SaveOutput(CreateFullPath(_script.Settings.ServiceLayer.ServiceNamespace, StringFormatter.CleanUpClassName(table.Name) + "Service.cs"), SaveActions.DontOverwrite);
        }
コード例 #27
0
        public void GetAllWithSortingAndPaging(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.autoTabLn("public List<" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + "> GetAll(string sortExpression, int startRowIndex, int maximumRows)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + "Collection coll = new " + StringFormatter.CleanUpClassName(tableName) + "Collection();");
            _output.autoTabLn("coll.Query.OrderBy(sortExpression);");
            _output.autoTabLn("coll.Query.Skip(startRowIndex).Take(maximumRows);");
            _output.autoTabLn("coll.Query.Load();");
            _output.autoTabLn("");
            _output.autoTabLn("return coll.ToBusinessObjects();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
        }
コード例 #28
0
        private void RenderDataAnnotationsBusinessObjectsClass(ITable table)
        {
            var output = _context.Zeus.Output;

            output.clear();

            try
            {
                _hdrUtil.WriteClassHeader(output);

                output.autoTabLn("using System;");
                output.autoTabLn("using System.Collections.Generic;");
                output.autoTabLn("using System.ComponentModel.DataAnnotations;");
                output.autoTabLn("using System.ComponentModel;");

                output.autoTabLn("");
                output.autoTabLn("namespace " + _script.Settings.BusinessObjects.BusinessObjectsNamespace);
                output.autoTabLn("{");
                output.tabLevel++;

                output.autoTabLn("public class " + StringFormatter.CleanUpClassName(table.Name));
                output.autoTabLn("{");
                output.tabLevel++;

                output.autoTabLn("#region Properties");
                RenderProperties(table);
                output.autoTabLn("#endregion");

                output.tabLevel--;
                output.autoTabLn("}");
                output.autoTabLn("");

                output.tabLevel--;
                output.autoTabLn("}");

                _context.FileList.Add("   " + StringFormatter.CleanUpClassName(table.Name) + ".cs");
                SaveOutput(CreateFullPath(@"BusinessObjects", StringFormatter.CleanUpClassName(table.Name) + ".cs"), SaveActions.DontOverwrite);
                output.clear();
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #29
0
        public void Delete(ITable table)
        {
            string tableName = table.Name;

            _output.tabLevel++;
            _output.autoTabLn("/// <summary>");
            _output.autoTabLn("/// Delete " + StringFormatter.CleanUpClassName(tableName) + ".");
            _output.autoTabLn("/// </summary>");
            _output.autoTabLn("/// <param name=\"" + StringFormatter.CleanUpClassName(tableName) + "\"></param>");
            _output.autoTabLn("public void Delete(" + _util.BuildModelClassWithNameSpace(StringFormatter.CleanUpClassName(tableName)) + " model)");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn(StringFormatter.CleanUpClassName(tableName) + " entity = new " + StringFormatter.CleanUpClassName(tableName) + "();");

            GenTable genTable = new GenTable(table, _context);
            string   args     = "";
            string   keys     = "";
            string   types    = "";

            for (int i = 0; i < genTable.GetPrimaryKeyNames.Length; i++)
            {
                // type + " " + key name
                args  += genTable.GetPrimaryKeyTypes[i] + " ";
                args  += StringFormatter.CamelCasing(genTable.GetPrimaryKeyNames[i]) + ", ";
                keys  += StringFormatter.PascalCasing(genTable.GetPrimaryKeyNames[i]) + ",";
                types += genTable.GetPrimaryKeyTypes[i] + ",";
            }
            // trim the trailing ", "
            args  = args.Substring(0, (args.Length - 2));
            keys  = keys.Substring(0, (keys.Length - 1));
            types = types.Substring(0, (types.Length - 1));

            _output.autoTabLn("if (entity.LoadByPrimaryKey(model." + keys + "))");
            _output.autoTabLn("{");
            _output.tabLevel++;
            _output.autoTabLn("entity.MarkAsDeleted();");
            _output.autoTabLn("entity.Save();");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
            _output.autoTabLn("}");
            _output.tabLevel--;
        }
コード例 #30
0
ファイル: WcfDto.cs プロジェクト: kahanu/CondorXE
        private void RenderClass(ITable table)
        {
            var output = _context.Zeus.Output;

            output.clear();

            try
            {
                _hdrUtil.WriteClassHeader(output);

                output.autoTabLn("using System;");
                output.autoTabLn("using System.Collections.Generic;");
                output.autoTabLn("using System.Runtime.Serialization;");
                output.autoTabLn("");
                output.autoTabLn("namespace " + _script.Settings.ServiceLayer.ServiceNamespace + ".DataTransferObjects");
                output.autoTabLn("{");
                output.autoTabLn("    [DataContract(Name = \"" + StringFormatter.CleanUpClassName(table.Name) + "\", Namespace = \"" + _script.Settings.ServiceLayer.DataContract + "\")]");
                output.autoTabLn("    public class " + StringFormatter.CleanUpClassName(table.Name) + "Dto ");
                output.autoTabLn("    {");
                output.autoTabLn("        #region Properties");
                output.autoTabLn("");
                output.tabLevel++;

                RenderProperties(table);

                output.tabLevel--;
                output.autoTabLn("");
                output.autoTabLn("");
                output.autoTabLn("        #endregion");
                output.autoTabLn("    }");
                output.autoTabLn("}");

                _context.FileList.Add("   " + StringFormatter.CleanUpClassName(table.Name) + "Dto.cs");
                SaveOutput(CreateFullPath(@"BusinessObjects", StringFormatter.CleanUpClassName(table.Name) + "Dto.cs"), SaveActions.DontOverwrite);
                output.clear();
            }
            catch (Exception)
            {
                throw;
            }
        }