コード例 #1
0
        private void Wakeup()
        {
            String sql = "SELECT * "
                         + "FROM AD_WF_Activity a "
                         + "WHERE Processed='N' AND WFState='OS'" //	suspended
                         + " AND EndWaitTime > SysDate"
                         + " AND AD_Client_ID=@AD_Client_ID"
                         + " AND EXISTS (SELECT * FROM AD_Workflow wf "
                         + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
                         + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID"
                         + " AND wfn.Action='Z'"        //	sleeping
                         + " AND wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=@AD_WorkflowProcessor_ID)";

            int count = 0;

            try
            {
                SqlParameter[] param = new SqlParameter[2];
                param[0] = new SqlParameter("@AD_Client_ID", m_model.GetAD_Client_ID());
                param[1] = new SqlParameter("@AD_WorkflowProcessor_ID", m_model.GetAD_WorkflowProcessor_ID());
                DataSet ds = DB.ExecuteDataset(sql, param);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MWFActivity activity = new MWFActivity(GetCtx(), dr, null);
                    activity.SetWFState(StateEngine.STATE_COMPLETED);
                    // saves and calls MWFProcess.checkActivities();
                    count++;
                }
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, "wakeup", e);
            }
            m_summary.Append("Wakeup #").Append(count).Append(" - ");
        }       //	wakeup
コード例 #2
0
        /// <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());
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        ///Perform Process.
        /// </summary>
        /// <returns>Message (variables are parsed)</returns>
        protected override String DoIt()
        {
            string      msg      = null;
            MWFActivity activity = new MWFActivity(GetCtx(), p_AD_WF_Activity_ID, Get_Trx());

            log.Info("" + activity);

            MUser user = MUser.Get(GetCtx(), GetAD_User_ID());

            //	Abort
            if (p_IsAbort)
            {
                msg = user.GetName() + ": Abort";
                activity.SetTextMsg(msg);
                activity.SetAD_User_ID(GetAD_User_ID());
                activity.SetWFState(StateEngine.STATE_ABORTED);
                //JID_0278 : To mark processing checkbox false.
                // Mohit
                // Date : 22 May 2019
                MTable table = new MTable(GetCtx(), activity.GetAD_Table_ID(), null);
                PO     po    = MTable.GetPO(GetCtx(), table.GetTableName(), activity.GetRecord_ID(), Get_Trx());
                if (po != null && po.Get_ColumnIndex("Processing") >= 0)
                {
                    po.Set_Value("Processing", false);
                    po.Save();
                }
                return(msg);
            }

            //	Change User
            if (p_AD_User_ID != 0 && activity.GetAD_User_ID() != p_AD_User_ID)
            {
                MUser from = MUser.Get(GetCtx(), activity.GetAD_User_ID());
                MUser to   = MUser.Get(GetCtx(), p_AD_User_ID);
                msg = user.GetName() + ": " + from.GetName() + " -> " + to.GetName();
                activity.SetTextMsg(msg);
                activity.SetAD_User_ID(p_AD_User_ID);
            }
            //	Change Responsible
            if (p_AD_WF_Responsible_ID != 0 && activity.GetAD_WF_Responsible_ID() != p_AD_WF_Responsible_ID)
            {
                MWFResponsible from = MWFResponsible.Get(GetCtx(), activity.GetAD_WF_Responsible_ID());
                MWFResponsible to   = MWFResponsible.Get(GetCtx(), p_AD_WF_Responsible_ID);
                String         msg1 = user.GetName() + ": " + from.GetName() + " -> " + to.GetName();
                activity.SetTextMsg(msg1);
                activity.SetAD_WF_Responsible_ID(p_AD_WF_Responsible_ID);
                if (msg == null)
                {
                    msg = msg1;
                }
                else
                {
                    msg += " - " + msg1;
                }
            }
            activity.Save();
            return(msg);
        }
コード例 #4
0
        /// <summary>
        /// Is this a Valid Transition For ..
        /// </summary>
        /// <param name="activity">activity</param>
        /// <returns>true if valid</returns>
        public bool IsValidFor(MWFActivity activity)
        {
            if (IsStdUserWorkflow())
            {
                PO po = activity.GetPO();
                if (po.GetType() == typeof(DocAction) || po.GetType().GetInterface("DocAction") == typeof(DocAction))
                {
                    DocAction da        = (DocAction)po;
                    String    docStatus = da.GetDocStatus();
                    String    docAction = da.GetDocAction();
                    if (!DocActionVariables.ACTION_COMPLETE.Equals(docAction) ||
                        DocActionVariables.STATUS_COMPLETED.Equals(docStatus) ||
                        DocActionVariables.STATUS_WAITINGCONFIRMATION.Equals(docStatus) ||
                        DocActionVariables.STATUS_WAITINGPAYMENT.Equals(docStatus) ||
                        DocActionVariables.STATUS_VOIDED.Equals(docStatus) ||
                        DocActionVariables.STATUS_CLOSED.Equals(docStatus) ||
                        DocActionVariables.STATUS_REVERSED.Equals(docStatus))

                    /*
                    || DocAction.ACTION_Complete.equals(docAction)
                    || DocAction.ACTION_ReActivate.equals(docAction)
                    || DocAction.ACTION_None.equals(docAction)
                    || DocAction.ACTION_Post.equals(docAction)
                    || DocAction.ACTION_Unlock.equals(docAction)
                    || DocAction.ACTION_Invalidate.equals(docAction)	) */
                    {
                        log.Fine("isValidFor =NO= StdUserWF - Status=" + docStatus + " - Action=" + docAction);
                        return(false);
                    }
                }
            }
            //	No Conditions
            if (GetConditions(false).Length == 0)
            {
                log.Fine("#0 " + ToString());
                return(true);
            }
            //	First condition always AND
            bool ok = _conditions[0].Evaluate(activity);

            for (int i = 1; i < _conditions.Length; i++)
            {
                if (_conditions[i].IsOr())
                {
                    ok = ok || _conditions[i].Evaluate(activity);
                }
                else
                {
                    ok = ok && _conditions[i].Evaluate(activity);
                }
            }           //	for all conditions
            log.Fine("isValidFor (" + ok + ") " + ToString());
            return(ok);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <summary>
        ///Perform Process.
        /// </summary>
        /// <returns>Message (variables are parsed)</returns>
        protected override String DoIt()
        {
            string      msg      = null;
            MWFActivity activity = new MWFActivity(GetCtx(), p_AD_WF_Activity_ID, Get_Trx());

            log.Info("" + activity);

            MUser user = MUser.Get(GetCtx(), GetAD_User_ID());

            //	Abort
            if (p_IsAbort)
            {
                msg = user.GetName() + ": Abort";
                activity.SetTextMsg(msg);
                activity.SetAD_User_ID(GetAD_User_ID());
                activity.SetWFState(StateEngine.STATE_ABORTED);
                return(msg);
            }

            //	Change User
            if (p_AD_User_ID != 0 && activity.GetAD_User_ID() != p_AD_User_ID)
            {
                MUser from = MUser.Get(GetCtx(), activity.GetAD_User_ID());
                MUser to   = MUser.Get(GetCtx(), p_AD_User_ID);
                msg = user.GetName() + ": " + from.GetName() + " -> " + to.GetName();
                activity.SetTextMsg(msg);
                activity.SetAD_User_ID(p_AD_User_ID);
            }
            //	Change Responsible
            if (p_AD_WF_Responsible_ID != 0 && activity.GetAD_WF_Responsible_ID() != p_AD_WF_Responsible_ID)
            {
                MWFResponsible from = MWFResponsible.Get(GetCtx(), activity.GetAD_WF_Responsible_ID());
                MWFResponsible to   = MWFResponsible.Get(GetCtx(), p_AD_WF_Responsible_ID);
                String         msg1 = user.GetName() + ": " + from.GetName() + " -> " + to.GetName();
                activity.SetTextMsg(msg1);
                activity.SetAD_WF_Responsible_ID(p_AD_WF_Responsible_ID);
                if (msg == null)
                {
                    msg = msg1;
                }
                else
                {
                    msg += " - " + msg1;
                }
            }
            activity.Save();
            return(msg);
        }
コード例 #7
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);
        }
コード例 #8
0
        }       //	wakeup

        private void DynamicPriority()
        {
            //	suspened activities with dynamic priority node
            String sql = "SELECT * "
                         + "FROM AD_WF_Activity a "
                         + "WHERE Processed='N' AND WFState='OS'" //	suspended
                         + " AND EXISTS (SELECT * FROM AD_Workflow wf"
                         + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
                         + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID AND wf.AD_WorkflowProcessor_ID=@AD_WorkflowProcessor_ID"
                         + " AND wfn.DynPriorityUnit IS NOT NULL AND wfn.DynPriorityChange IS NOT NULL)";
            int count = 0;

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@AD_WorkflowProcessor_ID", m_model.GetAD_WorkflowProcessor_ID());
                DataSet ds = DB.ExecuteDataset(sql, param);

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MWFActivity activity = new MWFActivity(GetCtx(), dr, null);
                    if (activity.GetDynPriorityStart() == 0)
                    {
                        activity.SetDynPriorityStart(activity.GetPriority());
                    }
                    long    ms       = CommonFunctions.CurrentTimeMillis() - CommonFunctions.CurrentTimeMillis(activity.GetCreated());
                    MWFNode node     = activity.GetNode();
                    int     prioDiff = node.CalculateDynamicPriority((int)(ms / 1000));
                    activity.SetPriority(activity.GetDynPriorityStart() + prioDiff);
                    activity.Save();
                    count++;
                }
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, sql, e);
            }
            m_summary.Append("DynPriority #").Append(count).Append(" - ");
        }       //	setPriority
コード例 #9
0
        }       //	sendAlerts

        private int SendEmail(MWFActivity activity, String AD_Message, bool toProcess, bool toSupervisor)
        {
            if (m_client == null || m_client.GetAD_Client_ID() != activity.GetAD_Client_ID())
            {
                m_client = MClient.Get(GetCtx(), activity.GetAD_Client_ID());
            }

            MWFProcess process = new MWFProcess(GetCtx(), activity.GetAD_WF_Process_ID(), null);

            String subjectVar = activity.GetNode().GetName();
            String message    = activity.GetTextMsg();

            if (message == null || message.Length == 0)
            {
                message = process.GetTextMsg();
            }
            FileInfo pdf = null;
            PO       po  = activity.GetPO();

            if (po is DocAction)
            {
                message = ((DocAction)po).GetDocumentInfo() + "\n" + message;
                pdf     = ((DocAction)po).CreatePDF();
            }

            //  Inactivity Alert: Workflow Activity {0}
            String subject = Msg.GetMsg(m_client.GetAD_Language(), AD_Message,
                                        new Object[] { subjectVar });

            //	Prevent duplicates
            List <int> list    = new List <int>();
            int        counter = 0;

            //	To Activity Owner
            if (m_client.SendEMail(activity.GetAD_User_ID(), subject, message, pdf))
            {
                counter++;
            }
            list.Add(activity.GetAD_User_ID());

            //	To Process Owner
            if (toProcess &&
                process.GetAD_User_ID() != activity.GetAD_User_ID())
            {
                if (m_client.SendEMail(process.GetAD_User_ID(), subject, message, pdf))
                {
                    counter++;
                }
                list.Add(process.GetAD_User_ID());
            }

            //	To Activity Responsible
            MWFResponsible responsible = MWFResponsible.Get(GetCtx(), activity.GetAD_WF_Responsible_ID());

            counter += sendAlertToResponsible(responsible, list, process, subject, message, pdf);

            //	To Process Responsible
            if (toProcess &&
                process.GetAD_WF_Responsible_ID() != activity.GetAD_WF_Responsible_ID())
            {
                responsible = MWFResponsible.Get(GetCtx(), process.GetAD_WF_Responsible_ID());
                counter    += sendAlertToResponsible(responsible, list, process, subject, message, pdf);
            }

            //	Processor SuperVisor
            if (toSupervisor && m_model.GetSupervisor_ID() != 0 &&
                !list.Contains(m_model.GetSupervisor_ID()))
            {
                if (m_client.SendEMail(m_model.GetSupervisor_ID(), subject, message, pdf))
                {
                    counter++;
                }
                list.Add(m_model.GetSupervisor_ID());
            }

            return(counter);
        }   //  sendAlert
コード例 #10
0
        }       //	setPriority

        private void SendAlerts()
        {
            int    count       = 0;
            int    countEMails = 0;
            String sql         = "";

            //	Alert over Priority
            if (m_model.GetAlertOverPriority() > 0)
            {
                sql = "SELECT * "
                      + "FROM AD_WF_Activity a "
                      + "WHERE Processed='N' AND WFState='OS'"  //	suspended
                      + " AND Priority >= @Priority"            //	##1
                      + " AND (DateLastAlert IS NULL";
                if (m_model.GetRemindDays() > 0)
                {
                    sql += " OR (DateLastAlert+" + m_model.GetRemindDays()
                           + ") < SysDate";
                }
                sql += ") AND EXISTS (SELECT * FROM AD_Workflow wf "
                       + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
                       + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID"
                       + " AND wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=@AD_WorkflowProcessor_ID)";



                try
                {
                    SqlParameter[] param = new SqlParameter[2];
                    param[0] = new SqlParameter("@Priority", m_model.GetAlertOverPriority());
                    param[1] = new SqlParameter("@AD_WorkflowProcessor_ID", m_model.GetAD_WorkflowProcessor_ID());

                    DataSet ds = DB.ExecuteDataset(sql, param);
                    foreach (DataRow dr in  ds.Tables[0].Rows)
                    {
                        MWFActivity activity = new MWFActivity(GetCtx(), dr, null);
                        bool        escalate = activity.GetDateLastAlert() != null;
                        countEMails += SendEmail(activity, "ActivityOverPriority", escalate, true);
                        activity.SetDateLastAlert(CommonFunctions.CovertMilliToDate(CommonFunctions.CurrentTimeMillis()));
                        activity.Save();
                        count++;
                    }
                }
                catch (SqlException e)
                {
                    log.Log(Level.SEVERE, "(Priority) - " + sql, e);
                }
                m_summary.Append("OverPriority #").Append(count);
                if (countEMails > 0)
                {
                    m_summary.Append(" (").Append(countEMails).Append(" EMail)");
                }
                m_summary.Append(" - ");
            }   //	Alert over Priority

            /**
             *  Over End Wait
             */
            sql = "SELECT * "
                  + "FROM AD_WF_Activity a "
                  + "WHERE Processed='N' AND WFState='OS'"      //	suspended
                  + " AND EndWaitTime > SysDate"
                  + " AND (DateLastAlert IS NULL";
            if (m_model.GetRemindDays() > 0)
            {
                sql += " OR (DateLastAlert+" + m_model.GetRemindDays()
                       + ") < SysDate";
            }
            sql += ") AND EXISTS (SELECT * FROM AD_Workflow wf "
                   + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
                   + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID"
                   + " AND wfn.Action<>'Z'"     //	not sleeping
                   + " AND wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=@AD_WorkflowProcessor_ID)";

            count       = 0;
            countEMails = 0;
            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@AD_WorkflowProcessor_ID", m_model.GetAD_WorkflowProcessor_ID());
                DataSet ds = DB.ExecuteDataset(sql, param);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MWFActivity activity = new MWFActivity(GetCtx(), dr, null);
                    bool        escalate = activity.GetDateLastAlert() != null;
                    countEMails += SendEmail(activity, "ActivityEndWaitTime", escalate, false);
                    activity.SetDateLastAlert(CommonFunctions.CovertMilliToDate(CommonFunctions.CurrentTimeMillis()));
                    activity.Save();
                    count++;
                }
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, "(EndWaitTime) - " + sql, e);
            }
            m_summary.Append("EndWaitTime #").Append(count);
            if (countEMails > 0)
            {
                m_summary.Append(" (").Append(countEMails).Append(" EMail)");
            }
            m_summary.Append(" - ");

            /**
             *  Send inactivity alerts
             */
            if (m_model.GetInactivityAlertDays() > 0)
            {
                sql = "SELECT * "
                      + "FROM AD_WF_Activity a "
                      + "WHERE Processed='N' AND WFState='OS'"  //	suspended
                      + " AND (Updated+" + m_model.GetInactivityAlertDays() + ") < SysDate"
                      + " AND (DateLastAlert IS NULL";
                if (m_model.GetRemindDays() > 0)
                {
                    sql += " OR (DateLastAlert+" + m_model.GetRemindDays()
                           + ") < SysDate";
                }
                sql += ") AND EXISTS (SELECT * FROM AD_Workflow wf "
                       + " INNER JOIN AD_WF_Node wfn ON (wf.AD_Workflow_ID=wfn.AD_Workflow_ID) "
                       + "WHERE a.AD_WF_Node_ID=wfn.AD_WF_Node_ID"
                       + " AND wf.AD_WorkflowProcessor_ID IS NULL OR wf.AD_WorkflowProcessor_ID=@AD_WorkflowProcessor_ID)";

                count       = 0;
                countEMails = 0;
                try
                {
                    SqlParameter[] param = new SqlParameter[1];
                    param[0] = new SqlParameter("@AD_WorkflowProcessor_ID", m_model.GetAD_WorkflowProcessor_ID());
                    DataSet ds = DB.ExecuteDataset(sql, param);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        MWFActivity activity = new MWFActivity(GetCtx(), dr, null);
                        bool        escalate = activity.GetDateLastAlert() != null;
                        countEMails += SendEmail(activity, "ActivityInactivity",
                                                 escalate, false);
                        activity.SetDateLastAlert(CommonFunctions.CovertMilliToDate(CommonFunctions.CurrentTimeMillis()));
                        activity.Save();
                        count++;
                    }
                }
                catch (SqlException e)
                {
                    log.Log(Level.SEVERE, "(Inactivity): " + sql, e);
                }
                m_summary.Append("Inactivity #").Append(count);
                if (countEMails > 0)
                {
                    m_summary.Append(" (").Append(countEMails).Append(" EMail)");
                }
                m_summary.Append(" - ");
            }   //	Inactivity
        }       //	sendAlerts
コード例 #11
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);
            }
        }
コード例 #12
0
 private string SetUserChoice(int AD_User_ID, string value, int dt, string textMsg, MWFActivity _activity, MWFNode _node)
 {
     try
     {
         _activity.SetUserChoice(AD_User_ID, value, dt, textMsg);
         return("OK");
     }
     catch (Exception ex)
     {
         //Dispatcher.BeginInvoke(delegate
         //{
         //    SetBusy(false);
         //    log.Log(Level.SEVERE, _node.GetName(), ex);
         //    ShowMessage.Error("Error", true, ex.ToString());
         //    return;
         //});
         return("Error" + ex.Message);
     }
 }
コード例 #13
0
        public string ApproveIt(int nodeID, int activityID, string textMsg, object forward, object answer, Ctx ctx)
        {
            MWFActivity activity      = new MWFActivity(ctx, activityID, null);
            MWFNode     node          = activity.GetNode();
            int         approvalLevel = node.GetApprovalLeval();
            int         AD_User_ID    = ctx.GetAD_User_ID();
            MColumn     column        = node.GetColumn();

            if (forward != null) // Prefer Forward
            {
                int fw = int.Parse(forward.ToString());
                if (fw == AD_User_ID || fw == 0)
                {
                    return("");
                }
                if (!activity.ForwardTo(fw, textMsg, true))
                {
                    return("CannotForward");
                }
            }
            //	User Choice - Answer
            else if (MWFNode.ACTION_UserChoice.Equals(node.GetAction()))
            {
                if (column == null)
                {
                    column = node.GetColumn();
                }
                //	Do we have an answer?
                int    dt    = column.GetAD_Reference_ID();
                String value = null;
                value = answer != null?answer.ToString() : null;

                //if (dt == DisplayType.YesNo || dt == DisplayType.List || dt == DisplayType.TableDir)
                if (!node.IsMultiApproval() &&
                    (dt == DisplayType.YesNo || dt == DisplayType.List || dt == DisplayType.TableDir))
                {
                    if (value == null || value.Length == 0)
                    {
                        return("FillMandatory");
                    }
                    //
                    string res = SetUserChoice(AD_User_ID, value, dt, textMsg, activity, node);
                    if (res != "OK")
                    {
                        return(res);
                    }
                }
                //Genral Attribute Instance
                //else if (column.GetColumnName().ToUpper().Equals("C_GENATTRIBUTESETINSTANCE_ID"))
                //{
                //    if (attrib == null)
                //    {
                //        Dispatcher.BeginInvoke(delegate
                //        {
                //            SetBusy(false);
                //            ShowMessage.Error("FillMandatory", true, Msg.GetMsg(Envs.GetContext(), "Answer", true));
                //            //log.Config("Answer=" + value + " - " + textMsg);
                //            return;
                //        });
                //        return;
                //    }

                //    SetUserChoice(AD_User_ID, attrib.GetAttributeSetInstance().ToString(), 0, textMsg, activity, node);
                //}

                else if (forward == null && node.IsMultiApproval() && approvalLevel > 0 && answer.ToString().Equals("Y"))
                {
                    int eventCount = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT COUNT(WFE.AD_WF_EventAudit_ID) FROM AD_WF_EventAudit WFE
                                                                                INNER JOIN AD_WF_Process WFP ON (WFP.AD_WF_Process_ID=WFE.AD_WF_Process_ID)
                                                                                INNER JOIN AD_WF_Activity WFA ON (WFA.AD_WF_Process_ID=WFP.AD_WF_Process_ID)
                                                                                WHERE WFE.AD_WF_Node_ID=" + node.GetAD_WF_Node_ID() + " AND WFA.AD_WF_Activity_ID=" + activity.GetAD_WF_Activity_ID()));
                    if (eventCount < approvalLevel) //Forward Activity
                    {
                        int superVisiorID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT Supervisor_ID FROM AD_User WHERE IsActive='Y' AND AD_User_ID=" + activity.GetAD_User_ID()));
                        if (superVisiorID == 0)//Approve
                        {
                            //SetUserConfirmation(AD_User_ID, textMsg, activity, node);

                            string res = SetUserChoice(AD_User_ID, value, dt, textMsg, activity, node);
                            if (res != "OK")
                            {
                                return(res);
                            }
                        }
                        else //forward
                        {
                            if (!activity.ForwardTo(superVisiorID, textMsg, true))
                            {
                                //Dispatcher.BeginInvoke(delegate
                                //{
                                //    SetBusy(false);
                                //    ShowMessage.Error("CannotForward", true);
                                //    return;
                                //});
                                return("CannotForward");
                            }
                        }
                    }
                    else //Approve
                    {
                        //SetUserConfirmation(AD_User_ID, textMsg, activity, node);

                        string res = SetUserChoice(AD_User_ID, value, dt, textMsg, activity, node);
                        if (res != "OK")
                        {
                            return(res);
                        }
                    }
                }
                else
                {
                    string res = SetUserChoice(AD_User_ID, value, dt, textMsg, activity, node);
                    if (res != "OK")
                    {
                        return(res);
                    }
                }
            }
            //	User Action
            else
            {
                //   log.Config("Action=" + node.GetAction() + " - " + textMsg);
                //try
                //{
                //    activity.SetUserConfirmation(AD_User_ID, textMsg);
                //}
                //catch (Exception exx)
                //{
                //    Dispatcher.BeginInvoke(delegate
                //            {
                //                SetBusy(false);
                //                log.Log(Level.SEVERE, node.GetName(), exx);
                //                ShowMessage.Error("Error", true, exx.ToString());
                //                return;
                //            });
                //    return;
                //}
                activity.SetUserConfirmation(AD_User_ID, textMsg);
            }

            return("");
        }
コード例 #14
0
        public ActivityInfo GetActivityInfo(int activityID, int nodeID, int wfProcessID, Ctx ctx)
        {
            ActivityInfo info = new ActivityInfo();

            try
            {
                MWFNode node = new MWFNode(ctx, nodeID, null);
                info.NodeAction = node.GetAction();
                info.NodeName   = node.GetName();
                if (MWFNode.ACTION_UserChoice.Equals(node.GetAction()))
                {
                    MColumn col = node.GetColumn();
                    info.ColID             = col.GetAD_Column_ID();
                    info.ColReference      = col.GetAD_Reference_ID();
                    info.ColReferenceValue = col.GetAD_Reference_Value_ID();
                    info.ColName           = col.GetColumnName();
                }
                else if (MWFNode.ACTION_UserWindow.Equals(node.GetAction()))
                {
                    info.AD_Window_ID = node.GetAD_Window_ID();
                    MWFActivity activity = new MWFActivity(ctx, activityID, null);
                    info.KeyCol = activity.GetPO().Get_TableName() + "_ID";
                }
                else if (MWFNode.ACTION_UserForm.Equals(node.GetAction()))
                {
                    info.AD_Form_ID = node.GetAD_Form_ID();
                }



                string  sql = @"SELECT node.ad_wf_node_ID,
                                  node.Name AS NodeName,
                                  usr.Name AS UserName,
                                  wfea.wfstate,
                                  wfea.TextMsg
                              FROM ad_wf_eventaudit wfea
                                INNER JOIN Ad_WF_Node node
                                ON (node.Ad_Wf_node_ID=wfea.AD_Wf_Node_id)
                                INNER JOIN AD_User usr
                                ON (usr.Ad_User_ID         =wfea.ad_User_ID)
                              WHERE wfea.AD_WF_Process_ID=" + wfProcessID + @"
                              Order By wfea.ad_wf_eventaudit_id desc";
                DataSet ds  = DB.ExecuteDataset(sql);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    List <NodeInfo> nodeInfo = new List <NodeInfo>();
                    List <int>      nodes    = new List <int>();
                    NodeInfo        ni       = null;
                    NodeHistory     nh       = null;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (!nodes.Contains(Util.GetValueOfInt(ds.Tables[0].Rows[i]["AD_WF_Node_ID"])))
                        {
                            ni            = new NodeInfo();
                            ni.Name       = Util.GetValueOfString(ds.Tables[0].Rows[i]["NodeName"]);
                            nh            = new NodeHistory();
                            nh.State      = Util.GetValueOfString(ds.Tables[0].Rows[i]["WFState"]);
                            nh.ApprovedBy = Util.GetValueOfString(ds.Tables[0].Rows[i]["UserName"]);
                            ni.History    = new List <NodeHistory>();

                            if (ds.Tables[0].Rows[i]["TextMsg"] == null || ds.Tables[0].Rows[i]["TextMsg"] == DBNull.Value)
                            {
                                nh.TextMsg = string.Empty;
                            }
                            else
                            {
                                nh.TextMsg = ds.Tables[0].Rows[i]["TextMsg"].ToString();
                            }
                            ni.History.Add(nh);
                            nodes.Add(Util.GetValueOfInt(ds.Tables[0].Rows[i]["AD_WF_Node_ID"]));
                            nodeInfo.Add(ni);
                        }
                        else
                        {
                            int index = nodes.IndexOf(Util.GetValueOfInt(ds.Tables[0].Rows[i]["AD_WF_Node_ID"]));
                            nh            = new NodeHistory();
                            nh.State      = Util.GetValueOfString(ds.Tables[0].Rows[i]["WFState"]);
                            nh.ApprovedBy = Util.GetValueOfString(ds.Tables[0].Rows[i]["UserName"]);
                            if (ds.Tables[0].Rows[i]["TextMsg"] == null || ds.Tables[0].Rows[i]["TextMsg"] == DBNull.Value)
                            {
                                nh.TextMsg = string.Empty;
                            }
                            else
                            {
                                nh.TextMsg = ds.Tables[0].Rows[i]["TextMsg"].ToString();
                            }
                            nodeInfo[index].History.Add(nh);
                        }
                    }
                    info.Node = nodeInfo;
                }

                return(info);
            }
            catch
            {
                return(info);
            }
        }
コード例 #15
0
        public WFInfo GetActivities(Ctx ctx, int AD_User_ID, int AD_Client_ID, int pageNo, int pageSize, bool refresh)
        {
            string sql = @"SELECT * FROM (SELECT a.*,rownum as abcx
                            FROM AD_WF_Activity a
                            WHERE a.Processed  ='N'
                            AND a.WFState      ='OS'
                            AND a.AD_Client_ID =@clientid
                            AND ( (a.AD_User_ID=@userid
                            OR a.AD_User_ID   IN
                              (SELECT AD_User_ID
                              FROM AD_User_Substitute
                              WHERE IsActive   ='Y'
                              AND Substitute_ID=@userid
                              AND (validfrom  <=sysdate)
                              AND (sysdate    <=validto )
                              ))
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND COALESCE(r.AD_User_ID,0)=0
                              AND (a.AD_User_ID           =@userid
                              OR a.AD_User_ID            IS NULL
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=@userid
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              )
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND (r.AD_User_ID           =@userid
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=@userid
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              )
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              INNER JOIN AD_User_Roles ur
                              ON (r.AD_Role_ID            =ur.AD_Role_ID)
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND (ur.AD_User_ID          =@userid
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=@userid
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              AND r.responsibletype !='H'
                              ) )
                           ORDER BY a.Priority DESC,Created ) WHERE abcx BETWEEN " + (((pageNo - 1) * pageSize) + 1) + " AND " + (((pageNo - 1) * pageSize) + pageSize);

            //temp ORDER BY Created desc,a.Priority DESC
            //final  ORDER BY a.Priority DESC,Created
            //int AD_User_ID = Envs.GetContext().GetAD_User_ID();
            try
            {
                SqlParameter[] param = new SqlParameter[2];
                param[0] = new SqlParameter("@clientid", AD_Client_ID);
                param[1] = new SqlParameter("@userid", AD_User_ID);

                DataSet ds = DB.ExecuteDataset(sql, param);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return(null);
                }
                List <WFActivityInfo> lstInfo = new List <WFActivityInfo>();
                WFActivityInfo        itm     = null;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    itm = new WFActivityInfo();

                    itm.AD_Table_ID       = Util.GetValueOfInt(dr["AD_Table_ID"]);
                    itm.AD_User_ID        = Util.GetValueOfInt(dr["AD_User_ID"]);
                    itm.AD_WF_Activity_ID = Util.GetValueOfInt(dr["AD_WF_Activity_ID"]);

                    itm.AD_Node_ID           = Util.GetValueOfInt(dr["AD_WF_Node_ID"]);
                    itm.AD_WF_Process_ID     = Util.GetValueOfInt(dr["AD_WF_Process_ID"]);
                    itm.AD_WF_Responsible_ID = Util.GetValueOfInt(dr["AD_WF_Responsible_ID"]);
                    itm.AD_Workflow_ID       = Util.GetValueOfInt(dr["AD_Workflow_ID"]);
                    itm.CreatedBy            = Util.GetValueOfInt(dr["CreatedBy"]);
                    itm.DynPriorityStart     = Util.GetValueOfInt(dr["DynPriorityStart"]);
                    itm.Record_ID            = Util.GetValueOfInt(dr["Record_ID"]);
                    itm.TxtMsg      = Util.GetValueOfString(dr["TextMsg"]);
                    itm.WfState     = Util.GetValueOfString(dr["WfState"]);
                    itm.EndWaitTime = Util.GetValueOfDateTime(dr["EndWaitTime"]);
                    itm.Created     = Util.GetValueOfString(dr["Created"]);
                    MWFActivity act = new MWFActivity(ctx, itm.AD_WF_Activity_ID, null);
                    itm.NodeName    = act.GetNodeName();
                    itm.Summary     = act.GetSummary();
                    itm.Description = act.GetNodeDescription();
                    itm.Help        = act.GetNodeHelp();
                    itm.History     = act.GetHistoryHTML();
                    itm.Priority    = Util.GetValueOfInt(dr["Priority"]);
                    lstInfo.Add(itm);
                }

                WFInfo info = new WFInfo();
                info.LstInfo = lstInfo;
                //return lstInfo;

                if (refresh)
                {
                    sql = @"SELECT COUNT(*)
                            FROM AD_WF_Activity a
                            WHERE a.Processed  ='N'
                            AND a.WFState      ='OS'
                            AND a.AD_Client_ID =" + ctx.GetAD_Client_ID() + @"
                            AND ( (a.AD_User_ID=" + ctx.GetAD_User_ID() + @"
                            OR a.AD_User_ID   IN
                              (SELECT AD_User_ID
                              FROM AD_User_Substitute
                              WHERE IsActive   ='Y'
                              AND Substitute_ID=" + ctx.GetAD_User_ID() + @"
                              AND (validfrom  <=sysdate)
                              AND (sysdate    <=validto )
                              ))
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND COALESCE(r.AD_User_ID,0)=0
                              AND (a.AD_User_ID           =" + ctx.GetAD_User_ID() + @"
                              OR a.AD_User_ID            IS NULL
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=" + ctx.GetAD_User_ID() + @"
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              )
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND (r.AD_User_ID           =" + ctx.GetAD_User_ID() + @"
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=" + ctx.GetAD_User_ID() + @"
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              )
                            OR EXISTS
                              (SELECT *
                              FROM AD_WF_Responsible r
                              INNER JOIN AD_User_Roles ur
                              ON (r.AD_Role_ID            =ur.AD_Role_ID)
                              WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID
                              AND (ur.AD_User_ID          =" + ctx.GetAD_User_ID() + @"
                              OR a.AD_User_ID            IN
                                (SELECT AD_User_ID
                                FROM AD_User_Substitute
                                WHERE IsActive   ='Y'
                                AND Substitute_ID=" + ctx.GetAD_User_ID() + @"
                                AND (validfrom  <=sysdate)
                                AND (sysdate    <=validto )
                                ))
                              AND r.responsibletype !='H'
                              ) )
                           ";

                    info.count = Util.GetValueOfInt(DB.ExecuteScalar(sql));
                }
                return(info);
            }
            catch
            {
                return(null);
            }
        }
コード例 #16
0
        public DocAtions GetActions(int AD_Table_ID, int Record_ID, string docStatus, bool processing, string orderType, bool isSOTrx, string docAction, string tableName, List <string> _values, List <string> _names)
        {
            DocAtions action = new DocAtions();

            string[] options  = null;
            int      index    = 0;
            string   defaultV = "";

            action.DocStatus = docStatus;

            VLogger.Get().Fine("DocStatus=" + docStatus
                               + ", DocAction=" + docAction + ", OrderType=" + orderType
                               + ", IsSOTrx=" + isSOTrx + ", Processing=" + processing
                               + ", AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID);
            options = new String[_values.Count()];
            String wfStatus = MWFActivity.GetActiveInfo(ctx, AD_Table_ID, Record_ID);

            if (wfStatus != null)
            {
                VLogger.Get().SaveError("WFActiveForRecord", wfStatus);
                action.Error = "WFActiveForRecord";
                return(action);
            }

            //	Status Change
            if (!CheckStatus(tableName, Record_ID, docStatus))
            {
                VLogger.Get().SaveError("DocumentStatusChanged", "");
                action.Error = "DocumentStatusChanged";
                return(action);
            }
            // if (processing != null)
            {
                bool locked = "Y".Equals(processing);
                if (!locked && processing.GetType() == typeof(Boolean))
                {
                    locked = ((Boolean)processing);
                }
                // do not show Unlock action on Production execution
                if (locked && !(AD_Table_ID == ViennaAdvantage.Model.X_VAMFG_M_WrkOdrTransaction.Table_ID))
                {
                    options[index++] = DocumentEngine.ACTION_UNLOCK;
                }
            }

            //	Approval required           ..  NA
            if (docStatus.Equals(DocumentEngine.STATUS_NOTAPPROVED))
            {
                options[index++] = DocumentEngine.ACTION_PREPARE;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	Draft/Invalid				..  DR/IN
            else if (docStatus.Equals(DocumentEngine.STATUS_DRAFTED) ||
                     docStatus.Equals(DocumentEngine.STATUS_INVALID))
            {
                options[index++] = DocumentEngine.ACTION_COMPLETE;
                //	options[index++] = DocumentEngine.ACTION_Prepare;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	In Process                  ..  IP
            else if (docStatus.Equals(DocumentEngine.STATUS_INPROGRESS) ||
                     docStatus.Equals(DocumentEngine.STATUS_APPROVED))
            {
                options[index++] = DocumentEngine.ACTION_COMPLETE;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	Complete                    ..  CO
            else if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
            {
                options[index++] = DocumentEngine.ACTION_CLOSE;
            }
            //	Waiting Payment
            else if (docStatus.Equals(DocumentEngine.STATUS_WAITINGPAYMENT) ||
                     docStatus.Equals(DocumentEngine.STATUS_WAITINGCONFIRMATION))
            {
                options[index++] = DocumentEngine.ACTION_VOID;
                options[index++] = DocumentEngine.ACTION_PREPARE;
            }
            //	Closed, Voided, REversed    ..  CL/VO/RE
            else if (docStatus.Equals(DocumentEngine.STATUS_CLOSED) ||
                     docStatus.Equals(DocumentEngine.STATUS_VOIDED) ||
                     docStatus.Equals(DocumentEngine.STATUS_REVERSED))
            {
                return(action);
            }

            int  refIndex        = index;
            bool indexFromModule = true;

            GetActionFromModuleClass(AD_Table_ID, docStatus, out index, options);

            if (index == 0)
            {
                index           = refIndex;
                indexFromModule = false;
            }

            /********************
             *  Order
             */
            if (AD_Table_ID == MOrder.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocumentEngine.STATUS_DRAFTED) ||
                    docStatus.Equals(DocumentEngine.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocumentEngine.STATUS_INVALID))
                {
                    options[index++] = DocumentEngine.ACTION_PREPARE;
                    options[index++] = DocumentEngine.ACTION_CLOSE;
                    //	Draft Sales Order Quote/Proposal - Process
                    if (isSOTrx &&
                        ("OB".Equals(orderType) || "ON".Equals(orderType)))
                    {
                        docAction = DocumentEngine.ACTION_PREPARE;
                    }
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REACTIVATE;
                }
                else if (docStatus.Equals(DocumentEngine.STATUS_WAITINGPAYMENT))
                {
                    options[index++] = DocumentEngine.ACTION_REACTIVATE;
                    options[index++] = DocumentEngine.ACTION_CLOSE;
                }
            }

            /********************
             *  Shipment
             */
            else if (AD_Table_ID == MInOut.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Invoice
             */
            else if (AD_Table_ID == MInvoice.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Payment
             */
            else if (AD_Table_ID == MPayment.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  GL Journal
             */
            //else if (AD_Table_ID == MJournal.Table_ID || AD_Table_ID == MJournalBatch.Table_ID)
            //{
            //    //	Complete                    ..  CO
            //    if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
            //    {
            //        options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
            //        options[index++] = DocumentEngine.ACTION_REVERSE_ACCRUAL;
            //    }
            //}

            /********************
             *  Allocation
             */
            else if (AD_Table_ID == MAllocationHdr.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Bank Statement
             */
            else if (AD_Table_ID == MBankStatement.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                }
            }

            /********************
             *  Inventory Movement, Physical Inventory
             */
            else if (AD_Table_ID == MMovement.Table_ID ||
                     AD_Table_ID == MInventory.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    // SI_0622 : not to show VOID and REVERSE_CORRECT action on Physical Inventory
                    bool isPhysicalInventory = false;
                    if (AD_Table_ID == MInventory.Table_ID)
                    {
                        MInventory inventory = MInventory.Get(ctx, Record_ID);
                        isPhysicalInventory = !inventory.IsInternalUse();
                    }
                    if (!isPhysicalInventory)
                    {
                        options[index++] = DocumentEngine.ACTION_VOID;
                        options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                    }
                }
            }

            // Added By Arpit
            else if (AD_Table_ID == MMovementConfirm.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    // SI_0630 : System should not allow to void the Move confirmation after its completion
                    //options[index++] = DocumentEngine.ACTION_VOID;
                }
            }
            //End

            //    /********************
            //*  Warehouse Task  New Add by raghu 11 april,2011
            //*/
            //    else if (AD_Table_ID == X_M_WarehouseTask.Table_ID
            //        || AD_Table_ID == X_M_TaskList.Table_ID)
            //    {
            //        //	Draft                       ..  DR/IP/IN
            //        if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED)
            //            || docStatus.Equals(DocActionVariables.STATUS_INPROGRESS)
            //            || docStatus.Equals(DocActionVariables.STATUS_INVALID))
            //        {
            //            options[index++] = DocActionVariables.ACTION_PREPARE;
            //        }
            //        //	Complete                    ..  CO
            //        else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
            //        {
            //            options[index++] = DocActionVariables.ACTION_VOID;
            //            options[index++] = DocActionVariables.ACTION_REVERSE_CORRECT;
            //        }
            //    }

            /********************
             *  Work Order New Add by raghu 11 april,2011
             */
            else if (AD_Table_ID == ViennaAdvantage.Model.X_VAMFG_M_WorkOrder.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED) ||
                    docStatus.Equals(DocActionVariables.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocActionVariables.STATUS_INVALID))
                {
                    options[index++] = DocActionVariables.ACTION_PREPARE;
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
                {
                    options[index++] = DocActionVariables.ACTION_VOID;
                    options[index++] = DocActionVariables.ACTION_REACTIVATE;
                }
            }

            /********************
             *  Work Order Transaction New Add by raghu 11 april,2011
             */
            else if (AD_Table_ID == ViennaAdvantage.Model.X_VAMFG_M_WrkOdrTransaction.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED) ||
                    docStatus.Equals(DocActionVariables.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocActionVariables.STATUS_INVALID))
                {
                    options[index++] = DocActionVariables.ACTION_PREPARE;
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
                {
                    options[index++] = DocActionVariables.ACTION_VOID;
                    options[index++] = DocActionVariables.ACTION_REVERSE_CORRECT;
                }
            }

            /* Obsolete Inventory New add by Amit 24-May-2016 */
            //else if (tableName == "VA024_ObsoleteInventory")
            //{
            //    // DR/IN
            //    if (docStatus.Equals(DocumentEngine.STATUS_DRAFTED)
            //        || docStatus.Equals(DocumentEngine.STATUS_INVALID))
            //    {
            //        options[index++] = DocumentEngine.ACTION_COMPLETE;
            //        options[index++] = DocumentEngine.ACTION_VOID;
            //    }
            //    //	Complete
            //    else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
            //    {
            //        options[index++] = DocActionVariables.ACTION_VOID;
            //        options[index++] = DocActionVariables.ACTION_REVERSE_CORRECT;
            //    }
            //}

            /***For Primary thread***/
            ///**
            // *	Fill actionCombo
            // */
            //for (int i = 0; i < index; i++)
            //{
            //    //	Serach for option and add it
            //    bool added = false;
            //    for (int j = 0; j < _values.Length && !added; j++)
            //        if (options[i].Equals(_values[j]))
            //        {
            //            //actionCombo.addItem(_names[j]);
            //            vcmbAction.Items.Add(_names[j]);
            //            added = true;
            //        }
            //}

            //	setDefault
            if (docAction.Equals("--"))         //	If None, suggest closing
            {
                docAction = DocumentEngine.ACTION_CLOSE;
            }



            //if (C_DocType_ID == 0)
            //{
            //    C_DocType_ID = C_DocTypeTarget_ID;
            //}

            //if (C_DocType_ID != null && C_DocType_ID > 0)
            //{
            //    String[] docActionHolder = new String[] { docAction };
            //    MTable table = MTable.Get(ctx, AD_Table_ID);
            //    PO po = table.GetPO(ctx, Record_ID, null);
            //    if (po is DocOptions)
            //        index = ((DocOptions)po).customizeValidActions(docStatus, processing, orderType, isSOTrx ? "Y" : "N",
            //                AD_Table_ID, docActionHolder, options, index);

            //    //   options = DocumentEngine.checkActionAccess(ctx, ctx.GetAD_Client_ID(), ctx.GetAD_Role_ID(), C_DocType_ID, options, ref index);
            //}

            for (int i = 0; i < _values.Count() && defaultV.Equals(""); i++)
            {
                if (docAction.Equals(_values[i]))
                {
                    defaultV = _names[i];
                }
            }


            action.Options = options.ToList();
            if (indexFromModule)
            {
                action.Index = index + 1;
            }
            else
            {
                action.Index = index;
            }
            action.DefaultV = defaultV;

            return(action);

            /***For Primary thread***/
            //if (!defaultV.Equals(""))
            //{
            //    //vcmbAction.SelectedValue = defaultV;
            //    vcmbAction.SelectedItem = defaultV;
            //}
        }
コード例 #17
0
        /// <summary>
        /// Evaluate Condition
        /// </summary>
        /// <param name="activity">activity</param>
        /// <returns>true if true</returns>
        public bool Evaluate(MWFActivity activity)
        {
            AD_WF_Activity_ID = activity.GetAD_WF_Activity_ID();
            if (GetAD_Column_ID() == 0)
            {
                //throw new IllegalStateException("No Column defined - " + this);
                throw new Exception("No Column defined - " + this);
            }



            PO po = activity.GetPO();

            if (po == null || po.Get_ID() == 0)
            {
                //throw new IllegalStateException("Could not evaluate " + po + " - " + this);
                throw new Exception("Could not evaluate " + po + " - " + this);
            }
            //
            Object valueObj = po.Get_ValueOfColumn(GetAD_Column_ID());

            if (valueObj == null)
            {
                valueObj = "";
            }
            String value1 = GetValue();

            if (value1 == null)
            {
                value1 = "";
            }



            String value2 = GetValue2();

            if (value2 == null)
            {
                value2 = "";
            }

            // If column is of bool type and user insert y or n in condition, then convert them to true or false to match with value got from PO.
            if (MColumn.Get(GetCtx(), GetAD_Column_ID()).GetAD_Reference_ID().Equals(DisplayType.YesNo))
            {
                if (value1.ToLower().Equals("y"))
                {
                    value1 = "true";
                }
                else if (value1.ToLower().Equals("n"))
                {
                    value1 = "false";
                }

                if (value2.ToLower().Equals("y"))
                {
                    value2 = "true";
                }
                else if (value2.ToLower().Equals("n"))
                {
                    value2 = "false";
                }
            }

            String resultStr = "PO:{" + valueObj + "} " + GetOperation() + " Condition:{" + value1 + "}";

            if (GetOperation().Equals(OPERATION_Sql))
            {
                throw new ArgumentException("SQL Operator not implemented yet: " + resultStr);
            }
            if (GetOperation().Equals(OPERATION_X))
            {
                resultStr += "{" + value2 + "}";
            }

            bool result = false;

            //Lakhwinder
            if (MColumn.Get(GetCtx(), GetAD_Column_ID()).GetColumnName().ToUpper().Equals("C_GENATTRIBUTESETINSTANCE_ID"))
            {
                return(EvaluateAttributeCondition(po));
            }

            //if (valueObj instanceof Number)
            if (valueObj != null && CommonFunctions.IsNumeric(valueObj.ToString()))
            {
                result = CompareNumber(valueObj, value1, value2);
            }
            else
            {
                result = CompareString(valueObj, value1, value2);
            }
            //
            log.Fine(resultStr + " -> " + result + (_numeric ? " (#)" : " ($)"));
            return(result);
        }
コード例 #18
0
        public DocAtions GetActions(int AD_Table_ID, int Record_ID, string docStatus, bool processing, string orderType, bool isSOTrx, string docAction, string tableName, List <string> _values, List <string> _names)
        {
            DocAtions action = new DocAtions();

            string[] options  = null;
            int      index    = 0;
            string   defaultV = "";

            action.DocStatus = docStatus;

            VLogger.Get().Fine("DocStatus=" + docStatus
                               + ", DocAction=" + docAction + ", OrderType=" + orderType
                               + ", IsSOTrx=" + isSOTrx + ", Processing=" + processing
                               + ", AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID);
            options = new String[_values.Count()];
            String wfStatus = MWFActivity.GetActiveInfo(ctx, AD_Table_ID, Record_ID);

            if (wfStatus != null)
            {
                VLogger.Get().SaveError("WFActiveForRecord", wfStatus);
                action.Error = "WFActiveForRecord";
                return(action);
            }

            //	Status Change
            if (!CheckStatus(tableName, Record_ID, docStatus))
            {
                VLogger.Get().SaveError("DocumentStatusChanged", "");
                action.Error = "DocumentStatusChanged";
                return(action);
            }
            // if (processing != null)
            {
                bool locked = "Y".Equals(processing);
                if (!locked && processing.GetType() == typeof(Boolean))
                {
                    locked = ((Boolean)processing);
                }
                if (locked)
                {
                    options[index++] = DocumentEngine.ACTION_UNLOCK;
                }
            }

            //	Approval required           ..  NA
            if (docStatus.Equals(DocumentEngine.STATUS_NOTAPPROVED))
            {
                options[index++] = DocumentEngine.ACTION_PREPARE;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	Draft/Invalid				..  DR/IN
            else if (docStatus.Equals(DocumentEngine.STATUS_DRAFTED) ||
                     docStatus.Equals(DocumentEngine.STATUS_INVALID))
            {
                options[index++] = DocumentEngine.ACTION_COMPLETE;
                //	options[index++] = DocumentEngine.ACTION_Prepare;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	In Process                  ..  IP
            else if (docStatus.Equals(DocumentEngine.STATUS_INPROGRESS) ||
                     docStatus.Equals(DocumentEngine.STATUS_APPROVED))
            {
                options[index++] = DocumentEngine.ACTION_COMPLETE;
                options[index++] = DocumentEngine.ACTION_VOID;
            }
            //	Complete                    ..  CO
            else if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
            {
                options[index++] = DocumentEngine.ACTION_CLOSE;
            }
            //	Waiting Payment
            else if (docStatus.Equals(DocumentEngine.STATUS_WAITINGPAYMENT) ||
                     docStatus.Equals(DocumentEngine.STATUS_WAITINGCONFIRMATION))
            {
                options[index++] = DocumentEngine.ACTION_VOID;
                options[index++] = DocumentEngine.ACTION_PREPARE;
            }
            //	Closed, Voided, REversed    ..  CL/VO/RE
            else if (docStatus.Equals(DocumentEngine.STATUS_CLOSED) ||
                     docStatus.Equals(DocumentEngine.STATUS_VOIDED) ||
                     docStatus.Equals(DocumentEngine.STATUS_REVERSED))
            {
                return(action);
            }

            GetActionFromModuleClass(AD_Table_ID, docStatus, index, options);

            /********************
             *  Order
             */
            if (AD_Table_ID == MOrder.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocumentEngine.STATUS_DRAFTED) ||
                    docStatus.Equals(DocumentEngine.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocumentEngine.STATUS_INVALID))
                {
                    options[index++] = DocumentEngine.ACTION_PREPARE;
                    options[index++] = DocumentEngine.ACTION_CLOSE;
                    //	Draft Sales Order Quote/Proposal - Process
                    if (isSOTrx &&
                        ("OB".Equals(orderType) || "ON".Equals(orderType)))
                    {
                        docAction = DocumentEngine.ACTION_PREPARE;
                    }
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REACTIVATE;
                }
                else if (docStatus.Equals(DocumentEngine.STATUS_WAITINGPAYMENT))
                {
                    options[index++] = DocumentEngine.ACTION_REACTIVATE;
                    options[index++] = DocumentEngine.ACTION_CLOSE;
                }
            }

            /********************
             *  Shipment
             */
            else if (AD_Table_ID == MInOut.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Invoice
             */
            else if (AD_Table_ID == MInvoice.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Payment
             */
            else if (AD_Table_ID == MPayment.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  GL Journal
             */
            //else if (AD_Table_ID == MJournal.Table_ID || AD_Table_ID == MJournalBatch.Table_ID)
            //{
            //    //	Complete                    ..  CO
            //    if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
            //    {
            //        options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
            //        options[index++] = DocumentEngine.ACTION_REVERSE_ACCRUAL;
            //    }
            //}

            /********************
             *  Allocation
             */
            else if (AD_Table_ID == MAllocationHdr.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            /********************
             *  Bank Statement
             */
            else if (AD_Table_ID == MBankStatement.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                }
            }

            /********************
             *  Inventory Movement, Physical Inventory
             */
            else if (AD_Table_ID == MMovement.Table_ID ||
                     AD_Table_ID == MInventory.Table_ID)
            {
                //	Complete                    ..  CO
                if (docStatus.Equals(DocumentEngine.STATUS_COMPLETED))
                {
                    options[index++] = DocumentEngine.ACTION_VOID;
                    options[index++] = DocumentEngine.ACTION_REVERSE_CORRECT;
                }
            }

            //    /********************
            //*  Warehouse Task  New Add by raghu 11 april,2011
            //*/
            //    else if (AD_Table_ID == X_M_WarehouseTask.Table_ID
            //        || AD_Table_ID == X_M_TaskList.Table_ID)
            //    {
            //        //	Draft                       ..  DR/IP/IN
            //        if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED)
            //            || docStatus.Equals(DocActionVariables.STATUS_INPROGRESS)
            //            || docStatus.Equals(DocActionVariables.STATUS_INVALID))
            //        {
            //            options[index++] = DocActionVariables.ACTION_PREPARE;
            //        }
            //        //	Complete                    ..  CO
            //        else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
            //        {
            //            options[index++] = DocActionVariables.ACTION_VOID;
            //            options[index++] = DocActionVariables.ACTION_REVERSE_CORRECT;
            //        }
            //    }

            /********************
             *  Work Order New Add by raghu 11 april,2011
             */
            else if (AD_Table_ID == ViennaAdvantage.Model.X_VAMFG_M_WorkOrder.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED) ||
                    docStatus.Equals(DocActionVariables.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocActionVariables.STATUS_INVALID))
                {
                    options[index++] = DocActionVariables.ACTION_PREPARE;
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
                {
                    options[index++] = DocActionVariables.ACTION_VOID;
                    options[index++] = DocActionVariables.ACTION_REACTIVATE;
                }
            }

            /********************
             *  Work Order Transaction New Add by raghu 11 april,2011
             */
            else if (AD_Table_ID == ViennaAdvantage.Model.X_VAMFG_M_WrkOdrTransaction.Table_ID)
            {
                //	Draft                       ..  DR/IP/IN
                if (docStatus.Equals(DocActionVariables.STATUS_DRAFTED) ||
                    docStatus.Equals(DocActionVariables.STATUS_INPROGRESS) ||
                    docStatus.Equals(DocActionVariables.STATUS_INVALID))
                {
                    options[index++] = DocActionVariables.ACTION_PREPARE;
                }
                //	Complete                    ..  CO
                else if (docStatus.Equals(DocActionVariables.STATUS_COMPLETED))
                {
                    options[index++] = DocActionVariables.ACTION_VOID;
                    options[index++] = DocActionVariables.ACTION_REVERSE_CORRECT;
                }
            }

            /***For Primary thread***/
            ///**
            // *	Fill actionCombo
            // */
            //for (int i = 0; i < index; i++)
            //{
            //    //	Serach for option and add it
            //    bool added = false;
            //    for (int j = 0; j < _values.Length && !added; j++)
            //        if (options[i].Equals(_values[j]))
            //        {
            //            //actionCombo.addItem(_names[j]);
            //            vcmbAction.Items.Add(_names[j]);
            //            added = true;
            //        }
            //}

            //	setDefault
            if (docAction.Equals("--"))         //	If None, suggest closing
            {
                docAction = DocumentEngine.ACTION_CLOSE;
            }

            for (int i = 0; i < _values.Count() && defaultV.Equals(""); i++)
            {
                if (docAction.Equals(_values[i]))
                {
                    defaultV = _names[i];
                }
            }


            action.Options  = options.ToList();
            action.Index    = index;
            action.DefaultV = defaultV;


            return(action);

            /***For Primary thread***/
            //if (!defaultV.Equals(""))
            //{
            //    //vcmbAction.SelectedValue = defaultV;
            //    vcmbAction.SelectedItem = defaultV;
            //}
        }