private void DispatcherTimer_Tick(object sender, EventArgs e) { try { if (!timerOn) { return; } dispatcherTimer.IsEnabled = false; var timedWindow = new TimedWarningWindow(timerCount, openedCentralFiles); if (timedWindow.ShowDialog() == true) { dispatcherTimer.Stop(); dispatcherTimer.IsEnabled = false; dispatcherTimer.Tick -= DispatcherTimer_Tick; timerOn = false; } else { dispatcherTimer.IsEnabled = true; timerCount++; } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }
private void Application_DocumentOpened(object sender, DocumentOpenedEventArgs args) { try { openedDocument = args.Document; if (null == openedDocument.ActiveView) { return; // to distinguish linked model } if (!openedDocument.IsWorkshared) { return; } if (string.IsNullOrEmpty(openedDocument.PathName)) { return; } if (openedDocument.IsDetached) { return; } var isOnNetwork = IsNetworkDrive(openedDocument.PathName); if (!isOnNetwork) { return; } isCentral = IsCentralFile(openedDocument); if (!isCentral) { return; } var fileInfo = new CentralFileInfo(openedDocument); var unused = new Dictionary <string, string>(); FMEServerUtil.RunFMEWorkspaceHTTP(fileInfo, "buildingSMART Notifications", "OpenCentralFileNotification.fmw", out unused); if (!openedCentralFiles.ContainsKey(fileInfo.DocCentralPath)) { openedCentralFiles.Add(openedDocument.PathName, fileInfo); } var firstWindow = new CentralFileWarningWindow(fileInfo); if (firstWindow.ShowDialog() != true) { return; } timerCount = 1; var timedWindow = new TimedWarningWindow(timerCount, openedCentralFiles); if (timedWindow.ShowDialog() == true) { timerOn = false; } else { timerOn = true; if (null != dispatcherTimer) { dispatcherTimer.IsEnabled = false; dispatcherTimer.Tick -= DispatcherTimer_Tick; dispatcherTimer = null; } dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 30); dispatcherTimer.IsEnabled = true; dispatcherTimer.Start(); } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); } }