Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------
        #endregion


        public CustomDatabase(Database db)
        {
            _dbObject        = db;
            _ProgramatlyName = Globals.GetProgramatlyName(NameInDatabase);
            //ProjectBuilder.Init(_ProgramatlyName);
            _Tables = new List <CustomTable>();
            CustomTable table = null;

            //string requiredTables = @"LK_BudgetCategories ";

            foreach (Table t in _dbObject.Tables)
            {
                //if (!requiredTables.Contains(t.Name))
                //    continue;
                if (!t.IsSystemObject)
                {
                    table = new CustomTable(t);
                    Tables.Add(table);
                }
            }
            //read relation
            foreach (CustomTable ct in this.Tables)
            {
                foreach (CustomColumn c in ct.ForeignKeys)
                {
                    GetRelatedTable(ct.dbObject.ForeignKeys, c);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Create(CustomTable t)
        {
            DtoBuilder builder = new DtoBuilder(t);

            string EntityFile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Dto.cs");

            string genEntityFile = builder.Prepare(EntityFile);

            FileManager.SaveFile(".cs", builder.CurrentTable.PathOfDtoClass, genEntityFile);
        }
Ejemplo n.º 3
0
        public static void Create(CustomTable t)
        {
            FactoryBuilder factory = new FactoryBuilder(t);

            string FactoryFile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Factory.cs");

            string genFactoryFile = factory.Prepare(FactoryFile);

            FileManager.SaveFile(".cs", factory.CurrentTable.PathOfFactoryClass, genFactoryFile);
        }
Ejemplo n.º 4
0
        public static void Create(CustomTable t)
        {
            ModelBuilder sqlProvider = new ModelBuilder(t);

            string EntityFile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Entity.cs");

            string genEntityFile = sqlProvider.Prepare(EntityFile);

            FileManager.SaveFile(".cs", sqlProvider.CurrentTable.PathOfModelClass, genEntityFile);
        }
Ejemplo n.º 5
0
        public static void Create(CustomTable t)
        {
            RepositoryBuilder builder = new RepositoryBuilder(t);

            string repositoryFile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Repository.cs");

            string genFactoryFile = builder.Prepare(repositoryFile);

            FileManager.SaveFile(".cs", builder.CurrentTable.PathOfRepositoryFile, genFactoryFile);
        }
        public static void Create(CustomTable t)
        {
            ControllerBuilder builder = new ControllerBuilder(t);

            string templatefile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Controller.cs");

            string genratedCode = builder.Prepare(templatefile);

            FileManager.SaveFile(".cs", builder.CurrentTable.PathOfControllerFile, genratedCode);
        }
        public new static void Create(CustomTable t)
        {
            SqlProviderBuilder sqlProvider = new SqlProviderBuilder(t);

            string SqlDataProviderFile = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/SqlDataProvider.cs");

            string genSqlDataProviderFile = sqlProvider.Prepare(SqlDataProviderFile);

            FileManager.SaveFile(".cs", sqlProvider.CurrentTable.PathOfSqlDataPrviderClass, genSqlDataProviderFile);
        }
Ejemplo n.º 8
0
        public static void Create(CustomTable t)
        {
            ApplicationServiceBuilder builder = new ApplicationServiceBuilder(t);

            string fileCode      = FileManager.ReadingTextFile(AppDomain.CurrentDomain.BaseDirectory + "Resources/Classes/Service.cs");
            string generatedCode = builder.GenerateAllCode();
            string tempCode      = fileCode.Replace("$code$", generatedCode);
            string finalCode     = builder.Prepare(tempCode);

            FileManager.SaveFile(".cs", builder.CurrentTable.PathOfApplicatioServiceFile, finalCode);
        }
        //------------------------------------------------------------------------------------------------------
        #endregion

        public static void Create(CustomTable t)
        {
            StoredProcedureBuilder sp = new StoredProcedureBuilder(t);
            string proc = sp.GenerateInsertProcedure();

            WriteStoredProcedure(proc);
            proc += sp.GenerateUpdatePrcedure();
            proc += sp.GenerateDeletePrcedure();
            proc += sp.GenerateGet();
            if (sp.CurrentTable.ID != null)
            {
                proc += sp.GenerateGetPageByPage();
            }
            FileManager.SaveFile(".Sql", sp.CurrentTable.PathOfStoredProcerduresFile, proc);
            //WriteStoredProcedure(proc);
        }
Ejemplo n.º 10
0
        //------------------------------------------------------------------------------------------------------
        #endregion


        public CustomDatabase(Database db)
        {
            _dbObject        = db;
            _ProgramatlyName = Globals.GetProgramatlyName(NameInDatabase);
            //ProjectBuilder.Init(_ProgramatlyName);
            _Tables = new List <CustomTable>();
            CustomTable table = null;

            foreach (Table t in _dbObject.Tables)
            {
                if (!t.IsSystemObject)
                {
                    table = new CustomTable(t);
                    Tables.Add(table);
                }
            }
        }
Ejemplo n.º 11
0
 public CustomColumn(Column c, CustomTable parentTable, string tableName, string tableProgramatlyName)
 {
     _dbObject            = c;
     ParentTable          = parentTable;
     TableName            = tableName;
     TableProgramatlyName = tableProgramatlyName;
     ProgramatlyName      = Globals.GetProgramatlyName(NameInDatabase);
     FriendlyName         = Globals.GetFriendlyName(ProgramatlyName);
     LowerProgramatlyName = ProgramatlyName.ToLower();
     InputType            = SetInputType();
     if (c.DefaultConstraint != null)
     {
         HasDefaultValue = true;
         DefaultValue    = GetDefaultValue();
     }
     //set data type and complete column analysis
     SetDataTypes();
 }
Ejemplo n.º 12
0
 public FactoryBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
Ejemplo n.º 13
0
 public static void Create(CustomTable t)
 {
 }
Ejemplo n.º 14
0
 public DtoBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
Ejemplo n.º 15
0
 public RepositoryBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
 public ControllerBuilder(CustomTable t)
 {
     CurrentTable = t;
     Init();
 }
Ejemplo n.º 17
0
 public ModelBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
Ejemplo n.º 18
0
 public ApplicationServiceBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
 public StoredProcedureBuilder(CustomTable t)
 {
     _CurrentTable = t;
 }
Ejemplo n.º 20
0
 public FormConfigurationBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
 public SqlProviderBuilder(CustomTable t)
 {
     CurrentTable = t;
     init();
 }
Ejemplo n.º 22
0
        private void init()
        {
            ///////////////////////////////////////////////////////////////////////
            //Calculate flexigrid column width
            int flexigridColumns = CurrentTable.Columns.Count;

            if (CurrentTable.ID != null)
            {
                --flexigridColumns;
            }
            int columnWidth = (ResourcesParameters.FlexiGridWidth / flexigridColumns);
            ///////////////////////////////////////////////////////////////////////
            string flwxiGridColumnsPattern            = "\t\t\t\tnew FlexigridColumn(\"{0}\",\"{0}\",{1},true,\"left\",false,false)";
            string ParametersToCreateFlexiJsonPattern = "\t\t\t\t\t\t\t\t\t\t\t\t\t\tx.{0}";
            //string forignkeysCodePatern = "\t\t\t\tViewData[\"{0}\"] = {1}.{2}().Select(x => new SelectListItem { Text = x.{3}, Value = x.{4}.ToString() }).ToList();";

            CustomColumn c = null;

            for (int i = 0; i < CurrentTable.Columns.Count - 1; i++)
            {
                c = CurrentTable.Columns[i];
                if (!c.InPrimaryKey)
                {
                    c = CurrentTable.Columns[i];
                    FlexiGridColumns.AppendFormat(flwxiGridColumnsPattern, new string[] { c.ProgramatlyName, columnWidth.ToString() });
                    FlexiGridColumns.Append(",\n");

                    if (c.DotNetType == typeof(DateTime))
                    {
                        ParametersToCreateFlexiJson.AppendFormat(ParametersToCreateFlexiJsonPattern + ".ToString(\"MM/dd/yyyy\")", new string[] { c.ProgramatlyName });
                    }
                    else
                    {
                        ParametersToCreateFlexiJson.AppendFormat(ParametersToCreateFlexiJsonPattern, new string[] { c.ProgramatlyName });
                    }

                    ParametersToCreateFlexiJson.Append(",\n");
                }
            }
            c = CurrentTable.Columns[CurrentTable.Columns.Count - 1];
            FlexiGridColumns.AppendFormat(flwxiGridColumnsPattern, new string[] { c.ProgramatlyName, columnWidth.ToString() });
            if (c.DotNetType == typeof(DateTime))
            {
                ParametersToCreateFlexiJson.AppendFormat(ParametersToCreateFlexiJsonPattern + ".ToString(\"MM/dd/yyyy\")", new string[] { c.ProgramatlyName });
            }
            else
            {
                ParametersToCreateFlexiJson.AppendFormat(ParametersToCreateFlexiJsonPattern, new string[] { c.ProgramatlyName });
            }

            //-----------------------------------------------------------------------------------------------------------------
            CustomTable      tableOfRelation   = null;
            string           columnOFTextFeild = "";
            string           forignkyText      = "";
            string           primaryKeyText    = "";
            ForeignKeyColumn rc = null;

            //-------------------------------
            foreach (ForeignKey r in CurrentTable.dbObject.ForeignKeys)
            {
                tableOfRelation   = null;
                columnOFTextFeild = "";
                forignkyText      = "";
                primaryKeyText    = "";
                rc = null;
                if (r != null)
                {
                    rc                = r.Columns[0];
                    forignkyText      = Globals.GetProgramatlyName(rc.Name);
                    primaryKeyText    = Globals.GetProgramatlyName(rc.ReferencedColumn);
                    tableOfRelation   = ProjectBuilder.db.GetTable(r.ReferencedTable);
                    columnOFTextFeild = tableOfRelation.FirstStringColumnName;
                    ForignkeysCode.Append("\n\t\t\tViewData[\"" + forignkyText + "\"] = " + tableOfRelation.FactoryClass + "." + tableOfRelation.MethodGet + "().Select(x => new SelectListItem { Text = x." + columnOFTextFeild + ", Value = x." + primaryKeyText + ".ToString() }).ToList();");
                }
            }
            //------------------------------------------------------------------------
        }