private void _003CbtnServerCtrl_MouseLeftButtonDown_003Eb__16() { try { _003C_003Ec__DisplayClass1e _003C_003Ec__DisplayClass1e = new _003C_003Ec__DisplayClass1e(); _003C_003Ec__DisplayClass1e._003C_003E4__this = this; _003C_003Ec__DisplayClass1e.success = StartSyncServer(MeetingID); base.Dispatcher.BeginInvoke(new Action(_003C_003Ec__DisplayClass1e._003CbtnServerCtrl_MouseLeftButtonDown_003Eb__17)); if (_003C_003Ec__DisplayClass1e.success) { AutoClosingMessageBox.Show("啟動成功"); try { _003C_003Ec__DisplayClass20 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass20(); _003C_003Ec__DisplayClass.CS_0024_003C_003E8__locals1f = _003C_003Ec__DisplayClass1e; _003C_003Ec__DisplayClass.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass._003CbtnServerCtrl_MouseLeftButtonDown_003Eb__18)); } catch (Exception ex) { LogTool.Debug(ex); } } else { AutoClosingMessageBox.Show("啟動失敗"); } } catch (Exception ex2) { LogTool.Debug(ex2); } }
private void _003CInitEvent_003Eb__8(Task <bool> task) { Action action = null; _003C_003Ec__DisplayClass12 _003C_003Ec__DisplayClass = new _003C_003Ec__DisplayClass12(); _003C_003Ec__DisplayClass.task = task; _003C_003Ec__DisplayClass._003C_003E4__this = this; try { Dispatcher dispatcher = base.Dispatcher; if (action == null) { action = new Action(_003C_003Ec__DisplayClass._003CInitEvent_003Eb__9); } dispatcher.BeginInvoke(action); if (_003C_003Ec__DisplayClass.task.Result) { try { _003C_003Ec__DisplayClass14 _003C_003Ec__DisplayClass2 = new _003C_003Ec__DisplayClass14(); _003C_003Ec__DisplayClass2.CS_0024_003C_003E8__locals13 = _003C_003Ec__DisplayClass; _003C_003Ec__DisplayClass2.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass2._003CInitEvent_003Eb__a)); } catch (Exception ex) { LogTool.Debug(ex); } } } catch (Exception ex2) { LogTool.Debug(ex2); } }
private void LightGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { string SyncOwnerID = ""; if (txtLight.Text.Equals("關")) { SyncOwnerID = clientId; } Task.Factory.StartNew(() => { try { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.setSyncOwner(Socket_FixEmailUserID.ToSocket(SyncOwnerID)); return; } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); return; } } catch (Exception ex) { LogTool.Debug(ex); } }); }
private void btnClose_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (IsInSync == true && IsSyncOwner == false) { return; } mediaPlayer.Stop(); mediaPlayer.Close(); this.Close(); if (IsInSync == true && IsSyncOwner == true) { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true); Task.Factory.StartNew(() => { if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.broadcast("{\"cmd\":\"R.CB\"}"); } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); } }
public void _003CUserControl_MouseLeftButtonDown_003Eb__4() { AutoClosingMessageBox.Show("連線中"); int num = 1; SocketClient instance; while (true) { if (num <= 10) { instance = Singleton_Socket.GetInstance(_003C_003E4__this.MeetingID, _003C_003E4__this.UserID, _003C_003E4__this.UserName, syncSwitch); Thread.Sleep(1); if (instance != null && instance.GetIsConnected()) { break; } Singleton_Socket.ClearInstance(); if (num == 10) { AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } Thread.Sleep(10); num++; continue; } return; } instance.syncSwitch(syncSwitch); }
public void _003CSentToOther_003Eb__21() { SocketClient instance = Singleton_Socket.GetInstance(CS_0024_003C_003E8__locals23._003C_003E4__this.MeetingID, CS_0024_003C_003E8__locals23._003C_003E4__this.UserID, CS_0024_003C_003E8__locals23._003C_003E4__this.UserName, true); if (instance != null && instance.GetIsConnected()) { instance.broadcast("{\"execTime\":" + CS_0024_003C_003E8__locals23.ecTime + ",\"action\":\"" + CS_0024_003C_003E8__locals23.function + "\",\"actionTime\":\"" + mydate.ToString("HH:mm:ss.fff") + "\",\"cmd\":\"R.SV\"}"); } }
private void _003CInitEvent_003Eb__6(Task task) { while (CanDetectServerState) { _003C_003Ec__DisplayClassf _003C_003Ec__DisplayClassf = new _003C_003Ec__DisplayClassf(); _003C_003Ec__DisplayClassf._003C_003E4__this = this; _003C_003Ec__DisplayClassf.inList = SyncServerAlreadyStarted(MeetingID); base.Dispatcher.BeginInvoke(new Action(_003C_003Ec__DisplayClassf._003CInitEvent_003Eb__7)); SocketClient instance = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); instance.getUserList(); Console.WriteLine("Detect Server Alive => IsCompleted: {0} IsCanceled: {1} IsFaulted: {2}", task.IsCompleted, task.IsCanceled, task.IsFaulted); Thread.Sleep(1000 * Settings.Default.DetectSyncServerSeconds); } }
private void btnClose_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!IsInSync || IsSyncOwner) { mediaPlayer.Stop(); mediaPlayer.Close(); Close(); if (IsInSync && IsSyncOwner) { _003C_003Ec__DisplayClass1a _003C_003Ec__DisplayClass1a = new _003C_003Ec__DisplayClass1a(); _003C_003Ec__DisplayClass1a.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true); Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass1a._003CbtnClose_MouseLeftButtonDown_003Eb__19)); } } }
public void _003CLightGrid_MouseLeftButtonDown_003Eb__6() { try { SocketClient instance = Singleton_Socket.GetInstance(_003C_003E4__this.MeetingID, _003C_003E4__this.UserID, _003C_003E4__this.UserName, false); if (instance != null && instance.GetIsConnected()) { instance.setSyncOwner(Socket_FixEmailUserID.ToSocket(SyncOwnerID)); } } catch (Exception ex) { LogTool.Debug(ex); } }
public App() { base.ShutdownMode = ShutdownMode.OnLastWindowClose; Singleton_Socket.Init(); ServicePointManager.DefaultConnectionLimit = Settings.Default.ServicePoint_DefaultConnectionLimit; ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.Expect100Continue = true; ServicePointManager.MaxServicePointIdleTime = 3600000; ServicePointManager.DnsRefreshTimeout = 240000; CheckDBVersion(); StartMenuShortCutTool.DeleteDirectory("hyweb"); StartMenuShortCutTool.DeleteDirectory("凌網科技股份有限公司"); Process currentProcess = Process.GetCurrentProcess(); currentProcess.PriorityClass = ProcessPriorityClass.AboveNormal; }
private void btnSync_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { _003C_003Ec__DisplayClass1e _003C_003Ec__DisplayClass1e = new _003C_003Ec__DisplayClass1e(); _003C_003Ec__DisplayClass1e._003C_003E4__this = this; _003C_003Ec__DisplayClass1e.syncSwitch = false; if (!IsInSync) { IsInSync = true; _003C_003Ec__DisplayClass1e.syncSwitch = true; } else { IsInSync = false; _003C_003Ec__DisplayClass1e.syncSwitch = false; } btnSync.Source = ButtonTool.GetSyncButtonImage(IsInSync, IsSyncOwner); _003C_003Ec__DisplayClass1e.socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(new Action(_003C_003Ec__DisplayClass1e._003CbtnSync_MouseLeftButtonDown_003Eb__1c)); }
private void SentToOther(string function) { long ecTime = DateTool.GetCurrentTimeInUnixMillis() - DeltaUTC; if (IsInSync == true && IsSyncOwner == true) { DateTime mydate = new DateTime(mediaPlayer.Position.Ticks); Task.Factory.StartNew(() => { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, true); if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.broadcast("{\"execTime\":" + ecTime.ToString() + ",\"action\":\"" + function + "\",\"actionTime\":\"" + mydate.ToString("HH:mm:ss.fff") + "\",\"cmd\":\"R.SV\"}"); } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); } }
private void btnSync_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { bool syncSwitch = false; // 沒有同步中,改成同步 if (IsInSync == false) { IsInSync = true; syncSwitch = true; } else // 同步中,改成沒有同步 { IsInSync = false; syncSwitch = false; } btnSync.Source = ButtonTool.GetSyncButtonImage(IsInSync, IsSyncOwner); SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(() => { if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.syncSwitch(syncSwitch); } else { IsInSync = false; IsSyncOwner = false; this.Dispatcher.BeginInvoke((Action)(() => { AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); btnSync.Source = ButtonTool.GetSyncButtonImage(IsInSync, IsSyncOwner); cbBooks.Visibility = Visibility.Visible; })); } }); }
public App() { this.ShutdownMode = ShutdownMode.OnLastWindowClose; Singleton_Socket.Init(); //在初始化方法設置以下相關屬性. //對象所允許的最大並發連接數//可在配置文件中設置 //*System.Net.ServicePointManager.DefaultConnectionLimit = 1000; //是否使用 Nagle 不使用 提高效率 //*System.Net.ServicePointManager.UseNagleAlgorithm = false; //Nagle 演算法能藉由緩衝處理小型的資料封包,再以單一封包傳送多個小型資料封包的方式,用以降低網路的資訊流量。 這種處理方式稱為 "Nagling"。由於這種技術可以減低資料封包傳送的數目,進而降低單位封包處理的固定資源損耗,因此廣為業界所使用。 //變更這個屬性值並不會影響現有的 ServicePoint 物件, 只有在變更設定之後所建立的新服務點才會有影響。 //《IETF RFC 896》對 Nagle 演算法有完整的說明。 //對象的最大空閒時間.(默認為100秒的) //*System.Net.ServicePointManager.MaxServicePointIdleTime = 3600 * 1000; // 取得或設定 ServicePoint 物件所允許的同時連線最大數。 // ServicePoint 物件所允許的同時連線最大數。 預設值為 2。 // 設定為1024; System.Net.ServicePointManager.DefaultConnectionLimit = PaperLess_Emeeting.Properties.Settings.Default.ServicePoint_DefaultConnectionLimit; System.Net.ServicePointManager.UseNagleAlgorithm = false; System.Net.ServicePointManager.Expect100Continue = true; //ServicePoint 物件的最大閒置時間,以毫秒為單位。 預設值為 100,000 毫秒 (100 秒)。 System.Net.ServicePointManager.MaxServicePointIdleTime = 3600 * 1000; //逾時值 (以毫秒為單位)。 -1 值表示無限逾時週期。 預設值為 120,000 毫秒 (兩分鐘)。 System.Net.ServicePointManager.DnsRefreshTimeout = 4 * 60 * 1000; // 4 minutes CheckDBVersion(); StartMenuShortCutTool.DeleteDirectory("hyweb"); StartMenuShortCutTool.DeleteDirectory("凌網科技股份有限公司"); var p = System.Diagnostics.Process.GetCurrentProcess(); p.PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal; }
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(); }
private void btnServerCtrl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // 做啟動Server動作 if (txtStatus.Text.Equals("未啟動") == true) { Task.Factory.StartNew(() => { try { bool success = StartSyncServer(MeetingID); this.Dispatcher.BeginInvoke(new Action(() => { ChangeServerCtrl(success); })); if (success == true) { AutoClosingMessageBox.Show("啟動成功"); try { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(() => { if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.getUserList(); } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); } catch (Exception ex) { LogTool.Debug(ex); } } else { AutoClosingMessageBox.Show("啟動失敗"); } } catch (Exception ex) { LogTool.Debug(ex); } }); } else // 做停止Server動作 { Task.Factory.StartNew(() => { try { bool success = StopSyncServer(MeetingID); this.Dispatcher.BeginInvoke(new Action(() => { ChangeServerCtrl(!success); })); if (success == true) { AutoClosingMessageBox.Show("停止成功"); this.Dispatcher.BeginInvoke(new Action(() => { BroadcastRowSP.Children.Clear(); })); } else { AutoClosingMessageBox.Show("停止失敗"); } } catch (Exception ex) { LogTool.Debug(ex); } }); } }
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(); }
private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (userButton.ID.Equals("BtnSync")) { 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; } if (Home_ReturnSyncStatus_Event != null) { Tuple <bool, bool> SyncStatus = Home_ReturnSyncStatus_Event(); bool syncSwitch = false; // 沒同步,按下去要變成同步且不是主控 if (SyncStatus.Item1 == false) { int FileNotFinished = 0; DataTable dt = MSCE.GetDataTable(@"select count(ID) as FileNotFinished from NowLogin as nl inner join FileRow as fr on nl.UserID=fr.UserID and nl.MeetingID=fr.MeetingID where DownloadBytes=0 or DownloadBytes<TotalBytes"); if (dt.Rows.Count > 0) { FileNotFinished = (int)dt.Rows[0]["FileNotFinished"]; } if (FileNotFinished > 0) { AutoClosingMessageBox.Show(string.Format("請將{0}資料下載完成後,再同步", PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String)); return; } syncSwitch = true; } else //有同步,不是主控,按下去要變成沒有同步 { syncSwitch = false; } btnImg.Source = ButtonTool.GetSyncButtonImage(SyncStatus.Item1, SyncStatus.Item2); //string UserID = ""; //string UserName = ""; //string MeetingID = ""; //DataTable dt = MSCE.GetDataTable("select UserID,UserName,UserPWD,MeetingID from NowLogin"); //if (dt.Rows.Count > 0) //{ // UserID = dt.Rows[0]["UserID"].ToString(); // UserName = dt.Rows[0]["UserName"].ToString(); // MeetingID = dt.Rows[0]["MeetingID"].ToString(); //} Task.Factory.StartNew(() => { AutoClosingMessageBox.Show("連線中"); int i = 1; while (i <= 10) { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, syncSwitch); Thread.Sleep(1); if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.syncSwitch(syncSwitch); break; } else { Singleton_Socket.ClearInstance(); if (i == 10) { AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } } Thread.Sleep(10); i++; } }); } } else { if (userButton.ID.Equals("BtnIndividualSign") || userButton.ID.Equals("BtnBroadcast")) { 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)); //AutoClosingMessageBox.Show("您不在會議室範圍內,無法使用此功能"); return; } } btnImg.Source = ButtonTool.GetButtonImage(userButton.ID, true); if (Home_PopUpButtons_Event != null) { Home_PopUpButtons_Event(userButton.ID); } } //if(userButton.ID.Equals("BtnQuit")==true) //{ // DataTable dt = MSCE.GetDataTable("select HomeUserButtonAryJSON from NowLogin"); // if (dt.Rows.Count > 0) // { // string HomeUserButtonAryJSON = dt.Rows[0]["HomeUserButtonAryJSON"].ToString(); // Task.Factory.StartNew(() => // { // Home_ChangeBtnSP_Event(JsonConvert.DeserializeObject<UserButton[]>(HomeUserButtonAryJSON), "BtnHome"); // }); // } //} //改變按鈕列表 Task.Factory.StartNew(() => { Home_ChangeCC_Event(userButton); }); }
private void InitEvent() { txtKeyword.MouseEnter += (sender, e) => { MouseTool.ShowIBeam(); txtKeyword.Focus(); }; txtKeyword.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); }; //Keyboard.ClearFocus(); txtKeyword.KeyUp += txtKeyword_KeyUp; txtKeyword.Focus(); btnServerCtrl.MouseEnter += (sender, e) => { MouseTool.ShowHand(); }; btnServerCtrl.MouseLeave += (sender, e) => { MouseTool.ShowArrow(); }; btnServerCtrl.MouseLeftButtonDown += btnServerCtrl_MouseLeftButtonDown; BroadcastCT_ChangeList_Callback = new BroadcastCT_ChangeList_Function(ChangeList); BroadcastCT_ClearList_Callback = new BroadcastCT_ClearList_Function(ClearList); Singleton_Socket.broadcastCT_OpenIEventManager.BroadcastCT_ChangeList_Event += BroadcastCT_ChangeList_Callback; Singleton_Socket.broadcastCT_CloseIEventManager.BroadcastCT_ClearList_Event += BroadcastCT_ClearList_Callback; Task.Factory.StartNew(() => { return(SyncServerAlreadyStarted(MeetingID)); }).ContinueWith(task => { try { this.Dispatcher.BeginInvoke(new Action(() => { ChangeServerCtrl(task.Result); })); if (task.Result == false) { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); return; } try { SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); Task.Factory.StartNew(() => { if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.getUserList(); } else { // AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); } catch (Exception ex) { LogTool.Debug(ex); } } catch (Exception ex) { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); LogTool.Debug(ex); } }).ContinueWith(task => { while (CanDetectServerState) { bool inList = SyncServerAlreadyStarted(MeetingID); this.Dispatcher.BeginInvoke(new Action(() => { ChangeServerCtrl(inList); })); SocketClient socketClient = Singleton_Socket.GetInstance(MeetingID, UserID, UserName, false); //20150708 Add Task.Factory.StartNew(() => { if (socketClient != null && socketClient.GetIsConnected() == true) { socketClient.getUserList(); } else { //AutoClosingMessageBox.Show("同步伺服器尚未啟動,請聯絡議事管理員開啟同步"); } }); //socketClient.getUserList(); Console.WriteLine("Detect Server Alive => IsCompleted: {0} IsCanceled: {1} IsFaulted: {2}", task.IsCompleted, task.IsCanceled, task.IsFaulted); Thread.Sleep(1000 * PaperLess_Emeeting.Properties.Settings.Default.DetectSyncServerSeconds); } }, tokenSource.Token); }