private async void View_SendLogOutput(object sender, EventArgs e) { View.Sending = true; try { var logId = DateTime.UtcNow.ToString("dd MMMM yyyy hh:mm:ss", CultureInfo.InvariantCulture); var file = Path.Combine(Resources.GameUserDir, "minidump.dmp"); if (FileSystem.Current.FileExists(file)) { var transfer = new TransferUtility(_game.SupportS3BucketAccessKey, _game.SupportS3BucketSecretKey, Amazon.RegionEndpoint.USEast1); var uploadRequest = new TransferUtilityUploadRequest(); uploadRequest.FilePath = file; uploadRequest.BucketName = _game.SupportS3Bucket; uploadRequest.Key = logId + "/minidump.dmp"; await transfer.UploadAsync(uploadRequest); } var client = new Amazon.S3.AmazonS3Client(_game.SupportS3BucketAccessKey, _game.SupportS3BucketSecretKey, Amazon.RegionEndpoint.USEast1); var putRequest = new PutObjectRequest(); putRequest.ContentBody = SubmitCoreErrorPresenter.GetLogContent(_game, _detail); putRequest.BucketName = _game.SupportS3Bucket; putRequest.Key = logId + "/log.txt"; await client.PutObjectAsync(putRequest); } catch (Exception ex) { Message.Show("Failed to send error report"); Logger.Current.Write(ex, "Failed to send error report"); } View.Sending = false; CloseView(); }
private void GameExited(object context, int exitCode) { Game game = (Game)context; if (exitCode != 0) { View.Invoke(() => { var presenter = SubmitCoreErrorPresenter.Create(game, game.Name + " has ended unexpectedly", "An unhandled exception or fatal MGDF error has occurred"); presenter.ShowView(View); }); } else if (StatisticsSession.CanSendStatistics(Game.Current)) { IFile statisticsFile = FileSystem.Current.GetFile(Resources.UserStatistics()); if (statisticsFile.Exists) { try { if (StatisticsSession.GetStatisticsPermission(Game.Current, GetStatisticsPermission)) { Logger.Current.Write(LogInfoLevel.Info, "Sending statistics..."); StatisticsSession session = new StatisticsSession(Game.Current.Uid, Game.Current.StatisticsService, statisticsFile.FullName); if (session.Bundles.Count > 0) { StatisticsServiceClient client = new StatisticsServiceClient(session); List <String> errors = new List <string>(); client.SendStatistics(errors); foreach (var error in errors) { Logger.Current.Write(LogInfoLevel.Error, error); } } Logger.Current.Write(LogInfoLevel.Info, "Statistics sent."); } } catch (Exception ex) { Logger.Current.Write(ex, "Unable to send statistics"); } finally { statisticsFile.DeleteWithTimeout(); } } } else if (!string.IsNullOrEmpty(Game.Current.StatisticsService)) { Logger.Current.Write(LogInfoLevel.Warning, "Cannot send statistics due to missing privacy policy url"); } View.Invoke(() => { _workerThread = null; View.CloseView(); }); }
void View_CopyLogOutput(object sender, EventArgs e) { var runner = new CrossThreadRunner(); runner.RunInSTA(() => Clipboard.SetText(SubmitCoreErrorPresenter.GetLogContent(_game, _detail))); }