当前位置: 首页>>代码示例>>C#>>正文


C# CodeActivityContext.GetExtension方法代码示例

本文整理汇总了C#中CodeActivityContext.GetExtension方法的典型用法代码示例。如果您正苦于以下问题:C# CodeActivityContext.GetExtension方法的具体用法?C# CodeActivityContext.GetExtension怎么用?C# CodeActivityContext.GetExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeActivityContext的用法示例。


在下文中一共展示了CodeActivityContext.GetExtension方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

 protected override void Execute(CodeActivityContext executionContext)
 {
     Boolean Logging = EnableLogging.Get(executionContext);
     string LogFilePath = LogFile.Get(executionContext);
     EntityReference Email = EmailId.Get(executionContext);
     try
     {
         if (Logging)
             Log("Workflow Execution Start", LogFilePath);
         IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
         IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
         IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
         if (Logging)
             Log("Sending Email", LogFilePath);
         SendEmailRequest sendEmailreq = new SendEmailRequest();
         sendEmailreq.EmailId = Email.Id;
         sendEmailreq.TrackingToken = "";
         sendEmailreq.IssueSend = true;
         SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);
         if (Logging)
             Log("Workflow Executed Successfully", LogFilePath);
     }
     catch (Exception ex)
     {
         Log(ex.Message, LogFilePath);
     }
 }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:27,代码来源:SendEmail.cs

示例2: Execute

        protected override void Execute(CodeActivityContext context)
        {
            //initialization code
            try
            {
                // Get the tracing service
                ITracingService tracingService =
                context.GetExtension<ITracingService>();

                // Get the context service.
                IWorkflowContext mycontext =
                context.GetExtension<IWorkflowContext>();

                IOrganizationServiceFactory serviceFactory =
                context.GetExtension<IOrganizationServiceFactory>();

                // Use the context service to create an instance of CrmService.
                IOrganizationService crmService =
                serviceFactory.CreateOrganizationService(mycontext.UserId);

                //Split parameters by Pipe
                string[] parameters = inSPParams.Get(context).Split('|');

                //create object parameters for sqlhelper
                object[] sqlPars = new object[parameters.Length];

                for (int i = 0; i < parameters.Length; i++)
                {
                    sqlPars[i] = parameters[i];
                }

                //format connection string
                string conn = String.Format("Data Source={0};Initial Catalog={1};User Id={2};Password={3}",
                                            inSPDBInstance.Get(context),
                                            inSPDatabase.Get(context),
                                            inUsername.Get(context),
                                            inPassword.Get(context));

                //Execute DataSet
                DataSet ds = SqlHelper.ExecuteDataset(conn, inSPName.Get(context), sqlPars);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        SPResult.Set(context, ds.Tables[0].Rows[0][0].ToString());
                    }
                    else
                        SPResult.Set(context, "0");
                }
                else
                {
                    SPResult.Set(context, "0");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:hbrenes,项目名称:onestopxrm,代码行数:60,代码来源:ExecuteSQLSP.cs

示例3: Execute

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        protected override void Execute(CodeActivityContext context)
        {
            var token = context.GetExtension<ActivityCancellationToken>();
            var notify = context.GetExtension<SpinNotify>();
            for (int i = 0; i < this.Loops; i++)
            {
                WorkflowTrace.Verbose(
                    "SpinWaiter loop {0} of {1}, spinning {2} iterations", i, this.Loops, this.Iterations);

                // Don't do this from a Code or Native Activity
                // The activity will be faulted
                // token.ThrowIfCancellationRequested();
                if (token != null && token.IsCancellationRequested(context))
                {
                    return;
                }

                Thread.SpinWait(this.Iterations);
                if (notify != null)
                {
                    notify.LoopComplete(this.Loops, this.Iterations);
                }
            }

            WorkflowTrace.Verbose("SpinWaiter done with {0} iterations", this.Iterations * this.Loops);
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:32,代码来源:SpinWaiter.cs

示例4: Execute

        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();
            //Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
            Entity entity = null;
            var inputs = context.InputParameters;
            if (context.InputParameters.Contains("target"))
                entity = (Entity)context.InputParameters["target"];

            if (entity == null)
                return;
            DocLogic logic = new DocLogic(service);
            LoadDocParametersFactory loadDocParametersFactory = null;
            var subject = Subject.Get(executionContext);
            switch (entity.LogicalName)
            {
                case "opportunity":
                    loadDocParametersFactory = new OpportunityParametersFactory(service, entity, subject);
                    break;
                case "new_order":
                    loadDocParametersFactory = new OrderParametersFactory(service, entity, subject);
                    break;
                default:
                    loadDocParametersFactory = null;
                    break;
            }
            logic.Excute(loadDocParametersFactory);
        }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:32,代码来源:DocsFindMissions.cs

示例5: Execute

        /// <summary>
        /// NOTE: When you add this activity to a workflow, you must set the following properties:
        ///
        /// URL - manually add the URL to which you will be posting data.  For example: http://myserver.com/ReceivePostURL.aspx  
        ///		 See this sample's companion file 'ReceivePostURL.aspx' for an example of how the receiving page might look.
        ///
        /// AccountName - populate this property with the Account's 'name' attribute.
        ///
        /// AccountNum - populate this property with the Account's 'account number' attribute.
        /// </summary>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory =
                executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);

            // Build data that will be posted to a URL
            string postData = "Name=" + this.AccountName.Get(executionContext) + "&AccountNum=" + this.AccountNum.Get(executionContext);

            // Encode the data
            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] encodedPostData = encoding.GetBytes(postData);

            // Create a request object for posting our data to a URL
            Uri uri = new Uri(this.URL.Get(executionContext));
            HttpWebRequest urlRequest = (HttpWebRequest)WebRequest.Create(uri);
            urlRequest.Method = "POST";
            urlRequest.ContentLength = encodedPostData.Length;
            urlRequest.ContentType = "application/x-www-form-urlencoded";

            // Add the encoded data to the request	
            using (Stream formWriter = urlRequest.GetRequestStream())
            {
                formWriter.Write(encodedPostData, 0, encodedPostData.Length);
            }

            // Post the data to the URL			
            HttpWebResponse urlResponse = (HttpWebResponse)urlRequest.GetResponse();
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:41,代码来源:PostUrl.cs

示例6: Execute

        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered " + _processName + ".Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                executionContext.ActivityInstanceId,
                executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace(_processName + ".Execute(), Correlation Id: {0}, Initiating User: {1}",
                context.CorrelationId,
                context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                //do the regex match
                Match match = Regex.Match(StringToValidate.Get(executionContext), MatchPattern.Get(executionContext),
                    RegexOptions.IgnoreCase);

                //did we match anything?
                if (match.Success)
                {
                    Valid.Set(executionContext, 1);
                }
                else
                {
                    Valid.Set(executionContext, 0);
                }
            }
            catch (FaultException<OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }
            catch (Exception e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());
                throw;
            }

            tracingService.Trace("Exiting " + _processName + ".Execute(), Correlation Id: {0}", context.CorrelationId);
        }
开发者ID:milos01,项目名称:Crm-Sample-Code,代码行数:64,代码来源:ValidateRegex.cs

示例7: Execute

 protected override void Execute(CodeActivityContext executionContext)
 {
     Boolean Logging = EnableLogging.Get(executionContext);
     string LogFilePath = LogFile.Get(executionContext);
     EntityReference Attachment = AttachmentId.Get(executionContext);
     string entityName = EntityName.Get(executionContext);
     string recordId = RecordId.Get(executionContext);
     try
     {
         if (Logging)
             Log("Workflow Execution Start", LogFilePath);
         if (ValidateParameters(executionContext))
         {
             IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
             IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
             IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
             if (Logging)
                 Log("Attaching Attachment", LogFilePath);
             Entity UpdatedAttachment = new Entity("annotation");
             UpdatedAttachment.Id = Attachment.Id;
             UpdatedAttachment.Attributes.Add("objectid", new EntityReference(entityName, new Guid(recordId)));
             service.Update(UpdatedAttachment);
             if (Logging)
                 Log("Attachment linked successfully", LogFilePath);
             if (Logging)
                 Log("Workflow Executed Successfully", LogFilePath);
         }
     }
     catch (Exception ex)
     {
         Log(ex.Message, LogFilePath);
     }
 }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:33,代码来源:AttachToEntity.cs

示例8: Execute

        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension<ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered " + _activityName + ".Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                executionContext.ActivityInstanceId,
                executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace(_activityName + ".Execute(), Correlation Id: {0}, Initiating User: {1}",
                context.CorrelationId,
                context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                EntityCollection recordsToProcess = service.RetrieveMultiple(new FetchExpression(FetchXMLQuery.Get(executionContext)));
                recordsToProcess.Entities.ToList().ForEach(a =>
                {
                    ExecuteWorkflowRequest request = new ExecuteWorkflowRequest
                    {
                        EntityId = a.Id,
                        WorkflowId = (Workflow.Get(executionContext)).Id
                    };

                    service.Execute(request); //run the workflow
                });

            }
            catch (FaultException<OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }
            catch (Exception e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());
                throw;
            }

            tracingService.Trace("Exiting StartScheduledWorkflows.Execute(), Correlation Id: {0}", context.CorrelationId);
        }
开发者ID:nwest88,项目名称:WestCustomWorkflowSolutions,代码行数:63,代码来源:StartScheduledWorkflows.cs

示例9: Execute

        /// <summary>
        /// This method is called when the workflow executes.
        /// </summary>
        /// <param name="executionContext">The data for the event triggering
        /// the workflow.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

            IServiceEndpointNotificationService endpointService =
                     executionContext.GetExtension<IServiceEndpointNotificationService>();
            endpointService.Execute(ServiceEndpoint.Get(executionContext), context);
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:13,代码来源:Activity.cs

示例10: Execute

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument

            bool doFlush = context.GetValue(this.DoFlush);
            List<string> text = context.GetValue(this.Text);
            if (doFlush)
                context.GetExtension<List<string>>().Clear();
            context.GetExtension<List<string>>().AddRange(text);
        }
开发者ID:blel,项目名称:WpfWithWf,代码行数:12,代码来源:AssignToExtensionActivity.cs

示例11: Execute

        /// <summary>
        /// Checks if the "Est. Close Date" is greater than 10 days. If it is,
        /// send an email to the administrator so that s/he can verify close date
        /// with the owner of the opportunity.
        /// </summary>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory =
                    executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service =
                    serviceFactory.CreateOrganizationService(context.UserId);

            // Get opportunity entity
            Entity opportunity = service.Retrieve("opportunity", 
                this.inputOpportunity.Get(executionContext).Id, new ColumnSet("estimatedclosedate"));

            // Calulate 10 days from today
            DateTime todayPlusTen = DateTime.UtcNow.AddDays(10.0);

            // Check "Est. Close Date"
            if (opportunity.Contains("estimatedclosedate"))
            {
                DateTime estCloseDate = (DateTime)opportunity["estimatedclosedate"];
                if (DateTime.Compare(estCloseDate, todayPlusTen) > 0)
                {
                    // Need system user id for activity party
                    WhoAmIRequest systemUserRequest = new WhoAmIRequest();
                    WhoAmIResponse systemUser = 
                        (WhoAmIResponse)service.Execute(systemUserRequest);

                    // Create an activity party for the email
                    Entity[] activityParty = new Entity[1];
                    activityParty[0] = new Entity("activityparty");
                    activityParty[0]["partyid"] = 
                        new EntityReference("systemuser", systemUser.UserId);

                    // Create an email message
                    Entity email = new Entity("email");
                    email.LogicalName = "email";
                    email["subject"] = 
                        "Warning: Close date has been extended more than 10 days.";
                    email["description"] = "Verify close date is correct.";
                    email["to"] = activityParty;
                    email["from"] = activityParty;
                    email["regardingobjectid"] = opportunity.ToEntityReference();
                    Guid emailId = service.Create(email);

                    // Send email
                    SendEmailRequest sendEmailRequest = new SendEmailRequest();
                    sendEmailRequest.EmailId = emailId;
                    sendEmailRequest.IssueSend = true;
                    sendEmailRequest.TrackingToken = "";
                    SendEmailResponse sendEmailResponse = 
                        (SendEmailResponse)service.Execute(sendEmailRequest);
                }
            }
        }
开发者ID:cesugden,项目名称:Scripts,代码行数:58,代码来源:DateChecker.cs

示例12: Execute

        /// <summary>
        /// Performs the addition of two summands
        /// </summary>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory =
                executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);


            // Retrieve the summands and perform addition
            this.MessageName.Set(executionContext, context.MessageName);
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:15,代码来源:CheckContextPropertyActivity.cs

示例13: Execute

 protected override void Execute(CodeActivityContext executionContext)
 {
     Boolean Logging = EnableLogging.Get(executionContext);
     string LogFilePath = LogFile.Get(executionContext);
     EntityReference Email = EmailId.Get(executionContext);
     EntityReference Attachment = AttachmentId.Get(executionContext);
     try
     {
         if (Logging)
             Log("Workflow Execution Start", LogFilePath);
         // Create CRM Service in Workflow
         IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
         IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
         IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
         if (Logging)
             Log("Retrieving Attahment", LogFilePath);
         // Retrieve the Attachment from the given template
         Entity TempAttachment = service.Retrieve("annotation", Attachment.Id, new ColumnSet(true));
         if (TempAttachment != null)
         {
             if (Logging)
                 Log("Creating New Attachment", LogFilePath);
             // Create new Attachment under Email Activity
             Entity NewAttachment = new Entity("activitymimeattachment");
             if (TempAttachment.Contains("subject"))
                 NewAttachment.Attributes.Add("subject", TempAttachment["subject"]);
             if (TempAttachment.Contains("filename"))
                 NewAttachment.Attributes.Add("filename", TempAttachment["filename"]);
             if (TempAttachment.Contains("mimetype"))
                 NewAttachment.Attributes.Add("mimetype", TempAttachment["mimetype"]);
             if (TempAttachment.Contains("documentbody"))
                 NewAttachment.Attributes.Add("body", TempAttachment["documentbody"]);
             NewAttachment.Attributes.Add("objectid", new EntityReference(Email.LogicalName, Email.Id));
             NewAttachment.Attributes.Add("objecttypecode", "email");
             NewAttachment.Attributes.Add("attachmentnumber", 1);
             service.Create(NewAttachment);
             if (Logging)
                 Log("New Attachment Added To Email", LogFilePath);
         }
         else
         {
             if (Logging)
                 Log("Temp Attachment doesnot exist", LogFilePath);
         }
         if (Logging)
             Log("Workflow Executed Successfully", LogFilePath);
     }
     catch (Exception ex)
     {
         Log(ex.Message, LogFilePath);
     }
 }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:52,代码来源:AttachToEmail.cs

示例14: Execute

        /// <summary>
        /// Performs the addition of two summands
        /// </summary>
        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory =
                executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);


            // Retrieve the summands and perform addition
            this.result.Set(executionContext,
                this.firstSummand.Get(executionContext) +
                this.secondSummand.Get(executionContext));
        }
开发者ID:ccellar,项目名称:fake-xrm-easy,代码行数:17,代码来源:AddActivity.cs

示例15: Execute

 protected override void Execute(CodeActivityContext executionContext)
 {
     Boolean Logging = EnableLogging.Get(executionContext);
     EntityReference Letter = LetterId.Get(executionContext);
     EntityReference Attachment = AttachmentId.Get(executionContext);
     IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
     IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
     IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
     try
     {
         if (Logging)
             Log("Workflow Execution Start",service);
         if (Logging)
             Log("Retrieving Attahment", service);
         Entity TempAttachment = service.Retrieve("annotation", Attachment.Id, new ColumnSet(true));
         if (TempAttachment != null)
         {
             if (Logging)
                 Log("Creating New Attachment", service);
             Entity NewAttachment = new Entity("annotation");
             if (TempAttachment.Contains("subject"))
                 NewAttachment.Attributes.Add("subject", TempAttachment["subject"]);
             if (TempAttachment.Contains("filename"))
                 NewAttachment.Attributes.Add("filename", TempAttachment["filename"]);
             if (TempAttachment.Contains("notetext"))
                 NewAttachment.Attributes.Add("notetext", TempAttachment["notetext"]);
             if (TempAttachment.Contains("mimetype"))
                 NewAttachment.Attributes.Add("mimetype", TempAttachment["mimetype"]);
             if (TempAttachment.Contains("documentbody"))
                 NewAttachment.Attributes.Add("documentbody", TempAttachment["documentbody"]);
             NewAttachment.Attributes.Add("objectid", new EntityReference(Letter.LogicalName, Letter.Id));
             service.Create(NewAttachment);
             if (Logging)
                 Log("New Attachment Added To Letter", service);
         }
         else
         {
             if (Logging)
                 Log("Temp Attachment doesnot exist", service);
         }
         if (Logging)
             Log("Workflow Executed Successfully", service);
     }
     catch (Exception ex)
     {
         Log(ex.Message, service);
         throw ex;
     }
 }
开发者ID:ZeeshanShafqat,项目名称:Aspose_Words_Cloud,代码行数:49,代码来源:AttachToLetter.cs


注:本文中的CodeActivityContext.GetExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。