public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); //string func = context.Request.QueryString["func"]; GetRegionIdHelper grih = new GetRegionIdHelper(); string regionid = grih.GetRegionID(); SM.YuQing.BLL.Regions bll = new SM.YuQing.BLL.Regions(); List <SM.YuQing.Model.Regions> lst = bll.GetModelList(" ID in (" + regionid + ")"); context.Response.Write(JsonConvert.SerializeObject(lst)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); string regionid = context.Request.QueryString["regionid"], reg = ""; string beginDate = context.Request.QueryString["beginDate"]; string endDate = context.Request.QueryString["endDate"]; string property = context.Request.QueryString["property"]; string func = context.Request.QueryString["func"]; if (regionid == "" || regionid.Contains("-1")) { GetRegionIdHelper grih = new GetRegionIdHelper(); regionid = grih.GetRegionID(); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); dt.Columns.Add("PublishDate"); dt.Columns.Add("ViewsCounts"); dt.Columns.Add("Region"); dt.Columns.Add("Property"); dt.Columns.Add("Url"); try { string strWhere = ""; ArrayList strWhereList = new ArrayList(); strWhereList.Add(" RegionID in (" + regionid + ")"); strWhereList.Add(" Keyword like \'SM\'"); if (beginDate != "" && endDate != "") { strWhereList.Add(" PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'"); } if (property != "" && !property.Contains("全部")) { //strWhereList.Add(" Property=N\'" + (property == "空" ? "" : property) + "\'"); //" (Property=N\'" + (p == "空" ? "" : p) + "\' or Property=N\'" + p + "\'") string[] props = property.Split(','); string tmpSql = ""; foreach (string p in props) { tmpSql += " or Property=N\'" + (p == "空" ? "" : p) + "\'"; } tmpSql = tmpSql.Substring(tmpSql.IndexOf("or") + 2, tmpSql.Length - 3); strWhereList.Add(" (" + tmpSql + ") "); } switch (strWhereList.Count) { case 2: strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString(); break; case 3: strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString(); break; case 4: strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString() + " and " + strWhereList[3].ToString(); break; default: break; } SM.YuQing.BLL.MonitorInfos monitorInfoBll = new SM.YuQing.BLL.MonitorInfos(); List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere); foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList) { DataRow dr = dt.NewRow(); dr["ID"] = monitorInfo.ID; dr["Title"] = monitorInfo.Title; dr["PublishDate"] = monitorInfo.PublishDate.ToString("yyyy-MM-dd"); dr["ViewsCounts"] = monitorInfo.ViewsCounts; if (monitorInfo.RegionID > 0) { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); SM.YuQing.Model.Regions region = regionBll.GetModel(Convert.ToInt32(monitorInfo.RegionID)); reg = region.Mall; } else { reg = ""; } dr["Region"] = reg; dr["Property"] = monitorInfo.Property; dr["Url"] = monitorInfo.Url; dt.Rows.Add(dr); } if (dt.Rows.Count == 0) { DataRow dr = dt.NewRow(); dr["ID"] = ""; dr["Title"] = "未查询到数据"; dr["PublishDate"] = ""; dr["ViewsCounts"] = ""; dr["Region"] = ""; dr["Property"] = ""; dr["Url"] = ""; dt.Rows.Add(dr); } //context.Response.Write("<script>lert(\'ManageInfos.DoSearch\');</script>"); } catch (Exception ex) { throw ex; //DataRow dr = dt.NewRow(); //dr["ID"] = ""; //dr["Title"] = "Error in ProcessRequest():" + ex.Message; //dr["PublishDate"] = ""; //dr["ViewsCounts"] = ""; //dr["Region"] = ""; //dr["Property"] = ""; //dr["Url"] = ""; //dt.Rows.Add(dr); } if (func == "1") //导出excel { ExportToExcelHelper eteh = new ExportToExcelHelper(); eteh.ExportToExcel(dt, "ManageInfoResult.xls", "[监测管理] -> [监测数据管理]"); } else { context.Response.Write(JsonConvert.SerializeObject(dt)); } }
public DataTable RealTimeMonitor(HttpContext context, int level) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); string regionid = context.Request.QueryString["regionid"]; string keyword = context.Request.QueryString["keyword"]; string website = context.Request.QueryString["website"]; string searchLevel = context.Request.QueryString["sl"]; string func = context.Request.QueryString["func"]; if (regionid == "" || regionid.Contains("-1")) { GetRegionIdHelper grih = new GetRegionIdHelper(); regionid = grih.GetRegionID(); } //keyword = System.Web.HttpUtility.UrlDecode(keyword); DataTable dt = new DataTable(); dt.Columns.Add("Title"); dt.Columns.Add("PublishDate"); dt.Columns.Add("ViewsCounts"); dt.Columns.Add("Region"); dt.Columns.Add("RegionID"); dt.Columns.Add("MonitorUrl"); dt.Columns.Add("Keyword"); dt.Columns.Add("Url"); SM.YuQing.BLL.RealTimeMonitorHelper rtmh = new SM.YuQing.BLL.RealTimeMonitorHelper(); try { if (website != "") { //dt = RemoveCommonRecord(rtmh.GetDataRows(dt, website, keyword, null, null)); //searchLevel 搜索级别 if (searchLevel == "1") { dt = rtmh.GetDataRows(dt, website, keyword, null, null); } else if (searchLevel == "2") { dt = rtmh.GetData(dt, website, keyword, null, null); } } else { string[] regs = regionid.Split(','); foreach (string reg in regs) { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); SM.YuQing.Model.Regions region = regionBll.GetModel(Convert.ToInt32(reg.Trim())); SM.YuQing.BLL.MonitorWebs webBll = new SM.YuQing.BLL.MonitorWebs(); List <SM.YuQing.Model.MonitorWebs> webList = webBll.GetModelList("RegionID=" + reg.Trim()); foreach (SM.YuQing.Model.MonitorWebs web in webList) { if (web.Status == "启用") { if (searchLevel == "1") { dt = rtmh.GetDataRows(dt, web.Url, keyword, region, web); } else if (searchLevel == "2") { dt = rtmh.GetData(dt, web.Url, keyword, region, web); } } } } } if (dt.Rows.Count == 0) { DataRow dr = dt.NewRow(); dr["Title"] = "未匹配到关键字“" + keyword + "”"; dr["PublishDate"] = ""; dr["ViewsCounts"] = ""; dr["Region"] = ""; dr["RegionID"] = ""; dr["MonitorUrl"] = ""; dr["Keyword"] = ""; dr["Url"] = ""; dt.Rows.Add(dr); } else { //DataTable去重 int rowsCount = dt.Rows.Count; for (int i = 0; i < rowsCount - 1; i++) { for (int j = i + 1; j < rowsCount;) { if (dt.Rows[i]["Url"].ToString() == dt.Rows[j]["Url"].ToString()) { dt.Rows.RemoveAt(j); rowsCount--; dt.AcceptChanges(); } else { j++; } } } if (func != "1") { //写入数据库 rtmh.RecordToDatabase(dt, context.User.Identity.Name); //写入日志Log SM.YuQing.Model.Log log = new SM.YuQing.Model.Log(); log.LogType = "实时监测"; log.Message = "本次共新增 " + dt.Rows.Count.ToString() + " 条数据"; log.IP = context.Request.UserHostAddress; log.MenuID = 0; log.PersonID = 0; log.CreateTime = DateTime.Now; SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log(); logBll.Add(log); } } } catch (Exception ex) { throw ex; //DataRow dr = dt.NewRow(); //dr["Title"] = "Error in ProcessRequest():" + ex.Message; //dr["PublishDate"] = ""; //dr["ViewsCounts"] = ""; //dr["Region"] = ""; //dr["RegionID"] = ""; //dr["MonitorUrl"] = ""; //dr["Keyword"] = ""; //dr["Url"] = ""; //dt.Rows.Add(dr); } if (func == "1") //导出excel { ExportToExcelHelper eteh = new ExportToExcelHelper(); eteh.ExportToExcel(dt, "RealTimeResult.xls", "[监测管理] -> [实时监测]"); } else { context.Response.Write(JsonConvert.SerializeObject(dt)); } return(dt); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); string regionid = context.Request.QueryString["regionid"], reg = ""; string beginDate = context.Request.QueryString["beginDate"]; string endDate = context.Request.QueryString["endDate"]; string keyword = context.Request.QueryString["keyword"]; string func = context.Request.QueryString["func"]; if (regionid == "" || regionid.Contains("-1")) { GetRegionIdHelper grih = new GetRegionIdHelper(); regionid = grih.GetRegionID(); } DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Title"); dt.Columns.Add("PublishDate"); dt.Columns.Add("ViewsCounts"); dt.Columns.Add("Keyword"); dt.Columns.Add("Region"); dt.Columns.Add("Url"); try { string strWhere = ""; ArrayList strWhereList = new ArrayList(); if (beginDate != "" && endDate != "") { strWhereList.Add(" PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'"); } if (regionid != "") { strWhereList.Add(" RegionID in (" + regionid + ")"); } if (keyword != "") { strWhereList.Add(" Keyword like N\'%" + keyword + "%\'"); } switch (strWhereList.Count) { case 1: strWhere = strWhereList[0].ToString(); break; case 2: strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString(); break; case 3: strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString() + " and " + strWhereList[2].ToString(); break; default: break; } SM.YuQing.BLL.MonitorInfos monitorInfoBll = new SM.YuQing.BLL.MonitorInfos(); List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere); foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList) { DataRow dr = dt.NewRow(); dr["ID"] = monitorInfo.ID; dr["Title"] = monitorInfo.Title; dr["PublishDate"] = monitorInfo.PublishDate.ToString("yyyy-MM-dd"); dr["ViewsCounts"] = monitorInfo.ViewsCounts; dr["Keyword"] = monitorInfo.Keyword; if (monitorInfo.RegionID > 0) { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); SM.YuQing.Model.Regions region = regionBll.GetModel(Convert.ToInt32(monitorInfo.RegionID)); reg = region.Mall; } else { reg = ""; } dr["Region"] = reg; dr["Url"] = monitorInfo.Url; dt.Rows.Add(dr); } if (dt.Rows.Count == 0) { DataRow dr = dt.NewRow(); dr["ID"] = ""; dr["Title"] = "未查询到数据"; dr["PublishDate"] = ""; dr["ViewsCounts"] = ""; dr["Keyword"] = ""; dr["Region"] = ""; dr["Url"] = ""; dt.Rows.Add(dr); } } catch (Exception ex) { throw ex; //DataRow dr = dt.NewRow(); //dr["Title"] = "Error in ProcessRequest():" + ex.Message; //dr["PublishDate"] = ""; //dr["ViewsCounts"] = ""; //dr["Keyword"] = ""; //dr["Region"] = ""; //dr["Url"] = ""; //dt.Rows.Add(dr); } if (func == "1") //导出excel { ExportToExcelHelper eteh = new ExportToExcelHelper(); eteh.ExportToExcel(dt, "IndustryResult.xls", "[监测管理] -> [行业监测]"); } else { context.Response.Write(JsonConvert.SerializeObject(dt)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Cache.SetNoStore(); string regionid = context.Request.QueryString["RegionId"]; string beginDate = context.Request.QueryString["beginDate"]; string endDate = context.Request.QueryString["endDate"]; string func = context.Request.QueryString["func"]; if (regionid == "" || regionid.Contains("-1")) { GetRegionIdHelper grih = new GetRegionIdHelper(); regionid = grih.GetRegionID(); } DataTable dt = new DataTable(); dt.Columns.Add("Region"); dt.Columns.Add("Positive"); dt.Columns.Add("Negative"); dt.Columns.Add("Neutral"); dt.Columns.Add("Empty"); dt.Columns.Add("Total"); try { string strWhere = ""; ArrayList strWhereList = new ArrayList(); //strWhereList.Add(" RegionID in (" + regionid + ")"); //strWhereList.Add(" Keyword like \'SM\'"); if (beginDate != "" && endDate != "") { if (regionid != "") { string[] regs = regionid.Split(','); foreach (string regid in regs) { strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'" + " and RegionID=" + regid; SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); SM.YuQing.Model.Regions region = regionBll.GetModel(Convert.ToInt32(regid)); dt = GetDataRow(dt, null, region.Mall, strWhere); } } else { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList(""); foreach (SM.YuQing.Model.Regions region in regionList) { strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'" + " and RegionID=" + region.ID; dt = GetDataRow(dt, region, "", strWhere); } } } else { if (regionid != "") { string[] regs = regionid.Split(','); foreach (string regid in regs) { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); SM.YuQing.Model.Regions region = regionBll.GetModel(Convert.ToInt32(regid)); dt = GetDataRow(dt, null, region.Mall, " RegionID=" + regid); } } else { SM.YuQing.BLL.Regions regionBll = new SM.YuQing.BLL.Regions(); List <SM.YuQing.Model.Regions> regionList = regionBll.GetModelList(""); foreach (SM.YuQing.Model.Regions region in regionList) { dt = GetDataRow(dt, region, "", " RegionID=" + region.ID.ToString()); } } } } catch (Exception ex) { throw ex; //DataRow dr = dt.NewRow(); //dr["Region"] = "Error in ProcessRequest():" + ex.Message; ; //dr["Positive"] = ""; //dr["Negative"] = ""; //dr["Neutral"] = ""; //dr["Empty"] = ""; //dr["Total"] = ""; //dt.Rows.Add(dr); } if (func == "1") //导出excel { ExportToExcelHelper eteh = new ExportToExcelHelper(); eteh.ExportToExcel(dt, "StatisticsResult.xls", "[监测管理] -> [监测性质统计表]"); } else { context.Response.Write(JsonConvert.SerializeObject(dt)); } }