private async void CollectAndUploadLog()
        {
            var pd = await this.ShowProgressAsync("Uploading log", $"Please wait while the application log is uploaded to the ME3Tweaks Log Viewing Service.");

            pd.SetIndeterminate();

            NamedBackgroundWorker nbw = new NamedBackgroundWorker("DiagnosticsWorker");

            nbw.DoWork += (a, b) =>
            {
                //ProgressIndeterminate = true;
                //GameTarget target = GameChosen != null ? Locations.GetTarget(GameChosen.Value) : null;
                StringBuilder logUploadText = new StringBuilder();

                string logText = "";
                //if (target != null)
                //{
                //    logUploadText.Append("[MODE]diagnostics\n"); //do not localize
                //    logUploadText.Append(LogCollector.PerformDiagnostic(target, FullDiagChosen,
                //            x => DiagnosticStatusText = x,
                //            x =>
                //            {
                //                ProgressIndeterminate = false;
                //                ProgressValue = x;
                //            },
                //            () => ProgressIndeterminate = true));
                //    logUploadText.Append("\n"); //do not localize
                //}

                if (SelectedLogForUpload != null)
                {
                    logUploadText.Append("[MODE]logs\n"); //do not localize
                    logUploadText.AppendLine(LogCollector.CollectLogs(SelectedLogForUpload.filepath));
                    logUploadText.Append("\n");           //do not localize
                }

                //DiagnosticStatusText = "Uploading to log viewing service";
                //ProgressIndeterminate = true;
                var response = LogUploader.UploadLog(logUploadText.ToString(), "https://me3tweaks.com/masseffect2randomizer/logservice/logupload");
                if (response.uploaded)
                {
                    var DiagnosticResultText = response.result;
                    if (response.result.StartsWith("http"))
                    {
                        Utilities.OpenWebPage(response.result);
                    }
                }


                if (!response.uploaded || QuickFixHelper.IsQuickFixEnabled(QuickFixHelper.QuickFixName.ForceSavingLogLocally))
                {
                    // Upload failed.
                    var GeneratedLogPath = Path.Combine(LogCollector.LogDir, $"FailedLogUpload_{DateTime.Now.ToString("s").Replace(":", ".")}.txt");
                    File.WriteAllText(GeneratedLogPath, logUploadText.ToString());
                }

                //DiagnosticComplete = true;
                //DiagnosticInProgress = false;
            };
            nbw.RunWorkerCompleted += async(sender, args) =>
            {
                CommandManager.InvalidateRequerySuggested();
                LogUploaderFlyoutOpen = false;
                await pd.CloseAsync();
            };
            //DiagnosticInProgress = true;
            nbw.RunWorkerAsync();
        }
Beispiel #2
0
 public static void UploadDirectToAWSCarlos(string nameFile)
 {
     log.Completed += log_Completed;
     log.UploadLog(nameFile);
 }