Ejemplo n.º 1
0
        /*  Get Deliveries
         *  @return deliveries
         */
        public MAssetDelivery[] GetDeliveries()
        {
            List <MAssetDelivery> list = new List <MAssetDelivery>();

            String      sql = "SELECT * FROM A_Asset_Delivery WHERE A_Asset_ID=" + GetA_Asset_ID() + " ORDER BY Created DESC";
            DataTable   dt  = null;
            IDataReader idr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName());

            try
            {
                dt = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MAssetDelivery(GetCtx(), dr, Get_TrxName()));
                }
                dt = null;
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                log.Log(Level.SEVERE, sql, e);
            }

            //
            MAssetDelivery[] retValue = new MAssetDelivery[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Ejemplo n.º 2
0
        /**
         *  Confirm Asset EMail Delivery
         *	@param email email sent
         *  @param AD_User_ID recipient
         *  @return asset delivery
         */
        public MAssetDelivery ConfirmDelivery(EMail email, int AD_User_ID)
        {
            SetVersionNo(GetProductVersionNo());
            MAssetDelivery ad = new MAssetDelivery(this, email, null, AD_User_ID);

            return(ad);
        }
Ejemplo n.º 3
0
        }       //	authenticateSubscription

        /// <summary>
        /// Authenticate Product Asset
        /// </summary>
        /// <param name="ldapUser">user</param>
        /// <param name="AD_User_ID">id</param>
        /// <param name="usr">user authentification (email, ...)</param>
        /// <param name="M_Product_ID">product</param>
        /// <param name="AD_Client_ID">client</param>
        /// <param name="remoteHost">remote info</param>
        /// <param name="remoteAddr">remote info</param>
        /// <returns>user with error message set if error</returns>
        private MLdapUser AuthenticateAsset(MLdapUser ldapUser,
                                            int AD_User_ID, String usr, int M_Product_ID,
                                            int AD_Client_ID, String remoteHost, String remoteAddr)
        {
            String error = null;
            String info  = null;

            //	Query 2 - Validate Asset
            MAsset asset = null;
            String sql   = "SELECT * "
                           + "FROM A_Asset "
                           + "WHERE M_Product_ID=@param1"
                           + " AND AD_User_ID=@param2"; //	only specific user

            //	Will have problems with multiple assets
            SqlParameter[] param = new SqlParameter[2];
            IDataReader    idr   = null;

            try
            {
                //pstmt = DataBase.prepareStatement (sql, null);
                //pstmt.setInt (1, M_Product_ID);
                param[0] = new SqlParameter("@param1", M_Product_ID);
                //pstmt.setInt (2, AD_User_ID);
                param[1] = new SqlParameter("@param2", AD_User_ID);
                idr      = DataBase.DB.ExecuteReader(sql, param, null);
                if (idr.Read())
                {
                    asset = new MAsset(GetCtx(), idr, null);
                }
                idr.Close();
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
                error = "System Error (3)";
            }

            //	System Error
            if (error != null)
            {
                _error++;
                ldapUser.SetErrorString(error);
                return(ldapUser);
            }
            int A_Asset_ID = 0;

            if (asset == null)
            {
                error = "@UserNoAsset@ User="******"No Asset - " + usr + " - " + M_Product_ID;
            }
            else if (!asset.IsActive())
            {
                A_Asset_ID = asset.GetA_Asset_ID();
                error      = "@UserNoAsset@ User="******"Asset not active - " + usr;
            }
            else if (!asset.IsActive(true))
            {
                A_Asset_ID = asset.GetA_Asset_ID();
                error      = "@UserNoAsset@ User="******" @GuaranteeDate@=" + asset.GetGuaranteeDate();
                info       = "Expired - " + usr + " - GuaranteeDate=" + asset.GetGuaranteeDate();
            }
            else
            {
                info = "Asset - " + usr;
            }

            if (error != null)  //	should use Language of the User
            {
                LogAccess(AD_Client_ID, AD_User_ID, 0, A_Asset_ID, info, error,
                          remoteHost, remoteAddr);
                ldapUser.SetErrorString(Msg.Translate(GetCtx(), error));
                return(ldapUser);
            }
            //	Done OK
            MLdapAccess log = LogAccess(AD_Client_ID, AD_User_ID, 0, asset.GetA_Asset_ID(), info, null,
                                        remoteHost, remoteAddr);
            MAssetDelivery ad = new MAssetDelivery(asset, null, log.ToString(), AD_User_ID);

            ad.SetRemote_Host(remoteHost);
            ad.SetRemote_Addr(remoteAddr);
            ad.Save();
            return(ldapUser);
        }       //	authenticateAsset