Exemplo n.º 1
0
        public CalculateModelsAndAffordability(int nCustomerID, DateTime?oHistory)
        {
            this.m_oTimeCounter = new TimeCounter("CalculateModelsAndAffordability elapsed times");

            using (this.m_oTimeCounter.AddStep("Constructor time")) {
                this.m_nCustomerID = nCustomerID;
                this.m_oHistory    = oHistory;
                this.m_oMundMs     = new List <LocalMp>();

                MpModel = new MpModel {
                    Affordability = new List <AffordabilityData>(),
                    MarketPlaces  = new List <MarketPlaceDataModel>(),
                };

                this.m_oRepo = ObjectFactory.GetInstance <CustomerMarketPlaceRepository>();
            }     // using
        }         // constructor
Exemplo n.º 2
0
        }         // Name

        public override void Execute()
        {
            MpModel = new MpModel {
                Affordability = new List <AffordabilityData>(),
                MarketPlaces  = new List <MarketPlaceDataModel>(),
            };

            using (this.m_oTimeCounter.AddStep("Total mp and affordability strategy execute time")) {
                try {
                    using (this.m_oTimeCounter.AddStep("All marketplaces build time"))
                        GetAllModels();

                    var oPaypal     = new List <LocalMp>();
                    var oEcomm      = new List <LocalMp>();
                    var oAccounting = new List <LocalMp>();

                    MarketPlaceDataModel oHmrc = null;

                    var oYodlee = new List <LocalMp>();

                    foreach (LocalMp mm in this.m_oMundMs)
                    {
                        if (mm.Marketplace.Disabled)
                        {
                            continue;
                        }

                        if (mm.Marketplace.Marketplace.InternalId == ms_oCompanyFilesID)
                        {
                            continue;
                        }

                        if (mm.Marketplace.Marketplace.InternalId == ms_oYodleeID)
                        {
                            oYodlee.Add(mm);
                            continue;
                        }                         // if

                        if (mm.Marketplace.Marketplace.InternalId == ms_oHmrcID)
                        {
                            if (oHmrc == null)
                            {
                                oHmrc = mm.Model;
                            }

                            continue;
                        }                         // if

                        if (mm.Marketplace.Marketplace.InternalId == ms_oPaypalID)
                        {
                            oPaypal.Add(mm);
                            continue;
                        }                         // if

                        if (mm.Marketplace.Marketplace.IsPaymentAccount)
                        {
                            oAccounting.Add(mm);
                        }
                        else
                        {
                            oEcomm.Add(mm);
                        }
                    }                     // for each marketplace

                    if (oHmrc != null)
                    {
                        using (this.m_oTimeCounter.AddStep("HMRC affordability build time"))
                            HmrcBank(oHmrc);
                    }                     // if

                    if (oYodlee.Any())
                    {
                        using (this.m_oTimeCounter.AddStep("Yodlee affordability build time"))
                            SaveBankStatement(oYodlee);
                    }                     // if

                    using (this.m_oTimeCounter.AddStep("PayPal affordability build time"))
                        Psp(oPaypal);

                    using (this.m_oTimeCounter.AddStep("Ecomm affordability build time"))
                        EcommAccounting(oEcomm, AffordabilityType.Ecomm);

                    using (this.m_oTimeCounter.AddStep("Accounting affordability build time"))
                        EcommAccounting(oAccounting, AffordabilityType.Accounting);

                    using (this.m_oTimeCounter.AddStep("Logging affordability time")) {
                        Log.Debug("**************************************************************************");
                        Log.Debug("*");
                        Log.Debug("* Affordability data for customer {0} - begin:", this.m_nCustomerID);
                        Log.Debug("*");
                        Log.Debug("**************************************************************************");

                        foreach (var a in MpModel.Affordability)
                        {
                            Log.Debug(a);
                        }

                        Log.Debug("**************************************************************************");
                        Log.Debug("*");
                        Log.Debug("* Affordability data for customer {0} - end.", this.m_nCustomerID);
                        Log.Debug("*");
                        Log.Debug("**************************************************************************");
                    }                     // using
                } catch (Exception ex) {
                    Log.Error(ex, "Failed calculation models and affordability for customer {0}", this.m_nCustomerID);
                }         //try
            }             // using total timer

            Log.Info(this.m_oTimeCounter.ToString());
        }         // Execute