Esempio n. 1
0
        public virtual async Task <JsonResult> SendVerifyCode(LoginViewModel loginModel)
        {
            var v = await SettingManager.GetSettingValueAsync(AppSettingNames.Rule.VerifyLogin);

            if (v == "true" && loginModel.UsernameOrEmailAddress != "admin")
            {
                var worker = _workManager.GetWorkerByCn(loginModel.UsernameOrEmailAddress);
                if (worker == null)
                {
                    throw new UserFriendlyException("找不到此员工");
                }
                string appName = _workManager.GetWorkerPostAppName(worker);
                if (string.IsNullOrEmpty(appName))
                {
                    throw new UserFriendlyException("此员工无对应的微信应用");
                }

                string code = ClcUtils.GetRandomNumber(ClcConsts.VerifyCodeLength);
                WeixinUtils.SendMessage(appName, worker.Cn, string.Format("你的登录验证码为:{0}", code));
                HttpContext.Session.SetString("WorkerCn", loginModel.UsernameOrEmailAddress);
                HttpContext.Session.SetString("VerifyCode", code);
                return(Json(new AjaxResponse()
                {
                    Success = true
                }));
            }
            return(Json(new AjaxResponse {
                Success = false
            }));
        }
Esempio n. 2
0
        public JsonResult AskOpenTemp(string style, int depotId, string routeName, int affairId, int doorId, string askWorkers)
        {
            var captain = WorkManager.GetCaptain(depotId);

            WorkManager.InsertTempAskDoorRecord(style, depotId, routeName, affairId, doorId, askWorkers, captain.Cn);

            WeixinUtils.SendMessage("App03", captain.Cn, "请审批临时存取开门请求");
            return(Json(new { Message = "已通知队长处理" }));
        }
Esempio n. 3
0
        public JsonResult NotifyAskWorkers(int doorRecordId)
        {
            if (doorRecordId == 0)
            {
                return(Json(new { Message = "直接开门方式" }));
            }

            var ret = _doorRecordAppService.GetNotifyInfo(doorRecordId);

            WeixinUtils.SendMessage("App01", ret.Item1, $"你申请的{ret.Item2}已打开");
            return(Json(new { Message = "已通知" }));
        }
Esempio n. 4
0
        public async Task <JsonResult> ProcessIssueEmergDoor(int issueId, int doorId, string content, int leaderId, string leader)
        {
            try
            {
                await _issueAppService.ProcessIssue(issueId, $"发送给 {leader} 审批");

                await _doorRecordAppService.ProcessIssueEmergDoor(issueId, doorId, content, leaderId);

                var toUser = leader.Split()[0];
                var wp     = WorkManager.GetWorkplace(doorId);
                var depot  = WorkManager.GetDepot(wp.DepotId);
                var msg    = string.Format("有来自{0}大队的应急开门({1})申请", depot.Name, wp.Name);
                WeixinUtils.SendMessage("App03", toUser, msg);

                return(Json(new { result = "success", content = $"完成处理并发送通知给{leader}" }));
            }
            catch (Exception ex)
            {
                throw new UserFriendlyException("操作失败", ex.Message);
            }
        }