/// <summary> /// New Constructor /// </summary> /// <param name="wf">workflow</param> /// <param name="pi">Process Info (Record_ID)</param> public MWFProcess(MWorkflow wf, ProcessInfo pi) : base(wf.GetCtx(), 0, wf.Get_TrxName()) { if (!Utility.TimeUtil.IsValid(wf.GetValidFrom(), wf.GetValidTo())) // make this class or this function { //throw new IllegalStateException("Workflow not valid"); throw new Exception("Workflow not valid"); } _wf = wf; _pi = pi; SetAD_Client_ID(wf.GetAD_Client_ID()); SetAD_Workflow_ID(wf.GetAD_Workflow_ID()); SetPriority(wf.GetPriority()); base.SetWFState(WFSTATE_NotStarted); // vinay bhatt for window id SetAD_Window_ID(pi.GetAD_Window_ID()); // // Document SetAD_Table_ID(wf.GetAD_Table_ID()); SetRecord_ID(pi.GetRecord_ID()); if (GetPO() == null) { SetTextMsg("No PO with ID=" + pi.GetRecord_ID()); base.SetWFState(WFSTATE_Terminated); } else { SetTextMsg(GetPO()); } // Responsible/User if (wf.GetAD_WF_Responsible_ID() == 0) { SetAD_WF_Responsible_ID(); } else { SetAD_WF_Responsible_ID(wf.GetAD_WF_Responsible_ID()); } SetUser_ID((int)pi.GetAD_User_ID()); // user starting // _state = new StateEngine(GetWFState()); _state.SetCtx(GetCtx()); SetProcessed(false); // Lock Entity GetPO(); if (_po != null) { // Set transaction organization on workflow process SetAD_Org_ID(_po.GetAD_Org_ID()); _po.Lock(); } }
/// <summary> /// Get Doc Value Workflow /// </summary> /// <param name="ctx">context</param> /// <param name="AD_Client_ID">client</param> /// <param name="AD_Table_ID">table</param> /// <returns>document value workflow array or null</returns> public static MWorkflow[] GetDocValue(Ctx ctx, int AD_Client_ID, int AD_Table_ID) { String key = "C" + AD_Client_ID + "T" + AD_Table_ID; //Reload if (_cacheDocValue.IsReset()) { String sql = "SELECT * FROM AD_Workflow " + "WHERE WorkflowType='V' AND IsActive='Y' AND IsValid='Y' " + "ORDER BY AD_Client_ID, AD_Table_ID"; List <MWorkflow> list = new List <MWorkflow>(); String oldKey = ""; String newKey = null; DataSet ds = null; try { ds = DataBase.DB.ExecuteDataset(sql, null, null); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow rs = ds.Tables[0].Rows[i]; MWorkflow wf = new MWorkflow(ctx, rs, null); newKey = "C" + wf.GetAD_Client_ID() + "T" + wf.GetAD_Table_ID(); if (!newKey.Equals(oldKey) && list.Count > 0) { MWorkflow[] wfs = new MWorkflow[list.Count]; wfs = list.ToArray(); _cacheDocValue.Add(oldKey, wfs); list = new List <MWorkflow>(); } oldKey = newKey; list.Add(wf); } ds = null; } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } // Last one if (list.Count > 0) { MWorkflow[] wfs = new MWorkflow[list.Count]; wfs = list.ToArray(); _cacheDocValue.Add(oldKey, wfs); } _log.Config("#" + _cacheDocValue.Count); } // Look for Entry MWorkflow[] retValue = (MWorkflow[])_cacheDocValue[key]; return(retValue); }