private DataTable GetDataRow(DataTable dt, SM.YuQing.Model.Regions region, string reg, string strWhere) { int positive = 0, negative = 0, neutral = 0, empty = 0; try { DataRow dr = dt.NewRow(); dr["Region"] = region == null?reg:region.Mall; SM.YuQing.BLL.MonitorInfos monitorInfoBll = new SM.YuQing.BLL.MonitorInfos(); List <SM.YuQing.Model.MonitorInfos> monitorInfoList = monitorInfoBll.GetModelList(strWhere + " and Keyword like \'SM\'"); foreach (SM.YuQing.Model.MonitorInfos monitorInfo in monitorInfoList) { switch (monitorInfo.Property) { case "正面": positive++; break; case "负面": negative++; break; case "中性": neutral++; break; case "": empty++; break; } } dr["Positive"] = positive.ToString(); dr["Negative"] = negative.ToString(); dr["Neutral"] = neutral.ToString(); dr["Empty"] = empty.ToString(); dr["Total"] = (positive + negative + neutral + empty).ToString(); dt.Rows.Add(dr); } catch (Exception ex) { DataRow dr = dt.NewRow(); dr["Region"] = "Error in GetDataRow():" + ex.Message;; dr["Positive"] = ""; dr["Negative"] = ""; dr["Neutral"] = ""; dr["Empty"] = ""; dr["Total"] = ""; dt.Rows.Add(dr); } 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 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 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)); } }