public void _003CGetMeetingData_DoAction_003Eb__23()
            {
                FileDownloader instance = Singleton_FileDownloader.GetInstance(md.ID);

                instance.Stop();
                List <MeetingDataDownloadFileFile> list = new List <MeetingDataDownloadFileFile>();

                try
                {
                    MeetingDataMeetingsFileFile[] fileList = md.MeetingsFile.FileList;
                    foreach (MeetingDataMeetingsFileFile meetingDataMeetingsFileFile in fileList)
                    {
                        MeetingDataDownloadFileFile meetingDataDownloadFileFile = new MeetingDataDownloadFileFile();
                        meetingDataDownloadFileFile.AgendaID = "record";
                        meetingDataDownloadFileFile.FileName = meetingDataMeetingsFileFile.FileName;
                        meetingDataDownloadFileFile.ID       = meetingDataMeetingsFileFile.ID;
                        meetingDataDownloadFileFile.Url      = meetingDataMeetingsFileFile.Url;
                        meetingDataDownloadFileFile.version  = meetingDataMeetingsFileFile.version;
                        list.Add(meetingDataDownloadFileFile);
                    }
                }
                catch (Exception ex)
                {
                    LogTool.Debug(ex);
                }
                list.AddRange(Enumerable.ToList(md.DownloadFile.DownloadFileList));
                _003C_003E4__this.TotalFiles = list.Count;
                List <File_DownloadItemViewModel> list2 = new List <File_DownloadItemViewModel>();

                foreach (MeetingDataDownloadFileFile item in list)
                {
                    File_DownloadItemViewModel file_DownloadItemViewModel = FileItemTool.Gen(item, _003C_003E4__this.UserID, md.ID);
                    if (file_DownloadItemViewModel.DownloadBytes == 0 || file_DownloadItemViewModel.DownloadBytes < file_DownloadItemViewModel.TotalBytes)
                    {
                        list2.Add(file_DownloadItemViewModel);
                    }
                }
                if (!instance.HasMeetingRoom_DownloadFileStart_Event())
                {
                    instance.MeetingRoom_DownloadFileStart_Event += _003C_003E4__this.Start_callback;
                }
                if (!instance.HasMeetingRoom_DownloadProgressChanged_Event())
                {
                    instance.MeetingRoom_DownloadProgressChanged_Event += _003C_003E4__this.Progress_callback;
                }
                if (!instance.HasMeetingRoom_DownloadFileToErrorCompleted_Event())
                {
                    instance.MeetingRoom_DownloadFileToErrorCompleted_Event += _003C_003E4__this.ErrorFinish_callback;
                }
                instance.AddItem(list2);
            }
        private void btnPausing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            btnPausing.Visibility = Visibility.Collapsed;
            FileDownloader             instance = Singleton_FileDownloader.GetInstance(MeetingID);
            File_DownloadItemViewModel inList   = instance.GetInList(MeetingID);

            instance.AddItem(fileItem);
            if (inList != null)
            {
                if (instance.NowFileItem != null && instance.NowFileItem.ID.Equals(fileItem.ID))
                {
                    btnPausing.Visibility = Visibility.Collapsed;
                    txtPercent.Text       = (int)inList.LastPercentage + " %";
                    txtPercent.Foreground = Brushes.Black;
                    txtPercent.Visibility = Visibility.Visible;
                    pb.Value            = inList.NowPercentage;
                    pb.Foreground       = Brushes.Orange;
                    pb.Background       = Brushes.Black;
                    pb.Visibility       = Visibility.Visible;
                    btnPause.Visibility = Visibility.Visible;
                }
                else
                {
                    btnPausing.Visibility = Visibility.Collapsed;
                    txtPercent.Text       = "等待中";
                    txtPercent.Foreground = Brushes.Gray;
                    txtPercent.Visibility = Visibility.Visible;
                    pb.Value            = inList.NowPercentage;
                    pb.Foreground       = Brushes.Wheat;
                    pb.Background       = Brushes.Gray;
                    pb.Visibility       = Visibility.Visible;
                    btnPause.Visibility = Visibility.Visible;
                }
            }
            else
            {
                btnPausing.Visibility = Visibility.Collapsed;
                txtPercent.Text       = "等待中";
                txtPercent.Foreground = Brushes.Gray;
                txtPercent.Visibility = Visibility.Visible;
                pb.Foreground         = Brushes.Wheat;
                pb.Background         = Brushes.Gray;
                pb.Visibility         = Visibility.Visible;
                btnPause.Visibility   = Visibility.Visible;
            }
        }
        private void btnDownload_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            FileDownloader instance = Singleton_FileDownloader.GetInstance(MeetingID);

            instance.AddItem(fileItem);
            btnDownload.Visibility = Visibility.Collapsed;
            txtPercent.Text        = "等待中";
            txtPercent.Foreground  = Brushes.Gray;
            txtPercent.Visibility  = Visibility.Visible;
            pb.Foreground          = Brushes.Wheat;
            pb.Background          = Brushes.Gray;
            pb.Visibility          = Visibility.Visible;
            btnPause.Visibility    = Visibility.Visible;
            if (MeetingDataCT_RaiseAllDownload_Event != null)
            {
                MeetingDataCT_RaiseAllDownload_Event(fileItem.ID, false, false);
            }
        }
        private void GetMeetingData_DoAction(MeetingData md, Image btnImage)
        {
            //先判斷是否要invoke
            if (this.Dispatcher.CheckAccess() == false)
            {
                // 這裡是下載事件處理,優先權設定為ContextIdle => 列舉值為 3。 幕後作業完成後,會處理作業。
                this.Dispatcher.BeginInvoke(new Action <MeetingData, Image>(GetMeetingData_DoAction), md, btnImage);
            }
            else
            {
                if (md != null)
                {
                    Task.Factory.StartNew(() =>
                    {
                        FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(md.ID);
                        fileDownloader.Stop();

                        List <MeetingDataDownloadFileFile> FileList = new List <MeetingDataDownloadFileFile>();
                        try
                        {
                            // <File ID="cAS66-P" Url="http://com-meeting.ntpc.hyweb.com.tw/Public/MeetingAttachFile/2/2-b167-P.phej" FileName="ae717047" version="1"/>

                            // 如果meetingData.MeetingsFile.FileList沒有子節點,就會轉型失敗
                            //XmlNode[] FileListXml = (XmlNode[])md.MeetingsFile.FileList;
                            //foreach (XmlNode item in FileListXml)
                            foreach (MeetingDataMeetingsFileFile item in md.MeetingsFile.FileList)
                            {
                                MeetingDataDownloadFileFile recordFile = new MeetingDataDownloadFileFile();
                                recordFile.AgendaID = "record";
                                //recordFile.FileName = item.Attributes["FileName"].Value;
                                //recordFile.ID = item.Attributes["ID"].Value;
                                //recordFile.Url = item.Attributes["Url"].Value;
                                //recordFile.version = byte.Parse(item.Attributes["version"].Value);
                                recordFile.FileName = item.FileName;
                                recordFile.ID       = item.ID;
                                recordFile.Url      = item.Url;
                                recordFile.version  = item.version;
                                FileList.Add(recordFile);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogTool.Debug(ex);
                        }

                        FileList.AddRange(md.DownloadFile.DownloadFileList.ToList());
                        TotalFiles = FileList.Count;
                        List <File_DownloadItemViewModel> fileItemList = new List <File_DownloadItemViewModel>();
                        foreach (MeetingDataDownloadFileFile meetingDataDownloadFileFile in FileList)
                        {
                            File_DownloadItemViewModel fileItem = FileItemTool.Gen(meetingDataDownloadFileFile, UserID, md.ID);
                            if (fileItem.DownloadBytes == 0 || fileItem.DownloadBytes < fileItem.TotalBytes)
                            {
                                fileItemList.Add(fileItem);
                            }
                        }


                        if (fileDownloader.HasMeetingRoom_DownloadFileStart_Event() == false)
                        {
                            fileDownloader.MeetingRoom_DownloadFileStart_Event += Start_callback;
                        }

                        if (fileDownloader.HasMeetingRoom_DownloadProgressChanged_Event() == false)
                        {
                            fileDownloader.MeetingRoom_DownloadProgressChanged_Event += Progress_callback;
                        }

                        if (fileDownloader.HasMeetingRoom_DownloadFileToErrorCompleted_Event() == false)
                        {
                            fileDownloader.MeetingRoom_DownloadFileToErrorCompleted_Event += ErrorFinish_callback;
                        }



                        fileDownloader.AddItem(fileItemList);
                    });

                    btnImage.Visibility = Visibility.Collapsed;
                    if (btnImage.Name.Equals(btnDownload.Name) == true)
                    {
                        txtPercent.Text = "0 %";
                        pb.Value        = pb.Minimum;
                    }
                    txtPercent.Foreground = Brushes.Black;
                    pb.Foreground         = Brushes.Orange;
                    pb.Background         = Brushes.Black;

                    txtPercent.Visibility = Visibility.Visible;
                    pb.Visibility         = Visibility.Visible;
                    btnPause.Visibility   = Visibility.Visible;
                }
                else
                {
                    AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                }
                MouseTool.ShowArrow();
            }
        }
Exemple #5
0
        // 準備做開啟下載,UI物件的顯示順序和btnPause是相反的
        private void btnPausing_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 隱藏要先做
            btnPausing.Visibility = Visibility.Collapsed;

            FileDownloader             fileDownloader  = Singleton_FileDownloader.GetInstance(MeetingID);
            File_DownloadItemViewModel _InListFileItem = fileDownloader.GetInList(MeetingID);

            fileDownloader.AddItem(fileItem);
            // 等待下載器自己開始。
            //Thread.Sleep(500);

            // 有排入下載,不用再開新下載
            if (_InListFileItem != null)
            {
                // 正在下載的檔案物件,正在下載的物件跟現在的檔案ID相同的話。
                // 正在下載的ID相同,就讓它繼續下載吧
                if (fileDownloader.NowFileItem != null && fileDownloader.NowFileItem.ID.Equals(fileItem.ID))
                {
                    // 進度和進度條是黑色可見
                    // 進度條文字顯示百分比
                    // 藍色暫停可見
                    // 橘色暫停不可見
                    btnPausing.Visibility = Visibility.Collapsed;
                    txtPercent.Text       = ((int)_InListFileItem.LastPercentage).ToString() + " %";
                    txtPercent.Foreground = Brushes.Black;
                    txtPercent.Visibility = Visibility.Visible;
                    pb.Value            = _InListFileItem.NowPercentage;
                    pb.Foreground       = Brushes.Orange;
                    pb.Background       = Brushes.Black;
                    pb.Visibility       = Visibility.Visible;
                    btnPause.Visibility = Visibility.Visible;
                    //goto TriggerFirst;
                    return;
                }
                else // 排入下載的檔案物件,但是未下載,所以藍色的 btnPause還是不能顯示
                {
                    // 進度和進度條是灰色可見
                    // 進度條文字顯示等待中
                    // 藍色暫停可見
                    // 橘色暫停不可見
                    btnPausing.Visibility = Visibility.Collapsed;
                    txtPercent.Text       = "等待中";
                    txtPercent.Foreground = Brushes.Gray;
                    txtPercent.Visibility = Visibility.Visible;
                    pb.Value            = _InListFileItem.NowPercentage;
                    pb.Foreground       = Brushes.Wheat;
                    pb.Background       = Brushes.Gray;
                    pb.Visibility       = Visibility.Visible;
                    btnPause.Visibility = Visibility.Visible;
                    //goto TriggerFirst;
                    return;
                }
            }
            else // 沒有下載中的物件可以判斷,只能以自身的進度判斷
            {
                // 要先變換
                // 進度和進度條是灰色可見
                // 進度條文字顯示等待中
                // 藍色暫停可見
                // 橘色暫停不可見
                btnPausing.Visibility = Visibility.Collapsed;
                txtPercent.Text       = "等待中";
                txtPercent.Foreground = Brushes.Gray;
                txtPercent.Visibility = Visibility.Visible;
                //pb.Value = fileItem.NowPercentage;
                pb.Foreground       = Brushes.Wheat;
                pb.Background       = Brushes.Gray;
                pb.Visibility       = Visibility.Visible;
                btnPause.Visibility = Visibility.Visible;
                //goto TriggerFirst;
                return;
            }

            //TriggerFirst:
            //MeetingDataCT_FirstTimeDownload_Event(this.meetingDataDownloadFileFile.ID);
        }