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);
        }
Ejemplo n.º 2
0
        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);
            }
        }
        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);
            }
        }