Beispiel #1
0
 public void Add(M_Collection model)
 {
     SqlParameter[] commandParameters = new SqlParameter[] {
         new SqlParameter("@ObjectName", SqlDbType.NVarChar), new SqlParameter("@WebSite", SqlDbType.NVarChar), new SqlParameter("@ColId", SqlDbType.Int, 4), new SqlParameter("@SpecialId", SqlDbType.NVarChar), new SqlParameter("@CharSet", SqlDbType.NVarChar), new SqlParameter("@ListPageUrl", SqlDbType.NVarChar), new SqlParameter("@ObjectDemo", SqlDbType.Text), new SqlParameter("@ListStartCode", SqlDbType.NText), new SqlParameter("@ListEndCode", SqlDbType.NText), new SqlParameter("@LinkStartCode", SqlDbType.NText), new SqlParameter("@LinkEndCode", SqlDbType.NText), new SqlParameter("@PageSet", SqlDbType.NVarChar), new SqlParameter("@ContentPageSet", SqlDbType.NVarChar), new SqlParameter("@FieldListSet", SqlDbType.NText), new SqlParameter("@SimpleFilterRule", SqlDbType.NVarChar), new SqlParameter("@ComplexityFilterRule", SqlDbType.NVarChar),
         new SqlParameter("@ProterySet", SqlDbType.NVarChar), new SqlParameter("@StarLevel", SqlDbType.NVarChar), new SqlParameter("@HiteCount", SqlDbType.Int, 4)
      };
     commandParameters[0].Value = model.ObjectName;
     commandParameters[1].Value = model.WebSite;
     commandParameters[2].Value = model.ColId;
     commandParameters[3].Value = model.SpecialId;
     commandParameters[4].Value = model.CharSet;
     commandParameters[5].Value = model.ListPageUrl;
     commandParameters[6].Value = model.ObjectDemo;
     commandParameters[7].Value = model.ListStartCode;
     commandParameters[8].Value = model.ListEndCode;
     commandParameters[9].Value = model.LinkStartCode;
     commandParameters[10].Value = model.LinkEndCode;
     commandParameters[11].Value = model.PageSet;
     commandParameters[12].Value = model.ContentPageSet;
     commandParameters[13].Value = model.FieldListSet;
     commandParameters[14].Value = model.SimpleFilterRule;
     commandParameters[15].Value = model.ComplexityFilterRule;
     commandParameters[16].Value = model.ProterySet;
     commandParameters[17].Value = model.StarLevel;
     commandParameters[18].Value = model.HiteCount;
     SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringKy, CommandType.StoredProcedure, "Up_Collection_Add", commandParameters);
 }
Beispiel #2
0
    private void ColectionData(int id)
    {
        CollectionM = CollectionBll.GetIdByCollection(id);
        string getlinkStr = CollectionBll.ListPageLink(CollectionM);
        string[] linkArr = getlinkStr.Split(',');
        string[] resultLinkArr = null;
        string linkStr = string.Empty;
        for (int i = 0; i < linkArr.Length;i++ )
        {
            if (linkArr[i] != "")
            {
                if (CollectionAddressBll.IsCheckAddress(linkArr[i]))
                {
                    CollectionAddressM.ColectionId = CollectionM.Id;
                    CollectionAddressM.CollectionUrl = linkArr[i];
                    CollectionAddressM.State = false;
                    CollectionAddressBll.Add(CollectionAddressM);
                    linkStr = linkStr + linkArr[i] + ",";
                }
            }
        }

        resultLinkArr = linkStr.Split(',');
        int RecordCount = resultLinkArr.Length - 1;
        Response.Write("<script>SetTotal(" + RecordCount + ")</script>\r\n");
        Response.Flush();
        for (int i = 0; i < RecordCount; i++)
        {
            string per = ((i * 100) / RecordCount).ToString("F1");
            bool result = CollectionBll.AddCollectionData(resultLinkArr[i].ToString(), CollectionM);
            if (result)
                 CollectionAddressBll.UpdateSate(resultLinkArr[i]);
             Response.Write("<script>Info('正在采集:" + resultLinkArr[i] + "')</script>\r\n");
            Response.Write("<script>SetPr('" + per + "%'," + i + ")</script>\r\n");
            Response.Flush();
        }
        Response.Write("<script>SetPr('100.0%'," + RecordCount + ")</script>");
        Response.Write("<script>document.getElementById('finallytd').innerText = '采集完毕'</script>");
        Response.Write("<script>Info(' ')</script>\r\n");
        Response.Write("<table align='center' width='500px'><tr><td align='left'><a href='CollectionManager.aspx'>继续采集</a></td><td align='right'><a href='javascript:history.back()'>返回上一页</a></td></tr></table>");
        Response.Flush();
        if (linkStr == string.Empty && getlinkStr.Length != 0)
        {
            Response.Write("<script>Info('注意:你所采集的数据已有部分入库了')</script>\r\n");
        }
    }
Beispiel #3
0
 private string GetPageCodeContent(string nextAddress, string contentPageRegexStr, M_Collection collectionM, string contentRegex, string contentStr)
 {
     string str;
     if (collectionM.CharSet == "0")
     {
         str = "gb2312";
     }
     else
     {
         str = "utf-8";
     }
     string webSite = collectionM.WebSite;
     string htmlCode = this.GetHtmlCode(nextAddress, str);
     contentStr = contentStr + "{Ky:PAGE}" + this.GetContent(collectionM, this.GetRegValue(contentRegex, htmlCode));
     nextAddress = this.IsFullAddress(webSite, collectionM.ListPageUrl, this.GetHref(this.GetRegValue(contentPageRegexStr, htmlCode)));
     if (nextAddress != "")
     {
         string[] strArray = nextAddress.Substring(0, nextAddress.Length - 1).Split(new char[] { ',' });
         nextAddress = strArray[strArray.Length - 1];
         if (nextAddress == strArray[0])
         {
             return contentStr;
         }
         return this.GetPageCodeContent(nextAddress, contentPageRegexStr, collectionM, contentRegex, contentStr);
     }
     return contentStr;
 }
Beispiel #4
0
 private string GetListAddressContent(string addressStr, M_Collection collectionM, string contentRegex, string contentStr)
 {
     string str;
     int num;
     addressStr = addressStr.Replace("\r\n", "|");
     if (collectionM.CharSet == "0")
     {
         str = "gb2312";
     }
     else
     {
         str = "utf-8";
     }
     string[] strArray = addressStr.Split(new char[] { '|' });
     string str2 = string.Empty;
     string htmlCode = string.Empty;
     for (num = 0; num < strArray.Length; num++)
     {
         if (strArray[num] != "")
         {
             str2 = str2 + strArray[num] + "|";
         }
     }
     string[] strArray2 = str2.Split(new char[] { '|' });
     for (num = 0; num < (strArray2.Length - 1); num++)
     {
         htmlCode = this.GetHtmlCode(strArray2[num], str);
         contentStr = contentStr + this.GetContent(collectionM, this.GetRegValue(contentRegex, htmlCode));
     }
     return contentStr;
 }
Beispiel #5
0
        private string GetContent(M_Collection collectionM, string contentStr)
        {
            this.ColumnM = this.ColumnBll.GetColumn(collectionM.ColId);
            this.ChannelM = this.ChannelBll.GetChannel(this.ColumnM.ChId);
            this.ModelM = this.InfoModelBll.GetModel(this.ChannelM.ModelType);
            this.SiteModel = this.SiteBll.GetSiteModel();
            B_ConvertImage image = new B_ConvertImage(this.SiteModel.Domain, this.ModelM.UploadPath);
            string simpleFilterRule = collectionM.SimpleFilterRule;
            string pattern = string.Empty;
            string complexityFilterRule = collectionM.ComplexityFilterRule;
            if (complexityFilterRule != "")
            {
                string[] strArray = complexityFilterRule.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    this.SuperiorM = this.SuperiorBll.GetIdBySuperior(int.Parse(strArray[i].ToString()));
                    pattern = this.TransferStr(this.SuperiorM.StartCode) + "((?:.|\n)*?)" + this.TransferStr(this.SuperiorM.EndCode);
                    contentStr = this.SuperiorHtml(contentStr, pattern);
                }
            }
            if (simpleFilterRule != "")
            {
                string[] strArray2 = simpleFilterRule.Split(new char[] { ',' });
                for (int j = 0; j < (strArray2.Length - 1); j++)
                {
                    switch (int.Parse(strArray2[j].ToString()))
                    {
                        case 0:
                            contentStr = this.FilterObject(contentStr);
                            break;

                        case 1:
                            contentStr = this.FilterScript(contentStr);
                            break;

                        case 2:
                            contentStr = this.FilterStyle(contentStr);
                            break;

                        case 3:
                            contentStr = this.FilterDiv(contentStr);
                            break;

                        case 4:
                            contentStr = this.FilterSpan(contentStr);
                            break;

                        case 5:
                            contentStr = this.FilterTableProtery(contentStr);
                            break;

                        case 6:
                            contentStr = this.FilterImg(contentStr);
                            break;

                        case 7:
                            contentStr = this.FilterFont(contentStr);
                            break;

                        case 8:
                            contentStr = this.FilterA(contentStr);
                            break;

                        case 9:
                            contentStr = this.RemoveHtml(contentStr);
                            break;
                    }
                }
            }
            contentStr = image.ConvertLocalImagePath(contentStr);
            contentStr = image.ConvertContent(contentStr);
            return contentStr;
        }
Beispiel #6
0
 public void Update(M_Collection collectionM)
 {
     this.dal.Update(collectionM);
 }
Beispiel #7
0
        public string ListPageLink(M_Collection collectionM)
        {
            string str9;
            string linkStr = string.Empty;
            string htmlCode = string.Empty;
            string regStr = string.Empty;
            string listStr = string.Empty;
            string linkReg = string.Empty;
            string str6 = string.Empty;
            string nextAddress = string.Empty;
            string pageSet = collectionM.PageSet;
            int num = int.Parse(pageSet.Split(new char[] { '|' })[0].ToString().Split(new char[] { '┃' })[1].ToString());
            if (collectionM.CharSet == "0")
            {
                str9 = "gb2312";
            }
            else
            {
                str9 = "utf-8";
            }
            htmlCode = this.GetHtmlCode(collectionM.ListPageUrl, str9);
            regStr = this.TransferStr(collectionM.ListStartCode) + "((?:.|\n)*?)" + this.TransferStr(collectionM.ListEndCode);
            listStr = this.GetRegValue(regStr, htmlCode);
            linkReg = this.TransferStr(collectionM.LinkStartCode) + "((?:.|\n)*?)" + this.TransferStr(collectionM.LinkEndCode);
            linkStr = this.LinkStr(listStr, collectionM.ListPageUrl, linkReg, collectionM.WebSite);
            switch (num)
            {
                case 1:
                    str6 = this.TransferStr(pageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString()) + "((?:.|\n)*?)" + this.TransferStr(pageSet.Split(new char[] { '|' })[2].Split(new char[] { '┃' })[1].ToString());
                    nextAddress = this.IsFullAddress(collectionM.WebSite, collectionM.ListPageUrl, this.GetHref(this.GetRegValue(str6, htmlCode)));
                    return (linkStr + this.GetPageCodeLink(nextAddress, collectionM.WebSite, collectionM.ListPageUrl, str9, regStr, linkReg, str6, linkStr));

                case 2:
                {
                    int startId = int.Parse(pageSet.Split(new char[] { '|' })[2].Split(new char[] { '┃' })[1].ToString());
                    int endId = int.Parse(pageSet.Split(new char[] { '|' })[3].Split(new char[] { '┃' })[1].ToString());
                    nextAddress = pageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString();
                    return (linkStr + this.GetPageIdLink(nextAddress, collectionM.WebSite, collectionM.ListPageUrl, str9, regStr, linkReg, startId, endId, linkStr));
                }
                case 3:
                    nextAddress = pageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString();
                    return (linkStr + this.GetListAddressLink(nextAddress, collectionM.WebSite, collectionM.ListPageUrl, str9, regStr, linkReg, linkStr));
            }
            return linkStr;
        }
Beispiel #8
0
 public string GetPageIdContent(string nextAddress, M_Collection collectionM, string contentRegex, string address, string contentStr, string imagePath)
 {
     string str;
     int num2;
     this.ColumnM = this.ColumnBll.GetColumn(collectionM.ColId);
     this.ChannelM = this.ChannelBll.GetChannel(this.ColumnM.ChId);
     if (collectionM.CharSet == "0")
     {
         str = "gb2312";
     }
     else
     {
         str = "utf-8";
     }
     string input = string.Empty;
     input = this.GetHtmlCode(address, str);
     int startIndex = address.LastIndexOf('.');
     string pattern = address.Insert(startIndex, "((?:.|\n)*?)");
     MatchCollection matchs = Regex.Matches(input, pattern, RegexOptions.IgnoreCase);
     string str5 = string.Empty;
     foreach (Match match in matchs)
     {
         str5 = str5 + match.Value + ",";
     }
     string[] strArray = null;
     if (str5 != "")
     {
         strArray = str5.Substring(0, str5.Length - 1).Split(new char[] { ',' });
     }
     string str6 = string.Empty;
     if ((strArray == null) && (strArray.Length == 0))
     {
         return string.Empty;
     }
     string[] strArray2 = new string[strArray.Length];
     if (strArray.Length > 0)
     {
         for (num2 = 0; num2 < strArray.Length; num2++)
         {
             int num3 = 0;
             for (int i = 0; i < strArray.Length; i++)
             {
                 if (strArray[num2] == strArray2[i])
                 {
                     num3++;
                 }
             }
             if (num3 == 0)
             {
                 strArray2[num2] = strArray[num2];
             }
         }
     }
     num2 = 0;
     while (num2 < strArray2.Length)
     {
         if (strArray2[num2] != "")
         {
             str6 = str6 + strArray2[num2] + ",";
         }
         num2++;
     }
     if (str6 != "")
     {
         strArray = str6.Substring(0, str6.Length - 1).Split(new char[] { ',' });
         for (num2 = 1; num2 < (strArray.Length - 1); num2++)
         {
             if (strArray[num2] != "")
             {
                 input = this.GetHtmlCode(strArray[num2], str);
                 contentStr = contentStr + "{Ky:PAGE}" + this.GetContent(collectionM, this.GetRegValue(contentRegex, input));
             }
         }
     }
     return contentStr;
 }
Beispiel #9
0
        public bool AddCollectionData(string contentAddress, M_Collection collectionM)
        {
            bool flag = true;
            string fieldName = string.Empty;
            string fieldValue = string.Empty;
            string tableName = string.Empty;
            string content = this.GetContent(contentAddress, collectionM);
            this.ColumnM = this.ColumnBll.GetColumn(collectionM.ColId);
            this.ChannelM = this.ChannelBll.GetChannel(this.ColumnM.ChId);
            this.ModelM = this.InfoModelBll.GetModel(this.ChannelM.ModelType);
            tableName = this.ModelM.TableName.Replace("\"", "");
            fieldName = content.Split(new char[] { '┃' })[0].ToString();
            fieldValue = content.Split(new char[] { '┃' })[1].ToString();
            fieldName = fieldName.Substring(0, fieldName.Length - 1);
            string str5 = ",colid,uid,usertype,adminuid,updatetime,IsRecommend,IsFocus,IsSideShow,IsTop,isAllowComment,IsCreated,HitCount,TemplatePath,SpecialIdStr,Status";
            string str6 = ",expiretime,IsIrregular,IsHeader,StarLevel";
            if (this.ModelM.ModelId == 1)
            {
                fieldName = fieldName + str5 + str6;
            }
            else
            {
                fieldName = fieldName + str5;
            }
            fieldValue = fieldValue.Substring(0, fieldValue.Length - 1);
            fieldValue = ((string.Concat(new object[] { fieldValue, "$", collectionM.ColId, "$" }) + "0$") + "1$" + "0$") + DateTime.Now.ToString() + "$";
            string str7 = "0$";
            string str8 = "0$";
            string str9 = "0$";
            string str10 = "0$";
            string str11 = "0$";
            string str12 = "0$";
            string str13 = "0$";
            string str14 = "0$";
            string proterySet = collectionM.ProterySet;
            if (proterySet != "")
            {
                string[] strArray = proterySet.Split(new char[] { ',' });
                for (int i = 0; i < (strArray.Length - 1); i++)
                {
                    switch (int.Parse(strArray[i].ToString()))
                    {
                        case 0:
                            str7 = "1$";
                            break;

                        case 1:
                            str8 = "1$";
                            break;

                        case 2:
                            str9 = "1$";
                            break;

                        case 3:
                            str10 = "1$";
                            break;

                        case 4:
                            str11 = "1$";
                            break;

                        case 5:
                            str12 = "1$";
                            break;

                        case 6:
                            str13 = "1$";
                            break;

                        case 7:
                            str14 = "1$";
                            break;
                    }
                }
            }
            fieldValue = ((((fieldValue + str7 + str8 + str10 + str11 + str13 + str14) + collectionM.HiteCount + "$") + this.ColumnM.InfoTemplatePath + "$") + collectionM.SpecialId + "$") + "3";
            if (this.ModelM.ModelId == 1)
            {
                fieldValue = (string.Concat(new object[] { fieldValue, "$", DateTime.Now.AddDays(500000.0), "$" }) + str12) + str9 + collectionM.StarLevel;
            }
            try
            {
                this.CollectionData(tableName, fieldName, fieldValue);
            }
            catch
            {
                flag = false;
            }
            return flag;
        }
Beispiel #10
0
 public void Add(M_Collection collectionM)
 {
     this.dal.Add(collectionM);
 }
Beispiel #11
0
        public string GetContent(string contentAddress, M_Collection collectionM)
        {
            string contentStr = string.Empty;
            string htmlCode = string.Empty;
            string input = string.Empty;
            string str5 = string.Empty;
            string regStr = string.Empty;
            string charSet = collectionM.CharSet;
            string imagePath = string.Empty;
            if (charSet == "0")
            {
                charSet = "gb2312";
            }
            else
            {
                charSet = "utf-8";
            }
            string webSite = collectionM.WebSite;
            string fieldListSet = collectionM.FieldListSet;
            string contentPageSet = collectionM.ContentPageSet;
            string[] strArray = fieldListSet.Split(new char[] { '|' });
            string[] strArray2 = new string[strArray.Length - 1];
            this.ColumnM = this.ColumnBll.GetColumn(collectionM.ColId);
            this.ChannelM = this.ChannelBll.GetChannel(this.ColumnM.ChId);
            int num = 0;
            if (contentPageSet != "")
            {
                num = int.Parse(contentPageSet.Split(new char[] { '|' })[0].ToString().Split(new char[] { '┃' })[1].ToString());
            }
            string str13 = string.Empty;
            string nextAddress = string.Empty;
            htmlCode = this.GetHtmlCode(contentAddress, charSet);
            for (int i = 0; i < strArray2.Length; i++)
            {
                regStr = this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()) + "((?:.|\n)*?)" + this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString());
                if (strArray[i].Split(new char[] { ',' })[0].ToString().ToLower() == "content")
                {
                    contentStr = this.GetRegValue(regStr, htmlCode);
                    contentStr = this.GetContent(collectionM, contentStr);
                    switch (num)
                    {
                        case 1:
                            str13 = this.TransferStr(contentPageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString()) + "((?:.|\n)*?)" + this.TransferStr(contentPageSet.Split(new char[] { '|' })[2].Split(new char[] { '┃' })[1].ToString());
                            nextAddress = this.IsFullAddress(collectionM.WebSite, collectionM.ListPageUrl, this.GetHref(this.GetRegValue(str13, htmlCode)));
                            if ((nextAddress != "") && (collectionM.WebSite != nextAddress))
                            {
                                string[] strArray3 = nextAddress.Substring(0, nextAddress.Length - 1).Split(new char[] { ',' });
                                nextAddress = strArray3[strArray3.Length - 1];
                                contentStr = contentStr + this.GetPageCodeContent(nextAddress, str13, collectionM, regStr, contentStr);
                            }
                            break;

                        case 2:
                            nextAddress = contentPageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString();
                            contentStr = contentStr + this.GetPageIdContent(nextAddress, collectionM, regStr, contentAddress, contentStr, imagePath);
                            break;

                        case 3:
                            nextAddress = contentPageSet.Split(new char[] { '|' })[1].Split(new char[] { '┃' })[1].ToString();
                            contentStr = contentStr + this.GetListAddressContent(nextAddress, collectionM, regStr, contentStr);
                            break;
                    }
                    if (contentStr == "")
                    {
                        contentStr = strArray[i].Split(new char[] { ',' })[3].ToString();
                    }
                    contentStr = Regex.Replace(Regex.Replace(contentStr, this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()), "", RegexOptions.IgnoreCase), this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()), "", RegexOptions.IgnoreCase);
                }
                else if (strArray[i].Split(new char[] { ',' })[0].ToString().ToLower() == "addtime")
                {
                    if ((((this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()) != "") && (this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()).Length != 0)) && (this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()) != "")) && (this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()).Length != 0))
                    {
                        contentStr = this.RemoveHtml(this.GetRegValue(regStr, htmlCode).Replace(this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()), "").Replace(this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()), "").Replace("\r\n", "").Replace("&nbsp;", "")).Trim();
                    }
                    else
                    {
                        contentStr = strArray[i].Split(new char[] { ',' })[3].ToString().Trim();
                    }
                }
                else
                {
                    if ((((this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()) != "") && (this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()).Length != 0)) && (this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()) != "")) && (this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()).Length != 0))
                    {
                        contentStr = this.RemoveHtml(this.GetRegValue(regStr, htmlCode).Replace(this.TransferStr(strArray[i].Split(new char[] { ',' })[1].ToString()), "").Replace(this.TransferStr(strArray[i].Split(new char[] { ',' })[2].ToString()), "").Trim());
                    }
                    else
                    {
                        contentStr = this.RemoveHtml(this.GetRegValue(regStr, htmlCode)).Trim();
                    }
                    if (contentStr == "")
                    {
                        contentStr = strArray[i].Split(new char[] { ',' })[3].ToString();
                    }
                }
                input = input + strArray[i].Split(new char[] { ',' })[0].ToString().ToLower() + ",";
                str5 = str5 + contentStr + "$";
            }
            if (!Regex.Match(input, "uname", RegexOptions.IgnoreCase).Success)
            {
                input = input + "uname,";
                str5 = str5 + "admin$";
            }
            if (!Regex.Match(input, "addtime", RegexOptions.IgnoreCase).Success)
            {
                input = input + "addtime,";
                str5 = str5 + DateTime.Now.ToString() + "$";
            }
            if ((imagePath != string.Empty) && (imagePath.Length != 0))
            {
                input = input + "ImgPath,";
                str5 = str5 + "|" + imagePath + "$";
            }
            return (input + "┃" + str5);
        }
Beispiel #12
0
 public M_Collection GetIdByCollection(int Id)
 {
     SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.Int, 4) };
     commandParameters[0].Value = Id;
     DataTable table = SqlHelper.ExecuteTable(SqlHelper.ConnectionStringKy, CommandType.StoredProcedure, "Up_Collection_GetIdByCollection", commandParameters);
     M_Collection m_s = new M_Collection();
     m_s.Id = Id;
     if (table.Rows.Count > 0)
     {
         m_s.ObjectName = table.Rows[0]["ObjectName"].ToString();
         m_s.WebSite = table.Rows[0]["WebSite"].ToString();
         if (table.Rows[0]["ColId"].ToString() != "")
         {
             m_s.ColId = int.Parse(table.Rows[0]["ColId"].ToString());
         }
         m_s.SpecialId = table.Rows[0]["SpecialId"].ToString();
         m_s.CharSet = table.Rows[0]["CharSet"].ToString();
         m_s.ListPageUrl = table.Rows[0]["ListPageUrl"].ToString();
         m_s.ObjectDemo = table.Rows[0]["ObjectDemo"].ToString();
         m_s.ListStartCode = table.Rows[0]["ListStartCode"].ToString();
         m_s.ListEndCode = table.Rows[0]["ListEndCode"].ToString();
         m_s.LinkStartCode = table.Rows[0]["LinkStartCode"].ToString();
         m_s.LinkEndCode = table.Rows[0]["LinkEndCode"].ToString();
         m_s.PageSet = table.Rows[0]["PageSet"].ToString();
         m_s.ContentPageSet = table.Rows[0]["ContentPageSet"].ToString();
         m_s.FieldListSet = table.Rows[0]["FieldListSet"].ToString();
         m_s.SimpleFilterRule = table.Rows[0]["SimpleFilterRule"].ToString();
         m_s.ComplexityFilterRule = table.Rows[0]["ComplexityFilterRule"].ToString();
         m_s.ProterySet = table.Rows[0]["ProterySet"].ToString();
         m_s.StarLevel = table.Rows[0]["StarLevel"].ToString();
         if (table.Rows[0]["HiteCount"].ToString() != "")
         {
             m_s.HiteCount = int.Parse(table.Rows[0]["HiteCount"].ToString());
         }
         return m_s;
     }
     return null;
 }
Beispiel #13
0
 private void CollectionStateFalse(int collId)
 {
     CollectionM = CollectionBll.GetIdByCollection(collId);
     DataTable dt = CollectionAddressBll.GetCollIdByCollAddress(collId);
     if (dt == null)
     {
         Response.Write("<script>Info('没有找到要采集的地址')</script>\r\n");
         return;
     }
     int RecordCount = dt.Rows.Count;
     Response.Write("<script>SetTotal(" + RecordCount + ")</script>\r\n");
     Response.Flush();
     for (int i = 0; i < RecordCount; i++)
     {
         string per = ((i * 100) / RecordCount).ToString("F1");
         bool result = CollectionBll.AddCollectionData(dt.Rows[i]["CollectionUrl"].ToString(), CollectionM);
         if (result)
             CollectionAddressBll.UpdateSate(dt.Rows[i]["CollectionUrl"].ToString());
         Response.Write("<script>Info('正在采集:" + dt.Rows[i]["CollectionUrl"].ToString() + "')</script>\r\n");
         Response.Write("<script>SetPr('" + per + "%'," + i + ")</script>\r\n");
         Response.Flush();
     }
     Response.Write("<script>SetPr('100.0%'," + RecordCount + ")</script>");
     Response.Write("<script>document.getElementById('finallytd').innerText = '采集完毕'</script>");
     Response.Write("<script>Info(' ')</script>\r\n");
     Response.Write("<table align='center' width='500px'><tr><td align='left'><a href='CollectionManager.aspx'>继续采集</a></td><td align='right'><a href='javascript:history.back()'>返回上一页</a></td></tr></table>");
     Response.Flush();
 }
Beispiel #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AdminGroupBll.Power_Judge(48);
        AjaxPro.Utility.RegisterTypeForAjax(typeof(system_collection_EditObject));
        if (!IsPostBack)
        {
            if (!(Request.QueryString["Id"] == null || Request.QueryString["Id"].Length == 0))
            {
                #region 边辑赋值
                BindSuperior();
                int id = int.Parse(Request.QueryString["Id"].ToString());

                CollectionM = CollectionBll.GetIdByCollection(id);

                BindTable(CollectionM.ColId);

                txtObjectName.Text = CollectionM.ObjectName;
                txtWebSite.Text = CollectionM.WebSite;

                ColumnM = ColumnBll.GetColumn(CollectionM.ColId);
                txtColumnId.Text = ColumnM.ColName;
                hidColumnId.Value = CollectionM.ColId.ToString();

                if (CollectionM.SpecialId != null && CollectionM.SpecialId.Length!=0)
                {
                    string[] specialIdArr = CollectionM.SpecialId.Split('|');
                    string notNullSpIdStr = string.Empty;
                    for (int i = 0; i < specialIdArr.Length;i++ )
                    {
                        if (specialIdArr[i].Length != 0)
                            notNullSpIdStr = notNullSpIdStr + specialIdArr[i]+"|";
                    }
                    string[] SpecialArr = notNullSpIdStr.Split('|');
                    string SpecialName = string.Empty;
                    for (int i = 0; i < SpecialArr.Length - 1; i++)
                    {
                        SpecialM = SpecialBll.GetSpecial(int.Parse(SpecialArr[i]));
                        if (i == SpecialArr.Length - 2)
                            SpecialName = SpecialName + SpecialM.SpecialCName;
                        else
                            SpecialName = SpecialName + SpecialM.SpecialCName + ",";
                    }
                    txtSpecialId.Text = SpecialName;
                    hidSpecialId.Value = CollectionM.SpecialId.ToString();
                }

                string charSet = CollectionM.CharSet;
                if (charSet == "0")
                    rdoCharSet.Items[0].Selected = true;
                else if (charSet == "1")
                    rdoCharSet.Items[1].Selected = true;

                txtListUrl.Text = CollectionM.ListPageUrl;
                txtObjectDemo.Text = CollectionM.ObjectDemo;
                txtListStart.Text = CollectionM.ListStartCode;
                txtListEnd.Text = CollectionM.ListEndCode;
                txtLinkStart.Text = CollectionM.LinkStartCode;
                txtLinkEnd.Text = CollectionM.LinkEndCode;

                //分页设置
                string pageSet = CollectionM.PageSet;
                if (pageSet != "")
                {
                    string[] pageArr = pageSet.Split('|');
                    int rdoId = int.Parse(pageArr[0].Split('┃')[1]);
                    switch (rdoId)
                    {
                        case 0:
                            rdoPage0.Checked = true;
                            break;
                        case 1:
                            rdoPage1.Checked = true;
                            txtNextPageStart.Text = pageArr[1].Split('┃')[1];
                            txtNextPageEnd.Text = pageArr[2].Split('┃')[1];
                            break;
                        case 2:
                            rdoPage2.Checked = true;
                            txtUrlStr.Text = pageArr[1].Split('┃')[1];
                            txtStartId.Text = pageArr[2].Split('┃')[1];
                            txtEndId.Text = pageArr[3].Split('┃')[1];
                            break;
                        case 3:
                            rdoPage3.Checked = true;
                            txtUrlList.Text = pageArr[1].Split('┃')[1];
                            break;
                    }
                }

                //内容分页设置
                string conPageSet = CollectionM.ContentPageSet;
                if (conPageSet != "")
                {
                    string[] pageArr = conPageSet.Split('|');
                    int rdoId = int.Parse(pageArr[0].Split('┃')[1]);
                    switch (rdoId)
                    {
                        case 0:
                            rdoConPage1.Checked = true;
                            break;
                        case 1:
                            rdoConPage2.Checked = true;
                            txtConPageStart.Text = pageArr[1].Split('┃')[1];
                            txtConPageEnd.Text = pageArr[2].Split('┃')[1];
                            break;
                        case 2:
                            rdoConPage3.Checked = true;
                            txtConAddress.Text = pageArr[1].Split('┃')[1];
                            txtConStartId.Text = pageArr[2].Split('┃')[1];
                            txtConEndId.Text = pageArr[3].Split('┃')[1];
                            break;
                        case 3:
                            rdoConPage4.Checked = true;
                            txtConPageAddress.Text = pageArr[1].Split('┃')[1];
                            break;
                    }
                }

                //字段设置
                string fieldList = CollectionM.FieldListSet;
                if (fieldList != "")
                {
                    string[] fieldArr = fieldList.Split('|');
                    for (int i = 0; i < fieldArr.Length - 1; i++)
                    {
                        for (int j = 0; j < lbFildList.Items.Count; j++)
                        {
                            if (lbFildList.Items[j].Value == fieldArr[i].ToString().Split(',')[0].ToString())
                                lbFildList.Items[j].Selected = true;
                        }
                    }
                    hidFieldValue.Value = fieldList;
                }

                //简单过滤规则
                string simpleFilterRule = CollectionM.SimpleFilterRule;
                if (simpleFilterRule != "")
                {
                    string[] simFilRuleArr = simpleFilterRule.Split(',');
                    for (int i = 0; i < simFilRuleArr.Length - 1; i++)
                    {
                        for (int j = 0; j < chkSimpleFilter.Items.Count; j++)
                        {
                            if (chkSimpleFilter.Items[j].Value == simFilRuleArr[i])
                            {
                                chkSimpleFilter.Items[j].Selected = true;
                            }
                        }
                    }
                }

                //复杂过滤规则
                string complexityFilterRule = CollectionM.ComplexityFilterRule;
                string[] superiorArr = complexityFilterRule.Split(',');
                if (complexityFilterRule != "")
                {
                    for (int j = 0; j < superiorArr.Length; j++)
                    {
                        for (int i = 0; i < lbFilterRule.Items.Count; i++)
                        {
                            if (lbFilterRule.Items[i].Value == superiorArr[j])
                            {
                                lbFilterRule.Items[i].Selected = true;
                            }
                        }
                    }
                }

                //属性设置
                string protery = CollectionM.ProterySet;
                if (protery != "")
                {
                    string[] proteryArr = protery.Split(',');
                    for (int i = 0; i < proteryArr.Length - 1; i++)
                    {
                        for (int j = 0; j < chkPropetry.Items.Count; j++)
                        {
                            if (chkPropetry.Items[j].Value == proteryArr[i])
                                chkPropetry.Items[j].Selected = true;
                        }
                    }
                }

                //评分等级
                for (int i = 0; i < ddlStarLevel.Items.Count; i++)
                {
                    if (ddlStarLevel.Items[i].Value == CollectionM.StarLevel)
                        ddlStarLevel.Items[i].Selected = true;
                }

                txtHitCout.Text = CollectionM.HiteCount.ToString();
                #endregion
            }
        }
    }