示例#1
0
        public void DoEditDoc([DataBind("DDocInfo")] DDocInfo doc, HttpPostedFile file)
        {
            try
            {
                //DocService us = Context.GetService<DocService>();
                UserService us     = Context.GetService <UserService>();
                DDocInfo    oldDoc = us.DocInfoBll.Get(doc.DocId);
                if (oldDoc != null)
                {
                    //更新缩略图
                    if (file != null && !string.IsNullOrEmpty(file.FileName))
                    {
                        string newThumbUrl = SaveNewDocThumbnail(file, oldDoc.ThumbnailUrl);
                        if (!string.IsNullOrEmpty(newThumbUrl))
                        {
                            oldDoc.ThumbnailUrl = newThumbUrl;
                        }
                    }
                    else
                    {
                        oldDoc.ThumbnailUrl = doc.ThumbnailUrl;
                    }

                    oldDoc.Title       = doc.Title;
                    oldDoc.Description = doc.Description;
                    oldDoc.Tags        = doc.Tags;
                    oldDoc.CateId      = doc.CateId;
                    oldDoc.Price       = doc.Price;
                    oldDoc.FlashUrl    = doc.FlashUrl;
                    us.DocInfoBll.Update(oldDoc);
                    //更新标签表
                    if (!string.IsNullOrEmpty(oldDoc.Tags) && oldDoc.Tags != doc.Tags)
                    {
                        string[] tags = doc.Tags.Split(' ');
                        us.DTagBll.UpdateFromDoc(tags, oldDoc.DocId);
                    }

                    //异步通知用户文档被管理员更新
                    M_Message msg = new M_Message()
                    {
                        Content    = string.Format("您上传的文档“{0}”被管理员更新", doc.Title),
                        CreateTime = DateTime.Now,
                        IsRead     = false,
                        Mtype      = (int)Model.Enums.MessageType.Inform,
                        RecieverId = oldDoc.UserId,
                        SenderId   = Helper.ConfigHelper.AdminUserId,
                        Title      = string.Format("您上传的文档“{0}”被管理员更新", doc.Title)
                    };
                    Common.AsynMessage am = new AsynMessage(msg);
                    am.Send();

                    Redirect("/admin/doc/index.do");
                    return;
                }
                throw new Exception("查询文档为空");
            }
            catch (Exception ex)
            {
                Utils.Log4Net.Error(ex);
                RedirectToReferrer();
            }
        }
示例#2
0
        public void DoManualOperate(int userId, int accountWay, decimal amount, string remark)
        {
            try
            {
                UserService us = Context.GetService <UserService>();
                if (amount == 0)
                {
                    throw new TmmException("金额不能为0");
                }
                if (accountWay == 0)
                {
                    throw new TmmException("请选择类型");
                }
                if (accountWay == (int)AmountWay.MIn)
                {
                    if (amount <= 0)
                    {
                        throw new TmmException("增加金额不能小于0");
                    }
                }
                if (accountWay == (int)AmountWay.AOut)
                {
                    if (amount >= 0)
                    {
                        throw new TmmException("扣除金额不能大于0");
                    }
                }
                if (string.IsNullOrEmpty(remark))
                {
                    throw new TmmException("备注不能为空");
                }
                MAccount acc = us.MAccountBll.GetByUserId(userId);
                //写账户日志
                AccountLog log = new AccountLog()
                {
                    AccountWay  = accountWay,
                    AdminRemark = remark,
                    Amount      = amount,
                    CreateTime  = DateTime.Now,
                    Ip          = Utils.TmmUtils.IPAddress(),
                    UserId      = userId
                };
                us.AccountLogBll.Insert(log);

                acc.Amount += amount;
                us.MAccountBll.Update(acc);
                //发消息-异步
                M_Message msg = new M_Message()
                {
                    Content = string.Format("【帐户通知】,您的账户由土木迷管理员{0}¥{1:F2}",
                                            amount > 0 ? "充入" : "扣除", amount),
                    CreateTime = DateTime.Now,
                    IsRead     = false,
                    Mtype      = (int)Model.Enums.MessageType.Inform,
                    RecieverId = userId,
                    SenderId   = Core.Helper.ConfigHelper.AdminUserId,
                    Title      = "帐户通知"
                };
                Queue <M_Message> queueMsg = new Queue <M_Message>();
                queueMsg.Enqueue(msg);
                Common.AsynMessage am = new AsynMessage(queueMsg);
                am.Send();

                base.SuccessInfo();
                Redirect("account.do");
                return;
            }
            catch (TmmException te)
            {
                AddError(te.Message);
                Flash["accountWay"] = accountWay;
                Flash["amount"]     = amount;
                Flash["remark"]     = remark;
            }
            RedirectToReferrer();
        }
示例#3
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();
        }