コード例 #1
0
    private void Bindddlprocess()
    {
        GetProcess.AppendDataBoundItems = true;
        SqlConnection conn     = new SqlConnection(DbConnect.x);
        String        strQuery = "select distinct Id,OperationName from tblProcess order by OperationName ASC ";
        SqlCommand    cmd      = new SqlCommand();

        cmd.CommandType = CommandType.Text;
        cmd.CommandText = strQuery;
        cmd.Connection  = conn;
        try
        {
            conn.Open();
            GetProcess.DataSource     = cmd.ExecuteReader();
            GetProcess.DataTextField  = "OperationName";
            GetProcess.DataValueField = "Id";

            GetProcess.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
コード例 #2
0
        /// </remarks>
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext)
        {
            if (crmWorkflowContext == null)
            {
                throw new ArgumentNullException("crmWorkflowContext");
            }

            var tracingService = executionContext.GetExtension <ITracingService>();
            var service        = crmWorkflowContext.OrganizationService;
            var context        = crmWorkflowContext.WorkflowExecutionContext;

            var processId = GetProcess.Get(executionContext).Id;
            var fetchXml  = GetFetchQuery.Get(executionContext);


            var recordsToProcess = new EntityCollection();



            // Define the fetch attributes.
            // Set the number of records per page to retrieve.
            int fetchCount = 3;
            // Initialize the page number.
            int pageNumber = 1;

            // Specify the current paging cookie. For retrieving the first page,
            // pagingCookie should be null.
            string pagingCookie = null;



            while (true)
            {
                // Build fetchXml string with the placeholders.
                string xml = CreateXml(fetchXml, pagingCookie, pageNumber, fetchCount);

                // Excute the fetch query and get the xml result.
                RetrieveMultipleRequest fetchRequest1 = new RetrieveMultipleRequest
                {
                    Query = new FetchExpression(xml)
                };

                EntityCollection returnCollection = ((RetrieveMultipleResponse)service.Execute(fetchRequest1)).EntityCollection;

                tracingService.Trace("Page Number: {0} - Number of Applications returned: {1}", pageNumber, returnCollection.Entities.Count());

                recordsToProcess.Entities.AddRange(returnCollection.Entities);

                // Check for morerecords, if it returns 1.
                if (returnCollection.MoreRecords)
                {
                    tracingService.Trace("\n****************\nPage number {0}\n****************", pageNumber);

                    // Increment the page number to retrieve the next page.
                    pageNumber++;

                    // Set the paging cookie to the paging cookie returned from current results.
                    pagingCookie = returnCollection.PagingCookie;
                }
                else
                {
                    // If no more records in the result nodes, exit the loop.
                    break;
                }
            }

            var i = 0;

            foreach (var app in recordsToProcess.Entities)
            {
                tracingService.Trace("{0} -Create an ExecuteWorkflow request for AppId: {1}", i.ToString(), app.Id.ToString());
                ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
                {
                    WorkflowId = processId,
                    EntityId   = app.Id
                };

                // Execute the workflow.
                ExecuteWorkflowResponse response =
                    (ExecuteWorkflowResponse)service.Execute(request);

                tracingService.Trace("and sent request to service.");
            }
        }