public CRMRetrieveMultiple CRMRetrieveMultiple(CRMRetrieveMultiple crmRetrieveMultiple)
    {
        CRMFunctions function = new CRMFunctions(crmRetrieveMultiple.Config);

        return(function.CRMRetrieveMultiple(crmRetrieveMultiple));
    }
    public CRMWorkflow CRMStartWorkflowByID(CRMWorkflow crmWF)
    {
        CRMFunctions function = new CRMFunctions(crmWF.Config);

        return(function.CRMStartWorkflowByID(crmWF));
    }
    public CRMEntityMetadata CRMGetEntityMetadata(CRMEntityMetadata crmEntityMetadata)
    {
        CRMFunctions function = new CRMFunctions(crmEntityMetadata.Config);

        return(function.CRMGetEntityMetadata(crmEntityMetadata));
    }
    public CRMTask CRMCreateTask(CRMTask crmTask)
    {
        CRMFunctions function = new CRMFunctions(crmTask.Config);

        return(function.CRMCreateTask(crmTask));
    }
    public CRMUser CRMGetUser(CRMUser crmUser)
    {
        CRMFunctions function = new CRMFunctions(crmUser.Config);

        return(function.CRMGetUser(crmUser));
    }
    public CRMFetchXML CRMGetEntities(CRMFetchXML crmFetchXML)
    {
        CRMFunctions function = new CRMFunctions(crmFetchXML.Config);

        return(function.CRMGetEntities(crmFetchXML));
    }
    public CRMBulkActionTask CRMBulkActionTasks(CRMBulkActionTask crmBulkActionTask)
    {
        CRMFunctions function = new CRMFunctions(crmBulkActionTask.Config);

        return(function.CRMBulkActionTasks(crmBulkActionTask));
    }
    public CRMState CRMSetStateStatus(CRMState crmState)
    {
        CRMFunctions function = new CRMFunctions(crmState.Config);

        return(function.CRMSetStateStatus(crmState));
    }
    public CRMEntityOwnership CRMChangeOwner(CRMEntityOwnership crmEntityOwnership)
    {
        CRMFunctions function = new CRMFunctions(crmEntityOwnership.Config);

        return(function.CRMChangeOwner(crmEntityOwnership));
    }
    public CRMPicklist CRMGetStateStatus(CRMPicklist picklist)
    {
        CRMFunctions function = new CRMFunctions(picklist.Config);

        return(function.CRMGetStateStatus(picklist));
    }
    public CRMEntityList CRMGetAllEntities(CRMEntityList EntityList)
    {
        CRMFunctions function = new CRMFunctions(EntityList.Config);

        return(function.CRMGetAllEntities(EntityList));
    }
        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")
            };

            if (!SvcI.ServiceConfiguration.ServiceAuthentication.Impersonate && !string.IsNullOrEmpty(SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Trim()) && !string.IsNullOrEmpty(SvcI.ServiceConfiguration.ServiceAuthentication.Password.Trim()))
            {
                // Static credentials
                if (SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Contains("\\"))
                {
                    char[]   sp   = { '\\' };
                    string[] user = SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Split(sp);
                    crmconfig.CRMDomain   = user[0].Trim();
                    crmconfig.CRMUsername = user[1].Trim();
                }
                else
                {
                    crmconfig.CRMUsername = SvcI.ServiceConfiguration.ServiceAuthentication.UserName.Trim();
                }
                crmconfig.CRMPassword = SvcI.ServiceConfiguration.ServiceAuthentication.Password;
            }

            CRMFunctions = new Functions.CRMFunctions(crmconfig);

            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;
            }
        }