private static void OnDownloadStatusChange(object sender, DownloadStatusChangeEventArgs e)
        {
            MediaFileDownload downloader  = sender as MediaFileDownload;
            string            statusImage = string.Empty;

            foreach (DownInfo info in MyDownloading)
            {
                if (info.VID == downloader.Tag as string)
                {
                    switch (e.Status)
                    {
                    case DownloadStatus.Paused:
                    case DownloadStatus.Error:
                    case DownloadStatus.Timeout:
                        foreach (DBMyDownloadInfo downInfo in DownFactory.GetAllRecords())
                        {
                            if (downInfo.VID == downloader.Tag as string)
                            {
                                if ((DateTime.Now.Second - _lastWriteDB.Second) >= _minDBOperationInterval)
                                {
                                    DownFactory.UpdateRecord(downloader.Tag as string, (int)e.Status, downloader.BytesReceived);
                                    _lastWriteDB = DateTime.Now;
                                }
                                break;
                            }
                        }
                        info.StatusImage = "/PPTVForWP7;component/Images/pause.png";
                        break;

                    case DownloadStatus.Downloading:
                        info.StatusImage = "/PPTVForWP7;component/Images/Download.png";
                        break;

                    case DownloadStatus.Completed:
                        MyDownloaded.Add(info);
                        MyDownloading.Remove(info);

                        break;

                    case DownloadStatus.Waiting:
                        info.StatusImage = "/PPTVForWP7;component/Images/waiting.png";
                        break;

                    case DownloadStatus.InsufficientDiskSpace:
                        MessageBox.Show("空间不足,请删除一些下载任务", "提示", MessageBoxButton.OK);
                        break;

                    default:
                        break;
                    }
                    break;
                }
            }

            DownFactory.UpdateRecord(downloader.Tag as string, (int)e.Status, -1);
        }
Exemple #2
0
        private static void OnDownloadStatusChange(object sender, DownloadStatusChangeEventArgs e)
        {
            MediaFileDownload downloader = sender as MediaFileDownload;
            string statusImage = string.Empty;
            foreach (DownInfo info in MyDownloading)
            {
                if (info.VID == downloader.Tag as string)
                {
                    switch (e.Status)
                    {
                        case DownloadStatus.Paused:
                        case DownloadStatus.Error:
                        case DownloadStatus.Timeout:
                            foreach (DBMyDownloadInfo downInfo in DownFactory.GetAllRecords())
                            {
                                if (downInfo.VID == downloader.Tag as string)
                                {
                                    if ((DateTime.Now.Second - _lastWriteDB.Second) >= _minDBOperationInterval)
                                    {
                                        DownFactory.UpdateRecord(downloader.Tag as string, (int)e.Status, downloader.BytesReceived);
                                        _lastWriteDB = DateTime.Now;
                                    }
                                    break;
                                }
                            }
                            info.StatusImage = "/PPTVForWP7;component/Images/pause.png";
                            break;
                        case DownloadStatus.Downloading:
                            info.StatusImage = "/PPTVForWP7;component/Images/Download.png";
                            break;
                        case DownloadStatus.Completed:
                            MyDownloaded.Add(info);
                            MyDownloading.Remove(info);

                            break;
                        case DownloadStatus.Waiting:
                            info.StatusImage = "/PPTVForWP7;component/Images/waiting.png";
                            break;
                        case DownloadStatus.InsufficientDiskSpace:
                            MessageBox.Show("空间不足,请删除一些下载任务", "提示", MessageBoxButton.OK);
                            break;
                        default:
                            break;
                    }
                    break;
                }
            }
            
            DownFactory.UpdateRecord(downloader.Tag as string, (int)e.Status, -1);


        }