Пример #1
0
        public override void Execute()
        {
            Log.Warn("Getting SalesForce activities for customer {0}", this.customerID);

            CustomerData customerData = new CustomerData(this, this.customerID, DB);

            customerData.Load();

            SalesForceRetier.Execute(ConfigManager.CurrentValues.Instance.SalesForceNumberOfRetries, ConfigManager.CurrentValues.Instance.SalesForceRetryWaitSeconds, this.salesForce, () => {
                Result = this.salesForce.GetActivity(new GetActivityModel {
                    Email  = customerData.Mail,
                    Origin = customerData.Origin
                });
            });

            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));
            }
        }
Пример #2
0
        /// <summary>
        /// Retrieve and update sales force contact data.
        /// if director id or email is provided retrieve contact data for them, else for customer itself
        /// executed when directors are added in wizard/dashboard/UW or when customer/directors data is updated in dashboard
        /// </summary>
        public override void Execute()
        {
            Thread.Sleep(60000);             // Solves race condition in converting lead to account on finish wizard, in order to improve sleep only when invoked from finish wizard flow
            ContactModel model = DB.FillFirst <ContactModel>("SF_LoadContact",
                                                             CommandSpecies.StoredProcedure,
                                                             new QueryParameter("CustomerID", this.customerID),
                                                             new QueryParameter("DirectorID", this.directorID),
                                                             new QueryParameter("DirectorEmail", this.directorEmail));


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

            SalesForceRetier.Execute(ConfigManager.CurrentValues.Instance.SalesForceNumberOfRetries, ConfigManager.CurrentValues.Instance.SalesForceRetryWaitSeconds, this.salesForce, () => {
                this.salesForce.CreateUpdateContact(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));
            }
        }
Пример #3
0
        public override void Execute()
        {
            Log.Info("Adding SalesForce task {1} to customer {0} {1}", this.taskModel.Subject, this.customerID, this.taskModel.Email);

            if (string.IsNullOrEmpty(this.taskModel.Description))
            {
                this.taskModel.Description = this.taskModel.Subject;
            }

            this.taskModel.Email = this.taskModel.Email.ToLower();

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

            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));
            }
        }
Пример #4
0
        public override void Execute()
        {
            if (this.customerID.HasValue)
            {
                Log.Info("Adding SalesForce event {1} to customer {0} ", this.activityModel.Type, this.customerID.Value);
            }

            this.activityModel.Email = this.activityModel.Email.ToLower();

            //fix race condition in sales force between create lead / convert lead into account and adding activity to it.
            if (this.activityModel.Description.Contains("Greeting") || this.activityModel.Description.Contains("under review"))
            {
                Thread.Sleep(10000);
            }
            else
            {
                Thread.Sleep(5000);
            }

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

            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));
            }
        }
Пример #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));
            }
        }
Пример #6
0
        public override void Execute()
        {
            Log.Info("Updating SalesForce opportunity to customer {0} ", this.customerID);

            this.opportunityModel.Email = this.opportunityModel.Email.ToLower();

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

            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));
            }
        }