Example #1
0
 private void btnOpen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     MouseTool.ShowLoading();
     try
     {
         _003C_003Ec__DisplayClass14 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass14();
         _003C_003Ec__DisplayClass._003C_003E4__this = this;
         ClickOnceTool.GetFilePath();
         _003C_003Ec__DisplayClass._bookPath      = lawItem.UnZipFilePath;
         _003C_003Ec__DisplayClass._bookId        = "";
         _003C_003Ec__DisplayClass._account       = "";
         _003C_003Ec__DisplayClass._userName      = "";
         _003C_003Ec__DisplayClass._email         = "";
         _003C_003Ec__DisplayClass._meetingId     = "";
         _003C_003Ec__DisplayClass._watermark     = "";
         _003C_003Ec__DisplayClass._dbPath        = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.bookInfo_Path);
         _003C_003Ec__DisplayClass._isSync        = false;
         _003C_003Ec__DisplayClass._isSyncOwner   = false;
         _003C_003Ec__DisplayClass._webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
         _003C_003Ec__DisplayClass._socketMessage = "";
         _003C_003Ec__DisplayClass.cbBooksData    = null;
         _003C_003Ec__DisplayClass.Home_Window    = Enumerable.FirstOrDefault(Enumerable.OfType <Home>(Application.Current.Windows));
         _003C_003Ec__DisplayClass.Home_Window.CloseAllWindow("", true);
         Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass._003CbtnOpen_MouseLeftButtonDown_003Eb__12));
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
     MouseTool.ShowArrow();
 }
Example #2
0
        private void btnOpen_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MouseTool.ShowLoading();

            try
            {
                //string AppPath = AppDomain.CurrentDomain.BaseDirectory;
                string filePath = ClickOnceTool.GetFilePath();

                //string _bookPath = System.IO.Path.Combine(AppPath, lawItem.UnZipFilePath);
                string _bookPath      = lawItem.UnZipFilePath;
                string _bookId        = "";
                string _account       = "";
                string _userName      = "";
                string _email         = "";
                string _meetingId     = "";
                string _watermark     = "";
                string _dbPath        = System.IO.Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.bookInfo_Path);
                bool   _isSync        = false;
                bool   _isSyncOwner   = false;
                string _webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                string _socketMessage = "";


                // 呼叫一個事件取得 BookVMs
                //Dictionary<string, BookVM> cbBooksData = new Dictionary<string, BookVM>();
                //if (LawListCT_GetBookVMs_ByMeetingFileCate_Event != null)
                //    cbBooksData = LawListCT_GetBookVMs_ByMeetingFileCate_Event(lawItem);

                Dictionary <string, BookVM> cbBooksData = null;
                Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault();

                Home_Window.CloseAllWindow("", true);
                Task.Factory.StartNew(() =>
                {
                    this.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                       , _userName, _email, _meetingId
                                                       , _watermark, _dbPath, _isSync
                                                       , _isSyncOwner, _webServiceUrl, _socketMessage, null);
                        rw.HideCollectFile = true;
                        rw.WindowStyle = WindowStyle.None;
                        rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        rw.WindowState = WindowState.Maximized;
                        if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                        {
                            //rw.WindowStyle = WindowStyle.SingleBorderWindow;
                        }
                        rw.Show();
                    }));
                });
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }

            MouseTool.ShowArrow();
        }
Example #3
0
 private void AccessTableAction(string sql)
 {
     try
     {
         BookManager bookManager = new BookManager(Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.bookInfo_Path));
         bookManager.sqlCommandNonQuery(sql);
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
 }
Example #4
0
        private void btnYes_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (StackLines.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            {
                if (!PicUrl.Equals(""))
                {
                    MessageBox.Show("已簽名,欲重新簽名請先按x清除");
                }
                else
                {
                    MessageBox.Show("請簽名後上傳");
                }
                return;
            }
            string    text      = "";
            DataTable dataTable = MSCE.GetDataTable("select AllowIpRange from NowLogin");

            if (dataTable.Rows.Count > 0)
            {
                text = dataTable.Rows[0]["AllowIpRange"].ToString();
            }
            if (!text.Equals("") && !IpTool.CheckInNowWifi(text))
            {
                string courseOrMeeting_String = Settings.Default.CourseOrMeeting_String;
                AutoClosingMessageBox.Show(string.Format("您不在{0}室範圍內,無法使用此功能", courseOrMeeting_String.Equals("課程") ? "教" : courseOrMeeting_String));
                return;
            }
            string path = System.IO.Path.Combine(ClickOnceTool.GetFilePath(), Settings.Default.SignInFolder);

            path = System.IO.Path.Combine(path, MeetingID, UserID);
            Directory.CreateDirectory(path);
            string      str     = Guid.NewGuid().ToString();
            string      path2   = str + ".png";
            string      text2   = System.IO.Path.Combine(path, path2);
            Application current = Application.Current;

            CanvasTool.SaveCanvas(current.Windows[0], SignPad, 96, text2);
            MouseTool.ShowLoading();
            if (UserID.Equals("guest"))
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            else if (UserID.Equals("dept"))
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            GetSigninDataUpload.AsyncPOST(MeetingID, UserID, DeptID, text2, new Action <SigninDataUpload>(_003CbtnYes_MouseDown_003Eb__1f));
        }
Example #5
0
        private void CheckDBVersion()
        {
            try
            {
                // DB最小版本為0;
                int    InitDBVersion      = 0;
                int    LocalDBVersion     = 0;
                int    ToDBVersion        = PaperLess_Emeeting.Properties.Settings.Default.NowDBVersion;
                string DB_FilePath        = Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.PaperLessDB_Path);
                string ConfigIni_FilePath = Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.ConfigIni_Path);

                if (File.Exists(ConfigIni_FilePath) == true)
                {
                    IniFileTool ini = new IniFileTool(ConfigIni_FilePath);
                    try
                    {
                        int.TryParse(ini.IniReadValue("DB", "Version"), out LocalDBVersion);
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                    bool Success = UpdateDBVersion(LocalDBVersion);
                    if (Success == true)
                    {
                        ini.IniWriteValue("DB", "Version", ToDBVersion.ToString());
                    }
                    else
                    {
                        throw new Exception("DB更新失敗!");
                    }
                }
                else
                {
                    //在嘗試更新一次,避免DB沒有更新到
                    UpdateDBVersion(LocalDBVersion);

                    using (var writer = new FileStream(ConfigIni_FilePath, FileMode.OpenOrCreate))
                    {
                    }
                    IniFileTool ini = new IniFileTool(ConfigIni_FilePath);
                    ini.IniWriteValue("DB", "Version", ToDBVersion.ToString());
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
        }
Example #6
0
 private static void _003CCopyLog_003Eb__0()
 {
     try
     {
         string   baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
         string[] directories   = Directory.GetDirectories(Path.Combine(baseDirectory, "Logs"));
         if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate3 == null)
         {
             CS_0024_003C_003E9__CachedAnonymousMethodDelegate3 = new Func <string, string>(_003CCopyLog_003Eb__1);
         }
         string sourcePath = Enumerable.First(Enumerable.OrderByDescending(directories, CS_0024_003C_003E9__CachedAnonymousMethodDelegate3));
         DirectoryTool.FullCopyDirectories(sourcePath, ClickOnceTool.GetFilePath());
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
 }
Example #7
0
 private void CopyLog()
 {
     if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
     {
         Task.Factory.StartNew(() =>
         {
             try
             {
                 string AppDir = AppDomain.CurrentDomain.BaseDirectory;
                 string dir    = Directory.GetDirectories(System.IO.Path.Combine(AppDir, "Logs")).OrderByDescending(f => f).First();
                 DirectoryTool.FullCopyDirectories(dir, ClickOnceTool.GetFilePath());
             }
             catch (Exception ex)
             {
                 LogTool.Debug(ex);
             }
         });
     }
 }
Example #8
0
        private Dictionary <string, App_Code.ViewModel.BookVM> LawListCT_GetBookVMs_ByMeetingFileCate_Callback(Law_DownloadItemViewModel lawItem)
        {
            Dictionary <string, BookVM> BookVMs = new Dictionary <string, BookVM>();

            IEnumerable <LawRow> LawRowS = LawRowSP.Children.OfType <LawRow>().Where(x => x.lawItem.FileCate == lawItem.FileCate && x.lawItem.DownloadBytes != 0 && x.lawItem.DownloadBytes >= x.lawItem.TotalBytes);
            string filePath        = ClickOnceTool.GetFilePath();
            string UnZipFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
            string baseBookPath    = filePath + "\\" + UnZipFileFolder + "\\" + UserID;

            if (LawRowS != null)
            {
                foreach (LawRow item in LawRowS)
                {
                    BookVMs[item.lawItem.Name] = new BookVM(item.lawItem.ID, baseBookPath + "\\" + item.lawItem.ID, lawItem.FileCate);
                }
            }

            return(BookVMs);
        }
Example #9
0
        private Dictionary <string, BookVM> LawListCT_GetBookVMs_ByMeetingFileCate_Callback(Law_DownloadItemViewModel lawItem)
        {
            _003C_003Ec__DisplayClass19 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass19();

            _003C_003Ec__DisplayClass.lawItem = lawItem;
            Dictionary <string, BookVM> dictionary = new Dictionary <string, BookVM>();
            IEnumerable <LawRow>        enumerable = Enumerable.Where(Enumerable.OfType <LawRow>(LawRowSP.Children), new Func <LawRow, bool>(_003C_003Ec__DisplayClass._003CLawListCT_GetBookVMs_ByMeetingFileCate_Callback_003Eb__18));
            string filePath             = ClickOnceTool.GetFilePath();
            string file_UnZipFileFolder = Settings.Default.File_UnZipFileFolder;
            string str = filePath + "\\" + file_UnZipFileFolder + "\\" + UserID;

            if (enumerable != null)
            {
                foreach (LawRow item in enumerable)
                {
                    dictionary[item.lawItem.Name] = new BookVM(item.lawItem.ID, str + "\\" + item.lawItem.ID, _003C_003Ec__DisplayClass.lawItem.FileCate);
                }
                return(dictionary);
            }
            return(dictionary);
        }
Example #10
0
 private void CheckDBVersion()
 {
     try
     {
         int result       = 0;
         int nowDBVersion = Settings.Default.NowDBVersion;
         Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.PaperLessDB_Path);
         string text = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.ConfigIni_Path);
         if (File.Exists(text))
         {
             IniFileTool iniFileTool = new IniFileTool(text);
             try
             {
                 int.TryParse(iniFileTool.IniReadValue("DB", "Version"), out result);
             }
             catch (Exception ex)
             {
                 LogTool.Debug(ex);
             }
             if (!UpdateDBVersion(result))
             {
                 throw new Exception("DB更新失敗!");
             }
             iniFileTool.IniWriteValue("DB", "Version", nowDBVersion.ToString());
         }
         else
         {
             UpdateDBVersion(result);
             using (new FileStream(text, FileMode.OpenOrCreate))
             {
             }
             IniFileTool iniFileTool2 = new IniFileTool(text);
             iniFileTool2.IniWriteValue("DB", "Version", nowDBVersion.ToString());
         }
     }
     catch (Exception ex2)
     {
         LogTool.Debug(ex2);
     }
 }
Example #11
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);
    }
        private void btnDelete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            string messageBoxText = "您確定要刪除檔案?";

            switch (meetingRoomButtonType)
            {
            case MeetingRoomButtonType.OY:
                messageBoxText = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", Settings.Default.CourseOrMeeting_String);
                break;

            case MeetingRoomButtonType.YO:
                messageBoxText = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", Settings.Default.CourseOrMeeting_String);
                break;
            }
            MessageBoxResult messageBoxResult = MessageBox.Show(messageBoxText, "系統訊息", MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                MouseTool.ShowLoading();
                bool flag = false;
                try
                {
                    DataTable dataTable = MSCE.GetDataTable("select ID,StorageFileName from FileRow where UserID =@1 and MeetingID=@2 and DownloadBytes!=0 and DownloadBytes >= TotalBytes;", UserID, userMeeting.ID);
                    foreach (DataRow row in dataTable.Rows)
                    {
                        string filePath = ClickOnceTool.GetFilePath();
                        string file_StorageFileFolder = Settings.Default.File_StorageFileFolder;
                        string file_UnZipFileFolder   = Settings.Default.File_UnZipFileFolder;
                        string path    = filePath + "\\" + file_StorageFileFolder + "\\" + row["StorageFileName"].ToString();
                        string dirPath = filePath + "\\" + file_UnZipFileFolder + "\\" + UserID + "\\" + userMeeting.ID + "\\" + row["ID"].ToString();
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        DirectoryTool.FullDeleteDirectories(dirPath);
                    }
                    string text = "update FileRow set DownloadBytes=0,TotalBytes=0,FinishedFileVersion=0 where UserID =@1 and MeetingID=@2 ";
                    int    num  = MSCE.ExecuteNonQuery(text, UserID, userMeeting.ID);
                    if (num < 1)
                    {
                        LogTool.Debug(new Exception("DB失敗: " + text));
                    }
                    else
                    {
                        flag = true;
                    }
                }
                catch (Exception ex)
                {
                    LogTool.Debug(ex);
                }
                MouseTool.ShowArrow();
                if (!flag)
                {
                    AutoClosingMessageBox.Show("刪除失敗");
                    return;
                }
                btnDelete.Visibility  = Visibility.Collapsed;
                btnRefresh.Visibility = Visibility.Visible;
                pb.Value        = pb.Minimum;
                txtPercent.Text = "0 %";
            }
        }
Example #13
0
        private void InitSelectDB()
        {
            DataTable dt = new DataTable();

            // 初始化User
            // 效能要好請改用從LawListCT傳入建構子
            //dt = MSCE.GetDataTable("select UserID,UserName,UserPWD from NowLogin");
            //if (dt.Rows.Count > 0)
            //{
            //    UserID = dt.Rows[0]["UserID"].ToString();
            //    UserName = dt.Rows[0]["UserName"].ToString();
            //    UserPWD = dt.Rows[0]["UserPWD"].ToString();
            //}

            //更新檔不支援續傳
            //檢查是否再下載當中
            LawDownloader lawDownloader = Singleton_LawDownloader.GetInstance();

            lawItem = lawDownloader.GetInList(lawDataLaw.ID);
            if (lawItem != null)
            {
                return;
            }

            #region DB
            string   db_LawRowID = "";
            DateTime db_AtDownloadFinished_XmlUpDate = DateTime.Parse("2010/01/01");
            string   db_Link            = "";
            string   db_StorageFileName = "";
            long     db_DownloadBytes   = 0;
            long     db_TotalBytes      = 0;

            dt = MSCE.GetDataTable("SELECT ID,AtDownloadFinished_XmlUpDate,Link,StorageFileName,DownloadBytes,TotalBytes FROM LawRow where ID=@1 and UserID=@2"
                                   , lawDataLaw.ID
                                   , UserID);
            if (dt.Rows.Count > 0)
            {
                db_LawRowID = dt.Rows[0]["ID"].ToString();
                db_AtDownloadFinished_XmlUpDate = (DateTime)dt.Rows[0]["AtDownloadFinished_XmlUpDate"];
                db_Link            = dt.Rows[0]["Link"].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
            {
                string SQL     = @"INSERT INTO LawRow(ID,AtDownloadFinished_XmlUpDate,DownloadBytes,TotalBytes,UserID) 
                                                    VALUES(@1,'2010/01/01',0,0,@2)";
                int    success = MSCE.ExecuteNonQuery(SQL
                                                      , lawDataLaw.ID
                                                      , UserID);
                if (success < 1)
                {
                    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                }
            }
            #endregion

            lawItem        = new Law_DownloadItemViewModel();
            lawItem.ID     = lawDataLaw.ID;
            lawItem.UserID = UserID;
            DateTime lawDataLaw_UpDate;
            DateTime.TryParse(lawDataLaw.UpDate, out lawDataLaw_UpDate);
            lawItem.UpDate = lawDataLaw_UpDate;
            lawItem.Name   = lawDataLaw.Name;
            lawItem.Link   = lawDataLaw.Link;
            lawItem.Status = (LawDataStatus)Enum.Parse(typeof(LawDataStatus), lawDataLaw.Status);

            string AppPath = System.AppDomain.CurrentDomain.BaseDirectory;
            string Law_StorageFileFolder = PaperLess_Emeeting.Properties.Settings.Default.Law_StorageFileFolder2;
            lawItem.StorageFileFolder = System.IO.Path.Combine(AppPath, Law_StorageFileFolder);

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

            lawItem.StorageFileName = string.Format("{0}_{1}_{2}", UserID, lawDataLaw.ID, fileName);
            lawItem.UnZipFileFolder = System.IO.Path.Combine(ClickOnceTool.GetFilePath(), PaperLess_Emeeting.Properties.Settings.Default.Law_UnZipFileFolder);

            // 續傳才要用到
            //lawItem.DownloadBytes = db_DownloadBytes;
            //lawItem.TotalBytes = db_DownloadBytes;

            //bool Law_ResumeDownload = false;
            ////不續傳
            //if (Law_ResumeDownload == false)
            //{
            //未下載完成的
            if (db_DownloadBytes == 0 || db_DownloadBytes < db_TotalBytes)
            {
                //刪除未下載完成的
                if (File.Exists(lawItem.StorageFilePath) == true)
                {
                    File.Delete(lawItem.StorageFilePath);
                }

                lawItem.DownloadBytes = 0;
                lawItem.TotalBytes    = 0;
                lawItem.FileType      = LawFileType.從未下載;
            }
            else     //有下載完成的
            {
                //先判斷是否有更新檔
                //需要更新檔案,UpdDate 日期比較新
                if (TimeSpan.Compare(new TimeSpan(lawDataLaw_UpDate.Ticks), new TimeSpan(db_AtDownloadFinished_XmlUpDate.Ticks)) > 0)
                {
                    lawItem.StorageFileName = lawItem.StorageFileName + ".update";
                    lawItem.DownloadBytes   = 0;
                    lawItem.TotalBytes      = 0;
                    lawItem.FileType        = LawFileType.更新檔未下載;
                }
                else     //不需更新檔案
                {
                    lawItem.FileType = LawFileType.已下載完成;
                    //結束;
                }
            }

            //}
            //else //續傳
            //{
            //    //目前不支援
            //}
        }
        private void CallOpenBook(bool HasOpenFinishedFileVersion = false)
        {
            MouseTool.ShowLoading();
            try
            {
                Action action  = null;
                Action action2 = null;
                Action action3 = null;
                _003C_003Ec__DisplayClass2a _003C_003Ec__DisplayClass2a = new _003C_003Ec__DisplayClass2a();
                _003C_003Ec__DisplayClass2a._003C_003E4__this = this;
                _003C_003Ec__DisplayClass2a.Home_Window       = Enumerable.FirstOrDefault(Enumerable.OfType <Home>(Application.Current.Windows));
                if (_003C_003Ec__DisplayClass2a.Home_Window.IsInSync && !_003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner)
                {
                    AutoClosingMessageBox.Show("同步中需由主控人員進行操作");
                    return;
                }
                string filePath             = ClickOnceTool.GetFilePath();
                string file_UnZipFileFolder = Settings.Default.File_UnZipFileFolder;
                _003C_003Ec__DisplayClass2a._bookPath = fileItem.UnZipFilePath;
                if (HasOpenFinishedFileVersion)
                {
                    DataTable dataTable = MSCE.GetDataTable("SELECT FinishedFileVersion FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3", meetingDataDownloadFileFile.ID, UserID, MeetingID);
                    if (dataTable.Rows.Count > 0)
                    {
                        _003C_003Ec__DisplayClass2a._bookPath = filePath + "\\" + file_UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + fileItem.ID + "\\" + dataTable.Rows[0]["FinishedFileVersion"].ToString();
                    }
                }
                _003C_003Ec__DisplayClass2a._bookId    = fileItem.ID;
                _003C_003Ec__DisplayClass2a._account   = UserID;
                _003C_003Ec__DisplayClass2a._userName  = UserName;
                _003C_003Ec__DisplayClass2a._email     = UserEmail;
                _003C_003Ec__DisplayClass2a._meetingId = MeetingID;
                _003C_003Ec__DisplayClass2a._watermark = "";
                if (MeetingDataCT_GetWatermark_Event != null)
                {
                    _003C_003Ec__DisplayClass2a._watermark = MeetingDataCT_GetWatermark_Event();
                }
                _003C_003Ec__DisplayClass2a._dbPath        = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.bookInfo_Path);
                _003C_003Ec__DisplayClass2a._isSync        = _003C_003Ec__DisplayClass2a.Home_Window.IsInSync;
                _003C_003Ec__DisplayClass2a._isSyncOwner   = _003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner;
                _003C_003Ec__DisplayClass2a._webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                _003C_003Ec__DisplayClass2a._socketMessage = "";
                _003C_003Ec__DisplayClass2a._socket        = null;
                SocketClient instance = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, _003C_003Ec__DisplayClass2a.Home_Window.IsInSync);
                if (instance != null && instance.GetIsConnected())
                {
                    _003C_003Ec__DisplayClass2a._socket = instance;
                }
                _003C_003Ec__DisplayClass2a.cbBooksData = new Dictionary <string, BookVM>();
                if (MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event != null)
                {
                    _003C_003Ec__DisplayClass2a.cbBooksData = MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event(fileItem);
                }
                _003C_003Ec__DisplayClass2a.Home_Window.CloseAllWindow("", true);
                switch (fileItem.FileCate)
                {
                case MeetingFileCate.電子書:
                {
                    InitSyncCenter(_003C_003Ec__DisplayClass2a._dbPath, _003C_003Ec__DisplayClass2a._bookId, _003C_003Ec__DisplayClass2a._account, _003C_003Ec__DisplayClass2a._meetingId);
                    TaskFactory factory2 = Task.Factory;
                    if (action == null)
                    {
                        action = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__20);
                    }
                    factory2.StartNew(action);
                    break;
                }

                case MeetingFileCate.Html5投影片:
                {
                    _003C_003Ec__DisplayClass2a._bookPath = _003C_003Ec__DisplayClass2a._bookPath + "\\" + new FileInfo(Directory.GetFiles(_003C_003Ec__DisplayClass2a._bookPath)[0]).Name;
                    InitSyncCenter(_003C_003Ec__DisplayClass2a._dbPath, _003C_003Ec__DisplayClass2a._bookId, _003C_003Ec__DisplayClass2a._account, _003C_003Ec__DisplayClass2a._meetingId);
                    TaskFactory factory3 = Task.Factory;
                    if (action2 == null)
                    {
                        action2 = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__22);
                    }
                    factory3.StartNew(action2);
                    break;
                }

                case MeetingFileCate.影片檔:
                {
                    _003C_003Ec__DisplayClass2a._bookPath = _003C_003Ec__DisplayClass2a._bookPath + "\\" + new FileInfo(Directory.GetFiles(_003C_003Ec__DisplayClass2a._bookPath)[0]).Name;
                    TaskFactory factory = Task.Factory;
                    if (action3 == null)
                    {
                        action3 = new Action(_003C_003Ec__DisplayClass2a._003CCallOpenBook_003Eb__24);
                    }
                    factory.StartNew(action3);
                    break;
                }
                }
                if (_003C_003Ec__DisplayClass2a.Home_Window.IsInSync && _003C_003Ec__DisplayClass2a.Home_Window.IsSyncOwner)
                {
                    _003C_003Ec__DisplayClass2c _003C_003Ec__DisplayClass2c = new _003C_003Ec__DisplayClass2c();
                    _003C_003Ec__DisplayClass2c.CS_0024_003C_003E8__locals2b = _003C_003Ec__DisplayClass2a;
                    _003C_003Ec__DisplayClass2c.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, _003C_003Ec__DisplayClass2a.Home_Window.IsInSync);
                    Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass2c._003CCallOpenBook_003Eb__26));
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            MouseTool.ShowArrow();
        }
Example #15
0
        private void btnYes_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //if (StackLines.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            if (SignPad.Strokes.Count < 1 || txtPLS.Visibility == Visibility.Visible)
            {
                if (PicUrl.Equals("") == false)
                {
                    MessageBox.Show("已簽名,欲重新簽名請先按x清除");
                    return;
                }
                else
                {
                    MessageBox.Show("請簽名後上傳");
                    return;
                }
            }


            string    AllowIpRange = "";
            DataTable dt           = MSCE.GetDataTable("select AllowIpRange from NowLogin");

            if (dt.Rows.Count > 0)
            {
                AllowIpRange = dt.Rows[0]["AllowIpRange"].ToString();
            }
            if (PaperLess_Emeeting.Properties.Settings.Default.HasIpRangeMode == true && AllowIpRange.Equals("") == false && IpTool.CheckInNowWifi(AllowIpRange) == false)
            {
                string CourseOrMeeting_String = PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String;
                AutoClosingMessageBox.Show(string.Format("您不在{0}室範圍內,無法使用此功能", CourseOrMeeting_String.Equals("課程") ? "教" : CourseOrMeeting_String));
                return;
            }

            // 系統暫存資料夾
            //string tempPath = System.IO.Path.GetTempPath(); //Environment.GetEnvironmentVariable("TEMP");
            string SignInFolder = System.IO.Path.Combine(ClickOnceTool.GetFilePath(), PaperLess_Emeeting.Properties.Settings.Default.SignInFolder);

            SignInFolder = System.IO.Path.Combine(SignInFolder, MeetingID, UserID);
            Directory.CreateDirectory(SignInFolder);
            string      GUID         = Guid.NewGuid().ToString();
            string      tempFileName = GUID + ".png";
            string      filePath     = System.IO.Path.Combine(SignInFolder, tempFileName);
            Application app          = Application.Current;

            //(1) Canvas
            CanvasTool.SaveCanvas(app.Windows[0], this.SignPad, 96, filePath);

            //(2) InkCanvas
            //double width = SignPad.ActualWidth;
            //double height = SignPad.ActualHeight;
            //RenderTargetBitmap bmpCopied = new RenderTargetBitmap((int)Math.Round(width), (int)Math.Round(height), 96, 96, PixelFormats.Default);
            //DrawingVisual dv = new DrawingVisual();
            //using (DrawingContext dc = dv.RenderOpen())
            //{
            //    VisualBrush vb = new VisualBrush(SignPad);
            //    dc.DrawRectangle(vb, null, new Rect(new System.Windows.Point(), new System.Windows.Size(width, height)));
            //}
            //bmpCopied.Render(dv);
            //System.Drawing.Bitmap bitmap;
            //using (MemoryStream outStream = new MemoryStream())
            //{
            //    // from System.Media.BitmapImage to System.Drawing.Bitmap
            //    BitmapEncoder enc = new BmpBitmapEncoder();
            //    enc.Frames.Add(BitmapFrame.Create(bmpCopied));
            //    enc.Save(outStream);
            //    bitmap = new System.Drawing.Bitmap(outStream);
            //}

            //EncoderParameter qualityParam =new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 85L);

            //// Jpeg image codec
            //ImageCodecInfo jpegCodec = getEncoderInfo("image/jpeg");

            //if (jpegCodec == null)
            //    return;

            //EncoderParameters encoderParams = new EncoderParameters(1);
            //encoderParams.Param[0] = qualityParam;
            //Bitmap btm = new Bitmap(bitmap);
            //bitmap.Dispose();
            //btm.Save(filePath, jpegCodec, encoderParams);
            //btm.Dispose();

            //SigninDataUpload sdu = GetSigninDataUpload.POST(MeetingID, "UserID", filePath);
            MouseTool.ShowLoading();

            if (UserID.Equals("guest") == true)
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            else if (UserID.Equals("dept") == true)
            {
                UserID_Origin = UserID;
                UserID        = "";
            }
            GetSigninDataUpload.AsyncPOST(MeetingID, UserID, DeptID, filePath, (sdu) => { GetSigninDataUpload_DoAction(sdu); });
        }
Example #16
0
        private void InitSelectDB()
        {
            DataTable     dataTable = new DataTable();
            LawDownloader instance  = Singleton_LawDownloader.GetInstance();

            lawItem = instance.GetInList(lawDataLaw.ID);
            if (lawItem != null)
            {
                return;
            }
            DateTime dateTime = DateTime.Parse("2010/01/01");
            long     num      = 0L;
            long     num2     = 0L;

            dataTable = MSCE.GetDataTable("SELECT ID,AtDownloadFinished_XmlUpDate,Link,StorageFileName,DownloadBytes,TotalBytes FROM LawRow where ID=@1 and UserID=@2", lawDataLaw.ID, UserID);
            if (dataTable.Rows.Count > 0)
            {
                dataTable.Rows[0]["ID"].ToString();
                dateTime = (DateTime)dataTable.Rows[0]["AtDownloadFinished_XmlUpDate"];
                dataTable.Rows[0]["Link"].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());
            }
            else
            {
                string text = "INSERT INTO LawRow(ID,AtDownloadFinished_XmlUpDate,DownloadBytes,TotalBytes,UserID) \r\n                                                    VALUES(@1,'2010/01/01',0,0,@2)";
                int    num3 = MSCE.ExecuteNonQuery(text, lawDataLaw.ID, UserID);
                if (num3 < 1)
                {
                    LogTool.Debug(new Exception("DB失敗: " + text));
                }
            }
            lawItem        = new Law_DownloadItemViewModel();
            lawItem.ID     = lawDataLaw.ID;
            lawItem.UserID = UserID;
            DateTime result;

            DateTime.TryParse(lawDataLaw.UpDate, out result);
            lawItem.UpDate = result;
            lawItem.Name   = lawDataLaw.Name;
            lawItem.Link   = lawDataLaw.Link;
            lawItem.Status = (LawDataStatus)Enum.Parse(typeof(LawDataStatus), lawDataLaw.Status);
            string baseDirectory         = AppDomain.CurrentDomain.BaseDirectory;
            string law_StorageFileFolder = Settings.Default.Law_StorageFileFolder2;

            lawItem.StorageFileFolder = Path.Combine(baseDirectory, law_StorageFileFolder);
            string arg = DateTime.Now.ToFileTime().ToString();

            try
            {
                Uri    uri      = new Uri(lawItem.Link);
                string fileName = Path.GetFileName(uri.LocalPath);
                if (!fileName.Equals("/"))
                {
                    arg = fileName;
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            lawItem.StorageFileName = string.Format("{0}_{1}_{2}", UserID, lawDataLaw.ID, arg);
            lawItem.UnZipFileFolder = Path.Combine(ClickOnceTool.GetFilePath(), Settings.Default.Law_UnZipFileFolder);
            if (num == 0 || num < num2)
            {
                if (File.Exists(lawItem.StorageFilePath))
                {
                    File.Delete(lawItem.StorageFilePath);
                }
                lawItem.DownloadBytes = 0L;
                lawItem.TotalBytes    = 0L;
                lawItem.FileType      = LawFileType.從未下載;
            }
            else if (TimeSpan.Compare(new TimeSpan(result.Ticks), new TimeSpan(dateTime.Ticks)) > 0)
            {
                lawItem.StorageFileName += ".update";
                lawItem.DownloadBytes    = 0L;
                lawItem.TotalBytes       = 0L;
                lawItem.FileType         = LawFileType.更新檔未下載;
            }
            else
            {
                lawItem.FileType = LawFileType.已下載完成;
            }
        }
Example #17
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);
        }
    }
        private void btnDelete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            string QuestSring = "您確定要刪除檔案?";

            // userMeeting.isDownload + userMeeting.isBrowserd
            switch (meetingRoomButtonType)
            {
            case MeetingRoomButtonType.NN:
                break;

            case MeetingRoomButtonType.YY:
                break;

            case MeetingRoomButtonType.OY:
                QuestSring = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String);
                break;

            case MeetingRoomButtonType.YO:
                QuestSring = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String);
                break;
            }

            MessageBoxResult result = MessageBox.Show(QuestSring, "系統訊息", MessageBoxButton.YesNo);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            MouseTool.ShowLoading();
            bool HasDelete = false;

            try
            {
                //找出資料庫所有的檔案並且重置和刪除。
                // 多少檔案完成

                // 抓取檔案路徑
                DataTable dt = MSCE.GetDataTable(@"select ID,StorageFileName from FileRow where UserID =@1 and MeetingID=@2 and DownloadBytes!=0 and DownloadBytes >= TotalBytes;"
                                                 , UserID, userMeeting.ID);

                // 多少檔案要被刪除
                foreach (DataRow dr in dt.Rows)
                {
                    string filePath          = ClickOnceTool.GetFilePath();
                    string StorageFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_StorageFileFolder;
                    string UnZipFileFolder   = PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
                    string StorageFilePath   = filePath + "\\" + StorageFileFolder + "\\" + dr["StorageFileName"].ToString();
                    string UnZipFilePath     = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + userMeeting.ID + "\\" + dr["ID"].ToString();

                    if (File.Exists(StorageFilePath) == true)
                    {
                        File.Delete(StorageFilePath);
                    }

                    DirectoryTool.FullDeleteDirectories(UnZipFilePath);
                }

                string SQL     = @"update FileRow set DownloadBytes=0,TotalBytes=0,FinishedFileVersion=0 where UserID =@1 and MeetingID=@2 ";
                int    success = MSCE.ExecuteNonQuery(SQL
                                                      , UserID, userMeeting.ID);

                if (success < 1)
                {
                    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                }
                else
                {
                    HasDelete = true;
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            MouseTool.ShowArrow();
            if (HasDelete == false)
            {
                AutoClosingMessageBox.Show("刪除失敗");
            }
            else
            {
                // userMeeting.isDownload + userMeeting.isBrowserd
                //switch (meetingRoomButtonType)
                //{
                //    case MeetingRoomButtonType.NN:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.YY:
                //            // 一般都會顯示這個,除非下載瀏覽過期之類的
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnDownload.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.OY:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnDownloadForbidden.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.YO:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnRead2Forbidden.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //}
                btnDelete.Visibility  = Visibility.Collapsed;
                btnRefresh.Visibility = Visibility.Visible;
                pb.Value        = pb.Minimum;
                txtPercent.Text = "0 %";
            }
        }
Example #19
0
        private void CallOpenBook(bool HasOpenFinishedFileVersion = false)
        {
            MouseTool.ShowLoading();
            try
            {
                Home Home_Window = Application.Current.Windows.OfType <Home>().FirstOrDefault();

                if (Home_Window.IsInSync == true && Home_Window.IsSyncOwner == false)
                {
                    AutoClosingMessageBox.Show("同步中需由主控人員進行操作");
                    return;
                }


                //

                string filePath = ClickOnceTool.GetFilePath();

                //string _bookPath = System.IO.Path.Combine(filePath, fileItem.UnZipFilePath);
                string UnZipFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
                //string _bookPath = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\"+ fileItem.ID +"\\"+fileItem.FileVersion.ToString();
                // 等於上面那個路徑
                string _bookPath = fileItem.UnZipFilePath;

                // 從資料庫查詢上一次完成的檔案版本
                if (HasOpenFinishedFileVersion == true)
                {
                    DataTable dt = MSCE.GetDataTable("SELECT FinishedFileVersion FROM FileRow where ID=@1 and UserID=@2 and MeetingID=@3"
                                                     , meetingDataDownloadFileFile.ID
                                                     , UserID
                                                     , MeetingID);
                    if (dt.Rows.Count > 0)
                    {
                        _bookPath = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + fileItem.ID + "\\" + dt.Rows[0]["FinishedFileVersion"].ToString();
                    }
                }
                string _bookId    = fileItem.ID;
                string _account   = UserID;
                string _userName  = UserName;
                string _email     = UserEmail;
                string _meetingId = MeetingID;
                string _watermark = "";
                if (MeetingDataCT_GetWatermark_Event != null)
                {
                    _watermark = MeetingDataCT_GetWatermark_Event();
                }
                string _dbPath        = System.IO.Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.bookInfo_Path);
                bool   _isSync        = Home_Window.IsInSync;
                bool   _isSyncOwner   = Home_Window.IsSyncOwner;
                string _webServiceUrl = WsTool.GetUrl() + "/AnnotationUpload";
                string _socketMessage = "";


                SocketClient _socket   = null;
                SocketClient tmpSocket = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, Home_Window.IsInSync);

                if (tmpSocket != null && tmpSocket.GetIsConnected() == true)
                {
                    _socket = tmpSocket;
                }

                //if (_socket.GetIsConnected() == false)
                //    _socket = null;
                //if (Home_Window.IsInSync == false)
                //    _socket = null;

                // 呼叫一個事件取得 BookVMs
                Dictionary <string, BookVM> cbBooksData = new Dictionary <string, BookVM>();
                if (MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event != null)
                {
                    cbBooksData = MeetingDataCT_GetBookVMs_ByMeetingFileCate_Event(fileItem);
                }
                // debug
                //BooksData["cAF6-P"] = new BookVM("cAF6-P", filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + "cAF6-P");
                //BooksData["cAF3-P"] = new BookVM("cAF3-P", filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + MeetingID + "\\" + "cAF3-P");

                Home_Window.CloseAllWindow("", true);

                switch (fileItem.FileCate)
                {
                case MeetingFileCate.電子書:

                    InitSyncCenter(_dbPath, _bookId, _account, _meetingId);

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            byte[] ReaderKey = new byte[1];

                            try
                            {
                                if (fileItem.EncryptionKey.Equals("") == false)
                                {
                                    ReaderKey = ReaderDecodeTool.GetReaderKey(fileItem.EncryptionKey);
                                }
                            }
                            catch (Exception ex)
                            {
                                LogTool.Debug(ex);
                            }
                            ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                           , _userName, _email, _meetingId
                                                           , _watermark, _dbPath, _isSync
                                                           , _isSyncOwner, _webServiceUrl, ReaderKey, _socketMessage, _socket);

                            //ReadWindow rw = new ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                            //                      , _userName, _email, _meetingId
                            //                      , _watermark, _dbPath, _isSync
                            //                      , _isSyncOwner, _webServiceUrl, _socketMessage, _socket);
                            rw.FolderID = this.FolderID;
                            rw.WindowStyle = WindowStyle.None;
                            rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            rw.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //rw.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            rw.Show();
                        }));
                    });


                    break;

                case MeetingFileCate.Html5投影片:
                    _bookPath = _bookPath + @"\" + new FileInfo(Directory.GetFiles(_bookPath)[0]).Name;

                    InitSyncCenter(_dbPath, _bookId, _account, _meetingId);

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            HTML5ReadWindow Html5rw = new HTML5ReadWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId, _account
                                                                          , _userName, _email, _meetingId
                                                                          , _watermark, _dbPath, _isSync
                                                                          , _isSyncOwner, _webServiceUrl, _socketMessage, _socket);
                            Html5rw.FolderID = this.FolderID;
                            Html5rw.WindowStyle = WindowStyle.None;
                            Html5rw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            Html5rw.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //Html5rw.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            Html5rw.Show();
                        }));
                    });


                    break;

                case MeetingFileCate.影片檔:
                    _bookPath = _bookPath + @"\" + new FileInfo(Directory.GetFiles(_bookPath)[0]).Name;

                    Task.Factory.StartNew(() =>
                    {
                        this.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            MVWindow mvWindow = new MVWindow(cbBooksData, Home_Window.OpenBookFromReader, _bookPath, _bookId);
                            mvWindow.WindowStyle = WindowStyle.None;
                            mvWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                            mvWindow.WindowState = WindowState.Maximized;
                            if (PaperLess_Emeeting.Properties.Settings.Default.AssemblyName.Contains("TPI4F") == true)
                            {
                                //mvWindow.WindowStyle = WindowStyle.SingleBorderWindow;
                            }
                            mvWindow.Show();
                        }));
                    });

                    break;
                }

                if (Home_Window.IsInSync == true && Home_Window.IsSyncOwner == true)
                {
                    SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, Home_Window.IsInSync);
                    Task.Factory.StartNew(() =>
                    {
                        if (socketClient != null && socketClient.GetIsConnected() == true)
                        {
                            string OB = "{\"bookId\":\"" + meetingDataDownloadFileFile.ID + "\",\"cmd\":\"R.OB\"}";
                            socketClient.broadcast(OB);
                        }
                        else
                        {
                            //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步");
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }

            MouseTool.ShowArrow();
        }