private void SyncContactInformation(ContactsViewItem contact) { Logs.WriteEvent(string.Format("Processing contact {0}({1}) of organization {2}({3})", contact.Name, contact.UserID, contact.Organization, contact.OrganizationID)); if (!string.IsNullOrEmpty(contact.Email)) { string responseText = string.Empty; string requestParameter = string.Format("{0}={1}", ContactObjects.Lookup.email.ToString(), contact.Email); string requestUrl = string.Format("{0}person.json?{1}", _baseURI, requestParameter); responseText = CustomerInsightsUtilities.MakeHttpWebRequest(requestUrl, _securityToken, Logs, Settings, _currentContactApiCallsKey, ref _currentContactApiCalls); try { if (!string.IsNullOrEmpty(responseText)) { JObject jObject = JObject.Parse(responseText); ContactObjects.RootObject contactInfo = JsonConvert.DeserializeObject <ContactObjects.RootObject>(jObject.ToString()); User currentContact = Users.GetUser(LoginUser, contact.UserID); UpdateContactInformation(contactInfo, currentContact, (int)contact.OrganizationParentID); } else { Logs.WriteEvent("CustomerInsights did not return information."); } } catch (Exception ex) { Logs.WriteException(ex); } } else { Logs.WriteEvent("This contact does not have a email entered, can't get its CustomerInsights information."); } UpdateFullContactContactModified(contact.UserID); }
private void SyncOrganizationInformation(Organization company) { Logs.WriteEvent(string.Format("Processing company {0}({1})", company.Name, company.OrganizationID)); if (!string.IsNullOrEmpty(company.Website)) { string responseText = string.Empty; string requestParameter = string.Format("{0}={1}", CompanyObjects.Lookup.domain.ToString(), company.Website); string requestUrl = string.Format("{0}company/lookup.json?{1}", _baseURI, requestParameter); responseText = CustomerInsightsUtilities.MakeHttpWebRequest(requestUrl, _securityToken, Logs, Settings, _currentCompanyApiCallsKey, ref _currentCompanyApiCalls); try { if (!string.IsNullOrEmpty(responseText)) { JObject jObject = JObject.Parse(responseText); CompanyObjects.RootObject companyInfo = JsonConvert.DeserializeObject <CompanyObjects.RootObject>(jObject.ToString()); UpdateCompanyInformation(companyInfo, company); } else { Logs.WriteEvent("CustomerInsights did not return information."); } } catch (Exception ex) { Logs.WriteException(ex); } } else { Logs.WriteEvent("This company does not have a website entered, can't get its CustomerInsights information."); } UpdateFullContactCompanyModified(company.OrganizationID); }