<%@ WebHandler Language="C#" Class="wx_scanlogin" %> using System; using System.Web; using System.Net; using Tencent; using eMIS.Data; public class wx_scanlogin : IHttpHandler,System.Web.SessionState.IRequiresSessionState { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string guid1= context.Request["guid"]; string userId = WeiXinWebCommon.ReadCookieUserId(context); eDbManager manager = new eDbManager(eMIS.Data.WebConfigManager.DefaultDb); eDbOperator dbo = manager.CreateDbOperator(); string sql = ""; try { sql = "select id,login,xingming from com_yhb where login=?"; System.Data.DataTable tabl = dbo.ExecuteTable(sql, System.Data.CommandType.Text, userId); if (tabl.Rows.Count > 0) { //eMIS.LoginManager lm = new eMIS.LoginManager(context); //lm.Login(Convert.ToString(tabl.Rows[0][0])); sql = "update xt_wx_scan_login set userid='{0}',logintime=getdate(),userLogin='{1}',username='{2}' where guid1=?"; sql = string.Format(sql, tabl.Rows[0]["id"], tabl.Rows[0]["login"], tabl.Rows[0]["xingming"]); dbo.ExecuteNonQuery(sql, guid1); dbo.ExecuteNonQuery("delete from xt_wx_scan_login where userid is null and datediff(mi,createtime,getdate())>20"); //超过20分钟的删除 } else { throw new Exception("未找到用户"); } } catch (Exception ex) { context.Response.Write(ex.Message); context.Response.End(); } context.Response.Write("您好,"+ userId); //context.Response.Redirect("http://here.sac-china.com/frame/default/default.aspx"); } public bool IsReusable { get { return false; } } }