private Ast ForLoop() { if (!_tokenStream.IsMatch <ForToken>()) { return(null); } ForToken token = _tokenStream.Take <ForToken>(); _tokenStream.Take <LeftParensToken>(); Ast initialization = Expression(); _tokenStream.Take <SemicolonToken>(); Ast condition = Expression(); _tokenStream.Take <SemicolonToken>(); Ast afterthought = Expression(); _tokenStream.Take <RightParensToken>(); Ast body = Statement(); if (body == null) { throw new InvalidSyntaxException("For-loop must have a body statement", _tokenStream.Current.Position, null); } return(new ForLoop(token, initialization, condition, afterthought, body.ToScope())); }
public ForToken LogOn(DataConnection pclsCache, string PwType, string userId, string password, string role) { int result = usersMethod.CheckPasswordByInput(pclsCache, PwType, userId, password); ForToken response = new ForToken(); response.Status = ""; response.Token = ""; if (result == 1) { //密码验证成功 string UId = usersMethod.GetIDByInput(pclsCache, PwType, userId); //输入手机号获取用户ID if (UId != "") { string Class = usersMethod.GetActivatedState(pclsCache, UId, role); if (Class == "0") { int flag = 0; List<string> AllRoleMatch = usersMethod.GetAllRoleMatch(pclsCache, UId); if (AllRoleMatch != null) { for (int i = 0; i < AllRoleMatch.Count; i++) { if (AllRoleMatch[i].ToString() == role)//查询条件 { flag = 1; break; } } } if (flag == 1) { string ticks = new CommonMethod().GetServerTime(pclsCache); response.Token = SecurityManager.GenerateToken(userId, password, role, ticks); response.Status = "已注册激活且有权限,登陆成功,跳转到主页"; return response; //"已注册激活且有权限,登陆成功,跳转到主页"1; } else { response.Status = "已注册激活,但没有权限"; //"已注册激活 但没有权限"2; } } else //Class == "1" or Class == "" { response.Status = "您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活)"; //您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活)3 } } else { response.Status = "用户不存在"; //"用户不存在"4; } } else if (result == 0) { response.Status = "密码错误"; //"密码错误"5; } else { response.Status = "用户不存在"; //"用户不存在"4 } return response; }
public HttpResponseMessage LogOn(LogOn logOn) { //msg.url = "http://my.company.com/login"; //if (SecurityManager.IsTokenValid(token)) //{ ForToken ret = new ForToken(); ret = repository.LogOn(pclsCache, logOn.PwType, logOn.username, logOn.password, logOn.role); return(new ExceptionHandler().LogOn(Request, ret)); }
public void ToStringReturnsCorrectRepresentation() { var token = new ForToken(); token.Line = 20; token.Column = 40; Assert.AreEqual("<Keyword - 'for'>", token.ToString()); var token2 = new VarToken(); Assert.AreEqual("<Keyword - 'var'>", token2.ToString()); }
public void TwoSameKeywordTokensAreEqual() { var token = new ForToken(); token.Line = 5; token.Column = 20; var token2 = new ForToken(); token2.Line = 44; token2.Column = 23; Assert.AreEqual(token, token2); }
public void TwoDifferentKeywordTokensAreNotEqual() { var token = new ForToken(); token.Line = 5; token.Column = 20; var token2 = new VarToken(); token2.Line = 44; token2.Column = 23; Assert.AreNotEqual(token, token2); }
public HttpResponseMessage LogOn(HttpRequestMessage request, ForToken ret) { #region Result res = new Result(); res.result = "登录失败"; var resp = request.CreateResponse(HttpStatusCode.InternalServerError, res); string operationResult = ret.Status; //resp.Headers = new HttpResponseMessage().Add("Access-Control-Allow-Origin","*"); switch (operationResult) { case "已注册激活且有权限,登陆成功,跳转到主页": //"已注册激活且有权限,登陆成功,跳转到主页"; res.result = "登陆成功" + "Token = " + ret.Token; resp = request.CreateResponse(HttpStatusCode.OK, res); //resp = resp + ret.Token; //resultString = Newtonsoft.Json.JsonConvert.SerializeObject("登陆成功"); //resp.Content = new StringContent(string.Format("登陆成功")); break; case "已注册激活,但没有权限": //"已注册激活 但没有权限"; res.result = "没有权限"; resp = request.CreateResponse(HttpStatusCode.Forbidden, res); //resultString = Newtonsoft.Json.JsonConvert.SerializeObject("没有权限"); //resp.Content = new StringContent(string.Format("没有权限")); break; case "您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活)": //您的账号对应的角色未激活,需要先激活;界面跳转到游客页面(已注册但未激活) res.result = "暂未激活"; resp = request.CreateResponse(HttpStatusCode.Forbidden, res); //resultString = Newtonsoft.Json.JsonConvert.SerializeObject("暂未激活"); //resp.Content = new StringContent(string.Format("暂未激活")); break; case "用户不存在": //"用户不存在"; res.result = "用户不存在"; resp = request.CreateResponse(HttpStatusCode.BadRequest, res); //resultString = Newtonsoft.Json.JsonConvert.SerializeObject("用户不存在"); //resp.Content = new StringContent(string.Format("用户不存在")); break; case "密码错误": //"密码错误"; res.result = "密码错误"; resp = request.CreateResponse(HttpStatusCode.BadRequest, res); //resultString = Newtonsoft.Json.JsonConvert.SerializeObject("密码错误"); //resp.Content = new StringContent(string.Format("密码错误")); break; default: break; } return(resp); #endregion }