void InvokeOnClient(ObjectChangedEventArgs objectChangedEventArgs, ObjectChangedWorkflow objectChangedWorkflow, object targetObjectKey) { Activity activity = ActivityXamlServices.Load(new StringReader(objectChangedWorkflow.Xaml)); var dictionary = ObjectChangedStartWorkflowService.Dictionary(targetObjectKey, objectChangedEventArgs.PropertyName, objectChangedEventArgs.OldValue); WorkflowInvoker.Invoke(activity, dictionary); }
ObjectChangedEventArgs GetObjectChangedEventArgs(ObjectChangedWorkflow objectChangedWorkflow) { var objectChangedEventArgs = _objectChangedEventArgses.FirstOrDefault(args => new Regex(objectChangedWorkflow.PropertyName).IsMatch(args.PropertyName) && args.Object.GetType() == objectChangedWorkflow.TargetObjectType); return(objectChangedEventArgs); }
void InvokeOnClient(ObjectChangedEventArgs objectChangedEventArgs, ObjectChangedWorkflow objectChangedWorkflow, object targetObjectKey) { Activity activity = ActivityXamlServices.Load(new StringReader(objectChangedWorkflow.Xaml)); var dictionary = StartWorkflowOnObjectChangeService.Dictionary(targetObjectKey, objectChangedEventArgs.PropertyName, objectChangedEventArgs.OldValue); WorkflowInvoker invoker = new WorkflowInvoker(activity); invoker.Extensions.Add(Application.ObjectSpaceProvider); invoker.Invoke(dictionary); }
void CreateServerRequest(ObjectChangedEventArgs objectChangedEventArgs, ObjectChangedWorkflow objectChangedWorkflow, object targetObjectKey, ITypeInfo typeInfo) { var request = ObjectSpace.CreateObject <ObjectChangedXpoStartWorkflowRequest>(); request.TargetWorkflowUniqueId = objectChangedWorkflow.GetUniqueId(); request.TargetObjectType = typeInfo.Type; request.TargetObjectKey = targetObjectKey; request.PropertyName = objectChangedEventArgs.PropertyName; request.OldValue = GetOldValue(objectChangedEventArgs); }
void StartWorkFlow(ObjectChangedEventArgs objectChangedEventArgs, ObjectChangedWorkflow objectChangedWorkflow) { var o = objectChangedEventArgs.Object; ITypeInfo typeInfo = XafTypesInfo.Instance.FindTypeInfo(o.GetType()); object targetObjectKey = typeInfo.KeyMember.GetValue(o); if (objectChangedWorkflow.ExecutionDomain == ExecutionDomain.Server) { CreateServerRequest(objectChangedEventArgs, objectChangedWorkflow, targetObjectKey, typeInfo); } else { InvokeOnClient(objectChangedEventArgs, objectChangedWorkflow, targetObjectKey); } }
ObjectChangedEventArgs GetObjectChangedEventArgs(ObjectChangedWorkflow objectChangedWorkflow) { ObjectChangedEventArgs objectChangedEventArgs = _objectChangedEventArgses.FirstOrDefault(args => args.PropertyName == objectChangedWorkflow.PropertyName && args.Object.GetType() == objectChangedWorkflow.TargetObjectType); return(objectChangedEventArgs); }