public bool UpdateSalesForceModulesStatus(SalesForceModuleStatus salesForceModuleStatus) { try { //We need to login to sales force to initiate the process.. //Get the credentials for logging into sales force.. var credentials = _salesForceCredentialFactory.Create(); if (_salesForceInterface.Login(credentials)) { //Update the sales fields with new values.. var isSuccess = _salesForceInterface.UpdateSalesForceModulesStatus(salesForceModuleStatus); //Since we have completed all the processing we will log out.. _salesForceInterface.Logout(); return(isSuccess); } } catch (Exception exception) { ServiceLogger.LogException("Exception in UpdateSalesForceModulesStatus", exception); } return(false); }
public bool UpdateSalesForceModulesStatus(SalesForceModuleStatus salesForceModuleStatus) { try { //if accountname does not contain single quotes we need to add to it for query execution.. if (!salesForceModuleStatus.AccountName.StartsWith("'") && !salesForceModuleStatus.AccountName.EndsWith("'")) { salesForceModuleStatus.AccountName = salesForceModuleStatus.AccountName.Insert(0, "'"); salesForceModuleStatus.AccountName = salesForceModuleStatus.AccountName.Insert((salesForceModuleStatus.AccountName.Length), "'"); } IList <Tuple <string, object> > propertyWithNewValues = new List <Tuple <string, object> >(); var accountFieldsDetails = GetAccountFieldsDetails(salesForceModuleStatus.AccountName); propertyWithNewValues.Add(new Tuple <string, object>("Menumate_Version__c", salesForceModuleStatus.SalesForceVersion)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Menumate_Version__c"); propertyWithNewValues.Clear(); //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.MobiToGo != salesForceModuleStatus.IsMobiToGoActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Mobi2Go__c", salesForceModuleStatus.IsMobiToGoActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Mobi2Go__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Mobi2Go_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("Mobi2Go_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Mobi2Go_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "Mobi2Go_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.Stock != salesForceModuleStatus.IsStockActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Stock_Activated__c", salesForceModuleStatus.IsStockActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Stock_Activated__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Stock_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("Stock_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Stock_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "Stock_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.Thorlink != salesForceModuleStatus.IsThorlinkActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Thorlink_Activated__c", salesForceModuleStatus.IsThorlinkActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Thorlink_Activated__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Thorlink_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("Thorlink_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Thorlink_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "Thorlink_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.Xero != salesForceModuleStatus.IsXeroActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Xero_Activated__c", salesForceModuleStatus.IsXeroActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Xero_Activated__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Xero_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("Xero_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Xero_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "Xero_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.ChefMate != salesForceModuleStatus.IsChefMateActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("ChefMate__c", salesForceModuleStatus.IsChefMateActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "ChefMate__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("ChefMate_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("ChefMate_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "ChefMate_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "ChefMate_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.PalmMate != salesForceModuleStatus.IsPalmMateActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("PalmMate__c", salesForceModuleStatus.IsPalmMateActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "PalmMate__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("PalmMate_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("PalmMate_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "PalmMate_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "PalmMate_Date_Updated__c"); } //The condition compares the values of Field in Menumate and Salesforce and then updates the Field value //accordingly in SalesForce if (accountFieldsDetails.Loyalty != salesForceModuleStatus.IsLoyaltyActivated) { propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Loyalty__c", salesForceModuleStatus.IsLoyaltyActivated)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Loyalty__c"); propertyWithNewValues.Clear(); propertyWithNewValues.Add(new Tuple <string, object>("Loyalty_Date_Updated__c", DateTime.Today)); propertyWithNewValues.Add(new Tuple <string, object>("Loyalty_Date_Updated__cSpecified", true)); _salesForceCommunicationHelper.UpdateSalesForceColumnValues(salesForceModuleStatus.AccountName, propertyWithNewValues, "ID", "Loyalty_Date_Updated__c"); //UpdateSalesForceDateColumn(salesForceModuleStatus.AccountName, "Loyalty_Date_Updated__c"); } return(true); } catch (Exception exception) { throw new Exception("There was an error updating menumate version on sales force.") { Source = exception.Source }; } }