示例#1
0
        }         // AppendOverridingResults

        public virtual void Save(
            AConnection oDB,
            ATrail oTrail,
            TrailPrimaryStatus primaryStatus   = TrailPrimaryStatus.Primary,
            TrailPrimaryStatus secondaryStatus = TrailPrimaryStatus.Verification
            )
        {
            ConnectionWrapper cw = null;

            try {
                cw = oDB.GetPersistent();
                cw.BeginTransaction();

                this.m_oLog.Debug("Transaction has been started, saving primary trail...");

                new SaveDecisionTrail(
                    this,
                    UniqueID,
                    (int)primaryStatus,
                    CashRequestID,
                    NLCashRequestID,
                    Tag,
                    oDB,
                    this.m_oLog
                    ).ExecuteNonQuery(cw);

                this.m_oLog.Debug("Saving primary trail done (pending transaction commit).");

                if (oTrail != null)
                {
                    this.m_oLog.Debug("Saving secondary trail...");

                    new SaveDecisionTrail(
                        oTrail,
                        UniqueID,
                        (int)secondaryStatus,
                        CashRequestID,
                        NLCashRequestID,
                        Tag,
                        oDB,
                        this.m_oLog
                        ).ExecuteNonQuery(cw);

                    this.m_oLog.Debug("Saving secondary trail done (pending transaction commit).");
                }                 // if

                cw.Commit();
                this.m_oLog.Debug("Decision trail has been saved, connection is closed.");
            } catch (Exception e) {
                if (cw != null)
                {
                    cw.Rollback();
                }

                this.m_oLog.Alert(e, "Failed to save decision trail.");
            }     // try
        }         // Save
示例#2
0
        }         // UniqueID

        public virtual void AppendOverridingResults(ATrail trail)
        {
            if (trail == null)
            {
                this.m_oLog.Alert("Cannot append a NULL trail.");
                return;
            }             // if

            bool isAssignable = TypeUtils.IsSubclassOf(GetType(), trail.GetType(), this.m_oLog);

            if (!isAssignable)
            {
                this.m_oLog.Alert("Cannot append {0} trail to {1} trail.", trail.GetType().Name, GetType().Name);
                return;
            }             // if

            if (trail.CustomerID != CustomerID)
            {
                this.m_oLog.Alert("Cannot append customer {0} trail to customer {1} trail.", trail.CustomerID, CustomerID);
                return;
            }             // if

            if (trail.CashRequestID != CashRequestID)
            {
                this.m_oLog.Alert(
                    "Cannot append cash request {0} trail to cash request {1} trail.",
                    trail.CashRequestID,
                    CashRequestID
                    );
                return;
            }             // if

            if (trail.NLCashRequestID != NLCashRequestID)
            {
                this.m_oLog.Alert(
                    "Cannot append NL cash request {0} trail to NL cash request {1} trail.",
                    trail.NLCashRequestID,
                    NLCashRequestID
                    );
                return;
            }             // if

            HasApprovalChance = trail.HasApprovalChance;
            Amount            = trail.Amount;
            DecisionStatus    = trail.DecisionStatus;
            IsDecisionLocked  = trail.IsDecisionLocked;
            this.m_oUniqueID  = trail.UniqueID;
            this.m_oDiffNotes.AddRange(trail.m_oDiffNotes);
            this.m_oSteps.AddRange(trail.m_oSteps);
            this.stepsWithDecision.AddRange(trail.stepsWithDecision);
            this.m_sToExplanationEmailAddress = trail.m_sToExplanationEmailAddress;
            this.m_sFromEmailAddress          = trail.m_sFromEmailAddress;
            this.m_sFromEmailName             = trail.m_sFromEmailName;
            this.timer.Append(trail.timer);
        }         // AppendOverridingResults
示例#3
0
            public SaveDecisionTrail(
                ATrail oTrail,
                Guid oDiffID,
                int isPrimary,
                long?cashRequestID,
                long?nlCashRequestID,
                string tag,
                AConnection oDB,
                ASafeLog oLog
                ) : base(oDB, oLog)
            {
                this.m_oTrail     = oTrail;
                CustomerID        = oTrail.CustomerID;
                DecisionID        = (int)oTrail.Decision;
                UniqueID          = oDiffID;
                DecisionStatusID  = (int)oTrail.DecisionStatus;
                InputData         = oTrail.InputData.Serialize();
                IsPrimary         = isPrimary;
                HasApprovalChance = oTrail.HasApprovalChance;
                CashRequestID     = cashRequestID;
                NLCashRequestID   = nlCashRequestID;
                Tag = tag;

                Traces = new List <ATrace.DBModel>();

                for (int i = 0; i < oTrail.Length; i++)
                {
                    Traces.Add(oTrail.m_oSteps[i].ToDBModel(i, false));
                }

                TimerSteps = new List <TimerStepDBModel>();

                for (int i = 0; i < oTrail.StepTimes.Count; i++)
                {
                    TimeCounter.Step st = oTrail.StepTimes[i];

                    TimerSteps.Add(new TimerStepDBModel {
                        Position   = i,
                        StepNameID = long.Parse(st.Name),
                        Length     = st.Length,
                    });
                }         // for each
            }             // constructor
示例#4
0
        }         // Add

        private void SendExplanationMail(ATrail oTrail, string sMsg)
        {
            var message = string.Format(
                EmailFormat,
                Name,
                CustomerID,
                HttpUtility.HtmlEncode(sMsg),
                HttpUtility.HtmlEncode(ToString()),
                HttpUtility.HtmlEncode(oTrail == null ? "no Trail specified" : oTrail.ToString()),
                HttpUtility.HtmlEncode(InputData.Serialize()),
                HttpUtility.HtmlEncode(oTrail == null ? "no Trail specified" : oTrail.InputData.Serialize()),
                Tag,
                UniqueID
                );

            new Mail().Send(
                this.m_sToExplanationEmailAddress,
                null,
                message,
                this.m_sFromEmailAddress,
                this.m_sFromEmailName,
                "#Mismatch in " + Name + " for customer " + CustomerID
                );
        }         // SendExplanationMail
示例#5
0
        }         // ToString

        public virtual bool EqualsTo(ATrail oTrail, bool bQuiet = false)
        {
            if (oTrail == null)
            {
                const string sMsg = "The second trail is not specified.";
                AddNote(sMsg);

                if (!bQuiet)
                {
                    this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    // ReSharper disable ExpressionIsAlwaysNull
                    SendExplanationMail(oTrail, sMsg: sMsg);
                    // ReSharper restore ExpressionIsAlwaysNull
                }                 // if

                return(false);
            }             // if

            if (GetType() != oTrail.GetType())
            {
                string sMsg = string.Format(
                    "This trail is of for decision '{0}' while the second one is for '{1}'.",
                    Decision,
                    oTrail.Decision
                    );

                AddNote(sMsg);

                if (!bQuiet)
                {
                    this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    SendExplanationMail(oTrail, sMsg);
                }                 // if

                return(false);
            }             // if

            bool bResult = true;

            if (DecisionStatus != oTrail.DecisionStatus)
            {
                bResult = false;

                string sMsg = string.Format(
                    "Different conclusions for '{2}' have been reached: '{0}' in this vs '{1}' in the second.",
                    GetDecisionName(),
                    oTrail.GetDecisionName(),
                    Decision
                    );

                AddNote(sMsg);

                if (!bQuiet)
                {
                    this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    SendExplanationMail(oTrail, sMsg);
                }         // if
            }             // if

            if (Amount != oTrail.Amount)
            {
                bResult = false;

                string sMsg = string.Format(
                    "Different amount for '{2}' have been reached: '{0}' in this vs '{1}' in the second.",
                    Amount.HasValue ? Amount.Value.ToString(CultureInfo.InvariantCulture) : "no value",
                    oTrail.Amount.HasValue ? oTrail.Amount.Value.ToString(CultureInfo.InvariantCulture) : "no value",
                    Decision
                    );

                AddNote(sMsg);

                if (!bQuiet)
                {
                    this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    SendExplanationMail(oTrail, sMsg);
                }         // if
            }             // if

            if (Length != oTrail.Length)
            {
                string sMsg = string.Format(
                    "Different number of steps in the trail: {0} in this vs {1} in the second.",
                    Length, oTrail.Length
                    );

                AddNote(sMsg);

                if (!bQuiet)
                {
                    this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    SendExplanationMail(oTrail, sMsg);
                }                 // if

                return(false);
            }             // if

            for (int i = 0; i < Length; i++)
            {
                ATrace oMyTrace    = this.m_oSteps[i];
                ATrace oOtherTrace = oTrail.m_oSteps[i];

                if (oMyTrace.GetType() != oOtherTrace.GetType())
                {
                    bResult = false;

                    string sMsg = string.Format(
                        "Different checks for '{3}' encountered on step {0}: {1} in this vs {2} in the second.",
                        i + 1,
                        oMyTrace.GetType().Name,
                        oOtherTrace.GetType().Name,
                        Decision
                        );

                    AddNote(sMsg);

                    if (!bQuiet)
                    {
                        this.m_oLog.Warn("Trails are different: {0}", sMsg);
                    }
                }
                else if (oMyTrace.DecisionStatus != oOtherTrace.DecisionStatus)
                {
                    if (!oMyTrace.AllowMismatch)
                    {
                        bResult = false;
                    }

                    string sMsg = string.Format(
                        "Different conclusions for '{4}' have been reached on step {0} - {1}: " +
                        "{2} in the first vs {3} in the second.",
                        i + 1,
                        oMyTrace.GetType().Name,
                        oMyTrace.DecisionStatus,
                        oOtherTrace.DecisionStatus,
                        Decision
                        );

                    AddNote(sMsg);

                    if (!bQuiet)
                    {
                        this.m_oLog.Warn("Trails are different: {0}", sMsg);
                        SendExplanationMail(oTrail, sMsg);
                    }             // if
                }                 // if
                else if (oMyTrace.HasLockedDecision != oOtherTrace.HasLockedDecision)
                {
                    if (!oMyTrace.AllowMismatch)
                    {
                        bResult = false;
                    }

                    string sMsg = string.Format(
                        "Different conclusions for '{4}' decision lock have been reached on step {0} - {1}: " +
                        "{2} in the first vs {3} in the second.",
                        i + 1,
                        oMyTrace.GetType().Name,
                        oMyTrace.HasLockedDecision ? "locked" : "not locked",
                        oOtherTrace.HasLockedDecision ? "locked" : "not locked",
                        Decision
                        );

                    AddNote(sMsg);

                    if (!bQuiet)
                    {
                        this.m_oLog.Warn("Trails are different: {0}", sMsg);
                        SendExplanationMail(oTrail, sMsg);
                    }     // if
                }         // if
            }             // for

            return(bResult);
        }         // EqualsTo