예제 #1
0
        internal void genMetaQuery()
        {
            foreach (TableType tt in myMaster.GetReadTables())
            {
                if (tt.generate.onlyForDbconfig == null)
                {
                    string utFil = outDirMetaQ + "MetaQuery_" + tt.modelName + ".cs";
                    outStreamWriter = new StreamWriter(utFil);

                    String[] myArr = new String[] { "System", "System.Data", "System.Collections.Generic",
                                                    "System.Collections.Specialized", "System.Text", "System.Xml.XPath", "System.Globalization", "",
                                                    "PCAxis.Sql.DbConfig", "PCAxis.Sql.Exceptions", "", "" };
                    String cnmmVersion = myMaster.Tables.CNMMversion;

                    printUsing(myArr);

                    printThisCodeIsGeneratedWarning();
                    printLine("namespace PCAxis.Sql.QueryLib_" + cnmmVersion);
                    printBegin();
                    printLine("public partial class MetaQuery");
                    printBegin();

                    setHelpers(tt);

                    genMetaQueryForTable(tt);

                    printEnd();
                    printEnd();

                    outStreamWriter.Close();
                    Console.Out.WriteLine("Wrote to file: " + utFil);
                }
            }
        }
예제 #2
0
파일: RowMaker.cs 프로젝트: trygu/PxWeb
        internal void genRowsClasses()
        {
            foreach (TableType tt in myMaster.GetReadTables())
            {
                if (!(tt.generate.dontMakeRowClasses != null || tt.generate.onlyForDbconfig != null))
                {
                    setHelpers(tt);

                    string utFil = this.outDirRows + rowClassName + ".cs";
                    outStreamWriter = new StreamWriter(utFil);

                    String[] myArr = new String[] { "System", "System.Data", "System.Collections.Generic",
                                                    "System.Collections.Specialized", "System.Text", "System.Xml.XPath", "System.Globalization", "",
                                                    "PCAxis.Sql.DbConfig", "" };
                    String cnmmVersion = myMaster.Tables.CNMMversion;

                    printUsing(myArr);

                    printThisCodeIsGeneratedWarning();
                    printLine("namespace PCAxis.Sql.QueryLib_" + cnmmVersion);
                    printBegin();



                    if (!String.IsNullOrEmpty(tt.Comment))
                    {
                        printLine("/*" + tt.Comment + "*/");
                    }



                    if (tt.hasSL)
                    {
                        genRowLangIndep(tt, cnmmVersion);
                        genRowLangDep(tt, cnmmVersion);
                    }
                    else
                    {
                        genRowLangNone(tt, cnmmVersion);
                    }


                    printEnd();
                    outStreamWriter.Close();
                    Console.Out.WriteLine("Wrote to file: " + utFil);
                }
            }
        }
예제 #3
0
        internal void genConfigStub()
        {
            outStreamWriter = new StreamWriter(outFileName);
            printLine("<Codes>");
            foreach (GrandMasterCode kode in myMaster.Codes)
            {
                printLine("<!--Code codeName=\"" + kode.codeName + "\" codeValue=\"" + kode.defaultCodeValue + "\"/-->");
            }
            printLine("</Codes>");


            printLine("<Keywords>");
            foreach (GrandMasterKeyword keyword in myMaster.Keywords)
            {
                if (keyword.optionalSpecified && keyword.optional)
                {
                    printLine("<!-- " + keyword.modelName + " represent an optional property, which has a default property value ( the others have a default property name ). -->");
                    printLine("<!--Keyword modelName=\"" + keyword.modelName + "\" keywordName=\"" + keyword.modelName.ToUpper() + "\"/-->");
                }
                else
                {
                    printLine("<!--Keyword modelName=\"" + keyword.modelName + "\" keywordName=\"" + keyword.defaultLocalName + "\"/-->");
                }
            }
            printLine("</Keywords>");

            printLine("<Tables>");
            printLine("<!-- To uncomment a column you need to uncomment the table as well -->");
            foreach (TableType tt in myMaster.GetReadTables())
            {
                printLine("<!--Table modelName=\"" + tt.modelName + "\" tableName=\"" + tt.tableName + "\" alias=\"" + tt.alias + "\">");
                printLine("<Columns-->");
                foreach (ColumnType ct in tt.GetReadColumns())
                {
                    printLine("<!--Column modelName=\"" + ct.modelName + "\" columnName=\"" + ct.defaultNameInDatabase() + "\"/-->");
                }
                printLine("<!--/Columns>");
                printLine("</Table-->");

                if (tt.hasSL)
                {
                    //omigjen for lang2
                    printLine("<!--Table modelName=\"" + tt.modelName + "Lang2\" tableName=\"" + tt.tableName + "_\" alias=\"" + tt.defaultAlias_lang2 + "\">");
                    printLine("<Columns-->");
                    foreach (ColumnType ct in tt.Columns)
                    {
                        if (!ct.readBySqlDbConfig)
                        {
                            continue;
                        }
                        if (ct.hasSL || ct.pkSpecified)
                        {
                            printLine("<!--Column modelName=\"" + ct.modelName + "\" columnName=\"" + ct.defaultNameInDatabase() + "\"/-->");
                        }
                    }
                    printLine("<!--/Columns>");
                    printLine("</Table-->");
                }
            }
            printLine("</Tables>");
            outStreamWriter.Close();
            Console.Out.WriteLine("Wrote to file " + outFileName);
        }
예제 #4
0
        internal void genSqlDbCongigSubclass()
        {
            String[] myArr = new String[] { "System", "System.Globalization",
                                            "System.Xml", "System.Xml.XPath", "log4net" };
            String className = "SqlDbConfig_" + myMaster.Tables.CNMMversion;
            String fileName  = outFileSqlDbConfig;

            outStreamWriter = new StreamWriter(fileName);
            printUsing(myArr);
            printLine("");

            printThisCodeIsGeneratedWarning();

            printLine("namespace PCAxis.Sql.DbConfig");
            printBegin();
            printLine("public class " + className + " : SqlDbConfig");
            printLine("{");

            indent++;
            printLine("private static readonly ILog log = LogManager.GetLogger(typeof(" + className + "));");

            printLine("");
            printLine("public Ccodes Codes;");

            printLine("public DbKeywords Keywords;");

            printLine("");
            printLine("#region Fields");

            foreach (TableType tt in myMaster.GetReadTables())
            {
                setHelpers(tt);
                genDbCongigPartialForTableFields(tt);
            }
            printLine("#endregion Fields");
            printLine("");
            printLine("private void initStructs()");
            printLine("{");
            printLine("");
            indent++;
            foreach (TableType tt in myMaster.GetReadTables())
            {
                setHelpers(tt);

                genDbCongigPartialForTableInitClasses(tt);
            }
            printEnd();
            printLine("");
            printLine("public " + className + "(XmlReader xmlReader, XPathNavigator nav)");
            printLine(": base(xmlReader, nav)");
            printBegin();
            printLine("log.Info(\"" + className + " called\");");
            printLine("");
            printLine("this.initStructs();");
            printLine("this.initCodesAndKeywords();");
            printEnd();
            printLine("");



            printLine("#region  structs");
            printLine("");
            printLine(" ");
            printLine("");

            foreach (TableType tt in myMaster.GetReadTables())
            {
                setHelpers(tt);


                genDbCongigPartialForTableClasses(tt, className);

                if (tt.hasSL)
                {
                    genDbCongigPartialForTableClassesLang2(tt, className);
                }
            }
            printLine("#endregion  structs");



            printLine("");
            printLine("");
            printLine("private void initCodesAndKeywords()");
            printBegin();
            #region Codes
            printLine("");
            printLine("#region Codes");
            printLine("");
            printLine("Codes = new Ccodes();");
            printLine("");
            foreach (GrandMasterCode kode in myMaster.Codes)
            {
                printLine("Codes." + kode.codeName + " = ExtractCode(\"" + kode.codeName + "\", \"" + kode.defaultCodeValue + "\");");
            }
            printLine("");
            printLine("#endregion Codes");
            printLine("");
            #endregion Codes

            #region Keywords
            printLine("");
            printLine("#region Keywords");
            printLine("");
            printLine("Keywords = new DbKeywords();");
            printLine("");
            foreach (GrandMasterKeyword keyword in myMaster.Keywords)
            {
                if (keyword.optionalSpecified && keyword.optional)
                {
                    printLine("if (FileHasKeyword(\"" + keyword.modelName + "\"))");
                    printBegin();
                    printLine("Keywords.Optional_" + keyword.modelName + " = ExtractKeyword(\"" + keyword.modelName + "\");");
                    printEnd();
                }
                else
                {
                    printLine("Keywords." + keyword.modelName + " = ExtractKeyword(\"" + keyword.modelName + "\", \"" + keyword.defaultLocalName + "\");");
                }
            }
            printLine("");
            printLine("#endregion Keywords");
            printLine("");
            #endregion Keywords
            printEnd();
            printLine("");


            printLine("public struct Ccodes");
            printBegin();
            foreach (GrandMasterCode kode in myMaster.Codes)
            {
                printLine("public String " + kode.codeName + ";");
            }
            printEnd();
            printLine("");
            printLine("public struct DbKeywords");
            printBegin();
            foreach (GrandMasterKeyword keyword in myMaster.Keywords)
            {
                if (keyword.optionalSpecified && keyword.optional)
                {
                    printLine("public String Optional_" + keyword.modelName + ";");
                }
                else
                {
                    printLine("public String " + keyword.modelName + ";");
                }
            }
            printEnd();
            printEnd();
            printEnd();

            outStreamWriter.Close();
            Console.Out.WriteLine("Wrote to file " + fileName);
        }