/// <summary> /// Perform Process. /// </summary> /// <returns>Message (variables are parsed)</returns> protected override String DoIt() { MWFProcess process = new MWFProcess(GetCtx(), p_AD_WF_Process_ID, Get_Trx()); log.Info("doIt - " + process); MUser user = MUser.Get(GetCtx(), GetAD_User_ID()); // Abort if (p_IsAbort) { msg = user.GetName() + ": Abort"; process.SetTextMsg(msg); process.SetAD_User_ID(GetAD_User_ID()); process.SetWFState(StateEngine.STATE_ABORTED); //JID_0278 : To mark processing checkbox false. // Mohit // Date : 22 May 2019 MTable table = new MTable(GetCtx(), process.GetAD_Table_ID(), null); PO po = MTable.GetPO(GetCtx(), table.GetTableName(), process.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 && process.GetAD_User_ID() != p_AD_User_ID) { MUser from = MUser.Get(GetCtx(), process.GetAD_User_ID()); MUser to = MUser.Get(GetCtx(), p_AD_User_ID); msg = user.GetName() + ": " + from.GetName() + " -> " + to.GetName(); process.SetTextMsg(msg); process.SetAD_User_ID(p_AD_User_ID); } // Change Responsible if (p_AD_WF_Responsible_ID != 0 && process.GetAD_WF_Responsible_ID() != p_AD_WF_Responsible_ID) { MWFResponsible from = MWFResponsible.Get(GetCtx(), process.GetAD_WF_Responsible_ID()); MWFResponsible to = MWFResponsible.Get(GetCtx(), p_AD_WF_Responsible_ID); String msg1 = user.GetName() + ": " + from.GetName() + " -> " + to.GetName(); process.SetTextMsg(msg1); process.SetAD_WF_Responsible_ID(p_AD_WF_Responsible_ID); if (msg == null) { msg = msg1; } else { msg += " - " + msg1; } } process.Save(); return("OK"); }
/// <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); }
/// <summary> /// Perform Process. /// </summary> /// <returns>Message (variables are parsed)</returns> protected override String DoIt() { MWFProcess process = new MWFProcess(GetCtx(), p_AD_WF_Process_ID, Get_Trx()); log.Info("doIt - " + process); MUser user = MUser.Get(GetCtx(), GetAD_User_ID()); // Abort if (p_IsAbort) { msg = user.GetName() + ": Abort"; process.SetTextMsg(msg); process.SetAD_User_ID(GetAD_User_ID()); process.SetWFState(StateEngine.STATE_ABORTED); return(msg); } // Change User if (p_AD_User_ID != 0 && process.GetAD_User_ID() != p_AD_User_ID) { MUser from = MUser.Get(GetCtx(), process.GetAD_User_ID()); MUser to = MUser.Get(GetCtx(), p_AD_User_ID); msg = user.GetName() + ": " + from.GetName() + " -> " + to.GetName(); process.SetTextMsg(msg); process.SetAD_User_ID(p_AD_User_ID); } // Change Responsible if (p_AD_WF_Responsible_ID != 0 && process.GetAD_WF_Responsible_ID() != p_AD_WF_Responsible_ID) { MWFResponsible from = MWFResponsible.Get(GetCtx(), process.GetAD_WF_Responsible_ID()); MWFResponsible to = MWFResponsible.Get(GetCtx(), p_AD_WF_Responsible_ID); String msg1 = user.GetName() + ": " + from.GetName() + " -> " + to.GetName(); process.SetTextMsg(msg1); process.SetAD_WF_Responsible_ID(p_AD_WF_Responsible_ID); if (msg == null) { msg = msg1; } else { msg += " - " + msg1; } } process.Save(); return("OK"); }
/// <summary> /// Set User from /// - (1) Responsible /// - (2) Document Sales Rep /// - (3) Document UpdatedBy /// - (4) Process invoker /// </summary> /// <param name="User_ID">process invoker</param> private void SetUser_ID(int User_ID) { // Responsible MWFResponsible resp = MWFResponsible.Get(GetCtx(), GetAD_WF_Responsible_ID()); // (1) User - Directly responsible int AD_User_ID = resp.GetAD_User_ID(); // Invoker - get Sales Rep or last updater of Document if (AD_User_ID == 0 && resp.IsInvoker()) { GetPO(); // (2) Doc Owner //if (_po != null && _po instanceof DocAction) if (_po != null && (_po.GetType() == typeof(DocAction) || _po.GetType().GetInterface("DocAction") == typeof(DocAction))) { DocAction da = (DocAction)_po; AD_User_ID = da.GetDoc_User_ID(); } // (2) Sales Rep if (AD_User_ID == 0 && _po != null && _po.Get_ColumnIndex("SalesRep_ID") != -1) { Object sr = _po.Get_Value("SalesRep_ID"); if (sr != null && sr.GetType() == typeof(int)) { AD_User_ID = int.Parse(sr.ToString()); } } // (3) UpdatedBy if (AD_User_ID == 0 && _po != null) { AD_User_ID = _po.GetUpdatedBy(); } } // (4) Process Owner if (AD_User_ID == 0) { AD_User_ID = User_ID; } // Fallback if (AD_User_ID == 0) { AD_User_ID = GetCtx().GetAD_User_ID(); } // SetAD_User_ID(AD_User_ID); }