using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using IReaper.FileData;
using IReaper.Running;
namespace IReaper.Statues{
public partial class CourseFileWorkBase : AsyncWork
{
IList<CourseFileData> data;
public CourseFileWorkBase()
{
InitializeComponent();
}
public CourseFileWorkBase(IContainer container)
{
container.Add(this);
InitializeComponent();
}
protected override void OnDoWork(DoWorkEventArgs e)
{
base.OnDoWork(e);
Running.DownloadEngine.PauseDownloadEngine(false);
//remove file in each
CourseFileData cfd = null;
BeforeEnterLoop();
CourseFileData[] files = new CourseFileData[data.Count];
data.CopyTo(files, 0);
for (int i = 0; i < files.Length;i++)
{
try
{
cfd = files[i];
if (cfd == null)
{
continue;
}
int percentage = (int)(i * 100 / this.data.Count);
this.ReportProgress(percentage, cfd.Owner.Headline + ":" + cfd.FileType.ToString());
TaskUnitEntry(cfd);
}
catch
{ }
}
AfterEnterLoop();
Running.DownloadEngine.ResumeDownloadEngine();
}
protected virtual void BeforeEnterLoop()
{ }
protected virtual void AfterEnterLoop()
{ }
protected virtual void TaskUnitEntry(CourseFileData data)
{ }
/// <summary>
///
/// </summary>
public IList<CourseFileData> Data
{
get { return data; }
set { data = value; }
}
}
}
|