Esempio n. 1
0
        /// main method
        public static void Main(string[] args)
        {
            TPetraServerConnector.Connect("../../etc/TestServer.config");

            try
            {
                string OutputPath = TAppSettingsManager.GetValue("OutputPath", "../../delivery/GDPdU/data");

                if (!Directory.Exists(OutputPath))
                {
                    Directory.CreateDirectory(OutputPath);
                }

                string SummaryCostCentres            = TAppSettingsManager.GetValue("SummaryCostCentres", "4300S");
                string IgnoreCostCentres             = TAppSettingsManager.GetValue("IgnoreCostCentres", "xyz");
                string IgnoreAccounts                = TAppSettingsManager.GetValue("IgnoreAccounts", "4300S,GIFT");
                string IncludeAccounts               = TAppSettingsManager.GetValue("IncludeAccounts", "4310");
                string FinancialYears                = TAppSettingsManager.GetValue("FinancialYearNumber", "0");
                string IgnoreTransactionsByReference = TAppSettingsManager.GetValue("IgnoreReference", "L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12");
                int    FirstFinancialYear            = TAppSettingsManager.GetInt32("FirstFinancialYear", DateTime.Now.Year);
                int    LedgerNumber = TAppSettingsManager.GetInt32("LedgerNumber", 43);
                char   CSVSeparator = TAppSettingsManager.GetValue("CSVSeparator", ";")[0];
                string NewLine      = "\r\n";
                string culture      = TAppSettingsManager.GetValue("culture", "de-DE");

                string ReportingCostCentres =
                    TFinanceReportingWebConnector.GetReportingCostCentres(LedgerNumber, SummaryCostCentres, IgnoreCostCentres);

                //TLogging.Log("cost centres " + ReportingCostCentres);
                //TLogging.Log("accounts " + IncludeAccounts);

                if (TAppSettingsManager.GetBoolean("IgnorePersonCostCentres", true))
                {
                    ReportingCostCentres = TGDPdUExportAccountsAndCostCentres.WithoutPersonCostCentres(LedgerNumber, ReportingCostCentres);
                }

                IgnoreAccounts =
                    TFinanceReportingWebConnector.GetReportingAccounts(LedgerNumber, IgnoreAccounts, IncludeAccounts);

                // set decimal separator, and thousands separator
                Ict.Common.Catalog.SetCulture(culture);

                List <string> CostCentresInvolved = new List <string>();
                List <string> AccountsInvolved    = new List <string>();

                foreach (string FinancialYearString in FinancialYears.Split(new char[] { ',' }))
                {
                    Int32 FinancialYear = Convert.ToInt32(FinancialYearString);

                    string OutputPathForYear = Path.Combine(OutputPath, (FirstFinancialYear + FinancialYear).ToString());

                    if (!Directory.Exists(OutputPathForYear))
                    {
                        Directory.CreateDirectory(OutputPathForYear);
                    }

                    TGDPdUExportWorkers.Export(OutputPathForYear, CSVSeparator, NewLine,
                                               LedgerNumber * 1000000,
                                               FirstFinancialYear + FinancialYear);

                    TGDPdUExportTransactions.ExportGLTransactions(OutputPathForYear,
                                                                  CSVSeparator,
                                                                  NewLine,
                                                                  LedgerNumber,
                                                                  FinancialYear,
                                                                  ReportingCostCentres,
                                                                  IgnoreAccounts,
                                                                  IgnoreTransactionsByReference,
                                                                  ref CostCentresInvolved,
                                                                  ref AccountsInvolved);

                    TGDPdUExportBalances.ExportGLBalances(OutputPathForYear, CSVSeparator, NewLine, LedgerNumber,
                                                          FinancialYear, ReportingCostCentres,
                                                          IgnoreAccounts);
                }

                TGDPdUExportAccountsAndCostCentres.ExportCostCentres(OutputPath, CSVSeparator, NewLine, LedgerNumber,
                                                                     CostCentresInvolved);

                TGDPdUExportAccountsAndCostCentres.ExportAccounts(OutputPath, CSVSeparator, NewLine, LedgerNumber,
                                                                  AccountsInvolved);
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
            }

            if (TAppSettingsManager.GetValue("interactive", "true") == "true")
            {
                Console.WriteLine("Please press Enter to continue...");
                Console.ReadLine();
            }
        }