Exemplo n.º 1
0
        public void UploadSuccessReward(Guid fileId, int reqId)
        {
            DocService ds  = Context.GetService <DocService>();
            U_UserInfo u   = base.GetUser();
            DDocInfo   doc = ds.DDocInfoBll.GetByFileId(fileId);
            //更新悬赏列表的加入文档数量
            TReqDoc trdoc = ds.TReqDocBll.Get(reqId);

            trdoc.DocCount += 1;
            ds.TReqDocBll.Update(trdoc);
            //新增到加入列表
            TJoinDoc jd = new TJoinDoc()
            {
                DocId  = doc.DocId,
                TId    = reqId,
                Title  = doc.Title,
                UserId = u.UserId,
                IsWin  = false
            };

            ds.TJoinDocBll.Insert(jd);
            //转至我的投稿页面
            AddSuccess("投稿成功");
            Redirect("/my/MyContribute.do");
        }
Exemplo n.º 2
0
 /// <summary>
 /// 删除投稿
 /// </summary>
 /// <param name="joinId"></param>
 public void DeleteContribute(int joinId)
 {
     try
     {
         DocService  ds = Context.GetService <DocService>();
         UserService us = Context.GetService <UserService>();
         U_UserInfo  u  = base.GetUser();
         //投稿对象
         TJoinDoc tj = ds.TJoinDocBll.Get(joinId);
         if (tj.UserId != u.UserId)
         {
             throw new TmmException("操作失败,您不是该投稿的所有者");
         }
         if (tj.IsWin)
         {
             throw new TmmException("操作失败,该投稿已中标");
         }
         //删除文档
         ds.DDocInfoBll.Delete(tj.DocId);
         //删除投稿记录
         ds.TJoinDocBll.Delete(joinId);
         //更新悬赏的投稿数
         TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId);
         trDoc.DocCount -= 1;
         ds.TReqDocBll.Update(trDoc);
     }
     catch (TmmException te)
     {
         AddError(te.Message);
     }
     RedirectToReferrer();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 设置中标
 /// </summary>
 /// <param name="joinId"></param>
 public void SetZb(int joinId)
 {
     try
     {
         DocService  ds = Context.GetService <DocService>();
         UserService us = Context.GetService <UserService>();
         U_UserInfo  u  = base.GetUser();
         //投稿对象
         TJoinDoc tj = ds.TJoinDocBll.Get(joinId);
         //是否已经中标了
         if (tj.IsWin)
         {
             throw new TmmException("此投稿已经设置为中标");
         }
         //悬赏对象
         TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId);
         //余额检测
         decimal ye = us.MAccountBll.GetByUserId(u.UserId).Amount;
         if (ye < trDoc.Price)
         {
             throw new TmmException("您的余额不足,请先充值");
         }
         //扣除需求方余额
         us.MAccountBll.AccountExpend(u.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(), trDoc.Title);
         //为投稿人增加余额
         us.MAccountBll.AddAmount(tj.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(), trDoc.Title);
         //更改原文档的owner
         DDocInfo doc = ds.DDocInfoBll.Get(tj.DocId);
         doc.UserId    = u.UserId;
         doc.IsTaskDoc = false;
         ds.DDocInfoBll.Update(doc);
         PropertyBag["doc"] = doc;
         //更改投稿文档的状态
         tj.IsWin   = true;
         tj.WinTime = DateTime.Now;
         ds.TJoinDocBll.Update(tj);
         //发送通知
         M_Message msg = new M_Message()
         {
             Mtype      = (int)Model.Enums.MessageType.Inform,
             SenderId   = ConfigHelper.AdminUserId,
             RecieverId = tj.UserId,
             Title      = "您的投稿被选中",
             IsRead     = false,
             CreateTime = DateTime.Now,
             Content    = string.Format("您的投稿【{0}】被{1}设置中标,获得收入¥{2}",
                                        tj.Title, "<a href='/home/" + u.UserId + ".html' target='_blank'>" + u.TmmDispName + "</a>"
                                        , string.Format("{0:N2}", trDoc.Price))
         };
         us.MessageBll.Insert(msg);
     }
     catch (TmmException te)
     {
         AddError(te.Message);
         RedirectToReferrer();
     }
 }
Exemplo n.º 4
0
        public void AuditReward(int tid)
        {
            DocService ds = Context.GetService <DocService>();
            TReqDoc    tr = ds.TReqDocBll.Get(tid);

            tr.Status = 2;
            ds.TReqDocBll.Update(tr);
            AddSuccess("操作成功");
            RedirectToReferrer();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns>返回:该条数据的主键Id</returns>
        public int Insert(TReqDoc obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "TReqDoc.Insert";

            return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>返回:ture 成功,false 失败</returns>
        public bool Update(TReqDoc obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "TReqDoc.Update";
            int    result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj);

            return(result > 0 ? true : false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 我要投稿
        /// </summary>
        public void AddContribute(int reqId)
        {
            PropertyBag["cur_page_addreward"] = true;
            PropertyBag["SessionId"]          = HttpContext.Session.SessionID;
            Service.Bll.Doc.TReqDocBLL tbll = new TMM.Service.Bll.Doc.TReqDocBLL();
            TReqDoc tdoc = tbll.Get(reqId);

            if (tdoc == null)
            {
                throw new Exception("该悬赏文档不存在");
            }
            PropertyBag["tdoc"] = tdoc;
        }
Exemplo n.º 8
0
        public void DeleteReward(int tid)
        {
            DocService ds = Context.GetService <DocService>();
            TReqDoc    tr = ds.TReqDocBll.Get(tid);

            if (tr.Status == 2)
            {
                throw new Exception("悬赏已经发布,不能删除");
            }
            ds.TReqDocBll.Delete(tr.TId);
            AddSuccess("操作成功");
            RedirectToReferrer();
        }
Exemplo n.º 9
0
        public void DeleteReward(int reqId)
        {
            UserService us   = Context.GetService <UserService>();
            U_UserInfo  u    = base.GetUser();
            TReqDoc     tdoc = us.TReqDocBll.Get(reqId);

            if (tdoc != null)
            {
                if (tdoc.UserId == u.UserId)
                {
                    //删除
                    us.TReqDocBll.Delete(reqId);
                    AddSuccess("操作成功");
                }
            }
            RedirectToReferrer();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 选稿
        /// </summary>
        public void SelectContribute(int first, int reqId)
        {
            PropertyBag["cur_page_addreward"] = true;
            int        rows  = 10;
            int        count = 0;
            DocService ds    = Context.GetService <DocService>();
            U_UserInfo u     = base.GetUser();
            TReqDoc    trDoc = ds.TReqDocBll.Get(reqId);

            if (trDoc.UserId != u.UserId)
            {
                throw new TmmException("操作错误,您不是该悬赏的所有者");
            }
            IList <TJoinDoc> list = ds.TJoinDocBll.GetListForXg(reqId, out count, first, rows);
            ListPage         lp   = new ListPage((IList)list, first, rows, count);

            PropertyBag["lp"] = lp;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 发布文档 from 投稿
        /// </summary>
        /// <param name="joinId"></param>
        public void PublishContribute(int joinId)
        {
            try
            {
                DocService  ds = Context.GetService <DocService>();
                UserService us = Context.GetService <UserService>();
                U_UserInfo  u  = base.GetUser();
                //投稿对象
                TJoinDoc tj = ds.TJoinDocBll.Get(joinId);
                if (tj.UserId != u.UserId)
                {
                    throw new TmmException("操作失败,您不是该投稿的所有者");
                }
                if (tj.IsWin)
                {
                    throw new TmmException("操作失败,该投稿已中标");
                }
                //发布文档
                DDocInfo doc = ds.DDocInfoBll.Get(tj.DocId);
                doc.IsAudit   = false;
                doc.IsTaskDoc = false;
                ds.DDocInfoBll.Update(doc);


                //删除投稿记录
                ds.TJoinDocBll.Delete(joinId);
                //更新悬赏的投稿数
                TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId);
                trDoc.DocCount -= 1;
                ds.TReqDocBll.Update(trDoc);

                Redirect("EditDoc.do?docId=" + doc.DocId.ToString());
                return;
            }
            catch (TmmException te)
            {
                AddError(te.Message);
            }
            RedirectToReferrer();
        }
Exemplo n.º 12
0
 public void DoAddReward([DataBind("TReqDoc")] TReqDoc tdoc)
 {
     try
     {
         if (string.IsNullOrEmpty(tdoc.Title))
         {
             throw new TmmException("标题不能为空");
         }
         if (string.IsNullOrEmpty(tdoc.Description))
         {
             throw new TmmException("备注不能为空");
         }
         UserService us = Context.GetService <UserService>();
         U_UserInfo  u  = base.GetUser();
         //余额判断
         decimal ye = us.MAccountBll.GetByUserId(u.UserId).Amount;
         if (ye >= tdoc.Price)
         {
             tdoc.UserId      = u.UserId;
             tdoc.Title       = tdoc.Title.FilterHtml();
             tdoc.Description = tdoc.Description.FilterHtml();
             tdoc.Status      = 1;
             tdoc.CreateTime  = DateTime.Now;
             us.TReqDocBll.Insert(tdoc);
             AddSuccess("发布成功,页面转至您的悬赏文档列表页面");
             Redirect("MyReward.do");
             return;
         }
         else
         {
             throw new TmmException("您的余额不足,请先充值");
         }
     }
     catch (TmmException ex) {
         AddError(ex.Message);
         Flash["model"] = tdoc;
     }
     RedirectToReferrer();
 }
Exemplo n.º 13
0
        public void Contribute(int first, int?tid, string likeTitle)
        {
            int        rows = 20;
            DocService ds   = Context.GetService <DocService>();

            Hashtable p = new Hashtable();

            if (tid.HasValue)
            {
                p.Add("TId", tid.Value);
                TReqDoc tr = ds.TReqDocBll.Get(tid.Value);
                PropertyBag["trdoc"] = tr;
            }
            if (!string.IsNullOrEmpty(likeTitle))
            {
                p.Add("LikeTitle", likeTitle);
            }
            int count             = ds.TJoinDocBll.GetCount(p);
            IList <TJoinDoc> list = ds.TJoinDocBll.GetList(p, null, first, rows);

            PropertyBag["lp"] = new ListPage((IList)list, first, rows, count);
        }
Exemplo n.º 14
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(TReqDoc obj)
 {
     return(dal.Update(obj));
 }
Exemplo n.º 15
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(TReqDoc obj)
 {
     return(dal.Insert(obj));
 }
Exemplo n.º 16
0
        /// <summary>
        /// 删除投稿
        /// </summary>
        /// <param name="joinIds"></param>
        public void DeleteContribute(int[] joinIds)
        {
            DocService        ds       = Context.GetService <DocService>();
            Queue <M_Message> queueMsg = new Queue <M_Message>();

            foreach (int joinId in joinIds)
            {
                TJoinDoc joinDoc = ds.TJoinDocBll.Get(joinId);
                if (joinDoc != null)
                {
                    //更新悬赏文档的投稿数量
                    TReqDoc reqDoc = ds.TReqDocBll.Get(joinDoc.TId);
                    if (reqDoc != null)
                    {
                        if (reqDoc.DocCount > 0)
                        {
                            reqDoc.DocCount -= 1;
                            ds.TReqDocBll.Update(reqDoc);
                        }
                    }
                    //删除原始文档
                    ds.DDocInfoBll.Delete(joinDoc.DocId);
                    //删除投稿记录
                    ds.TJoinDocBll.Delete(joinId);
                    //给投稿人发消息
                    M_Message msg = new M_Message()
                    {
                        Content           = string.Format("您上传的投稿文档【{0}】因违反相关规定,该文章已被管理员删除", joinDoc.Title),
                        CreateTime        = DateTime.Now,
                        IsRead            = false,
                        Mtype             = (int)Model.Enums.MessageType.Inform,
                        RecieveDeleteFlag = false,
                        RecieverId        = joinDoc.UserId,
                        SendDeleteFlag    = false,
                        SenderId          = Helper.ConfigHelper.AdminUserId,
                        Title             = "投稿文档删除通知"
                    };
                    queueMsg.Enqueue(msg);
                    //给悬赏人发消息
                    msg = new M_Message()
                    {
                        Content           = string.Format("您收到的投稿文档【{0}】因违反相关规定,该文章已被管理员删除", joinDoc.Title),
                        CreateTime        = DateTime.Now,
                        IsRead            = false,
                        Mtype             = (int)Model.Enums.MessageType.Inform,
                        RecieveDeleteFlag = false,
                        RecieverId        = reqDoc.UserId,
                        SendDeleteFlag    = false,
                        SenderId          = Helper.ConfigHelper.AdminUserId,
                        Title             = "投稿文档删除通知"
                    };
                    queueMsg.Enqueue(msg);
                }
            }
            //异步发送消息
            AsynMessage am = new AsynMessage(queueMsg);

            am.Send();

            AddSuccess("操作成功");
            RedirectToReferrer();
        }