public JsonResult CheckReset(string NewPassword, string ConfirmPassword, string SMSCode, string Phone) { if (string.IsNullOrEmpty(NewPassword) || string.IsNullOrEmpty(ConfirmPassword)) { return(Json(new { Status = "false", Result = "密码项不能为空!请仔细检查!" })); } if (string.IsNullOrEmpty(SMSCode)) { return(Json(new { Status = false, Result = "短信验证码不为空!" })); } if (string.IsNullOrEmpty(Phone)) { return(Json(new { Status = false, Result = "手机号不为空!" })); } if (!CheckerHelper.IsMobile(Phone.Trim())) { return(Json(new { Status = false, Result = "您发送的不是手机号!" })); } if (!UserBackendService.IsExist(Phone.Trim())) { return(Json(new { Status = false, Result = "系统不存在此用户!" })); } if (NewPassword != ConfirmPassword) { return(Json(new { Status = "false", Result = "新输入的密码不一致!" })); } var isdetectionon = PasswordStrengthDetectionService.IsDetectionOn(); if (isdetectionon) { var isstonger = CheckPasswordStronger(ConfirmPassword.Trim()); if (!isstonger) { return(Json(new { Status = "false", Result = "密码不按规则" })); } } var smsresult = SystemService.CheckVerificationCode(Phone.Trim(), SMSCode); if (smsresult == null) { SystemService.SendVerificationCode(Phone.Trim(), 120); return(Json(new { Status = "false", Result = smsresult.FailReson })); } if (!smsresult.IsSuccess) { return(Json(new { Status = "false", Result = "发短信失败,重新发送!" })); } var result = UserManager.ResetPassword(Phone.Trim(), ApplicationUserManager.Admintoken, ConfirmPassword.Trim()); if (!result.Succeeded) { return(Json(new { Status = false, Result = "更改密码失败,请重新确认修改!" })); } return(Json(new { Status = true, Result = "ResetSuccess" })); }
public static void Main() { var combinationChecker = GetChecker(); var hand = new Hand() .AddCard(new Card(Suit.Clubs, Rank.Two)) .AddCard(new Card(Suit.Diamonds, Rank.Two)) .AddCard(new Card(Suit.Clubs, Rank.Queen)) .AddCard(new Card(Suit.Diamonds, Rank.Queen)) .AddCard(new Card(Suit.Clubs, Rank.Ten)); var checkerHelper = new CheckerHelper(); combinationChecker.Check(checkerHelper, hand); }
static void Main() { var combinationChecker = GetChecker(); var hand = new Hand() .AddCard(new Card(Suit.Clubs, Rank.Two)) .AddCard(new Card(Suit.Diamonds, Rank.Two)) .AddCard(new Card(Suit.Clubs, Rank.Queen)) .AddCard(new Card(Suit.Diamonds, Rank.Queen)) .AddCard(new Card(Suit.Clubs, Rank.Ten)); var checkerHelper = new CheckerHelper(); combinationChecker.Check(checkerHelper, hand); }
public JsonResult SMSVerificationCode(string phone, string captcha) { if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(captcha)) { return(Json(new { Status = "error", Msg = "手机号或者验证码不能为空!" })); } if (!CheckerHelper.IsMobile(phone)) { return(Json(new { Status = "error", Msg = "输入的手机号不正确!" })); } if (!BConfigs.SimulateSendVCode && Session[CAPTCHA] != null && Session[CAPTCHA].ToString().ToUpper() != captcha.ToUpper()) { return(Json(new { Status = "error", Msg = "验证码不正确!" })); } if (!UserBackendService.IsExist(phone)) { return(Json(new { Status = "error", Msg = "您不是我们的成员,请联系后台管理员注册!" })); } SystemService.SendVerificationCode(phone, 120); return(Json(new { Status = "success", Msg = "短信已发送成功!" })); }
public ActionResult ConfirmedReset(string phone, string imgVerificationCode) { if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(imgVerificationCode)) { return(RedirectToAction("ConfirmIdentity", new { Message = "账户或者验证码不为空!" })); } if (!CheckerHelper.IsMobile(phone)) { return(RedirectToAction("ConfirmIdentity", new { Message = "您输入的不是手机号!" })); } if (!BConfigs.SimulateSendVCode && Session[CAPTCHA] != null && Session[CAPTCHA].ToString().ToUpper() != imgVerificationCode.ToUpper()) { return(RedirectToAction("ConfirmIdentity", new { Message = "您输入的验证码不对!" })); } var userbackend = db.UserBackend.Where(e => e.UserName == phone).FirstOrDefault(); if (userbackend == null) { return(RedirectToAction("ConfirmIdentity", new { Message = "没有该用户账号,请查证后再修改!" })); } //密码强度 var isdetectionoff = ConfigHelper.GetAppSetting("PasswordStrengthDetectionSwitch") != "on"; ViewData["IsDetection"] = !isdetectionoff; ViewData["RegexTxt"] = !isdetectionoff?ConfigHelper.GetAppSetting("PasswordRegEx") : string.Empty; var desc = ConfigHelper.GetAppSetting("RegExDesc"); ViewData["RegExDesc"] = !isdetectionoff ? (string.IsNullOrEmpty(desc) ? "密码长度必须不少于6个字符长度,密码只能包含英文字母(a-z)、数字字符(0-9)两个组合,不能全是数字或者全是字母!" : desc) : string.Empty; ViewBag.Phone = userbackend.UserName; ViewBag.Captcha = (string)Session[CAPTCHA]; ViewBag.Phone = phone; ViewBag.Captcha = imgVerificationCode; SystemService.SendVerificationCode(userbackend.UserName, 120); return(View()); }
void parseCheckDic() { checkHelper = new CheckerHelper(); TextAsset data = Resources.Load("TestJson_define/def-Character_Character", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Character = new JSONObject(strSrc); checkHelper.tableName = Character ["tablename"].str; Debug.Log(" table check : " + checkHelper.tableName); List <JSONObject> jsonList = Character ["tablefields"].list; for (int i = 0; i < jsonList.Count; i++) { CharacterInfoChecker checker = new CharacterInfoChecker(); checker.name = jsonList[i]["name"].str; checker.datatype = jsonList[i]["datatype"].str; checker.isunique = jsonList[i]["isunique"].b; if (jsonList[i].HasField("ref_tables")) { List <JSONObject> refTableList = jsonList[i]["ref_tables"].list; for (int j = 0; j < refTableList.Count; j++) { CharacterInfoChecker.ReferenceTable refTable = new CharacterInfoChecker.ReferenceTable(); refTable.name = refTableList[j]["tableName"].str; refTable.field = refTableList[j]["tableField"].str; checker.referenceTable.Add(j, refTable); } } checkHelper.checkerInfoDic.Add(checker.name, checker); } }
/// <summary> /// The main function of Vnvd. This runs the compiler. /// </summary> /// <param name="args">The command line arguments given to Vnvd.</param> public static void Main(String[] args) { Console.Out.WriteLine("Vnvd Compiler v" + Assembly.GetExecutingAssembly().GetName().Version); Console.Out.WriteLine("======================"); Console.Out.WriteLine(); ParseOptions(args); try { lib = new LibraryChecker(refs.ToArray()); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); Environment.Exit(1); } List <TreeNode> trees = new List <TreeNode>(); bool error = false; foreach (String filename in filenames) { VnvdLexer lexer = new VnvdLexer(new ANTLRFileStream(filename)); CommonTokenStream tokens = new CommonTokenStream(lexer); VnvdParser parser = new VnvdParser(tokens); parser.TreeAdaptor = new TreeNodeAdaptor(); VnvdParser.program_return result = parser.program(); TreeNode tree = (TreeNode)result.Tree; trees.Add(tree); if (parser.NumberOfSyntaxErrors > 0) { error = true; } } if (!error) { VnvdTreeWalker checker = null; if (!opt_nochecker) { // check the AST CheckerManual manual = new CheckerManual(); try { foreach (TreeNode tree in trees) { manual.WalkClasses(tree); } manual.WalkClassExtendation(); manual.WalkClassMembers(); for (int i = 0; i < trees.Count; i++) { TreeNode tree = trees[i]; ITreeNodeStream nodes = new CommonTreeNodeStream(tree); CheckerHelper helper = new CheckerHelper(); checker = new VnvdTreeWalker(helper, nodes); checker.Filename = filenames[i]; checker.TreeAdaptor = new TreeNodeAdaptor(); helper.Walker = checker; checker.program(); if (checker.SemanticErrorCount > 0 || checker.NumberOfSyntaxErrors > 0) { error = true; } } } catch (CheckerException ex) { Console.WriteLine(ex.ToString()); error = true; } } if (!error) { if (!opt_nogenerator) { AssemblyName aName = new AssemblyName(); aName.Name = Vnvd.OutputFile.Substring(0, Vnvd.OutputFile.LastIndexOf('.')); AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly( aName, AssemblyBuilderAccess.Save); // For a single-module assembly, the module name is usually // the assembly name plus an extension. mb = ab.DefineDynamicModule(aName.Name, Vnvd.OutputFile); GeneratorManual manualWalker = new GeneratorManual(mb, ab); foreach (TreeNode tree in trees) { manualWalker.WalkTypes(tree); } manualWalker.WalkTypeMembers(); foreach (TreeNode tree in trees) { ITreeNodeStream nodes = new CommonTreeNodeStream(tree); VnvdTreeWalker generator = new VnvdTreeWalker(new GeneratorHelper(), nodes); generator.program(); } foreach (TypeBuilder t in manualWalker.AllTypes) { t.CreateType(); } try { ab.Save(OutputFile); } catch (IOException) { Console.WriteLine("Error while saving the assembly. The output file is in use."); } } } if (opt_ast) { // print the AST as string StringBuilder sb = new StringBuilder(); foreach (TreeNode tree in trees) { String s = tree.ToStringTree(); int indent = 0; foreach (char c in s) { if (c == '(') { sb.Append('\n'); indent += 3; for (int i = 0; i < indent; i++) { sb.Append(' '); } } else if (c == ')') { indent -= 3; } sb.Append(c); } sb.AppendLine(); sb.AppendLine(); } //Console.WriteLine(sb.ToString()); Console.WriteLine("AST was written to ast.txt"); StreamWriter sw = new StreamWriter("ast.txt"); sw.Write(sb.ToString()); sw.Close(); } else if (opt_dot) { // print the AST as DOT specification DOTTreeGenerator gen = new DOTTreeGenerator(); Console.WriteLine("Graphviz AST graph (only first tree) was written to ast.dot"); StringTemplate st = gen.ToDOT(trees[0]); StreamWriter sw = new StreamWriter("ast.dot"); sw.Write(st.ToString()); sw.Close(); } } if (wait) { Console.Read(); } }