internal CrashReport(Database.DatabasePrivateApi database, Guid guid, long unixTimeStamp, string buildType, string errorFrindly, string key, string webFileLocation, Version version, string downloadedZip = null, string folderlocation = null, string stackTrace = null, string userstory = null) { _database = database; _key = key; _downloadedZip = downloadedZip; _folderlocation = folderlocation; Guid = guid; BuildType = buildType; ErrorFrindly = errorFrindly; WebFileLocation = webFileLocation; Version = version; StackTrace = stackTrace; Userstory = userstory; DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); //Addseconds complains, 1 second = 10000 ns ticks so do that instead Timestamp = unixStart.AddTicks(unixTimeStamp * 10000); if (folderlocation != null) { Progress = CrashReportProcessingProgress.Unpacked; } else if (downloadedZip != null) { Progress = CrashReportProcessingProgress.Downloaded; } else { Progress = CrashReportProcessingProgress.NotStarted; } }
private void WorkerOnStatusChanged(INotifyThreadStatus sender, StatusChangedEventArgs args) { if (args.AttachedData?.guid != Guid ?? false) { return; } _worker.StatusChanged -= WorkerOnStatusChanged; _database.SetZipFileLocation(Guid, args.AttachedData.destinationPath); WebFileLocation = args.AttachedData.destinationPath; string userstory = null, exception; using (ZipArchive archive = new ZipArchive(File.OpenRead(args.AttachedData.destinationPath), ZipArchiveMode.Read, false)) { ZipArchiveEntry userstoryEntry = archive.GetEntry("userstory.txt"); if (userstoryEntry != null) { using (Stream s = userstoryEntry.Open()) { byte[] buffer = new byte[userstoryEntry.Length]; s.Read(buffer, 0, buffer.Length); userstory = Encoding.UTF8.GetString(buffer); } } ZipArchiveEntry exceptionEntry = archive.GetEntry("exception.txt"); using (Stream s = exceptionEntry.Open()) { byte[] buffer = new byte[exceptionEntry.Length]; s.Read(buffer, 0, buffer.Length); exception = Encoding.UTF8.GetString(buffer); } } Userstory = userstory; StackTrace = exception; _database.SetStackTrace(Guid, exception); if (userstory != null) { _database.SetUserStory(Guid, userstory); } Progress = CrashReportProcessingProgress.Downloaded; }
internal void StartDownload(DownloaderWorker worker) { if (Progress != CrashReportProcessingProgress.NotStarted) { throw new InvalidOperationException(); } Progress = CrashReportProcessingProgress.Downloading; string file = PersistentState.Database.GetKey("crashdumps_zip_folder") + "\\" + Guid + ".zip"; _worker = worker; _worker.Enqueue(Guid, WebFileLocation, _key, file); _worker.StatusChanged += WorkerOnStatusChanged; }
private void OnProgressChanged(CrashReportProcessingProgress progress) { if (InvokeRequired) { Invoke(new Action(() => OnProgressChanged(progress))); return; } switch (progress) { case CrashReportProcessingProgress.NotStarted: btnAction.Text = "Download"; btnAction.Enabled = true; break; case CrashReportProcessingProgress.Downloading: btnAction.Text = "Downloading"; btnAction.Enabled = false; break; case CrashReportProcessingProgress.Downloaded: btnAction.Text = "Unpack"; btnAction.Enabled = true; break; case CrashReportProcessingProgress.Unpacking: btnAction.Text = "Unpacking"; btnAction.Enabled = false; break; case CrashReportProcessingProgress.Unpacked: btnAction.Text = "Open folder"; btnAction.Enabled = true; break; default: throw new ArgumentOutOfRangeException(); } if (_report.StackTrace != null) { lblExceptionGuess.Text = GuessStack(_report.StackTrace); lblExceptionGuess.Visible = true; } }
private void OnProgressChanged(CrashReportProcessingProgress progress) { if (InvokeRequired) { Invoke(new Action(() => OnProgressChanged(progress))); return; } switch (progress) { case CrashReportProcessingProgress.NotStarted: btnAction.Text = "Download"; btnAction.Enabled = true; break; case CrashReportProcessingProgress.Downloading: btnAction.Text = "Downloading"; btnAction.Enabled = false; break; case CrashReportProcessingProgress.Downloaded: btnAction.Text = "Unpack"; btnAction.Enabled = true; break; case CrashReportProcessingProgress.Unpacking: btnAction.Text = "Unpacking"; btnAction.Enabled = false; break; case CrashReportProcessingProgress.Unpacked: btnAction.Text = "Open folder"; btnAction.Enabled = true; break; default: throw new ArgumentOutOfRangeException(); } if (_report.StackTrace != null) { lblExceptionGuess.Text = GuessStack(_report.StackTrace); lblExceptionGuess.Visible = true; } }
internal void StartDownload(DownloaderWorker worker) { if (Uri.TryCreate(WebFileLocation, UriKind.RelativeOrAbsolute, out Uri uriLocation)) { if (Progress != CrashReportProcessingProgress.NotStarted) { throw new InvalidOperationException(); } Progress = CrashReportProcessingProgress.Downloading; string file = PersistentState.Database.GetKey("crashdumps_zip_folder") + Path.DirectorySeparatorChar + Guid + ".zip"; _worker = worker; _worker.Enqueue(Guid, uriLocation, _key, file); _worker.StatusChanged += WorkerOnStatusChanged; } else { throw new InvalidOperationException(); } }