Example #1
0
        //Thread thred;

        /// <summary>
        /// Standard Constructor
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="AD_WF_Process_ID">process id</param>
        /// <param name="trxName">transaction</param>
        public MWFProcess(Ctx ctx, int AD_WF_Process_ID, Trx trxName)
            : base(ctx, AD_WF_Process_ID, trxName)
        {
            if (AD_WF_Process_ID == 0)
            {
                throw new ArgumentException("Cannot create new WF Process directly");
            }
            _state = new StateEngine(GetWFState());
            _state.SetCtx(GetCtx());
        }
Example #2
0
        /// <summary>
        /// New Constructor
        /// </summary>
        /// <param name="wf">workflow</param>
        /// <param name="pi">Process Info (Record_ID)</param>
        public MWFProcess(MWorkflow wf, ProcessInfo pi)
            : base(wf.GetCtx(), 0, wf.Get_TrxName())
        {
            if (!Utility.TimeUtil.IsValid(wf.GetValidFrom(), wf.GetValidTo())) // make this class or this function
            {
                //throw new IllegalStateException("Workflow not valid");
                throw new Exception("Workflow not valid");
            }
            _wf = wf;
            _pi = pi;
            SetAD_Client_ID(wf.GetAD_Client_ID());
            SetAD_Workflow_ID(wf.GetAD_Workflow_ID());
            SetPriority(wf.GetPriority());
            base.SetWFState(WFSTATE_NotStarted);

            // vinay bhatt for window id
            SetAD_Window_ID(pi.GetAD_Window_ID());
            //

            //	Document
            SetAD_Table_ID(wf.GetAD_Table_ID());
            SetRecord_ID(pi.GetRecord_ID());
            if (GetPO() == null)
            {
                SetTextMsg("No PO with ID=" + pi.GetRecord_ID());
                base.SetWFState(WFSTATE_Terminated);
            }
            else
            {
                SetTextMsg(GetPO());
            }
            //	Responsible/User
            if (wf.GetAD_WF_Responsible_ID() == 0)
            {
                SetAD_WF_Responsible_ID();
            }
            else
            {
                SetAD_WF_Responsible_ID(wf.GetAD_WF_Responsible_ID());
            }
            SetUser_ID((int)pi.GetAD_User_ID());                //	user starting
            //
            _state = new StateEngine(GetWFState());
            _state.SetCtx(GetCtx());
            SetProcessed(false);
            //	Lock Entity
            GetPO();
            if (_po != null)
            {
                // Set transaction organization on workflow process
                SetAD_Org_ID(_po.GetAD_Org_ID());
                _po.Lock();
            }
        }
Example #3
0
 /// <summary>
 /// Set Process State and update Actions
 /// </summary>
 /// <param name="WFState">WFState</param>
 public new void   SetWFState(String WFState)
 {
     if (_state == null)
     {
         _state = new StateEngine(GetWFState());
         _state.SetCtx(GetCtx());
     }
     if (_state.IsClosed())
     {
         return;
     }
     if (GetWFState().Equals(WFState))
     {
         return;
     }
     //
     if (_state.IsValidNewState(WFState))
     {
         log.Fine(ToString() + " => " + WFState);
         base.SetWFState(WFState);
         _state = new StateEngine(GetWFState());
         _state.SetCtx(GetCtx());
         if (_state.IsClosed() || _state.IsBackground())
         {
             SetProcessed(true);
         }
         Save();
         //	Force close to all Activities
         if (_state.IsClosed() || _state.IsBackground())
         {
             MWFActivity[] activities = GetActivities(true, true);       //	requery only active
             for (int i = 0; i < activities.Length; i++)
             {
                 if (!activities[i].IsClosed())
                 {
                     activities[i].SetTextMsg("Process:" + WFState);
                     activities[i].SetWFState(WFState);
                 }
                 if (!activities[i].IsProcessed())
                 {
                     activities[i].SetProcessed(true);
                 }
                 activities[i].Save();
             }
         }       //	closed
     }
     else
     {
         log.Log(Level.SEVERE, "Ignored Invalid Transformation " + ToString() + " => " + WFState);
     }
 }
Example #4
0
 /// <summary>
 /// Load Constructor
 /// </summary>
 /// <param name="ctx">context</param>
 /// <param name="rs">result set</param>
 /// <param name="trxName">transaction</param>
 public MWFProcess(Ctx ctx, DataRow rs, Trx trxName)
     : base(ctx, rs, trxName)
 {
     _state = new StateEngine(GetWFState());
     _state.SetCtx(GetCtx());
 }