Example #1
0
        public static void Main(string[] args)
        {
            TCmdOpts cmd = new TCmdOpts();

            new TAppSettingsManager(false);

            TLogging.DebugLevel = TAppSettingsManager.GetInt32("debuglevel", 0);

            String OutputDir;

            if (!cmd.IsFlagSet("TemplateDir"))
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }

            if (cmd.IsFlagSet("plugin"))
            {
                OutputDir = cmd.GetOptValue("plugindir");

                // calculate ICTPath from outputdir
                string fullOutputPath = Path.GetFullPath(OutputDir).Replace("\\", "/");

                if (!fullOutputPath.Contains("csharp/ICT"))
                {
                    Console.WriteLine("Output path must be below the csharp/ICT directory");
                }

                CSParser.ICTPath = fullOutputPath.Substring(0, fullOutputPath.IndexOf("csharp/ICT") + "csharp/ICT".Length);
                GenerateGlueForPlugin(cmd, OutputDir);
            }
            else if (cmd.IsFlagSet("outputdir"))
            {
                OutputDir = cmd.GetOptValue("outputdir");

                // calculate ICTPath from outputdir
                string fullOutputPath = Path.GetFullPath(OutputDir).Replace("\\", "/");

                if (!fullOutputPath.Contains("csharp/ICT"))
                {
                    Console.WriteLine("Output path must be below the csharp/ICT directory");
                }

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

                GenerateGlueForOpenPetraCore(cmd, OutputDir);
            }
            else
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }
        }
Example #2
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);
            }
        }
Example #3
0
        /// <summary>
        /// this should be called by the constructors only;
        /// in C# one constructor cannot call another constructor, so we have moved the code to a different method
        /// </summary>
        /// <param name="CustomConfigFileName">Name of the .NET Configuration File to read from</param>
        /// <param name="AFailOnMissingConfigFile">if this is true and there is no config file, an exception is raised</param>
        /// <returns>void</returns>
        private void Create(String CustomConfigFileName, bool AFailOnMissingConfigFile)
        {
            FCmdOpts = new TCmdOpts();

            if (CustomConfigFileName != "")
            {
                FConfigFileName = CustomConfigFileName;
            }
            else if (FCmdOpts.IsFlagSet("C") == true)
            {
                FConfigFileName = FCmdOpts.GetOptValue("C");
            }
            else if (FConfigFileName.Length == 0) // don't reset the name if it was set manually before
            {
                if (Environment.GetCommandLineArgs().Length == 0)
                {
                    // somehow the Environment commandlineargs are empty during debugging
                    throw new Exception("During debugging, please use the parameter -C for the config file");
                }
                else
                {
                    FConfigFileName = Environment.GetCommandLineArgs()[0] + ".config";
                }
            }

            LoadCustomAppSettingFile(AFailOnMissingConfigFile);
        }
Example #4
0
        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;
        }
Example #5
0
        private static void GenerateGlueForOpenPetraCore(TCmdOpts ACmd, string AOutputDir)
        {
            TNamespace namespaceRoot;

            try
            {
                Console.WriteLine("parsing all cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(AOutputDir + "/Server/lib/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("problems with parsing namespaces from " + AOutputDir + "/Server/lib/");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                /*
                 * CreateInstantiators instantiators = new CreateInstantiators();
                 * instantiators.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                 * TCreateConnectors connectors = new TCreateConnectors();
                 * connectors.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                 */

                CreateInterfaces interfaces = new CreateInterfaces();
                interfaces.CreateFiles(namespaceRoot, AOutputDir + "/Shared/lib/Interfaces", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/Client/app/Core/Remoteobjects", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateConnectorCode(AOutputDir + "/../Common/Remoting/Client", ACmd.GetOptValue("TemplateDir"));
                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server/app/WebService", ACmd.GetOptValue("TemplateDir"));

                namespaceRoot = new TNamespace();
                TNamespace ServerAdminNamespace = new TNamespace("ServerAdmin");
                namespaceRoot.Children.Add("ServerAdmin", ServerAdminNamespace);
                TNamespace ServerAdminWebConnectorNamespace = new TNamespace("WebConnectors");
                ServerAdminNamespace.Children.Add("WebConnectors", ServerAdminWebConnectorNamespace);

                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server/app/WebService", ACmd.GetOptValue("TemplateDir"));
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/ServerAdmin/app/Core", ACmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Example #6
0
        private static void GenerateGlueForPlugin(TCmdOpts ACmd, string AOutputDir)
        {
            TNamespace namespaceRoot;

            AOutputDir = AOutputDir.Replace("\\", "/");

            try
            {
                Console.WriteLine("parsing plugin cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(AOutputDir + "/Server/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("There are no connectors in " + AOutputDir + "/Server/");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                CreateInterfaces interfaces = new CreateInterfaces();
#if disabled
                // at the moment, we do not support UIConnectors for plugins. Better to focus on Webconnectors!
                if (!Directory.Exists(AOutputDir + "/Shared"))
                {
                    Directory.CreateDirectory(AOutputDir + "/Shared");
                }
                interfaces.CreateFiles(namespaceRoot, AOutputDir + "/Shared", ACmd.GetOptValue("TemplateDir"));
#endif
                GenerateClientGlue.GenerateCode(namespaceRoot, AOutputDir + "/Client", ACmd.GetOptValue("TemplateDir"));
                GenerateServerGlue.GenerateCode(namespaceRoot, AOutputDir + "/Server", ACmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Example #7
0
        public static void Main(string[] args)
        {
            TCmdOpts cmd = new TCmdOpts();

            new TAppSettingsManager(false);

            TLogging.DebugLevel = TAppSettingsManager.GetInt32("debuglevel", 0);

            String OutputDir;

            if (!cmd.IsFlagSet("TemplateDir"))
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }

            if (cmd.IsFlagSet("outputdir"))
            {
                OutputDir = cmd.GetOptValue("outputdir");

                // calculate ICTPath from outputdir
                string fullOutputPath = Path.GetFullPath(OutputDir).Replace("\\", "/");

                if (!fullOutputPath.Contains("csharp/ICT"))
                {
                    Console.WriteLine("Output path must be below the csharp/ICT directory");
                }

                CSParser.ICTPath = fullOutputPath.Substring(0, fullOutputPath.IndexOf("csharp/ICT") + "csharp/ICT".Length);
            }
            else
            {
                Console.WriteLine("call: " + sampleCall);
                return;
            }

            TNamespace namespaceRoot;

            try
            {
                Console.WriteLine("parsing all cs files for namespaces...");
                namespaceRoot = TNamespace.ParseFromDirectory(OutputDir + "/Server/lib/");

                if (namespaceRoot.Children.Count < 1)
                {
                    Console.WriteLine("problems with parsing namespaces from " + OutputDir + "/Server/lib/");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
                return;
            }

            try
            {
                CreateInterfaces interfaces = new CreateInterfaces();
                interfaces.CreateFiles(namespaceRoot, OutputDir + "/Shared/lib/Interfaces", cmd.GetOptValue("TemplateDir"));
                CreateInstantiators instantiators = new CreateInstantiators();
                instantiators.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
                TCreateConnectors connectors = new TCreateConnectors();
                connectors.CreateFiles(namespaceRoot, OutputDir + "/Server/lib", cmd.GetOptValue("TemplateDir"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Example #8
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("");
            }
        }
Example #9
0
        public static void Main(string[] args)
        {
            try
            {
                // establish connection to database
                TCmdOpts settings = new TCmdOpts();

                if (!settings.IsFlagSet("Server.ODBC_DSN"))
                {
                    Console.WriteLine(
                        "sample call: " +
                        "ExportDataProgress.exe -Server.ODBC_DSN:Petra2_2sa -username:demo_sql -password:demo -sql:\"SELECT * from pub.a_account\" -output:test.xml");
                    Environment.Exit(-1);
                }

                new TLogging("debug.log");

                TDataBase db = new TDataBase();

                TDBType dbtype = TDBType.ProgressODBC;

                if (settings.IsFlagSet("Server.RDBMSType"))
                {
                    dbtype = CommonTypes.ParseDBType(settings.GetOptValue("Server.RDBMSType"));
                }

                if (dbtype != TDBType.ProgressODBC)
                {
                    throw new Exception("at the moment only Progress ODBC db is supported");
                }

                db.EstablishDBConnection(dbtype,
                    settings.GetOptValue("Server.ODBC_DSN"),
                    "",
                    "",
                    settings.GetOptValue("username"),
                    settings.GetOptValue("password"),
                    "");
                DBAccess.GDBAccessObj = db;

                TLogging.DebugLevel = 10;

                string sqlText = "";

                if (!settings.IsFlagSet("sql"))
                {
                    Console.WriteLine("Please enter sql and finish with semicolon: ");

                    while (!sqlText.Trim().EndsWith(";"))
                    {
                        sqlText += " " + Console.ReadLine();
                    }

                    sqlText = sqlText.Substring(0, sqlText.Length - 1);
                }
                else
                {
                    sqlText = settings.GetOptValue("sql");
                    Console.WriteLine(sqlText);
                }

                TDBTransaction transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadUncommitted);

                DataTable table = db.SelectDT(sqlText, "temp", transaction);

                XmlDocument doc = TDataBase.DataTableToXml(table);

                if (settings.IsFlagSet("output"))
                {
                    if (settings.GetOptValue("output").EndsWith("yml"))
                    {
                        TYml2Xml.Xml2Yml(doc, settings.GetOptValue("output"));
                    }
                    else if (settings.GetOptValue("output").EndsWith("csv"))
                    {
                        TCsv2Xml.Xml2Csv(doc, settings.GetOptValue("output"));
                    }
                    else if (settings.GetOptValue("output").EndsWith("xml"))
                    {
                        StreamWriter sw = new StreamWriter(settings.GetOptValue("output"));
                        sw.Write(TXMLParser.XmlToString2(doc));
                        sw.Close();
                    }
                }
                else
                {
                    TYml2Xml.Xml2Yml(doc, "temp.yml");
                    StreamReader sr = new StreamReader("temp.yml");
                    Console.WriteLine(sr.ReadToEnd());
                    sr.Close();
                }

                db.RollbackTransaction();
                db.CloseDBConnection();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }
        }