using FangYar.Common; using FangYar.Model.OA; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Runtime.Serialization; using System.Web; namespace FangYar.WebUI.ashx { /// /// 定时发送提醒信息 /// public class TaskRemindInfoHandler : IHttpHandler { int dateDiffer =Convert.ToInt32(ConfigurationManager.AppSettings["DateDiffer"]); BLL.OA.OA_TASKREMINDINFO taskRemindInfo = new BLL.OA.OA_TASKREMINDINFO(); BLL.OA.OA_REMINDMESSAGE remindMsg = new BLL.OA.OA_REMINDMESSAGE(); RemindMessageHandler remindMsgHangler = new RemindMessageHandler(); public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var action = context.Request.Params["Action"]; } /// /// 轮询任务记录表,发送信息 /// /// public string RollingTaskRemindInfo() { string startTime = DateTime.Now.ToString(); string endTime = DateTime.Now.AddMinutes(10).ToString(); string where = " STATE=0 and LASTREMINDTIME >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s') and LASTREMINDTIME <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')"; var list = taskRemindInfo.GetModelList(where); OA_REMINDMESSAGE entityRemindMsg; if (list.Count > 0) { for (int i = 0; i < list.Count; i++) { if (TimeFormatter.DateDiffHours(DateTime.Now, list[i].LASTREMINDTIME) > dateDiffer) { entityRemindMsg = new OA_REMINDMESSAGE(); entityRemindMsg.CATEGORY = list[i].TASKCATEGORY; entityRemindMsg.CONTENT = ""; entityRemindMsg.CREATEDATE =Convert.ToDateTime(DateTime.Now.ToString("G")); entityRemindMsg.ISDELETE = "0"; entityRemindMsg.MSGTYPE = ""; entityRemindMsg.PHONE = ""; entityRemindMsg.RECEIVER = ""; entityRemindMsg.SENDTIME= Convert.ToDateTime(DateTime.Now.ToString("G")); entityRemindMsg.STATE = "0"; //remindMsg.Add(entityRemindMsg); remindMsgHangler.WriteRemindMsg(entityRemindMsg); remindMsgHangler.SendShortMsg(); } } } return ""; } public bool IsReusable { get { return false; } } } }