Пример #1
0
        public static List <Model.TestInfoModel> AthTestUtil(DataSet ds)
        {
            List <Model.TestInfoModel> testInfoModelList = new List <Model.TestInfoModel>();

            BLL.TB_TestInfo    testInfoBLL    = new BLL.TB_TestInfo();
            BLL.TB_AthleteInfo athleteInfoBLL = new BLL.TB_AthleteInfo();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow             dr            = ds.Tables[0].Rows[i];
                Model.TestInfoModel testInfoModel = new Model.TestInfoModel();
                testInfoModel.Index = i + 1;

                testInfoBLL.GetModelFromDataRow(dr, testInfoModel);
                athleteInfoBLL.GetAthleteInfoFromDataRow(dr, testInfoModel);

                testInfoModel.DGravitycomp = DictCache.GetDictValue(DictCache.Gravitycomp, testInfoModel.Gravitycomp);
                testInfoModel.DInsuredSide = DictCache.GetDictValue(DictCache.InsuredSide, testInfoModel.InsuredSide);
                testInfoModel.DJoint       = DictCache.GetDictValue(DictCache.Joint, testInfoModel.Joint);
                testInfoModel.DJointSide   = DictCache.GetDictValue(DictCache.JointSide, testInfoModel.Joint_Side);
                testInfoModel.DTestMode    = DictCache.GetDictValue(DictCache.TestMode, testInfoModel.Test_Mode);

                testInfoModel.DPlane = DictCache.GetDict(testInfoModel.Joint, testInfoModel.Plane, testInfoModel.Test_Mode).Dict_Value;

                testInfoModelList.Add(testInfoModel);
            }
            return(testInfoModelList);
        }
Пример #2
0
        public IActionResult ForgetPassword(string emailOrUsername)
        {
            var user = emailOrUsername.IndexOf("@") != 0 ?
                       DbContext.Users.FirstOrDefault(u => u.Email == emailOrUsername) :
                       DbContext.Users.FirstOrDefault(u => u.UserName == emailOrUsername);

            if (user == null)
            {
                ViewBag.ErrorMsg = "邮箱不存在!";
                return(View());
            }

            string key   = "验证码";
            var    word1 = DictCache.GetDict((int)Language, key)?.Value ?? key;

            key = "您的验证码为";
            var word2 = DictCache.GetDict((int)Language, key)?.Value ?? key;

            string verCode = MailHelper.RandomNumber();

            HttpContext.Session.SetString("VerCode", verCode);
            MailHelper.SendMail(user.Email, word1, $"{word2}:{verCode}");
            HttpContext.Session.SetString("useremail", user.Email);
            return(RedirectToAction("InputVerCode"));
        }
Пример #3
0
        public async Task <IActionResult> Login(string userName, string password)
        {
            var _user = DbContext.Users.FirstOrDefault(u => u.UserName == userName && u.PassWord == password);

            if (_user != null)
            {
                var claims = new[] {
                    new Claim(ClaimTypes.Name, "bob"),
                    new Claim("name", _user.RealName ?? ""),
                    new Claim("email", _user.Email ?? ""),
                    new Claim("id", _user.ID.ToString())
                };
                var user = new ClaimsPrincipal(
                    new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme));

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, user);

                return(Json(new LoginModel()
                {
                    Success = true
                }));
            }

            var key  = "用户名或密码错误";
            var word = DictCache.GetDict((int)Language, key);

            return(Json(new LoginModel()
            {
                Success = false, Msg = word != null ? word.Value : key
            }));
        }
Пример #4
0
        public IActionResult RePassword(string password, string rePassword)
        {
            if (password != rePassword)
            {
                var key = "两次密码输入不一致";
                ViewBag.ErrorMsg = DictCache.GetDict((int)Language, key)?.Value ?? key;
                return(View());
            }

            if (password.Length < 6)
            {
                var key = "密码不能小于6位";
                ViewBag.ErrorMsg = DictCache.GetDict((int)Language, key)?.Value ?? key;
                return(View());
            }

            var user = DbContext.Users.FirstOrDefault(u => u.Email == HttpContext.Session.GetString("useremail"));

            user.PassWord = password;
            DbContext.SaveChanges();
            return(RedirectToAction("Index", "home"));
        }
Пример #5
0
        protected HtmlString _(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(new HtmlString(string.Empty));
            }

            if (this.languageId == 0)
            {
                string strLanId = this.ViewContext.RouteData.Values["LanguageId"].ToString();
                int.TryParse(strLanId, out int languageId);
                this.languageId = languageId;
            }

            var word = DictCache.GetDict(languageId, key);

            if (word != null)
            {
                return(new HtmlString(word.Value));
            }
            return(new HtmlString(key));
        }
Пример #6
0
        public IActionResult GetWord(string word)
        {
            var dict = DictCache.GetDict((int)Language, word);

            return(Json(dict == null ? word : dict.Value));
        }