protected void Page_Load(object sender, EventArgs e) { DataRsp rsp = new DataRsp(); if (Com.Session.userid != null) { rsp.RspData = Com.Public.Encrypt("schid:" + Com.Session.schid + "|uid:" + Com.Session.userid + "|upw:" + Com.Session.userpw + "|utp:" + Com.Session.usertp + "|usystp:" + Com.Session.systype + "|utid:" + Com.Session.usertid + "|ulgt:" + Com.Session.ulogintime, Com.Public.getKey("ApiSecretKey")); //string dddd = Com.Public.Decrypt(rsp.RspData.ToString()); //根据用户名获取用户密码并解密 } else { rsp.RspCode = "0010"; rsp.RspTxt = "验证信息不存在需要重新登录"; } Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rsp)); Response.End(); }
public static DataRsp <string> SendBaseImg(string SendBaseImgStr) { DataRsp <string> rsp = new DataRsp <string>(); //在配置文件中設置圖片路徑(本案例中暫時沒有使用) //string filePath = HttpContext.Current.Server.MapPath("~/" + @System.Configuration.ConfigurationManager.AppSettings["ImagePath"]); try { //設置圖片保存路徑 string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();//年月 string rootPath = HttpContext.Current.Server.MapPath("~/"); string ImageFilePath = rootPath + "UploadFileDir/Teacher/" + fileName; //判斷路徑是否存在,否則,創建文件夾 if (System.IO.Directory.Exists(ImageFilePath) == false) { System.IO.Directory.CreateDirectory(ImageFilePath); } string base64str = SendBaseImgStr.Substring(SendBaseImgStr.IndexOf(",") + 1); //将‘,’以前的多余字符串删除 byte[] bt = Convert.FromBase64String(base64str); //獲取圖片base64 string ImagePath = ImageFilePath + "/" + System.DateTime.Now.ToString("yyyyHHddHHmmss"); //定義圖片名稱 File.WriteAllBytes(ImagePath + ".png", bt); //保存圖片到服務器,然後獲取路徑 rsp.code = "ImgUpload"; rsp.msg = "圖片上傳成功"; rsp.RspData = ImagePath + ".png";//獲取保存后的路徑 } catch (Exception e) { rsp.code = "ExcepExit"; rsp.msg = e.Message; } return(rsp); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; DataRsp rsp = new DataRsp(); string Action = context.Request.Form["Action"]; if (Action == "null") { context.Response.Write(PublicProperty.PublicKey); } else if (Action == "Login")//登录 { string str = ""; //解密 RSA RSACryptoService rsa = new RSACryptoService(PublicProperty.PrivateKey, PublicProperty.PublicKey); try { string usernameEncode = context.Request.Form["UserName"]; string uname = Com.Public.SqlEncStr(rsa.Decrypt(usernameEncode)); //获取到学校ID,判断该学校是否正常 //bool isschcor = false; SchSystem.BLL.SchUserInfo userbll = new SchSystem.BLL.SchUserInfo(); SchSystem.BLL.SchInfo schbll = new SchSystem.BLL.SchInfo(); //if (Com.Public.getKey("issch") == "1")//单学校登录 //{ // string appschid = Com.Public.getKey("appschid"); // //判断该学校是否正常 // isschcor = schbll.Exists(int.Parse(appschid), 1); //} //else//统一登录 //{ // SchSystem.Model.SchUserInfo usermodel = userbll.GetModelByUname(uname); // if (usermodel != null && usermodel.UserId > 0) // { // isschcor = schbll.Exists(usermodel.SchId, 1); // } //} //if (!isschcor) //{ // rsp.RspCode = "6"; // rsp.RspTxt = "该学校已经被关闭或者账号不存在,请联系系统管理人员!"; //} //else //{ string pwdEncode = context.Request.Form["PassWord"]; string txtCode = context.Request.Form["TxtCode"]; //IsCookies //string IsCookies = context.Request.Form["IsCookies"]; string txtcode = rsa.Decrypt(txtCode); //string iscookies = rsa.Decrypt(IsCookies); //bool iscook =false; //if (iscookies == "1") iscook = true; if (recode(txtcode, context)) { if (!string.IsNullOrEmpty(uname)) { string pwd = Com.Public.SqlEncStr(rsa.Decrypt(pwdEncode)); Com.Session.userpw = pwd; Com.Session.usertp = "0"; string pwdmd5 = Com.Public.StrToMD5(pwd); //查询所登录的用户名和密码是否一致。如果一致,则返回true;否则,返回false。 bool result = false; if (Com.Public.getKey("issch") == "1") //分学校部署,需要在本学校中 { result = userbll.Exists("UserName='******' and PassWord='******' and Stat=1 and AccStat=1 and SysType=0 and schid=" + Com.Public.getKey("appschid")); } else //总平台不允许分学校部署的用户登录,则加上schid所在学校限制 { result = userbll.Exists("UserName='******' and PassWord='******' and Stat=1 and AccStat=1 and SysType=0 and schid not in (select schid from SchInfo where IsAlone=1)"); } if (result == true) { //用户登录处理函数 str = Com.Public.UserLoginDo(uname, false, Com.Public.getKey("appschid")); if (str == "1" && pwd == "123456") { rsp.RspCode = "2"; rsp.RspTxt = context.Request.Url.Authority + context.Request.ApplicationPath + "/userpwdedit.aspx"; //str = "2";//默认初始化密码,需要先修改密码 } else { rsp.RspCode = "1"; rsp.RspTxt = context.Request.Url.Authority + context.Request.ApplicationPath + "/index.aspx"; } } else { rsp.RspCode = "3"; rsp.RspTxt = "账号或密码错误,请联系系统管理员!"; //str = "3";//账号或密码错误,或者被停用,请联系管理员 } } else { rsp.RspCode = "4"; rsp.RspTxt = "用户名不能为空"; //str = "4";//用户名不能为空 } } else { rsp.RspCode = "5"; rsp.RspTxt = "验证码错误"; //str = "5";//验证码错误 } //} } catch (Exception ex) { rsp.RspCode = "9"; rsp.RspTxt = ex.Message; } context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rsp)); } else if (Action == "out")//退出 { /*PublicMethod.Clear();*/ context.Session.Clear(); context.Session.Abandon(); context.Response.Clear(); //清除cookies Com.CookieHelper.ClearCookie("uname"); rsp.RspCode = "success"; rsp.RspTxt = "Login.aspx"; if (Com.Public.getKey("isyssch") == "1") { rsp.RspTxt = "LoginYs.aspx"; } context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rsp)); } }