Exemple #1
0
        public static string Initialize_UsingStatementAndClassHeader(string nameSpace, string ClassName, ICD icdType)
        {
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(USUtil.LoadUsingCodex(nameSpace, ""));

            strBuilder.Append("\tpublic class ");
            strBuilder.Append(ClassName);
            strBuilder.Append(icdType.ToString());
            strBuilder.Append("\r");
            strBuilder.Append("\t{");

            switch (icdType)
            {
            case ICD.Controller:
                strBuilder.Append(BuilControllerMethods(ClassName));
                break;

            case ICD.DataProvider:
                strBuilder.Append(BuilSQLDataProviderMethods(ClassName));
                break;

            case ICD.Info:
                break;
            }

            strBuilder.Append("\r");
            strBuilder.Append("\t}");

            strBuilder.Append(" \r }");//Close namespace bracket

            return(strBuilder.ToString());
        }
Exemple #2
0
        public string GenerateInfoClassFromDataTable(DataTable table, string ClassName)
        {
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append("\t");
            strBuilder.Append("public class ");
            strBuilder.Append(ClassName);
            strBuilder.Append(USUtil.R);
            strBuilder.Append(USUtil.T_OpenBracket);

            foreach (DataColumn dc in table.Columns)
            {
                strBuilder.Append(USUtil.NTT);
                strBuilder.Append(" public ");
                string SystdataType = dc.DataType.ToString();
                strBuilder.Append(GetDataTypeBySystemDataType(SystdataType));
                strBuilder.Append(" ");
                string strColName = dc.ColumnName;
                strColName = USUtil.CovertFirstLetterToCapital(strColName);
                strBuilder.Append(strColName);
                strBuilder.Append(" ");

                strBuilder.Append(" { get; set; }");
            }
            strBuilder.Append(USUtil.R);
            strBuilder.Append(USUtil.T_CloseBracket);

            return(strBuilder.ToString());
        }
Exemple #3
0
        /// <summary>
        /// Add using statements
        /// </summary>
        /// <param name="codex">"using System;","using System.Collections.Generic;"...</param>
        /// <returns></returns>
        /// <returns></returns>
        public static string LoadUsingCodex(string defaultNameSpace, params string[] codex)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(USUtil.DynamicAppenderWithLineBreak("using System;", "using System.Collections.Generic;", "using System.Linq;", "using System.Text;"));
            sb.Append(USUtil.DynamicAppenderWithLineBreak(codex));
            sb.Append("\r\r");
            sb.Append("namespace " + defaultNameSpace);
            sb.Append("\r");
            sb.Append("{ \r");
            return(sb.ToString());
        }
        public string GetTableInfoByTableNameandClassName(AdonaiBuildStructureInfo buildInfo)
        {
            string tableName     = USUtil.CovertFirstLetterToCapital(buildInfo.TableName);
            string infoClassName = USUtil.CovertFirstLetterToCapital(buildInfo.InfoClassName);

            string strFinalinfoString = string.Empty;
            string strScript          = SmartBuilder.Repository.MsSQL.QueryCollaborator.GenerateQuery_GetListOfColumnInfoByTableName(tableName);
            AppUtilityDataProvider objInfoDataProvider = new AppUtilityDataProvider();

            DataTable dataTable = objInfoDataProvider.GetTableColumnsBySQLScritpt(strScript, buildInfo.ConnectionString);


            InfoClassGenerator infoClassGenerator = new InfoClassGenerator(GetSystemSettings());

            strFinalinfoString = infoClassGenerator.BuildInfoClassforGivenDataTable(dataTable, infoClassName, buildInfo.IsNullableRequired, buildInfo.IsSerializable);

            //Process data of data table to build final string for the C# info class
            //strFinalinfoString = TableInfoGenerator.BuildInfoClassforGivenDataTable(dt, infoClassName, buildInfo.IsNullableRequired, buildInfo.IsSerializable);

            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(USUtil.LoadUsingCodex(buildInfo.InfoNameSpace, string.Empty));
            strBuilder.Append(strFinalinfoString);
            strBuilder.Append(" \r }");
            USUtil.CreateClassFileForGivenTypeClass(infoClassName, strBuilder.ToString(), ICD.Info);

            //Add Controller Class
            if (buildInfo.IsControllerRequired)
            {
                strBuilder.Append(AddContentHeader("Your Controller Class"));

                string txtControllerCode = USUtil.Initialize_UsingStatementAndClassHeader(buildInfo.InfoNameSpace, tableName, ICD.Controller);
                USUtil.CreateClassFileForGivenTypeClass(tableName + USUtil.Controller, txtControllerCode, ICD.Controller);

                strBuilder.Append(txtControllerCode);
            }

            //Add SQL DataProvider Class
            if (buildInfo.IsProviderRequired)
            {
                strBuilder.Append(AddContentHeader("Your SQL Data Provider Class"));

                string txtProviderCode = USUtil.Initialize_UsingStatementAndClassHeader(buildInfo.InfoNameSpace, tableName, ICD.DataProvider);
                USUtil.CreateClassFileForGivenTypeClass(tableName + USUtil.Provider, txtProviderCode, ICD.DataProvider);
                strBuilder.Append(txtProviderCode);
            }
            return(strBuilder.ToString());
        }
Exemple #5
0
        internal string ExecuteGivenProcedureBuildInfoClass(string ProcedureName, string defaultNameSpace, string ClassName, IList <KeyValuePair <string, object> > listColl, string connectionString)
        {
            string        strText    = string.Empty;
            StringBuilder strBuilder = new StringBuilder();
            DataSet       ds         = ExecuteAsDataSet(ProcedureName, listColl, connectionString);

            if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
            {
                DataTable      dt            = ds.Tables[0];
                ClassGenerator dtInfoBuilder = new ClassGenerator();
                strText = dtInfoBuilder.GenerateInfoClassFromDataTable(dt, ClassName);

                strBuilder.Append(USUtil.LoadUsingCodex(defaultNameSpace, string.Empty));
                strBuilder.Append(strText);
                strBuilder.Append(" \r }");
                USUtil.CreateClassFileForGivenTypeClass(ClassName, strBuilder.ToString(), ICD.Info);
            }

            return(strBuilder.ToString());
        }