/// <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); } }
/// <summary> /// 删除信息 /// </summary> /// <param name="context"></param> public void DelPublishInfo(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var infoReleaseDetails = new InfoReleaseDetailsDal(); var id = context.Request.Params["id"]; try { infoReleaseDal.Del(new PowerCut() { Id = id }); hashtable["isSuccess"] = true; hashtable["jsMethod"] = "ajax_DelPowerInfo"; 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); } } }
private void Query1(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var businesstype = context.Request.Params["key"]; var total = 0; var page = int.Parse(context.Request["page"] ?? "1"); var rows = int.Parse(context.Request["rows"] ?? "10"); try { var data = infoReleaseDal.QueryByPage(new PowerCut() { BusinessType = businesstype, }, page, rows, ref total); var list = ConvertHelper<PowerCut>.ConvertToList(data); hashtable["rows"] = list.ToList(); hashtable["total"] = total; hashtable["isSuccess"] = true; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { hashtable["isSuccess"] = false; var json = _jss.Serialize(hashtable); context.Response.Write(json); Log.Debug(e); } }
private void Query(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var businesstype = context.Request.Params["key"]; var tmp = context.Request["kssj"] ?? ""; var dateBegin = DateTime.Now.Date; var dateEnd = DateTime.MinValue; var dateTmp = DateTime.MinValue; if (!string.IsNullOrEmpty(tmp)) { dateTmp = DateTime.Parse(tmp); dateBegin = dateTmp; } tmp = context.Request["jssj"] ?? ""; if (!string.IsNullOrEmpty(tmp)) { dateTmp = DateTime.Parse(tmp); dateEnd = dateTmp; } try { var data = infoReleaseDal.Query(new PowerCut() { BusinessType = businesstype, DateBegin = dateBegin, DateEnd = dateEnd, State = "1", FlagRelease = "'2','3'", }); var list = ConvertHelper<PowerCut>.ConvertToList(data); hashtable["data"] = list.ToList(); hashtable["total"] = list.Count; hashtable["isSuccess"] = true; hashtable["jsMethod"] = "ajax_QueryMessageList"; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { hashtable["isSuccess"] = false; var json = _jss.Serialize(hashtable); context.Response.Write(json); Log.Debug(e); } }
private void GetInfo2(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var id = context.Request["id"] ?? ""; var key = context.Request["key"] ?? ""; try { var data = infoReleaseDal.QueryDataById(id, key); var list = ConvertHelper<PowerCut>.ConvertToList(data); hashtable["data"] = list.ToList(); hashtable["total"] = list.Count; hashtable["isSuccess"] = true; hashtable["jsMethod"] = "ajax_QueryDetailInfo"; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { hashtable["isSuccess"] = false; var json = _jss.Serialize(hashtable); context.Response.Write(json); Log.Debug(e); } }
/// <summary> /// 查询信息 /// </summary> /// <param name="httpContext"></param> public void QueryPublishInfo(HttpContext httpContext) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var businesstype = httpContext.Request.Params["businesstype"]; //获取分页数据 var total = 0; var page = int.Parse(httpContext.Request["page"] ?? "1"); var rows = int.Parse(httpContext.Request["rows"] ?? "10"); try { var data = infoReleaseDal.QueryByPage(new PowerCut() { BusinessType = businesstype }, page, rows, ref total); var list = ConvertHelper<PowerCut>.ConvertToList(data); hashtable["rows"] = list.ToList(); hashtable["total"] = total; var json = _jss.Serialize(hashtable); httpContext.Response.Write(json); } catch (Exception e) { Log.Debug("方法名:QueryPowerInfo,描述:查询停电信息方法出错,错误原因:" + e.Message); hashtable["isSuccess"] = false; var json = _jss.Serialize(hashtable); httpContext.Response.Write(json); } }
/// <summary> /// 查询故障停电和计划停电 /// </summary> /// <param name="context"></param> public void QueryMap(HttpContext context) { var hashtable = new Hashtable(); var infoReleaseDal = new PowerCutDal(); var businesstype = context.Request.Params["key"]; try { DateTime dateBegin; DateTime dateEnd; switch (businesstype) { //计划停电key case "011_youo_tdtz": dateBegin = DateTime.Now.Date; dateEnd = DateTime.Now.AddDays(7).Date; break; //故障停电key case "011_youo_tdtz2": dateBegin = DateTime.Now.AddDays(-3).Date; dateEnd = DateTime.Now.Date; break; default: return; } var data = infoReleaseDal.Query(new PowerCut() { BusinessType = businesstype, DateBegin = dateBegin, DateEnd = dateEnd, State = "1", FlagRelease = "'2','3'", }); var list = ConvertHelper<PowerCut>.ConvertToList(data); hashtable["data"] = list.ToList(); hashtable["key"] = businesstype; hashtable["isSuccess"] = true; hashtable["jsMethod"] = "ajax_QueryMap"; var json = _jss.Serialize(hashtable); context.Response.Write(json); } catch (Exception e) { hashtable["isSuccess"] = false; var json = _jss.Serialize(hashtable); context.Response.Write(json); Log.Debug(e); } }
/// <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); } }