Esempio n. 1
0
        /// <summary>
        /// Get Trial Products for Entity Type
        /// </summary>
        /// <param name="ctx">ctx</param>
        /// <param name="entityType">entity type</param>
        /// <returns>trial product or null</returns>
        public static MProduct GetTrial(Ctx ctx, String entityType)
        {
            if (Util.IsEmpty(entityType))
            {
                _log.Warning("No Entity Type");
                return(null);
            }
            MProduct retValue = null;
            String   sql      = "SELECT * FROM M_Product "
                                + "WHERE LicenseInfo LIKE '%" + entityType + "%' AND TrialPhaseDays > 0 AND IsActive='Y'";
            //String entityTypeLike = "%" + entityType + "%";
            //pstmt.setString(1, entityTypeLike);
            DataSet ds = new DataSet();

            try
            {
                ds = DB.ExecuteDataset(sql, null, null);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    retValue = new MProduct(ctx, dr, null);
                }
                ds = null;
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, sql, e);
            }

            if (retValue != null && retValue.GetAD_Client_ID() != ctx.GetAD_Client_ID())
            {
                _log.Warning("ProductClient_ID=" + retValue.GetAD_Client_ID() + " <> EnvClient_ID=" + ctx.GetAD_Client_ID());
            }
            if (retValue != null && retValue.GetA_Asset_Group_ID() == 0)
            {
                _log.Warning("Product has no Asset Group - " + retValue);
                return(null);
            }
            if (retValue == null)
            {
                _log.Warning("No Product for EntityType - " + entityType);
            }
            return(retValue);
        }