コード例 #1
0
ファイル: AStrategy.cs プロジェクト: vijayamazon/ezbob
        }         // FireToBackground

        protected void FireToBackground(string description, Action task, Action <Exception> onFailedToExecute = null)
        {
            if (task == null)
            {
                return;
            }

            string taskID = Guid.NewGuid()
                            .ToString("N");

            ASafeLog log = Log;

            log.Debug("Starting background task '{1}' with id '{0}'...", taskID, description);

            try {
                Task.Run(() => {
                    try {
                        task();

                        log.Debug("Background task '{1}' (id: '{0}') completed successfully.", taskID, description);
                    } catch (Exception e) {
                        log.Alert(e, "Background task '{1}' (id: '{0}') failed.", taskID, description);
                    }                     // try
                });
            } catch (Exception e) {
                Log.Alert(e, "Failed to fire task '{1}' (id: '{0}') to background.", taskID, description);

                if (onFailedToExecute != null)
                {
                    onFailedToExecute(e);
                }
            }     // try
        }         // FireToBackground
コード例 #2
0
        public void UploadDoc(string description, int customerId)
        {
            var files = Request.Files;

            if (files.Count == 0)
            {
                string sError = string.Format("No files received for customer {0}.", customerId);
                Log.Debug("{0}", sError);
                throw new Exception(sError);
            }     // if

            OneUploadLimitation oLimitations = CurrentValues.Instance.GetUploadLimitations("AlertDocsController", "UploadDoc");

            var oErrors = new List <string>();

            for (int i = 0; i < files.Count; i++)
            {
                var file = Request.Files[i];

                if (file == null)
                {
                    string sError = string.Format("File #{0} for customer {1} is null.", i, customerId);
                    Log.Debug("{0}", sError);
                    oErrors.Add(sError);
                    continue;
                }         // if

                var body = new byte[file.InputStream.Length];
                file.InputStream.Read(body, 0, file.ContentLength);

                if (string.IsNullOrWhiteSpace(oLimitations.DetectFileMimeType(body, file.FileName)))
                {
                    string sError = string.Format("File #{0} for customer {1} cannot be accepted due to its MIME type.", i, customerId);
                    Log.Debug("{0}", sError);
                    oErrors.Add(sError);
                    continue;
                }         // if

                var customerRepo = ObjectFactory.GetInstance <CustomerRepository>();
                var customer     = customerRepo.Get(customerId);
                var doc          = new MP_AlertDocument {
                    BinaryBody  = body,
                    Customer    = customer,
                    Employee    = _context.User,
                    Description = description,
                    UploadDate  = DateTime.UtcNow,
                    DocName     = file.FileName
                };

                _docRepo.SaveOrUpdate(doc);
            }

            if (oErrors.Count > 0)
            {
                throw new Exception(string.Join(" ", oErrors));
            }
        }
コード例 #3
0
        private static void TestUiReportExt(AConnection oDB, ASafeLog log)
        {
            var rpt = new UiReportExt(oDB, new DateTime(2013, 12, 23), new DateTime(2013, 12, 31), log)
            {
                VerboseLogging = true
            };

            rpt.Run();

            log.Debug("Report start");

            log.Debug("Report end");
        }
コード例 #4
0
        private static void TestTableSpArgument(AConnection oDB, ASafeLog oLog)
        {
            oDB.LogVerbosityLevel = LogVerbosityLevel.Verbose;

            var lst = new List <ConfigTable> {
                new ConfigTable {
                    Start = 1,
                    End   = 2,
                    Value = 1.2m,
                },
                new ConfigTable {
                    Start = 2,
                    End   = 3,
                    Value = 2.3m,
                },
                new ConfigTable {
                    Start = 3,
                    End   = 4,
                    Value = 3.4m,
                },
                new ConfigTable {
                    Start = 4,
                    End   = 5,
                    Value = 4.5m,
                },
                new ConfigTable {
                    Start = 5,
                    End   = 6,
                    Value = 5.6m,
                },
            };

            oLog.Debug("Results - begin:");

            oDB.ForEachRowSafe(
                (sr, bRowsetStart) => {
                oLog.Debug("Returned value: {0}, {1}, {2}", (int)sr[0], (int)sr[1], (decimal)sr[2]);
                return(ActionResult.Continue);
            },
                "TestIntIntDecimalListType",
                CommandSpecies.StoredProcedure,
                oDB.CreateTableParameter <ConfigTable>("@TheList", lst, objbir => {
                var bir = (ConfigTable)objbir;
                return(new object[] {
                    bir.Start, bir.End, bir.Value,
                });
            })
                );

            oLog.Debug("Results - end");
        }
コード例 #5
0
ファイル: TypeUtils.cs プロジェクト: vijayamazon/ezbob
        }         // FindType

        private static Type PureFindType(string sName, Assembly asm, bool bHasDot, ASafeLog oLog)
        {
            Type[] aryTypes;

            oLog = oLog.Safe();

            try {
                aryTypes = asm.GetTypes();
            }
            catch (ReflectionTypeLoadException rtle) {
                oLog.Alert(rtle, "Failed to retrieve types list of assembly '{0}' while looking for '{1}'.", asm.FullName, sName);

                if ((rtle.LoaderExceptions != null) && (rtle.LoaderExceptions.Length > 0))
                {
                    oLog.Debug("ReflectionTypeLoadException.LoaderExceptions - begin");

                    for (int i = 0; i < rtle.LoaderExceptions.Length; i++)
                    {
                        oLog.Debug(rtle.LoaderExceptions[i], "Inner exception #{0}.", i);
                    }

                    oLog.Debug("ReflectionTypeLoadException.LoaderExceptions - end.");
                }                 // if

                return(null);
            }
            catch (Exception e) {
                oLog.Alert(e, "Failed to retrieve types list of assembly '{0}' while looking for '{1}'.", asm.FullName, sName);
                return(null);
            }             // try

            foreach (Type t in aryTypes)
            {
                if (bHasDot)
                {
                    if ((t.AssemblyQualifiedName ?? string.Empty).StartsWith(sName))
                    {
                        return(t);
                    }
                }
                else
                {
                    if (t.Name.EndsWith(sName))
                    {
                        return(t);
                    }
                }         // if
            }             // for each type

            return(null);
        }         // PureFindType
コード例 #6
0
        private static void TestExperianLimitedCompanyData(AConnection oDB, ASafeLog log)
        {
            var rpt = new ExperianLimitedCompanyData(oDB, log);

            rpt.VerboseLogging = true;

            Tuple <List <ExperianLimitedCompanyReportItem>, SortedSet <string> > oOutput = rpt.Run();

            log.Debug("Report start");

            ExperianLimitedCompanyData.ToOutput(@"c:\temp\dl99.csv", oOutput);

            log.Debug("Report end");
        }
コード例 #7
0
        public void Save(ASafeLog oLog)
        {
            oLog.Debug("FROM CLIENT log package {0} - begin", id);

            if (data != null)
            {
                foreach (var oEvt in data)
                {
                    oEvt.Write(oLog);
                }
            }

            oLog.Debug("FROM CLIENT log package {0} - end", id);
        } // Save
コード例 #8
0
        }         // Main

        private static void RunLoanDateScore(AConnection oDB, ASafeLog log)
        {
            var rpt = new LoanDateScore(oDB, log)
            {
                VerboseLogging = true
            };

            rpt.Run();

            log.Debug("Report start");

            rpt.ToOutput(@"c:\temp\loan_date_score.csv");

            log.Debug("Report end");
        }         // RunLoanDateScore
コード例 #9
0
        private static void LoadFromDBThread()
        {
            bool      bStop            = false;
            const int nStep            = 100;
            int       nRefreshInterval = CurrentValues.Instance.AvailableFundsRefreshInterval;

            for ( ; ;)
            {
                ms_oLog.Debug("Available funds loader: sleeping...");

                for (int i = 0; i < nRefreshInterval; i += nStep)
                {
                    if (StopBackgroundThread)
                    {
                        bStop = true;
                        break;
                    }                     // if

                    Thread.Sleep(nStep);
                }                 // if

                if (bStop)
                {
                    break;
                }

                LoadFromDB();
                nRefreshInterval = CurrentValues.Instance.AvailableFundsRefreshInterval;
            } // forever
        }     // LoadFromDBThread
コード例 #10
0
        }         // constructor

        public Request(RequestTypes requestType, DateTime time, ASafeLog log)
        {
            RequestType = requestType;
            Time        = time;

            log.Debug("New request created: {0}", this);
        }         // constructor
コード例 #11
0
ファイル: Default.aspx.cs プロジェクト: vijayamazon/ezbob
        }         // AdjustUIFiltersForReport

        protected void btnShowReport_Click(object sender, EventArgs e)
        {
            bool isDaily;

            ReportQuery rptDef = CreateReportQuery(out isDaily);

            var oColumnTypes = new List <string>();

            Log.Debug("Show report clicked for report: '{0}'", ddlReportTypes.SelectedItem.Text);

            bool isError;
            ATag data = reportHandler.GetReportData(ddlReportTypes.SelectedItem.Text, rptDef, isDaily, oColumnTypes, out isError);

            if (isError)
            {
                ResetBtn_Click(sender, e);
            }

            var aoColumnDefs = oColumnTypes.Select(
                sType => string.Format("{{ \"sType\": \"{0}\" }}", sType)
                ).ToList();

            divReportColumnTypes.Controls.Add(new LiteralControl(
                                                  "[" + string.Join(", ", aoColumnDefs) + "]"
                                                  ));

            var reportData = new LiteralControl(data.ToString());

            divReportData.Controls.Add(reportData);
        }         // btnShowReport_Click
コード例 #12
0
        private void SetWebSiteUploadLimitation(Microsoft.Web.Administration.Configuration oConfig, int nUploadLimit, string sControllerAction)
        {
            try {
                ConfigurationSection requestFilteringSection = string.IsNullOrWhiteSpace(sControllerAction)
                                        ? oConfig.GetSection(SectionPath)
                                        : oConfig.GetSection(SectionPath, sControllerAction);

                ConfigurationElement requestLimitsElement = requestFilteringSection.GetChildElement(ElementName);

                requestLimitsElement.SetAttributeValue(AttributeName, nUploadLimit);

                m_oLog.Debug("Updated upload limit to '{0}' for action '{1}'.", nUploadLimit, sControllerAction);
            }
            catch (Exception e) {
                m_oLog.Warn(e, "Failed to update upload limit to '{0}' for action '{1}'.", nUploadLimit, sControllerAction);
            }     // try
        }         // SetWebSiteUploadLimitation
コード例 #13
0
        private static void TestUiReport(AConnection oDB, ASafeLog log)
        {
            var rpt = new UiReport(oDB, new DateTime(2013, 12, 1), new DateTime(2013, 12, 10), log);

            rpt.VerboseLogging = true;

            List <UiReportItem> oOutput = rpt.Run();

            log.Debug("Report start");

            foreach (UiReportItem oItem in oOutput)
            {
                log.Debug(oItem.ToString());
            }

            log.Debug("Report end");
        }
コード例 #14
0
        }         // GetInstance

        public static Configuration GetInstance(ASafeLog oLog = null)
        {
            lock (typeof(Configuration)) {
                if (ms_oConfiguration != null)
                {
                    return(ms_oConfiguration);
                }

                var oPaths = new List <string>();

                oLog = oLog.Safe();

                foreach (System.Environment.SpecialFolder nFld in new [] {
                    System.Environment.SpecialFolder.ApplicationData,
                    System.Environment.SpecialFolder.CommonProgramFiles,
                    System.Environment.SpecialFolder.CommonProgramFilesX86,
                    System.Environment.SpecialFolder.ProgramFiles,
                    System.Environment.SpecialFolder.ProgramFilesX86
                })
                {
// ReSharper disable EmptyGeneralCatchClause
                    try {
                        oPaths.Add(Path.Combine(System.Environment.GetFolderPath(nFld), CompanyName));
                    }
                    catch (Exception) {
                        // silently ignore
                    }                     // try
// ReSharper restore EmptyGeneralCatchClause
                }

                foreach (var sDir in oPaths)
                {
                    string sFileContent;

                    try {
                        var sFilePath = Path.Combine(sDir, EnvNameFile);

                        oLog.Debug("Trying to load Channel Grabber configuration from {0}", sFilePath);

                        if (!File.Exists(sFilePath))
                        {
                            continue;
                        }

                        sFileContent = File.ReadAllText(sFilePath);
                    }
                    catch (Exception e) {
                        oLog.Error("Failed to read Channel Grabber configuration: {0}", e.Message);
                        continue;
                    }                     // try

                    ms_oConfiguration = new Configuration(sFileContent, oLog);
                    return(ms_oConfiguration);
                }         // for each
            }             // lock

            throw new ConfigException("Failed to load Channel Grabber configuration.");
        }         // GetInstance
コード例 #15
0
        private static void TestVectorSpArgument(AConnection oDB, ASafeLog oLog)
        {
            oDB.LogVerbosityLevel = LogVerbosityLevel.Verbose;

            oLog.Debug("Results - begin:");

            oDB.ForEachRowSafe(
                (sr, bRowsetStart) => {
                oLog.Debug("Returned value: {0}", (int)sr[0]);
                return(ActionResult.Continue);
            },
                "TestIntListType",
                CommandSpecies.StoredProcedure,
                oDB.CreateVectorParameter <int>("@TheList", 1, 2, 2, 2, 5, 5, 38, 1)
                );

            oLog.Debug("Results - end");
        }
コード例 #16
0
        }         // ReturnDetails

        public void Set(Field f, dynamic oValue, ASafeLog oLog = null)
        {
            this.properties[f] = oValue;

            if (oLog != null)
            {
                oLog.Debug("VatReturnSeeds.{0} := {1}", f, (oValue == null) ? "-- null --" : oValue.ToString());
            }
        }         // Set
コード例 #17
0
ファイル: Program.cs プロジェクト: vijayamazon/ezbob
        }         // IsNormalMode

        private static void SendReport(DateTime oDate, ASafeLog oLog)
        {
            oLog.Debug("Generating reconciliation report...");

            var oDB = new SqlConnection();

            oLog.Debug("Loading Pacnet report metadata from db...");

            var pacnet = new Report(oDB, "RPT_PACNET_RECONCILIATION");

            oLog.Debug("Loading Paypoint report metadata from db...");

            var paypoint = new Report(oDB, "RPT_PAYPOINT_RECONCILIATION");

            var rh = new BaseReportHandler(oDB, oLog);

            var sender = new ReportDispatcher(oDB, oLog);

            var email = new ReportEmail();

            oLog.Debug("Generating Pacnet report...");

            email.ReportBody.Append(new H2().Append(new Text(pacnet.GetTitle(oDate))));

            email.ReportBody.Append(
                rh.TableReport(new ReportQuery(pacnet, oDate, oDate))
                );

            oLog.Debug("Generating Paypoint report...");

            email.ReportBody.Append(new H2().Append(new Text(paypoint.GetTitle(oDate))));

            email.ReportBody.Append(
                rh.TableReport(new ReportQuery(paypoint, oDate, oDate))
                );

            var sTo = new StringBuilder();

            sTo.Append(pacnet.ToEmail);

            if (pacnet.ToEmail != "")
            {
                sTo.Append(",");
            }

            sTo.Append(paypoint.ToEmail);

            oLog.Debug("Sending report...");

            sender.Dispatch(
                "Reconciliation " + oDate.ToString("MMMM d yyyy", CultureInfo.InvariantCulture),
                oDate,
                email.HtmlBody,
                null,
                sTo.ToString()
                );

            oLog.Debug("Reconciliation report generation complete.");
        }         // SendReport
コード例 #18
0
            public void Calculate(int customerID, bool isHomeOwner, AConnection db, ASafeLog log)
            {
                var instance = new CalculateMedal(customerID, DecisionTime, true, false);

                instance.Execute();

                log.Debug("Before capping the offer: {0}", instance.Result);

                int amount = Math.Min(
                    instance.Result.RoundOfferedAmount(),
                    isHomeOwner
                                                ? CurrentValues.Instance.MaxCapHomeOwner
                                                : CurrentValues.Instance.MaxCapNotHomeOwner
                    );

                var approveAgent = new AutomationCalculator.AutoDecision.AutoApproval.ManAgainstAMachine.SameDataAgent(
                    customerID,
                    amount,
                    (AutomationCalculator.Common.Medal)instance.Result.MedalClassification,
                    (AutomationCalculator.Common.MedalType)instance.Result.MedalType,
                    (AutomationCalculator.Common.TurnoverType?)instance.Result.TurnoverType,
                    DecisionTime,
                    db,
                    log
                    ).Init();

                approveAgent.MakeDecision();

                Amount   = amount;
                Decision = approveAgent.Trail.GetDecisionName();

                if (amount == 0)
                {
                    RepaymentPeriod = 0;
                    InterestRate    = 0;
                    SetupFee        = 0;
                }
                else
                {
                    var odc = new OfferDualCalculator(
                        customerID,
                        DecisionTime,
                        amount,
                        LoanCount > 0,
                        instance.Result.MedalClassification
                        );

                    odc.CalculateOffer();

                    RepaymentPeriod = odc.VerifyBoundaries.RepaymentPeriod;
                    InterestRate    = odc.VerifyBoundaries.InterestRate / 100.0m;
                    SetupFee        = odc.VerifyBoundaries.SetupFee / 100.0m;
                }         // if
            }             // Calculate
コード例 #19
0
        private void ParseLeadData(string sLeadData)
        {
            sLeadData = sLeadData ?? string.Empty;

            ms_oLog.Debug("Raw lead data is: '{0}'.", sLeadData);

            string[] aryPairs = sLeadData.Split(';');

            foreach (string sPair in aryPairs)
            {
                if (string.IsNullOrWhiteSpace(sPair))
                {
                    continue;
                }

                int nPos = sPair.IndexOf(':');

                if (nPos < 0)
                {
                    continue;
                }

                string sDatumName = sPair.Substring(0, nPos);

                if (string.IsNullOrWhiteSpace(sDatumName))
                {
                    continue;
                }

                string sDatumValue = sPair.Substring(nPos + 1);

                Response.Cookies.Add(new HttpCookie("lead-datum-" + sDatumName, Url.Encode(sDatumValue))
                {
                    Expires  = DateTime.Now.AddMonths(3),
                    HttpOnly = false,
                    Secure   = true,
                });

                ms_oLog.Debug("Lead datum set: {0} = '{1}'.", sDatumName, sDatumValue);
            } // for each pair
        }     // ParseLeadData
コード例 #20
0
ファイル: Harvester.cs プロジェクト: vijayamazon/ezbob
        private static Hopper FetchBackdoorData(int nCustomerMarketplaceID, ASafeLog log)
        {
            log.Debug("Harvester: fetching back-door data for marketplace {0}...", nCustomerMarketplaceID);

            Hopper oBackdoorData;

            lock (typeof(Harvester)) {
                if ((ms_oBackdoorData == null) || !ms_oBackdoorData.ContainsKey(nCustomerMarketplaceID))
                {
                    log.Debug("Harvester: no back-door data found for marketplace {0}.", nCustomerMarketplaceID);
                    log.Debug("Harvester: fetching back-door data for marketplace {0} complete.", nCustomerMarketplaceID);
                    return(null);
                }                 // if

                oBackdoorData = ms_oBackdoorData[nCustomerMarketplaceID];

                ms_oBackdoorData.Remove(nCustomerMarketplaceID);
            }             // lock

            log.Debug("Harvester: fetching back-door data for marketplace {0} complete.", nCustomerMarketplaceID);
            return(oBackdoorData);
        }         // FetchBackdoorData
コード例 #21
0
        private static void TestBadPeriods(AConnection oDB, ASafeLog oLog)
        {
            oDB.LogVerbosityLevel = LogVerbosityLevel.Verbose;

            var bp = new BadPeriods(new DateTime(2001, 2, 12));

            bp.Add(new DateTime(2002, 3, 13), false);
            bp.Add(new DateTime(2002, 4, 18), false);
            bp.Add(new DateTime(2005, 5, 13), true);
            bp.Add(new DateTime(2006, 5, 13), false);

            oLog.Debug("{0}", bp);
        }
コード例 #22
0
        }         // Main

        private static RequestedTransactionsLibrary LoadRequested(string sDataFileName, ASafeLog log)
        {
            var oResult = new RequestedTransactionsLibrary(log);

            log.Debug("Loading requested transactions from {0}", sDataFileName);

            string[] aryFile = File.ReadAllLines(sDataFileName);

            foreach (var sLine in aryFile)
            {
                if (string.IsNullOrWhiteSpace(sLine))
                {
                    continue;
                }

                oResult.Add(sLine);
            }             // for each line

            log.Debug("Loading requested transactions from {0} complete, {1} entries found", sDataFileName, oResult.Count);

            return(oResult);
        } // LoadRequested
コード例 #23
0
        }         // Validate

        public void Log(ASafeLog log)
        {
            if (log == null)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat("\nGroup\n\tName: {0}\n\tPath to parent: {1}\n\tFields:\n", Name, PathToParent);

            Fields.ForEach(f => f.Log(sb, "\t\t"));

            log.Debug(sb.ToString());
        }         // Log
コード例 #24
0
ファイル: TurnoverDbRow.cs プロジェクト: vijayamazon/ezbob
        }         // MonthCount

        /// <summary>
        /// The write to log.
        /// </summary>
        /// <param name="oLog">The o log.</param>
        public void WriteToLog(ASafeLog oLog)
        {
            if (oLog == null)
            {
                return;
            }

            oLog.Debug(
                "One month turnover for customer marketplace {0} ('{1}'...'{2}' - {3}) - mp id {4} ({5}) of type {7} ({6})",
                this.Turnover,
                this.TheMonth.ToString("MMM yyyy", CultureInfo.InvariantCulture),
                this.CurrentMonth.ToString("d/MMM/yyyy", CultureInfo.InvariantCulture),
                Grammar.Number(this.Distance, "month"),
                this.MpID,
                this.IsPaymentAccount ? "payment account" : "online marketplace",
                this.MpTypeID,
                this.MpTypeName
                );
        } // WriteToLog
コード例 #25
0
        public Request(char requestType, DateTime time, ASafeLog log)
        {
            switch (requestType)
            {
            case 'N':
                RequestType = RequestTypes.NonLimited;
                break;

            case 'L':
                RequestType = RequestTypes.Limited;
                break;

            case 'B':
                RequestType = RequestTypes.Targeting;
                break;
            }             // switch

            Time = time;

            log.Debug("New request created: {0}", this);
        }         // constructor
コード例 #26
0
ファイル: LoanData.cs プロジェクト: vijayamazon/ezbob
        public void SaveTo(string basePath, ASafeLog log)
        {
            string fullDirName = Path.Combine(basePath, LoanID);

            if (!Directory.Exists(fullDirName))
            {
                Directory.CreateDirectory(fullDirName);
                log.Debug("Created directory for loan {0}: {1}", LoanID, fullDirName);
            }
            else
            {
                log.Debug("Already exists directory for loan {0}: {1}", LoanID, fullDirName);
            }

            ExcelPackage book = new ExcelPackage();

            ExcelWorksheet sheet = book.CreateSheet("Provided data", false, "Name", "Value");

            CustomerData.SaveTo(sheet);

            if (Directors.Count > 0)
            {
                var titles = new List <string> {
                    "Name",
                };

                for (int i = 1; i <= Directors.Count; i++)
                {
                    titles.Add(string.Format("Director #{0}", i));
                }

                sheet = book.CreateSheet("Directors", false, titles.ToArray());

                int column = 2;

                foreach (DirectorData dir in Directors)
                {
                    column = dir.SaveTo(sheet, column);
                }
            }             // if

            if (Crm.Count > 0)
            {
                sheet = CRMData.CreateSheet(book);

                int row = 2;

                foreach (CRMData crm in Crm)
                {
                    row = crm.SaveTo(sheet, row);
                }
            }             // if

            book.AutoFitColumns();

            string fileName = Path.Combine(fullDirName, LoanID + ".xlsx");

            book.SaveAs(new FileInfo(fileName));

            log.Debug("Saved loan file for {0}: {1}", LoanID, fileName);
        } // SaveTo
コード例 #27
0
ファイル: QuickOfferData.cs プロジェクト: vijayamazon/ezbob
        }                                                 // IsValid

        public QuickOfferModel GetOffer(bool bSaveOfferToDB, AConnection oDB, ASafeLog oLog)
        {
            if (RequestedAmount < Cfg.MinOfferAmount)
            {
                oLog.Debug("Requested amount (£{0}) is less than minimal offer amount (£{1}), not offering.", RequestedAmount, Cfg.MinOfferAmount);
                return(null);
            }             // if

            oDB.ForEachRowSafe(
                (sr, bRowsetStart) => {
                minLoanAmount = sr["MinLoanAmount"];
                return(ActionResult.SkipAll);
            },
                "GetBankBasedApprovalConfigs",
                CommandSpecies.StoredProcedure
                );

            decimal?nOffer = Calculate();

            if (!nOffer.HasValue)
            {
                return(null);
            }

            int nOfferID = default(int);

            decimal nRequestedAmount = RequestedAmount.Min(Cfg.PotentialMaxAmount);

            var oOffer = new QuickOfferModel {
                ID                 = nOfferID,
                Amount             = nOffer.Value,
                Aml                = Aml,
                BusinessScore      = BusinessScore,
                IncorporationDate  = IncorporationDate.Value,
                TangibleEquity     = TangibleEquity,
                TotalCurrentAssets = TotalCurrentAssets,

                ImmediateTerm         = Cfg.ImmediateTermMonths,
                ImmediateInterestRate = Cfg.ImmediateInterestRate,
                ImmediateSetupFee     = Cfg.ImmediateSetupFee,

                PotentialAmount       = nRequestedAmount,
                PotentialTerm         = Cfg.PotentialTermMonths,
                PotentialInterestRate = Cfg.LoanPct(BusinessScore, nRequestedAmount),
                PotentialSetupFee     = Cfg.PotentialSetupFee,
            };

            if (bSaveOfferToDB && (Cfg.Enabled != QuickOfferEnabledStatus.Silent))
            {
                try {
                    var oID = new QueryParameter("@QuickOfferID")
                    {
                        Type      = DbType.Int32,
                        Direction = ParameterDirection.Output,
                    };

                    oDB.ExecuteNonQuery(
                        "QuickOfferSave",
                        CommandSpecies.StoredProcedure,
                        new QueryParameter("@Now", DateTime.UtcNow),
                        new QueryParameter("@CustomerID", CustomerID),
                        new QueryParameter("@Amount", oOffer.Amount),
                        new QueryParameter("@Aml", oOffer.Aml),
                        new QueryParameter("@BusinessScore", oOffer.BusinessScore),
                        new QueryParameter("@IncorporationDate", oOffer.IncorporationDate),
                        new QueryParameter("@TangibleEquity", oOffer.TangibleEquity),
                        new QueryParameter("@TotalCurrentAssets", oOffer.TotalCurrentAssets),

                        new QueryParameter("@ImmediateTerm", oOffer.ImmediateTerm),
                        new QueryParameter("@ImmediateInterestRate", oOffer.ImmediateInterestRate),
                        new QueryParameter("@ImmediateSetupFee", oOffer.ImmediateSetupFee),
                        new QueryParameter("@PotentialAmount", oOffer.PotentialAmount),
                        new QueryParameter("@PotentialTerm", oOffer.PotentialTerm),
                        new QueryParameter("@PotentialInterestRate", oOffer.PotentialInterestRate),
                        new QueryParameter("@PotentialSetupFee", oOffer.PotentialSetupFee),
                        oID
                        );

                    if (int.TryParse(oID.SafeReturnedValue, out nOfferID))
                    {
                        oLog.Msg("Quick offer id is {0}", nOfferID);
                        oOffer.ID = nOfferID;
                    }
                    else
                    {
                        oLog.Warn("Failed to parse quick offer id from {0}", oID.Value.ToString());
                    }
                }
                catch (Exception e) {
                    oLog.Alert(e, "Failed to save a quick offer to DB.");
                }         // try
            }             // if

            return(oOffer);
        }         // GetOffer
コード例 #28
0
		} // Application_Start

		protected void Session_Start(object sender, EventArgs e) {
			Log.Debug("Session Start");
		} // Session_Start
コード例 #29
0
ファイル: Program.cs プロジェクト: vijayamazon/ezbob
        /*private static void TestGetSubscribers() {
         *      Campaigns.InitCampaignsList();
         *
         *      foreach (Campaign campaign in Campaigns.CampaignsList) {
         *              List<Subscriber> subscriberList = DbCommands.GetSubscriberList(campaign.CampaignType);
         *              PrintSubscribersList(campaign.Title, subscriberList);
         *      }
         * }
         *
         * static void Tests()
         * {
         * //ms_oLog.Debug((MailChimpApiControler.GetLists())[0].id);
         * //MailChimpApiControler.testSegment();
         * //MailChimpApiControler.printListMergeVars(Constants.LastStepCustomers_ListID);
         * //MailChimpApiControler.testSegment();
         * //MailChimpApiControler.UnsubscribeList((MailChimpApiControler.GetLists())[0].id);
         * //MailChimpApiControler.ListBatchSubscribe((MailChimpApiControler.GetLists())[0].id, MailChimpApiControler.GetTestSubscriberList());
         *
         * //Campaigns.InitCampaignsList();
         * //foreach (Campaign campaign in Campaigns.CampaignsList)
         * //{
         * //    //MailChimpApiControler.Unsubscribe(campaign.ListId, "*****@*****.**");
         * //    //MailChimpApiControler.Unsubscribe(campaign.ListId, "*****@*****.**");
         * //    //MailChimpApiControler.ListBatchSubscribe(campaign.ListId, MailChimpApiControler.GetTestSubscriberList());
         * //    foreach (Day day in campaign.DayList)
         * //    {
         * //        //MailChimpApiControler.testSegment(campaign.ListId, day.TemplateId, day.Condition, campaign.Subject, campaign.Title);
         * //        string campaignId = MailChimpApiControler.CreateSegmentedCampaign(campaign.ListId, day.TemplateId, day.Condition, campaign.Subject, campaign.Title);
         * //        MailChimpApiControler.SendCampaign(campaignId);
         * //    }
         * //    MailChimpApiControler.Unsubscribe(campaign.ListId, "*****@*****.**");
         * //    MailChimpApiControler.Unsubscribe(campaign.ListId, "*****@*****.**");
         * //    MailChimpApiControler.Unsubscribe(campaign.ListId, "*****@*****.**");
         * //}
         *
         * //FileStream fs = new FileStream("log.txt", FileMode.OpenOrCreate);
         * //StreamWriter sw = new StreamWriter(fs);
         * //Logger.Debug.SetOut(sw);
         * //Logger.Debug.WriteLine(DateTime.Now);
         *
         * //  MailChimpApiControler.GetLists();
         * // MailChimpApiControler.ListBatchSubscribe("0715376399", MailChimpApiControler.GetTestSubscriberList());
         * //   MailChimpApiControler.GetGroups(Constants.EzbobCustomersListId);
         * // Logger.Debug.WriteLine(Constants.CampaignsType.DidntTakeLoan.ToString());
         * //MailChimpApiControler.CreateSegmentedCampaign("0715376399", 32429, "DAYAFTER", "subjrxt", "titlre");
         * //MailChimpApiControler.SendCampaign("5f506652c9");
         *
         * //sw.AutoFlush = true;
         * //sw.Close();
         * }*/

        public static void TestAlibaba(MailChimpApiControler oMailChimpApiControler)
        {
            Campaigns.InitCampaignsList();
            foreach (Campaign campaign in Campaigns.CampaignsList)
            {
                if (campaign.CampaignType == Constants.CampaignsType.DidntTakeLoanAlibaba)
                {
                    var subscriberList = new List <Subscriber>()
                    {
                        new Subscriber()
                        {
                            Email     = "*****@*****.**",
                            DayAfter  = DateTime.Today,
                            FirstName = "Stas",
                            Group     = Constants.CampaignsType.DidntTakeLoanAlibaba.ToString(),
                            LastName  = "Dulman",
                            LoanOffer = 1000,
                            Month     = DateTime.Today,
                            TwoWeeks  = DateTime.Today,
                            Week      = DateTime.Today
                        }
                    };

                    if (subscriberList.Count == 0)
                    {
                        ms_oLog.Debug("subscriberList is empty {0}", campaign);
                        continue;
                    }                     // if

                    ms_oLog.Debug("subscriberList has {0} customers", subscriberList.Count);

                    PrintSubscribersList(campaign.Title, subscriberList);

                    oMailChimpApiControler.ListBatchSubscribe(campaign.ListId, subscriberList);

                    foreach (Day day in campaign.DayList)
                    {
                        if (day == null)
                        {
                            continue;
                        }

                        ms_oLog.Debug("CreateSegmentedCampaign listId:{0}, templateId:{1}, condition:{2}, subject:{3}, title:{4}, type:{5}",
                                      campaign.ListId, day.TemplateId, day.Condition, day.Subject, campaign.Title, campaign.CampaignType.ToString());

                        string campaignId = oMailChimpApiControler.CreateSegmentedCampaign(campaign.ListId, day.TemplateId, day.Condition,
                                                                                           day.Subject, campaign.Title,
                                                                                           campaign.CampaignType.ToString());

                        if (!string.IsNullOrEmpty(campaignId))
                        {
                            ms_oLog.Debug("Sending campaign {0}, {1} {2}", campaignId, campaign.Title, day.Condition);
                            //oMailChimpApiControler.SendCampaign(campaignId);
                        }                         // fi
                        else
                        {
                            ms_oLog.Error("Failed to CreateSegmentedCampaign");
                        }
                    } // for each day
                }
            }         // for each campaign
        }
コード例 #30
0
        public JsonResult Index(int id)
        {
            var customer = this.customerRepository.Get(id);
            var cr       = customer.LastCashRequest;

            var aiar = this.serviceClient.Instance.LoadApplicationInfo(
                this.context.UserId,
                customer.Id,
                cr == null ? (long?)null : cr.Id,
                DateTime.UtcNow
                );

            log.Debug(
                "Just loaded broker fee {0}, set up fee {1}",
                aiar.Model.BrokerSetupFeePercent == null ? "NULL" : aiar.Model.BrokerSetupFeePercent.Value.ToString("P4"),
                aiar.Model.ManualSetupFeePercent == null ? "NULL" : aiar.Model.ManualSetupFeePercent.Value.ToString("P4")
                );

            return(Json(aiar.Model, JsonRequestBehavior.AllowGet));
        }         // Index