Exemplo n.º 1
0
        public ActionResult <Result> PublishAuth([FromBody] dynamic ticket)
        {
            string user_id = Token.GetUserId(HttpContext.Request.Headers["Authorization"].ToString().Substring(7));
            TUser  user    = userServer.Retrieve(new TUser()
            {
                UserId = user_id
            });

            JObject data = JObject.Parse(ticket.ToString());
            //解析数据
            TTicket tkt = new TTicket
            {
                UserId = user.UserId,
                TypeId = int.Parse(data["TypeId"].ToString())
            };

            TTicketChat tktc = new TTicketChat
            {
                Content = data["Content"].ToString(),
                Annex   = data["Annex"]?.ToString(),
                UserId  = user.UserId
            };

            if (tkt.TypeId != 0 && tkt.TypeId != 400002 && (tkt.TypeId < 600000 || tkt.TypeId >= 700000))
            {
                throw new ResultException("工单类型错误");
            }

            //发布
            ticketServer.Publish(tkt, tktc);

            return(new Result(200, "成功"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 提交新工单
        /// </summary>
        /// <param name="t">工单信息</param>
        /// <param name="tc">内容信息</param>
        void ITicket.Publish(TTicket t, TTicketChat tc)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                m_iTicket.Create(t);

                m_iTicket.AddReply(t, new TTicketChat
                {
                    TicketId = t.TicketId,
                    Content  = tc.Content,
                    UserId   = tc.UserId,
                    Annex    = tc.Annex
                });

                scope.Complete();
            }
        }
Exemplo n.º 3
0
        public ActionResult <Result> Publish([FromBody] dynamic ticket)
        {
            JObject data = JObject.Parse(ticket.ToString());

            //解析数据
            TTicket tkt = new TTicket
            {
                Email  = data["Email"].ToString(),
                TypeId = int.Parse(data["TypeId"].ToString())
            };

            TTicketChat tktc = new TTicketChat
            {
                Content = data["Content"].ToString(),
                Annex   = data["Annex"]?.ToString()
            };

            string reg_email = @"^\w+(?<=[^ ])@\w+\.\w+$";

            if (!Regex.IsMatch(tkt.Email, reg_email))
            {
                throw new ResultException("邮箱格式错误");
            }

            if (tkt.TypeId != 0 && tkt.TypeId != 400002 && (tkt.TypeId < 600000 || tkt.TypeId >= 700000))
            {
                throw new ResultException("工单类型错误");
            }

            //发布
            ticketServer.Publish(tkt, tktc);

            // ticketServer.Create(new TTicket()
            // {
            //     TypeId = ticket.TypeId == 0 ? 400002 : ticket.TypeId,
            //     Email = ticket.Email,
            //     Content = ticket.Content,
            //     Annex = ticket.Annex
            // });
            return(new Result(200, "成功"));
        }
Exemplo n.º 4
0
        public ActionResult <Result> Reply([FromBody] TTicketChat tc)
        {
            string user_id = Token.GetUserId(HttpContext.Request.Headers["Authorization"].ToString().Substring(7));
            TUser  user    = userServer.Retrieve(new TUser()
            {
                UserId = user_id
            });

            TTicket t = ticketServer.Retrieve(new TTicket {
                TicketId = tc.TicketId
            });

            if (t.UserId != user.UserId && user.Super == 0)
            {
                throw new ResultException("无权操作");
            }

            if (t == null)
            {
                throw new ResultException("工单不存在");
            }

            if (tc.Content == null || tc.Content == "")
            {
                throw new ResultException("工单内容为空");
            }

            if (t.UserId != user.UserId)
            {
                t.StatusId = 700002;//等待回复
            }
            ticketServer.AddReply(t, new TTicketChat
            {
                TicketId = t.TicketId,
                Content  = tc.Content,
                Annex    = tc.Annex,
                UserId   = user.UserId
            });

            return(new Result(200, "成功"));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 为工单添加回复
        /// </summary>
        /// <param name="t">工单信息</param>
        /// <param name="tc">回复信息</param>
        void ITicket.AddReply(TTicket t, TTicketChat tc)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Random rand = new Random((int)Tools.Ticks());
                string id   = Tools.Ticks() + "" + rand.Next(1000, 10000);
                tc.TicketChatId = id;

                tc.CreateTime = DateTime.Now;
                m_db.TTicketChat.Add(tc);
                m_db.SaveChanges();

                m_redis.HashSet("DB:T_TicketChat", tc.TicketChatId, t);

                m_iTicket.Update(new TTicket
                {
                    TicketId   = t.TicketId,
                    ActiveTime = t.CreateTime,
                    StatusId   = t.StatusId
                });

                scope.Complete();
            }
        }