예제 #1
0
파일: Engine.cs 프로젝트: vijayamazon/ezbob
        }         // GetMonthlyRepayment

        public MonthlyRepaymentData GetMonthlyRepaymentData(int customerID, DateTime now)
        {
            string nowStr = now.ToString("d/MMM/yyyy H:mm:ss", CultureInfo.InvariantCulture);

            Log.Debug("Engine.GetMonthlyRepaymentData({0}, {1}) started...", customerID, nowStr);

            InferenceInputPackage inputPkg = Keeper.LoadInputData(customerID, Now, true);

            Log.Debug("Engine.GetMonthlyRepaymentData({0}, {1}) retrieved input package.", customerID, nowStr);

            return(new MonthlyRepaymentData {
                RequestedAmount = inputPkg.InferenceInput.RequestedAmount,
                RequestedTerm = inputPkg.InferenceInput.RequestedTerm,
                MonthlyRepayment = inputPkg.InferenceInput.MonthlyPayment ?? 0,
            });
        }         // GetMonthlyRepaymentData
예제 #2
0
        protected override ActionOutcomes ActionToRetry(int attemptNumber)
        {
            Result = null;

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) started...",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            InferenceInputPackage inputPkg = this.keeper.LoadInputData(this.customerID, this.now, false);

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) retrieved input package.",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            if (this.explicitMonthlyPayment > 0)
            {
                inputPkg.InferenceInput.MonthlyPayment = this.explicitMonthlyPayment;
            }

            List <string> errors = inputPkg.InferenceInput.Validate();

            if (errors != null)
            {
                Log.Warn(
                    "Cannot query Logical Glue for customer {0} due to errors in the input data:\n\t{1}",
                    this.customerID,
                    string.Join("\n\t", errors)
                    );
                return(ActionOutcomes.Fatal);
            }             // if

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) input package is valid.",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            long requestID = this.keeper.SaveInferenceRequest(
                this.customerID,
                inputPkg.CompanyID,
                this.isTryOut,
                inputPkg.InferenceInput
                );

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) input package has been stored.",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            Response <Reply> reply = this.harvester.Infer(inputPkg.InferenceInput, this.keeper.LoadHarvesterConfiguration());

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) reply received.",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            Result = this.keeper.SaveInference(this.customerID, requestID, reply);

            Log.Debug(
                "Engine.DownloadAndSave({0}, {1}, {2}, {3}) complete.",
                attemptNumber, this.customerID, this.explicitMonthlyPayment, this.isTryOut
                );

            return((Result != null) && (Result.Status != null) && (Result.Status.HttpStatus == HttpStatusCode.OK)
                                ? ActionOutcomes.Done
                                : ActionOutcomes.Retry);
        }         // ActionToRetry