/// <summary>
 /// Notify of step start. If e.Cancel is True, then cancel operation.
 /// </summary>
 protected virtual void OnProgress(HandlerProgressCancelEventArgs e)
 {
     if (Progress != null)
     {
         Progress(this, e);
     }
 }
 void rt_Progress(object sender, HandlerProgressCancelEventArgs e)
 {
     if (_wantsCancel)
     {
         e.Cancel = true;
     }
     OnProgress(e);
     if (e.Cancel)
     {
         _wantsCancel = true;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Notify of step progress.
        /// </summary>
        /// <param name="context">The method name or workflow activty.</param>
        /// <param name="message">Descriptive message.</param>
        /// <param name="status">Overall Package status indicator.</param>
        /// <param name="id">Message Id.</param>
        /// <param name="sequence">Message/error severity.</param>
        /// <param name="ex">Current exception (optional).</param>
        protected virtual bool OnProgress(string context, string message,
                                          StatusType status = StatusType.Running, long id = 0, int sequence = 0, bool cancel = false, Exception ex = null)
        {
            HandlerProgressCancelEventArgs e =
                new HandlerProgressCancelEventArgs(context, message, status, id, sequence, cancel, ex)
            {
                ActionName = this.ActionName
            };

            Progress?.Invoke(this, e);

            return(e.Cancel);
        }
Beispiel #4
0
        //void rt_Single_Progress(object sender, HandlerProgressCancelEventArgs e)
        //{
        //    if( _wantsCancel ) { e.Cancel = true; }
        //    (new ActionItem() { InstanceId = e.Id }).UpdateInstanceStatus( e.Status, e.Message, e.Sequence );
        //    OnProgress( e );
        //    if( e.Cancel ) { _wantsCancel = true; }
        //}
        #endregion


        #region progress/log handlers
        void rt_Progress(object sender, HandlerProgressCancelEventArgs e)
        {
            if (_wantsCancel)
            {
                e.Cancel = true;
            }
#if sqlite
            SynapseDal.UpdateActionInstance(e.Id, e.Status, e.Message, e.Sequence);
#endif
            OnProgress(e);
            if (e.Cancel)
            {
                _wantsCancel = true;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Notify of step progress.
        /// </summary>
        /// <param name="context">The method name or workflow activty.</param>
        /// <param name="message">Descriptive message.</param>
        /// <param name="status">Overall Package status indicator.</param>
        /// <param name="id">Message Id.</param>
        /// <param name="severity">Message/error severity.</param>
        /// <param name="ex">Current exception (optional).</param>
        protected virtual bool OnProgress(string context, string message,
                                          StatusType status = StatusType.Running, int id = 0, int severity = 0, bool cancel = false, Exception ex = null)
        {
            HandlerProgressCancelEventArgs e =
                new HandlerProgressCancelEventArgs(context, message, status, id, severity, cancel, ex)
            {
                ActionName = this.ActionName
            };

            if (Progress != null)
            {
                Progress(this, e);
            }

            return(e.Cancel);
        }
Beispiel #6
0
        void WriteUnhandledActionException(ActionItem a, Exception ex, bool writeProgress = true, bool writeLog = true)
        {
            //todo: serialize exception to composite string
            string context = "Synapse.Core PlanRuntime";
            string message = $"An unhandled exeption occurred in {a.Name}, Plan/Action Instance: {InstanceId}/{a.InstanceId}. Message: {ex.Message}.";

            if (writeProgress)
            {
                HandlerProgressCancelEventArgs e =
                    new HandlerProgressCancelEventArgs(context: context, message: message, status: StatusType.Failed,
                                                       id: a.InstanceId, sequence: Int32.MaxValue - 100, cancel: false, ex: ex)
                {
                    ActionName = a.Name
                };
                rt_Progress(this, e);
            }

            if (writeLog)
            {
                LogMessageEventArgs e =
                    new LogMessageEventArgs(context: context, message: message, level: LogLevel.Fatal, ex: ex);
                rt_LogMessage(this, e);
            }
        }
Beispiel #7
0
 void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (e.Data != null)
     {
         string data = CryptoHelpers.Decode(e.Data);
         try
         {
             HandlerProgressCancelEventArgs args = HandlerProgressCancelEventArgs.DeserializeSimple(data, true);
             OnProgress(args);
         }
         catch
         {
             try
             {
                 LogMessageEventArgs args = LogMessageEventArgs.DeserializeSimple(data, true);
                 OnLogMessage(args);
             }
             catch
             {
                 throw new Exception("Could not deserialize output into known args type");
             }
         }
     }
 }
        public static HandlerProgressCancelEventArgs DeserializeSimple(string s, bool asYaml = false)
        {
            HandlerProgressCancelEventArgs hpcev = FromYaml(s);

            return(hpcev);
        }
Beispiel #9
0
 /// <summary>
 /// Notify of step start. If e.Cancel is True, then cancel operation.
 /// </summary>
 protected virtual void OnProgress(HandlerProgressCancelEventArgs e)
 {
     Progress?.Invoke(this, e);
 }