Beispiel #1
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();
 }
Beispiel #2
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");
        }
Beispiel #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();
     }
 }
Beispiel #4
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <param name="obj">对象</param>
        /// <returns>返回:该条数据的主键Id</returns>
        public int Insert(TJoinDoc obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            String stmtId = "TJoinDoc.Insert";

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

            return(result > 0 ? true : false);
        }
Beispiel #6
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();
        }
Beispiel #7
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(TJoinDoc obj)
 {
     return(dal.Update(obj));
 }
Beispiel #8
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(TJoinDoc obj)
 {
     return(dal.Insert(obj));
 }
Beispiel #9
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();
        }