예제 #1
0
        public CRMWorkflow CRMStartWorkflowByID(CRMWorkflow crmWF)
        {
            OrganizationServiceProxy _serviceProxy;

            //IOrganizationService _service;

            using (_serviceProxy = GetCRMConnection())
            {
                try
                {
                    // Create an ExecuteWorkflow request.
                    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
                    {
                        WorkflowId = new Guid(crmWF.WorkflowId),
                        EntityId   = new Guid(crmWF.EntityId)
                    };

                    // Execute the workflow.
                    ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)_serviceProxy.Execute(request);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return(crmWF);
        }
예제 #2
0
        public CRMWorkflow CRMStartWorkflow(CRMWorkflow crmWF)
        {
            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
                              + "<entity name='workflow'>"
                              + "<attribute name='workflowid' />"
                              + "<attribute name='workflowidunique' />"
                              + "<attribute name='name' />"
                              + "<attribute name='category' />"
                              + "<attribute name='primaryentity' />"
                              + "<attribute name='statecode' />"
                              + "<attribute name='createdon' />"
                              + "<attribute name='ownerid' />"
                              + "<attribute name='owningbusinessunit' />"
                              + "<attribute name='type' />"
                              + "<attribute name='parentworkflowid' />"
                              + "<order attribute='name' descending='false' />"
                              + "<filter type='and'>"
                              + "<condition attribute='statecode' operator='eq' value='1' />"
                              + "<condition attribute='name' operator='eq' value='" + crmWF.WorkflowName + "' />"
                              + " <condition attribute='parentworkflowid' operator='null' />"
                              + "</filter>"
                              + "</entity>"
                              + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();

            fx.FetchXML = fetchxml;
            List <CRMState> wf = CRMGetEntities(fx).Entities;

            if (wf.Count > 0)
            {
                crmWF.WorkflowId = wf[0].EntityId;
                CRMStartWorkflowByID(crmWF);
            }

            return(crmWF);
        }
 public CRMWorkflow CRMStartWorkflowByID(CRMWorkflow crmWF)
 {
     CRMFunctions function = new CRMFunctions(crmWF.Config);
     return function.CRMStartWorkflowByID(crmWF);
 }
        public CRMWorkflow CRMStartWorkflowByID(CRMWorkflow crmWF)
        {
            OrganizationServiceProxy _serviceProxy;
            //IOrganizationService _service;

            using (_serviceProxy = GetCRMConnection())
            {
                try
                {
                    // Create an ExecuteWorkflow request.
                    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
                    {
                        WorkflowId = new Guid(crmWF.WorkflowId),
                        EntityId = new Guid(crmWF.EntityId)
                    };

                    // Execute the workflow.
                    ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)_serviceProxy.Execute(request);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            return crmWF;
        }
        public CRMWorkflow CRMStartWorkflow(CRMWorkflow crmWF)
        {
            string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
          + "<entity name='workflow'>"
            + "<attribute name='workflowid' />"
            + "<attribute name='workflowidunique' />"
            + "<attribute name='name' />"
            + "<attribute name='category' />"
            + "<attribute name='primaryentity' />"
            + "<attribute name='statecode' />"
            + "<attribute name='createdon' />"
            + "<attribute name='ownerid' />"
            + "<attribute name='owningbusinessunit' />"
            + "<attribute name='type' />"
            + "<attribute name='parentworkflowid' />"
            + "<order attribute='name' descending='false' />"
            + "<filter type='and'>"
              + "<condition attribute='statecode' operator='eq' value='1' />"
              + "<condition attribute='name' operator='eq' value='" + crmWF.WorkflowName + "' />"
              + " <condition attribute='parentworkflowid' operator='null' />"
            + "</filter>"
          + "</entity>"
        + "</fetch>";

            CRMFetchXML fx = new CRMFetchXML();
            fx.FetchXML = fetchxml;
            List<CRMState> wf = CRMGetEntities(fx).Entities;

            if (wf.Count > 0)
            {
                crmWF.WorkflowId = wf[0].EntityId;
                CRMStartWorkflowByID(crmWF);
            }

            return crmWF;
        }