public EntityCollection GetContacts(int pageSize = 500, int pageNumber = 1, string pagingCookie = null) { var appSettings = ConfigurationManager.AppSettings; string lastSyncDateString = appSettings["ContactLastSyncDate"]; DateTime lastSyncDate = new DateTime(2020, 4, 1); if (!string.IsNullOrEmpty(lastSyncDateString)) { try { lastSyncDate = DateTime.Parse(lastSyncDateString).AddHours(-1); } catch (Exception) { } } FilterExpression fe = new FilterExpression(); ConditionExpression ce = new ConditionExpression("createdon", ConditionOperator.GreaterEqual, lastSyncDate); ConditionExpression ce1 = new ConditionExpression("fullname", ConditionOperator.NotNull); ConditionExpression ce2 = new ConditionExpression("statecode", ConditionOperator.Equal, 0); ConditionExpression ce3 = new ConditionExpression("isw_freshdeskid", ConditionOperator.Null); fe.AddCondition(ce); fe.AddCondition(ce1); fe.AddCondition(ce2); fe.AddCondition(ce3); string[] contactFields = new string[] { "address1_line1", "parentcustomerid", "address1_line1", "fullname", "telephone1", "telephone2", "emailaddress1", "jobtitle", "contactid" }; var accountCollection = CrmServiceFactory.RetrieveEntities("contact", contactFields, fe, pageSize, pageNumber, pagingCookie); return(accountCollection); }
public bool UpdateAgent(AgentDto agentDto) { Entity agentEntity = new Entity("systemuser"); string[] columns = { "systemuserid" }; ConditionExpression ce = new ConditionExpression("internalemailaddress", ConditionOperator.Equal, agentDto.Contact.Email); FilterExpression fe = new FilterExpression(); fe.AddCondition(ce); var ec = CrmServiceFactory.RetrieveEntities("systemuser", columns, fe, 1); if (ec.Entities.Count > 0) { agentEntity.Id = ec.Entities[0].Id; agentEntity["isw_freshdeskid"] = agentDto.Id.ToString(); var a = UpdateEntity(agentEntity); return(a.Result); } return(false); }
public EntityCollection GetAccounts(int pageSize = 500, int pageNumber = 1, string pagingCookie = null) { var appSettings = ConfigurationManager.AppSettings; string lastSyncDateString = appSettings["AccountLastSyncDate"]; DateTime lastSyncDate = new DateTime(2020, 4, 1); if (!string.IsNullOrEmpty(lastSyncDateString)) { try { lastSyncDate = DateTime.Parse(lastSyncDateString); } catch (Exception) { } } FilterExpression fe = new FilterExpression(); ConditionExpression ce = new ConditionExpression("modifiedon", ConditionOperator.GreaterEqual, lastSyncDate); ConditionExpression ce1 = new ConditionExpression("isw_isobsoletedata", ConditionOperator.Equal, 0); ConditionExpression ce2 = new ConditionExpression("statecode", ConditionOperator.Equal, 0); fe.AddCondition(ce); fe.AddCondition(ce1); fe.AddCondition(ce2); string[] accountFields = new string[] { "name", "customertypecode", "industrycode", "accountnumber", "address1_composite", "accountid" }; var accountCollection = CrmServiceFactory.RetrieveEntities("account", accountFields, fe, pageSize, pageNumber, pagingCookie); return(accountCollection); }
public CheckExistenceResult CheckExistence(string entity, FilterExpression fe) { EntityCollection ec = CrmServiceFactory.RetrieveEntities(entity, new string[] { entity + "id" }, fe, 1); if (ec.Entities.Count > 0) { return(new CheckExistenceResult(true, ec.Entities[0].Id)); } else { return(new CheckExistenceResult(false, new Guid())); } }
public CrmRepository() { _service = CrmServiceFactory.GetOrganization(); _freshdeskRepo = new FreshdeskRepository(); _contactMapper = new ContactMapper(); }