public void Execute() { SvcI = SvcBase.Service; config = GetK2CRMConfig(SvcI.ServiceConfiguration.ServiceAuthentication.UserName, SvcI.ServiceConfiguration.ServiceAuthentication.Password, GetConfigPropertyValue("RESTServiceURL")); crmconfig = new CRMConfig { CRMURL = GetConfigPropertyValue("CRMURL"), CRMOrganization = GetConfigPropertyValue("CRMOrganization") }; ServiceObject so = SvcI.ServiceObjects[0]; string methodName = so.Methods[0].Name; switch (methodName.ToLower()) { case "changeowner": ChangeOwner(ref so); break; case "setstatestatus": SetStateStatus(ref so); break; case "getentities": GetEntities(ref so); break; case "bulkactiontasks": BulkActionTasks(ref so); break; case "createtask": CreateTask(ref so); break; case "getcrmuser": GetCRMUser(ref so); break; case "startcrmworkflow": StartCRMWorkflow(ref so); break; case "getentitymetadata": GetEntityMetadata(ref so); break; case "bulkactiontaskssetcriteria": BulkActionTasksSetCriteria(ref so); break; case "retrievemultiple": RetrieveMultiple(ref so); break; case "getallentities": GetAllEntities(ref so); break; case "getentityattributes": GetEntityAttributes(ref so); break; case "getpicklist": GetPicklist(ref so); break; case "getstatestatuspicklist": GetStateStatusPicklist(ref so); break; } }
private K2CRMConfig GetK2CRMConfig(string User, string Password, string RESTUrl) { K2CRMConfig config = new K2CRMConfig(); config.RESTUrl = RESTUrl; if (!string.IsNullOrEmpty(User)) { string[] domainuser = User.Split('\\'); config.User = domainuser[1]; config.Domain = domainuser[0]; config.Password = Password; config.Credentials = new NetworkCredential(domainuser[1], Password, domainuser[0]); config.CredentialCache = new CredentialCache(); config.CredentialCache.Add(new Uri(RESTUrl), "NTLM", config.Credentials); } return config; }