public void Execute()
        {
            SvcI = SvcBase.Service;

            config = GetK2CRMConfig(SvcI.ServiceConfiguration.ServiceAuthentication.UserName, SvcI.ServiceConfiguration.ServiceAuthentication.Password, GetConfigPropertyValue("RESTServiceURL"));

            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;
            }
        }
        public RestResponse<CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMGetEntities";

            request.AddBody(crmFetch);

            RestResponse<CRMFetchXML> response = client.Execute<CRMFetchXML>(request);

            return response;
        }
        public RestResponse<CRMState> SetStateStatus(CRMState crmState, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMSetStateStatus";

            request.AddBody(crmState);

            RestResponse<CRMState> response = client.Execute<CRMState>(request);

            return response;
        }
        public RestResponse<CRMEntityOwnership> ChangeOwner(CRMEntityOwnership crmEntityOwnership, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMChangeOwner";

            request.AddBody(crmEntityOwnership);

            RestResponse<CRMEntityOwnership> response = client.Execute<CRMEntityOwnership>(request);

            return response;
        }
Ejemplo n.º 5
0
        private K2CRMConfig GetK2CRMConfig(string User, string Password, string RESTUrl)
        {
            string[] domainuser = User.Split('\\');

            K2CRMConfig config = new K2CRMConfig();

            config.RESTUrl         = RESTUrl;
            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);
        }
        public RestResponse<CRMBulkActionTask> BulkActionTasks(CRMBulkActionTask crmBulk, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMBulkActionTasks";

            request.AddBody(crmBulk);

            RestResponse<CRMBulkActionTask> response = client.Execute<CRMBulkActionTask>(request);

            return response;
        }
        public RestResponse <CRMFetchXML> GetEntities(CRMFetchXML crmFetch, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMGetEntities";

            request.AddBody(crmFetch);

            RestResponse <CRMFetchXML> response = client.Execute <CRMFetchXML>(request);

            return(response);
        }
        public RestResponse <CRMState> SetStateStatus(CRMState crmState, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMSetStateStatus";

            request.AddBody(crmState);

            RestResponse <CRMState> response = client.Execute <CRMState>(request);

            return(response);
        }
        public RestResponse <CRMWorkflow> StartWorkflow(CRMWorkflow crmWF, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMStartWorkflow";

            request.AddBody(crmWF);

            RestResponse <CRMWorkflow> response = client.Execute <CRMWorkflow>(request);

            return(response);
        }
        public RestResponse <CRMUser> GetCRMUser(CRMUser crmUser, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMGetUser";

            request.AddBody(crmUser);

            RestResponse <CRMUser> response = client.Execute <CRMUser>(request);

            return(response);
        }
        public RestResponse <CRMTask> CreateTask(CRMTask crmTask, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMCreateTask";

            request.AddBody(crmTask);

            RestResponse <CRMTask> response = client.Execute <CRMTask>(request);

            return(response);
        }
Ejemplo n.º 12
0
        public void Execute()
        {
            SvcI = SvcBase.Service;

            config = GetK2CRMConfig(SvcI.ServiceConfiguration.ServiceAuthentication.UserName, SvcI.ServiceConfiguration.ServiceAuthentication.Password, GetConfigPropertyValue("RESTServiceURL"));

            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;
            }
        }
        public RestResponse<CRMWorkflow> StartWorkflow(CRMWorkflow crmWF, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMStartWorkflow";

            request.AddBody(crmWF);

            RestResponse<CRMWorkflow> response = client.Execute<CRMWorkflow>(request);

            return response;
        }
        public RestResponse <CRMEntityOwnership> ChangeOwner(CRMEntityOwnership crmEntityOwnership, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();

            request.Method        = Method.POST;
            request.Credentials   = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource      = "K2CRM/CRMChangeOwner";

            request.AddBody(crmEntityOwnership);

            RestResponse <CRMEntityOwnership> response = client.Execute <CRMEntityOwnership>(request);

            return(response);
        }
        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;
            }
        }
        public RestResponse<CRMUser> GetCRMUser(CRMUser crmUser, K2CRMConfig config)
        {
            var client = new RestClient(config.RESTUrl);

            var request = new RestRequest();
            request.Method = Method.POST;
            request.Credentials = config.CredentialCache;
            request.RequestFormat = RestSharp.DataFormat.Json;
            request.Resource = "K2CRM/CRMGetUser";

            request.AddBody(crmUser);

            RestResponse<CRMUser> response = client.Execute<CRMUser>(request);

            return response;
        }
        private K2CRMConfig GetK2CRMConfig(string User, string Password, string RESTUrl)
        {
            string[] domainuser = User.Split('\\');

            K2CRMConfig config = new K2CRMConfig();
            config.RESTUrl = RESTUrl;
            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;
        }