private async Task GetFileList() { List <RemoteFileInfo> remoteFileInfos; try { remoteFileInfos = await _restApi.GetRemoteFileListAsync(_remoteUrl); //Logger.Trace("Remote files:\r\n{0}", string.Join("\r\n", remoteFileInfos.Select(rfi => rfi.Name))); } catch (Exception e) { Logger.Error(e); var _errorView = new ErrorView(L("FilesNotReady"), e.Message, "https://www.bphots.com/articles/errors/"); //ShowMessageBox(L("FilesNotReady"), MessageBoxButton.OK, MessageBoxImage.Exclamation); RequestClose(false); return; } remoteFileInfos.ForEach(r => _totalBytes += long.Parse(r.Size)); FileUpdateInfos.AddRange(remoteFileInfos.Select(fi => new FileUpdateInfo { FileName = fi.Name, Url = fi.Url, RemoteMD5 = fi.MD5, LocalFilePath = Path.Combine(App.AppPath, _localDir, fi.Name.TrimStart('/')), Path = fi.Url.Remove(0, 24), //移去https://static.bphots.com/ FileStatus = L("Updating") })); }
private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { Pages.ErrorView _errorView; try { if (e.Exception.Message.ToLower().Contains("lang")) { _errorView = new Pages.ErrorView(e.Exception.Message + "\nApplication language=" + App.Language); } else { _errorView = new Pages.ErrorView(e.Exception.Message); } _log.Error(e.Exception); _errorView.ShowDialog(); _errorView.Pause(); //MessageBox.Show(e.Exception.Message, "", MessageBoxButton.OK, MessageBoxImage.Error); e.Handled = true; } catch (Exception) { // ignored } //Current.Shutdown(); }
private void CheckFiles() { try { if (FileUpdateInfos.Any(fui => fui.FileStatus == L("UpdateFailed"))) { var _errorView = new ErrorView(L("FileUpdateFail"), L("FilesNotReady"), "https://www.bphots.com/articles/errors/"); _errorView.ShowDialog(); //ShowMessageBox(L("FilesNotReady"), MessageBoxButton.OK, MessageBoxImage.Exclamation); RequestClose(false); } } catch (InvalidOperationException e) { Logger.Error(e); var errorView = new ErrorView(L("FileUpdateFail"), e.Message, "https://www.bphots.com/articles/errors/1"); errorView.ShowDialog(); RequestClose(false); return; } catch (Exception e) { Logger.Error(e); var errorView = new ErrorView(L("FilesNotReady"), e.Message, "https://www.bphots.com/articles/errors/"); errorView.ShowDialog(); RequestClose(false); return; } RequestClose(true); }