예제 #1
0
        internal ActionHandlerResult TryHandleStopped()
        {
            ActionHandlerResult ret = new ActionHandlerResult(this);
            ActionUnit          ou  = ActionUnitStop;

            if (ou != null)
            {
                ret = Handle(ou);
            }
            return(ret);
        }
예제 #2
0
        internal ActionHandlerResult TryHandle(IActionCase actionCase)
        {
            ActionHandlerResult ret = null;

            if (Token.IsStateActive)
            {
                if (ActionUnits.Count > 0)
                {
                    ActionUnit ou = ActionUnits.FirstOrDefault(x => x.TryHandle(actionCase));
                    ret = Handle(ou);
                    if (ou != null && ou.TimeoutMs > 0)
                    {
                        Token.Reset(ou.TimeoutMs);
                    }
                }
            }
            return(ret);
        }
예제 #3
0
        internal ActionHandlerResult Start()
        {
            ActionHandlerResult ret = null;

            Token.Name = Name;
            CreateInstance();
            CreateWorkflow();
            Token.SetRunning();
            if (ActionUnits.Count > 0)
            {
                ActionUnit ou = ActionUnits.FirstOrDefault(x => x is StartActionUnit);
                ret = Handle(ou);
                if (ou != null)
                {
                    Token.Reset(ou.TimeoutMs);
                }
            }
            return(ret);
        }
예제 #4
0
        private ActionHandlerResult Handle(ActionUnit actionUnit)
        {
            ActionHandlerResult ret = null;

            if (actionUnit != null)
            {
                ret = new ActionHandlerResult(this);
                {
                    ActionUnit ou = actionUnit;
                    if (actionUnit is DataReceivedUnit)
                    {
                        DataReceivedUnit dou = (DataReceivedUnit)actionUnit;
                        if (dou.DataFrame != null && dou.DataFrame.Data != null)
                        {
                            AddTraceLogItem(DateTime.Now, dou.DataFrame.Data, false);
                        }
                    }
                    if (ou.Func != null)
                    {
                        ou.Func(ou);
                    }
                    if (Token.IsStateActive)
                    {
                        if (ou.ActionItems != null && ou.ActionItems.Count > 0)
                        {
                            foreach (var item in ou.ActionItems)
                            {
                                item.ParentAction = this;
                                ret.NextActions.Add(item);
                            }
                        }
                        else
                        {
                            FixStates();
                        }
                    }
                }
            }
            return(ret);
        }
예제 #5
0
 protected virtual void SetStateFailing(ActionUnit ou)
 {
     Token.SetFailing();
 }
예제 #6
0
 protected virtual void SetStateCompleting(ActionUnit ou)
 {
     Token.SetCompleting();
 }
예제 #7
0
 protected virtual void SetStateExpired(ActionUnit ou)
 {
     Token.SetExpired();
 }
예제 #8
0
 protected virtual void SetStateCancelled(ActionUnit ou)
 {
     Token.SetCancelled();
 }