private void _003CInitSelectDB_003Eb__4() { fileItem = FileItemTool.Gen(meetingDataDownloadFileFile, UserID, MeetingID); if (fileItem.FileType == MeetingFileType.已下載完成 && MeetingDataCT_Counting_Finished_FileCount_Event != null) { MeetingDataCT_Counting_Finished_FileCount_Event(); } }
public void _003CInitSelectDB_003Eb__2() { int num = 0; foreach (MeetingDataDownloadFileFile file in FileList) { num++; File_DownloadItemViewModel fileItem = FileItemTool.Gen(file, _003C_003E4__this.UserID, _003C_003E4__this.MeetingID); _003C_003E4__this.PDFFactoryRowSP.Children.Add(new PDFFactoryRow(num, fileItem)); } }
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 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(); } }
private void InitSelectDB() { DataTable dt = MSCE.GetDataTable("select MeetingID,UserID from NowLogin"); if (dt.Rows.Count > 0) { this.MeetingID = dt.Rows[0]["MeetingID"].ToString().Trim(); this.UserID = dt.Rows[0]["UserID"].ToString().Trim(); } //DB查詢登入 dt = MSCE.GetDataTable("select MeetingJson from MeetingData where MeetingID=@1 and UserID =@2" , MeetingID , UserID); if (dt.Rows.Count > 0) { md = JsonConvert.DeserializeObject <MeetingData>(dt.Rows[0]["MeetingJson"].ToString()); //Task.Factory.StartNew(() => //{ //this.Dispatcher.BeginInvoke(new Action(() => //{ 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); HasRecordFile = true; } //if (HasRecordFile == true) //{ // this.Dispatcher.BeginInvoke(new Action(() => // { // //btnRecord.Visibility = Visibility.Visible; // })); //} } catch (Exception ex) { // 這裡不要寫Log好了 //LogTool.Debug(ex); } //foreach (MeetingDataMeetingsFileFile item in meetingData.MeetingsFile.FileList) //{ // MeetingDataDownloadFileFile recordFile = new MeetingDataDownloadFileFile(); // recordFile.AgendaID = "record"; // recordFile.FileName = item.FileName; // recordFile.ID = item.ID; // recordFile.Url = item.Url; // recordFile.version = item.version; // FileList.Add(recordFile); //} FileList.AddRange(md.DownloadFile.DownloadFileList.ToList()); All_FileCount = FileList.Count; //Task.Factory.StartNew(() => //{ this.Dispatcher.BeginInvoke(new Action(() => { // (7)加入檔案 int i = 0; //foreach (MeetingDataDownloadFileFile item in meetingData.DownloadFile.DownloadFileList) foreach (MeetingDataDownloadFileFile item in FileList) { i++; File_DownloadItemViewModel fileItem = FileItemTool.Gen(item, UserID, MeetingID); PDFFactoryRowSP.Children.Add(new PDFFactoryRow(i, fileItem)); //bool IsLastRow = (i == FileList.Count); //int mutiThreadIndex = i; //if (item.AgendaID.Equals("") == true || item.AgendaID.Equals("c") == true || item.AgendaID.Equals("i") == true) //{ // HasSubjectFile = true; // imgSubject.Visibility = Visibility.Visible; //} //FileRowSP.Children.Add(new FileRow(UserID, UserName, UserPWD, meetingData.ID, UserEmail // , mutiThreadIndex, IsLastRow, item // , MeetingDataCT_RaiseAllDownload_Callback // , MeetingDataCT_HangTheDownloadEvent_Callback // , MeetingDataCT_IsAllFileRowFinished_AddInitUIFinished_Callback // , MeetingDataCT_GetBookVMs_ByMeetingFileCate_Callback // , MeetingDataCT_GetWatermark_Callback // , meetingRoomButtonType)); } })); //})); //}); } else { AutoClosingMessageBox.Show("無法取得資料,請稍後再試"); MouseTool.ShowArrow(); } }
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)); }