private async void RefreshUI() { var files = await _logQuery.GetFilesAsync(0, 100); lock (_collectionLock) { LogFilesCollection.Clear(); foreach (var file in files) { LogFilesCollection.Add(new LogFile(file)); } } }
public void CollectionLimitsSizeOfTheFirstFile() { var encoding = Encoding.UTF8; File.WriteAllText(immutableFilePath_, ImmutableContent, encoding); File.WriteAllText(mutableFilePath_, MutableContentPart1, encoding); var immutableSize = GetSize(immutableFilePath_); var mutableSize = GetSize(mutableFilePath_); var initialFiles = new[] { mutableFilePath_, immutableFilePath_ }; var initialCollection = new LogFilesCollection(initialFiles, encoding, String.Empty); var initialCollectionSnapshot = initialCollection.GetSnapshot(); File.AppendAllText(mutableFilePath_, MutableContentPart2); File.WriteAllText(newFilePath_, ImmutableContent); var files = new[] { newFilePath_, mutableFilePath_, immutableFilePath_ }; var subject = new LogFilesCollection(files, encoding, initialCollectionSnapshot); using (var enumerator = subject.GetEnumerator()) { var actualMovedToMutableFile = enumerator.MoveNext(); Assert.That(actualMovedToMutableFile, Is.True); var actualMutableFile = enumerator.Current; Assert.That(actualMutableFile.FileName, Is.EqualTo(mutableFilePath_)); Assert.That(actualMutableFile.Size, Is.EqualTo(mutableSize)); var actualMovedToImmutableFile = enumerator.MoveNext(); Assert.That(actualMovedToImmutableFile, Is.True); var actualImutableFile = enumerator.Current; Assert.That(actualImutableFile.FileName, Is.EqualTo(immutableFilePath_)); var events = actualImutableFile.GetEvents(); Assert.That(actualImutableFile.Size, Is.EqualTo(immutableSize)); var actualMovedPastFiles = enumerator.MoveNext(); Assert.That(actualMovedPastFiles, Is.False); } }
private async void DeleteLogsButton_Click(object sender, RoutedEventArgs e) { var selected = LogFilesCollection.Where(item => item.IsSelected); var logs = await LogUtil.GetLogFilesAsync(); var fileList = new List <StorageFile>(); foreach (var sel in selected) { var temp = logs.Where(file => file.Path == sel.Path).FirstOrDefault(); if (temp != null) { fileList.Add(temp as StorageFile); } } if (fileList.Count > 0) { var deleteConfirmText = string.Format(fileList.Count > 1 || fileList.Count == 0 ? Common.GetLocalizedText("DeleteLogsText") : Common.GetLocalizedText("DeleteLogText"), fileList.Count); if (!await AppService.YesNoAsync(Common.GetLocalizedText("ConfirmationTitleText"), deleteConfirmText)) { return; } foreach (var file in fileList) { await file.DeleteAsync(); } var deleteSuccessText = string.Format(fileList.Count > 1 || fileList.Count == 0 ? Common.GetLocalizedText("DeletedLogsText") : Common.GetLocalizedText("DeletedLogText"), fileList.Count); PageService.ShowNotification(deleteSuccessText); RefreshUI(); } else { PageService.ShowNotification(Common.GetLocalizedText("NoLogsSelectedText")); } }
public EventsCollection GetEvents(ILogQuery query) { Debug.Assert(query != null, "LogSource.GetEvents: query is null."); var files = GetFiles(true); var encoding = config_.Encoding; var logFiles = new LogFilesCollection(files, encoding, query.Snapshot); var size = logFiles.GetSnapshot(); var accumulator = new LogAccumulator(statsCache_, query); var hintMaker = new CacheHintMaker(statsCache_, query, accumulator); var events = logFiles .Aggregate(hintMaker, (a, f) => a.Consume(f)) .Events .ToList(); events.Reverse(); return(new EventsCollection(events, Name, size)); }
private async void EmailLogsButton_Click(object sender, RoutedEventArgs e) { var provider = App.AuthManager.GetGraphProvider(); if (provider == null) { return; } if (!provider.IsTokenValid()) { AppService.DisplayAadSignInDialog(typeof(LogsPage)); return; } var selected = LogFilesCollection.Where(item => item.IsSelected); var logs = await LogUtil.GetLogFilesAsync(); var fileList = new List <StorageFile>(); foreach (var sel in selected) { var temp = logs.Where(file => file.Path == sel.Path).FirstOrDefault(); if (temp != null) { fileList.Add(temp as StorageFile); } } if (fileList.Count > 0) { var emailConfirmText = string.Format(fileList.Count > 1 || fileList.Count == 0 ? Common.GetLocalizedText("EmailLogsSelfText") : Common.GetLocalizedText("EmailLogSelfText"), fileList.Count); if (!await AppService.YesNoAsync(Common.GetLocalizedText("EmailLogsText"), emailConfirmText)) { return; } var messageContent = LogUtil.CreateMessageContent(GetType().Name, CustomContentService?.GetContent <string>(CustomContentConstants.BugTemplate)); using (var graphHelper = new GraphHelper(provider)) { try { var email = await LogUtil.EmailLogsAsync(graphHelper, "[Smart Display] LOG MAILER", messageContent, fileList.ToArray()); var emailSuccessText = string.Format(fileList.Count > 1 || fileList.Count == 0 ? Common.GetLocalizedText("EmailedLogsText") : Common.GetLocalizedText("EmailedLogText"), fileList.Count, email); PageService.ShowNotification(emailSuccessText); } catch (Exception ex) { PageService.ShowNotification(string.Format(Common.GetLocalizedText("EmailLogsProblemText"), ex.Message)); } } } else { PageService.ShowNotification(Common.GetLocalizedText("NoLogsSelectedText")); } }