/// <summary>
        /// 图片列表接口
        /// </summary>
        /// <returns></returns>
        public void GetList(HttpContext context)
        {
            int pageIndex = GetInt("start");
            int pageSize  = GetInt("limit");
            int sellerId  = GetInt("sellerid");

            PagResults <SourceMaterial> results = SourceMaterialHelper.GetPaging(pageIndex * pageSize, pageSize, sellerId);
            var data = new List <object>();

            foreach (var r in results.Results)
            {
                var imgurl = Utility.GetSizePicUrl(r.Url, 200, 0, context);
                var d      = new
                {
                    pid    = r.Id,
                    img    = imgurl,
                    height = Utility.GetImgHeight(imgurl, context),
                    title  = r.Title
                };
                r.Views += 1;
                SourceMaterialHelper.Update(r);
                data.Add(d);
            }
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
        /// <summary>
        /// 图片详情接口
        /// </summary>
        /// <returns></returns>
        public void GetItem(HttpContext context)
        {
            int            pid = GetInt("pid");
            SourceMaterial sm  = SourceMaterialHelper.GetItem(pid);

            if (sm == null)
            {
                ReturnErrorMsg("图片墙不存在id:" + pid);
                return;
            }

            var url  = Utility.GetSizePicUrl(sm.Url, 500, 0, context);
            var data = new
            {
                pid         = sm.Id,
                title       = sm.Title,
                img         = url,
                description = sm.Description,
                views       = sm.Views,
                commentnum  = sm.Commentnum,
                height      = Utility.GetImgHeight(url, context)
            };

            sm.Views += 1;
            SourceMaterialHelper.Update(sm);
            JsonTransfer jt = new JsonTransfer();

            jt.AddSuccessParam();
            jt.Add("data", data);
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
        /// <summary>
        /// 图片评论
        /// </summary>
        /// <returns></returns>
        public void ImgComment()
        {
            int            userId = GetInt("uid");
            int            imgId  = GetInt("pid");
            string         msg    = GetString("message");
            var            user   = AccountHelper.GetUser(userId);
            SourceMaterial sm     = SourceMaterialHelper.GetItem(imgId);
            Comment        c      = new Comment();

            c.SellerId = sm.SellerId;
            c.TypeId   = sm.Id;
            c.UserId   = userId;
            c.Content  = msg;
            c.Type     = CommentType.Img;
            //冗余两个字段
            c.Img   = sm.Url;
            c.Title = sm.Title;
            try
            {
                CommentHelper.Create(c);
                sm.Commentnum += 1;
                SourceMaterialHelper.Update(sm);
            }
            catch
            {
                ReturnErrorMsg("fail");
                throw;
            }
            ExtcreditLog log = new ExtcreditLog();

            if (!ExtcreditLogHelper.JudgeExtcreditGet(ExtcreditSourceType.CommentImg, imgId, userId))
            {
                //积分获得
                log.UserId   = userId;
                log.SellerId = user.SellerId;
                log.SourceId = imgId;
                var setting = SystemHelper.GetMerchantExtend(user.SellerId);
                log.Extcredit  = setting != null ? setting.CommentIntegral : 0;
                log.Type       = ExtcreditSourceType.CommentImg;
                log.CreateTime = DateTime.Now;

                ExtcreditLogHelper.AddExtcreditLog(log);

                user.Integral += log.Extcredit;
                AccountHelper.SaveAccount(user);
            }

            //ReturnCorrectMsg("评论成功");
            JsonTransfer jt = new JsonTransfer();

            jt.Add("data", new IntegralData(log.Extcredit));
            jt.AddSuccessParam();
            Response.Write(DesEncrypt(jt).ToLower());
            Response.End();
        }
        private void Update()
        {
            var id = GetInt("id");
            var sm = SourceMaterialHelper.GetItem(id);

            sm.Title = GetString("title");
            sm.Url   = GetString("thumbnail");
            var text = GetString("text");

            //sm.Summary = text.Length > 20 ? text.Substring(0, 20) : text;
            sm.Description = GetString("content");
            SourceMaterialHelper.Update(sm);
        }