public void Diagnostic(IMasterDisplayWindow msgOwner) { WaitingCollectLogView waitingview = new WaitingCollectLogView(); string appDataFolder = Utils.GetConfigDataPath(); LogFileCollector collector = new LogFileCollector(appDataFolder); Task.Run(() => { collector.Collect(); _isLogUploadSuccess = collector.UploadToOss(); CollectLogFinished(this, waitingview); }); waitingview.Owner = msgOwner.GetWindow(); waitingview.Topmost = true; waitingview.ShowDialog(); if (!_isLogUploadSuccess) { using (CommonOpenFileDialog dialog = new CommonOpenFileDialog()) { dialog.Title = LanguageUtil.Instance.GetValueByKey("CHOOSE_LOG_FILE_PATH"); dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.IsFolderPicker = true; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { try { collector.SaveAsTo(dialog.FileName); } catch (Exception ex) { log.ErrorFormat("Error:\n {0}", ex.Message); MessageBoxTip tip1 = new MessageBoxTip(msgOwner); tip1.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), string.Format("Error:\n {0}", ex.Message), LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip1.ShowDialog(); return; } } else { // no save file, just exit. return; } } } MessageBoxTip tip2 = new MessageBoxTip(msgOwner); string msg = LanguageUtil.Instance.GetValueByKey("SAVE_LOG_FILE_SUCCESS"); if (_isLogUploadSuccess) { msg = LanguageUtil.Instance.GetValueByKey("UPLOAD_LOG_FILE_SUCCESS"); } tip2.SetTitleAndMsg(LanguageUtil.Instance.GetValueByKey("PROMPT"), msg, LanguageUtil.Instance.GetValueByKey("CONFIRM")); tip2.ShowDialog(); }
private void OnCollectLogFinished(object sender, WaitingCollectLogView arg) { isCollecting = false; OnPropertyChanged("isCollecting"); App.Current.Dispatcher.Invoke(() => { System.Windows.Input.Mouse.OverrideCursor = appCursor; arg.Close(); }); }