public void AddLead(int customerID)
        {
            LeadAccountModel model = this.DB.FillFirst <LeadAccountModel>(
                "SF_LoadAccountLead",
                CommandSpecies.StoredProcedure,
                new QueryParameter("Email", null),
                new QueryParameter("CustomerID", customerID),
                new QueryParameter("IsBrokerLead", false),
                new QueryParameter("IsVipLead", false));


            if (string.IsNullOrEmpty(model.CompanyName))
            {
                model.CompanyName = model.Name;
            }

            if (string.IsNullOrEmpty(model.CompanyName))
            {
                model.CompanyName = "No name";
            }

            if (!string.IsNullOrEmpty(model.LeadSource) && model.LeadSource.Length > MaxLeadSourceLength)
            {
                model.LeadSource = model.LeadSource.Substring(0, MaxLeadSourceLength);
            }

            model.Email = model.Email.ToLower();

            this.salesForce.CreateUpdateLeadAccount(model);

            if (this.salesForce.HasError)
            {
                Log.ErrorFormat("Failed to create lead {0}, error {1}", customerID, this.salesForce.Error);
            }
        }
Beispiel #2
0
        private static void MigrateBrokerLeadsFromDb()
        {
            string[] leadEmails =
            {
                "*****@*****.**",
            };

            foreach (var leadEmail in leadEmails)
            {
                Log.InfoFormat("migrating lead {0}", leadEmail);
                LeadAccountModel model = DB.FillFirst <LeadAccountModel>("SF_LoadAccountLead", CommandSpecies.StoredProcedure,
                                                                         new QueryParameter("@CustomerID", null),
                                                                         new QueryParameter("@Email", leadEmail),
                                                                         new QueryParameter("@IsBrokerLead", true),
                                                                         new QueryParameter("@IsVipLead", false));

                if (string.IsNullOrEmpty(model.Email))
                {
                    Log.ErrorFormat("Email is null for lead {0}, skipping", leadEmail);
                    continue;
                }
                try {
                    SfClient.CreateUpdateLeadAccount(model);
                    Thread.Sleep(1000);
                } catch (Exception ex) {
                    Log.ErrorFormat("ERROR executing for lead {0}\n{1}", leadEmail, ex);
                }
            }
        }
Beispiel #3
0
        public void CreateUpdateLeadAccount(LeadAccountModel model)
        {
            string result = null;

            try {
                Model = model.ToJsonExtension();
                if (this.loginResult != null && !string.IsNullOrEmpty(this.loginResult.sessionId))
                {
                    var response = this.api.LeadAccountService(
                        new SalesForceServiceNS.SessionHeader {
                        sessionId = this.loginResult.sessionId
                    },
                        new SalesForceServiceNS.CallOptions(),
                        new SalesForceServiceNS.DebuggingHeader(),
                        new SalesForceServiceNS.AllowFieldTruncationHeader(),
                        Model,
                        out result);

                    Log.DebugFormat("Debug log: {0}", response == null ? "" : response.debugLog);
                }
            } catch (Exception ex) {
                var resultModel = new ApiResponse(null, ex.Message);
                result = resultModel.ToJsonExtension();
            }
            LogResult("LeadAccountService", result, model.Email);
        }
Beispiel #4
0
        public void CreateUpdateLeadAccount(LeadAccountModel model)
        {
            HasLoginError = false;
            Log.InfoFormat("SalesForce CreateUpdateLeadAccount\n {0}", model.ToStringExtension());
            ApiResponse response = new ApiResponse();

            if (!response.IsSuccess)
            {
                Log.ErrorFormat("SalesForce CreateUpdateLeadAccount failed for customer {0}, error: {1}", model.Email, response.Error);
            }
        }
Beispiel #5
0
        public override void Execute()
        {
            LeadAccountModel model = DB.FillFirst <LeadAccountModel>(
                "SF_LoadAccountLead",
                CommandSpecies.StoredProcedure,
                new QueryParameter("Email", this.email),
                new QueryParameter("CustomerID", this.customerID),
                new QueryParameter("IsBrokerLead", this.isBrokerLead),
                new QueryParameter("IsVipLead", this.isVipLead));

            if (string.IsNullOrEmpty(model.Email))
            {
                Log.Error("email is null or empty for the following parameters:\n exec SF_LoadAccountLead {0}, {1}, {2}, {3}",
                          this.email, this.customerID, this.isBrokerLead, this.isVipLead);
                return;
            }

            if (string.IsNullOrEmpty(model.CompanyName))
            {
                model.CompanyName = model.Name;
            }

            if (string.IsNullOrEmpty(model.CompanyName))
            {
                model.CompanyName = "No name";
            }

            if (!string.IsNullOrEmpty(model.LeadSource) && model.LeadSource.Length > MaxLeadSourceLength)
            {
                model.LeadSource = model.LeadSource.Substring(0, MaxLeadSourceLength);
            }

            model.Email = model.Email.ToLower();

            SalesForceRetier.Execute(ConfigManager.CurrentValues.Instance.SalesForceNumberOfRetries, ConfigManager.CurrentValues.Instance.SalesForceRetryWaitSeconds, this.salesForce, () => {
                this.salesForce.CreateUpdateLeadAccount(model);
            });

            if (this.salesForce.HasError)
            {
                DB.ExecuteNonQuery("SalesForceSaveError", CommandSpecies.StoredProcedure,
                                   new QueryParameter("Now", DateTime.UtcNow),
                                   new QueryParameter("CustomerID", this.customerID),
                                   new QueryParameter("Type", this.Name),
                                   new QueryParameter("Model", this.salesForce.Model),
                                   new QueryParameter("Error", this.salesForce.Error));
            }
        }
Beispiel #6
0
        public void TestLead()
        {
            LeadAccountModel model = new LeadAccountModel {
                Email               = "[email protected]",
                AddressCountry      = "Country",
                AddressCounty       = "County",
                AddressLine1        = "Line1",
                AddressLine2        = "Line2",
                AddressLine3        = "Line3",
                AddressPostcode     = "Postcode",
                AddressTown         = "Town",
                CompanyName         = "TestIsTestCompanyName",
                Name                = "TestIsTest",
                TypeOfBusiness      = "Limited",
                CompanyNumber       = "056456446",
                DateOfBirth         = new DateTime(1966, 12, 11),
                EzbobSource         = "EzbobSource",
                EzbobStatus         = "Wizard complete",
                Gender              = "M",
                Industry            = "Building",
                LeadSource          = "LeadSource",
                PhoneNumber         = "0564564654",
                RegistrationDate    = new DateTime(2015, 01, 27),
                RequestedLoanAmount = 10000,
                Origin              = "ezbob",
                CustomerID          = 2222.ToString(),
                IsTest              = true,
                NumOfLoans          = 2,
                Promocode           = "promotest",
                IsBroker            = true,
                BrokerID            = 115,
                BrokerEmail         = "*****@*****.**",
                BrokerName          = "Broker Name",
                BrokerFirmName      = "Jada Coldfusion",
                BrokerPhoneNumber   = "01000000115"
            };

            this.client.CreateUpdateLeadAccount(model);
            Assert.IsTrue(String.IsNullOrEmpty(this.client.Error));
        }
Beispiel #7
0
        private static void MigrateLeadsFromDb()
        {
            int[] customerIDs =
            {
                43397,
                42686,
                42687,
                31733,
                42771,
                43256,
                43579,
                17705,
                42389,
                42297,
                43627,
                37870,
                42858,
                15656,
                42973,
                28591,
                43161,
                42356,
                25000,
                42341,
                42772,
                34027,
                42886,
                42256,
                17151,
                3793,
                41534,
                40451,
                42520,
                26440,
                42759,
                40539,
                30237,
                42263,
                22498,
                43487,
                41428,
                43020,
                4013,
                43409,
                21865,
                43308,
                13738,
                43594,
                43337,
                42980,
                32833,
                35242,
                42588,
                7510,
                42525,
                21295,
                43604,
                43492,
                42230,
                42385,
                42381,
                40183,
                42453,
                43568,
                43123,
                42689,
                24822,
                42322,
                37503,
                28555,
                22596,
                19220,
                43438,
                43287,
                33654,
                42768,
                43632,
                25553,
                42968,
                39612,
                43045,
                42544,
                42332,
                32382,
                43214,
                37694,
                42292,
                19724,
                30940,
                42943,
                42584,
                5568,
                28670,
                43481,
                38225,
                43247,
                43552,
                38217,
                35795,
                43524,
                22173,
                42103,
                42660,
                34480,
                43114,
                40464,
                10134,
                42800,
                43623,
                42957,
                41726,
                43284,
                42929,
                20446,
                25361,
                5688,
                42490,
                43013,
                23116,
                43484,
                42733,
                24032,
                42299,
                43466,
                42202,
                32046,
                38702,
                42420,
                42856,
                24281,
                42715,
                28234,
                42050,
                42656,
                43065,
                32409,
                43442,
                40609,
                24584,
                42828,
                33059,
                42294,
                391,
                35933,
                43499,
                22993,
                42441,
                43347,
                43529,
                38075,
                43573,
                32680,
                42421,
                43540,
                42945,
                41779,
                43162,
                36061,
                42577,
                42988,
                37394,
                35288,
                39032,
                42435,
                42839,
                42965,
                42461,
                16303,
                43271,
                40479,
                43316,
                24179,
                43598,
                42324,
                43167,
                41132,
                41875,
                43603,
                36642,
                42802,
                20550,
                42889,
                42779,
                31973,
                26417,
                43372,
                14142,
                43191,
                43355,
                42862,
                42857,
                43076,
                42679,
                42250,
                24714,
                42440,
                42327,
                42585,
                43491,
                43242,
                21609,
                14991,
                43085,
                43577,
                42278,
                42657,
                42418,
                42966,
                43429,
                42725,
                42757,
                42482,
                42328,
                43171,
                43111,
                43009,
                43587,
                43564,
                42935,
                42762,
                43582,
                43323,
                42300,
                43493,
                43317,
                43160,
                42767,
                26679,
                23373,
                42878,
                28709,
                42434,
                41531,
                42611,
                42872,
                42566,
                31347,
                42429,
                42432,
                25749,
                42721,
                42557,
                42363,
                42362,
                42780,
                38165,
                30702,
                43363,
                42909,
                42400,
                17481,
                42653,
                43322,
                36028,
                42847,
                42672,
                42783,
                43184,
                42954,
                33197,
                43610,
                42342
            };

            foreach (var customerID in customerIDs)
            {
                Log.InfoFormat("migrating customer {0}", customerID);
                LeadAccountModel model = DB.FillFirst <LeadAccountModel>("SF_LoadAccountLead", CommandSpecies.StoredProcedure,
                                                                         new QueryParameter("@CustomerID", customerID),
                                                                         new QueryParameter("@Email"),
                                                                         new QueryParameter("@IsBrokerLead", false),
                                                                         new QueryParameter("@IsVipLead", false));

                if (string.IsNullOrEmpty(model.Email))
                {
                    Log.ErrorFormat("Email is null for customerID {0}, skipping", customerID);
                    continue;
                }

                try {
                    SfClient.CreateUpdateLeadAccount(model);
                } catch (Exception ex) {
                    Log.ErrorFormat("failed to rerun for customerID {0}, skipping \n {1}", customerID, ex);
                }
                Thread.Sleep(1000);
            }
        }
Beispiel #8
0
        public void TestRequestsToJson()
        {
            Log.Debug("call CreateUpdateLeadAccount");
            LeadAccountModel model = new LeadAccountModel {
                Email  = "[email protected]",
                Origin = "ezbob",

                AddressCountry           = "Country",
                AddressCounty            = "County",
                AddressLine1             = "Line1",
                AddressLine2             = "Line2",
                AddressLine3             = "Line3",
                AddressPostcode          = "Postcode",
                AddressTown              = "Town",
                CompanyName              = "CompanyName",
                Name                     = "CustomerName",
                TypeOfBusiness           = "Limited",
                CompanyNumber            = "056456446",
                DateOfBirth              = new DateTime(1966, 12, 11),
                EzbobSource              = "EzbobSource",
                EzbobStatus              = "Status",
                Gender                   = "M",
                Industry                 = "Building",
                IsBroker                 = false,
                LeadSource               = "LeadSource",
                PhoneNumber              = "0564564654",
                MobilePhoneNumber        = "07401201987",
                RegistrationDate         = new DateTime(2015, 01, 27),
                RequestedLoanAmount      = 10000,
                IsTest                   = false,
                Promocode                = "promo code test",
                BrokerEmail              = "*****@*****.**",
                BrokerFirmName           = "Broker Firm Name",
                BrokerName               = "Broker Name",
                BrokerPhoneNumber        = "01234567890",
                CollectionStatus         = "Active",
                ExternalCollectionStatus = "None"
            };

            Log.Debug(model.ToJsonExtension());
            Log.Debug("call CreateOpportunity/UpdateOpportunity");

            var opModel = new OpportunityModel {
                Email  = "[email protected]",
                Origin = "ezbob",

                ApprovedAmount  = 10000,
                ExpectedEndDate = new DateTime(2015, 01, 29),
                Stage           = OpportunityStage.s90.DescriptionAttr(),
                Name            = "opName",
            };

            Log.Debug(opModel.ToJsonExtension());


            Log.Debug("call CreateUpdateContact");

            var cModel = new ContactModel {
                Email  = "[email protected]",
                Origin = "ezbob",

                AddressCountry  = "Country",
                AddressCounty   = "County",
                AddressLine1    = "Line1",
                AddressLine2    = "Line2",
                AddressLine3    = "Line3",
                AddressPostcode = "Postcode",
                AddressTown     = "Town",
                ContactEmail    = "*****@*****.**",
                DateOfBirth     = new DateTime(1976, 10, 21),
                Gender          = "F",
                Name            = "ContactName",
                Type            = "Director",
                PhoneNumber     = "065645745"
            };

            Log.Debug(cModel.ToJsonExtension());


            Log.Debug("call CreateTask");

            var tModel = new TaskModel {
                Email  = "[email protected]",
                Origin = "ezbob",

                CreateDate  = new DateTime(2015, 01, 27),
                DueDate     = new DateTime(2015, 01, 29),
                Originator  = "Originator",
                Status      = "Status",
                Subject     = "Subject",
                Description = "Subject"
            };

            Log.Debug(tModel.ToJsonExtension());
            Log.Debug("call CreateActivity");

            var aModel = new ActivityModel {
                Email  = "[email protected]",
                Origin = "ezbob",

                Description   = "Description",
                Type          = "Mail",
                Originator    = "Originator",
                StartDate     = new DateTime(2015, 01, 27),
                EndDate       = new DateTime(2015, 01, 28),
                IsOpportunity = false,
            };

            Log.Debug(aModel.ToJsonExtension());
            Log.Debug("call ChangeEmail");

            var changeModel = new ChangeEmailModel {
                currentEmail = "[email protected]",
                Origin       = "ezbob",

                newEmail = "[email protected]"
            };

            Log.Debug(changeModel.ToJsonExtension());


            Log.Debug("call GetActivity");
            var gaModel = new GetActivityModel {
                Email  = "[email protected]",
                Origin = "ezbob"
            };

            Log.Debug(gaModel.ToJsonExtension());

            Log.Debug("All methods response");

            var rModel = new ApiResponse("Success", "");

            Log.Debug(rModel.ToJsonExtension());
        }