protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); if (callBack != null) { callBack.SendClientNotification(new ComponentProcessMessage().CreateServerMessage( Batch.Get(context).Id, Group.Get(context).Id, new Guid(), "Group Started")); } Thread thread = new Thread(DoProcess) { IsBackground = true }; var result = new AsyncGroupResult(callback, state) { ComponentList = ComponentList.Get(context), GroupNode = GroupNode.Get(context), Batch = Batch.Get(context), Group = Group.Get(context), RunningThread = thread, GroupCallback = context.GetExtension <INotificationCallback>() }; context.UserState = result; thread.Start(result); return(result); }
private static IEnumerable <ComponentNode> ExcuteComplexStartNode(List <ComponentNode> paramList, ComponentNode startNode, ICollection <ExtraProcessInfo> extraProcessInfos, INotificationCallback callback, ProcessBatch batch, ProcessGroup group, ProcessJob job) { Guid zero = new Guid(); IEnumerable <ComponentNode> childParams = from p in paramList where (p.ParentIdList.FirstOrDefault(pl => pl == startNode.Id) != zero) select p; IExecuteStartupComponent component = ProcessObjectLocator.LocateStartComponentProcess(startNode.CompopnentExcutionName); if (component != null) { //do waht ever client initiation here IResultForNextNode obj = component.ExecuteStartupComponent(batch, group, job, extraProcessInfos, paramList, startNode, callback); //since startup node takes raw file usually open it foreach (var param in paramList) { //set iRaw Data to each ComponentParameters param.StartupResult = obj; param.TreeExecutionTag = startNode.TreeExecutionTag; param.ParentComponentResults = new List <IResultForNextNode>(); param.ParentComponentResults.Add(obj); param.ProcessedParentCount = 0; } } return(childParams); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); if (callBack != null) { } Thread thread = new Thread(DoProcess) { IsBackground = true }; var startNode = ComponentParameters.Get(context)[0].FindStartupNode(ComponentParameters.Get(context)); Workflow.Activities.AsyncNodeResult result = new Workflow.Activities.AsyncNodeResult(callback, state) { ComponentList = ComponentParameters.Get(context), StartNode = startNode, Batch = Batch.Get(context), Job = (ProcessJob)(Batch.Get(context)).Groups[0].Jobs[0], Group = Batch.Get(context).Groups[0], JobCallback = context.GetExtension <INotificationCallback>(), RunningThread = thread, }; context.UserState = result; thread.Start(result); return(result); }
private static ComponentNode ExcuteComplexComponentNode(List <ComponentNode> paramList, ComponentNode thisNode, INotificationCallback callback, ProcessBatch batch, ProcessGroup group, ProcessJob job) { ComponentNode nextNode = null; if (thisNode.CompNodeValidation == NodeValidationType.Group) { return(thisNode); } Debug.WriteLine(thisNode.ComponentName); thisNode.ProcessedParentCount++; if (thisNode.ProcessedParentCount != thisNode.ParentIdList.Count) { // _excutableInWait.Add(thisNode); return(null); } Guid zero = new Guid(); var childrenParams = (from p in paramList where (p.ParentIdList.FirstOrDefault(pl => pl == thisNode.Id) != zero) select p).ToList(); // IEnumerable<ComponentNode> childrenParams = from p in paramList where p.ParentId == thisNode.Id select p; //IExcuteComponent component = ProcessObjectLocator.LocateComponentProcess(thisNode.CompopnentExcutionName); Type tp = ProcessRunTimeLocator.GetExecutableType(thisNode.CompopnentExcutionName); if (tp == null) { return(null); } IExcuteComponent component = (IExcuteComponent)Activator.CreateInstance(tp); if (component != null) { IResultForNextNode ret = component.ExcuteThermoComponent(paramList, thisNode, callback, batch, group, job); if (ret != null) { ret.ThisNodeId = thisNode.Id; foreach (var param in childrenParams) { param.ParentComponentResults.Add(ret); } } } thisNode.ParentComponentResults.Clear(); //_excutableInWait.Remove(thisNode); thisNode.ProcessedParentCount = 0; foreach (var childrenParam in childrenParams) { nextNode = ExcuteComplexComponentNode(paramList, childrenParam, callback, batch, group, job); } return(nextNode); }
private void Init(INotificationCallback callbackObject) { this.innerFactory = new DuplexChannelFactory <INotificationService>(callbackObject, "NotificationService"); this.innerFactory.Closed += (sender, e) => this.OnClosed(e); this.innerFactory.Closing += (sender, e) => this.OnClosing(e); this.innerFactory.Faulted += (sender, e) => this.OnFaulted(e); this.innerFactory.Opened += (sender, e) => this.OnOpened(e); this.innerFactory.Opening += (sender, e) => this.OnOpening(e); this.CallbackObject = callbackObject; }
protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { AsyncNodeResult endResult = result as AsyncNodeResult; if (endResult.Exception != null) { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); if (callBack != null) { callBack.SendClientNotification(new ComponentProcessMessage().CreateErrorMessage( Batch.Get(context).Id, Group.Get(context).Id, Job.Get(context).Id, endResult.Exception.Message)); } log4net.ILog log4Net = context.GetExtension <log4net.ILog>(); if (log4Net != null) { log4Net.Fatal(new ComponentProcessMessage().CreateErrorMessage( Batch.Get(context).Id, Group.Get(context).Id, Job.Get(context).Id, endResult.Exception.Message)); } } else { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); if (callBack != null) { callBack.SendClientNotification(new ComponentProcessMessage().CreateServerMessage( Batch.Get(context).Id, Group.Get(context).Id, Job.Get(context).Id, "Job Ended")); } } if (endResult != null && endResult.NextNode != null) { NextParameter.Set(context, endResult.NextNode); endResult.Dispose(); } if (endResult.Exception != null && !context.IsCancellationRequested) { //throw new ApplicationException("Error generating reports. See inner for details", endResult.Exception); } }
public ExchangeUpdate(INotificationCallback notificationCallback) { _notificationCallback = notificationCallback; _exchange = new ExchangeService(ExchangeVersion.Exchange2013_SP1) { TraceEnabled = false, PreferredCulture = CultureInfo.CurrentCulture }; Timer timer = new Timer { Interval = _trayUpdateInterval.TotalMilliseconds, Enabled = true, AutoReset = true, }; timer.Elapsed += (sender, e) => Update(); timer.Start(); }
protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result) { AsyncGroupResult endResult = result as AsyncGroupResult; if (endResult != null) { NextNode.Set(context, endResult.NextNode); endResult.Dispose(); } if (endResult.Exception != null) { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); callBack.SendClientNotification(new ComponentProcessMessage().CreateErrorMessage( Batch.Get(context).Id, Group.Get(context).Id, new Guid(), endResult.Exception.Message)); } else { INotificationCallback callBack = context.GetExtension <INotificationCallback>(); if (callBack != null) { callBack.SendClientNotification(new ComponentProcessMessage().CreateServerMessage( Batch.Get(context).Id, Group.Get(context).Id, new Guid(), "Group Ended")); } } if (endResult.Exception != null && !context.IsCancellationRequested) { throw new ApplicationException("Error generating reports. See inner for details", endResult.Exception); } }
public NotificationProcessor(INotificationCallback notificationCallback) { notificationCallback.ThrowIfNull(nameof(notificationCallback)); _callbackDictionary = new Dictionary <Type, object> { { typeof(ApiAlternativePaymentResponse), new Func <ApiAlternativePaymentResponse, Task <bool> >(notificationCallback.AlternativePaymentNotificationCallbackAsync) }, { typeof(ApiCardPaymentResponse), new Func <ApiCardPaymentResponse, Task <bool> >(notificationCallback.CardPaymentNotificationCallbackAsync) }, { typeof(ApiRefundResponse), new Func <ApiRefundResponse, Task <bool> >(notificationCallback.RefundNotificationCallbackAsync) }, { typeof(ApiPreapprovalResponse), new Func <ApiPreapprovalResponse, Task <bool> >(notificationCallback.PreapprovalNotificationCallbackAsync) }, { typeof(ApiCardPayoutResponse), new Func <ApiCardPayoutResponse, Task <bool> >(notificationCallback.CardPayoutNotificationCallbackAsync) }, { typeof(ApiDisputeResponse), new Func <ApiDisputeResponse, Task <bool> >(notificationCallback.DisputeNotificationCallbackAsync) }, { typeof(UnknownTypeNotification), new Func <UnknownTypeNotification, Task <bool> >(notificationCallback.UnknownTypeNotificationCallbackAsync) }, { typeof(InvalidFormatNotification), new Func <InvalidFormatNotification, Task <bool> >(notificationCallback.InvalidFormatNotificationCallbackAsync) }, }; }
//complex solver internal static ComponentNode SolveComplexComponentTree(this ComponentSolver solver, List <ComponentNode> paramList, ComponentNode startNode, ICollection <ExtraProcessInfo> extraProcessInfos, INotificationCallback callback, ProcessBatch batch, ProcessGroup group, ProcessJob job) { ComponentNode nextComponent = null; IEnumerable <ComponentNode> children = ExcuteComplexStartNode(paramList, startNode, extraProcessInfos, callback, batch, group, job); foreach (var componentParam in children) { var comparam = ExcuteComplexComponentNode(paramList, componentParam, callback, batch, group, job); if (nextComponent == null) { nextComponent = comparam; } } return(nextComponent); }