public WxIdentifyDto Login(string workerCn, string password, string deviceId) { WxIdentifyDto dto = new WxIdentifyDto(); var worker = WorkManager.GetWorkerByCn(workerCn); if (worker == null || password != worker.Password) { dto.ErrorMessage = "用户名或密码错误"; return(dto); } // judge right routeRole and subworker var ret = FindRoute(worker, dto); if (ret.Item1 == null) { dto.ErrorMessage = "找不到合适的线路"; return(dto); } if (ret.Item2 == null) { dto.ErrorMessage = "需要辅助交接员"; } dto.AllowDoIdentify = AllowDoIdentify(dto.DepotId); return(dto); }
public ActionResult SelectOutlet(string outletCn) { var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret); ViewBag.appId = _corpId; ViewBag.noncestr = JSSDKHelper.GetNoncestr(); ViewBag.timestamp = JSSDKHelper.GetTimestamp(); ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri()); WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify"); if (string.IsNullOrWhiteSpace(outletCn)) { ModelState.AddModelError("", "需要输入网点编号"); return(View("Identify", dto)); } var outlet = _outletCache.GetList().FindLast(x => x.Cn == outletCn); if (outlet != null) { SelectOutlet(outlet.Id, dto); return(View("Identify", dto)); } else { ModelState.AddModelError("", "此编号没有对应的网点"); return(View("Identify", dto)); } }
public WxIdentifyDto GetLookupInfo(int taskId, int routeId) { var dto = new WxIdentifyDto(); var ret = _routeAppService.GetRouteForLookup(routeId); var main = WorkManager.GetWorker(ret.Item1); var sub = WorkManager.GetWorker(ret.Item2); dto.Workers.Add(new WeixinWorkerDto() { Cn = main.Cn, Name = main.Name, AdditiveInfo = main.AdditiveInfo, Photo = main.Photo == null ? null : Convert.ToBase64String(main.Photo) }); dto.Workers.Add(new WeixinWorkerDto() { Cn = sub.Cn, Name = sub.Name, AdditiveInfo = sub.AdditiveInfo, Photo = sub.Photo == null ? null : Convert.ToBase64String(sub.Photo) }); var v = _vehicleCache[ret.Item3]; dto.Vehicle = new WeixinVehicleDto() { Cn = v.Cn, License = v.License, Photo = v.Photo == null ? null : Convert.ToBase64String(v.Photo) }; return(dto); }
public ActionResult Identify(string code) { if (string.IsNullOrEmpty(code)) { return(Redirect(OAuth2Api.GetCode(_corpId, AbsoluteUri(), "STATE", _agentId))); } WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify"); if (dto == null) { LoginViewModel vm = new LoginViewModel() { ReturnUrl = AbsoluteUri() }; try { var accessToken = AccessTokenContainer.GetToken(_corpId, _secret); GetUserInfoResult userInfo = OAuth2Api.GetUserId(accessToken, code); vm.WorkerCn = userInfo.UserId; vm.DeviceId = userInfo.DeviceId; } catch { Logger.Error("微信授权错误"); } return(View("login", vm)); } else { return(View("TaskList", dto)); } }
public ActionResult VerifyOutlet(int taskId, string password) { var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret); ViewBag.appId = _corpId; ViewBag.noncestr = JSSDKHelper.GetNoncestr(); ViewBag.timestamp = JSSDKHelper.GetTimestamp(); ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri()); WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify"); if (dto != null && !string.IsNullOrEmpty(password) && dto.OutletPassword == password) { if (taskId != 0) { _weixinAppService.SetIdentifyTime(taskId); _context.Clients.All.SendAsync("getMessage", "keypoint " + string.Format("{0},{1}", dto.OutletName, dto.DepotId)); } else { string issuer = null; foreach (var w in dto.Workers) { issuer += $"{w.Cn} {w.Name},"; } _weixinAppService.SetIdentifyEvent(dto.RouteId, $"{dto.OutletCn} {dto.OutletName}", issuer); } return(View("Information2", dto)); } else { ModelState.AddModelError("", "网点密码不符,请重新输入"); return(View("Identify", dto)); } }
private void SelectOutlet(int outletId, WxIdentifyDto dto) { var outlet = _outletCache[outletId]; dto.OutletCn = outlet.Cn; dto.OutletName = outlet.Name; dto.OutletPassword = outlet.Password; dto.OutletCipertext = outlet.Ciphertext; HttpContext.Session.SetObjectAsJson("WxIdentify", dto); }
public ActionResult Login(LoginViewModel vm) { WxIdentifyDto dto = _weixinAppService.Login(vm.WorkerCn, vm.Password, vm.DeviceId); if (!string.IsNullOrEmpty(dto.ErrorMessage)) { ModelState.AddModelError("", dto.ErrorMessage); return(View(vm)); } HttpContext.Session.SetObjectAsJson("WxIdentify", dto); return(Redirect(vm.ReturnUrl)); }
public ActionResult SelectTask(int taskId, int outletId) { var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret); ViewBag.appId = _corpId; ViewBag.noncestr = JSSDKHelper.GetNoncestr(); ViewBag.timestamp = JSSDKHelper.GetTimestamp(); ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri()); WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify"); dto.TaskId = taskId; SelectOutlet(outletId, dto); return(View("Identify", dto)); }
private (Route, Worker) FindRoute(Worker main, WxIdentifyDto dto) { var ret = _routeAppService.FindRouteForIdentify(main.DepotId, main.Id); if (ret.Item1 == null) { return(null, null); } if (ret.Item2 == 0) { return(ret.Item1, null); } var sub = WorkManager.GetWorker(ret.Item2); dto.Workers.Add(new WeixinWorkerDto() { Cn = main.Cn, Name = main.Name, AdditiveInfo = main.AdditiveInfo, Photo = main.Photo == null ? null : Convert.ToBase64String(main.Photo) }); dto.Workers.Add(new WeixinWorkerDto() { Cn = sub.Cn, Name = sub.Name, AdditiveInfo = sub.AdditiveInfo, Photo = sub.Photo == null ? null : Convert.ToBase64String(sub.Photo) }); var v = _vehicleCache[ret.Item1.GetFactVehicleId()]; dto.Vehicle = new WeixinVehicleDto() { Cn = v.Cn, License = v.License, Photo = v.Photo == null ? null : Convert.ToBase64String(v.Photo) }; dto.DepotId = ret.Item1.DepotId; dto.RouteId = ret.Item1.Id; dto.RouteName = ret.Item1.RouteName; foreach (RouteTask task in ret.Item1.Tasks) { var outlet = _outletCache[task.OutletId]; var type = _taskTypeCache[task.TaskTypeId]; string tm = task.IdentifyTime.HasValue ? task.IdentifyTime.Value.ToString("HH:mm") : ""; dto.Tasks.Add(new WeixinTaskDto( task.Id, task.ArriveTime, type.Name, outlet.Id, outlet.Cn, outlet.Name, tm, task.Remark, task.RouteId, task.Rated, task.OutletIdentifyInfo)); } return(ret.Item1, sub); }
public ActionResult DoIdentify() { var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret); ViewBag.appId = _corpId; ViewBag.noncestr = JSSDKHelper.GetNoncestr(); ViewBag.timestamp = JSSDKHelper.GetTimestamp(); ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri()); WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify"); // clear something dto.TaskId = 0; dto.OutletCn = dto.OutletName = null; HttpContext.Session.SetObjectAsJson("WxIdentify", dto); return(View("Identify", dto)); }
public ActionResult LookupTask(int taskId, int routeId) { WxIdentifyDto dto = _wxAppService.GetLookupInfo(taskId, routeId); return(View(dto)); }