動易SiteFactory資料擷取模組

來源:互聯網
上載者:User
    動易這套系統的資料擷取模組,是基於.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服務進程線程池的線程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.