Esempio n. 1
0
 private async void ThrowExceptionAsync()
 {
     ThrowExceptions.Custom(Exc.GetStackTrace(), type, Exc.CallingMethod(), "");
 }
Esempio n. 2
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4048Abs_long .cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        long          longVal;
        long          longKnown;

        do
        {
            try
            {
                ++iCountTestcases;
                longVal   = -((long)9223372036854775807L);
                longKnown = 9223372036854775807L;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_b9wu, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
                ++iCountTestcases;
                longVal   = -(0);
                longKnown = 0;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_pf71, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
                ++iCountTestcases;
                longVal   = -(1);
                longKnown = 1;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_6mz2, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
                ++iCountTestcases;
                longVal   = ((long)9223372036854775807L);
                longKnown = 9223372036854775807L;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_ss81, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
                ++iCountTestcases;
                longVal   = (0);
                longKnown = 0;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_4f9v, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
                ++iCountTestcases;
                longVal   = (1);
                longKnown = 1;
                if (Math.Abs(longVal) != longKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_bbq11, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected longKnown == " + longKnown);
                    sblMsg.Append(" intead got Math.Abs( longVal ) == " + Math.Abs(longVal));
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4048Abs_long .cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4048Abs_long .cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4048Abs_long .cs   FAiL !");
            return(false);
        }
    }
        public static void ConsolidateBudgets(Int32 ALedgerNumber, bool AConsolidateAll)
        {
            bool           NewTransaction           = false;
            TDBTransaction SubmitChangesTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable,
                                                                                                        out NewTransaction);

            ALedgerRow LedgerRow = FBudgetTDS.ALedger[0];

            try
            {
                // first clear the old budget from GLMPeriods
                if (AConsolidateAll)
                {
                    foreach (ABudgetRow BudgetRow in FBudgetTDS.ABudget.Rows)
                    {
                        BudgetRow.BudgetStatus = false;
                    }

                    foreach (AGeneralLedgerMasterRow GeneralLedgerMasterRow in GLPostingDS.AGeneralLedgerMaster.Rows)
                    {
                        for (int Period = 1; Period <= LedgerRow.NumberOfAccountingPeriods; Period++)
                        {
                            ClearAllBudgetValues(GeneralLedgerMasterRow.GlmSequence, Period);
                        }
                    }
                }
                else
                {
                    foreach (ABudgetRow BudgetRow in FBudgetTDS.ABudget.Rows)
                    {
                        if (!BudgetRow.BudgetStatus)
                        {
                            UnPostBudget(BudgetRow, ALedgerNumber);
                        }
                    }
                }

                foreach (ABudgetRow BudgetRow in FBudgetTDS.ABudget.Rows)
                {
                    if (!BudgetRow.BudgetStatus || AConsolidateAll)
                    {
                        List <ABudgetPeriodRow> budgetPeriods = new List <ABudgetPeriodRow>();

                        FBudgetTDS.ABudgetPeriod.DefaultView.RowFilter = ABudgetPeriodTable.GetBudgetSequenceDBName() + " = " +
                                                                         BudgetRow.BudgetSequence.ToString();

                        foreach (DataRowView rv in FBudgetTDS.ABudgetPeriod.DefaultView)
                        {
                            budgetPeriods.Add((ABudgetPeriodRow)rv.Row);
                        }

                        PostBudget(ALedgerNumber, BudgetRow, budgetPeriods);
                    }
                }

                FinishConsolidateBudget(SubmitChangesTransaction);


                GLPostingDS.ThrowAwayAfterSubmitChanges = true;
                GLPostingTDSAccess.SubmitChanges(GLPostingDS);
                GLPostingDS.Clear();

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured during the consolidation of Budgets:" + Environment.NewLine + Exc.ToString());

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

                throw;
            }
        }
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4077Sin.cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        double        dubExpected     = 0;
        double        dubEquation     = 0;
        double        dubOne          = 0;
        double        dubTwo          = 0;

        do
        {
            try
            {
                dubExpected = 0.5;
                dubOne      = (dubExpected - 0.1);
                dubTwo      = (dubExpected + 0.1);
                dubEquation = Math.Sin(Math.PI / 6);
                ++iCountTestcases;
                if ((dubOne <= dubEquation && dubEquation <= dubTwo) == false)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_s90h, Sin not equal to expected value");
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                dubExpected = 1.0;
                dubOne      = (dubExpected - 0.1);
                dubTwo      = (dubExpected + 0.1);
                dubEquation = Math.Sin(Math.PI / 2);
                ++iCountTestcases;
                if ((dubOne <= dubEquation && dubEquation <= dubTwo) == false)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_f32f, Sin not equal to expected value");
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                dubExpected = 0.0;
                dubOne      = (dubExpected - 0.01);
                dubTwo      = (dubExpected + 0.01);
                dubEquation = Math.Sin(0);
                ++iCountTestcases;
                if ((dubOne <= dubEquation && dubEquation <= dubTwo) == false)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_c93h, Sin not equal to expected value");
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                dubExpected = 0.7;
                dubOne      = (dubExpected - 0.1);
                dubTwo      = (dubExpected + 0.1);
                dubEquation = Math.Sin(Math.PI / 4);
                ++iCountTestcases;
                if ((dubOne <= dubEquation && dubEquation <= dubTwo) == false)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_c93h, Sin not equal to expected value");
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                dubExpected = 0.86;
                dubOne      = (dubExpected - 0.1);
                dubTwo      = (dubExpected + 0.1);
                dubEquation = Math.Sin(Math.PI / 3);
                ++iCountTestcases;
                if ((dubOne <= dubEquation && dubEquation <= dubTwo) == false)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_c93h, Sin not equal to expected value");
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4077Sin.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4077Sin.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4077Sin.cs   FAiL !");
            return(false);
        }
    }
Esempio n. 5
0
        private void BtnCancelClick(object sender, EventArgs e)
        {
            DialogResult CancelConfirmationResult = DialogResult.Yes;

            if (FShowCancellationConfirmationQuestion)
            {
                CancelConfirmationResult =
                    MessageBox.Show(Catalog.GetString("Do you really want to cancel?\r\n\r\nNote: Execution is continuing until 'Yes' is chosen!"),
                                    Catalog.GetString("Confirm Cancellation"),
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2);
            }

            if (CancelConfirmationResult == DialogResult.Yes)
            {
                if (FQueryServerForProgress)
                {
                    try
                    {
                        TRemote.MCommon.WebConnectors.CancelJob();
                    }
                    catch (Exception Exc)
                    {
                        TLogging.Log("While cancelling a job from a Progress Dialog we got the following Exception:\r\n" + Exc.ToString());
                    }
                }

                FCancelled = true;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// The AccountingPeriod Rows are updated ...
        /// </summary>
        override public Int32 RunOperation()
        {
            bool NewTransaction;
            Int32 JobSize = 0;

            Boolean ShouldCommit = false;
            TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction);
            AAccountingPeriodTable AccountingPeriodTbl = null;

            try
            {
                AccountingPeriodTbl = AAccountingPeriodAccess.LoadViaALedger(FLedgerNumber, Transaction);

                foreach (AAccountingPeriodRow accountingPeriodRow in AccountingPeriodTbl.Rows)
                {
                    accountingPeriodRow.PeriodStartDate =
                        accountingPeriodRow.PeriodStartDate.AddDays(1).AddYears(1).AddDays(-1);
                    accountingPeriodRow.PeriodEndDate =
                        accountingPeriodRow.PeriodEndDate.AddDays(1).AddYears(1).AddDays(-1);
                    JobSize++;
                }

                if (DoExecuteableCode)
                {
                    AAccountingPeriodAccess.SubmitChanges(AccountingPeriodTbl, Transaction);
                    ShouldCommit = true;
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("Exception during running the AccountPeriod To New Year operation:" + Environment.NewLine + Exc.ToString());
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    if (ShouldCommit)
                    {
                        DBAccess.GDBAccessObj.CommitTransaction();
                    }
                    else
                    {
                        DBAccess.GDBAccessObj.RollbackTransaction();
                    }
                }
            }
            return JobSize;
        }  // RunOperation
Esempio n. 7
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4075Round.cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        double        doubleVal1      = 0;
        double        expectedVal     = 0;
        String        stVal           = null;

        do
        {
            try
            {
                ++iCountTestcases;
                for (int a = 0; a < 1000; a++)
                {
                    stVal      = "0." + a;
                    doubleVal1 = Double.Parse(stVal, CultureInfo.InvariantCulture);
                    if (doubleVal1 <= 0.500)
                    {
                        expectedVal = 0.0;
                    }
                    if (doubleVal1 > 0.500)
                    {
                        expectedVal = 1.0;
                    }
                    if (Math.Round(doubleVal1) != expectedVal)
                    {
                        ++iCountErrors;
                        Console.Error.Write("POINTTOBREAK: find E_0cm3, Did not round properly! in loop number == ");
                        Console.Error.WriteLine(a);
                        Console.Error.WriteLine("; doubleVal1 == " + doubleVal1 + "; stVal == " + stVal);
                        break;
                    }
                }
                ++iCountTestcases;
                for (int a = 0; a < 1000; a++)
                {
                    stVal      = "1." + a;
                    doubleVal1 = Double.Parse(stVal, CultureInfo.InvariantCulture);
                    if (doubleVal1 < 1.500)
                    {
                        expectedVal = 1.0;
                    }
                    if (doubleVal1 >= 1.500)
                    {
                        expectedVal = 2.0;
                    }
                    if (Math.Round(doubleVal1) != expectedVal)
                    {
                        ++iCountErrors;
                        Console.Error.Write("POINTTOBREAK: find E_42d6, Did not round properly! in loop number == ");
                        Console.Error.WriteLine(a);
                        Console.Error.WriteLine("; doubleVal1 == " + doubleVal1 + "; stVal == " + stVal);
                        Console.Error.WriteLine("; expectedVal == " + expectedVal + " Math.Round( doubleVal1 ) == " + Math.Round(doubleVal1));
                    }
                }
                ++iCountTestcases;
                for (int a = 0; a < 1000; a++)
                {
                    stVal      = "-1." + a;
                    doubleVal1 = Double.Parse(stVal, CultureInfo.InvariantCulture);
                    if (doubleVal1 >= -1.500)
                    {
                        expectedVal = -1.0;
                    }
                    if (doubleVal1 <= -1.500)
                    {
                        expectedVal = -2.0;
                    }
                    if (Math.Round(doubleVal1) != expectedVal)
                    {
                        ++iCountErrors;
                        Console.Error.Write("POINTTOBREAK: find E_9f3g, Did not round properly! in loop number == ");
                        Console.Error.WriteLine(a);
                        break;
                    }
                }
                ++iCountTestcases;
                for (int a = 0; a < 1000; a++)
                {
                    stVal      = "2147483646." + a;
                    doubleVal1 = Double.Parse(stVal, CultureInfo.InvariantCulture);
                    if (doubleVal1 <= 2147483646.500)
                    {
                        expectedVal = 2147483646.0;
                    }
                    if (doubleVal1 > 2147483646.500)
                    {
                        expectedVal = 2147483647.0;
                    }
                    if (Math.Round(doubleVal1) != expectedVal)
                    {
                        ++iCountErrors;
                        Console.Error.Write("POINTTOBREAK: find E_bg25 Did not round properly! in loop number == ");
                        Console.Error.WriteLine(a);
                        break;
                    }
                }
                ++iCountTestcases;
                for (int a = 0; a < 1000; a++)
                {
                    stVal      = "-2147483646." + a;
                    doubleVal1 = Double.Parse(stVal, CultureInfo.InvariantCulture);
                    if (doubleVal1 >= -2147483646.500)
                    {
                        expectedVal = -2147483646.0;
                    }
                    if (doubleVal1 < -2147483646.500)
                    {
                        expectedVal = -2147483647.0;
                    }
                    if (Math.Round(doubleVal1) != expectedVal)
                    {
                        ++iCountErrors;
                        Console.Error.Write("POINTTOBREAK: find E_6pr1, Did not round properly! in loop number == ");
                        Console.Error.WriteLine(a);
                        break;
                    }
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4075Round.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4075Round.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4075Round.cs   FAiL !");
            return(false);
        }
    }
Esempio n. 8
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4061Min_single.cs  runTest() started.");
        StringBuilder sblMsg             = new StringBuilder(99);
        int           iCountErrors       = 0;
        int           iCountTestcases    = 0;
        float         floatVal1          = 0;
        float         floatVal2          = 0;
        float         floatexpectedValue = 0;

        do
        {
            try
            {
                ++iCountTestcases;
                floatVal1          = (float)9223372036854775806f;
                floatVal2          = (float)9223372036854775807f;
                floatexpectedValue = (float)9223372036854775806f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append(" floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)9223372036854775807f;
                floatVal2          = (float)9223372036854775806f;
                floatexpectedValue = (float)9223372036854775807f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_z55p, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append(" floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)-9223372036854775807f;
                floatVal2          = (float)-9223372036854775808f;
                floatexpectedValue = (float)-9223372036854775808f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append("floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)-9223372036854775808f;
                floatVal2          = (float)-9223372036854775807f;
                floatexpectedValue = (float)-9223372036854775808f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_ve73, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append("floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)9223372036854775807f;
                floatVal2          = (float)-9223372036854775808f;
                floatexpectedValue = (float)-9223372036854775808f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_s03p, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append("floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)-9223372036854775808f;
                floatVal2          = (float)9223372036854775807f;
                floatexpectedValue = (float)-9223372036854775808f;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find f90k, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append("floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                floatVal1          = (float)0;
                floatVal2          = (float)0;
                floatexpectedValue = (float)0;
                if (Math.Min(floatVal1, floatVal2) != floatexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_67dq, Min value did not come up, Expected floatVal1 == " + floatVal1);
                    sblMsg.Append("floatVal2 == " + floatVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4061Min_single.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4061Min_single.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4061Min_single.cs   FAiL !");
            return(false);
        }
    }
Esempio n. 9
0
        /// <summary>
        /// Records the logging-out (=disconnection) of a Client to the s_login DB Table. That DB Table contains a log
        /// of all the log-ins/log-in attempts to the system, and of log-outs from the system.
        /// </summary>
        /// <param name="AUserID">UserID of the User for which a logout should be recorded.</param>
        /// <param name="AProcessID">ProcessID of the User for which a logout should be recorded.
        /// This will need to be the number that got returned from an earlier call to
        /// <see cref="AddLoginLogEntry(string, string, string, out int, TDBTransaction)"/>!</param>
        /// <param name="ATransaction">Either an instantiated DB Transaction, or null. In the latter case
        /// a separate DB Connection gets opened, a DB Transaction on that separate DB Connection gets started,
        /// then committed/rolled back and the separate DB Connection gets closed. This is needed when this Method
        /// gets called from Method 'Ict.Common.Remoting.Server.TDisconnectClientThread.StartClientDisconnection()'!</param>
        public void RecordUserLogout(String AUserID, int AProcessID, TDBTransaction ATransaction)
        {
            TDataBase      DBConnectionObj  = null;
            TDBTransaction WriteTransaction = null;
            SLoginTable    LoginTable       = new SLoginTable();
            SLoginRow      NewLoginRow      = LoginTable.NewRowTyped(false);
            bool           SubmissionOK     = false;
            DateTime       LogoutDateTime   = DateTime.Now;

            // Set DataRow values
            NewLoginRow.LoginProcessId    = -1;
            NewLoginRow.UserId            = AUserID.ToUpper();
            NewLoginRow.LoginType         = LOGIN_STATUS_TYPE_LOGOUT;
            NewLoginRow.LoginDetails      = Catalog.GetString("User logout.");
            NewLoginRow.LoginProcessIdRef = AProcessID;
            NewLoginRow.Date = LogoutDateTime.Date;
            NewLoginRow.Time = Conversions.DateTimeToInt32Time(LogoutDateTime);

            //TLogging.Log(String.Format("RecordUserLogout: NewLoginRow.Date: {0}; NewLoginRow.Time: {1}",
            //    NewLoginRow.Date, NewLoginRow.Time));

            LoginTable.Rows.Add(NewLoginRow);

            if (ATransaction == null)
            {
                // Open a separate DB Connection (necessary because this Method gets executed in the Server's (Main) AppDomain
                // which hasn't got an instance of DBAccess.GDBAccess!) ...
                DBConnectionObj = DBAccess.SimpleEstablishDBConnection("RecordUserLogout");

                // ...and start a DB Transaction on that separate DB Connection
                WriteTransaction = DBConnectionObj.BeginTransaction(IsolationLevel.RepeatableRead, 0, "RecordUserLogout");
            }
            else
            {
                DBConnectionObj  = ATransaction.DataBaseObj;
                WriteTransaction = ATransaction;
            }

            try
            {
                try
                {
                    SLoginAccess.SubmitChanges(LoginTable, WriteTransaction);

                    SubmissionOK = true;
                }
                catch (Exception Exc)
                {
                    TLogging.Log("RecordUserLogout: An Exception occured during the saving of a Login Log entry:" +
                                 Environment.NewLine + Exc.ToString());

                    throw;
                }
            }
            finally
            {
                if (SubmissionOK)
                {
                    DBConnectionObj.CommitTransaction();
                }
                else
                {
                    DBConnectionObj.RollbackTransaction();
                }

                if (DBConnectionObj != null)
                {
                    DBConnectionObj.CloseDBConnection();
                }
            }
        }
Esempio n. 10
0
        // See also constants LOGIN_STATUS_TYPE_* in Ict.Petra.Server.MSysMan.Security.TLoginLog!

        /// <summary>
        /// Adds a record to the s_login DB Table. That DB Table contains a log of all the log-ins/log-in attempts to
        /// the system, and of log-outs from the system.
        /// </summary>
        /// <param name="AUserID">UserID of the User for which a record should be written.</param>
        /// <param name="ALoginType">Type of the login/logout record. This is a hard-coded constant value
        /// (there's no 'lookup table' for it); for available values and their meaning please check program code
        /// (Ict.Petra.Server.MSysMan.Security.TLoginLog Class).</param>
        /// <param name="ALoginDetails">Details/description of the login/login attempt/logout </param>
        /// <param name="AProcessID">'Process ID'; this is a unique key and comes from a sequence (seq_login_process_id).</param>
        /// <param name="ATransaction">Instantiated DB Transaction.</param>
        public static void AddLoginLogEntry(String AUserID, String ALoginType, String ALoginDetails, out Int32 AProcessID,
                                            TDBTransaction ATransaction)
        {
            SLoginTable LoginTable  = new SLoginTable();
            SLoginRow   NewLoginRow = LoginTable.NewRowTyped(false);

            OdbcParameter[] ParametersArray;
            DateTime        LoginDateTime = DateTime.Now;

            // Set DataRow values
            NewLoginRow.LoginProcessId = -1;
            NewLoginRow.UserId         = AUserID.ToUpper();
            NewLoginRow.LoginType      = ALoginType;
            NewLoginRow.LoginDetails   = ALoginDetails;
            NewLoginRow.Date           = LoginDateTime.Date;
            NewLoginRow.Time           = Conversions.DateTimeToInt32Time(LoginDateTime);

            //TLogging.Log(String.Format("AddLoginLogEntry: NewLoginRow.Date: {0}; NewLoginRow.Time: {1}",
            //    NewLoginRow.Date, NewLoginRow.Time));

            LoginTable.Rows.Add(NewLoginRow);

            try
            {
                SLoginAccess.SubmitChanges(LoginTable, ATransaction);
            }
            catch (Exception Exc)
            {
                TLogging.Log("AddLoginLogEntry: An Exception occured during the saving of a Login Log entry (Situation #1):" +
                             Environment.NewLine + Exc.ToString());

                throw;
            }

            // Retrieve ROWID of the SLogin record
            ParametersArray          = new OdbcParameter[4];
            ParametersArray[0]       = new OdbcParameter("", OdbcType.VarChar, 20);
            ParametersArray[0].Value = (System.Object)(AUserID);
            ParametersArray[1]       = new OdbcParameter("", OdbcType.Date);
            ParametersArray[1].Value = (System.Object)(LoginDateTime.Date);
            ParametersArray[2]       = new OdbcParameter("", OdbcType.Int);
            ParametersArray[2].Value = (System.Object)(NewLoginRow.Time);
            ParametersArray[3]       = new OdbcParameter("", OdbcType.VarChar, 500);
            ParametersArray[3].Value = (System.Object)(ALoginDetails);

            try
            {
                // ROWID for postgresql: see http://archives.postgresql.org/sydpug/2005-05/msg00002.php
                AProcessID =
                    Convert.ToInt32(ATransaction.DataBaseObj.ExecuteScalar("SELECT " + SLoginTable.GetLoginProcessIdDBName() + " FROM PUB_" +
                                                                           TTypedDataTable.GetTableNameSQL(SLoginTable.TableId) +
                                                                           ' ' +
                                                                           "WHERE " + SLoginTable.GetUserIdDBName() + " = ? AND " + SLoginTable.GetDateDBName() + " = ? AND " +
                                                                           SLoginTable.GetTimeDBName() + " = ? AND " + SLoginTable.GetLoginDetailsDBName() + " = ?", ATransaction,
                                                                           ParametersArray));
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured during the saving of the a Login Log entry (Situation #2):" +
                             Environment.NewLine + Exc.ToString());

                throw;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// todoComment
        /// </summary>
        /// <param name="AErrorCode"></param>
        /// <param name="AContext"></param>
        /// <param name="AMessageLine1"></param>
        /// <param name="AMessageLine2"></param>
        /// <param name="AMessageLine3"></param>
        /// <param name="AUserID"></param>
        /// <param name="AProcessID"></param>
        public void AddErrorLogEntry(String AErrorCode,
                                     String AContext,
                                     String AMessageLine1,
                                     String AMessageLine2,
                                     String AMessageLine3,
                                     String AUserID,
                                     Int32 AProcessID)
        {
            TDBTransaction WriteTransaction;

            SErrorLogTable ErrorLogTable;
            SErrorLogRow   NewErrorLogRow;
            DateTime       ErrorLogDateTime;
            Boolean        NewTransaction;
            String         Context;

            ErrorLogTable    = new SErrorLogTable();
            NewErrorLogRow   = ErrorLogTable.NewRowTyped(false);
            ErrorLogDateTime = DateTime.Now;

            if (AContext != "")
            {
                Context = AContext;
            }
            else
            {
                Context = UNKNOWN_CONTEXT;
            }

            // Set DataRow values
            NewErrorLogRow.ErrorCode     = AErrorCode;
            NewErrorLogRow.UserId        = AUserID.ToUpper();
            NewErrorLogRow.Date          = ErrorLogDateTime;
            NewErrorLogRow.Time          = Conversions.DateTimeToInt32Time(ErrorLogDateTime);
            NewErrorLogRow.ReleaseNumber = TSrvSetting.ApplicationVersion.ToString();
            NewErrorLogRow.FileName      = Context;
            NewErrorLogRow.ProcessId     = AProcessID.ToString();
            NewErrorLogRow.MessageLine1  = AMessageLine1;
            NewErrorLogRow.MessageLine2  = AMessageLine2;
            NewErrorLogRow.MessageLine3  = AMessageLine3;
            ErrorLogTable.Rows.Add(NewErrorLogRow);

            // Save DataRow
            WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted,
                                                                                 TEnforceIsolationLevel.eilMinimum,
                                                                                 out NewTransaction);

            try
            {
                SErrorLogAccess.SubmitChanges(ErrorLogTable, WriteTransaction);

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured during the saving of the Error Log:" + Environment.NewLine + Exc.ToString());

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

                throw;
            }
        }
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4073Log10.cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        double        doubleVal1      = 0;
        double        doubleVal2      = 0;
        double        expectedVal     = 0;
        double        exValHigh       = 0;
        double        exValLow        = 0;

        do
        {
            try
            {
                ++iCountTestcases;
                doubleVal1  = 10;
                expectedVal = 1;
                if (Math.Log10(doubleVal1) != expectedVal)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_n0d2, Log10 not equal to expected Value == " + expectedVal);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1  = 1e+308;
                doubleVal2  = 308.0;
                expectedVal = Math.Log10(doubleVal1);
                if (expectedVal != doubleVal2)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_295b, Log10 not equal to expected Value == " + expectedVal);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1  = 1e-308;
                doubleVal2  = -308.0;
                expectedVal = Math.Log10(doubleVal1);
                if (expectedVal != doubleVal2)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_d3ka, Log10 not equal to expected Value == " + expectedVal);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1  = 1e+0;
                doubleVal2  = 0.0;
                expectedVal = Math.Log10(doubleVal1);
                if (expectedVal != doubleVal2)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_0l32, Log10 not equal to expected Value == " + expectedVal);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1  = 1e-0;
                doubleVal2  = 0.0;
                expectedVal = Math.Log10(doubleVal1);
                if (expectedVal != doubleVal2)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_q25a, Log10 not equal to expected Value == " + expectedVal);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4073Log10.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4073Log10.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4073Log10.cs   FAiL !");
            return(false);
        }
    }
 internal FuncEventHandler(Func <TState, TEvent, TState> func, TState initialState)
 {
     this.dlgt         = func ?? throw Exc.Null(nameof(func));
     this.currentState = initialState;
 }
Esempio n. 14
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4055Max_double.cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        double        doubleVal1      = 0;
        double        doubleVal2      = 0;
        double        flexpectedValue = 0;

        do
        {
            try
            {
                ++iCountTestcases;
                doubleVal1      = (double)2147483646.0;
                doubleVal2      = (double)2147483647.0;
                flexpectedValue = (double)2147483647.0;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)2147483647.0;
                doubleVal2      = (double)2147483646.0;
                flexpectedValue = (double)2147483647.0;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_z55p, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)-2147483646.0;
                doubleVal2      = (double)-2147483647.0;
                flexpectedValue = (double)-2147483646.0;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)-2147483647.0;
                doubleVal2      = (double)-2147483646.0;
                flexpectedValue = (double)-2147483646.0;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_z55p, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)2147483647.0;
                doubleVal2      = (double)-2147483647.0;
                flexpectedValue = (double)2147483647;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_s03p, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)-2147483647.0;
                doubleVal2      = (double)2147483647.0;
                flexpectedValue = (double)2147483647;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find f90k, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1      = (double)0.0;
                doubleVal2      = (double)0.0;
                flexpectedValue = (double)0.0;
                if (Math.Max(doubleVal1, doubleVal2) != flexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_67dq, Max value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                if (!Double.NaN.Equals(Math.Max(Double.NaN, 5)))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_394tsg! Wrong value retunred");
                }
                if (!Double.NaN.Equals(Math.Max(5, Double.NaN)))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_394tsg! Wrong value retunred");
                }
                if (!Double.NaN.Equals(Math.Max(Double.NaN, Double.NaN)))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_394tsg! Wrong value retunred");
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4055Max_double.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4055Max_double.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4055Max_double.cs   FAiL !");
            return(false);
        }
    }
Esempio n. 15
0
        /// <summary>
        /// Closes the Server's DB Polling Connection in an orderly fashion.
        /// </summary>
        public override void CloseDBPollingConnection()
        {
            try
            {
                if (FDBConnectionCheckAccessObj != null)
                {
                    TLogging.Log("Closing the Server's DB Polling Connection...");

                    FDBConnectionCheckAccessObj.CloseDBConnection(true);

                    TLogging.Log("    The Server's DB Polling Connection got closed.");
                }
            }
            catch (Exception Exc)
            {
                // *Deliberate swallowing* of Exception as we don't care if we should encounter DB Connection problems when
                // stopping the Server as the Server process will end anyway.
                TLogging.Log("CloseDBPollingConnection: Encountered an Exception:" + Environment.NewLine + Exc.ToString());
            }
        }
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4062Min_double.cs  runTest() started.");
        StringBuilder sblMsg              = new StringBuilder(99);
        int           iCountErrors        = 0;
        int           iCountTestcases     = 0;
        double        doubleVal1          = 0;
        double        doubleVal2          = 0;
        double        doubleexpectedValue = 0;

        do
        {
            try
            {
                ++iCountTestcases;
                doubleVal1          = (double)1.79769e+307;
                doubleVal2          = (double)1.79769e+308;
                doubleexpectedValue = (double)1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append(" doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)1.79769e+308;
                doubleVal2          = (double)1.79769e+307;
                doubleexpectedValue = (double)1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_z55p, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)-1.79769e+306;
                doubleVal2          = (double)-1.79769e+307;
                doubleexpectedValue = (double)-1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_5g2f, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)-1.79769e+307;
                doubleVal2          = (double)-1.79769e+306;
                doubleexpectedValue = (double)-1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_ve73, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)1.79769e+308;
                doubleVal2          = (double)-1.79769e+307;
                doubleexpectedValue = (double)-1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find E_s03p, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)-1.79769e+307;
                doubleVal2          = (double)1.79769e+308;
                doubleexpectedValue = (double)-1.79769e+307;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Append("POINTTOBREAK: find f90k, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
                ++iCountTestcases;
                doubleVal1          = (double)0;
                doubleVal2          = (double)0;
                doubleexpectedValue = (double)0;
                if (Math.Min(doubleVal1, doubleVal2) != doubleexpectedValue)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_67dq, Min value did not come up, Expected doubleVal1 == " + doubleVal1);
                    sblMsg.Append("doubleVal2 == " + doubleVal2);
                    Console.Error.WriteLine(sblMsg.ToString());
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4062Min_double.cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4062Min_double.cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4062Min_double.cs   FAiL !");
            return(false);
        }
    }
Esempio n. 17
0
        /// <summary>
        /// this checks if the new key is still available,
        /// and makes sure it will not be used as a default key anymore
        /// </summary>
        /// <param name="AFieldPartnerKey"></param>
        /// <param name="AOriginalDefaultKey">this has been previously retrieved from GetNewPartnerKey</param>
        /// <param name="ANewPartnerKey">the user proposes this key for a new partner; the function can change it and return a valid value, or -1</param>
        /// <param name="ADataBase"></param>
        /// <returns>whether or not ANewPartnerKey has a valid new partner key;
        /// if it cannot be assigned, the function returns false, and ANewPartnerKey is -1
        /// </returns>
        public static bool SubmitNewPartnerKey(System.Int64 AFieldPartnerKey, System.Int64 AOriginalDefaultKey, ref System.Int64 ANewPartnerKey, TDataBase ADataBase = null)
        {
            bool                ReturnValue = true;
            TDBTransaction      ReadTransaction;
            TDBTransaction      WriteTransaction;
            Boolean             NewTransaction;
            PPartnerLedgerTable PartnerLedgerDT;

            TDataBase db = DBAccess.Connect("SubmitNewPartnerKey", ADataBase);

            System.Int64 CurrentDefaultPartnerKey;

            if (ANewPartnerKey == AOriginalDefaultKey)
            {
                // The user has selected the default
                ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                                 out NewTransaction);

                try
                {
                    // Fetch the partner ledger record to update the last key

                    PartnerLedgerDT          = PPartnerLedgerAccess.LoadByPrimaryKey(AFieldPartnerKey, ReadTransaction);
                    CurrentDefaultPartnerKey = PartnerLedgerDT[0].PartnerKey + PartnerLedgerDT[0].LastPartnerId + 1;

                    if (ANewPartnerKey != CurrentDefaultPartnerKey)
                    {
                        // Someone else has updated this since, so we will use the new default
                        ANewPartnerKey = CurrentDefaultPartnerKey;
                    }

                    // Now check that this does not exist, and increment until we
                    // find one which does not
                    while (PPartnerAccess.Exists(ANewPartnerKey, ReadTransaction))
                    {
                        ANewPartnerKey = ANewPartnerKey + 1;
                    }
                }
                finally
                {
                    if (NewTransaction)
                    {
                        ReadTransaction.Rollback();

                        if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_TRACE)
                        {
                            Console.WriteLine("TNewPartnerKey.SubmitNewPartnerKey: rolled back own transaction.");
                        }
                    }
                }

                PartnerLedgerDT[0].LastPartnerId = (int)(ANewPartnerKey - PartnerLedgerDT[0].PartnerKey);

                WriteTransaction = db.GetNewOrExistingTransaction(IsolationLevel.Serializable,
                                                                  out NewTransaction);

                try
                {
                    PPartnerLedgerAccess.SubmitChanges(PartnerLedgerDT, WriteTransaction);

                    if (NewTransaction)
                    {
                        WriteTransaction.Commit();
                    }
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the submission of a new PartnerKey:" + Environment.NewLine + Exc.ToString());

                    if (NewTransaction)
                    {
                        WriteTransaction.Rollback();
                    }

                    throw;
                }
            }
            // end of: The user has selected the default
            else
            {
                ReadTransaction = db.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                                 out NewTransaction);

                try
                {
                    // check if the Partner Key is already being used
                    if (PPartnerAccess.Exists(ANewPartnerKey, ReadTransaction))
                    {
                        ANewPartnerKey = -1;
                        ReturnValue    = false;
                    }
                }
                finally
                {
                    if (NewTransaction)
                    {
                        ReadTransaction.Rollback();

                        if (TLogging.DebugLevel >= TLogging.DEBUGLEVEL_TRACE)
                        {
                            Console.WriteLine("TNewPartnerKey.SubmitNewPartnerKey: rolled back own transaction.");
                        }
                    }
                }
            }

            if (ADataBase == null)
            {
                db.CloseDBConnection();
            }

            return(ReturnValue);
        }
Esempio n. 18
0
        private static Boolean SaveUser(String AUserID, SUserTable AUserDataTable)
        {
            TDBTransaction TheTransaction;

            if ((AUserDataTable != null) && (AUserDataTable.Rows.Count > 0))
            {
                TheTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

                try
                {
                    SUserAccess.SubmitChanges(AUserDataTable, TheTransaction);

                    DBAccess.GDBAccessObj.CommitTransaction();
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the saving of a User:" + Environment.NewLine + Exc.ToString());

                    DBAccess.GDBAccessObj.RollbackTransaction();

                    throw;
                }
            }
            else
            {
                // nothing to save!
                return(false);
            }

            return(true);
        }
Esempio n. 19
0
    public virtual bool runTest()
    {
        Console.Out.WriteLine("Co4046Abs_short .cs  runTest() started.");
        StringBuilder sblMsg          = new StringBuilder(99);
        int           iCountErrors    = 0;
        int           iCountTestcases = 0;
        short         shortVal;
        short         shortKnown;

        do
        {
            try
            {
                ++iCountTestcases;
                shortVal   = -((short)0x7FFF);
                shortKnown = (short)32767;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_3nk4, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
                ++iCountTestcases;
                shortVal   = -((short)0);
                shortKnown = 0;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_pf71, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
                ++iCountTestcases;
                shortVal   = -((short)1);
                shortKnown = 1;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_6mz2, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
                ++iCountTestcases;
                shortVal   = ((short)0x7FFF);
                shortKnown = (short)32767;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_ss81, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
                ++iCountTestcases;
                shortVal   = ((short)0);
                shortKnown = 0;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_4f9v, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
                ++iCountTestcases;
                shortVal   = ((short)1);
                shortKnown = 1;
                if (Math.Abs(shortVal) != shortKnown)
                {
                    ++iCountErrors;
                    sblMsg.Length = 99;
                    sblMsg.Append("POINTTOBREAK: find E_bbq11, ABS wrong! ");
                    sblMsg.Append("EXTENDEDINFO: Expected shortKnown == " + shortKnown);
                    sblMsg.Append(" intead got Math.Abs( shortVal ) == " + Math.Abs(shortVal));
                    break;
                }
            }
            catch (Exception Exc)
            {
                ++iCountErrors;
                sblMsg.Length = 99;
                sblMsg.Append("POINTTOBREAK: find E_f3h5, Generic Exception Caught, Exc.ToString() == ");
                sblMsg.Append(Exc.ToString());
                Console.Error.WriteLine(sblMsg.ToString());
                break;
            }
        }while (false);
        if (iCountErrors == 0)
        {
            Console.Error.Write("Math\\Co4046Abs_short .cs: paSs.  iCountTestcases==");
            Console.Error.WriteLine(iCountTestcases);
            return(true);
        }
        else
        {
            Console.Error.Write("Co4046Abs_short .cs iCountErrors==");
            Console.Error.WriteLine(iCountErrors);
            Console.Error.WriteLine("Co4046Abs_short .cs   FAiL !");
            return(false);
        }
    }
Esempio n. 20
0
        private static Boolean SaveUser(String AUserID, SUserTable AUserDataTable, TDBTransaction ATransaction)
        {
            if ((AUserDataTable != null) && (AUserDataTable.Rows.Count > 0))
            {
                try
                {
                    SUserAccess.SubmitChanges(AUserDataTable, ATransaction);
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the saving of a User:" + Environment.NewLine + Exc.ToString());

                    throw;
                }
            }
            else
            {
                // nothing to save!
                return(false);
            }

            return(true);
        }
Esempio n. 21
0
        public static bool GiftRevertAdjust(Hashtable requestParams, out int AAdjustmentBatchNumber, GiftBatchTDS AGiftDS)
        {
            AAdjustmentBatchNumber = 0;
            int AdjustmentBatchNo = AAdjustmentBatchNumber;

            if ((AGiftDS == null) || (AGiftDS.AGiftDetail == null) || (AGiftDS.AGiftDetail.Rows.Count == 0))
            {
                TLogging.Log("Empty dataset sent to GiftRevertAdjust");

                return(false);
            }

            Int32   ALedgerNumber = (Int32)requestParams["ALedgerNumber"];
            Boolean BatchSelected = (Boolean)requestParams["NewBatchSelected"];
            GiftAdjustmentFunctionEnum Function = (GiftAdjustmentFunctionEnum)requestParams["Function"];
            Int32 GiftDetailNumber = (Int32)requestParams["GiftDetailNumber"];
            bool  NoReceipt        = (Boolean)requestParams["NoReceipt"];

            DateTime DateEffective;
            decimal  batchGiftTotal  = 0;
            Int32    ANewBatchNumber = 0;

            if (BatchSelected)
            {
                ANewBatchNumber = (Int32)requestParams["NewBatchNumber"];
            }

            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable,
                                                                  ref Transaction,
                                                                  ref SubmissionOK,
                                                                  delegate
            {
                try
                {
                    ALedgerTable LedgerTable = ALedgerAccess.LoadByPrimaryKey(ALedgerNumber, Transaction);

                    AGiftBatchRow giftBatch;

                    // if we need to create a new gift batch
                    if (!BatchSelected)
                    {
                        giftBatch = CreateNewGiftBatch(requestParams, ref AGiftDS, out DateEffective, ref LedgerTable, Transaction);
                    }
                    else      // using an existing gift batch
                    {
                        AGiftBatchAccess.LoadByPrimaryKey(AGiftDS, ALedgerNumber, ANewBatchNumber, Transaction);

                        giftBatch     = AGiftDS.AGiftBatch[0];
                        DateEffective = giftBatch.GlEffectiveDate;
                        //If into an existing batch, then retrive the existing batch total
                        batchGiftTotal = giftBatch.BatchTotal;
                    }

                    AdjustmentBatchNo = giftBatch.BatchNumber;

                    //assuming new elements are added after these static borders

                    AGiftDS.AGift.DefaultView.Sort = string.Format("{0}, {1}",
                                                                   AGiftTable.GetBatchNumberDBName(),
                                                                   AGiftTable.GetGiftTransactionNumberDBName());

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

                    foreach (DataRowView giftRow in AGiftDS.AGift.DefaultView)
                    {
                        int cycle = 0;

                        // first cycle creates gift reversal; second cycle creates new adjusted gift (if needed)
                        do
                        {
                            AGiftRow oldGift = (AGiftRow)giftRow.Row;

                            if (oldGift.RowState != DataRowState.Added)
                            {
                                AGiftRow gift = AGiftDS.AGift.NewRowTyped(true);
                                DataUtilities.CopyAllColumnValuesWithoutPK(oldGift, gift);
                                gift.LedgerNumber          = giftBatch.LedgerNumber;
                                gift.BatchNumber           = giftBatch.BatchNumber;
                                gift.DateEntered           = DateEffective;
                                gift.GiftTransactionNumber = giftBatch.LastGiftNumber + 1;
                                giftBatch.LastGiftNumber++;
                                gift.LinkToPreviousGift = (cycle != 0);
                                gift.LastDetailNumber   = 0;

                                // do not print a receipt for reversed gifts
                                if (cycle == 0)
                                {
                                    gift.ReceiptPrinted = true;
                                    gift.PrintReceipt   = false;
                                }
                                else
                                {
                                    gift.ReceiptPrinted = false;
                                    gift.PrintReceipt   = !NoReceipt;
                                }

                                AGiftDS.AGift.Rows.Add(gift);

                                foreach (DataRowView giftDetailRow in AGiftDS.AGiftDetail.DefaultView)
                                {
                                    AGiftDetailRow oldGiftDetail = (AGiftDetailRow)giftDetailRow.Row;

                                    // if gift detail belongs to gift
                                    if ((oldGiftDetail.GiftTransactionNumber == oldGift.GiftTransactionNumber) &&
                                        (oldGiftDetail.BatchNumber == oldGift.BatchNumber) &&
                                        (!Function.Equals(GiftAdjustmentFunctionEnum.ReverseGiftDetail) ||
                                         (oldGiftDetail.DetailNumber == GiftDetailNumber)))
                                    {
                                        AddDuplicateGiftDetailToGift(ref AGiftDS, ref gift, oldGiftDetail, cycle == 0, Transaction,
                                                                     requestParams);

                                        batchGiftTotal += oldGiftDetail.GiftTransactionAmount * ((cycle == 0) ? -1 : 1);

                                        // original gift also gets marked as a reversal
                                        oldGiftDetail.ModifiedDetail = true;
                                    }
                                }
                            }

                            cycle++;
                        } while ((cycle < 2) &&
                                 (Function.Equals(GiftAdjustmentFunctionEnum.AdjustGift) ||
                                  Function.Equals(GiftAdjustmentFunctionEnum.FieldAdjust) ||
                                  Function.Equals(GiftAdjustmentFunctionEnum.TaxDeductiblePctAdjust)));
                    }

                    //When reversing into a new or existing batch, set batch total
                    if (!Function.Equals(GiftAdjustmentFunctionEnum.AdjustGift))
                    {
                        giftBatch.BatchTotal = batchGiftTotal;
                    }

                    // save everything at the end
                    AGiftBatchAccess.SubmitChanges(AGiftDS.AGiftBatch, Transaction);

                    ALedgerAccess.SubmitChanges(LedgerTable, Transaction);

                    AGiftAccess.SubmitChanges(AGiftDS.AGift, Transaction);

                    AGiftDetailAccess.SubmitChanges(AGiftDS.AGiftDetail, Transaction);

                    AGiftDS.AGiftBatch.AcceptChanges();

                    SubmissionOK = true;
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured while performing Gift Reverse/Adjust:" + Environment.NewLine + Exc.ToString());

                    throw new EOPAppException(Catalog.GetString("Gift Reverse/Adjust failed."), Exc);
                }
            });

            AAdjustmentBatchNumber = AdjustmentBatchNo;

            return(SubmissionOK);
        }
Esempio n. 22
0
        /// <summary>
        /// run the report
        /// </summary>
        private void Run(string ASessionID)
        {
            // need to initialize the database session
            TSession.InitThread(ASessionID);
            IsolationLevel Level;

            if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "readuncommitted")
            {
                // for long reports, that should not take out locks;
                // the data does not need to be consistent or will most likely not be changed during the generation of the report
                Level = IsolationLevel.ReadUncommitted;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "repeatableread")
            {
                // for financial reports: it is important to have consistent data; e.g. for totals
                Level = IsolationLevel.RepeatableRead;
            }
            else if (FParameterList.Get("IsolationLevel").ToString().ToLower() == "serializable")
            {
                // for creating extracts: we need to write to the database
                Level = IsolationLevel.Serializable;
            }
            else
            {
                // default behaviour for normal reports
                Level = IsolationLevel.ReadCommitted;
            }

            FSuccess = false;

            TDBTransaction Transaction  = null;
            bool           SubmissionOK = false;

            try
            {
                DBAccess.GDBAccessObj.BeginAutoTransaction(Level, ref Transaction,
                                                           ref SubmissionOK,
                                                           delegate
                {
                    if (FDatacalculator.GenerateResult(ref FParameterList, ref FResultList, ref FErrorMessage, ref FException))
                    {
                        FSuccess     = true;
                        SubmissionOK = true;
                    }
                    else
                    {
                        TLogging.Log(FErrorMessage);
                    }
                });
            }
            catch (Exception Exc)
            {
                TLogging.Log("Problem calculating report: " + Exc.ToString());
                TLogging.Log(Exc.StackTrace, TLoggingType.ToLogfile);

                FSuccess      = false;
                FErrorMessage = Exc.Message;
                FException    = Exc;
            }

            if (TDBExceptionHelper.IsTransactionSerialisationException(FException))
            {
                // do nothing - we want this exception to bubble up
            }
            else if (FException is Exception && FException.InnerException is EOPDBException)
            {
                EOPDBException DbExc = (EOPDBException)FException.InnerException;

                if (DbExc.InnerException is Exception)
                {
                    if (DbExc.InnerException is PostgresException)
                    {
                        PostgresException PgExc = (PostgresException)DbExc.InnerException;

                        if (PgExc.SqlState == "57014") // SQL statement timeout problem
                        {
                            FErrorMessage = Catalog.GetString(
                                "Error - Database took too long to respond. Try different parameters to return fewer results.");
                        }
                    }
                    else
                    {
                        FErrorMessage = DbExc.InnerException.Message;
                    }

                    FException = null;
                }
            }

            TProgressTracker.FinishJob(FProgressID);
        }
Esempio n. 23
0
        /// <summary>
        /// store the AP supplier
        ///
        /// All DataTables contained in the Typed DataSet are inspected for added,
        /// changed or deleted rows by submitting them to the DataStore.
        /// </summary>
        /// <param name="AInspectDS">Typed DataSet that needs to contain known DataTables</param>
        /// <returns>TSubmitChangesResult.scrOK in case everything went fine, otherwise throws an Exception.</returns>
        public TSubmitChangesResult SubmitChanges(ref AccountsPayableTDS AInspectDS)
        {
            TDBTransaction SubmitChangesTransaction;

            if (AInspectDS != null)
            {
                // I won't allow any null fields related to discount:

                if (AInspectDS.AApSupplier[0].IsDefaultDiscountDaysNull())
                {
                    AInspectDS.AApSupplier[0].DefaultDiscountDays = 0;
                }

                if (AInspectDS.AApSupplier[0].IsDefaultDiscountPercentageNull())
                {
                    AInspectDS.AApSupplier[0].DefaultDiscountPercentage = 0;
                }

                SubmitChangesTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

                try
                {
                    AApSupplierAccess.SubmitChanges(AInspectDS.AApSupplier, SubmitChangesTransaction);

                    DBAccess.GDBAccessObj.CommitTransaction();
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the storing of the AP Supplier):" + Environment.NewLine + Exc.ToString());

                    DBAccess.GDBAccessObj.RollbackTransaction();

                    throw;
                }
            }

            return(TSubmitChangesResult.scrOK);
        }