Ejemplo n.º 1
0
        private void _003CbtnPause_MouseLeftButtonDown_003Eb__27()
        {
            FileDownloader instance = Singleton_FileDownloader.GetInstance(userMeeting.ID);

            instance.ClearMeetingRoomEvent();
            instance.Stop();
        }
Ejemplo n.º 2
0
            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);
            }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        private void ajaxLoader_ChangeImage(object sender, EventArgs e)
        {
            string uriString = string.Format("images/ajaxLoader/{0}.gif", i);

            ajaxLoader.Source = new BitmapImage(new Uri(uriString, UriKind.Relative));
            i++;
            if (ForceStopAjaxLoader || i >= 11)
            {
                ajaxTimer.Stop();
                ajaxLoader.Visibility = Visibility.Collapsed;
                i = 1;
                FileDownloader instance = Singleton_FileDownloader.GetInstance(userMeeting.ID);
                if (instance.downloaderType != DownloaderType.正在下載中)
                {
                    ShowBtnPercent(FinishedPercent);
                }
            }
        }
Ejemplo n.º 6
0
        private void btnPause_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            Task.Factory.StartNew(() =>
            {
                FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(userMeeting.ID);
                fileDownloader.ClearMeetingRoomEvent();
                fileDownloader.Stop();
            });


            this.btnPause.Visibility   = Visibility.Collapsed;
            this.txtPercent.Foreground = Brushes.Gray;
            this.pb.Foreground         = Brushes.Wheat;
            this.pb.Background         = Brushes.Gray;
            this.txtPercent.Visibility = Visibility.Visible;
            this.btnPausing.Visibility = Visibility.Visible;
        }
Ejemplo n.º 7
0
        private void InitEvent()
        {
            // 下載事件不能這麼快掛上去,要等全部FileRow產生完成,在掛上去
            // 不然如果在下載中,會阻塞到UI的產生
            FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(userMeeting.ID);

            Start_callback       = new MeetingRoom_DownloadFileStart_Function(MeetingRoom_DownloadFileStart_Callback);
            Progress_callback    = new MeetingRoom_DownloadProgressChanged_Function(MeetingRoom_DownloadProgressChanged_Callback);
            ErrorFinish_callback = new MeetingRoom_DownloadFileToErrorCompleted_Function(MeetingRoom_DownloadFileToErrorCompleted_Callback);

            fileDownloader.MeetingRoom_DownloadFileStart_Event            += Start_callback;
            fileDownloader.MeetingRoom_DownloadProgressChanged_Event      += Progress_callback;
            fileDownloader.MeetingRoom_DownloadFileToErrorCompleted_Event += ErrorFinish_callback;


            this.MouseLeftButtonDown += MeetingRoom_MouseLeftButtonDown;

            btnSeries.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnSeries.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnSeries.MouseLeftButtonDown += btnSeries_MouseLeftButtonDown;

            btnDelete.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnDelete.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnDelete.MouseLeftButtonDown += btnDelete_MouseLeftButtonDown;

            btnRefresh.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnRefresh.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnRefresh.MouseLeftButtonDown += btnDownload_btnPausing_MouseLeftButtonDown;

            btnDownload.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnDownload.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnDownload.MouseLeftButtonDown += btnDownload_btnPausing_MouseLeftButtonDown;

            // 要變成暫停下載
            btnPause.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnPause.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnPause.MouseLeftButtonDown += btnPause_MouseLeftButtonDown;

            // 要變成繼續下載
            btnPausing.MouseEnter          += (sender, e) => { MouseTool.ShowHand(); };
            btnPausing.MouseLeave          += (sender, e) => { MouseTool.ShowArrow(); };
            btnPausing.MouseLeftButtonDown += btnDownload_btnPausing_MouseLeftButtonDown;
        }
Ejemplo n.º 8
0
        private void btnPause_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            btnPause.Visibility = Visibility.Collapsed;
            FileDownloader             instance = Singleton_FileDownloader.GetInstance(MeetingID);
            File_DownloadItemViewModel inList   = instance.GetInList(MeetingID);

            instance.Pause(meetingDataDownloadFileFile.ID);
            int num = 0;

            num = ((inList == null) ? ((int)fileItem.NowPercentage) : ((int)inList.NowPercentage));
            btnPause.Visibility   = Visibility.Collapsed;
            txtPercent.Text       = num + " %";
            txtPercent.Foreground = Brushes.Gray;
            txtPercent.Visibility = Visibility.Visible;
            pb.Value              = num;
            pb.Foreground         = Brushes.Wheat;
            pb.Background         = Brushes.Gray;
            pb.Visibility         = Visibility.Visible;
            btnPausing.Visibility = Visibility.Visible;
        }
Ejemplo n.º 9
0
        // 準備做暫停
        private void btnPause_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 隱藏要先做
            btnPause.Visibility = Visibility.Collapsed;

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

            fileDownloader.Pause(meetingDataDownloadFileFile.ID);
            // 等待下載器自己暫停。
            //Thread.Sleep(500);

            // 進度和進度條是灰色可見
            // 進度條文字顯示進度
            int percent = 0;

            if (_InListFileItem != null)
            {
                percent = (int)_InListFileItem.NowPercentage;
            }
            else
            {
                percent = (int)this.fileItem.NowPercentage;
            }
            // 進度和進度條是灰色可見
            // 進度條文字顯示進度
            // 藍色暫停不可見
            // 橘色暫停可見
            btnPause.Visibility   = Visibility.Collapsed;
            txtPercent.Text       = percent.ToString() + " %";
            txtPercent.Foreground = Brushes.Gray;
            txtPercent.Visibility = Visibility.Visible;
            pb.Value              = percent;
            pb.Foreground         = Brushes.Wheat;
            pb.Background         = Brushes.Gray;
            pb.Visibility         = Visibility.Visible;
            btnPausing.Visibility = Visibility.Visible;
            return;
        }
Ejemplo n.º 10
0
        //int ajaxTimes = 1;
        private void ajaxLoader_ChangeImage(object sender, EventArgs e)
        {
            string fileName = string.Format("images/ajaxLoader/{0}.gif", i);

            ajaxLoader.Source = new BitmapImage(new Uri(fileName, UriKind.Relative));
            i++;
            if (ForceStopAjaxLoader == true || i >= 11)
            {
                //i = 0;
                //if (ForceStopAjaxLoader==true || ajaxTimes > 1 )
                //{
                ajaxTimer.Stop();
                ajaxLoader.Visibility = Visibility.Collapsed;
                i = 1;          // Display first image after the last image

                FileDownloader fileItem = Singleton_FileDownloader.GetInstance(userMeeting.ID);
                if (fileItem.downloaderType != DownloaderType.正在下載中)
                {
                    ShowBtnPercent(this.FinishedPercent);
                }
                //}
                //ajaxTimes++;
            }
        }
Ejemplo n.º 11
0
        private void InitSelectDB()
        {
            Action action = null;

            txtIndex.Text    = index.ToString();
            txtFileName.Text = meetingDataDownloadFileFile.FileName;
            FileDownloader instance = Singleton_FileDownloader.GetInstance(MeetingID);

            fileItem = instance.GetInList(meetingDataDownloadFileFile.ID);
            if (fileItem != null)
            {
                IsWaitingForDownload = true;
                TaskFactory factory = Task.Factory;
                if (action == null)
                {
                    action = new Action(_003CInitSelectDB_003Eb__0);
                }
                factory.StartNew(action);
            }
            else
            {
                Task.Factory.StartNew(new Action(_003CInitSelectDB_003Eb__4)).ContinueWith(new Action <Task>(_003CInitSelectDB_003Eb__2));
            }
        }
Ejemplo n.º 12
0
        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();
            }
        }
Ejemplo n.º 13
0
 private void MeetingRoom_Unloaded(object sender, RoutedEventArgs e)
 {
     Singleton_FileDownloader.GetInstance(userMeeting.ID).ClearMeetingRoomEvent();
 }
Ejemplo n.º 14
0
        private void InitEvent()
        {
            FileDownloader instance = Singleton_FileDownloader.GetInstance(userMeeting.ID);

            Start_callback       = new MeetingRoom_DownloadFileStart_Function(MeetingRoom_DownloadFileStart_Callback);
            Progress_callback    = new MeetingRoom_DownloadProgressChanged_Function(MeetingRoom_DownloadProgressChanged_Callback);
            ErrorFinish_callback = new MeetingRoom_DownloadFileToErrorCompleted_Function(MeetingRoom_DownloadFileToErrorCompleted_Callback);
            instance.MeetingRoom_DownloadFileStart_Event            += Start_callback;
            instance.MeetingRoom_DownloadProgressChanged_Event      += Progress_callback;
            instance.MeetingRoom_DownloadFileToErrorCompleted_Event += ErrorFinish_callback;
            base.MouseLeftButtonDown += new MouseButtonEventHandler(MeetingRoom_MouseLeftButtonDown);
            Image image = btnSeries;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate13 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate13 = new MouseEventHandler(_003CInitEvent_003Eb__7);
            }
            image.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate13;
            Image image2 = btnSeries;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate14 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate14 = new MouseEventHandler(_003CInitEvent_003Eb__8);
            }
            image2.MouseLeave             += CS_0024_003C_003E9__CachedAnonymousMethodDelegate14;
            btnSeries.MouseLeftButtonDown += new MouseButtonEventHandler(btnSeries_MouseLeftButtonDown);
            Image image3 = btnDelete;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate15 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate15 = new MouseEventHandler(_003CInitEvent_003Eb__9);
            }
            image3.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate15;
            Image image4 = btnDelete;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate16 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate16 = new MouseEventHandler(_003CInitEvent_003Eb__a);
            }
            image4.MouseLeave             += CS_0024_003C_003E9__CachedAnonymousMethodDelegate16;
            btnDelete.MouseLeftButtonDown += new MouseButtonEventHandler(btnDelete_MouseLeftButtonDown);
            Image image5 = btnRefresh;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate17 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate17 = new MouseEventHandler(_003CInitEvent_003Eb__b);
            }
            image5.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate17;
            Image image6 = btnRefresh;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate18 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate18 = new MouseEventHandler(_003CInitEvent_003Eb__c);
            }
            image6.MouseLeave += CS_0024_003C_003E9__CachedAnonymousMethodDelegate18;
            btnRefresh.MouseLeftButtonDown += new MouseButtonEventHandler(btnDownload_btnPausing_MouseLeftButtonDown);
            Image image7 = btnDownload;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate19 == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate19 = new MouseEventHandler(_003CInitEvent_003Eb__d);
            }
            image7.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate19;
            Image image8 = btnDownload;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate1a == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate1a = new MouseEventHandler(_003CInitEvent_003Eb__e);
            }
            image8.MouseLeave += CS_0024_003C_003E9__CachedAnonymousMethodDelegate1a;
            btnDownload.MouseLeftButtonDown += new MouseButtonEventHandler(btnDownload_btnPausing_MouseLeftButtonDown);
            Image image9 = btnPause;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate1b == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate1b = new MouseEventHandler(_003CInitEvent_003Eb__f);
            }
            image9.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate1b;
            Image image10 = btnPause;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate1c == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate1c = new MouseEventHandler(_003CInitEvent_003Eb__10);
            }
            image10.MouseLeave           += CS_0024_003C_003E9__CachedAnonymousMethodDelegate1c;
            btnPause.MouseLeftButtonDown += new MouseButtonEventHandler(btnPause_MouseLeftButtonDown);
            Image image11 = btnPausing;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate1d == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate1d = new MouseEventHandler(_003CInitEvent_003Eb__11);
            }
            image11.MouseEnter += CS_0024_003C_003E9__CachedAnonymousMethodDelegate1d;
            Image image12 = btnPausing;

            if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate1e == null)
            {
                CS_0024_003C_003E9__CachedAnonymousMethodDelegate1e = new MouseEventHandler(_003CInitEvent_003Eb__12);
            }
            image12.MouseLeave             += CS_0024_003C_003E9__CachedAnonymousMethodDelegate1e;
            btnPausing.MouseLeftButtonDown += new MouseButtonEventHandler(btnDownload_btnPausing_MouseLeftButtonDown);
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        private void InitSelectDB()
        {
            //Wayne 20150429
            //從InitUI()移動到這裡
            //if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == false)
            //{
            txtIndex.Text = index.ToString();
            //}
            //else
            //{
            //    Grid.SetColumn(txtFileName, 0);
            //    Grid.SetColumnSpan(txtFileName, 2);
            //    lineCenter.BorderBrush = Brushes.Transparent;
            //}
            txtFileName.Text = meetingDataDownloadFileFile.FileName;

            // 這裡要確保FileItem已將產生出來
            // 才能做UI
            FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(MeetingID);

            fileItem = fileDownloader.GetInList(meetingDataDownloadFileFile.ID);

            if (fileItem != null)
            {
                IsWaitingForDownload = true;

                Task.Factory.StartNew(() =>
                {
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        InitUI();
                        // 有下載UI相關的把事件放到主線成
                        InitEvent();
                    }));
                });

                return;
            }


            // 取不到FileItem才去DB抓FileItem的狀態。
            Task.Factory.StartNew(() =>
            {
                fileItem = FileItemTool.Gen(meetingDataDownloadFileFile, UserID, MeetingID);
                if (fileItem.FileType == MeetingFileType.已下載完成)
                {
                    if (MeetingDataCT_Counting_Finished_FileCount_Event != null)
                    {
                        MeetingDataCT_Counting_Finished_FileCount_Event();
                    }
                }
            }).ContinueWith(task => {
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    InitUI();
                    // 有下載UI相關的把事件放到主線成
                    InitEvent();
                }));
            });



//            // 更新檔不支援續傳
//            // 檢查是否再下載當中
//            FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(MeetingID);
//            fileItem = fileDownloader.GetInList(meetingDataDownloadFileFile.ID);
//            if (fileItem != null)
//                return;

//            #region DB
//            string db_FileRowID = "";
//            string db_Url = "";
//            string db_StorageFileName = "";
//            long db_DownloadBytes = 0;
//            long db_TotalBytes = 0;
//            string SQL = "";
//            int success = 0;
//            DataTable dt = MSCE.GetDataTable("SELECT ID,Url,StorageFileName,DownloadBytes,TotalBytes FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3"
//                                   , meetingDataDownloadFileFile.ID
//                                   , UserID
//                                   , MeetingID);
//            if (dt.Rows.Count > 0)
//            {
//                db_FileRowID = dt.Rows[0]["ID"].ToString();
//                db_Url = dt.Rows[0]["Url"].ToString();
//                db_StorageFileName = dt.Rows[0]["StorageFileName"].ToString();
//                db_DownloadBytes = long.Parse(dt.Rows[0]["DownloadBytes"].ToString().Equals("") ? "0" : dt.Rows[0]["DownloadBytes"].ToString());
//                db_TotalBytes = long.Parse(dt.Rows[0]["TotalBytes"].ToString().Equals("") ? "0" : dt.Rows[0]["TotalBytes"].ToString());
//            }
//            else
//            {
//                SQL = @"INSERT INTO FileRow(ID,DownloadBytes,TotalBytes,UserID,MeetingID)
//                                                    VALUES(@1,0,0,@2,@3)";
//                success = MSCE.ExecuteNonQuery(SQL
//                                                   , meetingDataDownloadFileFile.ID
//                                                   , UserID
//                                                   , MeetingID);
//                if (success < 1)
//                    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
//            }
//            #endregion

//            fileItem = new File_DownloadItemViewModel();
//            fileItem.MeetingID = MeetingID;
//            fileItem.ID = meetingDataDownloadFileFile.ID;
//            fileItem.UserID = UserID;
//            fileItem.FileName = meetingDataDownloadFileFile.FileName;
//            fileItem.Url = meetingDataDownloadFileFile.Url;

//            string AppPath = System.AppDomain.CurrentDomain.BaseDirectory;
//            string File_StorageFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_StorageFileFolder;
//            fileItem.StorageFileFolder = System.IO.Path.Combine(AppPath, File_StorageFileFolder);

//            #region 取得 Http URL 的檔名
//            string fileName = DateTime.Now.ToFileTime().ToString();
//            try
//            {
//                Uri uri = new Uri(fileItem.Url);
//                string tempFileName = System.IO.Path.GetFileName(uri.LocalPath);
//                if (tempFileName.Equals(@"/") == false)
//                    fileName = tempFileName;
//            }
//            catch (Exception ex)
//            {
//                LogTool.Debug(ex);
//            }
//            #endregion

//            fileItem.StorageFileName = string.Format("{0}_{1}_{2}_{3}", UserID, MeetingID, meetingDataDownloadFileFile.ID, fileName);
//            fileItem.UnZipFileFolder = ClickOnceTool.GetFilePath()+"\\"+PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
//            fileItem.DownloadBytes = db_DownloadBytes;
//            fileItem.TotalBytes = db_TotalBytes;

//            // 先檢查檔案存不存在
//            if (File.Exists(fileItem.StorageFilePath) == true)
//            {
//                // 未下載完成的
//                if (db_DownloadBytes == 0)
//                {
//                    // 刪除未下載完成但是檔案存在的,但是DB紀錄為沒有下載過的,或是被刪除的
//                    if (File.Exists(fileItem.StorageFilePath) == true)
//                        File.Delete(fileItem.StorageFilePath);

//                    fileItem.DownloadBytes = 0;
//                    fileItem.TotalBytes = 0;
//                    fileItem.FileType = MeetingFileType.從未下載;

//                }
//                else if (db_DownloadBytes < db_TotalBytes) //未下載完成的,有下載過的
//                {
//                    fileItem.DownloadBytes = db_DownloadBytes;
//                    fileItem.TotalBytes =  db_TotalBytes;
//                    fileItem.FileType = MeetingFileType.已下載過但是未完成的檔案;
//                }
//                else
//                {
//                    fileItem.FileType = MeetingFileType.已下載完成;
//                    //結束;
//                }
//            }
//            else
//            {
//                fileItem.DownloadBytes = 0;
//                fileItem.TotalBytes = 0;
//                fileItem.FileType = MeetingFileType.從未下載;
//            }

//            // 把DB的檔案資訊更新
//            SQL = @"update FileRow set DownloadBytes=@1,TotalBytes=@2,UserID=@3,MeetingID=@4 where ID=@5";
//            success = MSCE.ExecuteNonQuery(SQL
//                                           , fileItem.DownloadBytes.ToString()
//                                           , fileItem.TotalBytes.ToString()
//                                           , UserID
//                                           , MeetingID
//                                           , fileItem.ID);
//            if (success < 1)
//                LogTool.Debug(new Exception(@"DB失敗: " + SQL));
        }