Example #1
0
        /// <summary>保存网络蜘蛛列表</summary>
        /// <param name="ws">网络蜘蛛对象</param>
        public static void SaveWebSpiderTable(WebSpider ws)
        {
            string upath = wapp.AppList.SaveConfigPath + _WebSpiderTable.TableName + ".xml";

            if (ws != null)
            {
                DateTime  dqrq = DateTime.Now;
                DataRow[] dr   = _WebSpiderTable.Select("SpiderName='" + ws.SpiderName + "'");
                if (dr.Length > 0)
                {
                    dr[0]["UrlList"]               = ws.UrlList;
                    dr[0]["UrlRangeRule"]          = ws.UrlRangeRule;
                    dr[0]["UrlRule"]               = ws.UrlRule;
                    dr[0]["UrlRangeRuleIndex"]     = ws.UrlRangeRuleIndex;
                    dr[0]["UrlRuleIndex"]          = ws.UrlRuleIndex;
                    dr[0]["IsSaveHtml"]            = ws.IsSaveHtml;
                    dr[0]["HtmlSavePath"]          = ws.HtmlSavePath;
                    dr[0]["ExcelSavePath"]         = ws.ExcelSavePath;
                    dr[0]["OrderNum"]              = ws.OrderNum;
                    dr[0]["OperDate"]              = dqrq;
                    dr[0]["NextRangeRule"]         = ws.NextRangeRule;
                    dr[0]["NextRule"]              = ws.NextRule;
                    dr[0]["NextRangeRuleIndex"]    = ws.NextRangeRuleIndex;
                    dr[0]["NextRuleIndex"]         = ws.NextRuleIndex;
                    dr[0]["CodingMode"]            = ws.CodingMode;
                    dr[0]["UrlRangeRule"]          = ws.UrlRangeRule;
                    dr[0]["PageCoding"]            = ws.PageCoding;
                    dr[0]["GatherMaxNum"]          = ws.GatherMaxNum;
                    dr[0]["IsEcho"]                = ws.IsEcho;
                    dr[0]["IsNext"]                = ws.IsNext;
                    dr[0]["NextMode"]              = ws.NextMode;
                    dr[0]["ConNextRangeRule"]      = ws.ConNextRangeRule;
                    dr[0]["ConNextRule"]           = ws.ConNextRule;
                    dr[0]["ConNextRangeRuleIndex"] = ws.ConNextRangeRuleIndex;
                    dr[0]["ConNextRuleIndex"]      = ws.ConNextRuleIndex;
                    dr[0]["ConIsNext"]             = ws.ConIsNext;
                    dr[0]["ConNextMode"]           = ws.ConNextMode;
                    dr[0]["ConIsNext"]             = ws.ConIsNext;
                    dr[0]["ConNextMode"]           = ws.ConNextMode;
                }
                else
                {
                    DataRow newRow = _WebSpiderTable.NewRow();
                    newRow["SpiderID"]              = ws.SpiderID;
                    newRow["SpiderName"]            = ws.SpiderName;
                    newRow["UrlList"]               = ws.UrlList;
                    newRow["UrlRangeRule"]          = ws.UrlRangeRule;
                    newRow["UrlRule"]               = ws.UrlRule;
                    newRow["UrlRangeRuleIndex"]     = ws.UrlRangeRuleIndex;
                    newRow["UrlRuleIndex"]          = ws.UrlRuleIndex;
                    newRow["IsSaveHtml"]            = ws.IsSaveHtml;
                    newRow["HtmlSavePath"]          = ws.HtmlSavePath;
                    newRow["ExcelSavePath"]         = ws.ExcelSavePath;
                    newRow["OrderNum"]              = ws.OrderNum;
                    newRow["AddDate"]               = dqrq;
                    newRow["OperDate"]              = dqrq;
                    newRow["NextRangeRule"]         = ws.NextRangeRule;
                    newRow["NextRule"]              = ws.NextRule;
                    newRow["NextRangeRuleIndex"]    = ws.NextRangeRuleIndex;
                    newRow["NextRuleIndex"]         = ws.NextRuleIndex;
                    newRow["CodingMode"]            = ws.CodingMode;
                    newRow["UrlRangeRule"]          = ws.UrlRangeRule;
                    newRow["PageCoding"]            = ws.PageCoding;
                    newRow["GatherMaxNum"]          = ws.GatherMaxNum;
                    newRow["IsEcho"]                = ws.IsEcho;
                    newRow["IsNext"]                = ws.IsNext;
                    newRow["NextMode"]              = ws.NextMode;
                    newRow["ConNextRangeRule"]      = ws.ConNextRangeRule;
                    newRow["ConNextRule"]           = ws.ConNextRule;
                    newRow["ConNextRangeRuleIndex"] = ws.ConNextRangeRuleIndex;
                    newRow["ConNextRuleIndex"]      = ws.ConNextRuleIndex;
                    newRow["ConIsNext"]             = ws.ConIsNext;
                    newRow["ConNextMode"]           = ws.ConNextMode;
                    _WebSpiderTable.Rows.Add(newRow);
                }
            }
            _WebSpiderTable = DataOften.GetSortTable(_WebSpiderTable, "OrderNum asc");
            if (File.Exists(upath))
            {
                File.Delete(upath);
            }
            _WebSpiderTable.WriteXml(upath, XmlWriteMode.WriteSchema);
        }
Example #2
0
        /// <summary>读取网络蜘蛛设置</summary>
        /// <param name="wsid">网络蜘蛛ID</param>
        public void LoadWebSpiderInfo(string wsid)
        {
            IsLoad   = false;
            SpiderID = wsid;
            DataRow[] sdrs = wapp.WebSpiderList.WebSpiderTable.Select("SpiderID='" + wsid + "'");
            if (sdrs.Length <= 0)
            {
                return;
            }
            ws                       = new WebSpider();
            ws.SpiderID              = DataOften.GetStr(sdrs, "SpiderID");
            ws.SpiderName            = DataOften.GetStr(sdrs, "SpiderName");
            ws.UrlList               = DataOften.GetStr(sdrs, "UrlList");
            ws.UrlRangeRule          = DataOften.GetStr(sdrs, "UrlRangeRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.UrlRule               = DataOften.GetStr(sdrs, "UrlRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.NextRangeRule         = DataOften.GetStr(sdrs, "NextRangeRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.NextRule              = DataOften.GetStr(sdrs, "NextRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.UrlRangeRuleIndex     = AppPub.GetInt(DataOften.GetStr(sdrs, "UrlRangeRuleIndex", "0"));
            ws.UrlRuleIndex          = AppPub.GetInt(DataOften.GetStr(sdrs, "UrlRuleIndex", "0"));
            ws.NextRangeRuleIndex    = AppPub.GetInt(DataOften.GetStr(sdrs, "NextRangeRuleIndex", "0"));
            ws.NextRuleIndex         = AppPub.GetInt(DataOften.GetStr(sdrs, "NextRuleIndex", "0"));
            ws.IsSaveHtml            = AppPub.GetInt(DataOften.GetStr(sdrs, "IsSaveHtml", "0"));
            ws.HtmlSavePath          = DataOften.GetStr(sdrs, "HtmlSavePath");
            ws.ExcelSavePath         = DataOften.GetStr(sdrs, "ExcelSavePath");
            ws.OrderNum              = AppPub.GetInt(DataOften.GetStr(sdrs, "OrderNum", "0"));
            ws.GatherCount           = AppPub.GetInt(DataOften.GetStr(sdrs, "GatherCount", "0"));
            ws.CodingMode            = AppPub.GetInt(DataOften.GetStr(sdrs, "CodingMode", "0"));
            ws.PageCoding            = DataOften.GetStr(sdrs, "PageCoding");
            ws.GatherMaxNum          = AppPub.GetInt(DataOften.GetStr(sdrs, "GatherMaxNum", "0"));
            ws.IsEcho                = AppPub.GetInt(DataOften.GetStr(sdrs, "IsEcho", "0"));
            ws.IsNext                = AppPub.GetInt(DataOften.GetStr(sdrs, "IsNext", "0"));
            ws.NextMode              = AppPub.GetInt(DataOften.GetStr(sdrs, "NextMode", "0"));
            ws.ConNextRangeRule      = DataOften.GetStr(sdrs, "ConNextRangeRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.ConNextRule           = DataOften.GetStr(sdrs, "ConNextRule").Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
            ws.ConNextRangeRuleIndex = AppPub.GetInt(DataOften.GetStr(sdrs, "ConNextRangeRuleIndex", "0"));
            ws.ConNextRuleIndex      = AppPub.GetInt(DataOften.GetStr(sdrs, "ConNextRuleIndex", "0"));
            ws.ConIsNext             = AppPub.GetInt(DataOften.GetStr(sdrs, "ConIsNext", "0"));
            ws.ConNextMode           = AppPub.GetInt(DataOften.GetStr(sdrs, "ConNextMode", "0"));
            DataRow[] sidrs = wapp.WebSpiderInfoList.WebSpiderInfoTable.Select("SpiderID='" + wsid + "'");
            if (sidrs.Length <= 0)
            {
                return;
            }
            Table table = new Table("GTable");
            bool  iscol = false;

            for (int i = 0; i < sidrs.Length; i++)
            {
                WebSpiderInfo wsi = new wapp.WebSpiderInfo();
                wsi.ListID                = DataOften.GetStr(sidrs, "ListID", i);
                wsi.SpiderID              = DataOften.GetStr(sidrs, "SpiderID", i);
                wsi.ListTitle             = DataOften.GetStr(sidrs, "ListTitle", i);
                wsi.ListCode              = DataOften.GetStr(sidrs, "ListCode", i);
                wsi.ContentRangeRule      = DataOften.GetStr(sidrs, "ContentRangeRule", i).Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
                wsi.ContentRule           = DataOften.GetStr(sidrs, "ContentRule", i).Replace("\\[RegRuleZhyNoLabel88088]", "([\\S\\s][^<>]*?)").Replace("\\[RegRuleZhyLabel88088]", "([\\S\\s]*?)");
                wsi.ContentRangeRuleIndex = AppPub.GetInt(DataOften.GetStr(sidrs, "ContentRangeRuleIndex", i, "0"));
                wsi.ContentRuleIndex      = AppPub.GetInt(DataOften.GetStr(sidrs, "ContentRuleIndex", i, "0"));
                wsi.ContentFilt           = DataOften.GetStr(sidrs, "ContentFilt", i);
                wsi.ContentRegFilt        = DataOften.GetStr(sidrs, "ContentRegFilt", i);
                wsi.ContentType           = AppPub.GetInt(DataOften.GetStr(sidrs, "ContentType", i, "0"));
                wsi.OrderNum              = AppPub.GetInt(DataOften.GetStr(sidrs, "OrderNum", i, "0"));
                wsi.ContentCodeMode       = AppPub.GetInt(DataOften.GetStr(sidrs, "ContentCodeMode", i, "0"));
                if (wsi.ContentType == 1)
                {
                    table.Add(wsi.ListTitle, "double", 0);
                }
                else if (wsi.ContentType == 2)
                {
                    table.Add(wsi.ListTitle, "datetime", 0);
                }
                else
                {
                    table.Add(wsi.ListTitle, "string", 0);
                }
                wsilist.Add(wsi);
                iscol = true;
            }
            gdt = DataTables.GetDataTable(table);
            if (iscol)
            {
                IsLoad = true;
            }
        }