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


C# ActivityExecutionContext.GetService方法代码示例

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


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

示例1: Execute

 protected override ActivityExecutionStatus Execute(ActivityExecutionContext aec)
 {
     //get the services needed
     //custom service to run the workflow
     CallWorkflowService ws = aec.GetService<CallWorkflowService>();
     
     //Queuing service to setup the queue so the service can "callback"
     WorkflowQueuingService qs = aec.GetService<WorkflowQueuingService>();
     //create the queue the service can call back on when the child workflow is done
     //you might want the queuename to be something different
     string qn = String.Format("{0}:{1}:{2}", this.WorkflowInstanceId.ToString(), Type.Name, this.Name);
     WorkflowQueue q = qs.CreateWorkflowQueue(qn, false);
     q.QueueItemAvailable += new EventHandler<QueueEventArgs>(q_QueueItemAvailable);
     //copy the params to a new collection
     Dictionary<string, object> inparams = new Dictionary<string, object>();
     foreach (WorkflowParameterBinding bp in this.Parameters)
     {
         PropertyInfo pi = Type.GetProperty(bp.ParameterName);
         if(pi.CanWrite)
             inparams.Add(bp.ParameterName, bp.Value);
     }
     //ask the service to start the workflow
     ws.StartWorkflow(Type, inparams, this.WorkflowInstanceId, qn);
     return ActivityExecutionStatus.Executing;
 }
开发者ID:haimon74,项目名称:KanNaim,代码行数:25,代码来源:CallWorkflow.cs

示例2: Execute

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
                throw new ArgumentNullException("executionContext");
           
            Type type = typeof(IInvokerLocalService);

            object obj = executionContext.GetService(type);
            if (obj == null)
                throw new InvalidOperationException("IInvokerLocalService not found");

            // pre-processing
            base.RaiseEvent(ReturnActivity.InvokingEvent, this, EventArgs.Empty);
            this.OnInvoking(EventArgs.Empty);

            // return object
            object returnValue = null;
            if (this.ConnectorActivityName != "(None)")
            {
                returnValue = this.Parameters.Contains("(ReturnValue)") ? this.Parameters["(ReturnValue)"].GetValue(WorkflowParameterBinding.ValueProperty) : null;
            }

            // fire and forget in sync manner
            object[] args = new object[2] { this.WorkflowInstanceId, returnValue };
            type.InvokeMember("RaiseResponseEvent", BindingFlags.InvokeMethod, null, obj, args);

            return ActivityExecutionStatus.Closed;
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:28,代码来源:ReturnActivity.cs

示例3: Execute

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ExternalRuleSetService.ExternalRuleSetService ruleSetService = context.GetService<ExternalRuleSetService.ExternalRuleSetService>();

            if (ruleSetService != null)
            {
                RuleSet ruleSet = ruleSetService.GetRuleSet(new RuleSetInfo(this.RuleSetName, this.MajorVersion, this.MinorVersion));
                if (ruleSet != null)
                {
                    Activity targetActivity = this.GetRootWorkflow(this.Parent);
                    RuleValidation validation = new RuleValidation(targetActivity.GetType(), null);
                    RuleExecution execution = new RuleExecution(validation, targetActivity, context);
                    ruleSet.Execute(execution);
                }
            }
            else
            {
                throw new InvalidOperationException("A RuleSetService must be configured on the host to use the PolicyFromService activity.");
            }

            return ActivityExecutionStatus.Closed;
        }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:27,代码来源:PolicyFromService.cs

示例4: DeleteQueue

 internal void DeleteQueue(ActivityExecutionContext context)
 {
     if (StateMachineHelpers.IsRootExecutionContext(context))
     {
         WorkflowQueuingService service = context.GetService<WorkflowQueuingService>();
         service.GetWorkflowQueue("SetStateQueue");
         service.DeleteWorkflowQueue("SetStateQueue");
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:SetStateSubscription.cs

示例5: CreateQueue

 internal void CreateQueue(ActivityExecutionContext context)
 {
     if (StateMachineHelpers.IsRootExecutionContext(context))
     {
         WorkflowQueuingService service = context.GetService<WorkflowQueuingService>();
         MessageEventSubscription subscription = new MessageEventSubscription("SetStateQueue", this._instanceId);
         service.CreateWorkflowQueue("SetStateQueue", true);
         base.SubscriptionId = subscription.SubscriptionId;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:SetStateSubscription.cs

示例6: Execute

        protected override sealed ActivityExecutionStatus Execute(ActivityExecutionContext context)
        {
            // Fire the Before Invoke Handler
            base.RaiseEvent(OnBeforeInvokeEvent, this, EventArgs.Empty);

            // Get reference to the transactional service from the context
            AbstractTransactionService service = context.GetService<AbstractTransactionService>();
            // Call a method on the service and pass the payload to it
            service.DebitAmount(this.Amount);

            // Return the status of the activity as closed
            return ActivityExecutionStatus.Closed;
        }
开发者ID:ssickles,项目名称:archive,代码行数:13,代码来源:DebitAmount.cs

示例7: ProcessEvent

 internal override void ProcessEvent(ActivityExecutionContext context)
 {
     SetStateEventArgs args = context.GetService<WorkflowQueuingService>().GetWorkflowQueue("SetStateQueue").Dequeue() as SetStateEventArgs;
     StateActivity currentState = StateMachineHelpers.GetCurrentState(context);
     if (currentState == null)
     {
         throw new InvalidOperationException(SR.GetStateMachineWorkflowMustHaveACurrentState());
     }
     StateMachineExecutionState state = StateMachineExecutionState.Get(StateMachineHelpers.GetRootState((StateActivity) context.Activity));
     SetStateAction action = new SetStateAction(currentState.QualifiedName, args.TargetStateName);
     state.EnqueueAction(action);
     state.ProcessActions(context);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:SetStateSubscription.cs

示例8: Execute

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            {
               List<string> ls = executionContext.GetService(typeof(List<string>)) as List<string>;
               if (ls != null)
               {
                   ls.Add("--------------------------归档-----------------------------------");
                   ls.Add("流程编号:" + Root().流程编号.ToString());
                   ls.Add("");
               }
            }

            return base.Execute(executionContext);
        }
开发者ID:wanghuifeng,项目名称:wxwinterwfWFDesigner,代码行数:14,代码来源:归档.cs

示例9: ExecuteForActivity

 internal static ActivityExecutionStatus ExecuteForActivity(HandleExternalEventActivity activity, ActivityExecutionContext context, Type interfaceType, string operation, out object[] args)
 {
     WorkflowQueuingService queueSvcs = (WorkflowQueuingService) context.GetService(typeof(WorkflowQueuingService));
     args = null;
     IComparable queueId = CorrelationService.ResolveQueueName(activity, interfaceType, operation);
     if (queueId != null)
     {
         WorkflowQueue queue;
         object msg = DequeueMessage(queueId, queueSvcs, activity, out queue);
         CorrelationService.UninitializeFollowers(interfaceType, operation, queue);
         if (msg != null)
         {
             args = ProcessEvent(activity, context, msg, interfaceType, operation);
             return ActivityExecutionStatus.Closed;
         }
     }
     return ActivityExecutionStatus.Executing;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:InboundActivityHelper.cs

示例10: Execute

 protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
 {
     if (executionContext == null)
     {
         throw new ArgumentNullException("executionContext");
     }
     if (this.Fault == null)
     {
         throw new InvalidOperationException(SR.GetString(CultureInfo.CurrentCulture, "Error_PropertyNotSet", new object[] { FaultProperty.Name }));
     }
     WorkflowQueuingService service = executionContext.GetService<WorkflowQueuingService>();
     base.RaiseEvent(SendingFaultEvent, this, EventArgs.Empty);
     WebServiceInputActivity activityByName = base.GetActivityByName(this.InputActivityName) as WebServiceInputActivity;
     IComparable queueName = new EventQueueName(activityByName.InterfaceType, activityByName.MethodName, activityByName.QualifiedName);
     IMethodResponseMessage message = null;
     WorkflowQueue workflowQueue = service.GetWorkflowQueue(queueName);
     if (workflowQueue.Count != 0)
     {
         message = workflowQueue.Dequeue() as IMethodResponseMessage;
     }
     message.SendException(this.Fault);
     return ActivityExecutionStatus.Closed;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:23,代码来源:WebServiceFaultActivity.cs

示例11: Execute

 protected sealed override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
 {
     if (executionContext == null)
     {
         throw new ArgumentNullException("executionContext");
     }
     if (this.InterfaceType == null)
     {
         throw new ArgumentException(SR.GetString("Error_MissingInterfaceType"), "executionContext");
     }
     Type interfaceType = this.InterfaceType;
     string methodName = this.MethodName;
     object service = executionContext.GetService(interfaceType);
     if (service == null)
     {
         throw new InvalidOperationException(SR.GetString("Error_ServiceNotFound", new object[] { this.InterfaceType }));
     }
     base.RaiseEvent(MethodInvokingEvent, this, EventArgs.Empty);
     this.OnMethodInvoking(EventArgs.Empty);
     MethodInfo method = interfaceType.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance);
     ParameterModifier[] parameterModifiers = null;
     object[] messageArgs = InvokeHelper.GetParameters(method, this.ParameterBindings, out parameterModifiers);
     WorkflowParameterBinding binding = null;
     if (this.ParameterBindings.Contains("(ReturnValue)"))
     {
         binding = this.ParameterBindings["(ReturnValue)"];
     }
     CorrelationService.InvalidateCorrelationToken(this, interfaceType, methodName, messageArgs);
     object source = interfaceType.InvokeMember(this.MethodName, BindingFlags.InvokeMethod, new ExternalDataExchangeBinder(), service, messageArgs, parameterModifiers, null, null);
     if (binding != null)
     {
         binding.Value = InvokeHelper.CloneOutboundValue(source, new BinaryFormatter(), "(ReturnValue)");
     }
     InvokeHelper.SaveOutRefParameters(messageArgs, method, this.ParameterBindings);
     this.OnMethodInvoked(EventArgs.Empty);
     return ActivityExecutionStatus.Closed;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:CallExternalMethodActivity.cs

示例12: WorkflowHistoryTraceListener

        public WorkflowHistoryTraceListener(ActivityExecutionContext context, Guid workflowInstanceID)
        {
            service = (ISharePointService)context.GetService(typeof(ISharePointService));

            if (service == null)
            {
                throw new InvalidOperationException();
            }

            this.workflowInstanceID = workflowInstanceID;
        }
开发者ID:chutinhha,项目名称:tvmcorptvs,代码行数:11,代码来源:Common.cs

示例13: SetTimer

		protected IComparable SetTimer (ActivityExecutionContext executionContext, DateTime expiresAt)
		{
		#if RUNTIME_DEP
			TimerEventSubscription te;
			WorkflowQueue queue;

			te = new TimerEventSubscription (executionContext.ExecutionContextManager.Workflow.InstanceId,
				expiresAt);

			WorkflowQueuingService qService = executionContext.GetService <WorkflowQueuingService> ();
		    	queue = qService.CreateWorkflowQueue (te.QueueName, true);
		    	queue.QueueItemArrived += OnQueueTimerItemArrived;
			executionContext.ExecutionContextManager.Workflow.TimerEventSubscriptionCollection.Add (te);
			return te.QueueName;
		#else
			return null;
		#endif

		}
开发者ID:alesliehughes,项目名称:olive,代码行数:19,代码来源:Activity.cs

示例14: Execute

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            if (executionContext == null)
                throw new ArgumentNullException("executionContext");

            WorkflowQueuingService queueService = executionContext.GetService<WorkflowQueuingService>();

            // fire event
            this.RaiseEvent(WebServiceOutputActivity.SendingOutputEvent, this, EventArgs.Empty);

            WebServiceInputActivity webservicereceive = this.GetActivityByName(this.InputActivityName) as WebServiceInputActivity;
            if (webservicereceive == null)
            {
                Activity parent = this.Parent;
                while (parent != null)
                {
                    //typically if defined inside a custom activity
                    string qualifiedName = parent.QualifiedName + "." + this.InputActivityName;
                    webservicereceive = this.GetActivityByName(qualifiedName) as WebServiceInputActivity;
                    if (webservicereceive != null)
                        break;
                    parent = this.Parent;
                }
            }
            if (webservicereceive == null)
                throw new InvalidOperationException(SR.GetString(SR.Error_CannotResolveWebServiceInput, this.QualifiedName, this.InputActivityName));

            IComparable queueId = new EventQueueName(webservicereceive.InterfaceType, webservicereceive.MethodName, webservicereceive.QualifiedName);

            MethodInfo mInfo = webservicereceive.InterfaceType.GetMethod(webservicereceive.MethodName);
            if (!queueService.Exists(queueId))
            {
                // determine if no response is required,
                // compiler did not catch it, do the runtime check and return
                if (mInfo.ReturnType == typeof(void))
                {
                    return ActivityExecutionStatus.Closed;
                }

                bool isresponseRequired = false;
                foreach (ParameterInfo formalParameter in mInfo.GetParameters())
                {
                    if (formalParameter.ParameterType.IsByRef || (formalParameter.IsIn && formalParameter.IsOut))
                    {
                        isresponseRequired = true;
                    }
                }

                if (isresponseRequired)
                {
                    return ActivityExecutionStatus.Closed;
                }
            }

            if (!queueService.Exists(queueId))
                throw new InvalidOperationException(SR.GetString(SR.Error_WebServiceInputNotProcessed, webservicereceive.QualifiedName));

            IMethodResponseMessage responseMessage = null;
            WorkflowQueue queue = queueService.GetWorkflowQueue(queueId);

            if (queue.Count != 0)
                responseMessage = queue.Dequeue() as IMethodResponseMessage;

            IMethodMessage message = responseMessage as IMethodMessage;

            WorkflowParameterBindingCollection parameterBindings = this.ParameterBindings;
            ArrayList outArgs = new ArrayList();
            // populate result
            if (this.ParameterBindings.Contains("(ReturnValue)"))
            {
                WorkflowParameterBinding retBind = this.ParameterBindings["(ReturnValue)"];
                if (retBind != null)
                {
                    outArgs.Add(retBind.Value);
                }
            }

            foreach (ParameterInfo formalParameter in mInfo.GetParameters())
            {
                // update out and byref values
                if (formalParameter.ParameterType.IsByRef || (formalParameter.IsIn && formalParameter.IsOut))
                {
                    WorkflowParameterBinding binding = parameterBindings[formalParameter.Name];
                    outArgs.Add(binding.Value);
                }
            }

            // reset the waiting thread
            responseMessage.SendResponse(outArgs);

            return ActivityExecutionStatus.Closed;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:92,代码来源:WebServiceResponse.cs

示例15: Unsubscribe

 internal void Unsubscribe(ActivityExecutionContext context)
 {
     context.GetService<WorkflowQueuingService>().GetWorkflowQueue("SetStateQueue").UnregisterForQueueItemAvailable(this);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:SetStateSubscription.cs


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