getSalesforceAccount( string siteId, string syndicateCode) { SalesforceServiceRef.Account accountInfo = null; // add the leading zeros to the site id so that it will match with what we have in the salesforce siteId = addLeadingZerosToNumber( Convert.ToInt32(siteId), this.salesforceSiteIdLength); QueryResult qr = this.executeQueryOnSalesforce( string.Format( "Select ID, Loyalty_Mate_Email__c, Loyalty_Mate_Password__c, Loyalty_Mate_Subdomain__c from Account where Site_ID__c='{0}' and Syndicate_Code__c='{1}' ", siteId, syndicateCode)); if (qr != null && qr.records != null && qr.records.Length > 0) { sObject[] records = qr.records; accountInfo = (SalesforceServiceRef.Account)records[0]; } return(accountInfo); }
Get_syndicate_credentials( string inSyndicateCode, string inSiteID) { try { // load credentials from encrypted xml file getCredentialsFromXML(); if (!sfCredentials.IsValid() || !this.loginToSalesforce( sfCredentials, out sfLoginResult)) { throw new Exception("Salesforce authentication failed"); } // retrieve the account by site id and syndicate code SalesforceServiceRef.Account account = getSalesforceAccount( inSiteID, inSyndicateCode); if (account == null) { throw new Exception("A matching account was not found on Salesforce"); } // assign properties for trineo credentials from account trineoCredentials.Username = account.Loyalty_Mate_Email__c; trineoCredentials.Password = account.Loyalty_Mate_Password__c; trineoCredentials.Site_name = account.Loyalty_Mate_Subdomain__c; // logout from salesforce salesforceServiceClient.logout(); } catch (Exception ex) { logger.ErrorException( "Failed to get credentials for the trineo cloud", ex); throw ex; // throwing the exception back to calling application so they know the login process failed } return(trineoCredentials); }