Beispiel #1
0
        /// <summary>
        /// Creates Sample Data using the raw data provided and exports this to the Petra Server
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            TLogging.Log("Running Sample Data Constructor");

            try
            {
                TLogging.Log("(1) Initialize (check availability of resources, start the server)");

                TLogging.Log("\tStarting the server...");

                // use the config file defined on the command line with -C:
                TPetraServerConnector.Connect(string.Empty);

                // data directory containing the raw data files created by benerator
                string datadirectory = TAppSettingsManager.GetValue("dir.data.generated");

                eOperations operation = eOperations.importPartners | eOperations.importRecipients | eOperations.ledgerOneYear;

                if (TAppSettingsManager.GetValue("operation", false) == "secondLedger")
                {
                    operation = eOperations.secondLedger;
                }
                else if (TAppSettingsManager.GetValue("operation", false) == "ledgerMultipleYears")
                {
                    operation = eOperations.importPartners | eOperations.importRecipients | eOperations.ledgerMultipleYears;
                }

                if ((int)(operation & eOperations.importPartners) > 0)
                {
                    TLogging.Log("(2) Import partners");
                    SampleDataBankPartners.GenerateBanks(
                        Path.Combine(datadirectory, "banks.csv"));

                    SampleDataDonors.GenerateFamilyPartners(
                        Path.Combine(datadirectory, "people.csv"));

                    TLogging.Log("(3) Import organisations");
                    SampleDataOrganisations.GenerateOrganisationPartners(
                        Path.Combine(datadirectory, "organisations.csv"));
                }

                TLogging.Log("(4) Import recipients");

                if ((int)(operation & eOperations.importRecipients) > 0)
                {
                    // parse random data generated by benerator
                    SampleDataUnitPartners.GenerateFields(
                        Path.Combine(datadirectory, "fields.csv"));
                    SampleDataUnitPartners.GenerateKeyMinistries(
                        Path.Combine(datadirectory, "keymins.csv"));
                    SampleDataWorkers.GenerateWorkers(
                        Path.Combine(datadirectory, "workers.csv"));
                }

                if ((int)(operation & eOperations.ledgerOneYear) > 0)
                {
                    SampleDataLedger.FLedgerNumber          = 43;
                    SampleDataLedger.FNumberOfClosedPeriods = CalculatedNumberOfClosedPeriods(0);
                    SampleDataLedger.InitCalendar();
                    SampleDataLedger.InitExchangeRate();
                    SampleDataLedger.PopulateData(datadirectory, true);
                    TLogging.Log("Please explicitely run nant importDemodata -D:operation=secondLedger");
                    TLogging.Log("   or                  nant importDemodata -D:operation=ledgerMultipleYears");
                }

                if ((int)(operation & eOperations.ledgerMultipleYears) > 0)
                {
                    SampleDataLedger.FLedgerNumber          = 43;
                    SampleDataLedger.FNumberOfClosedPeriods = TAppSettingsManager.GetInt32("NumberOfClosedPeriods", CalculatedNumberOfClosedPeriods(2));
                    SampleDataLedger.InitCalendar();
                    SampleDataLedger.InitExchangeRate();
                    SampleDataLedger.PopulateData(datadirectory, true);
                }

                if ((int)(operation & eOperations.secondLedger) > 0)
                {
                    TLogging.Log("creating a second ledger");

                    // this ledger starts in period 4
                    SampleDataLedger.FLedgerNumber          = 44;
                    SampleDataLedger.FNumberOfClosedPeriods = CalculatedNumberOfClosedPeriods(0) - 3;
                    SampleDataLedger.CreateNewLedger();
                    SampleDataLedger.InitExchangeRate();

                    SampleDataUnitPartners.FLedgerNumber = SampleDataLedger.FLedgerNumber;

                    SampleDataLedger.PopulateData(datadirectory);
                }

                TLogging.Log("Completed.");
            }
            catch (Exception e)
            {
                TLogging.Log(e.Message);
                TLogging.Log(e.StackTrace);
                Environment.Exit(-1);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates Sample Data using the raw data provided and exports this to the Petra Server
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            TLogging.Log("Running Sample Data Constructor");

            try
            {
                TLogging.Log("(1) Initialize (check availability of resources, start the server)");

                TLogging.Log("\tStarting the server...");

                // use the config file defined on the command line with -C:
                TPetraServerConnector.Connect(string.Empty);

                // data directory containing the raw data files created by benerator
                string datadirectory = TAppSettingsManager.GetValue("dir.data.generated");

                string operation = TAppSettingsManager.GetValue("operation", "importPartners");

                if ((operation == "importPartners") || (operation == "all"))
                {
                    TLogging.Log("(2) Import partners");
                    SampleDataBankPartners.GenerateBanks(
                        Path.Combine(datadirectory, "banks.csv"));

                    SampleDataDonors.GenerateFamilyPartners(
                        Path.Combine(datadirectory, "people.csv"));

                    TLogging.Log("(3) Import organisations");
                    SampleDataOrganisations.GenerateOrganisationPartners(
                        Path.Combine(datadirectory, "organisations.csv"));
                }

                TLogging.Log("(4) Import recipients");

                operation = TAppSettingsManager.GetValue("operation", "importRecipients");

                if ((operation == "importRecipients") || (operation == "all"))
                {
                    // parse random data generated by benerator
                    SampleDataUnitPartners.GenerateFields(
                        Path.Combine(datadirectory, "fields.csv"));
                    SampleDataUnitPartners.GenerateKeyMinistries(
                        Path.Combine(datadirectory, "keymins.csv"));
                    SampleDataWorkers.GenerateWorkers(
                        Path.Combine(datadirectory, "workers.csv"));
                }

                operation = TAppSettingsManager.GetValue("operation", "populateFirstLedger");

                if ((operation == "populateFirstLedger") || (operation == "all"))
                {
                    SampleDataLedger.FLedgerNumber          = 43;
                    SampleDataLedger.FNumberOfClosedPeriods = TAppSettingsManager.GetInt32("NumberOfClosedPeriods", 26);
                    SampleDataLedger.InitCalendar();
                    SampleDataLedger.InitExchangeRate();
                    SampleDataLedger.PopulateData(datadirectory);
                }

                if (operation == "secondLedger")
                {
                    TLogging.Log("creating a second ledger");

                    SampleDataLedger.FLedgerNumber          = 44;
                    SampleDataLedger.FNumberOfClosedPeriods = 6;
                    SampleDataLedger.CreateNewLedger();
                    SampleDataLedger.InitExchangeRate();

                    SampleDataUnitPartners.FLedgerNumber = SampleDataLedger.FLedgerNumber;
                    SampleDataUnitPartners.GenerateFieldsFinanceOnly(
                        Path.Combine(datadirectory, "fields.csv"));

                    SampleDataLedger.PopulateData(datadirectory);
                }
                else
                {
                    TLogging.Log("Please explicitely run nant importDemodata -D:operation=secondLedger");
                }

                TLogging.Log("(9) Creating applications for conference");

                operation = TAppSettingsManager.GetValue("operation", "conferenceApplications");

                if (operation == "conferenceApplications")
                {
                    SampleDataConferenceApplicants.GenerateApplications(Path.Combine(datadirectory, "conferenceApplications.csv"));
                }
                else
                {
                    TLogging.Log("Please explicitely run nant importDemodata -D:operation=conferenceApplications");
                }

                TLogging.Log("Completed.");
            }
            catch (Exception e)
            {
                TLogging.Log(e.Message);
                TLogging.Log(e.StackTrace);
                Environment.Exit(-1);
            }
        }