コード例 #1
0
        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));
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(context.User.Identity.Name)).Identity;
            string personid = identity.FID.ToString();

            SM.YuQing.BLL.Regions regbll = new SM.YuQing.BLL.Regions();
            string regionid = regbll.GetRegionIdByPersonID(personid);

            SM.YuQing.BLL.Regions bll = new SM.YuQing.BLL.Regions();
            //DataTable dt = bll.GetAllList().Tables[0];
            List <SM.YuQing.Model.Regions> lst = bll.GetModelList(" ID in (" + regionid + ")");

            context.Response.Write(JsonConvert.SerializeObject(lst));
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: webs3c/CSharp-YuQing
        void Global_ExecuteTask(object sender, System.Timers.ElapsedEventArgs e)
        {
            SM.YuQing.BLL.Regions          bllRegions = new SM.YuQing.BLL.Regions();
            List <SM.YuQing.Model.Regions> regions    = bllRegions.GetModelList("");

            SM.YuQing.BLL.MonitorInfos bllInfos = new SM.YuQing.BLL.MonitorInfos();

            SM.YuQing.BLL.Config bllConfig = new SM.YuQing.BLL.Config();
            int searchLevel = bllConfig.GetSearchLevels();

            foreach (SM.YuQing.Model.Regions region in regions)
            {
                //每天下午16点监测一次
                if (DateTime.Now.Hour == 16)
                {
                    bllInfos.GetMonitorInfos(region, region.Keyword, searchLevel);
                }

                //每小时监测一次
                bllInfos.GetMonitorInfos(region, "SM", searchLevel);
            }

            //foreach (SM.YuQing.Model.MonitorInfos item in infos)
            //{
            //    bllInfos.Add(item);
            //}

            //SM.YuQing.BLL.MonitorWebs bllwebs = new SM.YuQing.BLL.MonitorWebs();
            ////SM.YuQing.Model.MonitorWebs modelwebs = bllwebs.GetModel(7);
            //List<SM.YuQing.Model.MonitorWebs> webs = bllwebs.GetModelList("");
            //SM.YuQing.BLL.MonitorInfos bllinfos = new SM.YuQing.BLL.MonitorInfos();
            //List<SM.YuQing.Model.MonitorInfos> infos = bllinfos.GetMonitorInfos(webs, "SM");
            //foreach (SM.YuQing.Model.MonitorInfos item in infos)
            //{
            //    bllinfos.Add(item);
            //}
        }
コード例 #4
0
ファイル: DoSearch.ashx.cs プロジェクト: webs3c/CSharp-YuQing
        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));
            }
        }
コード例 #5
0
ファイル: Export.aspx.cs プロジェクト: webs3c/CSharp-YuQing
        public void ExportToExcel()
        {
            string beginDate = Request.QueryString["beginDate"];
            string endDate   = Request.QueryString["endDate"];
            string regionid  = Request.QueryString["RegionId"];

            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 = "";

                if (beginDate != "" && endDate != "")
                {
                    strWhere = " PublishDate>=\'" + beginDate + "\' and PublishDate<=\'" + endDate + " 23:59:59.999\'";
                    if (regionid != "")
                    {
                        string[] regs = regionid.Split(',');
                        foreach (string regid in regs)
                        {
                            strWhere += " 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 += " 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());
                        }
                    }
                }

                Response.Clear();
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", "StatisticsResult.xls"));
                Response.ContentType = "application/ms-excel";

                MemoryStream ms        = new MemoryStream();
                Workbook     workbook  = new Workbook();
                Worksheet    worksheet = new Worksheet("Sheet1");

                if (dt.Rows.Count < 30)
                {
                    for (int i = 0; i < 30; i++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Region"]   = "";
                        dr["Positive"] = "";
                        dr["Negative"] = "";
                        dr["Neutral"]  = "";
                        dr["Empty"]    = "";
                        dr["Total"]    = "";
                        dt.Rows.Add(dr);
                    }
                }

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    worksheet.Cells[0, i] = new Cell(dt.Columns[i].ColumnName);
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        worksheet.Cells[i + 1, j] = new Cell(dt.Rows[i][j].ToString());
                    }
                }

                workbook.Worksheets.Add(worksheet);
                workbook.SaveToStream(ms);
                Response.BinaryWrite(ms.ToArray());
                Response.Flush();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }