/// <summary> /// 保存信息 /// </summary> /// <param name="context"></param> public void EditPublishInfo(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var id = context.Request.Params["id"]; var key = context.Request.Params["key"]; var title = context.Request.Params["title"]; var jd = context.Request.Params["jd"]; var wd = context.Request.Params["wd"]; var sm = context.Request.Params["sm"]; var state = context.Request["State"] ?? ""; var tmp = context.Request["PowerCutTime"] ?? ""; DateTime PowerCutTime = DateTime.Now; if (!string.IsNullOrEmpty(tmp)) { PowerCutTime = DateTime.Parse(tmp); } var timeArea = context.Request["TimeArea"] ?? ""; var area = context.Request["Area"] ?? ""; var device = context.Request["Device"] ?? ""; var infoRelease = new PowerCut(); infoRelease.Id = id; infoRelease.BusinessType = key; infoRelease.CreateDt = DateTime.Now; infoRelease.CreatePerson = ""; infoRelease.State = state; infoRelease.Title = title; infoRelease.PowerCutTime = PowerCutTime; infoRelease.TimeArea = timeArea; infoRelease.Area = area; infoRelease.Device = device; infoRelease.Jd = jd; infoRelease.Wd = wd; infoRelease.Description = sm; try { infoReleaseDal.Modify(infoRelease); hashtable["isSuccess"] = true; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { Log.Debug("方法名:SavePowerInfo,描述:保存停电信息方法出错,错误原因:" + e.Message); } }
public void Send() { while (true) { try { Log.Debug("主网、配网、监控 推送。"); InfoReleaseDal dal = new InfoReleaseDal(); DataTable dt = dal.QueryByTypes(new string[] { "3080_youo_zwtz", "3081_youo_pwtz", "3082_youo_jkxx" }); UserGroupDal userGroupDal = new UserGroupDal(); DataTable dtUser = userGroupDal.QueryInternalUser(); //发送:主网、配网、监控 foreach (DataRow row in dt.Rows) { Success = false; var title = row["Title"].ToString(); var MessageDescription = row["MaterialContent"].ToString(); //var content = "标题:" + title + "\n内容:" + MessageDescription + "\n发布人:" + row["CreatePerson"].ToString(); var content = "标题:" + title + "\n内容:" + MessageDescription + "\n\r 国网铜陵供电公司"; foreach (DataRow row1 in dtUser.Rows) { var openId = row1["openid"].ToString(); SendMsg(openId, content); } if (Success) { dal.Modify(new InfoRelease() { Id = row["id"].ToString(), FlagRelease = "2", }); } } PowerCutDal powerCutDal = new PowerCutDal(); DataTable dtPowerCut = powerCutDal.Query(new PowerCut() { State = "1", //未送电 FlagRelease = "'2'", //已发布 DateBegin = DateTime.Now.Date, DateEnd = DateTime.MaxValue.AddDays(-2), BusinessType = "011_youo_tdtz2", }); //发送:故障停电 Log.Debug("故障停电"); foreach (DataRow row in dtPowerCut.Rows) { Success = false; var content = "尊敬的电力客户:\n\r 因突发电力故障,安排以下故障抢修工作安排。未经铜陵供电公司有关部门许可,严禁任何单位和个人在停电线路及设备上工作。为此造成的不便,敬请各客户给予谅解和支持。如有任何疑问,请致电供电公司24小时服务热线95598。\n\r 停电时间:" + row["PowerCutTime"].ToString().Split(' ')[0] + " " + row["TimeArea"].ToString() + "\n\r 停电设备:" + row["Device"].ToString() + "\n\r 停电区域:" + row["Area"].ToString() + "\n\r 国网铜陵供电公司"; foreach (DataRow row1 in dtUser.Rows) { var openId = row1["openid"].ToString(); SendMsg(openId, content); } if (Success) { powerCutDal.Modify(new PowerCut() { Id = row["id"].ToString(), FlagRelease = "3", }); Log.Debug("修改状态为已推送--" + row["id"].ToString()); } } #region 发送最新资讯091_youo_zxzx var sendMessage = new SendMessage(); var listnews = new List<Articles>(); var articles = new Articles(); InfoReleaseDal infoReleaseDal = new InfoReleaseDal(); DataTable yhcsDt = infoReleaseDal.Query(new InfoRelease() { FlagRelease = "1", BusinessType = "091_youo_zxzx", }); DataTable userDt = new UserInfoDal().Query(new UserInfo());//获取所有关注的微信用户 WebServ.WebService1 service1 = new WebService1(); var token = service1.GetToken(); foreach (DataRow row in yhcsDt.Rows) { var id = row["id"].ToString(); var discrip = row["MessageDescription"].ToString(); if (discrip.Length > 200) { discrip = discrip.Substring(0, 190) + "..."; } articles = new Articles() { title = row["title"].ToString(), description = discrip, picurl = "http://60.173.29.191/UploadImages/091_youo_zxzx.jpg", url = "http://60.173.29.191/views/messagelist/messagedetail.htm?id=" + id, }; listnews.Add(articles); foreach (DataRow uRow in userDt.Rows) { var openid = uRow["openid"].ToString(); sendMessage.SendNewsMessage(token, openid, listnews); } infoReleaseDal.Modify(new InfoRelease() { Id = id, FlagRelease = "2", }); Log.Debug("最新资讯-修改状态为已推送--" + row["id"].ToString()); } #endregion Thread.Sleep(10000); } catch (Exception ex) { Log.Debug("发送故障" + ex); Thread.Sleep(100000); } } }
/// <summary> /// 发布信息到人(实际上只是修改了下发布状态,仅此而已) /// </summary> /// <param name="context"></param> public void PublishInfoToPerson(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var userInfoDal = new UserInfoDal(); var id = context.Request.Params["id"]; try { infoReleaseDal.Modify(new PowerCut() { Id = id, FlagRelease = "2" }); hashtable["isSuccess"] = true; hashtable["jsMethod"] = "ajax_PublishInfoToPerson"; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { Log.Debug("方法名:PublishInfoToPerson,,错误原因:" + e.Message); } }