Пример #1
0
        /**
         *  Get all active interest areas
         *	@param ctx context
         *	@return interest areas
         */
        public static MInterestArea[] GetAll(Ctx ctx)
        {
            List <MInterestArea> list = new List <MInterestArea>();
            String      sql           = "SELECT * FROM R_InterestArea WHERE IsActive='Y'";
            DataTable   dt            = null;
            IDataReader idr           = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    MInterestArea ia = new MInterestArea(ctx, dr, null);
                    list.Add(ia);
                }
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally { dt = null; }

            MInterestArea[] retValue = new MInterestArea[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }
Пример #2
0
        }       //	isSubscribed

        /**
         *  After Save
         *	@param newRecord new
         *	@param success success
         *	@return success
         */
        protected override Boolean AfterSave(Boolean newRecord, Boolean success)
        {
            if (success && newRecord && IsSubscribed())
            {
                MInterestArea ia = MInterestArea.Get(GetCtx(), GetR_InterestArea_ID());
                if (ia.GetR_Source_ID() != 0)
                {
                    String summary = "Subscribe: " + ia.GetName();
                    //
                    MSource source = MSource.Get(GetCtx(), ia.GetR_Source_ID());
                    MUser   user   = null;
                    if (Get_TrxName() == null)
                    {
                        user = MUser.Get(GetCtx(), GetAD_User_ID());
                    }
                    else
                    {
                        user = new MUser(GetCtx(), GetAD_User_ID(), Get_TrxName());
                    }
                    //	Create Request
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Request.Equals(source.GetSourceCreateType()))
                    {
                        MRequest request = new MRequest(GetCtx(), 0, Get_TrxName());
                        request.SetClientOrg(this);
                        request.SetSummary(summary);
                        request.SetAD_User_ID(GetAD_User_ID());
                        request.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        request.SetR_Source_ID(source.GetR_Source_ID());
                        request.Save();
                    }
                    //	Create Lead
                    if (MSource.SOURCECREATETYPE_Both.Equals(source.GetSourceCreateType()) ||
                        MSource.SOURCECREATETYPE_Lead.Equals(source.GetSourceCreateType()))
                    {
                        MLead lead = new MLead(GetCtx(), 0, Get_TrxName());
                        lead.SetClientOrg(this);
                        lead.SetDescription(summary);
                        lead.SetAD_User_ID(GetAD_User_ID());
                        lead.SetR_InterestArea_ID(GetR_InterestArea_ID());
                        lead.SetC_BPartner_ID(user.GetC_BPartner_ID());
                        lead.SetR_Source_ID(source.GetR_Source_ID());
                        lead.Save();
                    }
                }
            }
            return(success);
        }       //	afterSave
Пример #3
0
        /**
         *  Get MInterestArea from Cache
         *	@param ctx context
         *	@param R_InterestArea_ID id
         *	@return MInterestArea
         */
        public static MInterestArea Get(Ctx ctx, int R_InterestArea_ID)
        {
            int           key      = R_InterestArea_ID;
            MInterestArea retValue = (MInterestArea)_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MInterestArea(ctx, R_InterestArea_ID, null);
            if (retValue.Get_ID() != 0)
            {
                _cache.Add(key, retValue);
            }
            return(retValue);
        }
Пример #4
0
        }       //	findClient

        /// <summary>
        /// Find Interest Area
        /// </summary>
        /// <param name="AD_Client_ID">client</param>
        /// <param name="interestArea">interset Name client name</param>
        /// <returns>AD_Client_ID</returns>
        private int FindInterestArea(int AD_Client_ID, String interestArea)
        {
            if (_interests == null)
            {
                _interests = MInterestArea.GetAll(GetCtx());
            }
            for (int i = 0; i < _interests.Length; i++)
            {
                if (AD_Client_ID == _interests[i].GetAD_Client_ID() &&
                    interestArea.ToLower().Equals(_interests[i].GetValue().ToLower()))     //  interestArea.equalsIgnoreCase(_interests[i].GetValue()))
                {
                    return(_interests[i].GetR_InterestArea_ID());
                }
            }
            return(0);
        }       //	findInterestArea