<%@ WebHandler Language="C#" Class="CheckPriKey" %> using System; using System.Collections.Generic; using System.Web; using System.Data; using System.IO; using eMIS.Data; using System.Data.Common; using System.Web.SessionState; using eMIS; using System.Web.Security; public class CheckPriKey : IHttpHandler, IRequiresSessionState { public void ProcessRequest (HttpContext context) { string taskid = context.Request.QueryString["tid"].ToString(); string userid = context.Request.QueryString["uid"].ToString(); DateTime d = DateTime.Parse(context.Request.QueryString["d"].ToString()); string token = context.Request.QueryString["t"].ToString(); string pwd = userid+taskid + d.ToString("yyyyMMddHHmmss") + "here.sac"; pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5"); string errinfo=""; if (pwd == token) { if (ExecDateDiff(d, DateTime.Now) > 30) { errinfo = "凭证过期"; } else { DataManager dm = new DataManager(); DataTable dt = dm.ExecuteTable("select lcid,jdid,jlid,JLLJ from XT_LCRW where id=? and jsrid=?", taskid, userid); if (dt.Rows.Count != 0) { LoginManager lm = new LoginManager(context); lm.Login(userid); string flowId = dt.Rows[0][0].ToString(); string nodeId = dt.Rows[0][1].ToString(); string recordId = dt.Rows[0][2].ToString(); string path = dt.Rows[0][3].ToString(); if(path=="") context.Response.Redirect("Kernel.ashx?page=0&flowid=" + flowId + "&nodeid=" + nodeId + "&varSign=" + recordId + "&" + DateTime.Now.Ticks.ToString()); else context.Response.Redirect(path); } else { errinfo = "验证失败!"; } } } else { errinfo = "验证凭证失败"; } context.Response.Write(errinfo); } /// /// 程序执行时间测试 /// /// 开始时间 /// 结束时间 /// 返回(秒)单位,比如: 0.00239秒 public double ExecDateDiff(DateTime dateBegin, DateTime dateEnd) { TimeSpan ts1 = new TimeSpan(dateBegin.Ticks); TimeSpan ts2 = new TimeSpan(dateEnd.Ticks); TimeSpan ts3 = ts1.Subtract(ts2).Duration(); //你想转的格式 //return ts3.TotalSeconds; return ts3.TotalDays; } public bool IsReusable { get { return false; } } }