protected void Page_Load(object sender, EventArgs e) { UserService.UserServiceClient userServiceClient = new UserService.UserServiceClient(); string login = string.Empty; login = userServiceClient.Login("admin", "admin"); Response.Write(login); if (login.Contains("false")) { return; } List<String> ls=new List<string>(); ls.Add("h"); ls.Add("y"); List<JsonTest> list = new List<JsonTest>(); list.Add(new JsonTest() { Name = "hy", Valuse = ls }); list.Add(new JsonTest() { Name = "hy", Valuse = ls }); list.Add(new JsonTest() { Name = "hy", Valuse = ls }); //UserView loginUser = null; //try //{ // loginUser = JsonHelper.DeserializeObject<UserView>(login); //} //catch (Exception ex) //{ } //if (loginUser == null) //{ // Response.Write("jsonConvert error!"); // return; //} //string roles = userServiceClient.GetRoles(); //Response.Write(JsonHelper.DeserializeObject<List<RoleView>>(roles).ToString()); //string register = userServiceClient.Register(JsonConvert.SerializeObject(loginUser), JsonConvert.SerializeObject( // new UserView() { // Id="000", // Duty="技术员", // RoleId = "RegisterUser", // Email="*****@*****.**", // Password="******", // Name="hy", // RoleName="注册用户" // } // )); //Response.Write(JsonConvert.DeserializeObject(register)); }
public ActionResult Login(LoginViewModel user) { if (ModelState.IsValid) { UserService.UserServiceClient client = new UserService.UserServiceClient(); string xmldata = client.Login(user.EmailId, user.UserPassword); DataSet ds = new DataSet(); ds.ReadXml(new StringReader(xmldata)); if (ds.Tables.Count > 0) { Session["UserId"] = ds.Tables[0].Rows[0]["User_ID"]; string fullname = ds.Tables[0].Rows[0]["First_Name"].ToString() + " " + ds.Tables[0].Rows[0]["Last_Name"].ToString(); Session["username"] = fullname; Session["emailid"] = ds.Tables[0].Rows[0]["Email_ID"]; Session["GroupCompanyId"] = ds.Tables[0].Rows[0]["Company_ID"]; Session["Isproductadmin"] = Session["GroupCompanyId"]; Session["Last_Login"] = ds.Tables[0].Rows[0]["Last_Login"]; Session["photo"] = ds.Tables[0].Rows[0]["Photo"]; if (Convert.ToInt32(Session["Isproductadmin"]) != 0) { CommonController commonController = new CommonController(); commonController.setGroupCompanyDetails(Convert.ToInt32(Session["GroupCompanyId"])); } return(RedirectToAction("dashboard", "common", new { pid = 0 })); //return View("~/Views/UserManagement/Landing_Page.cshtml"); } else { ModelState.AddModelError("", ConfigurationManager.AppSettings["Login_error"]); } } else { ModelState.AddModelError("", ConfigurationManager.AppSettings["Login_error_null"]); } return(View("~/Views/Shared/_Login.cshtml", user)); }