/// <summary>
        /// Activity Constructor
        /// </summary>
        /// <param name="activity">activity</param>
        public MWFEventAudit(MWFActivity activity)
            : base(activity.GetCtx(), 0, activity.Get_TrxName())
        {
            SetAD_WF_Process_ID(activity.GetAD_WF_Process_ID());
            SetAD_WF_Node_ID(activity.GetAD_WF_Node_ID());
            SetAD_Table_ID(activity.GetAD_Table_ID());
            SetRecord_ID(activity.GetRecord_ID());
            SetAD_WF_Responsible_ID(activity.GetAD_WF_Responsible_ID());
            SetAD_User_ID(activity.GetAD_User_ID());
            SetWFState(activity.GetWFState());
            SetEventType(EVENTTYPE_ProcessCreated);
            SetElapsedTimeMS(Utility.Env.ZERO);
            MWFNode node = activity.GetNode();

            if (node != null && node.Get_ID() != 0)
            {
                String action = node.GetAction();
                if (MWFNode.ACTION_SetVariable.Equals(action) ||
                    MWFNode.ACTION_UserChoice.Equals(action))
                {
                    SetAttributeName(node.GetAttributeName());
                    //SetOldValue(String.valueOf(activity.getAttributeValue()));
                    SetOldValue(Util.GetValueOfString(activity.GetAttributeValue()));
                    if (MWFNode.ACTION_SetVariable.Equals(action))
                    {
                        SetNewValue(node.GetAttributeValue());
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Check Status of Activities.
        /// - update Process if required
        /// - start new activity
        /// </summary>
        public void CheckActivities()
        {
            log.Info(ToString());
            if (_state.IsClosed())
            {
                return;
            }
            //
            MWFActivity[] activities  = GetActivities(true, true);      //	requery active
            String        closedState = null;
            bool          suspended   = false;
            bool          running     = false;

            for (int i = 0; i < activities.Length; i++)
            {
                MWFActivity activity = activities[i];
                activity.SetAD_Window_ID(GetAD_Window_ID());
                StateEngine activityState = activity.GetState();

                //	Completed - Start Next
                if (activityState.IsCompleted() || activityState.IsBackground())
                {
                    if (StartNext(activity, activities))
                    {
                        continue;
                    }
                }
                //
                String activityWFState = activity.GetWFState();
                if (activityState.IsClosed() || activityState.IsBackground())
                {
                    //	eliminate from active processed
                    //activity.SetProcessed(true);
                    activity.Set_ValueNoCheck("Processed", true);
                    //activities
                    activity.Save();
                    //
                    if (closedState == null)
                    {
                        closedState = activityWFState;
                    }
                    else if (!closedState.Equals(activityState))
                    {
                        //	Overwrite if terminated
                        if (WFSTATE_Terminated.Equals(activityState))
                        {
                            closedState = activityWFState;
                        }
                        //	Overwrite if activity aborted and no other terminated
                        else if (WFSTATE_Aborted.Equals(activityState) && !WFSTATE_Terminated.Equals(closedState))
                        {
                            closedState = activityWFState;
                        }
                    }
                }
                else                    //	not closed
                {
                    closedState = null; //	all need to be closed
                    if (activityState.IsSuspended())
                    {
                        suspended = true;
                    }
                    if (activityState.IsRunning())
                    {
                        running = true;
                    }
                }
            }   //	for all activities
            if (activities.Length == 0)
            {
                SetTextMsg("No Active Processed found");
                closedState = WFSTATE_Terminated;
            }
            if (closedState != null)
            {
                if (closedState == StateEngine.STATE_BACKGROUND)
                {
                    _state.SetState(StateEngine.STATE_BACKGROUND);
                }
                SetWFState(closedState);
                GetPO();
                if (_po != null)
                {
                    _po.Unlock(Get_TrxName());
                }
            }
            else if (suspended)
            {
                SetWFState(WFSTATE_Suspended);
            }
            else if (running)
            {
                SetWFState(WFSTATE_Running);
            }
        }