Пример #1
0
        public string GetRegionID()
        {
            SM.YuQing.Accounts.SiteIdentity identity = (SM.YuQing.Accounts.SiteIdentity)(new SM.YuQing.Accounts.AccountsPrincipal(HttpContext.Current.User.Identity.Name)).Identity;
            string personid = identity.FID.ToString();

            SM.YuQing.BLL.Regions regbll = new SM.YuQing.BLL.Regions();
            return(regbll.GetRegionIdByPersonID(personid));
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();
            int id = Convert.ToInt32(context.Request.QueryString["id"]);

            SM.YuQing.BLL.Regions   bll    = new SM.YuQing.BLL.Regions();
            SM.YuQing.Model.Regions region = bll.GetModel(id);
            context.Response.Write(JsonConvert.SerializeObject(region));
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Form["id"];

            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;
            int personid = identity.FID;

            SM.YuQing.BLL.Regions   bll    = new SM.YuQing.BLL.Regions();
            SM.YuQing.Model.Regions region = bll.GetModel(Convert.ToInt32(id));
            string mall = region.Mall;

            bool success;

            SM.YuQing.BLL.MonitorWebs  webBll  = new SM.YuQing.BLL.MonitorWebs();
            SM.YuQing.BLL.MonitorInfos infoBll = new SM.YuQing.BLL.MonitorInfos();
            if (!bll.ExistRegion(Convert.ToInt32(id), personid) && !webBll.ExistRegion(Convert.ToInt32(id)) && !infoBll.ExistRegion(Convert.ToInt32(id)))
            {
                bll.Delete(Convert.ToInt32(id));
                bll.DeletePersonRegion(personid, Convert.ToInt32(id));
                success = true;
            }
            else
            {
                success = false;
            }

            Hashtable ht = new Hashtable();

            if (success)
            {
                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = context.User.Identity.Name + " 删除了区域 " + mall;
                log.IP         = context.Request.UserHostAddress;
                log.MenuID     = 0;
                log.PersonID   = personid;
                log.CreateTime = DateTime.Now;
                SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                logBll.Add(log);

                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", "该区域已有关联监测数据,不允许删除");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
Пример #4
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));
        }
Пример #5
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));
        }
Пример #6
0
        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);
            //}
        }
Пример #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            //List<SM.YuQing.Model.MonitorWebs> lst = bll.GetModelList("");
            //context.Response.Write(JsonConvert.SerializeObject(lst));

            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.MonitorWebs bll = new SM.YuQing.BLL.MonitorWebs();
            DataTable dt = bll.GetList(" RegionID in (" + regionid + ")").Tables[0], retDt = new DataTable();

            retDt.Columns.Add("ID");
            retDt.Columns.Add("Region");
            retDt.Columns.Add("Name");
            retDt.Columns.Add("Url");
            retDt.Columns.Add("Status");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                SM.YuQing.Model.Regions region    = regionBll.GetModel(Convert.ToInt32(dt.Rows[i]["RegionID"]));
                DataRow dr = retDt.NewRow();
                dr["ID"]     = dt.Rows[i]["ID"];
                dr["Region"] = region.Region;
                dr["Name"]   = dt.Rows[i]["Name"];
                dr["Url"]    = dt.Rows[i]["Url"];
                dr["Status"] = dt.Rows[i]["Status"];
                retDt.Rows.Add(dr);
            }
            context.Response.Write(JsonConvert.SerializeObject(retDt));
        }
Пример #8
0
        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));
            }
        }
Пример #9
0
        public void ProcessRequest(HttpContext context)
        {
            string    id      = context.Request.QueryString["id"];
            string    Region  = context.Request.Form["Region"];
            string    Mall    = context.Request.Form["Mall"];
            string    Keyword = context.Request.Form["Keyword"];
            string    errMsg  = "";
            bool      success;
            Hashtable ht = new Hashtable();

            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;
            int personid = identity.FID;

            SM.YuQing.BLL.Regions bll = new SM.YuQing.BLL.Regions();
            if (id == null)
            {
                if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
                {
                    SM.YuQing.Model.Regions region = new SM.YuQing.Model.Regions();
                    region.Region       = Region;
                    region.Mall         = Mall;
                    region.Keyword      = Keyword;
                    region.CreatePerson = context.User.Identity.Name;
                    region.CreateTime   = DateTime.Now;
                    region.UpdatePerson = context.User.Identity.Name;
                    region.UpdateTime   = DateTime.Now;

                    success = bll.Add(region);

                    if (success)
                    {
                        int maxRegionID = bll.GetMaxRegionID(context.User.Identity.Name);
                        bll.AddPersonRegion(personid, maxRegionID);

                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 新增了区域 " + Mall;
                        log.IP         = context.Request.UserHostAddress;
                        log.MenuID     = 0;
                        log.PersonID   = personid;
                        log.CreateTime = DateTime.Now;
                        SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                        logBll.Add(log);
                    }
                    else
                    {
                        success = false;
                        errMsg  = "some error occured.";
                    }
                }
                else
                {
                    success = false;
                    errMsg  = "此区域已存在";
                }
            }
            else
            {
                SM.YuQing.Model.Regions region = bll.GetModel(Convert.ToInt32(id));
                string oldRegion = region.Region, oldMall = region.Mall, oldKeyword = region.Keyword;

                if (oldRegion == Region && oldMall == Mall && oldKeyword == Keyword)
                {
                    success = false;
                    errMsg  = "您未修改任何信息";
                }
                else if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
                {
                    region.Region  = Region;
                    region.Mall    = Mall;
                    region.Keyword = Keyword;

                    region.UpdatePerson = context.User.Identity.Name;
                    region.UpdateTime   = DateTime.Now;

                    success = bll.Update(region);

                    if (success)
                    {
                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 修改了ID=" + id + "的区域信息" + " | " + (oldRegion == Region ? "" : (oldRegion + " -> " + Region + " | ")) + (oldMall == Mall ? "" : (oldMall + " -> " + Mall + " | ")) + (oldKeyword == Keyword ? "" : ("关键字 | "));
                        log.IP         = context.Request.UserHostAddress;
                        log.MenuID     = 0;
                        log.PersonID   = personid;
                        log.CreateTime = DateTime.Now;
                        SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                        logBll.Add(log);
                    }
                    else
                    {
                        success = false;
                        errMsg  = "some error occured.";
                    }
                }
                else
                {
                    success = false;
                    errMsg  = "此区域已存在";
                }
            }
            //if (!bll.ExistRegion(Region.Trim(), Mall.Trim(), Keyword.Trim()))
            //{

            //}
            //else
            //{
            //    success = false;
            //    errMsg = "此区域已存在";
            //}

            if (success)
            {
                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", errMsg);
            }

            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
Пример #10
0
        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));
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
        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));
            }
        }
Пример #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Cache.SetNoStore();

            string regionid = context.Request.QueryString["regionid"];
            string status   = context.Request.QueryString["status"];

            DataTable dt = new DataTable();

            dt.Columns.Add("ID");
            dt.Columns.Add("Url");
            dt.Columns.Add("Name");
            dt.Columns.Add("Region");
            dt.Columns.Add("Status");

            try
            {
                string    strWhere     = "";
                ArrayList strWhereList = new ArrayList();

                if (regionid != "" && regionid != null)
                {
                    strWhereList.Add("  RegionID=" + regionid);
                }
                else
                {
                    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();
                    regionid = regbll.GetRegionIdByPersonID(personid);
                    strWhereList.Add(" RegionID in (" + regionid + ")");
                }
                if (status != "" && status != null)
                {
                    strWhereList.Add(" Status=N\'" + status + "\'");
                }

                switch (strWhereList.Count)
                {
                case 1:
                    strWhere = strWhereList[0].ToString();
                    break;

                case 2:
                    strWhere = strWhereList[0].ToString() + " and " + strWhereList[1].ToString();
                    break;

                default:
                    break;
                }

                SM.YuQing.BLL.MonitorWebs          webBll  = new SM.YuQing.BLL.MonitorWebs();
                List <SM.YuQing.Model.MonitorWebs> webList = webBll.GetModelList(strWhere);
                foreach (SM.YuQing.Model.MonitorWebs web in webList)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]   = web.ID;
                    dr["Url"]  = web.Url;
                    dr["Name"] = web.Name;
                    SM.YuQing.BLL.Regions   regionBll = new SM.YuQing.BLL.Regions();
                    SM.YuQing.Model.Regions region    = regionBll.GetModel(web.RegionID);
                    dr["Region"] = region.Region;
                    dr["Status"] = web.Status;
                    dt.Rows.Add(dr);
                }

                if (dt.Rows.Count == 0)
                {
                    DataRow dr = dt.NewRow();
                    dr["ID"]     = "";
                    dr["Url"]    = "未查询到数据";
                    dr["Name"]   = "";
                    dr["Region"] = "";
                    dr["Status"] = "";
                    dt.Rows.Add(dr);
                }

                context.Response.Write(JsonConvert.SerializeObject(dt));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #14
0
        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;
            }
        }