Example #1
0
        public JsonResult SubmitEvent(ITSM_Event ent)
        {
            if (Session["SEventFlag"] != null && ((DateTime)Session["SEventFlag"]).AddMinutes(5) > DateTime.Now)
            {
                return Json(ResultMsg.Failure("抱歉,您提交的太快,请五分钟后再提交!"));
            }
            CertificateDto cer = CurrentUser();
            ent.ReqMan = cer.UserName;
            ent.CreateUser = "******";
            ent.ProcessStatus = 0;//待派工
            ent.TntId = Guid.Parse(cer.GroupId);
            ent.Code = "";

            int temp = 0;
            DateTime timeNow = DateTime.Now.Date;
            IEnumerable<ITSM_Event> env1 = WMFactory.ITSMEvent.FindByPage(0, 1, out temp, o => o.OrderByDescending(x => x.CreateTime), f => f.CreateTime >= timeNow && f.TntId == ent.TntId);
            if (env1.Count() == 0)
            {
                ent.Code = DateTime.Now.ToString("yyyyMMdd001");
            }
            else
            {
                string strMaxCode = env1.FirstOrDefault().Code;
                ent.Code = DateTime.Now.ToString("yyyyMMdd") + (Convert.ToInt64(strMaxCode.Substring(8)) + 1).ToString("000");
            }

            //之前还有多少人排队等待
            int waiters = WMFactory.ITSMEvent.GetCount(f => f.ProcessStatus < 4 && f.TntId == ent.TntId && f.ReqIncident==ent.ReqIncident.Trim());

            if (WMFactory.ITSMEvent.Insert(ent))
            {
                Session["SEventFlag"] = DateTime.Now;
                WMFactory.ITSMEvent.Notice(0, ent);
                return Json(ResultMsg.Success("事件提交成功,您之前还有 “" + waiters.ToString() + "人” 在排队。"));
            }
            else
                return Json(ResultMsg.Failure("事件提交失败,请重试!"));
        }
Example #2
0
 public JsonResult Delete(ITSM_Event _t)
 {
     if (WMFactory.ITSMEvent.Delete(s => s.Id == _t.Id))
     {
         //删除事件日志
         WMFactory.ITSMEventLog.Delete(s => s.Eid == _t.Id);
         return Json(ResultMsg.Success("删除成功!"));
     }
     else
         return Json(ResultMsg.Failure("删除失败,请您重试!"));
 }
Example #3
0
 public JsonResult Post(ITSM_Event _t)
 {
     int temp = 0;
     DateTime timeNow = DateTime.Now.Date;
     Guid tntId = Guid.Parse(AuthToken.CurrentUser.GroupId);
     IEnumerable<ITSM_Event> env1 = WMFactory.ITSMEvent.FindByPage(0, 1, out temp, o => o.OrderByDescending(x => x.CreateTime), f => f.CreateTime >= timeNow && f.TntId == tntId);
     if (env1.Count() == 0)
     {
         _t.Code = DateTime.Now.ToString("yyyyMMdd001");
     }
     else
     {
         string strMaxCode = env1.FirstOrDefault().Code;
         _t.Code = DateTime.Now.ToString("yyyyMMdd") + (Convert.ToInt64(strMaxCode.Substring(8)) + 1).ToString("000");
     }
     //新增的时候,需要重置时间,否则导致加载两条
     Session["lastGetTime"] = DateTime.Now.AddMilliseconds(200);
     if (WMFactory.ITSMEvent.Insert(_t))
         return Json(ResultMsg.Success("新增成功!"));
     else
         return Json(ResultMsg.Failure("新增失败,请您重试!"));
 }
Example #4
0
 public JsonResult Put(ITSM_Event _t)
 {
     IITSMEventService service = WMFactory.ITSMEvent;
     ITSM_Event entity = service.GetById(_t.Id.ToString());
     entity = AutoMapper<ITSM_Event, ITSM_Event>.Convert(_t, entity);
     if (service.Update(entity))
         return Json(ResultMsg.Success("更新成功!"));
     else
         return Json(ResultMsg.Failure("更新失败,请您重试!"));
 }
Example #5
0
        /// <summary>
        /// 派工完成,微信通知用户
        /// </summary>
        private void SendWxSvrNotice(ITSM_Event evt)
        {
            //获取工程师的openId
            Guid sid = Guid.Parse("5E43EF3D-451F-49FC-86DA-8EDC32D08398");
            string egr = evt.Engineer;
            IEnumerable<WX_LK_FansC3AM> fans = WMFactory.WXLKFansC3AM.FindByConditions(null, f => f.AccountId == sid && f.UserName == egr);
            if (fans.Count() != 1)
            {
                log.Error("找不到工程师的OPENID:" + egr);
                return;
            }
            WxServiceNotice notice = new WxServiceNotice();
            notice.touser = fans.First().OpenId;
            notice.template_id = "Ikb2gb1JH5p9ZTTycb8i0RghIMlRqiyb48Be7EwZCK0";
            notice.url = "http://it.hwafashion.com/IT/SM/EventReport?sid=5E43EF3D-451F-49FC-86DA-8EDC32D08398";
            notice.topcolor = "#ff6666";
            notice.data = "{\"first\":{\"value\":\"尊敬的" + egr + ",事件经理分配了新的ITSM事件,请及时在ITDC公众账号中处理。\\n\\n\",\"color\":\"#ff6666\"},"
                          + "\"keynote1\":{\"value\":\"" + evt.Code + "\",\"color\":\"#ff6666\"},"
                          + "\"keynote2\":{\"value\":\"" + evt.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") + "\",\"color\":\"#ff6666\"},"
                          + "\"remark\":{\"value\":\"事件描述:" + evt.EventDesc.Replace("'", "").Replace("\"", "").Replace("\r", "").Replace("\n", "")
                                                + "\\n员工姓名:" + evt.ReqMan
                                                + "\\n所在部门:" + evt.ReqCom + "," + evt.ReqDept
                                                + "\\n办公地点:" + evt.ReqIncident + "\",\"color\":\"#333333\"}}";
            ElegantWM.WeiXin.Common.SendServiceNotice("5E43EF3D-451F-49FC-86DA-8EDC32D08398", notice);

        }
Example #6
0
        public JsonResult CompleteEvent(ITSM_Event evt)
        {
            CertificateDto cer = CurrentUser();
            string curUser = cer.UserName;
            Guid tntId = Guid.Parse(cer.GroupId);
            ITSM_Event ent = WMFactory.ITSMEvent.GetById(evt.Id.ToString());

            if (ent.Engineer != curUser)
            {
                return Json(ResultMsg.Failure("无法处理非己事件"));
            }
            if (ent.ProcessStatus != 3)
            {
                return Json(ResultMsg.Failure("非处理状态,不能完成!"));
            }
            ent.EventApp = evt.EventApp;
            ent.EventEquipment = evt.EventEquipment;
            ent.EventSolution = evt.EventSolution;

            ITSM_EventLog entlog = new ITSM_EventLog();
            entlog.Eid = ent.Id;
            entlog.CreateUser = curUser;
            entlog.Reason = "处理完成";
            entlog.TntId = tntId;
            WMFactory.ITSMEventLog.Insert(entlog);
            ent.ProcessStatus = 4;

            if (WMFactory.ITSMEvent.Update(ent))
            {
                if(!SendWxSvrNoticeWhenOver(ent))//如果执行失败了还是要发送小翅膀
                    WMFactory.ITSMEvent.Notice(4, ent);
                return Json(ResultMsg.Success("操作成功!"));
            }
            else
                return Json(ResultMsg.Failure("操作失败!"));
        }
Example #7
0
 private bool SendWxSvrNoticeWhenOver(ITSM_Event evt)
 {
     try
     {
         //获取申请人的openId
         Guid sid = Guid.Parse("5E43EF3D-451F-49FC-86DA-8EDC32D08398");
         string reqMan = evt.ReqMan;
         IEnumerable<WX_LK_FansC3AM> fans = WMFactory.WXLKFansC3AM.FindByConditions(null, f => f.AccountId == sid && f.UserName == reqMan);
         if (fans.Count() != 1)
         {
             log.Error("找不到事件提出人的OPENID:" + evt.ReqMan);
             return false;
         }
         WxServiceNotice notice = new WxServiceNotice();
         notice.touser = fans.First().OpenId;
         notice.template_id = "Ikb2gb1JH5p9ZTTycb8i0RghIMlRqiyb48Be7EwZCK0";
         notice.url = "http://it.hwafashion.com/IT/SM/Survey/" + evt.Id.ToString() + "?sid=5E43EF3D-451F-49FC-86DA-8EDC32D08398&oid=" + notice.touser;
         notice.topcolor = "#ff6666";
         notice.data = "{\"first\":{\"value\":\"尊敬的" + reqMan + ",您提交的事件申请,工程师“" + evt.Engineer + "”已经为您处理完成,请对我们的服务进行评价,谢谢您的支持!\\n\\n\",\"color\":\"#ff6666\"},"
                       + "\"keynote1\":{\"value\":\"" + evt.Code + "\",\"color\":\"#ff6666\"},"
                       + "\"keynote2\":{\"value\":\"" + evt.CreateTime.ToString("yyyy-MM-dd HH:mm:ss") + "\",\"color\":\"#666666\"},"
                       + "\"remark\":{\"value\":\"事件描述:" + evt.EventDesc.Replace("'", "").Replace("\"", "").Replace("\r", "").Replace("\n", "")
                                             + "\\n所在部门:" + evt.ReqCom + "," + evt.ReqDept
                                             + "\\n办公地点:" + evt.ReqIncident
                                             + "\\n\\n解决方案:" + evt.EventSolution.Replace("'", "").Replace("\"", "").Replace("\r", "").Replace("\n", "")
                                             + "\",\"color\":\"#333333\"}}";
         return ElegantWM.WeiXin.Common.SendServiceNotice("5E43EF3D-451F-49FC-86DA-8EDC32D08398", notice);
     }
     catch (Exception error)
     {
         log.Error(error.Message);
         return false;
     }
 }
Example #8
0
 public JsonResult SubmitEval(ITSM_Event ent)
 {
     CertificateDto cer = CurrentUser();
     string curUser = cer.UserName;
     IITSMEventService srv = WMFactory.ITSMEvent;
     ITSM_Event orgEvent = srv.GetById(ent.Id.ToString());
     if (orgEvent.ReqMan != curUser)
     {
         return Json(ResultMsg.Failure("只能评价自己的事件"));
     }
     if (orgEvent.ProcessStatus != 4)
     {
         return Json(ResultMsg.Failure("失败,事件非待评价状态!"));
     }
     orgEvent.ElvTime = ent.ElvTime;
     orgEvent.ElvAtude = ent.ElvAtude;
     orgEvent.ElvRst = ent.ElvRst;
     orgEvent.ElvDesc = ent.ElvDesc;
     orgEvent.ProcessStatus = 5;
     orgEvent.ModifyUser = curUser;
     //插入日志
     ITSM_EventLog entlog = new ITSM_EventLog();
     entlog.Reason = "完成评价";
     entlog.CreateUser = curUser;
     entlog.Eid = ent.Id;
     WMFactory.ITSMEventLog.Insert(entlog);
     if (srv.Update(orgEvent))
     {
         WMFactory.ITSMEvent.Notice(5, orgEvent);
         return Json(ResultMsg.Success("评价成功,感谢支持"));
     }
     else
         return Json(ResultMsg.Failure("评价失败,请重试"));
 }