public override void ProcessRequest(HttpContext context) { kyfly.BLL.jichu_renyuanxinxiB bll = new kyfly.BLL.jichu_renyuanxinxiB(context); base.ProcessRequest(context); context.Response.ContentType = "text/plain"; // writeFile("begin"); mycommonClass mycommonClassobj = new mycommonClass(); context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); if (context.Request.QueryString["type"] == "edit")//获取编辑信息 { if (context.Request.QueryString["Id"] != null) { string strret = bll.Geteditdata(context.Request.QueryString["Id"].ToString());//aa1 writeFile("f"); writeFile(strret); context.Response.Write(strret); } } else if (context.Request.QueryString["type"] == "del")//删除信息 { if (context.Request.QueryString["Id"] == null) { return; } string Id = context.Request.QueryString["Id"].ToString(); bll.Delete(int.Parse(Id)); } else if (context.Request.QueryString["type"] == "combox")//保存修改或添加 信息 aa2 { } else if (context.Request.QueryString["type"] == "save")//保存修改或添加 { string xingming = context.Request.QueryString["xingming"]; string shoujihao = context.Request.QueryString["shoujihao"]; string OpenId = context.Request.QueryString["OpenId"]; string mima = context.Request.QueryString["mima"]; string dizhi = context.Request.QueryString["dizhi"]; string zhuangtai = context.Request.QueryString["zhuangtai"]; string leibie = context.Request.QueryString["leibie"]; string quanxian = context.Request.QueryString["quanxian"]; string huiyuanjibie = context.Request.QueryString["huiyuanjibie"]; string peisongcishu = context.Request.QueryString["peisongcishu"]; string beizhu = context.Request.QueryString["beizhu"]; if (context.Request.QueryString["Id"] != null && context.Request.QueryString["Id"] != "") { bll.Update(context.Request.QueryString["Id"].ToString(), xingming, shoujihao, OpenId, mima, dizhi, zhuangtai, leibie, quanxian, huiyuanjibie, peisongcishu, beizhu); } else { bll.Add(xingming, shoujihao, OpenId, mima, dizhi, zhuangtai, leibie, quanxian, huiyuanjibie, peisongcishu, beizhu); } context.Response.Write("true"); } else if (context.Request.Form["action"] != null && Convert.ToString(context.Request.Form["action"]) == "query") { //string strret = bll.GetListByPageColumns_tojson("id,产品名称,产品数量,产品规格,备注", "1=1", "产品数量"); 加权限, 1=1 改为:部门编号 like '1010%' string strret = bll.GetListByPageColumns_tojson("Id,姓名,手机号,OpenId,密码,地址,状态,类别,权限,会员级别,配送次数,备注", pagestrif, "Id", 0); //writeFile("S"); //writeFile(strret); context.Response.Write(strret); return; } else if (context.Request.QueryString["type"] == "read") { string strret = bll.GetListByPageColumns_tojson("Id,姓名,手机号,OpenId,密码,地址,状态,类别,权限,会员级别,配送次数,备注", pagestrif, "Id", 0); //writeFile("S"); // writeFile(strret); context.Response.Write(strret); } else { } }
public void ProcessRequest(HttpContext context) { kyfly.BLL.jichu_renyuanxinxiB bll = new kyfly.BLL.jichu_renyuanxinxiB(context); context.Response.ContentType = "text/plain"; writeFile("getinfor"); string phone = ""; string key = ""; string iv = ""; string encryptedData = ""; string threedsession = ""; string value = ""; try { phone = HttpContext.Current.Request.QueryString["phone"].ToString(); key = HttpContext.Current.Request.QueryString["key"].ToString(); iv = HttpContext.Current.Request.QueryString["iv"].ToString(); encryptedData = HttpContext.Current.Request.QueryString["encryptedData"].ToString(); threedsession = HttpContext.Current.Request.QueryString["threedsession"].ToString(); } catch (Exception ex) { context.Response.Write(ex.ToString()); } writeFile(phone); writeFile(key); writeFile(iv); writeFile(encryptedData); writeFile(threedsession); if (!string.IsNullOrEmpty(threedsession)) { GetUsersHelper GetUsersHelper = new GetUsersHelper(); //用户数据解密 if (HttpContext.Current.Request.Cookies["threedsession"] != null) { value = HttpContext.Current.Request.Cookies["threedsession"].Value; } GetUsersHelper.AesIV = iv; GetUsersHelper.AesKey = value; string result = GetUsersHelper.AESDecrypt(encryptedData); //存储用户数据 JObject _usrInfo = (JObject)JsonConvert.DeserializeObject(result); userInfo userInfo = new userInfo(); userInfo.openId = _usrInfo["openId"].ToString(); try //部分验证返回值中没有unionId { userInfo.unionId = _usrInfo["unionId"].ToString(); } catch (Exception) { userInfo.unionId = "unionId"; } userInfo.nickName = _usrInfo["nickName"].ToString(); userInfo.gender = _usrInfo["gender"].ToString(); userInfo.city = _usrInfo["city"].ToString(); userInfo.province = _usrInfo["province"].ToString(); userInfo.country = _usrInfo["country"].ToString(); userInfo.avatarUrl = _usrInfo["avatarUrl"].ToString(); object watermark = _usrInfo["watermark"].ToString(); object appid = _usrInfo["watermark"]["appid"].ToString(); object timestamp = _usrInfo["watermark"]["timestamp"].ToString(); bll.Add(userInfo.nickName, phone, userInfo.openId, key, "", "", "客户", "", "", "", ""); //#region ////创建连接池对象(与数据库服务器进行连接) //SqlConnection conn = new SqlConnection("server=127.0.0.1;database=Test;uid=sa;pwd=1"); ////打开连接池 //conn.Open(); ////创建命令对象 //string Qrystr = "SELECT * FROM WeChatUsers WHERE openId='" + userInfo.openId + "'"; //SqlCommand cmdQry = new SqlCommand(Qrystr, conn); //object obj = cmdQry.ExecuteScalar(); //if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) //{ // string str = "INSERT INTO WeChatUsers ([UnionId] ,[OpenId],[NickName],[Gender],[City],[Province],[Country],[AvatarUrl],[Appid],[Timestamp],[Memo],[counts])VALUES('" + userInfo.unionId + "','" + userInfo.openId + "','" + userInfo.nickName + "','" + userInfo.gender + "','" + userInfo.city + "','" + userInfo.province + "','" + userInfo.country + "','" + userInfo.avatarUrl + "','" + appid.ToString() + "','" + timestamp.ToString() + "','来自微信小程序','1')"; // SqlCommand cmdUp = new SqlCommand(str, conn); // // 执行操作 // try // { // int row = cmdUp.ExecuteNonQuery(); // } // catch (Exception ex) // { // context.Response.Write(ex.ToString()); // } //} //else //{ // //多次访问,记录访问次数counts 更新unionId是预防最初没有,后期关联后却仍未记录 // string str = "UPDATE dbo.WeChatUsers SET counts = counts+1,UnionId = '" + userInfo.unionId + "' WHERE OpenId='" + userInfo.openId + "'"; // SqlCommand cmdUp = new SqlCommand(str, conn); // int row = cmdUp.ExecuteNonQuery(); //} ////关闭连接池 //conn.Close(); //#endregion //返回解密后的用户数据 context.Response.Write(result); } }