private void Dispatch() { // Make sure that we are not interfering with the crucial startup work); if (!Settings.RemoveThreadSleep) { Thread.Sleep(Settings.SleepBeforeSend * 1000); } // Turncate extra report files and try to send the first one in the queue Storer.TruncateReportFiles(); // Now go through configured destinations and submit to all automatically for (var hasReport = true; hasReport;) { using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { if (stream != null) { var exceptionData = this.GetDataFromZip(stream); if (this.EnumerateDestinations(stream, exceptionData) == false) { break; } // Delete the file after it was sent storer.DeleteCurrentReportFile(); } else { hasReport = false; } } } }
internal void VerifyAndDeleteCompressedReportFile(bool verifyCustomReport) { using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); this.VerifyIndividualReportItems(stream, verifyCustomReport); storer.DeleteCurrentReportFile(); } }
internal void DeleteGarbageReportFile() { using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { if (stream != null) { storer.DeleteCurrentReportFile(); } } }
private void Dispatch() { // Make sure that we are not interfering with the crucial startup work); if (!Settings.RemoveThreadSleep) { Thread.Sleep(Settings.SleepBeforeSend * 1000); } // Truncate extra report files and try to send the first one in the queue Storer.TruncateReportFiles(); // Now go through configured destinations and submit to all automatically for (var hasReport = true; hasReport;) { using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { if (stream != null) { // Extract crash/exception report data from the zip file. Delete the zip file if no data can be retrieved (i.e. corrupt file) ExceptionData exceptionData; try { exceptionData = GetDataFromZip(stream); } catch (Exception exception) { storer.DeleteCurrentReportFile(); Logger.Error( "An exception occurred while extraction report data from zip file. Check the inner exception for details.", exception); return; } // Now submit the report file to all configured bug report submission targets if (EnumerateDestinations(stream, exceptionData) == false) { break; } // Delete the file after it was sent storer.DeleteCurrentReportFile(); } else { hasReport = false; } } } }
public void StoragePathWindowsTemp() { Settings.StoragePath = StoragePath.WindowsTemp; new BugReport().Report(new Exception(), ExceptionThread.Main); Assert.Equal(Storer.GetReportCount(), 1); using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); Assert.True(storer.FilePath.Contains(Path.Combine(new[] { Path.GetTempPath(), Settings.EntryAssembly.GetName().Name }))); storer.DeleteCurrentReportFile(); } Assert.Equal(Storer.GetReportCount(), 0); }
public void StoragePathCustom() { Settings.StoragePath = "C:\\"; new BugReport().Report(new Exception(), ExceptionThread.Main); Assert.Equal(Storer.GetReportCount(), 1); using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); Assert.True(storer.FilePath.Contains("C:\\")); storer.DeleteCurrentReportFile(); } Assert.Equal(Storer.GetReportCount(), 0); }
public void StoragePathCurrentDirectory() { Settings.StoragePath = StoragePath.CurrentDirectory; new BugReport().Report(new Exception(), ExceptionThread.Main); Assert.Equal(Storer.GetReportCount(), 1); using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); Assert.True(storer.FilePath.Contains(Path.GetDirectoryName(Settings.EntryAssembly.Location))); storer.DeleteCurrentReportFile(); } Assert.Equal(Storer.GetReportCount(), 0); }
public void MiniDumpTypeTiny() { Settings.MiniDumpType = MiniDumpType.Tiny; new BugReport().Report(new Exception(), ExceptionThread.Main); Assert.Equal(Storer.GetReportCount(), 1); using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); Assert.InRange(stream.Length, 10 * 1024, 1 * 1024 * 1024); storer.DeleteCurrentReportFile(); } Assert.Equal(Storer.GetReportCount(), 0); }
public void StoragePathIsolatedStorage() { Settings.StoragePath = StoragePath.IsolatedStorage; new BugReport().Report(new Exception(), ExceptionThread.Main); Assert.Equal(Storer.GetReportCount(), 1); using (var storer = new Storer()) using (var stream = storer.GetFirstReportFile()) { Assert.NotNull(stream); var filePath = stream.GetType().GetField("m_FullPath", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(stream).ToString(); Assert.True(filePath.Contains("IsolatedStorage")); storer.DeleteCurrentReportFile(); } Assert.Equal(Storer.GetReportCount(), 0); }