public override void Execute() { var getAvailableFunds = new GetAvailableFunds(); getAvailableFunds.Execute(); decimal availableFunds = getAvailableFunds.AvailableFunds; var today = DateTime.UtcNow; int relevantLimit = (today.DayOfWeek == DayOfWeek.Thursday || today.DayOfWeek == DayOfWeek.Friday) ? CurrentValues.Instance.PacnetBalanceWeekendLimit : CurrentValues.Instance.PacnetBalanceWeekdayLimit; Log.Info("AvailableFunds:{0} Required:{1} Deducted:{2}", availableFunds, relevantLimit, deductAmount); if (availableFunds - deductAmount < relevantLimit) { HasEnoughFunds = false; SendMail(availableFunds - deductAmount, relevantLimit); } } // Execute
} // Name public override void Execute() { var availableFunds = new GetAvailableFunds(); availableFunds.Execute(); var availFunds = availableFunds.AvailableFunds; var openOffers = availableFunds.ReservedAmount; var remainingFunds = availableFunds.AvailableFunds - availableFunds.ReservedAmount; switch (this.contentCase) { case 1: this.content = String.Format("Please make a transfer for {0} to Pacnet. \nAvailable funds: {1}; \nOpenoffers: {2}; \nRemaining funds: {3}", FormattingUtils.FormatPoundsNoDecimals(this.amount), FormattingUtils.FormatPoundsNoDecimals(availFunds), FormattingUtils.FormatPoundsNoDecimals(openOffers), FormattingUtils.FormatPoundsNoDecimals(remainingFunds)); break; case 2: this.content = String.Format("There is no confirmation from Pacnet regarding money transfer of {0} for more than an hour.", FormattingUtils.FormatPoundsNoDecimals(this.amount)); break; } if (string.IsNullOrEmpty(this.content)) { Log.Info("Empty content message is not sent"); return; } List <string> emails = new List <string>(); DB.ForEachRowSafe((sr, bRowsetStart) => { if (!string.IsNullOrEmpty(sr["SendMobilePhone"]) && !CurrentValues.Instance.SmsTestModeEnabled) { Log.Info("UW sending sms to top-up phone number {0}\n content {1}", sr["SendMobilePhone"], this.content); new SendSms(null, this.underwriterId, sr["SendMobilePhone"], this.content, sr["PhoneOriginIsrael"]).Execute(); } ; if (!string.IsNullOrEmpty(sr["email"])) { emails.Add(sr["email"]); } return(Database.ActionResult.Continue); }, "GetTopUpReceivers", CommandSpecies.StoredProcedure); SendEmail(emails); }
public override void Execute() { Result = string.Empty; try { var instance = new GetAvailableFunds(); instance.Execute(); decimal availableFunds = instance.AvailableFunds; SafeReader sr = DB.GetFirst("GetCustomerDetailsForStateCalculation", CommandSpecies.StoredProcedure, new QueryParameter("CustomerId", this.customerID)); int minLoanAmount = CurrentValues.Instance.MinLoan; int xMinLoanAmount = CurrentValues.Instance.XMinLoan; int numOfActiveLoans = sr["NumOfActiveLoans"]; bool isTest = sr["IsTest"]; string creditResult = sr["CreditResult"]; string status = sr["Status"]; bool isEnabled = sr["IsEnabled"]; bool hasLateLoans = sr["HasLateLoans"]; DateTime offerStart = sr["ApplyForLoan"]; DateTime offerValidUntil = sr["ValidFor"]; bool hasFunds = isTest ? availableFunds >= xMinLoanAmount : availableFunds >= minLoanAmount; bool blockTakingLoan = sr["BlockTakingLoan"]; bool canTakeAnotherLoan = numOfActiveLoans < (int)CurrentValues.Instance.NumofAllowedActiveLoans; if (!isEnabled || !canTakeAnotherLoan) { Result = "disabled"; } else if (hasLateLoans) { Result = "late"; } else if (string.IsNullOrEmpty(creditResult) || creditResult == "WaitingForDecision" || blockTakingLoan) { Result = "wait"; } else if (status == "Rejected") { Result = "bad"; } else if (status == "Manual") { Result = "wait"; } else if (hasFunds && DateTime.UtcNow >= offerStart && DateTime.UtcNow <= offerValidUntil && status == "Approved") { Result = "get"; } else if (hasFunds && DateTime.UtcNow < offerStart && offerStart < offerValidUntil && status == "Approved") { Result = "wait"; } else if (!hasFunds || DateTime.UtcNow > offerValidUntil) { Result = "apply"; } } catch (Exception e) { Log.Error("Exception occurred during calculation of customer's state. The exception:{0}", e); } }