Exemplo n.º 1
0
        public void MakeDecision()
        {
            using (Trail.AddCheckpoint(ProcessCheckpoints.OldWayFlow)) {
                this.oldWayAgent.MakeDecision(this.oldWayAgent.GetRejectionInputData(this.args.Now));
                this.oldWayAgent.Trail.Save(DB, null, TrailPrimaryStatus.OldVerification);
            }             // old way step

            using (Trail.AddCheckpoint(ProcessCheckpoints.GatherData))
                GatherData();

            using (Trail.AddCheckpoint(ProcessCheckpoints.MakeDecision)) {
                Log.Debug("Secondary LG: checking auto reject for customer {0}...", this.args.CustomerID);

                if (Trail.MyInputData.AutoDecisionInternalLogic)
                {
                    Output.FlowType = AutoDecisionFlowTypes.Internal;
                    StepNoDecision <InternalFlow>().Init();
                    Trail.AppendOverridingResults(this.oldWayAgent.Trail);
                    return;
                }
                else
                {
                    Output.FlowType = AutoDecisionFlowTypes.LogicalGlue;
                    StepNoDecision <LogicalGlueFlow>().Init();
                }                 // if

                bool noLgData =
                    (Trail.MyInputData.RequestID == null) ||
                    (Trail.MyInputData.ResponseHttpStatus != (int)HttpStatusCode.OK);

                if (noLgData)
                {
                    StepNoDecision <LGDataFound>().Init(false);
                    StepNoDecision <InternalFlow>().Init();
                    Trail.AppendOverridingResults(this.oldWayAgent.Trail);
                    return;
                }
                else
                {
                    StepNoDecision <LGDataFound>().Init(true);
                }

                if (Trail.MyInputData.ResponseErrors.Count > 0)
                {
                    Output.ErrorInLGData = true;
                    StepNoReject <LGWithoutError>(true).Init(false);
                }
                else
                {
                    Output.ErrorInLGData = false;
                    StepNoDecision <LGWithoutError>().Init(true);
                }                 // if

                if (Trail.MyInputData.HardReject)
                {
                    StepReject <LGHardReject>(true).Init(true);
                }
                else
                {
                    StepNoDecision <LGHardReject>().Init(false);
                }

                if (Trail.MyInputData.Bucket == null)
                {
                    StepNoReject <HasBucket>(true).Init(false);
                }
                else
                {
                    StepNoDecision <HasBucket>().Init(true);
                }

                int rangesCount = Trail.MyInputData.MatchingGradeRanges.Count;

                if (rangesCount < 1)
                {
                    StepReject <OfferConfigurationFound>(true).Init(0);
                    return;
                }                 // if

                if (rangesCount > 1)
                {
                    StepNoReject <OfferConfigurationFound>(true).Init(rangesCount);

                    Log.Alert(
                        "Too many configurations found for a {0} customer {1}, " +
                        "score {2}, origin {3}, company is {4}regulated, loan source {5}.",
                        Trail.MyInputData.LoanCount > 0 ? "returning" : "new",
                        this.args.CustomerID,
                        Trail.MyInputData.Score == null ? "'N/A'" : Trail.MyInputData.Score.ToString(),
                        Trail.MyInputData.CustomerOrigin == null
                                                        ? "'N/A'"
                                                        : Trail.MyInputData.CustomerOrigin.Value.ToString(),
                        Trail.MyInputData.CompanyIsRegulated ? string.Empty : "non-",
                        Trail.MyInputData.LoanSource == null ? "'N/A'" : Trail.MyInputData.LoanSource.Value.ToString()
                        );

                    return;
                }                 // if

                StepNoDecision <OfferConfigurationFound>().Init(1);

                MatchingGradeRanges.SubproductGradeRange spgr = Trail.MyInputData.MatchingGradeRanges.First();

                Output.GradeRangeID     = spgr.GradeRangeID;
                Output.ProductSubTypeID = spgr.ProductSubTypeID;

                Trail.DecideIfNotDecided();
            }     // using
        }         // MakeDecision
Exemplo n.º 2
0
        }         // GatherData

        private void LogicalGlueFlow()
        {
            Output.FlowType = AutoDecisionFlowTypes.LogicalGlue;

            if ((Trail.MyInputData.RequestID == null) || (Trail.MyInputData.ResponseHttpStatus != (int)HttpStatusCode.OK))
            {
                Trail.Dunno <LGDataFound>().Init(false);
                Trail.Dunno <InternalFlow>().Init();
                InternalFlow();
                return;
            }
            else
            {
                Trail.Dunno <LGDataFound>().Init(true);
            }

            if (Trail.MyInputData.ResponseErrors.Count > 0)
            {
                Output.ErrorInLGData = true;
                Trail.Negative <LGWithoutError>(true).Init(false);
            }
            else
            {
                Output.ErrorInLGData = false;
                Trail.Dunno <LGWithoutError>().Init(true);
            }             // if

            if (Trail.MyInputData.HardReject)
            {
                Trail.Affirmative <LGHardReject>(true).Init(true);
            }
            else
            {
                Trail.Dunno <LGHardReject>().Init(false);
            }

            if (Trail.MyInputData.Bucket == null)
            {
                Trail.Negative <HasBucket>(true).Init(false);
            }
            else
            {
                Trail.Dunno <HasBucket>().Init(true);
            }

            if (Trail.MyInputData.MatchingGradeRanges.Count < 1)
            {
                Trail.Affirmative <OfferConfigurationFound>(true).Init(0);
            }
            else if (Trail.MyInputData.MatchingGradeRanges.Count > 1)
            {
                Trail.Negative <OfferConfigurationFound>(true).Init(Trail.MyInputData.MatchingGradeRanges.Count);

                Log.Alert(
                    "Too many grade range + product subtype pairs found for a {0} customer {1}, " +
                    "score {2}, origin {3}, company is {4}regulated, loan source {5}.",
                    Trail.MyInputData.LoanCount > 0 ? "returning" : "new",
                    this.args.CustomerID,
                    Trail.MyInputData.Score == null ? "'N/A'" : Trail.MyInputData.Score.ToString(),
                    Trail.MyInputData.CustomerOrigin == null ? "'N/A'" : Trail.MyInputData.CustomerOrigin.Value.ToString(),
                    Trail.MyInputData.CompanyIsRegulated ? string.Empty : "non-",
                    Trail.MyInputData.LoanSource == null ? "'N/A'" : Trail.MyInputData.LoanSource.Value.ToString()
                    );
            }
            else
            {
                Trail.Dunno <OfferConfigurationFound>().Init(1);

                MatchingGradeRanges.SubproductGradeRange spgr = Trail.MyInputData.MatchingGradeRanges[0];

                Output.GradeRangeID     = spgr.GradeRangeID;
                Output.ProductSubTypeID = spgr.ProductSubTypeID;
            }             // if

            Trail.DecideIfNotDecided();
        }         // LogicalGlueFlow