public IActionResult Release(string id) { if (id == null) { return(View()); } try { ViewBag.Title = "下载页面"; int assignmentId = int.Parse(AESEncode.Decrypt(WebUtility.HtmlDecode(id))); using (var session = _documentStore.LightweightSession()) { Assignment model = session.Query <Assignment>().SingleOrDefault(x => x.id == assignmentId); FanyiNetwork.Models.User cs = session.Query <User>().SingleOrDefault(x => x.id == model.cs); ViewData["wechat"] = cs.wechat; ViewData["wechat_img"] = cs.barcode; ViewData["qq"] = cs.qq; return(View(model)); } } catch { return(View()); } }
public IActionResult SMS([FromBody] Assignment model) { if (!User.HasClaim(x => x.Type == ClaimTypes.Role && (x.Value == "客服主管" || x.Value == "客服部" || x.Value == "经理办"))) { return(BadRequest("你没有权限执行该操作!")); } if (model == null) { return(BadRequest()); } using (var session = _documentStore.LightweightSession()) { DateTime dueTime = (DateTime)model.finishDue; TimeSpan ts = dueTime - DateTime.Now; string remainTime; if (ts.TotalHours >= 1) { remainTime = ts.Days + "天," + ts.Hours + "小时," + ts.Minutes + "分钟"; } else { remainTime = "不足一小时"; } FanyiNetwork.Models.User editor = session.Query <User>().FirstOrDefault(x => x.id == model.editor); if (editor != null) { SMSNotification.SendChangeOrderSMS(model.no, remainTime, editor.mobile); } return(Ok()); } }
public IActionResult Assign([FromBody] Assignment model) { if (!User.HasClaim(x => x.Type == ClaimTypes.Role && (x.Value == "主编" || x.Value == "客服主管" || x.Value == "经理办"))) { return(BadRequest("你没有权限执行该操作!")); } if (model == null) { return(BadRequest()); } using (var session = _documentStore.LightweightSession()) { model.status = "待交稿"; model.chiefeditor = int.Parse(User.FindFirst(ClaimTypes.Sid).Value); model.assignTime = DateTime.Now; model.isParttimeConfirm = false; session.Store <Assignment>(model); Notification notification = new Notification(); notification.userid = model.editor; notification.assignmentid = model.id; notification.message = "单号已分配至你,请按时提交稿件!"; notification.time = DateTime.Now; session.Store <Notification>(notification); Flow flow = new Flow(); flow.AssignmentID = model.id; flow.Operator = User.Identity.Name; flow.Operation = "成功分配,标记单号为待交稿."; flow.Time = DateTime.Now; session.Store <Flow>(flow); session.SaveChanges(); DateTime dueTime = (DateTime)model.finishDue; TimeSpan ts = dueTime - DateTime.Now; string remainTime; if (ts.TotalHours >= 1) { remainTime = ts.Days + "天," + ts.Hours + "小时," + ts.Minutes + "分钟"; } else { remainTime = "不足一小时"; } FanyiNetwork.Models.User editor = session.Query <User>().FirstOrDefault(x => x.id == model.editor); if (editor != null) { SMSNotification.SendAssignOrderSMS(model.no, remainTime, editor.mobile); } return(Ok()); } }
// PUT api/values/5 public IActionResult Put([FromBody] FanyiNetwork.Models.User model) { if (!User.HasClaim(x => x.Type == ClaimTypes.Role && (x.Value == "经理办" || x.Value == "人事部"))) { return(BadRequest("你没有权限执行该操作!")); } if (model == null) { return(BadRequest()); } using (var session = _documentStore.LightweightSession()) { session.Store <FanyiNetwork.Models.User>(model); session.SaveChanges(); } return(Ok()); }
public IActionResult Get(int id) { if (id == 0) { return(BadRequest()); } FanyiNetwork.Models.User model = new FanyiNetwork.Models.User(); using (var session = _documentStore.LightweightSession()) { model = session.Query <FanyiNetwork.Models.User>().SingleOrDefault(x => x.id == id); } if (model == null) { return(BadRequest()); } return(new ObjectResult(model)); }