public CRMUser CRMGetUser(CRMUser crmUser) { CRMState returnEntities = new CRMState(); CRMUser ret = new CRMUser(); string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='systemuser'> <attribute name='fullname' /> <attribute name='businessunitid' /> <attribute name='title' /> <attribute name='address1_telephone1' /> <attribute name='systemuserid' /> <order attribute='fullname' descending='false' /> <filter type='and'> <condition attribute='domainname' operator='eq' value='" + crmUser.UserFQN + "' />" + "</filter>" + "</entity>" + "</fetch>"; CRMFetchXML fx = new CRMFetchXML(); fx.FetchXML = fetchxml; List <CRMState> user = CRMGetEntities(fx).Entities; if (user.Count > 0) { crmUser.UserId = user[0].EntityId; } return(crmUser); }
public CRMUser CRMGetUser(CRMUser crmUser) { CRMFunctions function = new CRMFunctions(crmUser.Config); return function.CRMGetUser(crmUser); }
public CRMUser CRMGetUser(CRMUser crmUser) { CRMState returnEntities = new CRMState(); CRMUser ret = new CRMUser(); string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='systemuser'> <attribute name='fullname' /> <attribute name='businessunitid' /> <attribute name='title' /> <attribute name='address1_telephone1' /> <attribute name='systemuserid' /> <order attribute='fullname' descending='false' /> <filter type='and'> <condition attribute='domainname' operator='eq' value='" + crmUser.UserFQN + "' />" + "</filter>" + "</entity>" + "</fetch>"; CRMFetchXML fx = new CRMFetchXML(); fx.FetchXML = fetchxml; List<CRMState> user = CRMGetEntities(fx).Entities; if (user.Count > 0) { crmUser.UserId = user[0].EntityId; } return crmUser; }
public CRMTask CRMCreateTask(CRMTask crmTask) { OrganizationServiceProxy _serviceProxy; IOrganizationService _service; string res = ""; List<CRMState> returnEntities = new List<CRMState>(); using (_serviceProxy = GetCRMConnection()) { // This statement is required to enable early-bound type support. _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); _service = (IOrganizationService)_serviceProxy; try { Entity task = new Entity(); task.LogicalName = "task"; task["subject"] = crmTask.Subject; task["description"] = crmTask.Description; task["category"] = crmTask.Category; task["subcategory"] = crmTask.Subcategory; if (!string.IsNullOrEmpty(crmTask.RegardingId.Trim()) && !string.IsNullOrEmpty(crmTask.Regarding.Trim())) { task["regardingobjectid"] = new EntityReference(crmTask.Regarding.ToLower(), new Guid(crmTask.RegardingId)); } // assumes that the K2 CRM solution has been deployed task["k2_k2serialnumber"] = crmTask.K2SerialNumber; task["k2_k2activityname"] = crmTask.K2ActivityName; task["k2_k2processname"] = crmTask.K2ProcessName; task["k2_k2processinstanceid"] = crmTask.K2ProcessInstanceId; task["scheduleddurationminutes"] = crmTask.Duration; task["scheduledend"] = crmTask.DueDate; task["prioritycode"] = new OptionSetValue(crmTask.Priority); task["statecode"] = new OptionSetValue(crmTask.State); task["statuscode"] = new OptionSetValue(crmTask.Status); Guid newtask = _service.Create(task); crmTask.Id = newtask.ToString(); if (string.IsNullOrEmpty(crmTask.OwnerId.Trim()) && !string.IsNullOrEmpty(crmTask.OwnerFQN.Trim())) { CRMUser cu = new CRMUser(); cu.UserFQN = crmTask.OwnerFQN; cu = CRMGetUser(cu); crmTask.OwnerId = cu.UserId; } if (!string.IsNullOrEmpty(crmTask.OwnerId.Trim())) { CRMEntityOwnership eo = new CRMEntityOwnership(); eo.Target = "task"; eo.TargetId = newtask.ToString(); eo.Assignee = crmTask.Owner.ToLower(); eo.AssigneeId = crmTask.OwnerId; CRMChangeOwner(eo); } crmTask.Id = newtask.ToString(); } catch (Exception ex) { throw; } } return crmTask; }
public CRMTask CRMCreateTask(CRMTask crmTask) { OrganizationServiceProxy _serviceProxy; IOrganizationService _service; string res = ""; List <CRMState> returnEntities = new List <CRMState>(); using (_serviceProxy = GetCRMConnection()) { // This statement is required to enable early-bound type support. _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); _service = (IOrganizationService)_serviceProxy; try { Entity task = new Entity(); task.LogicalName = "task"; task["subject"] = crmTask.Subject; task["description"] = crmTask.Description; task["category"] = crmTask.Category; task["subcategory"] = crmTask.Subcategory; if (!string.IsNullOrEmpty(crmTask.RegardingId.Trim()) && !string.IsNullOrEmpty(crmTask.Regarding.Trim())) { task["regardingobjectid"] = new EntityReference(crmTask.Regarding.ToLower(), new Guid(crmTask.RegardingId)); } // assumes that the K2 CRM solution has been deployed task["k2_k2serialnumber"] = crmTask.K2SerialNumber; task["k2_k2activityname"] = crmTask.K2ActivityName; task["k2_k2processname"] = crmTask.K2ProcessName; task["k2_k2processinstanceid"] = crmTask.K2ProcessInstanceId; task["scheduleddurationminutes"] = crmTask.Duration; task["scheduledend"] = crmTask.DueDate; task["prioritycode"] = new OptionSetValue(crmTask.Priority); task["statecode"] = new OptionSetValue(crmTask.State); task["statuscode"] = new OptionSetValue(crmTask.Status); Guid newtask = _service.Create(task); crmTask.Id = newtask.ToString(); if (string.IsNullOrEmpty(crmTask.OwnerId.Trim()) && !string.IsNullOrEmpty(crmTask.OwnerFQN.Trim())) { CRMUser cu = new CRMUser(); cu.UserFQN = crmTask.OwnerFQN; cu = CRMGetUser(cu); crmTask.OwnerId = cu.UserId; } if (!string.IsNullOrEmpty(crmTask.OwnerId.Trim())) { CRMEntityOwnership eo = new CRMEntityOwnership(); eo.Target = "task"; eo.TargetId = newtask.ToString(); eo.Assignee = crmTask.Owner.ToLower(); eo.AssigneeId = crmTask.OwnerId; CRMChangeOwner(eo); } crmTask.Id = newtask.ToString(); } catch (Exception ex) { throw; } } return(crmTask); }