예제 #1
0
        /// <summary>
        /// get the data structure for the version that should be upgraded
        /// </summary>
        public static TDataDefinitionStore GetStoreOld()
        {
            if (storeOld == null)
            {
                string PetraOldPath = TAppSettingsManager.GetValue("oldpetraxml", "petra23.xml");

                TLogging.Log(String.Format("Reading 2.x xml file {0}...", PetraOldPath));
                TDataDefinitionParser parserOld = new TDataDefinitionParser(PetraOldPath);
                storeOld = new TDataDefinitionStore();

                parserOld.SupportPetra2xLegacyStandard = true;

                if (!parserOld.ParseDocument(ref storeOld, false, true))
                {
                    return null;
                }
            }

            return storeOld;
        }
예제 #2
0
        public static void Main(string[] args)
        {
            try
            {
                new TAppSettingsManager(false);

                if (Directory.Exists(TAppSettingsManager.GetValue("logPath")))
                {
                    new TLogging(TAppSettingsManager.GetValue("logPath") + "/generateextjsforms.log");
                }
                else
                {
                    new TLogging("generateextjsforms.log");
                }

                TLogging.DebugLevel = TAppSettingsManager.GetInt16("DebugLevel", 0);

                if (!TAppSettingsManager.HasValue("ymlfile"))
                {
                    Console.WriteLine("call: GenerateExtJsForms -ymlfile:c:\\test.yaml -petraxml:petra.xml -localisation:en");
                    Console.Write("Press any key to continue . . . ");
                    Console.ReadLine();
                    Environment.Exit(-1);
                    return;
                }

                // calculate ICTPath from ymlfile path
                string fullYmlfilePath = Path.GetFullPath(TAppSettingsManager.GetValue("ymlfile")).Replace("\\", "/");

                string SelectedLocalisation = null;         // none selected by default

                if (TAppSettingsManager.HasValue("localisation"))
                {
                    SelectedLocalisation = TAppSettingsManager.GetValue("localisation");
                }

                CSParser.ICTPath = fullYmlfilePath.Substring(0, fullYmlfilePath.IndexOf("csharp/ICT") + "csharp/ICT".Length);

                TDataBinding.FPetraXMLStore = new TDataDefinitionStore();
                Console.WriteLine("parsing " + TAppSettingsManager.GetValue("petraxml", true));
                TDataDefinitionParser parser = new TDataDefinitionParser(TAppSettingsManager.GetValue("petraxml", true));
                parser.ParseDocument(ref TDataBinding.FPetraXMLStore, true, true);

                string ymlfileParam = TAppSettingsManager.GetValue("ymlfile", true);

                if (ymlfileParam.Contains(","))
                {
                    StringCollection collection = StringHelper.StrSplit(ymlfileParam, ",");

                    foreach (string file in collection)
                    {
                        ProcessFile(file, SelectedLocalisation);
                    }
                }
                else if (System.IO.Directory.Exists(ymlfileParam))
                {
                    ProcessDirectory(ymlfileParam, SelectedLocalisation);
                }
                else
                {
                    ProcessFile(ymlfileParam, SelectedLocalisation);
                }

                // TODO: generate localised versions
                // TODO: generate minified version. either using YUICompressor, or simple string operation?
                // Or should the xsp server do that? generate js files on the fly? figure out the language of the client? cache files?
            }
            catch (Exception e)
            {
                string commandline = "";

                foreach (string s in args)
                {
                    commandline += s + " ";
                }

                Console.WriteLine("Problem while processing " + commandline);
                Console.WriteLine(e.GetType().ToString() + ": " + e.Message);

                if (e.InnerException != null)
                {
                    Console.WriteLine(e.InnerException.GetType().ToString() + ": " + e.InnerException.Message);
                }

                // do not print a stacktrace for custom generated exception, eg. by the YML parser
                if ((e.GetType() != typeof(System.Exception)) || (TLogging.DebugLevel > 0))
                {
                    Console.WriteLine(e.StackTrace);
                }

                Environment.Exit(-1);
            }
        }
예제 #3
0
        public static void Main(string[] args)
        {
            new TAppSettingsManager(false);

            //enable execution without nant -> debugging easier
            bool independentmode = false;

            if (independentmode)
            {
                TLogging.Log("started in independent-mode");
            }

            try
            {
                if ((TAppSettingsManager.HasValue("do") && (TAppSettingsManager.GetValue("do") == "removeDoNotTranslate")) || independentmode)
                {
                    string doNotTranslatePath;
                    string poFilePath;

                    if (independentmode)
                    {
                        doNotTranslatePath = "E:\\openpetra\\bzr\\work-690\\i18n\\doNotTranslate.po";
                        poFilePath = "E:\\openpetra\\bzr\\work-690\\i18n\\template.pot";
                    }
                    else
                    {
                        doNotTranslatePath = TAppSettingsManager.GetValue("dntFile");
                        poFilePath = TAppSettingsManager.GetValue("poFile");
                    }

                    // remove all strings from po file that are listed in the "Do Not Translate" file
                    TDropUnwantedStrings.RemoveUnwantedStringsFromTranslation(doNotTranslatePath, poFilePath);
                }
                else if (TAppSettingsManager.HasValue("do") && (TAppSettingsManager.GetValue("do") == "errorcodedoc"))
                {
                    TGenerateErrorCodeDoc.Execute(TAppSettingsManager.GetValue("csharppath"),
                        TAppSettingsManager.GetValue("templatefilepath"),
                        TAppSettingsManager.GetValue("outfilepath"));
                }
                else if (TAppSettingsManager.HasValue("do") && (TAppSettingsManager.GetValue("do") == "yamlfiles"))
                {
                    GenerateYamlFiles.WriteYamlFiles(
                        TAppSettingsManager.GetValue("language"),
                        TAppSettingsManager.GetValue("path"),
                        TAppSettingsManager.GetValue("pofile"));
                }
                else if (TAppSettingsManager.HasValue("file"))
                {
                    TGenerateCatalogStrings.Execute(TAppSettingsManager.GetValue("file"), null, null);
                }
                else if (TAppSettingsManager.HasValue("filelist"))
                {
                    TDataDefinitionStore store = new TDataDefinitionStore();
                    Console.WriteLine("parsing " + TAppSettingsManager.GetValue("petraxml", true));
                    TDataDefinitionParser parser = new TDataDefinitionParser(TAppSettingsManager.GetValue("petraxml", true));
                    parser.ParseDocument(ref store, true, true);

                    string CollectedStringsFilename = TAppSettingsManager.GetValue("tmpPath") +
                                                      Path.DirectorySeparatorChar +
                                                      "GenerateI18N.CollectedGettext.cs";
                    StreamWriter writerCollectedStringsFile = new StreamWriter(CollectedStringsFilename);

                    string GettextApp = TAppSettingsManager.GetValue("gettext");

                    string filesToParseWithGettext = string.Empty;
                    StreamReader readerFilelist = new StreamReader(TAppSettingsManager.GetValue("filelist"));

                    while (!readerFilelist.EndOfStream)
                    {
                        string pathCodeFile = readerFilelist.ReadLine().Trim();
                        string ext = Path.GetExtension(pathCodeFile);

                        if (".cs" == ext)
                        {
                            if (TGenerateCatalogStrings.Execute(pathCodeFile, store, writerCollectedStringsFile))
                            {
                                filesToParseWithGettext += "\"" + pathCodeFile + "\" ";

                                if (filesToParseWithGettext.Length > 1500)
                                {
                                    ParseWithGettext(GettextApp, TAppSettingsManager.GetValue("poFile"), filesToParseWithGettext);
                                    filesToParseWithGettext = string.Empty;
                                }
                            }
                        }
                        else if (".yml" == ext)
                        {
                            TGenerateCatalogStrings.AddTranslationUINavigation(pathCodeFile, writerCollectedStringsFile);
                        }
                        else
                        {
                            Console.WriteLine("the file " + pathCodeFile + " has an unknown extension! File ignored!");
                        }
                    }

                    if (filesToParseWithGettext.Length > 0)
                    {
                        ParseWithGettext(GettextApp, TAppSettingsManager.GetValue("poFile"), filesToParseWithGettext);
                    }

                    writerCollectedStringsFile.Close();

                    // delete the file if it is empty
                    if (File.ReadAllText(CollectedStringsFilename).Length == 0)
                    {
                        File.Delete(CollectedStringsFilename);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
예제 #4
0
        public static void Main(string[] args)
        {
            TCmdOpts cmdLine = new TCmdOpts();
            string operation, xmlfile, outputfile;

            try
            {
                operation = cmdLine.GetOptValue("do");
                xmlfile = cmdLine.GetOptValue("petraxml");
                outputfile = cmdLine.GetOptValue("outputFile");
                TWriteSQL.eDatabaseType dbms = TWriteSQL.StringToDBMS(cmdLine.GetOptValue("dbms"));

                if (operation == "sql")
                {
                    System.Console.WriteLine("Reading xml file {0}...", xmlfile);
                    TDataDefinitionParser parser = new TDataDefinitionParser(xmlfile);
                    TDataDefinitionStore store = new TDataDefinitionStore();

                    if (parser.ParseDocument(ref store))
                    {
                        if (dbms == TWriteSQL.eDatabaseType.Sqlite)
                        {
                            // we want to write directly to the database
                            string password = "";

                            if (cmdLine.IsFlagSet("password"))
                            {
                                password = cmdLine.GetOptValue("password");
                            }

                            if (!TSQLiteWriter.CreateDatabase(store, outputfile, password))
                            {
                                Environment.Exit(-1);
                            }
                        }
                        else
                        {
                            // create an sql script that will be loaded into the database later
                            TWriteSQL.WriteSQL(store, dbms, outputfile);
                        }
                    }
                }

                if (operation == "load")
                {
                    if (dbms == TWriteSQL.eDatabaseType.MySQL)
                    {
                        TLoadMysql.LoadData(cmdLine.GetOptValue("database"), cmdLine.GetOptValue("username"),
                            cmdLine.GetOptValue("password"), cmdLine.GetOptValue("sqlfile"));
                    }
                    else if (dbms == TWriteSQL.eDatabaseType.Sqlite)
                    {
                        System.Console.WriteLine("Reading xml file {0}...", xmlfile);
                        TDataDefinitionParser parser = new TDataDefinitionParser(xmlfile);
                        TDataDefinitionStore store = new TDataDefinitionStore();

                        if (parser.ParseDocument(ref store))
                        {
                            if (dbms == TWriteSQL.eDatabaseType.Sqlite)
                            {
                                // we want to write directly to the database
                                string password = "";

                                if (cmdLine.IsFlagSet("password"))
                                {
                                    password = cmdLine.GetOptValue("password");
                                }

                                TSQLiteWriter.ExecuteLoadScript(store, outputfile,
                                    cmdLine.GetOptValue("datapath"),
                                    cmdLine.GetOptValue("sqlfile"),
                                    password);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Error " + e.GetType().ToString() + ": " + e.Message);
                System.Console.WriteLine(e.StackTrace);
                System.Console.WriteLine();
                System.Console.WriteLine("generate the SQL files to create the database in SQL");
                System.Console.WriteLine(
                    "usage: GenerateSQL -do:<operation> -dbms:<type of database system> -petraxml:<path and filename of petra.xml> -outputFile:<path and filename of the output file>");
                System.Console.WriteLine("operations available:");
                System.Console.WriteLine("  sql ");
                System.Console.WriteLine("    sample call: ");
                System.Console.WriteLine(
                    "        GenerateSQL -do:sql -dbms:postgresql -petraxml:u:/sql/datadefinition/petra.xml -outputFile:U:/setup/petra0300/petra.sql");
                System.Console.WriteLine("Available database managment systems and their code:");
                System.Console.WriteLine("  postgresql (Recommended)");
                System.Console.WriteLine("  mysql (experimental)");
                System.Console.WriteLine("  sqlite (for the light version)");
                System.Environment.Exit(-1);
            }
        }
예제 #5
0
파일: main.cs 프로젝트: Davincier/openpetra
        int run()
        {
            new TAppSettingsManager(false);

            cmdLine = new TCmdOpts();

            if (!cmdLine.IsFlagSet("do")
                || ((cmdLine.GetOptValue("do") == "dataset") && (!cmdLine.IsFlagSet("input") || !cmdLine.IsFlagSet("outputNamespace")))
                || ((cmdLine.GetOptValue("do") == "referencecount")
                    && (!cmdLine.IsFlagSet("inputclient") || !cmdLine.IsFlagSet("outputserver") || !cmdLine.IsFlagSet("templatedir"))))
            {
                System.Console.WriteLine("GenerateORM: generate Typed Tables and Datasets");
                System.Console.WriteLine("usage: GenerateORM -do:<operation> -petraxml:<xyz/petra.xml>");
                System.Console.WriteLine("operations available:");
                System.Console.WriteLine("  defaulttables ");
                System.Console.WriteLine("           with parameters: ");
                System.Console.WriteLine("                 -outputshared:<path to ICT/Petra/Shared>");
                System.Console.WriteLine("  dataaccess ");
                System.Console.WriteLine("           with parameters: ");
                System.Console.WriteLine("                 -outputshared:<path to ICT/Petra/Shared>");
                System.Console.WriteLine("  dataset ");
                System.Console.WriteLine("           with parameters: ");
                System.Console.WriteLine("                 -input:<dataset XML file>");
                System.Console.WriteLine("                 -outputNamespace:<Namespace of the file>");
                System.Console.WriteLine("  cachedtables ");
                System.Console.WriteLine("           with parameters: ");
                System.Console.WriteLine("                 -cachedef:<dataset XML file>");
                System.Console.WriteLine("                 -outputshared:<path to ICT/Petra/Shared>");
                System.Console.WriteLine("  referencecount ");
                System.Console.WriteLine("           with parameters: ");
                System.Console.WriteLine("                 -inputclient:<path to ICT/Petra/Client>");
                System.Console.WriteLine("                 -outputserver:<path to ICT/Petra/Server>");
                System.Console.WriteLine("                 -templatedir:<path to inc/template/src>");
                System.Console.WriteLine(
                    "       e.g. GenerateORM -do:dataset -petraxml:U:/sql/datadefinition/petra.xml -input:U:/sql/datadefinition/dataset.xml -outputNamespace:Ict.Petra.Shared.MCommon.Data.Dataset");
                return 100;
            }

            try
            {
                if (cmdLine.GetOptValue("do") == "referencecount")
                {
                    // No need to parse the petra.xml document for this task - so we just run and exit
                    new TLogging();
                    TCreateReferenceCountConnectors createConnectors = new TCreateReferenceCountConnectors();

                    if (!createConnectors.CreateFiles(cmdLine.GetOptValue("outputserver"), cmdLine.GetOptValue("inputclient"),
                            cmdLine.GetOptValue("templatedir")))
                    {
                        return -1;
                    }

                    return 0;
                }

                parser = new TDataDefinitionParser(cmdLine.GetOptValue("petraxml"));
                store = new TDataDefinitionStore();

                if (parser.ParseDocument(ref store))
                {
                    if ((cmdLine.GetOptValue("do") == "defaulttables") || (cmdLine.GetOptValue("do") == "datatables"))
                    {
                        CodeGenerationTable.WriteTypedTable(store, "partner", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MPartner.Partner.Data",
                            "Partner.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "mailroom", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MPartner.Mailroom.Data",
                            "Mailroom.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "personnel", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MPersonnel.Personnel.Data",
                            "Personnel.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "units", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MPersonnel.Units.Data",
                            "Units.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "conference", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MConference.Data",
                            "Conference.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "hospitality", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MHospitality.Data",
                            "Hospitality.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "account", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MFinance.Account.Data",
                            "Account.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "ap", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MFinance.AP.Data",
                            "AP.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "ar", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MFinance.AR.Data",
                            "AR.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "gift", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MFinance.Gift.Data",
                            "Gift.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "sysman", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MSysMan.Data",
                            "SysMan.Tables");
                        CodeGenerationTable.WriteTypedTable(store, "common", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Shared.MCommon.Data",
                            "Common.Tables");

                        CodeGenerationTableValidation.WriteValidation(store, "partner", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MPartner/validation/",
                            "Ict.Petra.Shared.MPartner.Partner.Validation",
                            "Partner.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "mailroom", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MPartner/validation/",
                            "Ict.Petra.Shared.MPartner.Mailroom.Validation",
                            "Mailroom.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "personnel", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MPersonnel/validation/",
                            "Ict.Petra.Shared.MPersonnel.Personnel.Validation",
                            "Personnel.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "units", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MPersonnel/validation/",
                            "Ict.Petra.Shared.MPersonnel.Units.Validation",
                            "Units.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "conference", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MConference/validation/",
                            "Ict.Petra.Shared.MConference.Validation",
                            "Conference.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "hospitality", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MHospitality/validation/",
                            "Ict.Petra.Shared.MHospitality.Validation",
                            "Hospitality.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "account", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MFinance/validation/",
                            "Ict.Petra.Shared.MFinance.Account.Validation",
                            "Account.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "ap", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MFinance/validation/",
                            "Ict.Petra.Shared.MFinance.AP.Validation",
                            "AP.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "ar", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MFinance/validation/",
                            "Ict.Petra.Shared.MFinance.AR.Validation",
                            "AR.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "gift", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MFinance/validation/",
                            "Ict.Petra.Shared.MFinance.Gift.Validation",
                            "Gift.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "sysman", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MSysMan/validation/",
                            "Ict.Petra.Shared.MSysMan.Validation",
                            "SysMan.Validation");
                        CodeGenerationTableValidation.WriteValidation(store, "common", cmdLine.GetOptValue(
                                "outputshared") + "/lib/MCommon/validation/",
                            "Ict.Petra.Shared.MCommon.Validation",
                            "Common.Validation");

                        TGenerateTableList.WriteTableList(store, cmdLine.GetOptValue(
                                "outputshared") + Path.DirectorySeparatorChar + "TableList-generated.cs");
                        TGenerateTableList.WriteDBClean(store, Path.GetDirectoryName(cmdLine.GetOptValue(
                                    "petraxml")) + Path.DirectorySeparatorChar + "basedata" + Path.DirectorySeparatorChar + "clean.sql");
                    }
                    else if (cmdLine.GetOptValue("do") == "dataaccess")
                    {
                        CodeGenerationAccess.WriteTypedDataAccess(store, "partner", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MPartner.Partner.Data.Access",
                            "Partner.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "mailroom", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MPartner.Mailroom.Data.Access",
                            "Mailroom.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "personnel", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MPersonnel.Personnel.Data.Access",
                            "Personnel.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "units", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MPersonnel.Units.Data.Access",
                            "Units.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "conference", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MConference.Data.Access",
                            "Conference.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "hospitality", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MHospitality.Data.Access",
                            "Hospitality.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "account", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MFinance.Account.Data.Access",
                            "Account.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "ap", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MFinance.AP.Data.Access",
                            "AP.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "ar", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MFinance.AR.Data.Access",
                            "AR.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "gift", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MFinance.Gift.Data.Access",
                            "Gift.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "sysman", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MSysMan.Data.Access",
                            "SysMan.Access");
                        CodeGenerationAccess.WriteTypedDataAccess(store, "common", cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MCommon.Data.Access",
                            "Common.Access");
                        CodeGenerationCascading.WriteTypedDataCascading(store, cmdLine.GetOptValue(
                                "outputshared") + "/lib/data/",
                            "Ict.Petra.Server.MCommon.Data.Cascading",
                            "Cascading");
                    }
                    else if (cmdLine.GetOptValue("do") == "dataset")
                    {
                        string[] groups = new string[] {
                            "common", "mailroom", "sysman", "partner",
                            "account", "gift", "ap", "ar", "personnel", "units", "conference", "hospitality"
                        };

                        CodeGenerationDataset.CreateTypedDataSets(cmdLine.GetOptValue("input"),
                            cmdLine.GetOptValue("outputdir"),
                            cmdLine.GetOptValue("outputNamespace"),
                            store, groups,
                            cmdLine.GetOptValue("outputFilename"));
                    }
                    else if (cmdLine.GetOptValue("do") == "datasetaccess")
                    {
                        string[] groups = new string[] {
                            "common", "mailroom", "sysman", "partner",
                            "account", "gift", "ap", "ar", "personnel", "units", "conference", "hospitality"
                        };

                        CodeGenerationDatasetAccess.CreateTypedDataSets(cmdLine.GetOptValue("input"),
                            cmdLine.GetOptValue("outputdir"),
                            cmdLine.GetOptValue("outputNamespace"),
                            store, groups,
                            cmdLine.GetOptValue("outputFilename"));
                    }
                    else if (cmdLine.GetOptValue("do") == "cachedtables")
                    {
                        Ict.Tools.CodeGeneration.CachedTables.TGenerateCachedTables.WriteCachedTables(
                            store,
                            cmdLine.GetOptValue("cachedef"),
                            cmdLine.GetOptValue("outputshared"),
                            cmdLine.GetOptValue("TemplateDir"));
                    }
                    else
                    {
                        Console.WriteLine("could not recognise: " + cmdLine.GetOptValue("do"));
                    }
                }
            }
            catch (Exception E)
            {
                System.Console.WriteLine(E.Message);
                System.Console.WriteLine(E.StackTrace);
                return 100;
                // System.Console.ReadLine();
            }
            return 0;
        }
예제 #6
0
        public static void Main(string[] args)
        {
            new TLogging("delivery/bin/Ict.Tools.DataMigrateStatistics.log");
            new TAppSettingsManager(false);

            string row_count_location = TAppSettingsManager.GetValue("fulldumpPath", "delivery/bin/fulldump") +
                                        Path.DirectorySeparatorChar + "_row_count.txt";

            if (File.Exists(row_count_location))
            {
                DBAccess.GDBAccessObj = new TDataBase();

                TCmdOpts cmdLine = new TCmdOpts();
                string xmlfile = cmdLine.GetOptValue("petraxml");

                DBAccess.GDBAccessObj.EstablishDBConnection(CommonTypes.ParseDBType(cmdLine.GetOptValue("type")), cmdLine.GetOptValue("host"),
                    cmdLine.GetOptValue("port"), cmdLine.GetOptValue("database"), cmdLine.GetOptValue("username"), cmdLine.GetOptValue(
                        "password"), "");

                TDataDefinitionParser parserNew = new TDataDefinitionParser(xmlfile, false);
                TDataDefinitionStore storeNew = new TDataDefinitionStore();
                parserNew.ParseDocument(ref storeNew, false, true);
                List <TTable>newTables = storeNew.GetTables();

                // table names and row numbers on alternate lines
                string[] checkRows = File.ReadAllLines(row_count_location);

                Console.WriteLine();
                Console.WriteLine("--- Testing all rows have loaded successfully ---");

                int totalRows = 0; // total number of rows in database
                int totalCheckRows = 0; // total number of rows there should be in the database
                bool rowsMissing = false;

                foreach (TTable newTable in newTables)
                {
                    if (newTable.strName != "s_login") // ignore this table as the row count changes everytime a connection is made to the database
                    {
                        int i = 0;
                        int rowCount; // number of rows actually in table
                        int rowCountCheck = 0; // number of rows there should be in table

                        // count rows in table
                        string sql = "SELECT count(*) from " + newTable.strName + ";";
                        rowCount = Convert.ToInt32(DBAccess.GDBAccessObj.ExecuteScalar(sql, IsolationLevel.ReadUncommitted));

                        // read how many rows there should be in the same table
                        while (i < checkRows.Length)
                        {
                            if (checkRows[i] == newTable.strName)
                            {
                                rowCountCheck = Convert.ToInt32(checkRows[i + 1]);
                                break;
                            }

                            i += 2;
                        }

                        totalRows += rowCount;
                        totalCheckRows += rowCountCheck;

                        // if there are rows missing
                        if (rowCount != rowCountCheck)
                        {
                            Console.Write(newTable.strName + " is incomplete. ");
                            Console.WriteLine((rowCountCheck - rowCount) + " out of " + rowCountCheck + " rows did not load!");
                            rowsMissing = true;
                        }
                    }
                }

                // if all rows are present
                if (!rowsMissing)
                {
                    Console.WriteLine("All rows successfully loaded.");
                }

                // write a summary of the number of rows successfully loaded
                Console.WriteLine();
                Console.WriteLine("--- Total number of rows loaded ---");
                Console.WriteLine(totalRows + " out of " + totalCheckRows + " rows loaded successfully.");
                string percentage = (((double)totalRows / totalCheckRows) * 100).ToString("#.##");
                Console.WriteLine(percentage + "%");
                Console.WriteLine();

                DBAccess.GDBAccessObj.CloseDBConnection();
            }
            else
            {
                TLogging.Log("Warning: unable to perform a row count test. _row_count.txt is missing from the folder .../delivery/bin/fulldump.");
                TLogging.Log("");
            }
        }
        /// <summary>
        /// create a Progress .p program for dumping the Progress data to CSV files
        /// </summary>
        public void GenerateFulldumpCode()
        {
            string PetraOldPath = TAppSettingsManager.GetValue("oldpetraxml", "petra23.xml");

            TDataDefinitionParser parserOld = new TDataDefinitionParser(PetraOldPath);

            parserOld.SupportPetra2xLegacyStandard = true;

            storeOld = new TDataDefinitionStore();

            System.Console.WriteLine("Reading 2.x xml file {0}...", PetraOldPath);

            if (!parserOld.ParseDocument(ref storeOld, false, true))
            {
                return;
            }

            string OutputFile = "fulldump23.p";

            System.Console.WriteLine("Writing file to {0}...", OutputFile);
            StreamWriter progressWriter = new StreamWriter(OutputFile);

            // print file header
            progressWriter.WriteLine("/* Generated with Ict.Tools.DataDumpPetra2x.exe */");

            System.Resources.ResourceManager RM = new System.Resources.ResourceManager("Ict.Tools.DataDumpPetra2.templateCode",
                System.Reflection.Assembly.GetExecutingAssembly());
            progressWriter.WriteLine(RM.GetString("progress_dump_functions"));

            progressWriter.WriteLine();

            List <TTable>oldTables = storeOld.GetTables();

            foreach (TTable oldTable in oldTables)
            {
                DumpTable(ref progressWriter, oldTable);
            }

            DumpSequences(ref progressWriter);
            progressWriter.WriteLine();
            progressWriter.Close();
            System.Console.WriteLine("Success: file written: {0}", Path.GetFullPath(OutputFile));
        }
예제 #8
0
        /// <summary>
        /// get the data structure for the new version
        /// </summary>
        public static TDataDefinitionStore GetStoreNew()
        {
            if (storeNew == null)
            {
                string PetraNewPath = TAppSettingsManager.GetValue("newpetraxml", "petra.xml");

                TLogging.Log(String.Format("Reading OpenPetra xml file {0}...", PetraNewPath));

                TDataDefinitionParser parserNew = new TDataDefinitionParser(PetraNewPath, false);
                storeNew = new TDataDefinitionStore();

                if (!parserNew.ParseDocument(ref storeNew, false, true))
                {
                    return null;
                }
            }

            return storeNew;
        }