/// <summary>
        /// Start Next Activity
        /// </summary>
        /// <param name="last">last activity</param>
        /// <param name="activities">all activities</param>
        /// <returns>true if there is a next activity</returns>
        private bool StartNext(MWFActivity last, MWFActivity[] activities)
        {
            log.Config("Last=" + last);
            //	transitions from the last processed node
            MWFNodeNext[] transitions = GetWorkflow().GetNodeNexts(last.GetAD_WF_Node_ID(), last.GetAD_Client_ID());
            if (transitions == null || transitions.Length == 0)
            {
                log.Config("none");
                return(false);   //	done
            }

            //	We need to wait for last activity
            if (MWFNode.JOINELEMENT_AND.Equals(last.GetNode().GetJoinElement()))
            {
                //	get previous nodes
                //	check if all have closed activities
                //	return false for all but the last
            }
            //	eliminate from active processed
            //last.SetProcessed(true);
            last.Set_ValueNoCheck("Processed", true);
            last.Save();

            //	Start next activity
            String split = last.GetNode().GetSplitElement();

            for (int i = 0; i < transitions.Length; i++)
            {
                //	Is this a valid transition?
                if (!transitions[i].IsValidFor(last))
                {
                    continue;
                }

                //	Start new Activity
                MWFActivity activity = new MWFActivity(this, transitions[i].GetAD_WF_Next_ID());
                // set Last Activity ID property in current WF Activity
                activity.SetLastActivity(last.GetAD_WF_Activity_ID());
                // new Thread(activity).Start();
                //thred = new Thread(new ThreadStart(activity.Run));
                //thred.CurrentCulture = Utility.Env.GetLanguage(Utility.Env.GetContext()).GetCulture(Utility.Env.GetLoginLanguage(Utility.Env.GetContext()).GetAD_Language());
                //thred.CurrentUICulture = Utility.Env.GetLanguage(Utility.Env.GetContext()).GetCulture(Utility.Env.GetLoginLanguage(Utility.Env.GetContext()).GetAD_Language());
                activity.Run();
                // thred.Start();

                //	only the first valid if XOR
                if (MWFNode.SPLITELEMENT_XOR.Equals(split))
                {
                    return(true);
                }
            }   //	for all transitions
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Start WF Execution async
        /// </summary>
        /// <returns>true if success</returns>
        public bool StartWork()
        {
            if (!_state.IsValidAction(StateEngine.ACTION_START))
            {
                log.Warning("State=" + GetWFState() + " - cannot start");
                return(false);
            }
            int AD_WF_Node_ID = GetWorkflow().GetAD_WF_Node_ID();

            log.Fine("AD_WF_Node_ID=" + AD_WF_Node_ID);
            SetWFState(WFSTATE_Running);
            try
            {
                ////	Start first Activity with first Node
                //MWFActivity activity = new MWFActivity(this, AD_WF_Node_ID);
                ////new Thread(activity).Start();
                //thred = new Thread(new ThreadStart(activity.Run));
                ////System.Threading.Thread.CurrentThread.CurrentCulture = Env.GetLanguage(p_ctx).GetCulture(Env.GetBaseAD_Language());
                ////System.Threading.Thread.CurrentThread.CurrentUICulture = Env.GetLanguage(p_ctx).GetCulture(Env.GetBaseAD_Language());

                //thred.CurrentCulture = Utility.Env.GetLanguage(p_ctx).GetCulture(Utility.Env.GetBaseAD_Language());
                //thred.CurrentUICulture = Utility.Env.GetLanguage(p_ctx).GetCulture(Utility.Env.GetBaseAD_Language());
                //thred.Start();

                //Update By --Raghu
                //Date-14-Feb-2012
                //remove thread logic for workflow becouse to show updated workflow record on window
                MWFActivity activity = new MWFActivity(this, AD_WF_Node_ID);
                activity.Run();
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, "AD_WF_Node_ID=" + AD_WF_Node_ID, e);
                SetTextMsg(e.Message);
                SetWFState(StateEngine.STATE_TERMINATED);
                return(false);
            }
            return(true);
        }