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")); }
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); }
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 })); }
public bool Equals(StagedOrderRecord x, Order other, DictCache dictCache) { return(x.ServiceLocationIdentifier == other.Tasks[0].LocationIdentifier && x.OrderIdentifier == other.Identifier && x.BeginDate == other.BeginDate && x.OrderClassIdentifier == dictCache.orderClassesDict.Where(orderclass => orderclass.Value == other.OrderClassEntityKey).Select(orderclass => orderclass.Key).FirstOrDefault(null) && x.RegionIdentifier == MainService.Regions.Where(region => region.EntityKey == other.RegionEntityKey).Select(region => region.Identifier).FirstOrDefault(null)); }
//Save word public async Task <JsonResult> saveWord(string Voca) { string userId = User.Identity.GetUserId(); DictCache dictCache = _dictCache.findWordCache(Voca); if (dictCache == null) { return(Json(new { result = "False", })); } DetailOurWord detailWord = _detailOutWordService.findDetailOurWord(userId, dictCache.Id); //tick từ mới thành công if (detailWord == null) { ApplicationUser user = _service.GetUserById(userId); detailWord = new DetailOurWord(); detailWord.Id_User = userId; detailWord.Id_Messenger = user.Id_Messenger; detailWord.Id_OurWord = dictCache.Id; detailWord.Learned = 1; detailWord.Id = 0; detailWord.Schedule = DateTime.Now.AddDays(-1); _detailOutWordService.Add(detailWord); _detailOutWordService.Save(); await notifyMessenger(true); return(Json(new { result = "True" })); } else { //tick cái nữa thì xóa tick _detailOutWordService.Delete(detailWord); _detailOutWordService.Save(); return(Json(new { result = "False" })); } }
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")); }
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)); }
public async Task <string> searchDictViaBot(string contain, string id = "1554844547918927", string userid = null) { bool multiLetters = false; contain = contain.ToString().ToLower().Trim(); //Tim trong cache nếu ko có thì request crawler var dictTemp = _dictCache.findWordCache(contain); //post // bool isSaveCached = true; DictCache cacheDict = new DictCache(); OxfordDict dict = new OxfordDict(); GoogleTrans googleTransJson = new GoogleTrans(); GoogleTrans detailVietnamese = new GoogleTrans(); //Explain main of letter MessJson messExplaintion = new MessJson(); //Pron MessJson messPron = new MessJson(); //Vietnamese MessJson messVietnamese = new MessJson(); // ChatfuelJson hello = new ChatfuelJson(); AttachmentJson sound = new AttachmentJson(); sound.attachment.type = "audio"; Attachment2 attach = new Attachment2(); //Json is returned Customer AttachmentJson soundDic = new AttachmentJson(); MessJson messExplaintionDict = new MessJson(); MessJson resultGoogle = new MessJson(); // JsonMessengerText jsonTextMessenger = new JsonMessengerText(); jsonTextMessenger.recipient.id = id; JsonMessengerText jsonSoundMessenger = new JsonMessengerText(); jsonSoundMessenger.recipient.id = id; messExplaintionDict.text += "*" + ToTitleCase(contain) + "*"; Payload2 payload = new Payload2(); // if (dictTemp != null) { messPron.text = dictTemp.Pron; messExplaintion.text = dictTemp.MeanEn; messVietnamese.text = dictTemp.MeanVi; sound.attachment.payload.url = dictTemp.SoundUrl; // messExplaintionDict.text += "\r\n" + dictTemp.Pron; messExplaintionDict.text += "\r\n" + dictTemp.MeanEn; messExplaintionDict.text += "\r\n" + dictTemp.MeanVi; soundDic.attachment.payload.url = dictTemp.SoundUrl; } else { int size = contain.Split(' ').Length; if (size > 1) { multiLetters = true; googleTransJson = await _clientDictionaryService.startGoogleTrans(contain); foreach (var sentence in googleTransJson.sentences) { messExplaintion.text += sentence.trans; resultGoogle.text += sentence.trans; } // resultGoogle.text = googleTransJson.sentences[0].trans; //messExplaintionDict.text +="\r\n" + googleTransJson.sentences[0].trans; } else { try { dict = await _clientDictionaryService.startCrawlerOxford(contain); messPron.text = dict.m_Pron; messExplaintion.text = dict.m_Explanation.First().m_UseCase; // messExplaintionDict.text += "\r\n" + dict.m_Pron; messExplaintionDict.text += "\r\n" + dict.m_Explanation.First().m_UseCase; } catch { isSaveCached = false; messExplaintion.text = contain; messExplaintionDict.text += "\r\n" + contain; } try { detailVietnamese = await _clientDictionaryService.startGoogleDetailTrans(contain); } catch { detailVietnamese = null; } try { messVietnamese.text = detailVietnamese.dict.First().pos + ": "; foreach (var item in detailVietnamese.dict.First().terms) { messVietnamese.text += item + ", "; } messExplaintionDict.text += "\r\n" + messVietnamese.text; } catch { isSaveCached = false; messVietnamese.text = detailVietnamese.sentences.FirstOrDefault().trans; messExplaintionDict.text += "\r\n" + detailVietnamese.sentences.FirstOrDefault().trans; } } sound.attachment.payload.url = dict.m_SoundUrl; soundDic.attachment.payload.url = dict.m_SoundUrl; //Add database cacheDict = new DictCache(); cacheDict.VocaID = contain; cacheDict.Pron = messPron.text; cacheDict.MeanEn = messExplaintion.text; cacheDict.MeanVi = messVietnamese.text; cacheDict.SoundUrl = dict.m_SoundUrl; _dictCache.Add(cacheDict); if (isSaveCached) { _dictCache.Save(); } dictTemp = cacheDict; } //DetailOurWord detailWord = _detailOutWordService.findDetailOurWord(userid, dictTemp.Id); //if (detailWord == null) //{ // hello.Selected = false; //} //else //{ // hello.Selected = true; //} hello.messages.Add(messPron); hello.messages.Add(messVietnamese); hello.messages.Add(messExplaintion); hello.messages.Add(sound); try { hello.strVoca = ToTitleCase(contain); ApplicationUser currentUser = _service.listUserID().Where(x => x.Id_Messenger == id).FirstOrDefault(); NotificationHub.sendNoti(currentUser.Email, JsonConvert.SerializeObject(hello)); } catch { } if (multiLetters) { jsonTextMessenger.message = messExplaintionDict; jsonSoundMessenger.message = resultGoogle; PostRaw("", JsonConvert.SerializeObject(jsonTextMessenger)); PostRaw("", JsonConvert.SerializeObject(jsonSoundMessenger)); return(""); } jsonTextMessenger.message = messExplaintionDict; jsonSoundMessenger.message = soundDic; PostRaw("", JsonConvert.SerializeObject(jsonTextMessenger)); PostRaw("", JsonConvert.SerializeObject(jsonSoundMessenger)); return(JsonConvert.SerializeObject(hello)); }
public async Task <string> getDictToExtension(string contain) { bool isVN = false; string userid = User.Identity.GetUserId(); contain = contain.ToString().ToLower().Trim(); DictCache dictTemp = new DictCache(); //Tim trong cache nếu ko có thì request crawler try { dictTemp = _dictCache.findWordCache(contain); } catch (Exception e) { } //post // bool isSaveCached = true; DictCache cacheDict; OxfordDict dict = new OxfordDict(); GoogleTrans googleTransJson = new GoogleTrans(); GoogleTrans detailVietnamese = new GoogleTrans(); //Explain main of letter MessJson messExplaintion = new MessJson(); //Pron MessJson messPron = new MessJson(); //Vietnamese MessJson messVietnamese = new MessJson(); // ChatfuelJson hello = new ChatfuelJson(); AttachmentJson sound = new AttachmentJson(); sound.attachment.type = "audio"; Attachment2 attach = new Attachment2(); if (contain.LastOrDefault() == '.') { messPron.text = ""; hello.messages.Add(messPron); return(JsonConvert.SerializeObject(hello)); } Payload2 payload = new Payload2(); // if (dictTemp != null) { messPron.text = dictTemp.Pron; messExplaintion.text = dictTemp.MeanEn; messVietnamese.text = dictTemp.MeanVi; sound.attachment.payload.url = dictTemp.SoundUrl; } else { int size = contain.Split(' ').Length; if (size > 1) { isSaveCached = false; googleTransJson = await _clientDictionaryService.startGoogleTrans(contain); hello.strVietnamese = googleTransJson.src; if (googleTransJson.src == "vi") { isVN = true; } messExplaintion.text = googleTransJson.sentences[0].trans; } else { try { dict = await _clientDictionaryService.startCrawlerOxford(contain); messPron.text = dict.m_Pron; messExplaintion.text = dict.m_Explanation.First().m_UseCase; } catch { isSaveCached = false; messExplaintion.text = contain; } detailVietnamese = await _clientDictionaryService.startGoogleDetailTrans(contain); hello.strVietnamese = detailVietnamese.src; if (detailVietnamese.src == "vi") { isVN = true; } try { messVietnamese.text = detailVietnamese.dict.First().pos + ": "; foreach (var item in detailVietnamese.dict.First().terms) { messVietnamese.text += item + ", "; } } catch { isSaveCached = false; messVietnamese.text = detailVietnamese.sentences.FirstOrDefault().trans; } } sound.attachment.payload.url = dict.m_SoundUrl; //Add database cacheDict = new DictCache(); cacheDict.VocaID = contain; cacheDict.Pron = messPron.text; cacheDict.MeanEn = messExplaintion.text; cacheDict.MeanVi = messVietnamese.text; cacheDict.SoundUrl = dict.m_SoundUrl; _dictCache.Add(cacheDict); if (isSaveCached) { _dictCache.Save(); } dictTemp = cacheDict; } DetailOurWord detailWord = _detailOutWordService.findDetailOurWord(userid, dictTemp.Id); if (detailWord == null) { hello.Selected = false; } else { hello.Selected = true; } hello.messages.Add(messPron); hello.messages.Add(messVietnamese); hello.messages.Add(messExplaintion); hello.messages.Add(sound); if (isVN) { return(null); } return(JsonConvert.SerializeObject(hello)); }
public async Task <string> callChatBot(string contain, string id, string userid) { contain = contain.ToString().ToLower().Trim(); //Tim trong cache nếu ko có thì request crawler var dictTemp = _dictCache.findWordCache(contain); //post // bool isSaveCached = true; DictCache cacheDict = new DictCache(); OxfordDict dict = new OxfordDict(); GoogleTrans googleTransJson = new GoogleTrans(); GoogleTrans detailVietnamese = new GoogleTrans(); //Explain main of letter MessJson messExplaintion = new MessJson(); //Pron MessJson messPron = new MessJson(); //Vietnamese MessJson messVietnamese = new MessJson(); // ChatfuelJson hello = new ChatfuelJson(); AttachmentJson sound = new AttachmentJson(); sound.attachment.type = "audio"; Attachment2 attach = new Attachment2(); if (contain.LastOrDefault() == '.') { messPron.text = ""; hello.messages.Add(messPron); return(JsonConvert.SerializeObject(hello)); } Payload2 payload = new Payload2(); // if (dictTemp != null) { messPron.text = dictTemp.Pron; messExplaintion.text = dictTemp.MeanEn; messVietnamese.text = dictTemp.MeanVi; sound.attachment.payload.url = dictTemp.SoundUrl; } else { int size = contain.Split(' ').Length; if (size > 1) { googleTransJson = await _clientDictionaryService.startGoogleTrans(contain); messExplaintion.text = googleTransJson.sentences[0].trans; } else { try { dict = await _clientDictionaryService.startCrawlerOxford(contain); messPron.text = dict.m_Pron; messExplaintion.text = dict.m_Explanation.First().m_UseCase; } catch { isSaveCached = false; messExplaintion.text = contain; } detailVietnamese = await _clientDictionaryService.startGoogleDetailTrans(contain); try { messVietnamese.text = detailVietnamese.dict.First().pos + ": "; foreach (var item in detailVietnamese.dict.First().terms) { messVietnamese.text += item + ", "; } } catch { isSaveCached = false; messVietnamese.text = detailVietnamese.sentences.FirstOrDefault().trans; } } sound.attachment.payload.url = dict.m_SoundUrl; //Add database cacheDict = new DictCache(); cacheDict.VocaID = contain; cacheDict.Pron = messPron.text; cacheDict.MeanEn = messExplaintion.text; cacheDict.MeanVi = messVietnamese.text; cacheDict.SoundUrl = dict.m_SoundUrl; _dictCache.Add(cacheDict); if (isSaveCached) { _dictCache.Save(); } dictTemp = cacheDict; } DetailOurWord detailWord = _detailOutWordService.findDetailOurWord(userid, dictTemp.Id); if (detailWord == null) { hello.Selected = false; } else { hello.Selected = true; } hello.messages.Add(messPron); hello.messages.Add(messVietnamese); hello.messages.Add(messExplaintion); hello.messages.Add(sound); try { hello.strVoca = ToTitleCase(contain); ApplicationUser currentUser = _service.listUserID().Where(x => x.Id_Messenger == id).FirstOrDefault(); NotificationHub.sendNoti(currentUser.Email, JsonConvert.SerializeObject(hello)); } catch { } return(JsonConvert.SerializeObject(hello)); }
public async Task <JsonResult> Tick(OurWordViewModel data) { if (data != null) { DictCache dictCache = _dictCache.findWordCache(data.VocaID); if (dictCache == null) { dictCache = new DictCache(); data.MeanVi = HttpUtility.HtmlDecode(data.MeanVi).ToString(); FieldHelper.CopyNotNullValue(dictCache, data); try { _dictCache.Add(dictCache); _dictCache.Save(); } catch (Exception e) { return(Json(new { result = "failed", })); } } var userId = User.Identity.GetUserId(); DetailOurWord detailWord = _detailOutWordService.findDetailOurWord(userId, dictCache.Id); if (detailWord == null) { ApplicationUser user = _service.GetUserById(userId); detailWord = new DetailOurWord(); detailWord.Id_User = userId; detailWord.Id_Messenger = user.Id_Messenger; detailWord.Id_OurWord = dictCache.Id; detailWord.Learned = 1; detailWord.Id = 0; detailWord.Schedule = DateTime.Now.AddDays(-1); _detailOutWordService.Add(detailWord); } else { _detailOutWordService.Delete(detailWord); } try { _detailOutWordService.Save(); await notifyMessenger(); return(Json(new { result = "success" })); } catch (Exception e) { return(Json(new { result = "failed", })); } } return(Json(new { result = "failed" })); }
public async Task <PartialViewResult> Dictionaries(string keyword) { bool isVN = false; OxfordDict dict = new OxfordDict(); GoogleTrans googleTransJson = new GoogleTrans(); keyword = keyword.Trim(); _viewModel = new DictionariesViewModel(); bool downloadSucceeded = false; if (keyword != "") { int size = keyword.Split(' ').Length; if (size > 1) { googleTransJson = await _clientDictionaryService.startGoogleTrans(keyword); DictionariesViewModel.isGoogleTrans = true; DictionariesViewModel.m_GoogleTrans = googleTransJson; } else { try { dict = await _clientDictionaryService.startCrawlerOxford(keyword); downloadSucceeded = true; } catch (Exception e) { downloadSucceeded = false; } if (!downloadSucceeded) { googleTransJson = await _clientDictionaryService.startGoogleTrans(keyword); if (googleTransJson.src == "vi") { isVN = true; } DictionariesViewModel.isGoogleTrans = true; DictionariesViewModel.m_GoogleTrans = googleTransJson; } try { GoogleTrans detailVietnamese = new GoogleTrans(); detailVietnamese = await _clientDictionaryService.startGoogleDetailTrans(keyword); if (detailVietnamese.src == "vi") { isVN = true; } string meanVN = detailVietnamese.dict.First().pos + ": "; foreach (var item in detailVietnamese.dict.First().terms) { meanVN += item + ", "; } DictionariesViewModel.m_MeanVn = meanVN; } catch { } DictionariesViewModel.m_Explanation = dict.m_Explanation; DictionariesViewModel.m_SoundUrl = dict.m_SoundUrl; DictionariesViewModel.m_Type = dict.m_Type; DictionariesViewModel.m_Voca = dict.m_Voca; DictionariesViewModel.m_Pron = dict.m_Pron.Replace("BrE", ""); } DictionariesViewModel.m_ExaTraCau = await _clientDictionaryService.startCrawlerTraCau(keyword); } try { DictCache dictCache = _dictCache.findWordCache(keyword); if (dictCache == null) { dictCache = new DictCache(); dictCache.VocaID = keyword; dictCache.Pron = DictionariesViewModel.m_Pron; dictCache.MeanEn = DictionariesViewModel.m_Explanation.FirstOrDefault().m_UseCase; dictCache.MeanVi = DictionariesViewModel.m_MeanVn; dictCache.SoundUrl = DictionariesViewModel.m_SoundUrl; _dictCache.Add(dictCache); _dictCache.Save(); } else { if (_detailOutWordService.findDetailOurWord(User.Identity.GetUserId(), dictCache.Id) != null) { DictionariesViewModel.love = true; } } } catch (Exception e) { } return(PartialView("_Dictionaries", DictionariesViewModel)); }
public IActionResult GetWord(string word) { var dict = DictCache.GetDict((int)Language, word); return(Json(dict == null ? word : dict.Value)); }
public IActionResult InitDict() { DictCache.InitWordDict(); return(Json(new { Success = true })); }