Exemplo n.º 1
0
        /**
         *  Migrate Download URLs (2.5.2c)
         *	@param ctx context
         */
        public static void MigrateDownloads(Ctx ctx)
        {
            String sql = "SELECT COUNT(*) FROM M_ProductDownload";
            int    no  = DataBase.DB.GetSQLValue(null, sql);

            if (no > 0)
            {
                return;
            }
            //
            int count = 0;

            sql = "SELECT AD_Client_ID, AD_Org_ID, M_Product_ID, Name, DownloadURL "
                  + "FROM M_Product "
                  + "WHERE DownloadURL IS NOT NULL";
            IDataReader idr = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                while (idr.Read())
                {
                    int    AD_Client_ID = Utility.Util.GetValueOfInt(idr[0].ToString());
                    int    AD_Org_ID    = Utility.Util.GetValueOfInt(idr[1].ToString());
                    int    M_Product_ID = Utility.Util.GetValueOfInt(idr[2].ToString());
                    String Name         = idr[3].ToString();
                    String DownloadURL  = idr[4].ToString();
                    //
                    MProductDownload pdl = new MProductDownload(ctx, 0, null);
                    pdl.SetClientOrg(AD_Client_ID, AD_Org_ID);
                    pdl.SetM_Product_ID(M_Product_ID);
                    pdl.SetName(Name);
                    pdl.SetDownloadURL(DownloadURL);
                    if (pdl.Save())
                    {
                        count++;
                        String sqlUpdate = "UPDATE M_Product SET DownloadURL = NULL WHERE M_Product_ID=" + M_Product_ID;
                        int    updated   = DataBase.DB.ExecuteQuery(sqlUpdate, null, null);
                        if (updated != 1)
                        {
                            _log.Warning("Product not updated");
                        }
                    }
                    else
                    {
                        _log.Warning("Product Download not created M_Product_ID=" + M_Product_ID);
                    }
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            _log.Info("#" + count);
        }
Exemplo n.º 2
0
        /**
         *  Get Product Download from Cache
         *	@param ctx context
         *	@param M_ProductDownload_ID id
         *	@return MProductDownload
         */
        public static MProductDownload Get(Ctx ctx, int M_ProductDownload_ID)
        {
            int key = M_ProductDownload_ID;
            MProductDownload retValue = (MProductDownload)s_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MProductDownload(ctx, M_ProductDownload_ID, null);
            if (retValue.Get_ID() != 0)
            {
                s_cache.Add(key, retValue);
            }
            return(retValue);
        }