示例#1
0
        /// <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);
        }