using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Services;
using TopWinCMS.BLL;
using TopWinCMS.Common;
using TopWinCMS.GatherEngine;
using TopWinCMS.Model;

namespace TopWinCMS.WebUI.Admin.ArticleGather
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class GatherWeb : IHttpHandler
    { 
        /// <summary>
        /// 回发反馈信息
        /// </summary>
        List<string> Messages = new List<string>();
        /// <summary>
        /// 回发警告信息
        /// </summary>
        List<string> Alerts = new List<string>();
        /// <summary>
        /// 回发错误信息
        /// </summary>
        List<string> Errs = new List<string>();

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Expires = 0;
            context.Response.CacheControl = "no-cache";
            context.Response.ContentType = "text/plain";


            string Url = context.Server.UrlDecode(context.Request.Form["URL"]);
            string AdminName = AdminLoginInfo.UserName;
            int intBadLinkNum = int.Parse(context.Request.Form["BadLinkNum"]);
            bool IsTest = bool.Parse(context.Request.Form["IsTest"]);
            int ModelID = int.Parse(context.Request.Form["ModelID"]);
            int GatherID = int.Parse(context.Request.Form["ID"]);
            bool IsUpdate = bool.Parse(context.Request.Form["IsUpdate"]);
            bool IsLeech = bool.Parse(context.Request.Form["IsLeech"]);

            string ReturnString = "";
            GatherContentPage GC = new GatherContentPage(AdminName, intBadLinkNum, IsTest, ModelID, GatherID, IsUpdate, IsLeech);
            GC.BSGather(Url.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), ref ReturnString);



            context.Response.Write(ReturnString);
        }



        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}