Ejemplo n.º 1
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.MonitorWebs   bll = new SM.YuQing.BLL.MonitorWebs();
            SM.YuQing.Model.MonitorWebs web = bll.GetModel(id);
            context.Response.Write(JsonConvert.SerializeObject(web));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 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.MonitorWebs   bll = new SM.YuQing.BLL.MonitorWebs();
            SM.YuQing.Model.MonitorWebs web = bll.GetModel(Convert.ToInt32(id));
            string url = web.Url, name = web.Name;

            bool      success = bll.Delete(Convert.ToInt32(id));
            Hashtable ht = new Hashtable();

            if (success)
            {
                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "操作";
                log.Message    = context.User.Identity.Name + " 删除了网站 " + url + "(" + name + ")";;
                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", "Some errors occured.");
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  BasicMethod

        #region  ExtensionMethod

        public void GetMonitorInfos(Model.Regions region, string keywords, int searchLevel)
        {
            List <Model.MonitorInfos> infos = new List <Model.MonitorInfos>();

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

            RealTimeMonitorHelper rtmh = new RealTimeMonitorHelper();

            string[] keywordArray = keywords.Split('、');

            //foreach(Model.Regions region in regions)
            {
                SM.YuQing.BLL.MonitorWebs          bllWebs = new SM.YuQing.BLL.MonitorWebs();
                List <SM.YuQing.Model.MonitorWebs> webs    = bllWebs.GetModelList(" RegionID=" + region.ID.ToString());

                foreach (Model.MonitorWebs web in webs)
                {
                    foreach (string keyword in keywordArray)
                    {
                        if (searchLevel == 1)
                        {
                            dt = rtmh.GetDataRows(dt, web.Url, keyword.Trim(), region, web);
                        }
                        else if (searchLevel == 2)
                        {
                            dt = rtmh.GetData(dt, web.Url, keyword, region, web);
                        }
                    }

                    //string keys = null;
                    //if (keywords != null)
                    //{
                    //    keys = keywords;
                    //}
                    //else
                    //{
                    //    Model.Regions region = bllRegions.GetModel(web.RegionID);
                    //    keys = region.Keyword;
                    //}
                    //string[] arrayKeys = keys.Split(new char[] {'、'});

                    //string content = getRequest(web.Url);
                    //content = System.Text.RegularExpressions.Regex.Replace(content, @"<!--(.|[\r\n])*?-->", "");
                    //while (content.Contains("<a"))
                    //{
                    //    try
                    //    {
                    //        content = content.Remove(0, content.IndexOf("<a"));
                    //        string link = content.Substring(0, content.IndexOf("</a>") + 4);
                    //        content = content.Remove(0, content.IndexOf("</a>") + 4);

                    //        string url = GetUrlFromLink(link);

                    //        string text = ReplaceHtmlTag(link);
                    //        string matchkey = GetMatchKey(text, arrayKeys);

                    //        if (matchkey != "" && url != "")
                    //        {
                    //            Model.MonitorInfos info = new Model.MonitorInfos();
                    //            info.Title = text;
                    //            info.Url = url.Contains("http://") ? url : web.Url + url;
                    //            info.PublishDate = DateTime.Now;
                    //            info.ViewsCounts = 0;
                    //            info.RegionID = web.RegionID;
                    //            info.MonitorUrl = web.Url;
                    //            info.Keyword = matchkey;
                    //            info.Property = "";
                    //            info.CreatePerson = "";
                    //            info.CreateTime = DateTime.Now;
                    //            info.UpdatePerson = "";
                    //            info.UpdateTime = DateTime.Now;
                    //            if (!Exists(info))
                    //            {
                    //                infos.Add(info);
                    //            }
                    //        }
                    //    }
                    //    catch { }
                    //}
                }
            }

            //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++;
                    }
                }
            }

            //写入数据库表MonitorInfo
            int count = rtmh.RecordToDatabase(dt, "System");

            //写入数据库表Log
            if (count != 0)
            {
                SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                log.LogType    = "后台";
                log.Message    = "本次共新增 " + count.ToString() + " 条数据(" + region.Mall + ")";
                log.IP         = "";
                log.MenuID     = 0;
                log.PersonID   = 0;
                log.CreateTime = DateTime.Now;
                SM.YuQing.BLL.Log logBll = new SM.YuQing.BLL.Log();
                logBll.Add(log);
            }
            //return infos;
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            string id       = context.Request.QueryString["id"];
            string Url      = context.Request.Form["Url"];
            string Name     = context.Request.Form["Name"];
            string RegionID = context.Request.Form["RegionID"];
            string Status   = context.Request.Form["Status"];
            string errMsg   = "";
            bool   success;

            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;

            if (id == null) //新增
            {
                SM.YuQing.BLL.MonitorWebs bll = new SM.YuQing.BLL.MonitorWebs();
                if (!bll.ExistWeb(Convert.ToInt32(RegionID), Url, Status))
                {
                    SM.YuQing.Model.MonitorWebs web = new SM.YuQing.Model.MonitorWebs();
                    web.Url          = Url;
                    web.Name         = Name;
                    web.RegionID     = Convert.ToInt32(RegionID);
                    web.Status       = Status;
                    web.CreatePerson = context.User.Identity.Name;
                    web.CreateTime   = DateTime.Now;
                    web.UpdatePerson = context.User.Identity.Name;
                    web.UpdateTime   = DateTime.Now;

                    success = bll.Add(web);
                    if (success)
                    {
                        SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                        log.LogType    = "操作";
                        log.Message    = context.User.Identity.Name + " 新增了网站 " + Url + "(" + Name + ")";
                        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.BLL.MonitorWebs   bll = new SM.YuQing.BLL.MonitorWebs();
                SM.YuQing.Model.MonitorWebs web = bll.GetModel(Convert.ToInt32(id));
                string oldUrl = web.Url, oldName = web.Name, oldRegionID = web.RegionID.ToString(), oldStatus = web.Status;

                web.Url      = Url;
                web.Name     = Name;
                web.RegionID = Convert.ToInt32(RegionID);
                web.Status   = Status;

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

                if (oldUrl == Url && oldName == Name && oldRegionID == RegionID && oldStatus == Status)
                {
                    success = false;
                    errMsg  = "您未修改任何信息";
                }
                else if (oldUrl == Url && oldName != Name && oldRegionID == RegionID && oldStatus == Status)
                {
                    success = bll.Update(web);
                }
                else if (!bll.ExistWeb(Convert.ToInt32(RegionID), Url, Status))
                {
                    success = bll.Update(web);
                }
                else
                {
                    success = false;
                    errMsg  = "该网址已存在于此区域中!";
                }

                if (success)
                {
                    SM.YuQing.Model.Log log = new SM.YuQing.Model.Log();
                    log.LogType    = "操作";
                    log.Message    = context.User.Identity.Name + " 修改了ID=" + id + "的网站信息" + " | " + (oldUrl == Url ? "" : (oldUrl + " -> " + Url + " | ")) + (oldName == Name ? "" : (oldName + " -> " + Name + " | ")) + (oldRegionID == RegionID ? "" : ("RegionID: " + oldRegionID + " -> " + RegionID + " | ")) + (oldStatus == Status ? "" : (oldStatus + " -> " + Status + " | "));
                    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 if (!success && errMsg == "")
                {
                    errMsg = "some error occured.";
                }
            }

            Hashtable ht = new Hashtable();

            if (success)
            {
                ht.Add("success", true);
            }
            else
            {
                ht.Add("errorMsg", errMsg);
            }
            context.Response.Write(JsonConvert.SerializeObject(ht));
        }