日期:2014-05-17 浏览次数:20772 次
private void btnDownload_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(tbInputs.Text))
{
MessageBox.Show("请输入要下载的产品信息,包括产品编号和下载地址,多个产品请用换行分开");
return;
}
btnDownload.Enabled = false;
ThreadStart ts = new ThreadStart(StartDownload);
workerThread = new Thread(ts);
workerThread.Start();
}
private void StartDownload() {
string[] products = tbInputs.Text.Split('\n');
int i = 0;
foreach (var product in products)
{
i++;
var productInfo = product.Split(',');
string productCode = productInfo[0].Trim();
string downloadURL = productInfo[1].Trim();
if (string.IsNullOrEmpty(productCode) || string.IsNullOrEmpty(downloadURL))
{
AddDownloadResult(productCode, downloadURL, 0, i, products.Length, true);
continue;
}
var pro = TmallProductFactory.GetProduct(productCode, downloadURL);
if (pro != null)
{
int cnt = pro.DownloadPictures();
&n