public void TestAddingElements()
        {
            TVerificationResult           res;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            Assert.AreEqual(0, coll.Count, "there should be no verification result");

            coll.AddAndIgnoreNullValue(null);
            Assert.AreEqual(0, coll.Count, "there should be no verification result and no exception thrown");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Noncritical);
            coll.AddAndIgnoreNullValue(res);
            Assert.AreEqual(1, coll.Count, "there should be one verification result");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Noncritical);
            coll.Add(res);
            Assert.AreEqual(2, coll.Count, "there should be 2 verification results");

            Exception caught = null;

            try
            {
                coll.Add(null);
            }
            catch (Exception e)
            {
                caught = e;
            }

            Assert.IsInstanceOf(typeof(ArgumentException), caught, "there should be an ArgumentException thrown");

            Assert.AreEqual(2, coll.Count, "there should be 2 verification results");
        }
        public void TestInsertAndIndexOf()
        {
            TVerificationResult           res0, res1, res2, res3, res4;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            // insert in the middle
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical);
            coll.Add(res1);
            res3 = new TVerificationResult(null, "test3", TResultSeverity.Resv_Noncritical);
            coll.Add(res3);
            Assert.AreEqual(0, coll.IndexOf(res1), "res1 should be at position 0");
            Assert.AreEqual(1, coll.IndexOf(res3), "res3 should be at position 1");
            res2 = new TVerificationResult(null, "test2", TResultSeverity.Resv_Noncritical);
            coll.Insert(1, res2);
            Assert.AreEqual(0, coll.IndexOf(res1), "res1 should be at position 0");
            Assert.AreEqual(1, coll.IndexOf(res2), "res2 should be at position 1");
            Assert.AreEqual(2, coll.IndexOf(res3), "res3 should be at position 2");

            // insert at the front
            res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical);
            coll.Insert(0, res0);
            Assert.AreEqual(0, coll.IndexOf(res0), "res0 should be at position 0");
            Assert.AreEqual(1, coll.IndexOf(res1), "res1 should be at position 1");
            Assert.AreEqual(2, coll.IndexOf(res2), "res2 should be at position 2");
            Assert.AreEqual(3, coll.IndexOf(res3), "res3 should be at position 3");

            // insert at the back
            res4 = new TVerificationResult(null, "test4", TResultSeverity.Resv_Noncritical);
            coll.Insert(4, res4);
            Assert.AreEqual(0, coll.IndexOf(res0), "res0 should be at position 0");
            Assert.AreEqual(1, coll.IndexOf(res1), "res1 should be at position 1");
            Assert.AreEqual(2, coll.IndexOf(res2), "res2 should be at position 2");
            Assert.AreEqual(3, coll.IndexOf(res3), "res3 should be at position 3");
            Assert.AreEqual(4, coll.IndexOf(res4), "res4 should be at position 4");
        }
        public void TestAddingCollection()
        {
            TVerificationResult           res;
            TVerificationResultCollection coll  = new TVerificationResultCollection();
            TVerificationResultCollection coll2 = new TVerificationResultCollection();

            res = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical);
            coll2.Add(res);
            res = new TVerificationResult(null, "test2", TResultSeverity.Resv_Noncritical);
            coll2.Add(res);

            Assert.AreEqual(2, coll2.Count, "there should be two verification results in the coll2 collection");
            Assert.AreEqual(0, coll.Count, "there should be no verification results in the coll collection");

            coll.AddCollection(coll2);
            Assert.AreEqual(2, coll.Count, "there should be two verification results in the coll collection after the adding of coll2");

            Assert.AreEqual("test1", coll[0].ResultText, "added result text should be test1");
            Assert.AreEqual("test2", coll[1].ResultText, "added result text should be test2");

            coll2 = new TVerificationResultCollection();
            res   = new TVerificationResult(null, "test3", TResultSeverity.Resv_Noncritical);
            coll2.Add(res);
            res = new TVerificationResult(null, "test4", TResultSeverity.Resv_Noncritical);
            coll2.Add(res);
            coll.AddCollection(coll2);
            Assert.AreEqual(4, coll.Count, "there should be four verification results in the coll collection after the adding of coll2 another time");
            Assert.AreEqual("test3", coll[2].ResultText, "added result text should be test3");
            Assert.AreEqual("test4", coll[3].ResultText, "added result text should be test4");
        }
        public void TestRemoveAt()
        {
            TVerificationResult           res0, res1, res2, res3;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical);
            coll.Add(res0);
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical);
            coll.Add(res1);
            res2 = new TVerificationResult(null, "test2", TResultSeverity.Resv_Noncritical);
            coll.Add(res2);
            res3 = new TVerificationResult(null, "test3", TResultSeverity.Resv_Noncritical);
            coll.Add(res3);

            // RemoveAt(index)
            Assert.Throws(typeof(ArgumentOutOfRangeException), delegate { coll.RemoveAt(4); }, "there is no verification result at index 4");
            // remove from the middle
            coll.RemoveAt(1);
            Assert.AreEqual(res0, coll.FindBy(0), "res0 should be at position 0");
            Assert.AreEqual(res2, coll.FindBy(1), "res2 should be at position 1");
            Assert.AreEqual(res3, coll.FindBy(2), "res3 should be at position 2");
            // remove from the front
            coll.RemoveAt(0);
            Assert.AreEqual(res2, coll.FindBy(0), "res2 should be at position 0");
            Assert.AreEqual(res3, coll.FindBy(1), "res3 should be at position 1");
            // remove from the back
            coll.RemoveAt(1);
            Assert.AreEqual(res2, coll.FindBy(0), "res2 should be at position 0");
            Assert.AreEqual(1, coll.Count, "only one element should be left");
        }
        public void TestDowngradeScreenVerificationResults()
        {
            TScreenVerificationResult     res0, res1;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            DataColumn col = new DataColumn("test", typeof(int));

            res0 = new TScreenVerificationResult(null, col, "test0", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res0);

            DataColumn          col2     = new DataColumn("test2", typeof(int));
            TextBox             txtField = new TextBox();
            TVerificationResult resVR    = new TVerificationResult(null, "test", TResultSeverity.Resv_Critical);

            res1 = new TScreenVerificationResult(resVR, col2, txtField);
            coll.Add(res1);

            Assert.AreEqual(2, coll.Count, "there should be two results");

            foreach (object o in coll)
            {
                Assert.IsInstanceOf(typeof(TScreenVerificationResult), o, "should be TScreenVerificationResult");
            }

            TVerificationResultCollection.DowngradeScreenVerificationResults(coll);

            Assert.AreEqual(2, coll.Count, "there should be two results after downgrade");

            foreach (object o in coll)
            {
                Assert.IsInstanceOf(typeof(TVerificationResult), o, "should be TVerificationResult");
                Assert.IsNotInstanceOf(typeof(TScreenVerificationResult), o, "should not be TScreenVerificationResult");
            }
        }
Esempio n. 6
0
        /// Returns true if it seems to be OK.
        private Boolean RunRevaluationIntern()
        {
            TDBTransaction Transaction = null;

            AGeneralLedgerMasterTable GlmTable    = new AGeneralLedgerMasterTable();
            AGeneralLedgerMasterRow   glmTemplate = (AGeneralLedgerMasterRow)GlmTable.NewRowTyped(false);
            Boolean transactionsWereCreated       = false;

            glmTemplate.LedgerNumber = F_LedgerNum;
            glmTemplate.Year         = F_FinancialYear;

            for (Int32 i = 0; i < F_ForeignAccount.Length; i++)
            {
                glmTemplate.AccountCode = F_ForeignAccount[i];
                DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted,
                                                                          ref Transaction,
                                                                          delegate
                {
                    GlmTable = AGeneralLedgerMasterAccess.LoadUsingTemplate(glmTemplate, Transaction);
                });

                if (GlmTable.Rows.Count > 0)
                {
                    transactionsWereCreated |= RevaluateAccount(GlmTable, F_ExchangeRate[i], F_ForeignAccount[i]);
                }
            }

            Boolean batchPostedOK = true;

            if (transactionsWereCreated)
            {
                batchPostedOK = CloseRevaluationAccountingBatch();
            }

            if (batchPostedOK)
            {
                if (!transactionsWereCreated) // If no transactions were needed, I'll just advise the user:
                {
                    FVerificationCollection.Add(new TVerificationResult(
                                                    "Post Forex Batch",
                                                    "Exchange rates are unchanged - no revaluation was required.",
                                                    TResultSeverity.Resv_Status));
                }

                for (Int32 i = 0; i < F_ForeignAccount.Length; i++)
                {
                    TLedgerInitFlag.RemoveFlagComponent(F_LedgerNum, MFinanceConstants.LEDGER_INIT_FLAG_REVAL, F_ForeignAccount[i]);
                }
            }
            else
            {
                FVerificationCollection.Add(new TVerificationResult(
                                                "Post Forex Batch",
                                                "The Revaluation Batch could not be posted.",
                                                TResultSeverity.Resv_Critical));
            }

            return(batchPostedOK);
        }
Esempio n. 7
0
        public static bool ValidateIBAN(string AIban, out string ABic, out string ABankName,
                                        out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = new TVerificationResultCollection();
            ABic      = String.Empty;
            ABankName = String.Empty;

            if ((AIban == null) || (AIban.Trim() == String.Empty))
            {
                AVerificationResult.Add(new TVerificationResult("error", "The IBAN is invalid", "",
                                                                "MaintainPartners.ErrInvalidIBAN", TResultSeverity.Resv_Critical));
                return(false);
            }

            string IBANCheckURL = TAppSettingsManager.GetValue("IBANCheck.Url", "https://kontocheck.solidcharity.com/?iban=");
            string url          = IBANCheckURL + AIban.Replace(" ", "");
            string result       = THTTPUtils.ReadWebsite(url);

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(result);

                XmlNode IbanCheck = TXMLParser.GetChild(doc.DocumentElement, "iban");
                if (IbanCheck.InnerText == "0")
                {
                    AVerificationResult.Add(new TVerificationResult("error", "The IBAN is invalid", "",
                                                                    "MaintainPartners.ErrInvalidIBAN", TResultSeverity.Resv_Critical));
                    return(false);
                }

                XmlNode BankName = TXMLParser.GetChild(doc.DocumentElement, "bankname");
                XmlNode City     = TXMLParser.GetChild(doc.DocumentElement, "city");
                ABankName = BankName.InnerText + ", " + City.InnerText;
                XmlNode BIC = TXMLParser.GetChild(doc.DocumentElement, "bic");
                ABic = BIC.InnerText;
            }
            catch (Exception)
            {
                TLogging.Log("Error validating IBAN: " + AIban.Replace(" ", ""));
                AVerificationResult.Add(new TVerificationResult("error", "The IBAN is invalid", "",
                                                                "MaintainPartners.ErrInvalidIBAN", TResultSeverity.Resv_Critical));
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        /// <summary>
        /// Imports a decimal value from the specified text line using the specified delimiter and culture info
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="ACultureInfoNumberFormat"></param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="AValidationColumnsDict"></param>
        /// <param name="ADefaultString"></param>
        /// <returns>The value.  The AImportLine parameter will have been clipped.</returns>
        public static decimal ImportDecimal(ref String AImportLine,
                                            String ADelimiter,
                                            CultureInfo ACultureInfoNumberFormat,
                                            String AColumnTitle,
                                            DataColumn ADataColumn,
                                            int ARowNumber,
                                            TVerificationResultCollection AMessages,
                                            TValidationControlsDict AValidationColumnsDict,
                                            String ADefaultString = "")
        {
            if ((ADataColumn != null) && (AValidationColumnsDict != null) && !AValidationColumnsDict.ContainsKey(ADataColumn))
            {
                AValidationColumnsDict.Add(ADataColumn, new TValidationControlsData(null, AColumnTitle));
            }

            String sReturn = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            if (sReturn == String.Empty)
            {
                sReturn = ADefaultString;
            }

            try
            {
                decimal dec = Convert.ToDecimal(sReturn, ACultureInfoNumberFormat);
                return(dec);
            }
            catch
            {
                AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                      String.Format(Catalog.GetString("Cannot convert '{0}' to a decimal number."), sReturn),
                                                      TResultSeverity.Resv_Critical));
                return(1.0m);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Imports an Int64 value from the specified text line using the specified delimiter
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="ADefaultString"></param>
        /// <returns>The value.  The AImportLine parameter will have been clipped.</returns>
        public static Int64 ImportInt64(ref String AImportLine,
                                        String ADelimiter,
                                        String AColumnTitle,
                                        DataColumn ADataColumn,
                                        int ARowNumber,
                                        TVerificationResultCollection AMessages,
                                        String ADefaultString = "")
        {
            String sReturn = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            if (sReturn == String.Empty)
            {
                sReturn = ADefaultString;
            }

            Int64 retVal;

            if (Int64.TryParse(sReturn, out retVal))
            {
                return(retVal);
            }

            AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                  String.Format(Catalog.GetString("Cannot convert '{0}' to an integer number."), sReturn),
                                                  TResultSeverity.Resv_Critical));
            return(1);
        }
Esempio n. 10
0
        /// <summary>
        /// Imports a string value from the specified text line using the specified delimiter
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="AValidationColumnsDict"></param>
        /// <param name="ATreatEmptyStringAsText">When true the return value will be the empty string. When false the return value will be null.</param>
        /// <returns>The string value.  The AImportLine parameter will have been clipped.</returns>
        public static String ImportString(ref String AImportLine,
                                          String ADelimiter,
                                          String AColumnTitle,
                                          DataColumn ADataColumn,
                                          int ARowNumber,
                                          TVerificationResultCollection AMessages,
                                          TValidationControlsDict AValidationColumnsDict,
                                          bool ATreatEmptyStringAsText = true)
        {
            if ((ADataColumn != null) && (AValidationColumnsDict != null) && !AValidationColumnsDict.ContainsKey(ADataColumn))
            {
                AValidationColumnsDict.Add(ADataColumn, new TValidationControlsData(null, AColumnTitle));
            }

            String sReturn = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            if ((sReturn == StringHelper.CSV_STRING_FORMAT_ERROR) && (AMessages != null))
            {
                AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                      Catalog.GetString("Could not parse the quoted string. Did you forget a quotation mark?"),
                                                      TResultSeverity.Resv_Critical));
            }

            if ((sReturn.Length == 0) && !ATreatEmptyStringAsText)
            {
                return(null);
            }

            return(sReturn);
        }
Esempio n. 11
0
        /// <summary>
        /// Updates the KeyCount on an Extract.
        /// </summary>
        /// <param name="AExtractId">ExtractId of the Extract that the KeyCount should
        /// get updated for.</param>
        /// <param name="ACount">New Key Count.</param>
        /// <param name="AVerificationResult">Contains errors or DB call exceptions, if there are any.</param>
        /// <returns>True if the updating was successful, otherwise false.</returns>
        public static bool UpdateExtractKeyCount(int AExtractId, int ACount,
                                                 out TVerificationResultCollection AVerificationResult)
        {
            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;
            TVerificationResultCollection VerificationResult = new TVerificationResultCollection();

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK,
                                                                  delegate
            {
                MExtractMasterTable ExtractMasterDT = MExtractMasterAccess.LoadByPrimaryKey(AExtractId,
                                                                                            Transaction);

                if (ExtractMasterDT.Rows.Count == 1)
                {
                    ExtractMasterDT[0].KeyCount = ACount;

                    MExtractMasterAccess.SubmitChanges(ExtractMasterDT, Transaction);
                    SubmissionOK = true;
                }
                else
                {
                    VerificationResult.Add(new TVerificationResult(
                                               "TExtractsHandling.UpdateExtractCount", "Extract with Extract Id " + AExtractId.ToString() +
                                               " doesn't exist!", TResultSeverity.Resv_Critical));
                }
            });

            AVerificationResult = VerificationResult;

            return(SubmissionOK);
        }
Esempio n. 12
0
        /// <summary>
        /// Imports a boolean value from the specified text line using the specified delimiter.
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="ADefaultString">A string to apply if the import returns empty text.  Must be either 'yes' or 'no'</param>
        /// <returns>Returns true if the text is 'yes', false if the text is 'no'. Otherwise the method returns a critical Verification Result.</returns>
        public static Boolean ImportBoolean(ref String AImportLine,
                                            String ADelimiter,
                                            String AColumnTitle,
                                            DataColumn ADataColumn,
                                            int ARowNumber,
                                            TVerificationResultCollection AMessages,
                                            String ADefaultString = "")
        {
            String sReturn  = StringHelper.GetNextCSV(ref AImportLine, ADelimiter).ToLower();
            String sDefault = ADefaultString.ToLower();

            bool canBeEmptyString = ((sDefault == "yes") || (sDefault == "no"));

            if ((sReturn == String.Empty) && canBeEmptyString)
            {
                sReturn = sDefault;
            }

            if ((sReturn == "yes") || (sReturn == "no"))
            {
                return(sReturn.Equals("yes"));
            }

            AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                  String.Format(Catalog.GetString("Cannot convert '{0}' to a Boolean. The text must be {1}. The text is not case-sensitive."),
                                                                sReturn,
                                                                canBeEmptyString ? Catalog.GetString("one of 'yes', 'no' or an empty string") : Catalog.GetString("either 'yes' or 'no'")),
                                                  TResultSeverity.Resv_Critical));
            return(false);
        }
Esempio n. 13
0
        /// <summary>
        /// Imports an Int32 value from the specified text line using the specified delimiter
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="AValidationColumnsDict"></param>
        /// <param name="ADefaultString"></param>
        /// <returns>The value.  The AImportLine parameter will have been clipped.</returns>
        public static Int32 ImportInt32(ref String AImportLine,
                                        String ADelimiter,
                                        String AColumnTitle,
                                        DataColumn ADataColumn,
                                        int ARowNumber,
                                        TVerificationResultCollection AMessages,
                                        TValidationControlsDict AValidationColumnsDict,
                                        String ADefaultString = "")
        {
            if ((ADataColumn != null) && (AValidationColumnsDict != null) && !AValidationColumnsDict.ContainsKey(ADataColumn))
            {
                AValidationColumnsDict.Add(ADataColumn, new TValidationControlsData(null, AColumnTitle));
            }

            String sReturn = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            if (sReturn == String.Empty)
            {
                sReturn = ADefaultString;
            }

            Int32 retVal;

            if (Int32.TryParse(sReturn, out retVal))
            {
                return(retVal);
            }

            AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                  String.Format(Catalog.GetString("Cannot convert '{0}' to an integer number.."), sReturn),
                                                  TResultSeverity.Resv_Critical));
            return(1);
        }
Esempio n. 14
0
        /// <summary>
        /// Method to check and, if possible fix, codes that have had leading zeros removed by Excel for example.
        /// </summary>
        /// <param name="ALedgerNumber">The ledger number</param>
        /// <param name="ARowNumber">The current row number</param>
        /// <param name="AAccountCode">The account code that may get changed</param>
        /// <param name="AAccountTableRef">The account table that will be checked for valid codes</param>
        /// <param name="ACostCentreCode">The cost centre code that may get changed</param>
        /// <param name="ACostCentreTableRef">The cost centre table that will be checked for valid codes</param>
        /// <param name="AMessages">A message collection.  If a change is made a 'Information' (non-critical) message will be added to the collection</param>
        public static void FixAccountCodes(int ALedgerNumber, int ARowNumber, ref string AAccountCode, AAccountTable AAccountTableRef,
                                           ref string ACostCentreCode, ACostCentreTable ACostCentreTableRef, TVerificationResultCollection AMessages)
        {
            // Start with the Account code
            string code = ConvertTo4DigitCode(AAccountCode);

            if (code != AAccountCode)
            {
                // Maybe it is wrong?
                if (AAccountTableRef.Rows.Find(new object[] { ALedgerNumber, AAccountCode }) == null)
                {
                    // That one does not exist, so try our new 4 digit one
                    if (AAccountTableRef.Rows.Find(new object[] { ALedgerNumber, code }) != null)
                    {
                        // Swap the short code for the longer one
                        AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrImportValidationWarningInLine, ARowNumber),
                                                              String.Format(Catalog.GetString(
                                                                                "The account code '{0}' does not exist.  The code has been converted to '{1}' (which does exist).  Please check that this is what you intended."),
                                                                            AAccountCode, code),
                                                              TResultSeverity.Resv_Noncritical));
                        AAccountCode = code;
                    }
                }
            }

            // Do the same for the cost centre code
            code = ConvertTo4DigitCode(ACostCentreCode);

            if (code != ACostCentreCode)
            {
                // Maybe it is wrong?
                if (ACostCentreTableRef.Rows.Find(new object[] { ALedgerNumber, ACostCentreCode }) == null)
                {
                    // That one does not exist, so try our new 4 digit one
                    if (ACostCentreTableRef.Rows.Find(new object[] { ALedgerNumber, code }) != null)
                    {
                        // Swap the short code for the longer one
                        AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrImportValidationWarningInLine, ARowNumber),
                                                              String.Format(Catalog.GetString(
                                                                                "The cost centre code '{0}' does not exist.  The code has been converted to '{1}' (which does exist).  Please check that this is what you intended."),
                                                                            ACostCentreCode, code),
                                                              TResultSeverity.Resv_Noncritical));
                        ACostCentreCode = code;
                    }
                }
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Standard routine to execute each PeriodEndOperation, and then confirm its success
        /// </summary>
        /// <param name="AOperation"></param>
        /// <param name="AOperationName"></param>
        protected void RunPeriodEndSequence(AbstractPeriodEndOperation AOperation, string AOperationName)
        {
            if (WasCancelled)
            {
                TLogging.Log(AOperationName + ": operation cancelled by user.");
                return;
            }

            AOperation.IsInInfoMode = FInfoMode;
            AOperation.VerificationResultCollection = FverificationResults;
            AOperation.FPeriodEndOperator           = this;

            if (FInfoMode)
            {
                // non-critical messages to be omitted - 3829

                /*if (AOperation.GetJobSize() == 0)
                 * {
                 *  // Non Critical Problem but the user shall be informed ...
                 *  String strTitle = Catalog.GetString("Period end status");
                 *  String strMessage = String.Format(Catalog.GetString("Nothing to be done for \"{0}\""), AOperationName);
                 *  TVerificationResult tvt =
                 *      new TVerificationResult(strTitle, strMessage, "",
                 *          TPeriodEndErrorAndStatusCodes.PEEC_01.ToString(),
                 *          TResultSeverity.Resv_Info);
                 *  FverificationResults.Add(tvt);
                 * }*/
            }
            else
            {
                // now we actually run the operation
                Int32 OperationsDone = AOperation.RunOperation();
//              TLogging.Log("Period End: RunPeriodEndSequence (" + AOperationName + ") returns " + OperationsDone);

                AbstractPeriodEndOperation VerifyOperation = AOperation.GetActualizedClone();
                VerifyOperation.IsInInfoMode = true;
                VerifyOperation.VerificationResultCollection = FverificationResults;
                Int32 RemainingItems = VerifyOperation.GetJobSize();

                if (RemainingItems > 0)
                {
                    // Critical Problem because there should be nothing left to do.
                    TVerificationResult tvt =
                        new TVerificationResult(
                            String.Format(Catalog.GetString("Problem in \"{0}\""), AOperationName),
                            String.Format(Catalog.GetString("{0} operations were completed, but {1} were found still to do!"),
                                          OperationsDone, RemainingItems),
                            "",
                            TPeriodEndErrorAndStatusCodes.PEEC_02.ToString(),
                            TResultSeverity.Resv_Critical);
                    FverificationResults.Add(tvt);
                    FHasCriticalErrors = true;
                }

                FHasCriticalErrors |= AOperation.HasCriticalErrors;
                FHasCriticalErrors |= VerifyOperation.HasCriticalErrors;
            }
        }
Esempio n. 16
0
        public static bool PeriodMonthEnd(
            Int32 ALedgerNumber,
            bool AInfoMode,
            out List <Int32> AglBatchNumbers,
            out Boolean AStewardshipBatch,
            out TVerificationResultCollection AVerificationResults)
        {
            AglBatchNumbers   = new List <int>();
            AStewardshipBatch = false;
            try
            {
                TLedgerInfo ledgerInfo    = new TLedgerInfo(ALedgerNumber);
                Int32       PeriodClosing = ledgerInfo.CurrentPeriod;
                bool        res           = new TMonthEnd(ledgerInfo).RunMonthEnd(AInfoMode,
                                                                                  out AglBatchNumbers,
                                                                                  out AStewardshipBatch,
                                                                                  out AVerificationResults);

                if (!res && !AInfoMode)
                {
                    TDBTransaction         Transaction = null;
                    AAccountingPeriodTable PeriodTbl   = null;

                    DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadUncommitted,
                                                                              TEnforceIsolationLevel.eilMinimum,
                                                                              ref Transaction,
                                                                              delegate
                    {
                        PeriodTbl = AAccountingPeriodAccess.LoadByPrimaryKey(ledgerInfo.LedgerNumber, PeriodClosing, Transaction);
                    });

                    if (PeriodTbl.Rows.Count > 0)
                    {
                        AVerificationResults.Add(
                            new TVerificationResult(
                                Catalog.GetString("Month End"),
                                String.Format(Catalog.GetString("The period {0} - {1} has been closed."),
                                              PeriodTbl[0].PeriodStartDate.ToShortDateString(), PeriodTbl[0].PeriodEndDate.ToShortDateString()),
                                TResultSeverity.Resv_Status));
                    }
                }

                return(res);
            }
            catch (Exception e)
            {
                TLogging.Log("TPeriodIntervallConnector.TPeriodMonthEnd() throws " + e.ToString());
                AVerificationResults = new TVerificationResultCollection();
                AVerificationResults.Add(
                    new TVerificationResult(
                        Catalog.GetString("Month End"),
                        Catalog.GetString("Uncaught Exception: ") + e.Message,
                        TResultSeverity.Resv_Critical));


                return(true);
            }
        }
Esempio n. 17
0
        private static void AddVerificationResult(String AResultText, TResultSeverity ASeverity)
        {
            if (ASeverity != TResultSeverity.Resv_Status)
            {
                TLogging.Log(AResultText);
            }

            ResultsCol.Add(new TVerificationResult(ResultsContext, AResultText, ASeverity));
        }
        public void TestCountErrorsAndHasProperties()
        {
            TVerificationResult           res;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            Assert.AreEqual(0, coll.Count, "there should be no verification result");
            Assert.AreEqual(0, coll.CountCriticalErrors, "there should be no critical errors");
            Assert.IsFalse(coll.HasOnlyNonCriticalErrors, "HasOnlyNonCriticalErrors: false because there are no errors at all");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Info);
            coll.Add(res);
            Assert.AreEqual(1, coll.Count, "there should be 1 verification result");
            Assert.AreEqual(0, coll.CountCriticalErrors, "there should be no critical error");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Status);
            coll.Add(res);
            Assert.AreEqual(2, coll.Count, "there should be 2 verification results");
            Assert.AreEqual(0, coll.CountCriticalErrors, "there should be no critical error");
            Assert.IsFalse(coll.HasOnlyNonCriticalErrors, "there are info and status");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Noncritical);
            coll.Add(res);
            Assert.AreEqual(3, coll.Count, "there should be 3 verification results");
            Assert.AreEqual(0, coll.CountCriticalErrors, "there should be no critical error");
            Assert.IsFalse(coll.HasCriticalErrors, "should not have critical errors");
            Assert.IsFalse(coll.HasOnlyNonCriticalErrors, "there are info and status and noncritical errors");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Critical);
            coll.Add(res);
            Assert.AreEqual(4, coll.Count, "there should be 4 verification results");
            Assert.AreEqual(1, coll.CountCriticalErrors, "there should be 1 critical error");
            Assert.IsTrue(coll.HasCriticalErrors, "should have critical errors");
            Assert.IsFalse(coll.HasOnlyNonCriticalErrors, "HasOnlyNonCriticalErrors: false because there is a critical error");
            Assert.IsTrue(coll.HasCriticalOrNonCriticalErrors, "has critical and non critical errors");

            coll = new TVerificationResultCollection();
            Assert.IsFalse(coll.HasOnlyNonCriticalErrors, "HasOnlyNonCriticalErrors: false because there are no errors at all");

            res = new TVerificationResult(null, "test", TResultSeverity.Resv_Noncritical);
            coll.Add(res);
            Assert.AreEqual(0, coll.CountCriticalErrors, "there should be no critical error");
            Assert.IsFalse(coll.HasCriticalErrors, "should not have critical errors");
            Assert.IsTrue(coll.HasOnlyNonCriticalErrors, "there is only one noncritical errors");
        }
        public void TestContains()
        {
            TVerificationResult           res1;
            TScreenVerificationResult     res2;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            // Contains(IResultInterface)
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical);
            Assert.IsFalse(coll.Contains(res1), "should not contain res1");
            coll.Add(res1);
            Assert.IsTrue(coll.Contains(res1), "should contain res1");

            // Contains(string AResultContext)
            res1 = new TVerificationResult("testcontext", "testresulttext", "testcaption", "testresultcode", TResultSeverity.Resv_Noncritical);
            Assert.IsFalse(coll.Contains("testcontext"), "should not contain testcontext");
            coll.Add(res1);
            Assert.IsTrue(coll.Contains("testcontext"), "should contain testcontext (by string)");

            // Contains(object AResultContext) with a control
            TextBox txtTest1 = new TextBox();

            res2 = new TScreenVerificationResult(txtTest1, null, "test1", "t1", txtTest1, TResultSeverity.Resv_Noncritical);
            Assert.IsFalse(coll.Contains(txtTest1), "should not contain txtTest1 box");
            coll.Add(res2);
            Assert.IsTrue(coll.Contains(txtTest1), "should contain txtTest1 box");

            // Contains(DataColumn)
            DataColumn col = new DataColumn("test", typeof(int));

            Assert.IsFalse(coll.Contains(col), "should not contain col");
            res2 = new TScreenVerificationResult(null, col, "test1", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res2);
            Assert.IsTrue(coll.Contains(col), "should contain col");

            // Contains(DataTable)
            DataTable  tab  = new DataTable("test");
            DataColumn col2 = new DataColumn("test2", typeof(string));

            tab.Columns.Add(col2);
            Assert.IsFalse(coll.Contains(tab), "should not contain tab");
            res2 = new TScreenVerificationResult(null, col2, "test1", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res2);
            Assert.IsTrue(coll.Contains(tab), "should contain tab");
        }
Esempio n. 20
0
        /// <summary>
        /// Imports a Date value from the specified text line using the specified delimiter
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="ACultureInfoDateFormat"></param>
        /// <param name="ADateMayBeAnInteger"></param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="AValidationColumnsDict"></param>
        /// <param name="ADefaultString"></param>
        /// <returns>The date value.  The AImportLine parameter will have been clipped.</returns>
        public static DateTime ImportDate(ref String AImportLine,
                                          String ADelimiter,
                                          CultureInfo ACultureInfoDateFormat,
                                          bool ADateMayBeAnInteger,
                                          String AColumnTitle,
                                          DataColumn ADataColumn,
                                          int ARowNumber,
                                          TVerificationResultCollection AMessages,
                                          TValidationControlsDict AValidationColumnsDict,
                                          String ADefaultString = "")
        {
            if ((ADataColumn != null) && (AValidationColumnsDict != null) && !AValidationColumnsDict.ContainsKey(ADataColumn))
            {
                AValidationColumnsDict.Add(ADataColumn, new TValidationControlsData(null, AColumnTitle));
            }

            String sDate = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            int dateAsInt;
            int dateLength = sDate.Length;

            if (sDate == String.Empty)
            {
                sDate = ADefaultString;
            }
            else if (ADateMayBeAnInteger && ((dateLength == 6) || (dateLength == 8)) && !sDate.Contains(".") && !sDate.Contains(","))
            {
                if (int.TryParse(sDate, out dateAsInt) && (dateAsInt > 10100) && (dateAsInt < 311300))
                {
                    sDate = sDate.Insert(dateLength - 2, "-").Insert(dateLength - 4, "-");
                }
                else if (int.TryParse(sDate, out dateAsInt) && (dateAsInt > 1011900) && (dateAsInt < 31133000))
                {
                    sDate = sDate.Insert(dateLength - 4, "-").Insert(dateLength - 6, "-");
                }
            }

            DateTime dtReturn;

            try
            {
                dtReturn = Convert.ToDateTime(sDate, ACultureInfoDateFormat);
            }
            catch (Exception)
            {
                AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                      String.Format(Catalog.GetString("Cannot convert '{0}' to a date."), sDate),
                                                      TResultSeverity.Resv_Critical));
                TLogging.Log("Problem parsing " + sDate + " with format " + ACultureInfoDateFormat.DateTimeFormat.ShortDatePattern);
                return(DateTime.Today);
            }

            return(dtReturn);
        }
Esempio n. 21
0
 void ProcessConfidentialMessage()
 {
     if (!confidentialMessageGiven)
     {
         FMessages.Add(new TVerificationResult(
                           Catalog.GetString("Gift Details"), Catalog.GetString("Please note that some gifts in this report are restricted.\n" +
                                                                                "To include full details of these gifts, the export\n" +
                                                                                "must be run by someone with a higher level of access."),
                           TResultSeverity.Resv_Noncritical));
         confidentialMessageGiven = true;
     }
 }
        public void TestBuildVerificationResultString()
        {
            TVerificationResult           res0, res1, res2, res3, res4, res5, res6, res7;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical);
            coll.Add(res0);
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Info);
            coll.Add(res1);
            TextBox tb1 = new TextBox();

            res2 = new TVerificationResult(tb1, "test2", TResultSeverity.Resv_Critical);
            coll.Add(res2);
            res3 = new TVerificationResult(tb1, "test3", TResultSeverity.Resv_Noncritical);
            coll.Add(res3);
            DataColumn col = new DataColumn("test", typeof(int));

            res4 = new TScreenVerificationResult(null, col, "test4", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res4);
            DataTable  tab  = new DataTable("test");
            DataColumn col2 = new DataColumn("test2", typeof(string));

            tab.Columns.Add(col2);
            DataColumn col3 = new DataColumn("test3", typeof(string));

            tab.Columns.Add(col3);
            res5 = new TScreenVerificationResult(null, col2, "test5", null, TResultSeverity.Resv_Status);
            coll.Add(res5);
            res6 = new TScreenVerificationResult(null, col, "test6", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res6);
            res7 = new TScreenVerificationResult(null, col3, "test7", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res7);

            Console.WriteLine(coll.BuildVerificationResultString());
            Console.WriteLine(coll.BuildVerificationResultString().Replace("\n", "\\n").Replace("\r", "\\r"));

            const string expectedString =
                "\r\n    Problem: test0\r\n    (Non-critical)\r\n\r\n" +
                "\r\n    Status: test1\r\n\r\n\r\nSystem.Windows.Forms.TextBox, Text: " +
                "\r\n    Problem: test2\r\n    (Critical)\r\n\r\nSystem.Windows.Forms.TextBox, Text: " +
                "\r\n    Problem: test3\r\n    (Non-critical)\r\n\r\n" +
                "\r\n    Problem: test4\r\n    (Non-critical)\r\n\r\n" +
                "\r\n    Status: test5\r\n\r\n\r\n" +
                "\r\n    Problem: test6\r\n    (Non-critical)\r\n\r\n" +
                "\r\n    Problem: test7\r\n    (Non-critical)\r\n\r\n";

            Assert.AreEqual(expectedString, coll.BuildVerificationResultString(), "comparing the string");
        }
Esempio n. 23
0
        public static bool DeletePartner(Int64 APartnerKey,
                                         out TVerificationResultCollection AVerificationResult)
        {
            string ErrorMsg = String.Empty;

            if (!TPartnerWebConnector.CanPartnerBeDeleted(APartnerKey, out ErrorMsg))
            {
                AVerificationResult = new TVerificationResultCollection();
                AVerificationResult.Add(new TVerificationResult("error", ErrorMsg, TResultSeverity.Resv_Critical));
                return(false);
            }

            return(TPartnerWebConnector.DeletePartner(APartnerKey, out AVerificationResult));
        }
Esempio n. 24
0
        /// <summary>
        /// Master routine ...
        /// </summary>
        /// <param name="AInfoMode"></param>
        /// <param name="AVRCollection"></param>
        /// <returns>True if an error occurred</returns>
        public bool RunYearEnd(bool AInfoMode,
            out TVerificationResultCollection AVRCollection)
        {
            FInfoMode = AInfoMode;
            AVRCollection = new TVerificationResultCollection();
            FverificationResults = AVRCollection;

            if (!FledgerInfo.ProvisionalYearEndFlag)
            {
                TVerificationResult tvt =
                    new TVerificationResult(Catalog.GetString("Month End is required!"),
                        Catalog.GetString("In this situation you cannot run Year End."), "",
                        TPeriodEndErrorAndStatusCodes.PEEC_04.ToString(),
                        TResultSeverity.Resv_Critical);
                AVRCollection.Add(tvt);
                FHasCriticalErrors = true;
                return true;
            }

            Int32 FOldYearNum = FledgerInfo.CurrentFinancialYear;

            RunPeriodEndSequence(new TArchive(FledgerInfo),
                Catalog.GetString("Archive old financial information"));

            RunPeriodEndSequence(new TReallocation(FledgerInfo),
                Catalog.GetString("Reallocate all income and expense accounts"));

            RunPeriodEndSequence(new TGlmNewYearInit(FledgerInfo, FOldYearNum, this),
                Catalog.GetString("Initialize the database for next year"));

/* As far as we can tell, there's nothing to do for budgets:
 *          RunPeriodEndSequence(new TNewYearBudgets(FledgerInfo),
 *              Catalog.GetString("Initialise budgets for next year"));
 */

            RunPeriodEndSequence(new TResetForwardPeriodBatches(FledgerInfo, FOldYearNum),
                Catalog.GetString("Re-base last year's forward-posted batches so they're in the new year."));

            RunPeriodEndSequence(new TResetForwardPeriodICH(FledgerInfo),
                Catalog.GetString("Re-base last year's forward-posted ICH Stewardship to the new year."));

            if (!FInfoMode && !FHasCriticalErrors)
            {
                FledgerInfo.ProvisionalYearEndFlag = false;
            }

            return FHasCriticalErrors;
        }
Esempio n. 25
0
        public static bool CheckGiftsNotPreviouslyReversed(GiftBatchTDS AGiftDS, out TVerificationResultCollection AMessages)
        {
            string Message   = string.Empty;
            int    GiftCount = 0;

            AMessages = new TVerificationResultCollection();

            // sort gifts
            AGiftDS.AGiftDetail.DefaultView.Sort = string.Format("{0}, {1}, {2}",
                                                                 AGiftDetailTable.GetBatchNumberDBName(),
                                                                 AGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                                 AGiftDetailTable.GetDetailNumberDBName());

            foreach (DataRowView RowView in AGiftDS.AGiftDetail.DefaultView)
            {
                AGiftDetailRow GiftDetailRow = (AGiftDetailRow)RowView.Row;

                if (GiftDetailRow.ModifiedDetail)
                {
                    Message += "\n" + String.Format(Catalog.GetString("Gift {0} with Detail {1} in Batch {2}"),
                                                    GiftDetailRow.GiftTransactionNumber, GiftDetailRow.DetailNumber, GiftDetailRow.BatchNumber);

                    GiftCount++;
                }
            }

            if (GiftCount != 0)
            {
                if (GiftCount > 1)
                {
                    Message = String.Format(Catalog.GetString("Cannot reverse or adjust the following gifts:")) + "\n" + Message +
                              "\n\n" + Catalog.GetString("They have already been adjusted or reversed.");
                }
                else if (GiftCount == 1)
                {
                    Message = String.Format(Catalog.GetString("Cannot reverse or adjust the following gift:")) + "\n" + Message +
                              "\n\n" + Catalog.GetString("It has already been adjusted or reversed.");
                }

                AMessages.Add(new TVerificationResult(null, Message, TResultSeverity.Resv_Critical));

                return(false);
            }

            return(true);
        }
        public void TestRemove()
        {
            TVerificationResult           res0, res1, res4, res5, res6, res7;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical);
            coll.Add(res0);
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Noncritical);
            coll.Add(res1);
            DataColumn col = new DataColumn("test", typeof(int));

            res4 = new TScreenVerificationResult(null, col, "test4", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res4);
            DataTable  tab  = new DataTable("test");
            DataColumn col2 = new DataColumn("test2", typeof(string));

            tab.Columns.Add(col2);
            DataColumn col3 = new DataColumn("test3", typeof(string));

            tab.Columns.Add(col3);
            res5 = new TScreenVerificationResult(null, col2, "test5", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res5);
            res6 = new TScreenVerificationResult(null, col, "test6", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res6);
            res7 = new TScreenVerificationResult(null, col3, "test7", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res7);

            Assert.AreEqual(6, coll.Count, "should be 6 elements at the start of the test");

            // Remove(DataColumn)
            coll.Remove(col);
            Assert.AreEqual(5, coll.Count, "only one element should be removed, even if there are 2 results with column col");
            Assert.AreEqual(2, coll.IndexOf(res5), "res4 was removed");
            coll.Insert(2, res4);
            coll.Remove(new DataColumn("test"));
            Assert.AreEqual(6, coll.Count, "nothing happens when trying to remove unknown column");

            // Remove(IResultInterface value)
            coll.Remove(res1);
            Assert.AreEqual(5, coll.Count, "res1 should have been removed");
            coll.Insert(1, res1);
            Assert.Throws(typeof(ArgumentException),
                          delegate { coll.Remove(new TVerificationResult(null, "test3", TResultSeverity.Resv_Info)); },
                          "trying to remove unknown verification result throws ArgumentException");

            // Remove(String AResultColumnName)
            coll.Remove("nonexisting");
            Assert.AreEqual(6, coll.Count, "nothing happens when trying to remove unknown resultcolumnname");
            coll.Remove(col.ColumnName);
            Assert.AreEqual(5, coll.Count, "should have removed res4");
            Assert.AreEqual(res6, coll.FindBy(col), "first result with col should be res6");
            coll.Insert(4, res4);
        }
Esempio n. 27
0
        /// <summary>
        /// Imports a decimal value from the specified text line using the specified delimiter and culture info
        /// </summary>
        /// <param name="AImportLine">The line containing the text to be imported.  When the method returns the imported value
        /// will have been removed from the start ready for the next call to an Import method.</param>
        /// <param name="ADelimiter">The delimiter</param>
        /// <param name="ACultureInfoNumberFormat"></param>
        /// <param name="AColumnTitle"></param>
        /// <param name="ADataColumn"></param>
        /// <param name="ARowNumber"></param>
        /// <param name="AMessages"></param>
        /// <param name="AValidationColumnsDict"></param>
        /// <param name="ADefaultString"></param>
        /// <returns>The value.  The AImportLine parameter will have been clipped.</returns>
        public static decimal ImportDecimal(ref String AImportLine,
                                            String ADelimiter,
                                            CultureInfo ACultureInfoNumberFormat,
                                            String AColumnTitle,
                                            DataColumn ADataColumn,
                                            int ARowNumber,
                                            TVerificationResultCollection AMessages,
                                            TValidationControlsDict AValidationColumnsDict,
                                            String ADefaultString = "")
        {
            if ((ADataColumn != null) && (AValidationColumnsDict != null) && !AValidationColumnsDict.ContainsKey(ADataColumn))
            {
                AValidationColumnsDict.Add(ADataColumn, new TValidationControlsData(null, AColumnTitle));
            }

            String sReturn = StringHelper.GetNextCSV(ref AImportLine, ADelimiter);

            if (sReturn == String.Empty)
            {
                sReturn = ADefaultString;
            }

            try
            {
                // Always use the invariant culture
                if (ACultureInfoNumberFormat.NumberFormat.NumberDecimalSeparator == ".")
                {
                    // Decimal dot: just replace thousands with nothing (comma, space and apostrophe)
                    return(Convert.ToDecimal(sReturn.Replace(",", "").Replace(" ", "").Replace("'", ""), CultureInfo.InvariantCulture));
                }
                else
                {
                    // Decimal comma: replace thousands with nothing (dot, space and apostrophe) and then comma with dot
                    return(Convert.ToDecimal(sReturn.Replace(".", "").Replace(" ", "").Replace("'", "").Replace(",",
                                                                                                                "."), CultureInfo.InvariantCulture));
                }
            }
            catch
            {
                AMessages.Add(new TVerificationResult(String.Format(MCommonConstants.StrParsingErrorInLineColumn, ARowNumber, AColumnTitle),
                                                      String.Format(Catalog.GetString("Cannot convert '{0}' to a decimal number."), sReturn),
                                                      TResultSeverity.Resv_Critical));
                return(1.0m);
            }
        }
Esempio n. 28
0
        public static bool TPeriodYearEnd(
            int ALedgerNum,
            bool AIsInInfoMode,
            out TVerificationResultCollection AVerificationResult)
        {
            bool NewTransaction;

            DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction);

            try
            {
                TLedgerInfo LedgerInfo = new TLedgerInfo(ALedgerNum);
                bool res = new TYearEnd(LedgerInfo).RunYearEnd(AIsInInfoMode, out AVerificationResult);

                if (!res)
                {
                    String SuccessMsg = AIsInInfoMode ? "YearEnd check: No problems found." : "Success.";
                    AVerificationResult.Add(new TVerificationResult("Year End", SuccessMsg, "Success", TResultSeverity.Resv_Status));
                }

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }

                return res;
            }
            catch (Exception e)
            {
                TLogging.Log("TPeriodIntervalConnector.TPeriodYearEnd() throws " + e.ToString());
                AVerificationResult = new TVerificationResultCollection();
                AVerificationResult.Add(
                    new TVerificationResult(
                        Catalog.GetString("Year End"),
                        Catalog.GetString("Uncaught Exception: ") + e.Message,
                        TResultSeverity.Resv_Critical));

                DBAccess.GDBAccessObj.RollbackTransaction();

                return false;
            }
        }
Esempio n. 29
0
        public static bool EditHistory(
            Int64 APartnerKey,
            string ADataType,
            string AChannelCode,
            DateTime AConsentDate,
            string AConsentCodes,
            out TVerificationResultCollection AVerificationResult
            )
        {
            AVerificationResult = new TVerificationResultCollection();
            DataConsentTDS LastEntry = LastKnownEntry(APartnerKey, ADataType);
            DataConsentTDSPConsentHistoryRow LastEntryRow = LastEntry.PConsentHistory[0];

            // tried to save with same permissions, we skip these actions and throw a error
            if (LastEntryRow.AllowedPurposes == AConsentCodes && LastEntryRow.ConsentDate == AConsentDate &&
                LastEntryRow.ChannelCode == AChannelCode)
            {
                AVerificationResult.Add(new TVerificationResult("error", "no_changes", TResultSeverity.Resv_Critical));
                return(false);
            }

            DataHistoryChange ToChange = new DataHistoryChange
            {
                ConsentDate = AConsentDate,
                ChannelCode = AChannelCode,
                PartnerKey  = APartnerKey,
                Type        = ADataType,
                Value       = LastEntryRow.Value,
                Permissions = AConsentCodes
            };

            String        ToRegister = JsonConvert.SerializeObject(ToChange);
            List <string> JsonList   = new List <string> {
                ToRegister
            };

            RegisterChanges(JsonList, new List <string>()
            {
                ADataType
            });
            return(true);
        }
        public void TestBuildScreenVerificationResultList()
        {
            TVerificationResult           res0, res1, res4, res5, res6, res7, res8;
            TVerificationResultCollection coll = new TVerificationResultCollection();

            res0 = new TVerificationResult(null, "test0", TResultSeverity.Resv_Noncritical);
            coll.Add(res0);
            res1 = new TVerificationResult(null, "test1", TResultSeverity.Resv_Info);
            coll.Add(res1);
            DataColumn col = new DataColumn("test", typeof(int));

            res4 = new TScreenVerificationResult(null, col, "test4", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res4);
            DataTable  tab  = new DataTable("test");
            DataColumn col2 = new DataColumn("test2", typeof(string));

            tab.Columns.Add(col2);
            DataColumn col3 = new DataColumn("test3", typeof(string));

            tab.Columns.Add(col3);
            res5 = new TScreenVerificationResult(null, col2, "test5", null, TResultSeverity.Resv_Status);
            coll.Add(res5);
            res6 = new TScreenVerificationResult(null, col, "test6", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res6);
            res7 = new TScreenVerificationResult(null, col3, "test7", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res7);
            res8 = new TScreenVerificationResult("test8", col3, "test8", null, TResultSeverity.Resv_Noncritical);
            coll.Add(res8);

            String ErrorMessages;
            Object testObject;

            coll.BuildScreenVerificationResultList(out ErrorMessages, out testObject, null, true);

            coll.BuildScreenVerificationResultList("test8", out ErrorMessages);

            Console.WriteLine(ErrorMessages);
            Console.WriteLine(ErrorMessages.Replace("\n", "\\n").Replace("\r", "\\r"));

            String expectedErrorMessages =
                "test8" + Environment.NewLine + Environment.NewLine;

            Assert.AreEqual(expectedErrorMessages, ErrorMessages, "only show errors of resultcontext test1 and of TVerificationScreenResult");
        }