<%@ WebHandler Language="C#" Class="send_weichat_task" Debug="true" %> using System; using System.Web; using System.Text; using System.Data; using System.Web.Security; using eMIS; public class send_weichat_task : IHttpHandler,System.Web.SessionState.IRequiresSessionState { public void ProcessRequest (HttpContext context) { DataManager dm = new DataManager(); string id = context.Request.QueryString["id"].ToString(); DataTable dt = dm.ExecuteTable("select INST_DESC,RECORD_ID,USER_ID,TASK_ID from XT_ERR_REPORT where id=?",id); string userId = dt.Rows[0]["USER_ID"].ToString(); string taskId=dt.Rows[0]["TASK_ID"].ToString(); string title="您提交的问题上报《"+dt.Rows[0]["INST_DESC"].ToString()+"》错误已解决,"; dm.ExecuteNonQuery("update XT_LCRW set BZ='上报问题已处理'+isnull(BZ,''),JSSJ=getdate() where id=" + taskId); WeChatSend(dm,UserManager.GetUsersName(dm, userId, "|"), GetTaskEmailContent(title, taskId, userId)); context.Response.Write("ok"); } public string GetTaskEmailContent(string title,string taskId,string userid) { //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"); DateTime d = DateTime.Now; string pwd = userid + taskId + d.ToString("yyyyMMddHHmmss") + "here.sac"; pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5"); string dstr = d.ToString("yyyy-MM-dd HH:mm:ss"); dstr = dstr.Replace(" ", "%20"); //string guid=Guid.NewGuid().ToString(); //instance.SystemDataManager.DmExecuteNonQuery("insert into XT_LCRWYZ (id,guid,receivetime,action,keyvalue,userid) values ("+instance.GetNewID()+",'" + guid + "','"+nowString+"','0','" + taskId + "','"+userid+"')"); string content = title+"[请点击进入处理页面]"; return content; } public void WeChatSend(DataManager dm,string sendTo,string content) { int contentMaxLength = 500; if (content.Length > contentMaxLength) content = content.Substring(0, contentMaxLength); DataTable dt = dm.ExecuteTable("select ID,SENDTO ,WXCONTENT from XT_WX_Outbox where 1=2"); DataRow row = dt.NewRow(); dt.Columns["ID"].AutoIncrement = true; row["SENDTO"] = sendTo; row["WXCONTENT"] = content; dt.Rows.Add(row); dm.Operator.Append(dt, "XT_WX_Outbox"); } public bool IsReusable { get { return false; } } }