public static SfVirtualParentChildAccount GetParentInfo(SfVirtualParentChildAccount childAcct) { try { String connectionString = SalesforceCxn.SalesforceConnectionString(); using (SalesforceConnection connection = new SalesforceConnection(connectionString)) { SalesforceCommand cmd = new SalesforceCommand("SELECT Account.Name, Account.CCAN__c , Record_type_Name__c FROM Account Where Id = " + childAcct.SfIdParent, connection); SalesforceDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { childAcct.ParentAccountName = rdr["Name"].ToString(); if (!string.IsNullOrEmpty(rdr["CCAN__c"].ToString())) { childAcct.Ccan = Convert.ToDecimal(rdr["CCAN__c"].ToString()); } childAcct.ParentRecordType = rdr["Record_type_Name__c"].ToString(); } return(childAcct); } } catch (Exception ex) { CfsLogging.LogFatal("Error occured Salesforce Data Loader", String.Format(MethodBase.GetCurrentMethod().Name + " method failed in SalesforceContext class") + "\n" + ex); throw; } }
public List <SfVirtualParentChildAccount> GetVirtualAccountParentChildList(string customerRecordTypeId, string virtualRecordTypeId) { List <SfVirtualParentChildAccount> sfVirtualParentAcctList = new List <SfVirtualParentChildAccount>(); try { String connectionString = SalesforceCxn.SalesforceConnectionString(); var sql = "SELECT Id, Name, ParentId FROM Account WHERE ParentId <> '' AND Account.IsDeleted = 'False' AND Account.RecordTypeId in('" + customerRecordTypeId + "', '" + virtualRecordTypeId + "') ORDER BY Name "; using (SalesforceConnection connection = new SalesforceConnection(connectionString)) { SalesforceCommand cmd = new SalesforceCommand(sql, connection); SalesforceDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { SfVirtualParentChildAccount sfVirtualParentChildAcct = new SfVirtualParentChildAccount(); sfVirtualParentChildAcct.AccountName = rdr["Name"].ToString(); sfVirtualParentChildAcct.SfIdAccount = rdr["Id"].ToString(); sfVirtualParentChildAcct.SfIdParent = rdr["ParentId"].ToString(); sfVirtualParentChildAcct = GetParentInfo(sfVirtualParentChildAcct); sfVirtualParentAcctList.Add(sfVirtualParentChildAcct); } return(sfVirtualParentAcctList); } } catch (Exception ex) { CfsLogging.LogFatal("Error occured Salesforce Data Loader", String.Format(MethodBase.GetCurrentMethod().Name + " method failed in SalesforceContext class") + "\n" + ex); throw; } }