/// <summary>
        /// 处理内容
        /// </summary>
        /// <param name="content">Content实例</param>
        private void DoProcess(Content content)
        {
            if (null == this.settings.ContentHandlers && null == content.RawUrl.ContentHandlers)
            {
                return;
            }

            if (null == content)
            {
                return;
            }

            //排序处理程序集合
            List <IContentHandler> handlers = new List <IContentHandler>();

            foreach (IContentHandler h in this.settings.ContentHandlers)
            {
                if (null != h)
                {
                    handlers.Add(h);
                }
            }

            foreach (IContentHandler h in content.RawUrl.ContentHandlers)
            {
                if (null != h)
                {
                    handlers.Add(h);
                }
            }

            handlers.Sort(new ContentHandlerPriorityCompare());

            ProcessContext context = new ProcessContext(this);

            using (content)
            {
                //按照优先次序调用内容处理程序
                foreach (IContentHandler handler in handlers)
                {
                    handler.Process(content, context);
                }

                //处理完成后操作
                this.OnProcessCompleted(content, context);
            }

            Thread.Sleep((int)this.settings.SpeedMode);
        }
        /// <summary>
        /// 处理内容
        /// </summary>
        /// <param name="content">Content实例</param>
        private void DoProcess(Content content)
        {
            if (null == this.settings.ContentHandlers && null == content.RawUrl.ContentHandlers)
            {
                return;
            }

            if (null == content)
            {
                return;
            }

            //排序处理程序集合
            List<IContentHandler> handlers = new List<IContentHandler>();
            foreach (IContentHandler h in this.settings.ContentHandlers)
            {
                if (null != h)
                {
                    handlers.Add(h);
                }
            }

            foreach (IContentHandler h in content.RawUrl.ContentHandlers)
            {
                if (null != h)
                {
                    handlers.Add(h);
                }
            }

            handlers.Sort(new ContentHandlerPriorityCompare());

            ProcessContext context = new ProcessContext(this);

            using (content)
            {
                //按照优先次序调用内容处理程序
                foreach (IContentHandler handler in handlers)
                {
                    handler.Process(content, context);
                }

                //处理完成后操作
                this.OnProcessCompleted(content, context);
            }

            Thread.Sleep((int)this.settings.SpeedMode);
        }
 /// <summary>
 /// 在派生类中重写此方法,以便在完成对一个Content处理之后进行处理
 /// </summary>
 /// <param name="content">Content</param>
 /// <param name="context">ProcessContext</param>
 protected virtual void OnProcessCompleted(Content content, ProcessContext context)
 {
     //
 }
Exemple #4
0
 /// <summary>
 /// 在派生类中重写此方法,对内容进行处理
 /// </summary>
 /// <param name="content">Content实例</param>
 /// <param name="context">ProcessContext上下文信息</param>
 public abstract void Process(Content content, ProcessContext context);
Exemple #5
0
        public void Process(Content content, ProcessContext context)
        {
            if (!(content is TextContent))
            {
                return;
            }

            content.SaveToFile(@"E:\SOUEX\tmp\" + content.RawUrl.GetRawParam("id")+".txt");

            Console.WriteLine("提取Email From: {0}", content.RawUrl.GetUrl());
            Match m = mReg.Match(((TextContent)content).Content);

            if (null != m && m.Success)
            {
                string sql = String.Format("UPDATE users SET email='{0}' WHERE uid='{1}'", m.Value, content.RawUrl.GetRawParam("id"));
                Console.WriteLine(sql);
                db.ExecuteNonQuery(sql);
            }
        }
Exemple #6
0
        public void Process(Content content, ProcessContext context)
        {
            if (!(content is TextContent))
            {
                return;
            }

            //content.SaveToFile(Utils.GetAppPath() +"DATA\\"+ content.RawUrl.CheckSum+".txt");

            StringDictionary list = new StringDictionary();
            string uid, uname;

            MatchCollection matches = mReg.Matches(((TextContent)content).Content);
            foreach (Match m in matches)
            {
                if (!m.Success)
                {
                    continue;
                }
                uid = m.Groups["ID"].Value;
                uname = m.Groups["NAME"].Value;
                if (!String.IsNullOrEmpty(uid) && !list.ContainsKey(uid) && !String.IsNullOrEmpty(uname))
                {
                    list.Add(uid, uname);
                    Console.WriteLine("ID={0},Name='{1}'", uid, uname);
                }
            }

            if (list.Count == 0)
            {
                return;
            }

            foreach (string k in list.Keys)
            {
                string sql = String.Format("select COUNT(`uid`) from users where uid={0:d}", k);
                int n = Convert.ToInt32(db.ExecuteScalar(sql));
                if (n > 0)
                {
                    continue;
                }

                sql = String.Format("INSERT INTO users (uid, uname, email)VALUES('{0:d}', '{1}', '');", k, list[k]);
                db.ExecuteNonQuery(sql);
            }
        }
 /// <summary>
 /// 在派生类中重写此方法,对内容进行处理
 /// </summary>
 /// <param name="content">Content实例</param>
 /// <param name="context">ProcessContext上下文信息</param>
 public abstract void Process(Content content, ProcessContext context);
 /// <summary>
 /// 在派生类中重写此方法,以便在完成对一个Content处理之后进行处理
 /// </summary>
 /// <param name="content">Content</param>
 /// <param name="context">ProcessContext</param>
 protected virtual void OnProcessCompleted(Content content, ProcessContext context)
 {
     //
 }