Exemple #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.SpiderInfo model)
        {
            string startUrl   = model.start_urls;
            string loginUrl   = model.login_url;
            string customData = model.customdata;
            string ruleData   = model.ruledatas;

            if (startUrl != "")
            {
                startUrl = model.start_urls.Replace(@"'", @"\'");
            }
            if (loginUrl != null)
            {
                loginUrl = model.login_url.Replace(@"'", @"\'");
            }
            if (customData != "")
            {
                customData = model.customdata.Replace(@"'", @"\'");
            }
            if (ruleData != "")
            {
                ruleData = model.ruledatas.Replace(@"'", @"\'");
            }
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SpiderInfo(");
            strSql.Append("spiderName,website,files_store,start_urls,allowed_domains,rules,class,loader,away,login_url,_account,customdata,cls,ruledatas,cookies)");
            strSql.Append(" values (");
            string values = "'" + model.spidername + "','" + model.website + "','" + model.file_store + "',\"" + startUrl + "\",'" + model.allowed_domains + "','" + model.rules + "','" + model._class + "','" + model.loader + "','" + model.away + "',\"" + loginUrl + "\",'" + model.account + "','" + customData + "','" + model.cls + "','" + ruleData + "','" + model.cookies + "')";

            strSql.Append(values);

            int rows = mshelper.InsertSQl(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.SpiderInfo model)
        {
            string startUrl   = model.start_urls;
            string loginUrl   = model.login_url;
            string customData = model.customdata;
            string ruleData   = model.ruledatas;

            if (startUrl != "")
            {
                startUrl = model.start_urls.Replace(@"'", @"\'");
            }
            if (loginUrl != null)
            {
                loginUrl = model.login_url.Replace(@"'", @"\'");
            }
            if (customData != "")
            {
                customData = model.customdata.Replace(@"'", @"\'");
            }
            if (ruleData != "")
            {
                ruleData = model.ruledatas.Replace(@"'", @"\'");
            }
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SpiderInfo set ");
            strSql.Append("website='" + model.website + "',files_store='" + model.file_store + "',start_urls=\"" + model.start_urls + "\",allowed_domains='" + model.allowed_domains + "',Rules='" + model.rules + "',class='" + model._class +
                          "',loader='" + model.loader + "',away='" + model.away + "',login_url=\"" + model.login_url + "\",_account='" + model.account + "',customdata='" + customData + "',cls='" + model.cls + "',ruledatas='" + ruleData + "',cookies='" + model.cookies + "'");
            strSql.Append(" where spiderName='" + model.spidername + "'");
            int rows = mshelper.UpdateSQl(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
 /// <summary>
 /// 更新
 /// </summary>
 public bool Update(Model.SpiderInfo model)
 {
     return(dal.Update(model));
 }
Exemple #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Model.SpiderInfo model)
 {
     return(dal.Add(model));
 }