Beispiel #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(SM.YuQing.Model.Log model)
 {
     return(dal.Add(model));
 }
Beispiel #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(SM.YuQing.Model.Log model)
 {
     return(dal.Update(model));
 }
Beispiel #3
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;
        }