private void ShowMessages(TVerificationResultCollection AMessages)
        {
            StringBuilder ErrorMessages = new StringBuilder();

            if (AMessages.Count > 0)
            {
                foreach (TVerificationResult message in AMessages)
                {
                    ErrorMessages.AppendFormat("[{0}] {1}: {2}{3}", message.ResultContext, message.ResultTextCaption,
                                               message.ResultText.Replace(Environment.NewLine, " "), Environment.NewLine);
                }
            }

            if (ErrorMessages.Length > 0)
            {
                TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm());
                extendedMessageBox.ShowDialog(ErrorMessages.ToString(), Catalog.GetString("Import Errors"), String.Empty,
                                              TFrmExtendedMessageBox.TButtons.embbOK, TFrmExtendedMessageBox.TIcon.embiError);
            }
        }
Exemplo n.º 2
0
        // This manual method lets us peek at the data that is about to be saved...
        // The data has already been collected from the contols and validated and there is definitely something to save...
        private TSubmitChangesResult StoreManualCode(ref GiftBatchTDS SubmitDS, out TVerificationResultCollection VerificationResult)
        {
            FLatestSaveIncludedForex = false;

            if (SubmitDS.AGiftBatch != null)
            {
                // Check whether we are saving any rows that are in foreign currency
                foreach (AGiftBatchRow row in SubmitDS.AGiftBatch.Rows)
                {
                    if (row.CurrencyCode != FMainDS.ALedger[0].BaseCurrency)
                    {
                        FLatestSaveIncludedForex = true;
                        break;
                    }
                }
            }

            // Now do the standard call to save the changes
            return(TRemote.MFinance.Gift.WebConnectors.SaveGiftBatchTDS(ref SubmitDS, out VerificationResult));
        }
Exemplo n.º 3
0
        //
        // Put Methods for the validation of Common Module WebConnectors and DataReaders in this code file.
        //

        static partial void ValidateInternationalPostalTypeManual(ref TVerificationResultCollection AVerificationResult,
                                                                  TTypedDataTable ASubmitTable)
        {
            TValidationControlsDict ValidationControlsDict = new TValidationControlsDict();

            ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnInternatPostalTypeCodeId],
                                       new TValidationControlsData(null, PInternationalPostalTypeTable.GetInternatPostalTypeCodeDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnDescriptionId],
                                       new TValidationControlsData(null, PInternationalPostalTypeTable.GetDescriptionDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[(short)PInternationalPostalTypeTable.ColumnDeletableId],
                                       new TValidationControlsData(null, PInternationalPostalTypeTable.GetDeletableDBName()));

            for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++)
            {
                PInternationalPostalTypeValidation.Validate("TCommonDataReader.ValidateInternationalPostalTypeManual" +
                                                            " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English
                                                            (PInternationalPostalTypeRow)ASubmitTable.Rows[Counter], ref AVerificationResult,
                                                            ValidationControlsDict);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Checks that a <see cref="TVerificationResultCollection" /> is either null or that it doesn't contain
        /// any <see cref="TVerificationResult" /> items that are CriticalErrors. If it isn't null and it contains such items, an Assert.Fail
        /// call is issued by this Method!
        /// </summary>
        /// <remarks>
        /// Can be used for 'Guard Asserts' to check that the <see cref="TVerificationResultCollection" />
        /// that is returned from server calls is null or holds only non-critical <see cref="TVerificationResult" /> items.
        /// </remarks>
        /// <param name="AVerificationResult"><see cref="TVerificationResultCollection" /> reference (can be null!).</param>
        /// <param name="AMessage">String to append before the Assert message that this Method produces (optional).</param>
        public static void EnsureNullOrOnlyNonCriticalVerificationResults(TVerificationResultCollection AVerificationResult, string AMessage = "")
        {
            string VerificationResultStr;

            if ((AMessage != String.Empty) &&
                (!AMessage.EndsWith(" ")))
            {
                AMessage = AMessage + " ";
            }

            if (!TVerificationHelper.IsNullOrOnlyNonCritical(AVerificationResult))
            {
                VerificationResultStr = AVerificationResult.BuildVerificationResultString();

                TLogging.Log(VerificationResultStr);

                Assert.Fail(AMessage + "*** TVerificationResult HAS CRITICAL ERRORS *** : " +
                            VerificationResultStr);
            }
        }
Exemplo n.º 5
0
        private Boolean CloseSaveAndPost_(TVerificationResultCollection AVerifications)
        {
            if (FJournalCount != 0)
            {
                // The checksum of the "last journal" is used to update the checksum of the batch.
                FBatchRow.BatchControlTotal += FJournalRow.JournalDebitTotal - FJournalRow.JournalCreditTotal;
            }

            FBatchTDS.ThrowAwayAfterSubmitChanges = true;
            GLBatchTDSAccess.SubmitChanges(FBatchTDS);

            Boolean PostedOk = TGLPosting.PostGLBatch(
                FLedgerInfo.LedgerNumber, FBatchNumber, out AVerifications);

            // Make sure that this object cannot be used for another posting ...
            FBatchTDS   = null;
            FBatchRow   = null;
            FJournalRow = null;
            return(PostedOk);
        }
        private void ValidateDataDetailsManual(AGiftBatchRow ARow)
        {
            if ((ARow == null) || (ARow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                return;
            }

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            //Hash total special case in view of the textbox handling
            ParseHashTotal(ARow);

            //Check if the user has made a Bank Cost Centre or Account Code inactive
            //this was removed because of speed issues!
            //TODO: Revisit this
            //RefreshBankCostCentreAndAccountCodes();

            TSharedFinanceValidation_Gift.ValidateGiftBatchManual(this, ARow, ref VerificationResultCollection,
                                                                  FValidationControlsDict, FAccountTable, FCostCentreTable);
        }
Exemplo n.º 7
0
        //
        // Put Methods for the validation of Cacheable DataTables in this code file.
        //

        partial void ValidateCountryListManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable)
        {
            TValidationControlsDict ValidationControlsDict = new TValidationControlsDict();

            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatTelephoneCodeId],
                                       new TValidationControlsData(null, PCountryTable.GetInternatTelephoneCodeDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnInternatPostalTypeCodeId],
                                       new TValidationControlsData(null, PCountryTable.GetInternatAccessCodeDBName()));
            ValidationControlsDict.Add(ASubmitTable.Columns[PCountryTable.ColumnTimeZoneMinimumId],
                                       new TValidationControlsData(null, PCountryTable.GetTimeZoneMinimumDBName(),
                                                                   null, PCountryTable.GetTimeZoneMaximumDBName()));

            for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++)
            {
                TSharedValidation_CacheableDataTables.ValidateCountrySetupManual(this.GetType().Name +
                                                                                 " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English
                                                                                 (PCountryRow)ASubmitTable.Rows[Counter], ref AVerificationResult,
                                                                                 ValidationControlsDict);
            }
        }
        private TSubmitChangesResult StoreManualCode(ref CorporateExchangeSetupTDS ASubmitChanges,
                                                     out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = null;
            int TransactionsChanged;

            TSubmitChangesResult Result = TRemote.MFinance.Setup.WebConnectors.SaveCorporateExchangeSetupTDS(
                ref ASubmitChanges, out TransactionsChanged, out AVerificationResult);

            if ((Result == TSubmitChangesResult.scrOK) && (TransactionsChanged > 0) && (FPetraUtilsObject.GetCallerForm() != null))
            {
                MessageBox.Show(string.Format(Catalog.GetPluralString(
                                                  "{0} GL Transaction was automatically updated with the new corporate exchange rate.",
                                                  "{0} GL Transactions were automatically updated with the new corporate exchange rate.",
                                                  TransactionsChanged, true), TransactionsChanged),
                                Catalog.GetString("Save Corporate Exchange Rates"), MessageBoxButtons.OK);
            }

            return(Result);
        }
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="AInspectDT"></param>
        public void SubmitChangesAsync(PSubscriptionTable AInspectDT)
        {
            Thread TheThread;

            // Cleanup (might be left in a certain state from a possible earlier call)
            FSubmitException    = null;
            FSubmissionDT       = null;
            FVerificationResult = null;
            FResponseDT         = null;
            FInspectDT          = null;
            FProgressID         = Guid.NewGuid().ToString();
            TProgressTracker.InitProgressTracker(FProgressID, string.Empty, 100.0m);
            FInspectDT = AInspectDT;
            ThreadStart ThreadStartDelegate = new ThreadStart(SubmitChangesInternal);

            TheThread      = new Thread(ThreadStartDelegate);
            TheThread.Name = "ExtractsAddSubscriptionsSubmitChanges" + Guid.NewGuid().ToString();
            TheThread.Start();
            TLogging.LogAtLevel(6, "TExtractsAddSubscriptionsUIConnector.SubmitChangesAsync thread started.");
        }
Exemplo n.º 10
0
        private TSubmitChangesResult StoreManualCode(ref MaintainUsersTDS ASubmitDS, out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = null;

            TSubmitChangesResult Result = TRemote.MSysMan.Maintenance.WebConnectors.SaveSUser(ref ASubmitDS);

            if (Result == TSubmitChangesResult.scrOK)
            {
                MessageBox.Show(Catalog.GetString("Changes to users will take effect at next login."),
                                Catalog.GetString("Maintain Users"));

                // Reload the grid after every successful save. (This will add new password's hash and salt to the table.)
                LoadUsers();

                btnChangePassword.Enabled     = true;
                txtDetailPasswordHash.Enabled = false;
            }

            return(Result);
        }
Exemplo n.º 11
0
        public void TestImportCSV()
        {
            TVerificationResultCollection VerificationResult = null;
            string doc = String.Empty;

            using (StreamReader sr = new StreamReader("../../demodata/partners/samplePartnerImport.csv"))
            {
                doc = sr.ReadToEnd();
            }

            PartnerImportExportTDS MainDS = TImportExportWebConnector.ImportFromCSVFileReturnDataSet(doc, "DMY", ";", out VerificationResult);

            if (VerificationResult != null)
            {
                Assert.IsFalse(VerificationResult.HasCriticalErrors, "there was an error importing the csv file");
            }

            // there should be 2 partners imported
            Assert.AreEqual(2, MainDS.PPartner.Rows.Count);
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AContext"></param>
        /// <param name="ARow"></param>
        /// <param name="AVerificationResultCollection"></param>
        /// <param name="AValidationControlsDict"></param>
        public static void ValidateAccountingPeriod(object AContext, AAccountingPeriodRow ARow,
                                                    ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            DataColumn ValidationColumn;
            TValidationControlsData ValidationControlsData;
            TVerificationResult     VerificationResult;

            // 'Period End Date' must be later than 'Period Start Date'
            ValidationColumn = ARow.Table.Columns[AAccountingPeriodTable.ColumnPeriodEndDateId];

            if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
            {
                VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.PeriodEndDate, ARow.PeriodStartDate,
                                                                                   ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel,
                                                                                   AContext, ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="AInspectDT"></param>
        public void SubmitChangesAsync(PSubscriptionTable AInspectDT)
        {
            Thread TheThread;

            // Cleanup (might be left in a certain state from a possible earlier call)
            FSubmitException        = null;
            FSubmissionDT           = null;
            FAsyncExecProgress      = null;
            FVerificationResult     = null;
            FResponseDT             = null;
            FInspectDT              = null;
            this.FAsyncExecProgress = new TAsynchronousExecutionProgress();
            this.FAsyncExecProgress.ProgressState = TAsyncExecProgressState.Aeps_ReadyToStart;
            FInspectDT = AInspectDT;
            ThreadStart ThreadStartDelegate = new ThreadStart(SubmitChangesInternal);

            TheThread = new Thread(ThreadStartDelegate);
            TheThread.Start();
            TLogging.LogAtLevel(6, "TExtractsAddSubscriptionsUIConnector.SubmitChangesAsync thread started.");
        }
Exemplo n.º 14
0
        public static bool SetDefaultMotivationDetail(Int32 ALedgerNumber,
                                                      String AMotivationGroupCode, String AMotivationDetailCode,
                                                      out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = new TVerificationResultCollection();
            GiftBatchTDS MainDS = new GiftBatchTDS();

            TDBTransaction Transaction = new TDBTransaction();
            TDataBase      db          = DBAccess.Connect("SetDefaultMotivationDetail");

            if (!(AMotivationGroupCode == String.Empty && AMotivationDetailCode == String.Empty))
            {
                bool validDetail = true;

                db.ReadTransaction(
                    ref Transaction,
                    delegate
                {
                    // is this a valid motivation group and detail combination?
                    AMotivationDetailAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, AMotivationGroupCode, AMotivationDetailCode, Transaction);

                    if (MainDS.AMotivationDetail.Rows.Count == 0)
                    {
                        validDetail = false;
                    }
                    else if (MainDS.AMotivationDetail[0].MotivationStatus == false)
                    {
                        validDetail = false;
                    }
                });

                if (!validDetail)
                {
                    AVerificationResult.Add(new TVerificationResult("error", "invalid or inactive motivation detail", TResultSeverity.Resv_Critical));
                    return(false);
                }
            }

            // Store System Default for this ledger
            return(new TSystemDefaults().SetSystemDefault("DEFAULTMOTIVATION" + ALedgerNumber.ToString(), AMotivationGroupCode + "::" + AMotivationDetailCode));
        }
Exemplo n.º 15
0
        /// <summary>
        /// import the data of a CSV file
        /// </summary>
        /// <param name="ALedgerNumber">the current ledger number</param>
        /// <param name="ABankAccountCode">the bank account against which the statement should be stored</param>
        /// <param name="ABankStatementFilename"></param>
        /// <param name="ACSVContent"></param>
        /// <param name="ASeparator"></param>
        /// <param name="ADateFormat">DMY or MDY</param>
        /// <param name="ANumberFormat">European or American</param>
        /// <param name="ACurrencyCode">eg. EUR</param>
        /// <param name="AColumnMeaning"></param>
        /// <param name="AStartAfterLine">can be empty, otherwise only the lines after the line matching AStartAfterLine will be parsed</param>
        /// <param name="AStatementKey">this returns the first key of a statement that was imported. depending on the implementation, several statements can be created from one file</param>
        /// <param name="AVerificationResult"></param>
        public static bool ImportBankStatement(
            Int32 ALedgerNumber,
            string ABankAccountCode,
            string ABankStatementFilename,
            string ACSVContent,
            string ASeparator,
            string ADateFormat,
            string ANumberFormat,
            string ACurrencyCode,
            string AColumnMeaning,
            string AStartAfterLine,
            out Int32 AStatementKey,
            out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = new TVerificationResultCollection();

            BankImportTDS MainDS = ImportBankStatementHelper(
                ALedgerNumber,
                ABankAccountCode,
                ASeparator,
                ADateFormat,
                ANumberFormat,
                ACurrencyCode,
                AColumnMeaning,
                AStartAfterLine,
                ABankStatementFilename,
                ACSVContent);

            if (MainDS != null)
            {
                if (TBankStatementImport.StoreNewBankStatement(
                        MainDS,
                        out AStatementKey) == TSubmitChangesResult.scrOK)
                {
                    return(AStatementKey != -1);
                }
            }

            AStatementKey = -1;
            return(false);
        }
Exemplo n.º 16
0
        private void RunTestImport(string AFileName,
                                   string ACSVSeparator,
                                   TVerificationResultCollection AResults,
                                   out string AResultText,
                                   out string AFirstResultCode,
                                   out Boolean AGotDateWarning)
        {
            string TestFile = Path.GetFullPath(TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/ExchangeRates/" + AFileName);

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

            AResults.Clear();
            TImportExchangeRates.ImportCurrencyExRates(FMainDS.ACorporateExchangeRate, TestFile, ACSVSeparator, "Corporate", AResults);

            AResultText     = String.Empty;
            AGotDateWarning = false;

            for (int i = 0; i < AResults.Count; i++)
            {
                if (AResults[i].ResultText.Contains("Warning:") && AResults[i].ResultText.Contains("before the current accounting period"))
                {
                    AGotDateWarning = true;
                }
                else
                {
                    AResultText += String.Format("{0}: {1}{2}", i.ToString(), AResults[i].ResultText, Environment.NewLine);
                }
            }

            if (AResultText.Length > 0)
            {
                Console.WriteLine(AResultText);
            }

            AFirstResultCode = String.Empty;

            if (AResults.Count > 0)
            {
                AFirstResultCode = AResults[0].ResultCode;
            }
        }
Exemplo n.º 17
0
        public static bool ReplaceHeaderInFile(string AFileName, string AHeaderText, ref TVerificationResultCollection AVerificationResult)
        {
            bool retVal = true;

            try
            {
                StringBuilder newFileContents = new StringBuilder();

                string[] file = File.ReadAllLines(AFileName);

                bool IsFirstLine = true;

                foreach (string line in file)
                {
                    //If first line
                    if (IsFirstLine)
                    {
                        newFileContents.Append(AHeaderText + "\r\n");
                        IsFirstLine = false;
                    }
                    else
                    {
                        newFileContents.Append(line + "\r\n");
                    }
                }

                File.WriteAllText(AFileName, newFileContents.ToString());
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
                retVal = false;
                AVerificationResult.Add(new TVerificationResult("Generating HOSA Files",
                                                                "Unable to replace the header in file: " + AFileName,
                                                                "Replacing Header in Text File",
                                                                TResultSeverity.Resv_Critical, new Guid()));
                throw new Exception("Error in generating HOSA Files. Unable to replace the header in file: " + AFileName);
            }

            return(retVal);
        }
Exemplo n.º 18
0
        public void Test_TAccountPeriodToNewYear()
        {
            // create new ledger which is in year 2010
            int intLedgerNumber2010 = CommonNUnitFunctions.CreateNewLedger(new DateTime(2010, 1, 1));

            TDBTransaction transaction  = null;
            bool           SubmissionOK = false;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(
                IsolationLevel.Serializable,
                TEnforceIsolationLevel.eilMinimum,
                ref transaction,
                ref SubmissionOK,
                delegate
            {
                // We are in 2010 and this and 2011 is not a leap year
                TVerificationResultCollection verificationResult = new TVerificationResultCollection();
                TAccountPeriodToNewYear accountPeriodToNewYear   = new TAccountPeriodToNewYear(intLedgerNumber2010, transaction);

                accountPeriodToNewYear.VerificationResultCollection = verificationResult;
                accountPeriodToNewYear.IsInInfoMode = false;

                // RunEndOfPeriodOperation ...
                accountPeriodToNewYear.RunOperation();

                TAccountPeriodInfo accountPeriodInfo     = new TAccountPeriodInfo(intLedgerNumber2010);
                accountPeriodInfo.AccountingPeriodNumber = 2;
                Assert.AreEqual(2011, accountPeriodInfo.PeriodStartDate.Year, "Test of the year");
                Assert.AreEqual(28, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 28th");

                // Switch to 2012 - this is a leap year ...
                accountPeriodToNewYear = new TAccountPeriodToNewYear(intLedgerNumber2010, transaction);
                accountPeriodToNewYear.IsInInfoMode = false;
                accountPeriodToNewYear.RunOperation();
                SubmissionOK = true;

                accountPeriodInfo = new TAccountPeriodInfo(intLedgerNumber2010);
                accountPeriodInfo.AccountingPeriodNumber = 2;
                Assert.AreEqual(29, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 29th");
            });
        }
Exemplo n.º 19
0
        partial void ValidateFeesReceivableListManual(ref TVerificationResultCollection AVerificationResult, TTypedDataTable ASubmitTable)
        {
            Type DataTableType;
            AFeesPayableTable otherTable = (AFeesPayableTable)TCacheableTablesManager.GCacheableTablesManager.GetCachedDataTable("FeesPayableList",
                                                                                                                                 out DataTableType);

            otherTable.DefaultView.Sort = String.Format("{0}, {1} ASC", AFeesPayableTable.GetLedgerNumberDBName(), AFeesPayableTable.GetFeeCodeDBName());

            for (int i = 0; i < ASubmitTable.Rows.Count; i++)
            {
                DataRow row = ASubmitTable.Rows[i];

                if ((row.RowState == DataRowState.Added) || (row.RowState == DataRowState.Modified))
                {
                    string feeCode      = row[AFeesReceivableTable.ColumnFeeCodeId].ToString();
                    int    ledgerNumber = Convert.ToInt32(row[AFeesReceivableTable.ColumnLedgerNumberId]);

                    int otherRowNum = otherTable.DefaultView.Find(new object[] { ledgerNumber, feeCode });

                    if (otherRowNum >= 0)
                    {
                        AFeesPayableRow otherRow  = (AFeesPayableRow)(otherTable.DefaultView[otherRowNum].Row);
                        string          otherUser = otherRow.CreatedBy;

                        if (!String.IsNullOrEmpty(otherRow.ModifiedBy))
                        {
                            otherUser = otherRow.ModifiedBy;
                        }

                        // The message text doesn't get back to the user - but maybe one day it will
                        throw new EDBConcurrencyException(String.Format(Catalog.GetString(
                                                                            "While you were editing this screen another user created a fee code '{0}' for the Grants Payable screen.  You will have to close and re-open the Grants Receivable screen and make your changes again."),
                                                                        feeCode),
                                                          "write",
                                                          otherTable.TableName,
                                                          otherUser,
                                                          otherRow.ModificationId);
                    }
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// This over-ride should be used for testing purposes.  It reads from the specified test file and always uses US numbers and date/time.
        /// You supply the separator character as a single character string
        /// </summary>
        /// <param name="AExchangeRateDT">The corporate or daily exchange rate table</param>
        /// <param name="AImportFileName">The test file to import</param>
        /// <param name="ACSVSeparator">The separator that the file uses</param>
        /// <param name="AImportMode">Determines whether corporate or daily exchange rates specified - either 'Daily' or 'Corporate'</param>
        /// <param name="AResultCollection">A validation collection to which errors will be added</param>
        /// <returns>The number of rows that were actually imported.  Rows that duplicate existing rows do not count.
        /// This is usually because this is an attempt to import again after a failed previous attempt.</returns>
        public static int ImportCurrencyExRates(TTypedDataTable AExchangeRateDT,
            string AImportFileName,
            string ACSVSeparator,
            string AImportMode,
            TVerificationResultCollection AResultCollection)
        {
            // Test import always uses standard file with US formats
            TDlgSelectCSVSeparator separatorDialog = new TDlgSelectCSVSeparator(false);

            separatorDialog.OpenCsvFile(AImportFileName);

            return ImportCurrencyExRatesFromCSV(AExchangeRateDT,
                separatorDialog.FileContent,
                ACSVSeparator,
                TDlgSelectCSVSeparator.NUMBERFORMAT_AMERICAN,
                "MM/dd/yyyy",
                false,
                AImportMode,
                AResultCollection,
                Path.GetFileNameWithoutExtension(AImportFileName));
        }
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("NumberFormat", "American");
            parameters.Add("NewLine", Environment.NewLine);

            GiftBatchTDSAGiftDetailTable NeedRecipientLedgerNumber;

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

            int BatchNumber = importer.GetLastGiftBatchNumber();

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

                return(false);
            }

            return(true);
        }
        public void TestBuildVerificationResultString()
        {
            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_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);

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

            string expectedString =
                Environment.NewLine + "    Problem: test0" + Environment.NewLine + "    (Non-critical)" + Environment.NewLine + Environment.NewLine +
                Environment.NewLine + "    Status: test1" + Environment.NewLine + Environment.NewLine + Environment.NewLine +
                Environment.NewLine + "    Problem: test4" + Environment.NewLine + "    (Non-critical)" + Environment.NewLine + Environment.NewLine +
                Environment.NewLine + "    Status: test5" + Environment.NewLine + Environment.NewLine + Environment.NewLine +
                Environment.NewLine + "    Problem: test6" + Environment.NewLine + "    (Non-critical)" + Environment.NewLine + Environment.NewLine +
                Environment.NewLine + "    Problem: test7" + Environment.NewLine + "    (Non-critical)" + Environment.NewLine + Environment.NewLine;

            Assert.AreEqual(expectedString, coll.BuildVerificationResultString(), "comparing the string");
        }
Exemplo n.º 23
0
        private void ValidateDataDetailsManual(AGiftBatchRow ARow)
        {
            if ((ARow == null) || (ARow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED))
            {
                return;
            }

            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;

            //Hash total special case in view of the textbox handling
            ParseHashTotal(ARow);

            //Check if the user has made a Bank Cost Centre or Account Code inactive
            //this was removed because of speed issues!
            //TODO: Revisit this
            //RefreshBankCostCentreAndAccountCodes();

            TSharedFinanceValidation_Gift.ValidateGiftBatchManual(this, ARow, ref VerificationResultCollection,
                                                                  FValidationControlsDict, FAccountTable, FCostCentreTable);

            //TODO: remove this once database definition is set for Batch Description to be NOT NULL
            // Description is mandatory then make sure it is set
            if (txtDetailBatchDescription.Text.Length == 0)
            {
                DataColumn          ValidationColumn;
                TVerificationResult VerificationResult = null;
                object ValidationContext;

                ValidationColumn  = ARow.Table.Columns[AGiftBatchTable.ColumnBatchDescriptionId];
                ValidationContext = String.Format("Batch number {0}",
                                                  ARow.BatchNumber);

                VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.BatchDescription,
                                                                        "Description of " + ValidationContext,
                                                                        this, ValidationColumn, null);

                // Handle addition/removal to/from TVerificationResultCollection
                VerificationResultCollection.Auto_Add_Or_AddOrRemove(this, VerificationResult, ValidationColumn, true);
            }
        }
Exemplo n.º 24
0
        public void TestPostGLBatchArgumentValidation()
        {
            TVerificationResultCollection VerificationResult = null;

            string Message = "Validation failed for posting a GL Batch with ledger number less than 1.";

            // Post a GL Batch with ledger number less than 1
            try
            {
                TGLPosting.PostGLBatch(-1, 1, out VerificationResult);

                if ((VerificationResult.CountCriticalErrors != 1) ||
                    (!VerificationResult.BuildVerificationResultString().Contains("The Ledger number must be greater than 0")))
                {
                    Assert.Fail(Message);
                }
            }
            catch
            {
                Assert.Fail(Message);
            }

            Message = "Validation failed for posting a GL Batch with batch number less than 1.";

            // Post a GL Batch with batch number less than 1
            try
            {
                TGLPosting.PostGLBatch(1, -1, out VerificationResult);

                if ((VerificationResult.CountCriticalErrors != 1) ||
                    (!VerificationResult.BuildVerificationResultString().Contains("The Batch number must be greater than 0")))
                {
                    Assert.Fail(Message);
                }
            }
            catch
            {
                Assert.Fail(Message);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Check that Foreign Currency Accounts are using a valid currency
        /// </summary>
        /// <param name="AContext">Context that describes what I'm validating.</param>
        /// <param name="ARow">DataRow with the the data I'm validating</param>
        /// <param name="AVerificationResultCollection">Will be filled with TVerificationResult items if data validation errors occur.</param>
        /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        public static void ValidateAccountDetailManual(object AContext, GLSetupTDSAAccountRow ARow,
                                                       ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            TValidationControlsData ValidationControlsData;

            // If this account is foreign, its currency must be assigned!
            if (ARow.ForeignCurrencyFlag)
            {
                if (ARow.ForeignCurrencyCode == "")
                {
                    DataColumn ValidationColumn = ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId];

                    Control targetControl = null;

                    if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData))
                    {
                        targetControl = ValidationControlsData.ValidationControl;
                    }

                    TScreenVerificationResult VerificationResult = new TScreenVerificationResult(
                        AContext,
                        ValidationColumn,
                        Catalog.GetString("Currency Code must be specified for foreign accounts."),
                        targetControl,
                        TResultSeverity.Resv_Critical);
                    // Handle addition/removal to/from TVerificationResultCollection
                    AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
                }
            }
            else // If the Account is not foreign, I have nothing at all to say about the contents of the currency field.
            {
                AVerificationResultCollection.AddOrRemove(null, ARow.Table.Columns[AAccountTable.ColumnForeignCurrencyCodeId]);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Validates SUser Details
        /// </summary>
        /// <param name="AContext">Context that describes where the data validation failed.</param>
        /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param>
        /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if
        /// data validation errors occur.</param>
        /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that
        /// display data that is about to be validated.</param>
        public static void ValidateSUserDetails(object AContext, SUserRow ARow,
                                                ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict)
        {
            DataColumn ValidationColumn;
            TValidationControlsData ValidationControlsData;
            TVerificationResult     VerificationResult = null;

            // Don't validate deleted DataRows
            if (ARow.RowState == DataRowState.Deleted)
            {
                return;
            }

            ValidationColumn = ARow.Table.Columns[SUserTable.ColumnPasswordHashId];
            AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData);

            // PasswordHash must not be empty.
            if ((ARow.RowState != DataRowState.Unchanged) && string.IsNullOrEmpty(ARow.PasswordHash))
            {
                VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext,
                                                                                           ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_MISSING_PASSWORD, new string[] { ARow.UserId })),
                                                                   ValidationColumn, ValidationControlsData.ValidationControl);

                // Handle addition to/removal from TVerificationResultCollection
                AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
            }

            // If this is a first password (no salt) check that the password is valid.
            if ((ARow.RowState != DataRowState.Unchanged) && string.IsNullOrEmpty(ARow.PasswordSalt) && !string.IsNullOrEmpty(ARow.PasswordHash))
            {
                VerificationResult = null;

                if (!CheckPasswordQuality(ARow.PasswordHash, out VerificationResult))
                {
                    VerificationResult = new TScreenVerificationResult(VerificationResult, ValidationColumn, ValidationControlsData.ValidationControl);
                    AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn);
                }
            }
        }
Exemplo n.º 27
0
        public static int ExportBudgets(Int32 ALedgerNumber,
                                        string ACSVFileName,
                                        string[] AFdlgSeparator,
                                        ref string AFileContents,
                                        ref BudgetTDS AExportDS,
                                        out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = null;

            if (AExportDS != null)
            {
                int retVal = ExportBudgetToCSV(ALedgerNumber,
                                               ACSVFileName,
                                               AFdlgSeparator,
                                               ref AFileContents,
                                               ref AExportDS,
                                               ref AVerificationResult);
                return(retVal);
            }

            return(0);
        }
Exemplo n.º 28
0
        public static decimal ImportBudgets(Int32 ALedgerNumber,
                                            Int32 ACurrentBudgetYear,
                                            string ACSVFileName,
                                            string[] AFdlgSeparator,
                                            ref BudgetTDS AImportDS,
                                            out TVerificationResultCollection AVerificationResult)
        {
            AVerificationResult = null;

            if (AImportDS != null)
            {
                decimal retVal = ImportBudgetFromCSV(ALedgerNumber,
                                                     ACurrentBudgetYear,
                                                     ACSVFileName,
                                                     AFdlgSeparator,
                                                     ref AImportDS,
                                                     ref AVerificationResult);
                return(retVal);
            }

            return(0);
        }
Exemplo n.º 29
0
        static partial void ValidateGiftDetailManual(ref TVerificationResultCollection AVerificationResult,
                                                     TTypedDataTable ASubmitTable)
        {
            TPartnerClass RecipientPartnerClass;
            string        RecipientDescription;

            for (int Counter = 0; Counter < ASubmitTable.Rows.Count; Counter++)
            {
                if (ASubmitTable.Rows[Counter].RowState != DataRowState.Deleted)
                {
                    TPartnerServerLookups.GetPartnerShortName(((GiftBatchTDSAGiftDetailRow)ASubmitTable.Rows[Counter]).RecipientKey,
                                                              out RecipientDescription,
                                                              out RecipientPartnerClass);
                    GiftBatchTDSAGiftDetailRow Row = (GiftBatchTDSAGiftDetailRow)ASubmitTable.Rows[Counter];
                    Row.RecipientClass = RecipientPartnerClass.ToString();

                    TSharedFinanceValidation_Gift.ValidateGiftDetailManual("TTransactionWebConnector" +
                                                                           " (Error in Row #" + Counter.ToString() + ")", // No translation of message text since the server's messages should be all in English
                                                                           Row, ref AVerificationResult);
                }
            }
        }
Exemplo n.º 30
0
        public void TestImportCSV2()
        {
            XmlDocument doc = TCsv2Xml.ParseCSVFile2Xml("../../demodata/partners/samplefilepartnerimport2.csv", ",");
            TVerificationResultCollection VerificationResult = null;

            Console.WriteLine(TXMLParser.XmlToString(doc));
            PartnerImportExportTDS MainDS = TImportExportWebConnector.ImportFromCSVFile(TXMLParser.XmlToString(doc), "dMy", out VerificationResult);

            if (VerificationResult != null)
            {
                Assert.IsFalse(VerificationResult.HasCriticalErrors, "there was an error importing the csv file");
            }

            foreach (PFamilyRow f in MainDS.PFamily.Rows)
            {
                Console.WriteLine("Family name : " + f.FamilyName);
            }

            // we are currently ignoring UNIT and ORGANISATION partners, only importing the 7 FAMILY partners.
            // due to the strange format of the file, each row is imported as a separate partner, ending up with 27 invalid partners
            Assert.AreEqual(7, MainDS.PPartner.Rows.Count);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Initializes a new instance of this Exception Class with serialized data. Needed for Remoting and general serialization.
 /// </summary>
 /// <remarks>
 /// Only to be used by the .NET Serialization system (eg within .NET Remoting).
 /// </remarks>
 /// <param name="AInfo">The <see cref="SerializationInfo" /> that holds the serialized object data about the <see cref="Exception" /> being thrown.</param>
 /// <param name="AContext">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
 public EVerificationResultsException(SerializationInfo AInfo, StreamingContext AContext) : base(AInfo, AContext)
 {
     FVerificationResults = (TVerificationResultCollection)AInfo.GetValue("VerificationResults", typeof(TVerificationResultCollection));
 }
Exemplo n.º 32
0
 /// <summary>
 /// Initializes a new instance of this Exception Class with a specified error message, access richt and Database Table.
 /// </summary>
 /// <param name="AMessage">The error message that explains the reason for the <see cref="Exception" />.</param>
 /// <param name="AVerificationResults"><see cref ="TVerificationResultCollection" /> that holds one or more severe TVerificationResult item(s).</param>
 public EVerificationResultsException(String AMessage, TVerificationResultCollection AVerificationResults) : base(AMessage)
 {
     FVerificationResults = AVerificationResults;
 }