Exemplo n.º 1
0
        /// <summary>
        /// Allows the server or admin console to run a timed processing job now
        /// </summary>
        public override void PerformTimedProcessingNow(string AProcessName)
        {
            //
            // Set up 'Timed Processing'
            //
            TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30");

            if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true))
            {
                Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing");
                Type     PartnerReminderClass      = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders");
                TTimedProcessing.AddProcessingJob(
                    "TProcessPartnerReminders",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        PartnerReminderClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     ProcessDataChecksClass   = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks");
                TTimedProcessing.AddProcessingJob(
                    "TProcessDataChecks",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        ProcessDataChecksClass,
                        "Process"));
            }

            TTimedProcessing.RunJobManually(AProcessName);
        }
Exemplo n.º 2
0
        public static void GetServerSmtpSettings(out string ASMTPHost,
                                                 out int ASMTPPort,
                                                 out bool AEnableSsl,
                                                 out string ALoginUsername,
                                                 out string ALoginPassword)
        {
            ASMTPHost      = TAppSettingsManager.GetValue("SmtpHost", "");
            ASMTPPort      = TAppSettingsManager.GetInt32("SmtpPort", 25);
            AEnableSsl     = TAppSettingsManager.GetBoolean("SmtpEnableSsl", false);
            ALoginUsername = null;
            ALoginPassword = null;

            // Validate the host name.  It should not be the content of an unmodified config file.
            if (ASMTPHost.Contains("example.org"))
            {
                ASMTPHost = string.Empty;
                return;
            }

            if (TAppSettingsManager.GetBoolean("SmtpRequireCredentials", false) == true)
            {
                // We give the client the details of the OP Email user.
                // The password is converted from a byte array (rather than being compiled into this DLL as plain text).
                // The username and password are stored in different server DLL's.
                ALoginUsername = MSysManConstants.EMAIL_USER_LOGIN_NAME;
                ALoginPassword = Encoding.ASCII.GetString(EmailUserPassword);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Use a .NET PrintPreview Dialog to print (or not print) this (possibly multi-page) HTML document.
        /// </summary>
        /// <param name="HtmlPages"></param>
        public static void PreviewOrPrint(String HtmlPages)
        {
            System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
            bool printerInstalled = printDocument.PrinterSettings.IsValid;

            if (!printerInstalled)
            {
                MessageBox.Show(Catalog.GetString("There is no printer, so printing is not possible"));
                return;
            }

            TGfxPrinter  GfxPrinter  = new TGfxPrinter(printDocument, TGfxPrinter.ePrinterBehaviour.eFormLetter);
            TPrinterHtml htmlPrinter = new TPrinterHtml(HtmlPages,
                                                        TAppSettingsManager.GetValue("Formletters.Path"),
                                                        GfxPrinter);

            GfxPrinter.Init(eOrientation.ePortrait, htmlPrinter, eMarginType.ePrintableArea);

            CoolPrintPreviewDialog PrintDlg = new CoolPrintPreviewDialog();

            PrintDlg.Document   = GfxPrinter.Document;
            PrintDlg.ClientSize = new System.Drawing.Size(500, 720);
            try
            {
                PrintDlg.ShowDialog();
            }
            catch (Exception)  // if the user presses Cancel, an exception may be raised!
            {
            }
        }
Exemplo n.º 4
0
        public void Init()
        {
            new TLogging("../../log/test.log");
            new TAppSettingsManager("../../etc/TestServer.config");
            FDBType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType"));

            FDataBase = DBAccess.Connect(DefaultDBConnName);

            // Reset some Fields for every Test
            FTestDBInstance1                      = null;
            FTestDBInstance2                      = null;
            FTestCallDBCommand1                   = null;
            FTestCallDBCommand2                   = null;
            FTestingThread1                       = null;
            FTestingThread2                       = null;
            FTestingThread1NewTransaction         = false;
            FTestingThread2NewTransaction         = false;
            FTestingThread1Exception              = null;
            FTestingThread2Exception              = null;
            FEstablishedDBConnectionSignalDBConn1 = null;
            FEstablishedDBConnectionSignalDBConn2 = null;
            FCloseDBConnectionSignalDBConn1       = null;
            FCloseDBConnectionSignalDBConn2       = null;
            FDBConnectionClosedSignalDBConn1      = null;
            FDBConnectionClosedSignalDBConn2      = null;
            FGotNewOrExistingDBTransactionSignal1 = null;
            FGotNewOrExistingDBTransactionSignal2 = null;
            FRollbackDBTransactionSignal1         = null;
            FRollbackDBTransactionSignal2         = null;
            FDBTransactionRolledbackSignal1       = null;
            FDBTransactionRolledbackSignal2       = null;
            FProgressUpdateCounter                = 0;
            FProgressUpdateNumber                 = 0;
        }
Exemplo n.º 5
0
        private static WebClientWithSession GetNewWebClient(string url)
        {
            CookieContainer CookieCont = new CookieContainer();

            TLogging.LogAtLevel(1, "SetWebClient: url argument is: " + url);

            if (url.StartsWith("Login"))
            {
                ResetSession();
            }

            if ((OverallCookie == null) &&
                url.StartsWith(TAppSettingsManager.GetValue("OpenPetra.HTTPServer")) &&
                !(url.Contains("Login") || (url.Contains("/client")) ||
                  (url.Contains("serverMServerAdmin.asmx"))))
            {
                TLogging.Log("GetNewWebClient: Cannot connect to the server without a cookie!  url=" + url);
                throw new Exception("Cannot connect to the server without a cookie!  url=" + url);
            }

            if (OverallCookie != null)
            {
                TLogging.LogAtLevel(1, "SetWebClient: OverallCookie exists - copying!");
                CookieCont = new CookieContainer();
                CookieCont.Add(new Cookie(OverallCookie.Name, OverallCookie.Value, OverallCookie.Path, OverallCookie.Domain));
                TLogging.LogAtLevel(1, "GetNewWebClient: copying cookie\r\n" +
                                    "Name: " + OverallCookie.Name + "\r\n" +
                                    "Value: " + OverallCookie.Value + "\r\n" +
                                    "Path: " + OverallCookie.Path + "\r\n" +
                                    "Domain: " + OverallCookie.Domain);
            }

            return(new WebClientWithSession(CookieCont));
        }
Exemplo n.º 6
0
        /// <summary>
        /// create the code for a typed table
        /// </summary>
        /// <param name="AStore"></param>
        /// <param name="strGroup"></param>
        /// <param name="AFilePath"></param>
        /// <param name="ANamespaceName"></param>
        /// <param name="AFileName"></param>
        /// <returns></returns>
        public static Boolean WriteTypedTable(TDataDefinitionStore AStore, string strGroup, string AFilePath, string ANamespaceName, string AFileName)
        {
            Console.WriteLine("processing namespace Typed Tables " + strGroup.Substring(0, 1).ToUpper() + strGroup.Substring(1));

            string          templateDir = TAppSettingsManager.GetValue("TemplateDir", true);
            ProcessTemplate Template    = new ProcessTemplate(templateDir + Path.DirectorySeparatorChar +
                                                              "ORM" + Path.DirectorySeparatorChar +
                                                              "DataTable.cs");

            Template.AddToCodelet("NAMESPACE", ANamespaceName);

            // load default header with license and copyright
            Template.SetCodelet("GPLFILEHEADER", ProcessTemplate.LoadEmptyFileComment(templateDir));

            foreach (TTable currentTable in AStore.GetTables())
            {
                if (currentTable.strGroup == strGroup)
                {
                    if (!currentTable.HasPrimaryKey())
                    {
                        TLogging.Log("Warning: there is no primary key for table " + currentTable.strName);
                    }

                    InsertTableDefinition(Template, currentTable, null, "TABLELOOP", false);
                    InsertRowDefinition(Template, currentTable, null, "TABLELOOP");
                }
            }

            Template.FinishWriting(AFilePath + AFileName + "-generated.cs", ".cs", true);

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// This will import a test gift batch, and post it.
        /// </summary>
        public static int ImportAndPostGiftBatch(DateTime AGiftDateEffective, TDataBase ADataBase)
        {
            TGiftImporting importer = new TGiftImporting();

            string testFile = TAppSettingsManager.GetValue("GiftBatch.file",
                                                           CommonNUnitFunctions.rootPath + "/csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv");

            TLogging.Log(testFile);

            StreamReader sr          = new StreamReader(testFile);
            string       FileContent = sr.ReadToEnd();

            sr.Close();

            FileContent = FileContent.Replace("{ledgernumber}", FLedgerNumber.ToString());
            FileContent = FileContent.Replace("{thisyear}-01-01", AGiftDateEffective.ToString("yyyy-MM-dd"));

            Hashtable parameters = new Hashtable();

            parameters.Add("Delimiter", ",");
            parameters.Add("ALedgerNumber", FLedgerNumber);
            parameters.Add("DateFormatString", "yyyy-MM-dd");
            parameters.Add("DatesMayBeIntegers", false);
            parameters.Add("NumberFormat", "American");
            parameters.Add("NewLine", Environment.NewLine);

            TVerificationResultCollection VerificationResult;
            GiftBatchTDSAGiftDetailTable  NeedRecipientLedgerNumber;
            bool refreshRequired;

            importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult, ADataBase);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult,
                                                                                "error when importing gift batch:");

            int BatchNumber = importer.GetLastGiftBatchNumber();

            Assert.AreNotEqual(-1, BatchNumber, "Should have imported the gift batch and return a valid batch number");

            Int32 generatedGlBatchNumber;

            if (!TGiftTransactionWebConnector.PostGiftBatch(FLedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult, ADataBase))
            {
                string VerifResStr;

                if (VerificationResult != null)
                {
                    VerifResStr = ": " + VerificationResult.BuildVerificationResultString();
                }
                else
                {
                    VerifResStr = String.Empty;
                }

                Assert.Fail("Gift Batch was not posted" + VerifResStr);
            }

            return(BatchNumber);
        }
        /// <summary>
        /// Generate PDF document
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void BtnPDF_Click(object sender, EventArgs e)
        {
            string PDFPath = TFormLettersTools.GeneratePDFFromHTML(FHtmlDoc,
                                                                   TAppSettingsManager.GetValue("Server.PathData") + Path.DirectorySeparatorChar +
                                                                   "reports");

            lblLoadStatus.Text = Catalog.GetString("Generated PDF Document: ") + PDFPath;
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            new TAppSettingsManager(false);

            ServicePointManager.ServerCertificateValidationCallback = delegate {
                return(true);
            };

            if (!TAppSettingsManager.HasValue("sf-username"))
            {
                Console.WriteLine("call: MantisUpdateVersions.exe -sf-username:pokorra -sf-pwd:xyz -release-version:0.2.16.0");
                Console.WriteLine(
                    "or: MantisUpdateVersions.exe -sf-username:pokorra -sf-pwd:xyz -bug-id:abc,def,ghi -version-fixed-in:\"Alpha 0.2.20\"");
                return;
            }

            string mantisURL = TAppSettingsManager.GetValue("mantis-url", "https://tracker.openpetra.org/api/soap/mantisconnect.php");

            try
            {
                Session session = LoginToMantis(mantisURL, TAppSettingsManager.GetValue("sf-username"), TAppSettingsManager.GetValue("sf-pwd"));

                if (TAppSettingsManager.HasValue("version-fixed-in"))
                {
                    string[] bugids = TAppSettingsManager.GetValue("bug-id").Split(new char[] { ',' });

                    foreach (string bugid in bugids)
                    {
                        SetVersionFixedInForResolvedBug(
                            session,
                            Convert.ToInt32(bugid),
                            TAppSettingsManager.GetValue("version-fixed-in"));
                    }
                }
                else
                {
                    Version releaseVersion = new Version(TAppSettingsManager.GetValue("release-version"));
                    Version devVersion     = new Version(releaseVersion.Major, releaseVersion.Minor, releaseVersion.Build + 1, releaseVersion.Revision);
                    Version nextVersion    = new Version(releaseVersion.Major, releaseVersion.Minor, releaseVersion.Build + 2, releaseVersion.Revision);

                    SortedList <int, string> projectIDs = GetAllProjects(session);

                    foreach (int id in projectIDs.Keys)
                    {
                        Console.WriteLine("project " + projectIDs[id]);
                        UpdateVersionsOfProject(session,
                                                id,
                                                "Alpha " + releaseVersion.ToString(3),
                                                "Alpha " + devVersion.ToString(3) + " Dev",
                                                "Alpha " + nextVersion.ToString(3));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 10
0
        public void TestGenerateICHEmail()
        {
            TVerificationResultCollection VerificationResults = new TVerificationResultCollection();

            int    PeriodNumber        = 5;
            int    ICHProcessingNumber = 1;
            int    CurrencyType        = 1; //base
            string FileName            = TAppSettingsManager.GetValue("Server.PathTemp") + Path.DirectorySeparatorChar + "TestGenerateICHEmail.csv";
            bool   SendEmail           = true;

            // make sure there is a valid email destination
            if (TGenFilesReports.GetICHEmailAddress(null).Length == 0)
            {
                string sqlStatement =
                    String.Format("INSERT INTO PUB_{0}({1},{2},{3},{4}) VALUES (?,?,?,?)",
                                  AEmailDestinationTable.GetTableDBName(),
                                  AEmailDestinationTable.GetFileCodeDBName(),
                                  AEmailDestinationTable.GetConditionalValueDBName(),
                                  AEmailDestinationTable.GetPartnerKeyDBName(),
                                  AEmailDestinationTable.GetEmailAddressDBName());

                OdbcParameter parameter;

                List <OdbcParameter> parameters = new List <OdbcParameter>();
                parameter       = new OdbcParameter("name", OdbcType.VarChar);
                parameter.Value = MFinanceConstants.EMAIL_FILE_CODE_STEWARDSHIP;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("condition", OdbcType.VarChar);
                parameter.Value = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) / 100;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("partnerkey", OdbcType.Int);
                parameter.Value = Convert.ToInt64(MFinanceConstants.ICH_COST_CENTRE) * 10000;
                parameters.Add(parameter);
                parameter       = new OdbcParameter("email", OdbcType.VarChar);
                parameter.Value = TAppSettingsManager.GetValue("ClearingHouse.EmailAddress");
                parameters.Add(parameter);

                bool           SubmissionOK  = true;
                TDBTransaction DBTransaction = null;
                DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref DBTransaction, ref SubmissionOK,
                                                           delegate
                {
                    DBAccess.GDBAccessObj.ExecuteNonQuery(sqlStatement, DBTransaction, parameters.ToArray());
                    DBAccess.GDBAccessObj.CommitTransaction();
                });
            }

            TGenFilesReports.GenerateStewardshipFile(FLedgerNumber,
                                                     PeriodNumber,
                                                     ICHProcessingNumber,
                                                     CurrencyType,
                                                     FileName,
                                                     SendEmail,
                                                     out VerificationResults);

            CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResults,
                                                                                "Performing ICH Email File Generation Failed!");
        }
Exemplo n.º 11
0
        /**
         * Called by the Client to obtain a DataTable that contains ClientTasks.
         *
         * @return DataTable containing the ClientTasks for the connected Client, or
         * null in case there are no ClientTasks for the connected Client.
         *
         */
        public DataTable PollClientTasks()
        {
            int UnusualNumberOfEntries = Convert.ToInt16(TAppSettingsManager.GetValue(
                                                             "Server.DEBUG.ClientTasks_UnusualNumberOfEntries", "5", false));
            DataTable ReturnValue = null;

            TLogging.LogAtLevel(4, "TPollClientTasks: PollClientTasks called");

            if (FClientTasksManager == null)
            {
                // TODO: ClientTasks should be stored in the database
                TLogging.LogAtLevel(4, "FClientTasksManager is null");
                return(null);
            }

            FLastPollingTime = DateTime.Now;

            // Check whether new ClientTasks should be transferred to the Client
            if (FClientTasksManager.ClientTasksNewDataTableEmpty)
            {
                // This argument is set to null instead of transfering an empty DataTable to
                // reduce the number of bytes that are transfered to the Client!
                ReturnValue = null;

                TLogging.LogAtLevel(4, "TPollClientTasks: Client Tasks Table is empty!");
            }
            else
            {
                // Retrieve new ClientTasks DataTable and pass it on the the Client
                ReturnValue = FClientTasksManager.ClientTasksNewDataTable;

                //
                // Debugging
                //
                if (TLogging.DL >= 2)
                {
                    if (ReturnValue.Rows.Count >= UnusualNumberOfEntries)
                    {
                        TLogging.Log(String.Format(
                                         "TPollClientTasks: Client Tasks Table has got a rather unusal number of entries (more than {0}): it holds {1} entries!!!   AppDomain: '{2}'",
                                         UnusualNumberOfEntries, ReturnValue.Rows.Count, AppDomain.CurrentDomain.FriendlyName));

                        for (int Counter = 0; Counter < ReturnValue.Rows.Count; Counter++)
                        {
                            TLogging.Log(String.Format(
                                             "TPollClientTasks: Data of Entry #{0} for AppDomain '{1}': TaskGroup: '{2}'; TaskCode: '{3}'; TaskParameter1: '{4}', ; TaskParameter2: '{5}'",
                                             Counter, AppDomain.CurrentDomain.FriendlyName,
                                             ReturnValue.Rows[Counter]["TaskGroup"], ReturnValue.Rows[Counter]["TaskCode"],
                                             ReturnValue.Rows[Counter]["TaskParameter1"], ReturnValue.Rows[Counter]["TaskParameter2"]));
                        }
                    }
                }

                TLogging.LogAtLevel(4, "TPollClientTasks: Client Tasks Table has " + (ReturnValue.Rows.Count).ToString() + " entries!");
            }

            return(ReturnValue);
        }
Exemplo n.º 12
0
        /// main method
        public static void Main(string[] args)
        {
            new TAppSettingsManager();
            new TLogging();

            if (!TAppSettingsManager.HasValue("YmlGzFile") || !TAppSettingsManager.HasValue("Action"))
            {
                TLogging.Log("sample call: -C:../../etc/TestServer.config -Action:dump -YmlGzFile:test.yml.gz");
                TLogging.Log("sample call: -C:../../etc/TestServer.config -Action:load -YmlGzFile:test.yml.gz");
                Environment.Exit(-1);
            }

            string YmlFile = TAppSettingsManager.GetValue("YmlGzFile");
            string Action  = TAppSettingsManager.GetValue("Action");

            TLogging.DebugLevel = TAppSettingsManager.GetInt32("Server.DebugLevel", 0);
            TSession.InitThread();

            TServerManager.TheServerManager = new TServerManager();

            bool ExitWithError = false;

            try
            {
                if (Action == "dump")
                {
                    if (!DumpYmlGz(YmlFile))
                    {
                        ExitWithError = true;
                    }
                }
                else if (Action == "load")
                {
                    if (!LoadYmlGz(YmlFile))
                    {
                        ExitWithError = true;
                    }
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
                ExitWithError = true;
            }

            TServerManager.TheServerManager.StopServer();

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

            if (ExitWithError)
            {
                Environment.Exit(-1);
            }
        }
Exemplo n.º 13
0
        private void LoadTable(TTable newTable)
        {
            bool IgnoreFile = false;

            TLogging.Log(newTable.strName);

            string oldTableName = DataDefinitionDiff.GetOldTableName(newTable.strName);

            TTable oldTable = storeOld.GetTable(oldTableName);

            // if this is a new table in OpenPetra, do not dump anything. the table will be empty in OpenPetra
            // (except p_partner_attribute_category and p_partner_attribute_type which are populated here)
            if ((oldTable == null) && (newTable.strName != "p_partner_attribute_category") && (newTable.strName != "p_partner_attribute_type"))
            {
                return;
            }

            // the file has already been stored in fulldump, tablename.d.gz
            string dumpFile = TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar + oldTableName;

            if (!File.Exists(dumpFile + ".d.gz"))
            {
                TLogging.Log("cannot find file " + dumpFile + ".d.gz");
                return;
            }

            FileInfo info = new FileInfo(dumpFile + ".d.gz");

            // ignore empty files (with one exception)
            if ((oldTableName == "p_partner_gift_destination") ||
                (oldTableName == "p_partner_attribute_category") ||
                (oldTableName == "p_partner_attribute_type"))
            {
                IgnoreFile = true;
            }

            if ((info.Length == 0) && !IgnoreFile)
            {
                TLogging.Log("ignoring " + dumpFile + ".d.gz");
                return;
            }

            if (TAppSettingsManager.HasValue("table") || !File.Exists(dumpFile + ".sql.gz") || ((new FileInfo(dumpFile + ".sql.gz")).Length == 0))
            {
                if (((long)info.Length > MAX_SIZE_D_GZ_SEPARATE_PROCESS) && !TAppSettingsManager.HasValue("table"))
                {
                    if (TAppSettingsManager.GetValue("IgnoreBigTables", "false", false) == "false")
                    {
                        ProcessAndWritePostgresqlFile(dumpFile, newTable);
                    }
                }
                else
                {
                    ProcessAndWritePostgresqlFile(dumpFile, newTable);
                }
            }
        }
Exemplo n.º 14
0
        public void Init()
        {
            new TAppSettingsManager("../../etc/TestClient.config");

            FTestShepherdYAMLFile = TAppSettingsManager.GetValue("UINavigation.File").Substring(0, TAppSettingsManager.GetValue(
                                                                                                    "UINavigation.File").IndexOf("UINavigation.yml")) +
                                    Path.DirectorySeparatorChar + "Shepherd_Church_Definition.yaml";
            new TLogging("test.log");
        }
Exemplo n.º 15
0
        public void TestAnnualReceipt()
        {
            CommonNUnitFunctions.ResetDatabase();

            // import a test gift batch
            TVerificationResultCollection VerificationResult;

            if (!ImportAndPostGiftBatch(FLedgerNumber, out VerificationResult))
            {
                Assert.Fail("ImportAndPostGiftBatch failed: " + VerificationResult.BuildVerificationResultString());
            }

            // TODO test reversed gifts

            string formletterTemplateFile = TAppSettingsManager.GetValue("ReceiptTemplate.file",
                                                                         "../../csharp/ICT/Testing/lib/MFinance/SampleData/AnnualReceiptTemplate.html");
            Encoding     encodingOfHTMLfile = TTextFile.GetFileEncoding(formletterTemplateFile);
            StreamReader sr          = new StreamReader(formletterTemplateFile, encodingOfHTMLfile, false);
            string       FileContent = sr.ReadToEnd();

            sr.Close();

            string formletterExpectedFile = TAppSettingsManager.GetValue("ReceiptExptected.file",
                                                                         "../../csharp/ICT/Testing/lib/MFinance/SampleData/AnnualReceiptExpected.html");

            Catalog.Init("de-DE", "de-DE");
            sr = new StreamReader(formletterExpectedFile, encodingOfHTMLfile, false);
            string ExpectedFormletterContent = sr.ReadToEnd().
                                               Replace("#TODAY#", DateTime.Now.ToString("d. MMMM yyyy")).
                                               Replace("#THISYEAR#", DateTime.Today.Year.ToString());

            sr.Close();

            StreamWriter sw = new StreamWriter(formletterExpectedFile + ".updated", false, encodingOfHTMLfile);

            sw.WriteLine(ExpectedFormletterContent);
            sw.Close();

            TLanguageCulture.SetLanguageAndCulture("de-DE", "de-DE");

            //TODO: Calendar vs Financial Date Handling - Check if this should use financial year start/end and not assume calendar
            string receipts =
                TReceiptingWebConnector.CreateAnnualGiftReceipts(FLedgerNumber,
                                                                 new DateTime(DateTime.Today.Year, 1, 1), new DateTime(DateTime.Today.Year, 12, 31), FileContent);

            sw = new StreamWriter(formletterExpectedFile + ".new", false, encodingOfHTMLfile);
            sw.WriteLine(receipts);
            sw.WriteLine();
            sw.Close();

            Assert.IsTrue(
                TTextFile.SameContent(formletterExpectedFile + ".updated", formletterExpectedFile + ".new"),
                "receipt was not printed as expected, check " + formletterExpectedFile + ".new");

            File.Delete(formletterExpectedFile + ".new");
            File.Delete(formletterExpectedFile + ".updated");
        }
Exemplo n.º 16
0
        /// <summary>
        /// Routine to start nant ...
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="ignoreError"></param>
        private static void nant(String argument, bool ignoreError)
        {
            Process NantProcess = new Process();

            NantProcess.EnableRaisingEvents = false;

            if (Ict.Common.Utilities.DetermineExecutingOS() >= TExecutingOSEnum.eosWinNTOrLater)
            {
                NantProcess.StartInfo.FileName  = "cmd";
                NantProcess.StartInfo.Arguments = "/c " + pathAndFileNameToNantExe + " " + argument + " -logfile:nant.txt";
            }
            else
            {
                NantProcess.StartInfo.FileName  = pathAndFileNameToNantExe;
                NantProcess.StartInfo.Arguments = argument.Replace("\\", "/") + " -logfile:nant.txt";
            }

            // this is needed for running the NUnit tests with sqlite on Jenkins
            if (TAppSettingsManager.GetValue("Server.RDBMSType").ToLower() == "sqlite")
            {
                NantProcess.StartInfo.Arguments += " -D:DBMS.Type=sqlite -D:DBMS.Password="******"failed to start " + NantProcess.StartInfo.FileName);
            }
            else
            {
                NantProcess.WaitForExit(60000);
                Debug.Print("OS says nant process is finished");
            }

            string nantLogFile = rootPath + Path.DirectorySeparatorChar + "nant.txt";

            if (!File.Exists(nantLogFile))
            {
                FileStream fs = File.Create(nantLogFile);
                fs.Close();
            }

            StreamReader sr = new StreamReader(nantLogFile);

            TLogging.Log(sr.ReadToEnd());
            sr.Close();
            File.Delete(rootPath + Path.DirectorySeparatorChar + "nant.txt");

            if ((NantProcess.ExitCode != 0) && !ignoreError)
            {
                throw new Exception("Nant did not succeed");
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initialise method
        /// </summary>
        /// <param name="ASMTPHost">The address of the mail server</param>
        /// <param name="ASMTPPort">The port for the connection</param>
        /// <param name="AEnableSsl">True to use SSL</param>
        /// <param name="AUsername">A username on the server.  Can be null or empty string in which case default credentials are used.</param>
        /// <param name="APassword">Password for the username specified.</param>
        /// <param name="AOutputEMLToDirectory">Path to pickup folder</param>
        /// <returns></returns>
        private Boolean Initialise(string ASMTPHost, int ASMTPPort, bool AEnableSsl, string AUsername, string APassword, string AOutputEMLToDirectory)
        {
            try
            {
                FSmtpClient = new SmtpClient();

                if (AOutputEMLToDirectory.Length > 0)
                {
                    FSmtpClient.PickupDirectoryLocation = AOutputEMLToDirectory;
                    FSmtpClient.DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory;
                }
                else
                {
                    FSmtpClient.Host           = ASMTPHost;
                    FSmtpClient.Port           = ASMTPPort;
                    FSmtpClient.EnableSsl      = AEnableSsl;
                    FSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

                    if (AUsername == null)
                    {
                        AUsername = string.Empty;
                    }

                    if (APassword == null)
                    {
                        APassword = string.Empty;
                    }

                    FSmtpClient.UseDefaultCredentials = (AUsername.Length == 0);

                    if (FSmtpClient.UseDefaultCredentials == false)
                    {
                        FSmtpClient.Credentials = new NetworkCredential(AUsername, APassword);
                    }

                    if (TAppSettingsManager.GetValue("IgnoreServerCertificateValidation", "false", false) == "true")
                    {
                        // when checking the validity of a SSL certificate, always pass
                        // this is needed for smtp.outlook365.com, since I cannot find a place to get the public key for the ssl certificate
                        ServicePointManager.ServerCertificateValidationCallback =
                            new RemoteCertificateValidationCallback(
                                delegate
                                { return(true); }
                                );
                    }
                }

                FailedRecipients = new List <TsmtpFailedRecipient>();
                FInitOk          = true;
            } // try
            catch (Exception e)
            {
                FErrorStatus = e.Message;
                FInitOk      = false;
            }
            return(FInitOk);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize the Petra server and connect to the database
        /// </summary>
        /// <param name="AConfigName">just provide the server config file, plus AutoLogin and AutoLoginPasswd</param>
        public static TServerManager Connect(string AConfigName)
        {
            if (File.Exists(AConfigName))
            {
                new TAppSettingsManager(AConfigName);
            }
            else
            {
                new TAppSettingsManager();
            }

            new TLogging(TAppSettingsManager.GetValue("Server.LogFile"));

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TServerManager.TheServerManager = new TServerManager();

            DBAccess.GDBAccessObj = new TDataBase();
            DBAccess.GDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                        TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort,
                                                        TSrvSetting.PostgreSQLDatabaseName,
                                                        TSrvSetting.DBUsername, TSrvSetting.DBPassword, "", "Ict.Testing.NUnitPetraServer.TPetraServerConnector.Connect DB Connection");

            bool       SystemEnabled;
            string     WelcomeMessage;
            IPrincipal ThisUserInfo;
            Int32      ClientID;

            TConnectedClient CurrentClient = TClientManager.ConnectClient(
                TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                TAppSettingsManager.GetValue("AutoLoginPasswd"),
                "NUNITTEST", "127.0.0.1",
                TFileVersionInfo.GetApplicationVersion().ToVersion(),
                TClientServerConnectionType.csctLocal,
                out ClientID,
                out WelcomeMessage,
                out SystemEnabled,
                out ThisUserInfo);

            // the following values are stored in the session object
            DomainManager.GClientID     = ClientID;
            DomainManager.CurrentClient = CurrentClient;
            UserInfo.GUserInfo          = (TPetraPrincipal)ThisUserInfo;

            TSetupDelegates.Init();
            TSystemDefaultsCache.GSystemDefaultsCache = new TSystemDefaultsCache();
            DomainManager.GetSiteKeyFromSystemDefaultsCacheDelegate =
                @TSystemDefaultsCache.GSystemDefaultsCache.GetSiteKeyDefault;

            TUserDefaults.InitializeUnit();

            StringHelper.CurrencyFormatTable = DBAccess.GDBAccessObj.SelectDT("SELECT * FROM PUB_a_currency", "a_currency", null);

            return((TServerManager)TServerManager.TheServerManager);
        }
Exemplo n.º 19
0
        // creates p_postcode_region_range.d.gz and populates with data from p_postcode_region.d.gz
        private void CreatePostcodeRegionRangeTable()
        {
            string   dumpFile = TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar + "p_postcode_region";
            FileInfo FileName = new FileInfo(dumpFile + ".d.gz");

            // new file is not needed if p_postcode_region.d.gz does not exist or is empty
            if (!File.Exists(dumpFile + ".d.gz") || (FileName.Length == 0))
            {
                return;
            }

            Encoding ProgressFileEncoding;
            string   ProgressCodepage = TAppSettingsManager.GetValue("CodePage", Environment.GetEnvironmentVariable("PROGRESS_CP"));

            try
            {
                ProgressFileEncoding = Encoding.GetEncoding(Convert.ToInt32(ProgressCodepage));
            }
            catch
            {
                ProgressFileEncoding = Encoding.GetEncoding(ProgressCodepage);
            }

            try
            {
                string FilePath = TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar +
                                  "p_postcode_region" + ".d.gz";
                Stream          fs         = new FileStream(FilePath, FileMode.Open, FileAccess.Read);
                GZipInputStream gzipStream = new GZipInputStream(fs);
                StreamReader    MyReader   = new StreamReader(gzipStream, ProgressFileEncoding);

                FileStream outStream = File.Create(
                    TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar +
                    "p_postcode_region_range" + ".d.gz");
                Stream       gzoStream = new GZipOutputStream(outStream);
                StreamWriter MyWriter  = new StreamWriter(gzoStream, Encoding.UTF8);

                char[] block = new char[10000];
                int    count = 0;

                // copy entire contents of p_postcode_region.d.gz to p_postcode_region_range.d.gz
                while ((count = MyReader.ReadBlock(block, 0, block.Length)) != 0)
                {
                    MyWriter.Write(block, 0, count);
                }

                MyWriter.Close();
            }
            catch (Exception e)
            {
                TLogging.Log("Memory usage: " + (GC.GetTotalMemory(false) / 1024 / 1024).ToString() + " MB");
                TLogging.Log("WARNING Problems processing file " + "p_postcode_region_range" + ": " + e.ToString());
            }

            storeOld.AddTable(storeNew.GetTable("p_postcode_region_range"));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Create a mail message from a language specific template and send it as from the specified sender address.
        /// The first line in the template is the subject, all following lines are the body.
        /// </summary>
        /// <returns>Flag indicating whether email was sent.</returns>
        /// <exception cref="ESmtpSenderInitializeException">Thrown when the sender address is invalid. An inner exception may contain more detail.</exception>
        public bool SendEmailFromTemplate(string fromemail, string fromDisplayName, string recipients,
                                          string template, string language, Dictionary <string, string> parameters,
                                          string[] attachfiles = null)
        {
            SetSender(fromemail, fromDisplayName);

            string TemplateFilename = TAppSettingsManager.GetValue("EMailTemplates.Path", ".") +
                                      Path.DirectorySeparatorChar +
                                      template + "_" + language.ToLower() + ".txt";

            if (!File.Exists(TemplateFilename) && language.Contains("-"))
            {
                TemplateFilename = TAppSettingsManager.GetValue("EMailTemplates.Path", ".") +
                                   Path.DirectorySeparatorChar +
                                   template + "_" + language.ToLower().Substring(0, language.IndexOf('-')) + ".txt";
            }

            if (!File.Exists(TemplateFilename))
            {
                TemplateFilename = TAppSettingsManager.GetValue("EMailTemplates.Path", ".") +
                                   Path.DirectorySeparatorChar +
                                   template + "_en.txt";
            }

            string subject = String.Empty;
            string body    = String.Empty;

            using (StreamReader reader = new StreamReader(TemplateFilename))
            {
                if (reader == null)
                {
                    throw new Exception("cannot open file " + TemplateFilename);
                }

                subject = reader.ReadLine();

                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    body += line + Environment.NewLine;
                }
            }

            foreach (var pair in parameters)
            {
                subject = subject.Replace("{" + pair.Key + "}", pair.Value);
                body    = body.Replace("{" + pair.Key + "}", pair.Value);
            }

            if ((subject.Length == 0) || (body.Length == 0))
            {
                return(false);
            }

            return(SendEmail(recipients, subject, body, attachfiles));
        }
Exemplo n.º 21
0
        /// <summary>
        /// prepare the test case
        /// </summary>
        public static bool ImportAndPostGiftBatch(int ALedgerNumber, out TVerificationResultCollection VerificationResult)
        {
            TGiftImporting importer = new TGiftImporting();

            string testFile = TAppSettingsManager.GetValue("GiftBatch.file", "../../csharp/ICT/Testing/lib/MFinance/SampleData/sampleGiftBatch.csv");

            StreamReader sr          = new StreamReader(testFile);
            string       FileContent = sr.ReadToEnd();

            FileContent = FileContent.Replace("{ledgernumber}", ALedgerNumber.ToString());
            FileContent = FileContent.Replace("{thisyear}", DateTime.Today.Year.ToString());

            sr.Close();

            Hashtable parameters = new Hashtable();

            parameters.Add("Delimiter", ",");
            parameters.Add("ALedgerNumber", ALedgerNumber);
            parameters.Add("DateFormatString", "yyyy-MM-dd");
            parameters.Add("DatesMayBeIntegers", false);
            parameters.Add("NumberFormat", "American");
            parameters.Add("NewLine", Environment.NewLine);

            GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber;
            bool refreshRequired;

            if (!importer.ImportGiftBatches(parameters, FileContent, out NeedRecipientLedgerNumber, out refreshRequired, out VerificationResult))
            {
                return(false);
            }

            int   BatchNumber = importer.GetLastGiftBatchNumber();
            Int32 generatedGlBatchNumber;

            if (!TGiftTransactionWebConnector.PostGiftBatch(ALedgerNumber, BatchNumber, out generatedGlBatchNumber, out VerificationResult))
            {
                CommonNUnitFunctions.EnsureNullOrOnlyNonCriticalVerificationResults(VerificationResult);

                return(false);
            }

            TDataBase      db           = DBAccess.Connect("FixSendMailPartnerLocation");
            TDBTransaction t            = new TDBTransaction();
            bool           SubmissionOK = false;

            db.WriteTransaction(ref t, ref SubmissionOK,
                                delegate
            {
                // need to set sendmail = true for the donor with partner key 43005001
                string sql = "UPDATE p_partner_location SET p_send_mail_l = true WHERE p_partner_key_n = 43005001";
                db.ExecuteNonQuery(sql, t);
                SubmissionOK = true;
            });

            return(true);
        }
Exemplo n.º 22
0
        // creates p_partner_gift_destination.d.gz and leaves it blank
        private void CreateGiftDestinationTable()
        {
            FileStream outStream = File.Create(
                TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar +
                "p_partner_gift_destination" + ".d.gz");

            outStream.Close();

            storeOld.AddTable(storeNew.GetTable("p_partner_gift_destination"));
        }
Exemplo n.º 23
0
 /// Method to obtain the SMTP email server configuration settings from the configuration file
 public static TSmtpServerSettings GetSmtpSettingsFromAppSettings()
 {
     return(new TSmtpServerSettings(
                TAppSettingsManager.GetValue("SmtpHost"),
                TAppSettingsManager.GetInt16("SmtpPort"),
                TAppSettingsManager.GetBoolean("SmtpEnableSsl", true),
                TAppSettingsManager.GetValue("SmtpUser"),
                TAppSettingsManager.GetValue("SmtpPassword"),
                TAppSettingsManager.GetBoolean("IgnoreServerCertificateValidation", false)));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Create a PDF file from the HTML
        /// </summary>
        public static bool HTMLToPDF(HtmlDocument html, string AOutputPDFFilename)
        {
            // export HTML including the CSS to a single file.
            string HTMLFile = TFileHelper.GetTempFileName(
                "htmlreport",
                ".html");

            string CSSContent = String.Empty;

            // ApplicationDirectory points to eg. /home/openpetra/server/bin, we want /home/openpetra/
            string InstallPath = Path.GetFullPath(TAppSettingsManager.GetValue("ApplicationDirectory") + "/../../");

            using (StreamReader sr = new StreamReader(InstallPath + "client/css/report.css"))
            {
                CSSContent = sr.ReadToEnd();
            }

            string BootstrapCSSContent = String.Empty;

            using (StreamReader sr = new StreamReader(InstallPath + "bootstrap-4.0/bootstrap.min.css"))
            {
                BootstrapCSSContent = sr.ReadToEnd();
            }

            string BundledJSContent = string.Empty;

            using (StreamReader sr = new StreamReader(InstallPath + "bootstrap-4.0/bootstrap.bundle.min.js"))
            {
                BundledJSContent = sr.ReadToEnd();
            }


            using (StreamWriter sw = new StreamWriter(HTMLFile))
            {
                string strhtml = html.DocumentNode.WriteTo().
                                 Replace("<link href=\"/css/report.css\" rel=\"stylesheet\">",
                                         "<style>" +
                                         BootstrapCSSContent + Environment.NewLine +
                                         CSSContent + "</style>" + Environment.NewLine +
                                         "<script>" + BundledJSContent + "</script>");
                sw.Write(strhtml);
                sw.Close();
            }

            Process process = new Process();

            process.StartInfo.FileName  = TAppSettingsManager.GetValue("wkhtmltopdf.Path", "/usr/local/bin/wkhtmltopdf");
            process.StartInfo.Arguments = HTMLFile + " " + AOutputPDFFilename;
            process.Start();
            process.WaitForExit();

            File.Delete(HTMLFile);

            return(true);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initialize the Petra server and connect to the database
        /// </summary>
        /// <param name="AConfigName">just provide the server config file, plus AutoLogin and AutoLoginPasswd</param>
        public static TServerManager Connect(string AConfigName)
        {
            if (File.Exists(AConfigName))
            {
                new TAppSettingsManager(AConfigName);
            }
            else
            {
                new TAppSettingsManager();
            }

            new TLogging(TAppSettingsManager.GetValue("Server.LogFile"));

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TServerManager ServerManager = new TServerManager();

            DBAccess.GDBAccessObj = new TDataBase();
            DBAccess.GDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                        TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort,
                                                        TSrvSetting.PostgreSQLDatabaseName,
                                                        TSrvSetting.DBUsername, TSrvSetting.DBPassword, "");

            bool            SystemEnabled;
            int             ProcessID;
            TPetraPrincipal UserInfo = (TPetraPrincipal)TClientManager.PerformLoginChecks(TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                                                                                          TAppSettingsManager.GetValue("AutoLoginPasswd"),
                                                                                          "NUNITTEST", "127.0.0.1", out ProcessID, out SystemEnabled);

            if (FDomain != null)
            {
                FDomain.StopClientAppDomain();
            }

            TClientManager ClientManager = new TClientManager();

            DomainManager.UClientManagerCallForwarderRef = new TClientManagerCallForwarder(ClientManager);

            // do the same as in Ict.Petra.Server.App.Main.TRemoteLoader.LoadDomainManagerAssembly
            FDomain = new TClientDomainManager("0",
                                               TClientServerConnectionType.csctLocal,
                                               DomainManager.UClientManagerCallForwarderRef,
                                               new TSystemDefaultsCache(),
                                               new TCacheableTablesManager(null),
                                               UserInfo);
            FDomain.InitAppDomain(TSrvSetting.ServerSettings);

            new TCallForwarding();

            // we don't need to establish the database connection anymore
            // FDomain.EstablishDBConnection();

            return(ServerManager);
        }
Exemplo n.º 26
0
 /// <summary>
 /// start the gui program
 /// </summary>
 public override void Setup()
 {
     // Before Execution of any Test we should do something like
     // nant stopPetraServer
     // nant ResetDatabase
     // nant startPetraServer
     // this may take some time ....
     new TLogging("../../log/TestClient.log");
     TPetraConnector.Connect("../../etc/TestClient.config");
     FLedgerNumber = Convert.ToInt32(TAppSettingsManager.GetValue("LedgerNumber"));
 }
Exemplo n.º 27
0
        public void TestImportGLBatch()
        {
            int NumberOfBatches = 0;

            string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchImportFloatTest.csv";

            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

            TFrmGLBatch frmBatch  = new TFrmGLBatch(null);
            TFrmGLBatch frmBatch1 = new TFrmGLBatch(null);

            //Open the batch form and count no. of batches
            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();
            TSgrdDataGridPagedTester grdDetails = new TSgrdDataGridPagedTester("grdDetails");

            NumberOfBatches = grdDetails.Count - 1;
            TLogging.Log("NumberOfBatches: " + NumberOfBatches.ToString());

            //Close the form
            frmBatch.Close();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                OpenFileDialogTester tester = new OpenFileDialogTester(hWnd);

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat          = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "MM/dd/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;

                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    btnOK.Click();
                };

                tester.OpenFile(TestFile);
            };

            //Set the batch form to open with importing batches dialog
            frmBatch1.LoadForImport = true;
            frmBatch1.LedgerNumber  = FLedgerNumber;
            frmBatch1.Show();

            TSgrdDataGridPagedTester grdDetails1 = new TSgrdDataGridPagedTester("grdDetails");

            TLogging.Log("grdDetails.Count after import: " + grdDetails1.Count.ToString());
            Assert.AreNotEqual(NumberOfBatches, grdDetails1.Count, "The grid should include imported batches");

            frmBatch1.Close();
        }
Exemplo n.º 28
0
        private static void LoadLedgersCurrentFinancialYear()
        {
            LedgersCurrentFinancialYear = new SortedList <string, string>();

            // load a_ledger table and a_accounting_period
            TTable ledgerTableOld = TDumpProgressToPostgresql.GetStoreOld().GetTable("a_ledger");

            TParseProgressCSV Parser = new TParseProgressCSV(
                TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar + "a_ledger.d.gz",
                ledgerTableOld.grpTableField.Count);

            StringCollection LedgerColumnNames = GetColumnNames(ledgerTableOld);

            while (true)
            {
                string[] OldRow = Parser.ReadNextRow();

                if (OldRow == null)
                {
                    break;
                }

                string LedgerNumber         = GetValue(LedgerColumnNames, OldRow, "a_ledger_number_i");
                string CurrentFinancialYear = GetValue(LedgerColumnNames, OldRow, "a_current_financial_year_i");
                LedgersCurrentFinancialYear.Add(LedgerNumber, CurrentFinancialYear);
            }

            TTable accountingPeriodTableOld = TDumpProgressToPostgresql.GetStoreOld().GetTable("a_accounting_period");

            Parser = new TParseProgressCSV(
                TAppSettingsManager.GetValue("fulldumpPath", "fulldump") + Path.DirectorySeparatorChar + "a_accounting_period.d.gz",
                accountingPeriodTableOld.grpTableField.Count);

            StringCollection PeriodColumnNames = GetColumnNames(accountingPeriodTableOld);

            while (true)
            {
                string[] OldRow = Parser.ReadNextRow();

                if (OldRow == null)
                {
                    break;
                }

                string PeriodNumber = GetValue(PeriodColumnNames, OldRow, "a_accounting_period_number_i");

                if (PeriodNumber == "1")
                {
                    string LedgerNumber = GetValue(PeriodColumnNames, OldRow, "a_ledger_number_i");
                    string RealYear     = GetValue(PeriodColumnNames, OldRow, "a_period_start_date_d").Substring(6, 4);
                    LedgersCurrentFinancialYear[LedgerNumber] += "," + RealYear;
                }
            }
        }
Exemplo n.º 29
0
        XmlDocument LoadYAMLTestFile()
        {
            String yamlFile = txtYaml.Text.ToString();

            new TAppSettingsManager("../../csharp/ICT/Testing/exe/Controls/ControlTestBench/ControlTestBench.exe.config");
            TYml2Xml parser = new TYml2Xml(TAppSettingsManager.GetValue("YAMLDemodataPath") + '/' + yamlFile);

            XmlDocument UINavigation = parser.ParseYML2XML();

            return(UINavigation);
        }
Exemplo n.º 30
0
        /// <summary>
        /// create a patch file containing all differences between two versions of the software
        /// </summary>
        public static void CreateDiff(String ATmpDirectory, String ADeliveryDirectory,
                                      String AAppName,
                                      String AZipName,
                                      String oldPatch, String newPatch)
        {
            if (Directory.Exists(ATmpDirectory + Path.DirectorySeparatorChar + oldPatch))
            {
                // never reuse an unzipped tar file, because it might be from a different language
                Directory.Delete(ATmpDirectory + Path.DirectorySeparatorChar + oldPatch, true);
            }

            string OldTarFile = ADeliveryDirectory + Path.DirectorySeparatorChar +
                                AZipName + "-" + oldPatch + ".tar.gz";

            if (File.Exists(OldTarFile))
            {
                UnzipTarFile(ATmpDirectory + Path.DirectorySeparatorChar + oldPatch,
                             OldTarFile,
                             AAppName);
            }

            if (Directory.Exists(ATmpDirectory + Path.DirectorySeparatorChar + newPatch))
            {
                // never reuse an unzipped tar file, because we might have done two builds with the same build number.
                // then the patch file would be old
                Directory.Delete(ATmpDirectory + Path.DirectorySeparatorChar + newPatch, true);
            }

            UnzipTarFile(ATmpDirectory + Path.DirectorySeparatorChar + newPatch,
                         ADeliveryDirectory + Path.DirectorySeparatorChar + AZipName + "-" + newPatch + ".tar.gz",
                         AAppName);

            string DiffDirectory = ATmpDirectory + '/' + "Patch-win" + "_" + oldPatch + '_' + newPatch;

            // clear the diff directory
            PreparePatchTmpDirectory(DiffDirectory);
            Directory.CreateDirectory(DiffDirectory + Path.DirectorySeparatorChar + "openpetraorg-" + newPatch);

            CreateDiffFiles(ATmpDirectory,
                            DiffDirectory + Path.DirectorySeparatorChar + "openpetraorg-" + newPatch,
                            ATmpDirectory + Path.DirectorySeparatorChar + oldPatch + Path.DirectorySeparatorChar + "openpetraorg-" + oldPatch,
                            ATmpDirectory + Path.DirectorySeparatorChar + newPatch + Path.DirectorySeparatorChar + "openpetraorg-" + newPatch,
                            string.Empty);

            // put it all into a zip file
            string ZipFileName = TAppSettingsManager.GetValue("OutputZipFilename");

            PackTools.ZipDirectory(DiffDirectory, DiffDirectory + "/../" + ZipFileName);

            // copy that file to the delivery directory
            System.IO.File.Copy(DiffDirectory + "/../" + ZipFileName,
                                ADeliveryDirectory + Path.DirectorySeparatorChar + ZipFileName, true);
            TLogging.Log("Successfully created file " + ADeliveryDirectory + Path.DirectorySeparatorChar + ZipFileName);
        }