/// <summary> /// 验证是否登录,Code返回1为没有登录或者token失效,要重新登录 /// </summary> /// <param name="context"></param> /// <returns></returns> public override bool OnActionExecuting(ActionContext context) { LogonBLL logonbll = new LogonBLL(); UserBLL userbll = new UserBLL(); //验证没有token if (!context.Parameters.ContainsKey("token") || context.Parameters["token"] == null) { this.Message = "没有token!"; context.Code = 2; return false; } //验证有没有登录 string token = context.Parameters["token"].ToString(); int result = userbll.CheckUserAuth(token); switch (result) { case 3: this.Message = "token失效,请重新登录!"; context.Code = result; return false; case 4: this.Message = "您没有权限进行该操作!"; context.Code = result; return false; } return true; }
private void button26_Click(object sender, EventArgs e) { Workflow wf = new Workflow(); LogonBLL bll = new LogonBLL(); var result = bll.Logon(textBox1.Text); }
private void button1_Click(object sender, EventArgs e) { //string dt = "{\"dt\":\"2010-01-01\"}"; //string dt1 = "{\"2010-01-01\"}"; //jsonTest t = JsonHelper.Deserialize<jsonTest>(dt); //var t1 = JsonHelper.Deserialize<DateTime?>(dt1); Workflow wf = new Workflow(); RoleBLL rolebll = new RoleBLL(); //AssetBLL assetbll = new AssetBLL(); //var list = rolebll.GetUserSubUserIDs("13"); //var roles = assetbll.Query(new AssetQueryForm //{ // Creators = list, //}); //LogonRequest request = new LogonRequest(); //request.form = new LogonServiceForm //{ // username = "******", // password = "******", //}; //var response = SDKFactory.Client.Execute(request); //token = response.form.token; //MessageBox.Show(response.ResponseBody); LogonBLL bll = new LogonBLL(); var result = bll.Logon("admin", "123456"); token = result.token; }