From 6c57a826a4287b1ca3ea418fcc2aed50ed129bdc Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 24 Nov 2019 16:39:46 +0200 Subject: Implemented AutoLogRemoval & MaxFileSizeLimit to FileLogger, LogFileParser and TFS bug reporting!!! --- .../TFS/TeamFoundationServicePPCClient.cs | 54 +++++++++++++++------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs index 26d6425bf..c28c5fcba 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.BugReporting/TFS/TeamFoundationServicePPCClient.cs @@ -53,6 +53,21 @@ namespace Tango.PPC.BugReporting.TFS } } + private string[] GetLogFiles(FileLogger logger) + { + string[] fileEntries = new string[1]; + fileEntries[0] = logger.LogFile; + string fileName = Path.GetFileNameWithoutExtension(logger.LogFile); + int indexPos = fileName.IndexOf(FileLogger.FILE_SET_EXTENSION); + if (indexPos > 0) + { + string extension = Path.GetExtension(logger.LogFile); + fileName = fileName.Substring(0, indexPos); + fileEntries = Directory.GetFiles(logger.Folder, $"{fileName}*{extension}").Where(x => Path.GetFileName(x).StartsWith(logger.Tag)).OrderBy(x => x.Length).ThenBy(x => x).ToArray(); + } + return fileEntries; + } + public async Task SubmitBug(String title, String steps, TeamMember createdBy, TeamMember assignedTo, Severity severity) { LogManager.Log("Submitting bug report..."); @@ -87,31 +102,36 @@ namespace Tango.PPC.BugReporting.TFS if (appFileLogger != null) { LogManager.Log($"Attaching application log file ${appFileLogger.LogFile}"); - - var appLogFile = tempFolder.CreateImaginaryFile(); - File.Copy(appFileLogger.LogFile, appLogFile.Path); - - item.Attachments.Add(new Attachment() + string[] logFiles = GetLogFiles(appFileLogger); + foreach (string file in logFiles) { - Description = "Application Log File", - FilePath = appLogFile.Path, - Name = Path.GetFileName(appFileLogger.LogFile), - }); + var appLogFile = tempFolder.CreateImaginaryFile(); + File.Copy(file, appLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Application Log File", + FilePath = appLogFile.Path, + Name = Path.GetFileName(file), + }); + } } if (embeddedFileLogger != null && File.Exists(embeddedFileLogger.LogFile)) { LogManager.Log($"Attaching embedded log file ${embeddedFileLogger.LogFile}"); - var embeddedLogFile = tempFolder.CreateImaginaryFile(); - File.Copy(embeddedFileLogger.LogFile, embeddedLogFile.Path); - - item.Attachments.Add(new Attachment() + string[] logFiles = GetLogFiles(embeddedFileLogger); + foreach (string file in logFiles) { - Description = "Embedded Log File", - FilePath = embeddedLogFile.Path, - Name = Path.GetFileName(embeddedFileLogger.LogFile), - }); + var embeddedLogFile = tempFolder.CreateImaginaryFile(); + File.Copy(file, embeddedLogFile.Path); + item.Attachments.Add(new Attachment() + { + Description = "Embedded Log File", + FilePath = embeddedLogFile.Path, + Name = Path.GetFileName(file), + }); + } } SystemInformationModel sysModel = new SystemInformationModel(); -- cgit v1.3.1