コード例 #1
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
コード例 #2
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("");
        }
コード例 #3
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);
     }
 }
コード例 #4
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);
            }
        }