Ejemplo n.º 1
0
        //启用宝贝
        public RespResult OpenBBPost(int bbPostID, string token)
        {
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    ProProduct pro = new ProProduct();
                    pro = ProProductAccessor.Instance.Get(bbPostID);

                    pro.State = 1;
                    ProProductAccessor.Instance.Update(pro);
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Ejemplo n.º 2
0
        //发布宝贝帖子
        public AdvancedResult <int> publishBBPost(string title, string qq, string mobile, string bbinfo, bool iswash, double price, int age, ItemType bbType, ItemSort bbSort, SexType sex, string token)
        {
            AdvancedResult <int> result = new AdvancedResult <int>();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));

                    if (!string.IsNullOrEmpty(qq) || !string.IsNullOrEmpty(mobile))
                    {
                        AdUser user = UserAccessor.Instance.Get(userid, string.Empty, string.Empty, StateType.Active);
                        if (!string.IsNullOrEmpty(qq))
                        {
                            user.Qq = qq;
                        }
                        if (!string.IsNullOrEmpty(mobile))
                        {
                            user.Mobile = mobile;
                        }
                        UserAccessor.Instance.Update(user);
                    }

                    ProProduct pro = new ProProduct();
                    pro.Title  = title.Trim();
                    pro.BbInfo = bbinfo.Trim();

                    pro.Price      = price;
                    pro.MinAge     = (age - 1) < 0 ? 0 : (age - 1);
                    pro.MaxAge     = age + 1;
                    pro.ItemType   = bbType;
                    pro.Sex        = sex;
                    pro.ItemSort   = bbSort;
                    pro.CreateId   = userid;
                    pro.CreateTime = DateTime.Now;
                    pro.Level      = 1;
                    pro.IsWash     = iswash;

                    result.Data  = ProProductAccessor.Instance.Insert(pro);
                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public ProductModel Bind(ProProduct product, ViewModelBindOption bindOptions)
        {
            this.Id          = product.Pid;
            this.Title       = product.Title;
            this.Description = product.BbInfo;
            this.IsWash      = product.IsWash;
            this.CreateTime  = product.CreateTime;
            this.ViewNum     = product.ViewNum;
            this.State       = product.State;
            this.Price       = product.Price;
            this.Sex         = product.Sex;
            this.ItemType    = product.ItemType;
            this.ItemSort    = product.ItemSort;
            this.Age         = (int)((product.MinAge + product.MaxAge) / 2.0);

            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.Pics))
            {
                this.Pics = PicModel.BindList(product.pics, bindOptions);
            }

            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.Author))
            {
                UserServiceClient       client  = new UserServiceClient();
                AdvancedResult <AdUser> userRes = client.GetUserInfoByID(product.CreateId);
                if (userRes.Error == DataStructure.AppError.ERROR_SUCCESS && userRes.Data != null)
                {
                    this.Author = new UserModel().Bind(userRes.Data, bindOptions);
                    if (!string.IsNullOrEmpty(userRes.Data.Qq))
                    {
                        this.QQ = userRes.Data.Qq;
                    }
                    if (!string.IsNullOrEmpty(userRes.Data.Mobile))
                    {
                        this.Phone = userRes.Data.Mobile;
                    }
                }
            }
            if (ContainEnumType <ProductBindType>(bindOptions.ProductBindType, ProductBindType.ReplyCount))
            {
                ReplyServiceClient client = new ReplyServiceClient();
                AdvancedResult <PageEntity <GenReply> > response = client.LoadReplyListByBBPostID(product.Pid, 0, 0);
                if (response.Error == AppError.ERROR_SUCCESS)
                {
                    this.ReplyNum = response.Data.RecordsCount;
                }
            }
            return(this);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加数据
        /// <param name="es">数据实体对象数组</param>
        /// <returns></returns>
        /// </summary>
        public int Insert(ProProduct e)
        {
            MySqlConnection oc = ConnectManager.Create();
            MySqlCommand    _cmdInsertProProduct = cmdInsertProProduct.Clone() as MySqlCommand;
            int             returnValue          = 0;

            _cmdInsertProProduct.Connection = oc;
            try
            {
                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }
                _cmdInsertProProduct.Parameters["@Pid"].Value        = e.Pid;
                _cmdInsertProProduct.Parameters["@Title"].Value      = e.Title;
                _cmdInsertProProduct.Parameters["@BbInfo"].Value     = e.BbInfo;
                _cmdInsertProProduct.Parameters["@State"].Value      = e.State == 0 ? 1 : e.State;
                _cmdInsertProProduct.Parameters["@Level"].Value      = e.Level;
                _cmdInsertProProduct.Parameters["@CreateTime"].Value = e.CreateTime;
                _cmdInsertProProduct.Parameters["@CreateId"].Value   = e.CreateId;
                _cmdInsertProProduct.Parameters["@ViewNum"].Value    = e.ViewNum;
                _cmdInsertProProduct.Parameters["@IsWash"].Value     = e.IsWash ? 1 : 2;
                _cmdInsertProProduct.Parameters["@MinAge"].Value     = e.MinAge;
                _cmdInsertProProduct.Parameters["@MaxAge"].Value     = e.MaxAge;
                _cmdInsertProProduct.Parameters["@Price"].Value      = e.Price;
                _cmdInsertProProduct.Parameters["@ItemType"].Value   = (int)e.ItemType;
                _cmdInsertProProduct.Parameters["@ItemSort"].Value   = (int)e.ItemSort;
                _cmdInsertProProduct.Parameters["@Sex"].Value        = (int)e.Sex;

                _cmdInsertProProduct.ExecuteNonQuery();



                returnValue = Convert.ToInt32(_cmdInsertProProduct.LastInsertedId);
                return(returnValue);
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdInsertProProduct.Dispose();
                _cmdInsertProProduct = null;
            }
        }
Ejemplo n.º 5
0
        //获取宝贝帖子信息(包含宝贝信息)
        public AdvancedResult <ProProduct> GetBBInfo(int bbPostID)
        {
            AdvancedResult <ProProduct> result = new AdvancedResult <ProProduct>();

            try
            {
                ProProduct pro = new ProProduct();
                pro          = ProProductAccessor.Instance.Get(bbPostID);
                result.Data  = pro;
                result.Error = AppError.ERROR_SUCCESS;
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Ejemplo n.º 6
0
        //浏览单个宝贝(+1)
        public RespResult SetBBPostViewNum(int bbPostID)
        {
            RespResult result = new RespResult();

            try
            {
                ProProduct pro = new ProProduct();
                pro = ProProductAccessor.Instance.Get(bbPostID);

                pro.ViewNum = pro.ViewNum + 1;
                ProProductAccessor.Instance.Update(pro);
                result.Error = AppError.ERROR_SUCCESS;
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Ejemplo n.º 7
0
        //回复评论
        public RespResult ReplyBBPost(int bbPostID, int refReplyID, string Content, string token)
        {
            RespResult result = new RespResult();

            try
            {
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int        userid  = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));
                    ProProduct product = ProProductAccessor.Instance.Get(bbPostID);
                    if (product != null)
                    {
                        GenReply reply = new GenReply();
                        reply.ObjId      = bbPostID;
                        reply.ObjType    = (int)ReplyType.BB;
                        reply.Content    = Content;
                        reply.CreateId   = userid;
                        reply.RefUserId  = product.CreateId;
                        reply.RefReplyId = refReplyID;
                        GenReplyAccessor.Instance.Insert(reply);
                        result.Error = AppError.ERROR_SUCCESS;
                    }
                    else
                    {
                        result.Error = AppError.ERROR_FAILED;
                    }
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取指定记录
        /// <param name="id">Id值</param>
        /// </summary>
        public ProProduct Get(int bbPostID)
        {
            ProProduct      returnValue       = null;
            MySqlConnection oc                = ConnectManager.Create();
            MySqlCommand    _cmdGetProProduct = cmdGetProProduct.Clone() as MySqlCommand;

            _cmdGetProProduct.Connection = oc;
            try
            {
                _cmdGetProProduct.Parameters["@Pid"].Value = bbPostID;

                if (oc.State == ConnectionState.Closed)
                {
                    oc.Open();
                }

                MySqlDataReader reader = _cmdGetProProduct.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    returnValue = new ProProduct().BuildSampleEntity(reader);
                }

                List <ResPic> returnValue_item = new List <ResPic>();
                returnValue_item = ResPicAccessor.Instance.Search(bbPostID, PicType.BBPicture);
                returnValue.pics = returnValue_item;
            }
            finally
            {
                oc.Close();
                oc.Dispose();
                oc = null;
                _cmdGetProProduct.Dispose();
                _cmdGetProProduct = null;
                GC.Collect();
            }
            return(returnValue);
        }