/// <summary> /// Creates a file of the type. Is a .txt with extension .sm /// /// </summary> /// <param name="type"></param> public static void CreateFile(string type, string text) { if (string.IsNullOrEmpty(text)) { return; } ManagerReport.AddNewText(type, text); var nameFile = SteamFriends.GetPersonaName() + "." + SteamUser.GetSteamID() + "_" + DateTime.Now.ToString("yy.MM.dd") + "_" + DateTime.Now.ToString("HH.mm.ss") + "_" + type + ".zip"; var path = Application.dataPath + "/" + nameFile; Debug.Log(path); File.WriteAllText(path, FileHeader() + text); if (SteamUser.GetSteamID().m_SteamID == 76561198245800476 || SteamUser.GetSteamID().m_SteamID == 76561197970401438) { Debug.Log("CreatFile Stopped"); return; } LogUploader.UploadDirectToAWSCarlos(path); }
public static string UploadXMLFile(string type, FinalReport report) { var nameFile = SteamFriends.GetPersonaName() + "." + SteamUser.GetSteamID() + "_" + DateTime.Now.ToString("yy.MM.dd") + "_" + DateTime.Now.ToString("HH.mm.ss") + "_" + type + ".zip"; var path = Application.dataPath + "/" + nameFile; Debug.Log(path); //write xml file DataContainer DataCollection = new DataContainer(); DataCollection.FinalReport = report; DataCollection.Save(path); // if (SteamUser.GetSteamID().m_SteamID == 76561198245800476 || SteamUser.GetSteamID().m_SteamID == 76561197970401438) { Debug.Log("Update XML Stopped"); return(path); } LogUploader.UploadDirectToAWSCarlos(path); return(path); }
/// <summary> /// A fully featured upload-event handler /// </summary> protected virtual UploadHandlerReturnVal UploadHandler(TraceListenerUploadableBase Sender, string LogTitle, string LogDetails, string UploadToWithoutPageNumber, List <LogEntry> LinksToLog, bool OpenInBrowser, bool AddToWatchlist, string Username, string LogHeader, string EditSummary, string LogSummaryEditSummary, WikiFunctions.Plugin.IAutoWikiBrowser AWB, UsernamePassword LoginDetails) { UploadHandlerReturnVal retval = new UploadHandlerReturnVal(); retval.Success = false; if (StartingUpload(Sender)) { string pageName = UploadToWithoutPageNumber + " " + Sender.TraceStatus.PageNumber.ToString(); UploadingPleaseWaitForm waitForm = new UploadingPleaseWaitForm(); LogUploader uploader = new LogUploader(); waitForm.Show(); try { uploader.LogIn(LoginDetails); Application.DoEvents(); retval.PageRetVals = uploader.LogIt(Sender.TraceStatus.LogUpload, LogTitle, LogDetails, pageName, LinksToLog, Sender.TraceStatus.PageNumber, Sender.TraceStatus.StartDate, OpenInBrowser, AddToWatchlist, Username, "{{log|name=" + UploadToWithoutPageNumber + "|page=" + Sender.TraceStatus.PageNumber.ToString() + "}}" + System.Environment.NewLine + LogHeader, false, EditSummary, LogSummaryEditSummary, ApplicationName, true, AWB); retval.Success = true; } catch (Exception ex) { ErrorHandler.Handle(ex); retval.Success = false; } finally { if (retval.Success) { Sender.WriteCommentAndNewLine("Log uploaded to " + pageName); } else { Sender.WriteCommentAndNewLine( "LOG UPLOADING FAILED. Please manually upload this section to " + pageName); } } waitForm.Dispose(); FinishedUpload(); } return(retval); }
/// <summary> /// A fully featured upload-event handler /// </summary> protected virtual UploadHandlerReturnVal UploadHandler(TraceListenerUploadableBase sender, string logTitle, string logDetails, string uploadToWithoutPageNumber, List <LogEntry> linksToLog, bool openInBrowser, bool addToWatchlist, string username, string logHeader, string editSummary, string logSummaryEditSummary, Plugin.IAutoWikiBrowser awb, UsernamePassword loginDetails) { UploadHandlerReturnVal retval = new UploadHandlerReturnVal { Success = false }; if (StartingUpload(sender)) { string pageName = uploadToWithoutPageNumber + " " + sender.TraceStatus.PageNumber; UploadingPleaseWaitForm waitForm = new UploadingPleaseWaitForm(); LogUploader uploader = new LogUploader(awb.TheSession.Editor); waitForm.Show(); try { uploader.LogIn(loginDetails); Application.DoEvents(); retval.PageRetVals = uploader.LogIt(sender.TraceStatus.LogUpload, logTitle, logDetails, pageName, linksToLog, sender.TraceStatus.PageNumber, sender.TraceStatus.StartDate, openInBrowser, addToWatchlist, username, "{{log|name=" + uploadToWithoutPageNumber + "|page=" + sender.TraceStatus.PageNumber + "}}" + Environment.NewLine + logHeader, false, editSummary, logSummaryEditSummary, ApplicationName, true, awb); retval.Success = true; } catch (Exception ex) { ErrorHandler.Handle(ex); retval.Success = false; } finally { if (retval.Success) { sender.WriteCommentAndNewLine("Log uploaded to " + pageName); } else { sender.WriteCommentAndNewLine( "LOG UPLOADING FAILED. Please manually upload this section to " + pageName); } } waitForm.Dispose(); FinishedUpload(); } return(retval); }
private void SendAnalysisLink() { if (LogUploader.Instance.previousUrl != null) { LogUploader.PostToChat(LogUploader.Instance.previousUrl); } else { LogUploader.Instance.postOnComplete = true; } }
private void Start() { _gameInfo = GetComponent <KMGameInfo>(); _gameInfo.OnStateChange += OnStateChange; _modSettings = GetComponent <KMModSettings>(); ModSettingsJSON settings = JsonConvert.DeserializeObject <ModSettingsJSON>(_modSettings.Settings); if (settings == null) { DebugHelper.LogError("Failed to read connection settings from mod settings."); return; } DebugMode = (settings.debug == true); _ircConnection = new IRCConnection(settings.authToken, settings.userName, settings.channelName, settings.serverName, settings.serverPort); _ircConnection.Connect(); _coroutineCanceller = new CoroutineCanceller(); _coroutineQueue = GetComponent <CoroutineQueue>(); _coroutineQueue.coroutineCanceller = _coroutineCanceller; logUploader = GetComponent <LogUploader>(); logUploader.ircConnection = _ircConnection; urlHelper = GetComponent <UrlHelper>(); urlHelper.ChangeMode(settings.shortUrls == true); _leaderboard = new Leaderboard(); _leaderboard.LoadDataFromFile(); ModuleData.LoadDataFromFile(); ModuleData.WriteDataToFile(); TwitchPlaySettings.LoadDataFromFile(); UserAccess.AddUser(settings.userName, AccessLevel.Streamer | AccessLevel.SuperUser | AccessLevel.Admin | AccessLevel.Mod); UserAccess.AddUser(settings.channelName.Replace("#", ""), AccessLevel.Streamer | AccessLevel.SuperUser | AccessLevel.Admin | AccessLevel.Mod); UserAccess.WriteAccessList(); SetupResponder(bombMessageResponder); SetupResponder(postGameMessageResponder); SetupResponder(missionMessageResponder); SetupResponder(miscellaneousMessageResponder); bombMessageResponder.leaderboard = _leaderboard; postGameMessageResponder.leaderboard = _leaderboard; miscellaneousMessageResponder.leaderboard = _leaderboard; bombMessageResponder.parentService = this; }
private async Task SaveReplays() { if (!_savedReplay && _game.CurrentGameStats != null) { _savedReplay = true; await LogIsComplete(); var powerLog = new List <string>(); foreach (var stored in _game.StoredPowerLogs.Where(x => x.Item1 == _game.MetaData.ServerInfo.GameHandle)) { powerLog.AddRange(stored.Item2); } powerLog.AddRange(_game.PowerLog); var createGameCount = 0; powerLog = powerLog.TakeWhile(x => !(x.Contains("CREATE_GAME") && createGameCount++ == 1)).ToList(); if (Config.Instance.RecordReplays && RecordCurrentGameMode && _game.Entities.Count > 0 && !_game.SavedReplay && _game.CurrentGameStats.ReplayFile == null) { _game.CurrentGameStats.ReplayFile = ReplayMaker.SaveToDisk(_game.CurrentGameStats, powerLog); } if (Config.Instance.HsReplayAutoUpload && UploadCurrentGameMode) { var log = powerLog.ToArray(); var validationResult = LogValidator.Validate(log); if (validationResult.IsValid) { LogUploader.Upload(log, (GameMetaData)_game.MetaData.Clone(), _game.CurrentGameStats).Forget(); } else { Log.Error("Invalid log: " + validationResult.Reason); Influx.OnEndOfGameUploadError(validationResult.Reason); } } } }
public void Awake() => Instance = this;
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(); }
/// <inheritdoc/> public Task <int> TryFlushAsync <TLog>(Predicate <TLog> predicate, LogUploader <TLog> uploader, CancellationToken token, FlushMode mode) where TLog : LogBase => TryFlushAsync(predicate, (log, _) => uploader(log), token, mode);
/// <inheritdoc/> public Task <int> TryFlushAsync <TLog>(Predicate <TLog> predicate, LogUploader <TLog> uploader, CancellationToken token) where TLog : LogBase => TryFlushAsync(predicate, uploader, token, FlushMode.Serial);
public void Awake() { Instance = this; }