/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(KiwiCrawler.Model.Urlconfigs_k model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update urlconfigs_k set ");
            strSql.Append("kUrl=@kUrl,");
            strSql.Append("kPageTotal=@kPageTotal,");
            strSql.Append("kCaptureType=@kCaptureType,");
            strSql.Append("kDetailPattern=@kDetailPattern,");
            strSql.Append("kDetailPatternType=@kDetailPatternType,");
            strSql.Append("kNextPagePattern=@kNextPagePattern,");
            strSql.Append("kNextPagePatternType=@kNextPagePatternType,");
            strSql.Append("kComplateDegree=@kComplateDegree,");
            strSql.Append("kAddressBusinessType=@kAddressBusinessType,");
            strSql.Append("kKeyWords=@kKeyWords,");
            strSql.Append("kNotes=@kNotes");
            strSql.Append(" where kId=@kId");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@kUrl",                 MySqlDbType.Text),
                new MySqlParameter("@kPageTotal",           MySqlDbType.Int32,    11),
                new MySqlParameter("@kCaptureType",         MySqlDbType.Text),
                new MySqlParameter("@kDetailPattern",       MySqlDbType.Text),
                new MySqlParameter("@kDetailPatternType",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@kNextPagePattern",     MySqlDbType.Text),
                new MySqlParameter("@kNextPagePatternType", MySqlDbType.VarChar, 255),
                new MySqlParameter("@kComplateDegree",      MySqlDbType.Float),
                new MySqlParameter("@kAddressBusinessType", MySqlDbType.Text),
                new MySqlParameter("@kKeyWords",            MySqlDbType.Text),
                new MySqlParameter("@kNotes",               MySqlDbType.VarChar, 255),
                new MySqlParameter("@kId",                  MySqlDbType.Int32, 11)
            };

            parameters[0].Value  = model.kUrl;
            parameters[1].Value  = model.kPageTotal;
            parameters[2].Value  = model.kCaptureType;
            parameters[3].Value  = model.kDetailPattern;
            parameters[4].Value  = model.kDetailPatternType;
            parameters[5].Value  = model.kNextPagePattern;
            parameters[6].Value  = model.kNextPagePatternType;
            parameters[7].Value  = model.kComplateDegree;
            parameters[8].Value  = model.kAddressBusinessType;
            parameters[9].Value  = model.kKeyWords;
            parameters[10].Value = model.kNotes;
            parameters[11].Value = model.kId;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KiwiCrawler.Model.Urlconfigs_k DataRowToModel(DataRow row)
 {
     KiwiCrawler.Model.Urlconfigs_k model = new KiwiCrawler.Model.Urlconfigs_k();
     if (row != null)
     {
         if (row["kId"] != null && row["kId"].ToString() != "")
         {
             model.kId = int.Parse(row["kId"].ToString());
         }
         if (row["kUrl"] != null)
         {
             model.kUrl = row["kUrl"].ToString();
         }
         if (row["kPageTotal"] != null && row["kPageTotal"].ToString() != "")
         {
             model.kPageTotal = int.Parse(row["kPageTotal"].ToString());
         }
         if (row["kCaptureType"] != null)
         {
             model.kCaptureType = row["kCaptureType"].ToString();
         }
         if (row["kDetailPattern"] != null)
         {
             model.kDetailPattern = row["kDetailPattern"].ToString();
         }
         if (row["kDetailPatternType"] != null)
         {
             model.kDetailPatternType = row["kDetailPatternType"].ToString();
         }
         if (row["kNextPagePattern"] != null)
         {
             model.kNextPagePattern = row["kNextPagePattern"].ToString();
         }
         if (row["kNextPagePatternType"] != null)
         {
             model.kNextPagePatternType = row["kNextPagePatternType"].ToString();
         }
         if (row["kComplateDegree"] != null && row["kComplateDegree"].ToString() != "")
         {
             model.kComplateDegree = decimal.Parse(row["kComplateDegree"].ToString());
         }
         if (row["kAddressBusinessType"] != null)
         {
             model.kAddressBusinessType = row["kAddressBusinessType"].ToString();
         }
         if (row["kKeyWords"] != null)
         {
             model.kKeyWords = row["kKeyWords"].ToString();
         }
         if (row["kNotes"] != null)
         {
             model.kNotes = row["kNotes"].ToString();
         }
     }
     return(model);
 }
Пример #3
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            KiwiCrawler.Model.Urlconfigs_k urlFrmMode = new KiwiCrawler.Model.Urlconfigs_k();

            urlFrmMode.kAddressBusinessType = txtBusinessType.Text.Trim();
            urlFrmMode.kCaptureType         = cbCaptureType.Text.Trim();
            urlFrmMode.kComplateDegree      = 0;
            urlFrmMode.kDetailPattern       = txtDetailPattern.Text.Trim();
            urlFrmMode.kDetailPatternType   = cbDetailPatternType.Text.Trim();
            urlFrmMode.kKeyWords            = txtKeyWords.Text.Trim();
            urlFrmMode.kNextPagePattern     = txtNextPagePattern.Text.Trim();
            urlFrmMode.kNextPagePatternType = cbNextPagePatternType.Text.Trim();
            urlFrmMode.kPageTotal           = String.IsNullOrEmpty(txtPageNum.Text.Trim()) ? -1 : Int32.Parse(txtPageNum.Text.Trim());
            urlFrmMode.kUrl = txtUrl.Text.Trim();
            string msg = "";

            //保存到数据库
            KiwiCrawler.BLL.Urlconfigs_kBll bll = new KiwiCrawler.BLL.Urlconfigs_kBll();

            if (bll.Add(urlFrmMode))
            {
                msg += "添加种子链接成功。\r\n";
                //添加到抽取配置表
                KiwiCrawler.BLL.Extractionconfig_kBll extractionconfigBll   = new KiwiCrawler.BLL.Extractionconfig_kBll();
                KiwiCrawler.Model.Extractionconfig_k  extractionconfigModel = new KiwiCrawler.Model.Extractionconfig_k();
                //extractionconfigModel.KId = bll.GetMaxId()-1;//查询出来的比实际加了1
                extractionconfigModel.KId      = bll.GetModelList("kUrl='" + urlFrmMode.kUrl + "'").FirstOrDefault().kId;
                extractionconfigModel.KUrl     = urlFrmMode.kUrl;
                extractionconfigModel.KKeyword = urlFrmMode.kKeyWords;
                extractionconfigModel.KPercent = 0;
                if (extractionconfigBll.Add(extractionconfigModel))
                {
                    msg += "同步抽取信息成功。\r\n";
                }
                else
                {
                    msg += "同步抽取信息失败。";
                }
            }
            else
            {
                msg += "添加种子链接失败。\r\n";
            }

            MessageBox.Show(msg);
            urlFrmMode_k = urlFrmMode;
            this.Close();
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(KiwiCrawler.Model.Urlconfigs_k model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into urlconfigs_k(");
            strSql.Append("kUrl,kPageTotal,kCaptureType,kDetailPattern,kDetailPatternType,kNextPagePattern,kNextPagePatternType,kComplateDegree,kAddressBusinessType,kKeyWords,kNotes)");
            strSql.Append(" values (");
            strSql.Append("@kUrl,@kPageTotal,@kCaptureType,@kDetailPattern,@kDetailPatternType,@kNextPagePattern,@kNextPagePatternType,@kComplateDegree,@kAddressBusinessType,@kKeyWords,@kNotes)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@kUrl",                 MySqlDbType.Text),
                new MySqlParameter("@kPageTotal",           MySqlDbType.Int32,    11),
                new MySqlParameter("@kCaptureType",         MySqlDbType.Text),
                new MySqlParameter("@kDetailPattern",       MySqlDbType.Text),
                new MySqlParameter("@kDetailPatternType",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@kNextPagePattern",     MySqlDbType.Text),
                new MySqlParameter("@kNextPagePatternType", MySqlDbType.VarChar, 255),
                new MySqlParameter("@kComplateDegree",      MySqlDbType.Float),
                new MySqlParameter("@kAddressBusinessType", MySqlDbType.Text),
                new MySqlParameter("@kKeyWords",            MySqlDbType.Text),
                new MySqlParameter("@kNotes",               MySqlDbType.VarChar, 255)
            };
            parameters[0].Value  = model.kUrl;
            parameters[1].Value  = model.kPageTotal;
            parameters[2].Value  = model.kCaptureType;
            parameters[3].Value  = model.kDetailPattern;
            parameters[4].Value  = model.kDetailPatternType;
            parameters[5].Value  = model.kNextPagePattern;
            parameters[6].Value  = model.kNextPagePatternType;
            parameters[7].Value  = model.kComplateDegree;
            parameters[8].Value  = model.kAddressBusinessType;
            parameters[9].Value  = model.kKeyWords;
            parameters[10].Value = model.kNotes;
            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /*
         *      /// <summary>
         *      /// 分页获取数据列表
         *      /// </summary>
         *      public DataSet GetList(int PageSize,int PageIndex,string strWhere)
         *      {
         *              MySqlParameter[] parameters = {
         *                              new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
         *                              new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
         *                              new MySqlParameter("@PageSize", MySqlDbType.Int32),
         *                              new MySqlParameter("@PageIndex", MySqlDbType.Int32),
         *                              new MySqlParameter("@IsReCount", MySqlDbType.Bit),
         *                              new MySqlParameter("@OrderType", MySqlDbType.Bit),
         *                              new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
         *                              };
         *              parameters[0].Value = "urlconfigs_k";
         *              parameters[1].Value = "kId";
         *              parameters[2].Value = PageSize;
         *              parameters[3].Value = PageIndex;
         *              parameters[4].Value = 0;
         *              parameters[5].Value = 0;
         *              parameters[6].Value = strWhere;
         *              return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
         *      }*/

        #endregion  BasicMethod
        #region  ExtensionMethod
        public int AddBringId(KiwiCrawler.Model.Urlconfigs_k model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into urlconfigs_k(");
            strSql.Append("kUrl,kPageTotal,kCaptureType,kDetailPattern,kDetailPatternType,kNextPagePattern,kNextPagePatternType,kComplateDegree,kAddressBusinessType,kKeyWords,kNotes)");
            strSql.Append(" output inserted.kId");
            strSql.Append(" values (");
            strSql.Append("@kUrl,@kPageTotal,@kCaptureType,@kDetailPattern,@kDetailPatternType,@kNextPagePattern,@kNextPagePatternType,@kComplateDegree,@kAddressBusinessType,@kKeyWords,@kNotes)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@kUrl",                 MySqlDbType.Text),
                new MySqlParameter("@kPageTotal",           MySqlDbType.Int32,    11),
                new MySqlParameter("@kCaptureType",         MySqlDbType.Text),
                new MySqlParameter("@kDetailPattern",       MySqlDbType.Text),
                new MySqlParameter("@kDetailPatternType",   MySqlDbType.VarChar, 255),
                new MySqlParameter("@kNextPagePattern",     MySqlDbType.Text),
                new MySqlParameter("@kNextPagePatternType", MySqlDbType.VarChar, 255),
                new MySqlParameter("@kComplateDegree",      MySqlDbType.Float),
                new MySqlParameter("@kAddressBusinessType", MySqlDbType.Text),
                new MySqlParameter("@kKeyWords",            MySqlDbType.Text),
                new MySqlParameter("@kNotes",               MySqlDbType.VarChar, 255)
            };
            parameters[0].Value  = model.kUrl;
            parameters[1].Value  = model.kPageTotal;
            parameters[2].Value  = model.kCaptureType;
            parameters[3].Value  = model.kDetailPattern;
            parameters[4].Value  = model.kDetailPatternType;
            parameters[5].Value  = model.kNextPagePattern;
            parameters[6].Value  = model.kNextPagePatternType;
            parameters[7].Value  = model.kComplateDegree;
            parameters[8].Value  = model.kAddressBusinessType;
            parameters[9].Value  = model.kKeyWords;
            parameters[10].Value = model.kNotes;
            int id = Convert.ToInt32(DbHelperMySQL.GetSingle(strSql.ToString(), parameters));

            return(id);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KiwiCrawler.Model.Urlconfigs_k GetModel(int kId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select kId,kUrl,kPageTotal,kCaptureType,kDetailPattern,kDetailPatternType,kNextPagePattern,kNextPagePatternType,kComplateDegree,kAddressBusinessType,kKeyWords,kNotes from urlconfigs_k ");
            strSql.Append(" where kId=@kId");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@kId", MySqlDbType.Int32)
            };
            parameters[0].Value = kId;

            KiwiCrawler.Model.Urlconfigs_k model = new KiwiCrawler.Model.Urlconfigs_k();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        private void btnCompute_Click(object sender, EventArgs e)
        {
            KiwiCrawler.Model.Urlconfigs_k  configModel = new KiwiCrawler.Model.Urlconfigs_k();
            KiwiCrawler.BLL.Urlconfigs_kBll configBll   = new KiwiCrawler.BLL.Urlconfigs_kBll();
            configModel = configBll.GetModel(_modeId);
            if (ckbDetail.Checked)
            {
                _page = configModel.kPageTotal == null ? -1 : Convert.ToInt32(configModel.kPageTotal);
                //计算完成度
                // 98.33%|590/600
                Int32 pageCapture, pageTotal;
                pageTotal = _page; //总的记录数
                                   //获得pageCapture
                                   //目前根据关键词搜索吧,域名不太适用
                KiwiCrawler.BLL.Capturedata_kBll capBll = new KiwiCrawler.BLL.Capturedata_kBll();
                pageCapture = capBll.GetRecordCount("kNotes=" + "'" + configModel.kId + ":" + configModel.kKeyWords.Trim() + "'");
                double percentage = pageCapture * 1.0 / (pageTotal * 1.0);
                string msg        = (percentage * 100).ToString("0.00") + "%" + "|" + pageCapture + "/" + pageTotal;
                configModel.kNotes          = msg + "|R无详细页R|" + "T无详细页T";
                configModel.kComplateDegree = (decimal)percentage;
                if (configBll.Update(configModel))
                {
                    MessageBox.Show("完成情况为:" + msg);
                    this.Close();
                }
            }
            else
            {
                #region  详细页
                string msg = "";
                if (!Int32.TryParse(txtRow.Text.Trim(), out _row))
                {
                    msg += "每页记录数输入有误\r\n";
                }
                if (!Int32.TryParse(txtTail.Text.Trim(), out _tail))
                {
                    msg += "末页记录数输入有误\r\n";
                }
                if (configModel.kPageTotal == null)
                {
                    msg += "选择网站总页数有误\r\n";
                }

                if (!string.IsNullOrEmpty(msg.Trim()))
                {
                    MessageBox.Show(msg);
                }
                _page = configModel.kPageTotal == null ? -1 : Convert.ToInt32(configModel.kPageTotal);
                //计算完成度
                // 98.33%|590/600
                Int32 pageCapture, pageTotal;
                pageTotal = _row * _page - (_row - _tail); //总的记录数
                                                           //获得pageCapture
                                                           //目前根据关键词搜索吧,域名不太适用
                KiwiCrawler.BLL.Capturedata_kBll capBll = new KiwiCrawler.BLL.Capturedata_kBll();
                pageCapture = capBll.GetRecordCount("kNotes=" + "'" + configModel.kId + ":" + configModel.kKeyWords.Trim() + "'") - _page;
                double percentage = pageCapture * 1.0 / (pageTotal * 1.0);
                msg = (percentage * 100).ToString("0.00") + "%" + "|" + pageCapture + "/" + pageTotal;
                configModel.kNotes          = msg + "|R" + _row + "R|" + "T" + _tail + "T";
                configModel.kComplateDegree = (decimal)percentage;
                if (configBll.Update(configModel))
                {
                    MessageBox.Show("完成情况为:" + msg);
                    this.Close();
                }
                #endregion
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KiwiCrawler.Model.Urlconfigs_k DataRowToModel(DataRow row)
 {
     KiwiCrawler.Model.Urlconfigs_k model = new KiwiCrawler.Model.Urlconfigs_k();
     if (row != null)
     {
         if (row["kId"] != null && row["kId"].ToString() != "")
         {
             model.kId = int.Parse(row["kId"].ToString());
         }
         if (row["kUrl"] != null)
         {
             model.kUrl = row["kUrl"].ToString();
         }
         if (row["kPageTotal"] != null && row["kPageTotal"].ToString() != "")
         {
             model.kPageTotal = int.Parse(row["kPageTotal"].ToString());
         }
         if (row["kCaptureType"] != null)
         {
             model.kCaptureType = row["kCaptureType"].ToString();
         }
         if (row["kDetailPattern"] != null)
         {
             model.kDetailPattern = row["kDetailPattern"].ToString();
         }
         if (row["kDetailPatternType"] != null)
         {
             model.kDetailPatternType = row["kDetailPatternType"].ToString();
         }
         if (row["kNextPagePattern"] != null)
         {
             model.kNextPagePattern = row["kNextPagePattern"].ToString();
         }
         if (row["kNextPagePatternType"] != null)
         {
             model.kNextPagePatternType = row["kNextPagePatternType"].ToString();
         }
         if (row["kComplateDegree"] != null && row["kComplateDegree"].ToString() != "")
         {
             model.kComplateDegree = decimal.Parse(row["kComplateDegree"].ToString());
         }
         if (row["kAddressBusinessType"] != null)
         {
             model.kAddressBusinessType = row["kAddressBusinessType"].ToString();
         }
         if (row["kKeyWords"] != null)
         {
             model.kKeyWords = row["kKeyWords"].ToString();
         }
         if (row["kNotes"] != null)
         {
             model.kNotes = row["kNotes"].ToString();
         }
     }
     return model;
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KiwiCrawler.Model.Urlconfigs_k GetModel(int kId)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select kId,kUrl,kPageTotal,kCaptureType,kDetailPattern,kDetailPatternType,kNextPagePattern,kNextPagePatternType,kComplateDegree,kAddressBusinessType,kKeyWords,kNotes from urlconfigs_k ");
            strSql.Append(" where kId=@kId");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@kId", MySqlDbType.Int32)
            };
            parameters[0].Value = kId;

            KiwiCrawler.Model.Urlconfigs_k model = new KiwiCrawler.Model.Urlconfigs_k();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Пример #10
0
 public frmEdit(KiwiCrawler.Model.Urlconfigs_k model)
     : this()
 {
     editFrmModel = new KiwiCrawler.Model.Urlconfigs_k();
     editFrmModel = model;
 }
Пример #11
0
        private void btnCompute_Click(object sender, EventArgs e)
        {
            KiwiCrawler.Model.Urlconfigs_k configModel = new KiwiCrawler.Model.Urlconfigs_k();
            KiwiCrawler.BLL.Urlconfigs_kBll configBll = new KiwiCrawler.BLL.Urlconfigs_kBll();
            configModel = configBll.GetModel(_modeId);
            if (ckbDetail.Checked)
            {
                _page = configModel.kPageTotal == null ? -1 : Convert.ToInt32(configModel.kPageTotal);
                //计算完成度
                // 98.33%|590/600
                Int32 pageCapture, pageTotal;
                pageTotal = _page;//总的记录数
                                  //获得pageCapture
                                  //目前根据关键词搜索吧,域名不太适用
                KiwiCrawler.BLL.Capturedata_kBll capBll = new KiwiCrawler.BLL.Capturedata_kBll();
                pageCapture = capBll.GetRecordCount("kNotes=" + "'" + configModel.kId + ":" + configModel.kKeyWords.Trim() + "'");
                double percentage = pageCapture * 1.0 / (pageTotal * 1.0);
                string msg = (percentage * 100).ToString("0.00") + "%" + "|" + pageCapture + "/" + pageTotal;
                configModel.kNotes = msg + "|R无详细页R|" + "T无详细页T";
                configModel.kComplateDegree = (decimal)percentage;
                if (configBll.Update(configModel))
                {
                    MessageBox.Show("完成情况为:" + msg);
                    this.Close();
                }


            }
            else
            {
                #region 有详细页
                string msg = "";
                if (!Int32.TryParse(txtRow.Text.Trim(), out _row))
                {
                    msg += "每页记录数输入有误\r\n";
                }
                if (!Int32.TryParse(txtTail.Text.Trim(), out _tail))
                {
                    msg += "末页记录数输入有误\r\n";
                }
                if (configModel.kPageTotal == null)
                {
                    msg += "选择网站总页数有误\r\n";
                }

                if (!string.IsNullOrEmpty(msg.Trim()))
                {
                    MessageBox.Show(msg);
                }
                _page = configModel.kPageTotal == null ? -1 : Convert.ToInt32(configModel.kPageTotal);
                //计算完成度
                // 98.33%|590/600
                Int32 pageCapture, pageTotal;
                pageTotal = _row * _page - (_row - _tail);//总的记录数
                                                          //获得pageCapture
                                                          //目前根据关键词搜索吧,域名不太适用
                KiwiCrawler.BLL.Capturedata_kBll capBll = new KiwiCrawler.BLL.Capturedata_kBll();
                pageCapture = capBll.GetRecordCount("kNotes=" + "'" + configModel.kId + ":" + configModel.kKeyWords.Trim() + "'") - _page;
                double percentage = pageCapture * 1.0 / (pageTotal * 1.0);
                msg = (percentage * 100).ToString("0.00") + "%" + "|" + pageCapture + "/" + pageTotal;
                configModel.kNotes = msg + "|R" + _row + "R|" + "T" + _tail + "T";
                configModel.kComplateDegree = (decimal)percentage;
                if (configBll.Update(configModel))
                {
                    MessageBox.Show("完成情况为:" + msg);
                    this.Close();
                }
                #endregion
            }


        }
Пример #12
0
 public frmEdit(KiwiCrawler.Model.Urlconfigs_k model)
     : this()
 {
     editFrmModel = new KiwiCrawler.Model.Urlconfigs_k();
     editFrmModel = model;
 }