Пример #1
0
        public SpSelectCustomers(Constants.CampaignsType nCampaignType, DateTime oDateStart, DateTime oDateEnd, bool bIncludeTest, AConnection oDB, ASafeLog oLog) : base(oDB, oLog)
        {
            DateStart   = oDateStart;
            DateEnd     = oDateEnd;
            IncludeTest = bIncludeTest;

            switch (nCampaignType)
            {
            case Constants.CampaignsType.OnlyRegisteredEmail:
                m_sSpName = Constants.GetFirstStepCustomersSp;
                break;

            case Constants.CampaignsType.DidntFinishWizard:
                m_sSpName = Constants.GetSecondStepCustomersSp;
                break;

            case Constants.CampaignsType.DidntTakeLoan:
                m_sSpName = Constants.GetLastStepCustomersSp;
                DateStart = oDateStart.AddDays(-1);
                DateEnd   = oDateEnd.AddDays(-1);
                break;

            case Constants.CampaignsType.DidntTakeLoanAlibaba:
                m_sSpName = Constants.GetLastStepCustomersAlibabaSp;
                DateStart = oDateStart.AddDays(-1);
                DateEnd   = oDateEnd.AddDays(-1);
                break;

            default:
                throw new NotImplementedException("Not implemented for campaign type " + nCampaignType);
            }     // switch
        }         // constructor
Пример #2
0
        }         // constructor

        public List <Subscriber> GetSubscriberList(Constants.CampaignsType campaign, bool bIncludeTest)
        {
            try {
                var fromDate = new DateTime();
                var toDate   = new DateTime();

                var subscriberList = new List <Subscriber>();

                foreach (Constants.ConditionType condition in Enum.GetValues(typeof(Constants.ConditionType)))
                {
                    var oSubscriberModel = new Subscriber();

                    switch (condition)
                    {
                    case Constants.ConditionType.DayAfter:
                        toDate = DateTime.Today;
                        oSubscriberModel.DayAfter = DateTime.Today;
                        break;

                    case Constants.ConditionType.Week:
                        toDate = DateTime.Today.AddDays(-7);
                        oSubscriberModel.Week = DateTime.Today;
                        break;

                    case Constants.ConditionType.TwoWeeks:
                        toDate = DateTime.Today.AddDays(-14);
                        oSubscriberModel.TwoWeeks = DateTime.Today;
                        break;

                    case Constants.ConditionType.Month:
                        toDate = DateTime.Today.AddMonths(-1);
                        oSubscriberModel.Month = DateTime.Today;
                        break;
                    }                     // switch

                    fromDate = toDate.AddDays(-1);

                    var sp = new SpSelectCustomers(campaign, fromDate, toDate, bIncludeTest, m_oDB, m_oLog);

                    sp.ForEachRowSafe((sr, bRowsetStart) => {
                        decimal loanOffer = 0;

                        string loanOfferStr = sr["MaxApproved"];

                        if (!string.IsNullOrEmpty(loanOfferStr))
                        {
                            decimal.TryParse(loanOfferStr, out loanOffer);
                        }
                        else
                        {
                            string approximateLoanOfferStr = sr["ApproximateLoanOffer"];

                            if (!string.IsNullOrEmpty(approximateLoanOfferStr))
                            {
                                decimal.TryParse(approximateLoanOfferStr, out loanOffer);
                            }
                        }                         // if

                        var subscriber = oSubscriberModel.Clone();

                        subscriber.Email       = sr["eMail"];
                        subscriber.BrokerEmail = sr["BrokerEmail"];
                        subscriber.FirstName   = sr["FirstName"];
                        subscriber.LastName    = sr["SurName"];
                        subscriber.LoanOffer   = loanOffer;
                        subscriber.Group       = campaign.ToString();

                        subscriberList.Add(subscriber);

                        return(ActionResult.Continue);
                    });                     // for each result

                    m_oLog.Debug("Added subscribers from db for campaign: {0} {1}", campaign, condition);
                }                 // for each condition

                return(subscriberList);
            }
            catch (Exception e) {
                m_oLog.Error(e);
                return(null);
            }     // try
        }         // GetSubscriberList
Пример #3
0
        private static List <Day> GetDayList(Constants.CampaignsType type)
        {
            var dayList = new List <Day>();

            switch (type)
            {
            case Constants.CampaignsType.OnlyRegisteredEmail:
                //day after
                dayList.Add(new Day
                {
                    Condition  = Constants.DayAfterConditionField,
                    TemplateId = Constants.FirstStepCustomersDayAfterTemplateId,
                    Subject    = Constants.FirstStepCustomersDayAfterSubject,
                });
                dayList.Add(new Day {
                    Condition  = Constants.WeekConditionField,
                    TemplateId = Constants.FirstStepCustomersWeekTemplateId,
                    Subject    = Constants.FirstStepCustomersWeekSubject,
                });
                break;

            case Constants.CampaignsType.DidntFinishWizard:
                dayList.Add(new Day {
                    Condition  = Constants.WeekConditionField,
                    TemplateId = Constants.SecondStepCustomersWeekTemplateId,
                    Subject    = Constants.SecondStepCustomersWeekSubject,
                });
                break;

            case Constants.CampaignsType.DidntTakeLoan:
                //day after
                dayList.Add(new Day
                {
                    Condition  = Constants.DayAfterConditionField,
                    TemplateId = Constants.LastStepCustomersDayAfterTemplateId,
                    Subject    = Constants.LastStepCustomersDayAfterSubject,
                });
                //week
                dayList.Add(new Day
                {
                    Condition  = Constants.WeekConditionField,
                    TemplateId = Constants.LastStepCustomersWeekTemplateId,
                    Subject    = Constants.LastStepCustomersWeekSubject,
                });
                ////two weeks
                //dayList.Add(new Day
                //	{
                //		Condition = Constants.TwoWeeksConditionField,
                //		TemplateId = Constants.LastStepCustomersTwoWeeksTemplateId,
                //		Subject = Constants.LastStepCustomersTwoWeeksSubject,
                //	});
                ////month
                //dayList.Add(new Day
                //	{
                //		Condition = Constants.MonthConditionField,
                //		TemplateId = Constants.LastStepCustomersMonthTemplateId,
                //		Subject = Constants.LastStepCustomersMonthSubject,
                //	});
                break;
                //case Constants.CampaignsType.DidntTakeLoanAlibaba:
                //	//week
                //	dayList.Add(new Day
                //	{
                //		Condition = Constants.WeekConditionField,
                //		TemplateId = Constants.LastStepCustomersAlibabaWeekTemplateId,
                //		Subject = Constants.LastStepCustomersWeekSubject,
                //	});
                //	//two weeks
                //	dayList.Add(new Day
                //	{
                //		Condition = Constants.TwoWeeksConditionField,
                //		TemplateId = Constants.LastStepCustomersAlibabaTwoWeeksTemplateId,
                //		Subject = Constants.LastStepCustomersTwoWeeksSubject,
                //	});
                //	//month
                //	dayList.Add(new Day
                //	{
                //		Condition = Constants.MonthConditionField,
                //		TemplateId = Constants.LastStepCustomersAlibabaMonthTemplateId,
                //		Subject = Constants.LastStepCustomersMonthSubject,
                //	});
                //	break;
            }
            return(dayList);
        }