Пример #1
0
 public FileRow(string UserID, string UserName, string UserPWD, string MeetingID, string UserEmail
                , int index, bool IsLastRow, MeetingDataDownloadFileFile meetingDataDownloadFileFile
                , MeetingDataCT_RaiseAllDownload_Function callback1
                , MeetingDataCT_HangTheDownloadEvent_Function callback2
                , MeetingDataCT_IsAllFileRowFinished_AddInitUIFinished_Function callback3
                , MeetingDataCT_GetBookVMs_ByMeetingFileCate_Function callback4
                , MeetingDataCT_GetWatermark_Function callback5
                , MeetingRoomButtonType meetingRoomButtonType
                , MeetingDataCT_Counting_Finished_FileCount_Function callback6)
 {
     //MouseTool.ShowLoading();
     InitializeComponent();
     this.UserID    = UserID;
     this.UserName  = UserName;
     this.UserPWD   = UserPWD;
     this.MeetingID = MeetingID;
     this.UserEmail = UserEmail;
     this.index     = index;
     this.IsLastRow = IsLastRow;
     this.meetingDataDownloadFileFile              = meetingDataDownloadFileFile;
     this.MeetingDataCT_RaiseAllDownload_Event     = callback1;
     this.MeetingDataCT_HangTheDownloadEvent_Event = callback2;
     this.MeetingDataCT_IsAllFileRowFinished_AddInitUIFinished_Event = callback3;
     this.MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event           = callback4;
     this.MeetingDataCT_GetWatermark_Event = callback5;
     this.MeetingDataCT_Counting_Finished_FileCount_Event = callback6;
     this.meetingRoomButtonType = meetingRoomButtonType;
     this.fileItem  = null;
     this.Loaded   += FileRow_Loaded;
     this.Unloaded += FileRow_Unloaded;
     //MouseTool.ShowArrow();
 }
            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 InitSelectDB()
        {
            DataTable dataTable = MSCE.GetDataTable("select MeetingID,UserID from NowLogin");

            if (dataTable.Rows.Count > 0)
            {
                MeetingID = dataTable.Rows[0]["MeetingID"].ToString().Trim();
                UserID    = dataTable.Rows[0]["UserID"].ToString().Trim();
            }
            dataTable = MSCE.GetDataTable("select MeetingJson from MeetingData where MeetingID=@1 and UserID =@2", MeetingID, UserID);
            if (dataTable.Rows.Count > 0)
            {
                _003C_003Ec__DisplayClass3 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass3();
                _003C_003Ec__DisplayClass._003C_003E4__this = this;
                md = JsonConvert.DeserializeObject <MeetingData>(dataTable.Rows[0]["MeetingJson"].ToString());
                _003C_003Ec__DisplayClass.FileList = 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;
                        _003C_003Ec__DisplayClass.FileList.Add(meetingDataDownloadFileFile);
                        HasRecordFile = true;
                    }
                }
                catch (Exception)
                {
                }
                _003C_003Ec__DisplayClass.FileList.AddRange(Enumerable.ToList(md.DownloadFile.DownloadFileList));
                All_FileCount = _003C_003Ec__DisplayClass.FileList.Count;
                base.Dispatcher.BeginInvoke(new Action(_003C_003Ec__DisplayClass._003CInitSelectDB_003Eb__2));
            }
            else
            {
                AutoClosingMessageBox.Show("無法取得資料,請稍後再試");
                MouseTool.ShowArrow();
            }
        }
Пример #4
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();
            }
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
    public static File_DownloadItemViewModel Gen(MeetingDataDownloadFileFile meetingDataDownloadFileFile, string UserID, string MeetingID)
    {
        // 更新檔不支援續傳
        // 檢查是否再下載當中
        // 下面兩行在多執行緒環境可能換造成死結
        // 把把他們都丟到main thread去跑就可以解決死結了
        //FileDownloader fileDownloader = Singleton_FileDownloader.GetInstance(MeetingID);
        //File_DownloadItemViewModel fileItem = fileDownloader.GetInList(meetingDataDownloadFileFile.ID);
        //if (fileItem != null)
        //    return fileItem;

        File_DownloadItemViewModel fileItem = new File_DownloadItemViewModel();

        try
        {
            #region DB
            string db_FileRowID       = "";
            string db_Url             = "";
            string db_StorageFileName = "";
            long   db_DownloadBytes   = 0;
            long   db_TotalBytes      = 0;
            // FileVersion為現在目前檔案的版本
            int db_FileVersion = 1;
            // 有完成過的檔案版本
            int       db_FinishedFileVersion = 0;
            string    db_EncryptionKey       = "";
            string    SQL     = "";
            int       success = 0;
            DataTable dt      = MSCE.GetDataTable("SELECT ID,Url,StorageFileName,DownloadBytes,TotalBytes,FileVersion,FinishedFileVersion,EncryptionKey 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());
                db_FileVersion         = int.Parse(dt.Rows[0]["FileVersion"].ToString().Equals("") || dt.Rows[0]["FileVersion"].ToString().Equals("0") ? "1" : dt.Rows[0]["FileVersion"].ToString());
                db_FinishedFileVersion = int.Parse(dt.Rows[0]["FinishedFileVersion"].ToString().Equals("") ? "0" : dt.Rows[0]["FileVersion"].ToString());
                db_EncryptionKey       = dt.Rows[0]["EncryptionKey"].ToString();
            }
            else
            {
                SQL     = @"INSERT INTO FileRow(ID,DownloadBytes,TotalBytes,UserID,MeetingID,DisplayFileName,FileVersion,EncryptionKey) 
                                                    VALUES(@1,0,0,@2,@3,@4,@5,@6)";
                success = MSCE.ExecuteNonQuery(SQL
                                               , meetingDataDownloadFileFile.ID
                                               , UserID
                                               , MeetingID
                                               , meetingDataDownloadFileFile.FileName
                                               , meetingDataDownloadFileFile.version.Equals("") == true ? "1" : meetingDataDownloadFileFile.version
                                               , meetingDataDownloadFileFile.EncryptionKey == null ? "" : meetingDataDownloadFileFile.EncryptionKey);
                if (success < 1)
                {
                    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                }
            }
            #endregion

            //File_DownloadItemViewModel fileItem = new File_DownloadItemViewModel();
            fileItem.MeetingID     = MeetingID;
            fileItem.ID            = meetingDataDownloadFileFile.ID;
            fileItem.UserID        = UserID;
            fileItem.FileName      = meetingDataDownloadFileFile.FileName;
            fileItem.Url           = meetingDataDownloadFileFile.Url;
            fileItem.AgendaID      = meetingDataDownloadFileFile.AgendaID;
            fileItem.EncryptionKey = meetingDataDownloadFileFile.EncryptionKey == null ? "" : meetingDataDownloadFileFile.EncryptionKey;
            //string AppPath = System.AppDomain.CurrentDomain.BaseDirectory;
            //string File_StorageFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_StorageFileFolder;
            //fileItem.StorageFileFolder = System.IO.Path.Combine(ClickOnceTool.GetFilePath() , File_StorageFileFolder);
            fileItem.StorageFileFolder = Path.Combine(ClickOnceTool.GetFilePath(), PaperLess_Emeeting.Properties.Settings.Default.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 = Path.Combine(ClickOnceTool.GetFilePath(), PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder);
            LogTool.Debug(ClickOnceTool.GetFilePath());
            fileItem.DownloadBytes = db_DownloadBytes;
            fileItem.TotalBytes    = db_TotalBytes;
            int tempFileItemFileVersion = 0;
            int.TryParse(meetingDataDownloadFileFile.version, out tempFileItemFileVersion);
            if (tempFileItemFileVersion < 1)
            {
                tempFileItemFileVersion = 1;
            }
            fileItem.FileVersion = tempFileItemFileVersion;
            if (db_FinishedFileVersion > 0 && (fileItem.FileVersion > db_FinishedFileVersion))
            {
                //可更新
                fileItem.CanUpdate = true;
            }

            // 先檢查檔案存不存在
            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) //未下載完成的,有下載過的
                {
                    if (fileItem.CanUpdate == true)
                    {
                        // 未下載完成的,需要更新
                        // 可以更新,就算未下載完成
                        // DownloadBytes和 TotalBytes 也把他設定成0
                        fileItem.DownloadBytes = 0;
                        fileItem.TotalBytes    = 0;
                        fileItem.FileType      = MeetingFileType.已經下載過一次且可以更新版本的檔案_目前下載未完成;
                    }
                    else   // 未下載完成的,不用更新
                    {
                        // 下載到一半的
                        fileItem.DownloadBytes = db_DownloadBytes;
                        fileItem.TotalBytes    = db_TotalBytes;
                        fileItem.FileType      = MeetingFileType.已下載過但是未完成的檔案;
                    }
                }
                else
                {
                    // 已經下載完成的,需要更新
                    if (fileItem.CanUpdate == true)
                    {
                        fileItem.DownloadBytes = 0;
                        fileItem.TotalBytes    = 0;
                        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,FileVersion=@5 where ID=@6";
            success = MSCE.ExecuteNonQuery(SQL
                                           , fileItem.DownloadBytes.ToString()
                                           , fileItem.TotalBytes.ToString()
                                           , UserID
                                           , MeetingID
                                           , fileItem.FileVersion.ToString()
                                           , fileItem.ID);
            if (success < 1)
            {
                LogTool.Debug(new Exception(@"DB失敗: " + SQL));
            }
        }
        catch (Exception ex)
        {
            LogTool.Debug(ex);
        }
        return(fileItem);
    }
Пример #7
0
    public static File_DownloadItemViewModel Gen(MeetingDataDownloadFileFile meetingDataDownloadFileFile, string UserID, string MeetingID)
    {
        File_DownloadItemViewModel file_DownloadItemViewModel = new File_DownloadItemViewModel();

        try
        {
            long      num       = 0L;
            long      num2      = 0L;
            int       num3      = 0;
            string    text      = "";
            int       num4      = 0;
            DataTable dataTable = MSCE.GetDataTable("SELECT ID,Url,StorageFileName,DownloadBytes,TotalBytes,FileVersion,FinishedFileVersion,EncryptionKey FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3", meetingDataDownloadFileFile.ID, UserID, MeetingID);
            if (dataTable.Rows.Count > 0)
            {
                dataTable.Rows[0]["ID"].ToString();
                dataTable.Rows[0]["Url"].ToString();
                dataTable.Rows[0]["StorageFileName"].ToString();
                num  = long.Parse(dataTable.Rows[0]["DownloadBytes"].ToString().Equals("") ? "0" : dataTable.Rows[0]["DownloadBytes"].ToString());
                num2 = long.Parse(dataTable.Rows[0]["TotalBytes"].ToString().Equals("") ? "0" : dataTable.Rows[0]["TotalBytes"].ToString());
                int.Parse((dataTable.Rows[0]["FileVersion"].ToString().Equals("") || dataTable.Rows[0]["FileVersion"].ToString().Equals("0")) ? "1" : dataTable.Rows[0]["FileVersion"].ToString());
                num3 = int.Parse(dataTable.Rows[0]["FinishedFileVersion"].ToString().Equals("") ? "0" : dataTable.Rows[0]["FileVersion"].ToString());
                dataTable.Rows[0]["EncryptionKey"].ToString();
            }
            else
            {
                text = "INSERT INTO FileRow(ID,DownloadBytes,TotalBytes,UserID,MeetingID,DisplayFileName,FileVersion,EncryptionKey) \r\n                                                    VALUES(@1,0,0,@2,@3,@4,@5,@6)";
                num4 = MSCE.ExecuteNonQuery(text, meetingDataDownloadFileFile.ID, UserID, MeetingID, meetingDataDownloadFileFile.FileName, meetingDataDownloadFileFile.version.Equals("") ? "1" : meetingDataDownloadFileFile.version, (meetingDataDownloadFileFile.EncryptionKey == null) ? "" : meetingDataDownloadFileFile.EncryptionKey);
                if (num4 < 1)
                {
                    LogTool.Debug(new Exception("DB失敗: " + text));
                }
            }
            file_DownloadItemViewModel.MeetingID         = MeetingID;
            file_DownloadItemViewModel.ID                = meetingDataDownloadFileFile.ID;
            file_DownloadItemViewModel.UserID            = UserID;
            file_DownloadItemViewModel.FileName          = meetingDataDownloadFileFile.FileName;
            file_DownloadItemViewModel.Url               = meetingDataDownloadFileFile.Url;
            file_DownloadItemViewModel.AgendaID          = meetingDataDownloadFileFile.AgendaID;
            file_DownloadItemViewModel.EncryptionKey     = ((meetingDataDownloadFileFile.EncryptionKey == null) ? "" : meetingDataDownloadFileFile.EncryptionKey);
            file_DownloadItemViewModel.StorageFileFolder = Path.Combine(ClickOnceTool.GetFilePath(), Settings.Default.File_StorageFileFolder);
            string text2 = DateTime.Now.ToFileTime().ToString();
            try
            {
                Uri    uri      = new Uri(file_DownloadItemViewModel.Url);
                string fileName = Path.GetFileName(uri.LocalPath);
                if (!fileName.Equals("/"))
                {
                    text2 = fileName;
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            file_DownloadItemViewModel.StorageFileName = string.Format("{0}_{1}_{2}_{3}", UserID, MeetingID, meetingDataDownloadFileFile.ID, text2);
            file_DownloadItemViewModel.UnZipFileFolder = Path.Combine(ClickOnceTool.GetFilePath(), Settings.Default.File_UnZipFileFolder);
            LogTool.Debug(ClickOnceTool.GetFilePath());
            file_DownloadItemViewModel.DownloadBytes = num;
            file_DownloadItemViewModel.TotalBytes    = num2;
            int result = 0;
            int.TryParse(meetingDataDownloadFileFile.version, out result);
            if (result < 1)
            {
                result = 1;
            }
            file_DownloadItemViewModel.FileVersion = result;
            if (num3 > 0 && file_DownloadItemViewModel.FileVersion > num3)
            {
                file_DownloadItemViewModel.CanUpdate = true;
            }
            if (File.Exists(file_DownloadItemViewModel.StorageFilePath))
            {
                if (num == 0)
                {
                    if (File.Exists(file_DownloadItemViewModel.StorageFilePath))
                    {
                        File.Delete(file_DownloadItemViewModel.StorageFilePath);
                    }
                    file_DownloadItemViewModel.DownloadBytes = 0L;
                    file_DownloadItemViewModel.TotalBytes    = 0L;
                    file_DownloadItemViewModel.FileType      = MeetingFileType.從未下載;
                }
                else if (num < num2)
                {
                    if (file_DownloadItemViewModel.CanUpdate)
                    {
                        file_DownloadItemViewModel.DownloadBytes = 0L;
                        file_DownloadItemViewModel.TotalBytes    = 0L;
                        file_DownloadItemViewModel.FileType      = MeetingFileType.已經下載過一次且可以更新版本的檔案_目前下載未完成;
                    }
                    else
                    {
                        file_DownloadItemViewModel.DownloadBytes = num;
                        file_DownloadItemViewModel.TotalBytes    = num2;
                        file_DownloadItemViewModel.FileType      = MeetingFileType.已下載過但是未完成的檔案;
                    }
                }
                else if (file_DownloadItemViewModel.CanUpdate)
                {
                    file_DownloadItemViewModel.DownloadBytes = 0L;
                    file_DownloadItemViewModel.TotalBytes    = 0L;
                    file_DownloadItemViewModel.FileType      = MeetingFileType.已經下載過一次且可以更新版本的檔案_目前下載已完成;
                }
                else
                {
                    file_DownloadItemViewModel.FileType = MeetingFileType.已下載完成;
                }
            }
            else
            {
                file_DownloadItemViewModel.DownloadBytes = 0L;
                file_DownloadItemViewModel.TotalBytes    = 0L;
                file_DownloadItemViewModel.FileType      = MeetingFileType.從未下載;
            }
            text = "update FileRow set DownloadBytes=@1,TotalBytes=@2,UserID=@3,MeetingID=@4,FileVersion=@5 where ID=@6";
            num4 = MSCE.ExecuteNonQuery(text, file_DownloadItemViewModel.DownloadBytes.ToString(), file_DownloadItemViewModel.TotalBytes.ToString(), UserID, MeetingID, file_DownloadItemViewModel.FileVersion.ToString(), file_DownloadItemViewModel.ID);
            if (num4 >= 1)
            {
                return(file_DownloadItemViewModel);
            }
            LogTool.Debug(new Exception("DB失敗: " + text));
            return(file_DownloadItemViewModel);
        }
        catch (Exception ex2)
        {
            LogTool.Debug(ex2);
            return(file_DownloadItemViewModel);
        }
    }