zoukankan      html  css  js  c++  java
  • 动易SiteFactory数据采集模块

        动易这套系统的数据采集模块,是基于.Net2.0开发的,里用到了Asp.net Ajax,WebService,线程序等技术.
     具体实现思路是:
      数据采集类PowerEasy.Collection.CollectionProgress 的StartCreate()中启动数据采集线程
     代码如下: 
    private void StartCreate()
      {
        this.m_CreateThread = new Thread(new ThreadStart(this.Work));
        this.m_CreateThread.Start();
      }
    接着将自己保存到Appliction中

    public void CreateCollectionProc()
    {
        this.m_CreateId = Guid.NewGuid().ToString();
        if (HttpContext.Current != null)
        {
            this.m_PhysicalApplicationPath = this.PhysicalApplicationPath;
        }
        XmlManage manage = XmlManage.Instance("Config/CreateCollectionWork.config", XmlType.File);
        manage.SetNodeValue("CollectionWork/WorkId", this.m_CreateId);
        try
        {
            manage.Save("Config/CreateCollectionWork.config");
        }
        catch (FileNotFoundException)
        {
            throw new CustomException("CreateCollectionWork.config文件未找到。");
        }
        catch
        {
            throw new CustomException("检查您的服务器是否给配置文件CreateCollectionWork.config或文件夹写入权限。");
        }
        this.StartCreate();
        if (HttpContext.Current != null)
        {
            HttpContext.Current.Application[this.m_CreateId] = this;
        }

    }

     
    Application 的键,是一个生成的Guid 此Guid会保存到 /Config/CreateCollectionWork.config 文件中
    进度显示页面\Admin\Collection\CollectionProc.aspx 采用Ajax技术调用Web服务GetCreateProgressService.asmx中的public ProgressInfo AcquireProgress()方法获取CollectionProgress 实例的运行信息并显示给用户,

    具体的页面数据截取类为System.Net下的 WebRequest ,WebClient ,WebResponse等,采用WebClient类来下载文件,图片等.

    下面是Work方法的代码框架:
       try
        {
            try
            {
                //具体操作
            }
            catch (Exception exception)
            {
                this.m_ErrorInfo = exception.Message;
            }
        }
        finally
        {
            if (this.CreateThread != null)
            {
                this.CreateThread.Abort();
            }
        }


    通过new Thread(new ThreadStart(this.Work)); 启动的线程是非池线程,即不是Asp.net服务进程线程池的线程

  • 相关阅读:
    “12306”的架构到底有多牛逼
    数字治理
    浅谈web网站架构演变过程
    MapReduce基本原理
    Flink+Hologres亿级用户实时UV精确去重最佳实践
    全链路压测体系建设方案的思考与实践
    如何做好一场技术演讲?
    “控本焦虑”的工程企业 用钉钉宜搭找到了低成本数字化的“捷径”
    友盟+《小程序用户增长白皮书》:从五个角度入手分析小程序数据
    数字化让618有了洞悉消费者内心的“大脑”
  • 原文地址:https://www.cnblogs.com/wdfrog/p/1072218.html
Copyright © 2011-2022 走看看