static TrafficLog() { collector = new StatsCollector(); collector.FlushInterval = 60 * 1000; // 1 minute collector.FlushToConsole = false; collector.PctThreshold = new[] { 90 }; collector.DeleteIdleStats = false; collector.DeleteGauges = true; collector.BeforeFlush += () => { collector.InReadLock(() => { collector.SetGauge("haproxy.logs.queue", queue.Count); collector.IncrementMetricsReceived(); }); }; if (DatabaseWriter.FlushToDatabase) { collector.OnFlush += DatabaseWriter.Flush; DatabaseRollup.StartRollupTimer(); } if (ConsolePrinter.FlushToConsole) { collector.OnFlush += ConsolePrinter.Flush; } collector.OnFlushError += (exception) => { Program.Log.Error("Exception OnFlush(): ", exception); }; collector.StartFlushTimer(); }
public BackendUploader(Func <IBackend> backendFactory, Options options, DatabaseCommon database, ITaskReader taskReader, StatsCollector stats) { m_backendFactory = backendFactory; m_options = options; m_taskReader = taskReader; m_stats = stats; m_database = database; m_progressUpdater = new FileProgressThrottler(stats, options.MaxUploadPrSecond); }
public void When_a_method_is_jitted_then_the_CPU_ratio_can_be_measured() { // act (call a method, JIT'ing it) ToJit(); StatsCollector.UpdateMetrics(); // assert Assert.That(() => StatsCollector.CpuRatio.Value, Is.GreaterThanOrEqualTo(0.0).After(100, 10)); }
public void Should_calculate_stats_for_top_25_packages() { var packages = repo.Search(String.Empty, Frameworks, false) .Take(50) .ToList(); var statCollector = new StatsCollector(repo, packages); statCollector.Limit = 25; statCollector.Report(); }
public void Should_calculate_stats_for_NServiceBus_packages() { var packages = repo.Search("NServiceBus", Frameworks, false) .Take(50) .ToList() .Where(p => p.Authors.Contains("NServiceBus Ltd")) .OrderByDescending(p => p.DownloadCount) .ToList(); var statCollector = new StatsCollector(repo, packages); statCollector.Filter = "^NServiceBus"; statCollector.SkipPackages = new[] { "NServiceBus.AcceptanceTesting", "NServiceBus.RavenDB", "NServiceBus.Wire" }; statCollector.Report(); }
public GetScriptStatsResponse GetScriptStats(GetTokenStatisticsRequest request) { try { var syntaxTree = SyntaxTree.ParseText(request.Script); var root = syntaxTree.GetRoot(); var statsCollector = new StatsCollector(); statsCollector.Visit(root); var response = new GetScriptStatsResponse { NumericLiteralStatistics = statsCollector.GetNumericLiteralStats(), StringLiteralStatistics = statsCollector.GetStringLiteralStats(), IdentifierStatistics = statsCollector.GetInIdentifierStats(), InvalidTokens = statsCollector.GetInvalidTokens().ToList(), }; response.IsValid = response.InvalidTokens.Count == 0; return response; } catch { throw; } }
public override void Install(ModuleManager manager) { Random rng = new Random(); manager.CreateCommands("", cgb => { var client = manager.Client; cgb.CreateCommand("\\o\\") .Description("Nadeko replies with /o/") .Do(async e => { await e.Send(e.User.Mention + "/o/"); }); cgb.CreateCommand("/o/") .Description("Nadeko replies with \\o\\") .Do(async e => { await e.Send(e.User.Mention + "\\o\\"); }); }); manager.CreateCommands(NadekoBot.botMention, cgb => { var client = manager.Client; commands.ForEach(cmd => cmd.Init(cgb)); CreateCommand(cgb, "do you love me") .Description("Replies with positive answer only to the bot owner.") .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { await e.Send(e.User.Mention + ", Of course I do, my Master."); } else { await e.Send(e.User.Mention + ", Don't be silly."); } }); CreateCommand(cgb, "die") .Description("Works only for the owner. Shuts the bot down.") .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { Timer t = new Timer(); t.Interval = 2000; t.Elapsed += (s, ev) => { Environment.Exit(0); }; t.Start(); await e.Send(e.User.Mention + ", Yes, my love."); } else { await e.Send(e.User.Mention + ", No."); } }); CreateCommand(cgb, "how are you") .Description("Replies positive only if bot owner is online.") .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { await e.Send(e.User.Mention + " I am great as long as you are here."); } else { var kw = e.Server.GetUser(NadekoBot.OwnerID); if (kw != null && kw.Status == UserStatus.Online) { await e.Send(e.User.Mention + " I am great as long as " + kw.Mention + " is with me."); } else { await e.Send(e.User.Mention + " I am sad. My Master is not with me."); } } }); CreateCommand(cgb, "insult") .Parameter("mention", ParameterType.Required) .Description("Only works for owner. Insults @X person.\n**Usage**: @NadekoBot insult @X.") .Do(async e => { List <string> insults = new List <string> { " you are a poop.", " you jerk.", " i will eat you when i get my powers back." }; Random r = new Random(); var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); if (u == null) { await e.Send("Invalid user specified."); return; } if (u.Id == NadekoBot.OwnerID) { await e.Send("I would never insult my master <3"); } else if (e.User.Id == NadekoBot.OwnerID) { await e.Send(u.Mention + insults[r.Next(0, insults.Count)]); } else { await e.Send(e.User.Mention + " Eww, why would i do that for you ?!"); } }); CreateCommand(cgb, "praise") .Description("Only works for owner. Praises @X person.\n**Usage**: @NadekoBot praise @X.") .Parameter("mention", ParameterType.Required) .Do(async e => { List <string> praises = new List <string> { " You are cool.", " You are nice... But don't get any wrong ideas.", " You did a good job." }; Random r = new Random(); var u = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); if (u == null) { await e.Send("Invalid user specified."); return; } if (e.User.Id == NadekoBot.OwnerID) { if (u.Id != NadekoBot.OwnerID) { await e.Send(u.Mention + praises[r.Next(0, praises.Count)]); } else { await e.Send(u.Mention + " No need, you know I love you <3"); } } else { if (u.Id == NadekoBot.OwnerID) { await e.Send(e.User.Mention + " I don't need your permission to praise my beloved Master <3"); } else { await e.Send(e.User.Mention + " Yeah... No."); } } }); CreateCommand(cgb, "are you real") .Description("Useless.") .Do(async e => { await e.Send(e.User.Mention + " I will be soon."); }); cgb.CreateCommand("are you there") .Description("Checks if nadeko is operational.") .Alias(new string[] { "!", "?" }) .Do(SayYes()); CreateCommand(cgb, "draw") .Description("Nadeko instructs you to type $draw. Gambling functions start with $") .Do(async e => { await e.Send("Sorry i don't gamble, type $draw for that function."); }); CreateCommand(cgb, "uptime") .Description("Shows how long is Nadeko running for.") .Do(async e => { var time = (DateTime.Now - Process.GetCurrentProcess().StartTime); string str = "I am online for " + time.Days + " days, " + time.Hours + " hours, and " + time.Minutes + " minutes."; await e.Send(str); }); CreateCommand(cgb, "fire") .Description("Shows a unicode fire message. Optional parameter [x] tells her how many times to repeat the fire.\n**Usage**: @NadekoBot fire [x]") .Parameter("times", ParameterType.Optional) .Do(async e => { int count = 0; if (e.Args?.Length > 0) { int.TryParse(e.Args[0], out count); } if (count < 1) { count = 1; } else if (count > 12) { count = 12; } string str = ""; for (int i = 0; i < count; i++) { str += firestr; } await e.Send(str); }); CreateCommand(cgb, "rip") .Description("Shows a grave image.Optional parameter [@X] instructs her to put X's name on the grave.\n**Usage**: @NadekoBot rip [@X]") .Parameter("user", ParameterType.Unparsed) .Do(async e => { var usr = e.Channel.FindUsers(e.GetArg("user")).FirstOrDefault(); string text = ""; if (usr == null) { text = e.GetArg("user"); } else { text = usr.Name; } await e.Channel.SendFile("ripzor_m8.png", RipName(text)); }); cgb.CreateCommand("j") .Description("Joins a server using a code. Obsolete, since nadeko will autojoin any valid code in chat.") .Parameter("id", ParameterType.Required) .Do(async e => { try { await(await client.GetInvite(e.Args[0])).Accept(); await e.Send("I got in!"); } catch (Exception) { await e.Send("Invalid code."); } }); cgb.CreateCommand("i") .Description("Pulls a first image using a search parameter.\n**Usage**: @NadekoBot img Multiword_search_parameter") .Alias("img") .Parameter("all", ParameterType.Unparsed) .Do(async e => { await e.Send("This feature is being reconstructed."); /* * var httpClient = new System.Net.Http.HttpClient(); * string str = e.Args[0]; * * var r = httpClient.GetAsync("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + Uri.EscapeDataString(str) + "&start=0").Result; * * dynamic obj = JObject.Parse(r.Content.ReadAsStringAsync().Result); * if (obj.responseData.results.Count == 0) * { * await e.Send("No results found for that keyword :\\"); * return; * } * string s = Searches.ShortenUrl(obj.responseData.results[0].url.ToString()); * await e.Send(s); */ }); cgb.CreateCommand("ir") .Description("Pulls a random image using a search parameter.\n**Usage**: @NadekoBot img Multiword_search_parameter") .Alias("imgrandom") .Parameter("all", ParameterType.Unparsed) .Do(async e => { await e.Send("This feature is being reconstructed."); /* * var httpClient = new System.Net.Http.HttpClient(); * string str = e.Args[0]; * var r = httpClient.GetAsync("http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=" + Uri.EscapeDataString(str) + "&start=" + rng.Next(0, 30)).Result; * JObject obj = JObject.Parse(r.Content.ReadAsStringAsync().Result); * try * { * Console.WriteLine(obj.ToString()); * if (obj["responseData"]["results"].Count() == 0) * { * await e.Send("No results found for that keyword :\\"); * return; * } * int rnd = rng.Next(0, obj["responseData"]["results"].Count()); * string s = Searches.ShortenUrl(obj["responseData"]["results"][rnd]["url"].ToString()); * await e.Send(s); * } * catch (Exception ex) { * Console.WriteLine(ex.ToString()); * } */ }); AliasCommand(CreateCommand(cgb, "save"), "s") .Description("Saves something for the owner in a file.") .Parameter("all", ParameterType.Unparsed) .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { string m = ""; try { FileStream f = File.OpenWrite("saves.txt"); m = e.Args[0]; byte[] b = Encoding.ASCII.GetBytes(m + "\n"); f.Seek(f.Length, SeekOrigin.Begin); f.Write(b, 0, b.Length); f.Close(); } catch (Exception) { await e.Send("Error saving. Sorry :("); } if (m.Length > 0) { await e.Send("I saved this for you: " + Environment.NewLine + "```" + m + "```"); } else { await e.Send("No point in saving empty message..."); } } else { await e.Send("Not for you, only my Master <3"); } }); CreateCommand(cgb, "ls") .Description("Shows all saved items.") .Do(async e => { FileStream f = File.OpenRead("saves.txt"); if (f.Length == 0) { await e.Send("Saves are empty."); return; } byte[] b = new byte[f.Length / sizeof(byte)]; f.Read(b, 0, b.Length); f.Close(); string str = Encoding.ASCII.GetString(b); await e.User.Send("```" + (str.Length < 1950 ? str : str.Substring(0, 1950)) + "```"); }); cgb.CreateCommand("slm") .Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)") .Do(async e => { Message msg; var msgs = e.Channel.Messages .Where(m => m.MentionedUsers.Contains(e.User)) .OrderBy(m => m.Timestamp); if (msgs.Count() > 0) { msg = msgs.FirstOrDefault(); } else { var msgsarr = await e.Channel.DownloadMessages(10000); msg = msgsarr .Where(m => m.MentionedUsers.Contains(e.User)) .OrderBy(m => m.Timestamp) .FirstOrDefault(); } if (msg != null) { await e.Send("Last message mentioning you was at " + msg.Timestamp + "\n**Message:** " + msg.RawText); } else { await e.Send("I can't find a message mentioning you."); } }); CreateCommand(cgb, "cs") .Description("Deletes all saves") .Do(async e => { File.Delete("saves.txt"); await e.Send("Cleared all saves."); }); CreateCommand(cgb, "bb") .Description("Says bye to someone. **Usage**: @NadekoBot bb @X") .Parameter("ppl", ParameterType.Unparsed) .Do(async e => { string str = "Bye"; foreach (var u in e.Message.MentionedUsers) { str += " " + u.Mention; } await e.Send(str); }); AliasCommand(CreateCommand(cgb, "req"), "request") .Description("Requests a feature for nadeko.\n**Usage**: @NadekoBot req new_feature") .Parameter("all", ParameterType.Unparsed) .Do(async e => { string str = e.Args[0]; try { StatsCollector.SaveRequest(e, str); } catch (Exception) { await e.Send("Something went wrong."); return; } await e.Send("Thank you for your request."); }); CreateCommand(cgb, "lr") .Description("PMs the user all current nadeko requests.") .Do(async e => { string str = StatsCollector.GetRequests(); if (str.Trim().Length > 110) { await e.User.Send(str); } else { await e.User.Send("No requests atm."); } }); CreateCommand(cgb, "dr") .Description("Deletes a request. Only owner is able to do this.") .Parameter("reqNumber", ParameterType.Required) .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { try { if (StatsCollector.DeleteRequest(int.Parse(e.Args[0]))) { await e.Send(e.User.Mention + " Request deleted."); } else { await e.Send("No request on that number."); } } catch { await e.Send("Error deleting request, probably NaN error."); } } else { await e.Send("You don't have permission to do that."); } }); CreateCommand(cgb, "rr") .Description("Resolves a request. Only owner is able to do this.") .Parameter("reqNumber", ParameterType.Required) .Do(async e => { if (e.User.Id == NadekoBot.OwnerID) { try { var sc = StatsCollector.ResolveRequest(int.Parse(e.Args[0])); if (sc != null) { await e.Send(e.User.Mention + " Request resolved, notice sent."); await client.GetServer(sc.ServerId).GetUser(sc.Id).Send("**This request of yours has been resolved:**\n" + sc.Text); } else { await e.Send("No request on that number."); } } catch { await e.Send("Error resolving request, probably NaN error."); } } else { await e.Send("You don't have permission to do that."); } }); CreateCommand(cgb, "clr") .Description("Clears some of nadeko's messages from the current channel.") .Do(async e => { try { if (e.Channel.Messages.Count() < 50) { await e.Channel.DownloadMessages(100); } e.Channel.Messages.Where(msg => msg.User.Id == client.CurrentUser.Id).ForEach(async m => await m.Delete()); } catch (Exception) { await e.Send("I cant do it :("); } }); CreateCommand(cgb, "call") .Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ") .Parameter("who", ParameterType.Required) .Do(async e => { await e.Send("Calling " + e.Args[0] + "..."); }); CreateCommand(cgb, "hide") .Description("Hides nadeko in plain sight!11!!") .Do(async e => { try { using (MemoryStream ms = new MemoryStream()) using (Image img = Image.FromFile("images/hidden.png")) { img.Save(ms, ImageFormat.Png); await client.CurrentUser.Edit(NadekoBot.password, null, null, null, ms, ImageType.Png); } await e.Send("*hides*"); } catch (Exception ex) { StatsCollector.DEBUG_LOG(ex.ToString()); } }); CreateCommand(cgb, "unhide") .Description("Unhides nadeko in plain sight!1!!1") .Do(async e => { try { using (MemoryStream ms = new MemoryStream()) using (Image img = Image.FromFile("images/nadeko.jpg")) { img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); await client.CurrentUser.Edit(NadekoBot.password, null, null, null, ms, ImageType.Jpeg); } await e.Send("*unhides*"); } catch (Exception ex) { StatsCollector.DEBUG_LOG(ex.ToString()); } }); cgb.CreateCommand("dump") .Description("Dumps all of the invites it can to dump.txt") .Do(async e => { int i = 0; int j = 0; string invites = ""; foreach (var s in client.Servers) { try { var invite = await s.CreateInvite(0); invites += invite.Url + "\n"; i++; } catch (Exception) { j++; continue; } } File.WriteAllText("dump.txt", invites); await e.Send($"Got invites for {i} servers and failed to get invites for {j} servers"); }); Stopwatch randServerSW = new Stopwatch(); randServerSW.Start(); cgb.CreateCommand("randserver") .Description("Generates an invite to a random server and prints some stats.") .Do(async e => { if (randServerSW.ElapsedMilliseconds / 1000 < 1800) { await e.Send("You have to wait " + (1800 - randServerSW.ElapsedMilliseconds / 1000) + " more seconds to use this function."); return; } randServerSW.Reset(); while (true) { var server = client.Servers.OrderBy(x => rng.Next()).FirstOrDefault(); if (server == null) { continue; } try { var inv = await server.CreateInvite(100, 5); await e.Send("**Server:** " + server.Name + "\n**Owner:** " + server.Owner.Name + "\n**Channels:** " + server.AllChannels.Count() + "\n**Total Members:** " + server.Users.Count() + "\n**Online Members:** " + server.Users.Where(u => u.Status == UserStatus.Online).Count() + "\n**Invite:** " + inv.Url); break; } catch (Exception) { continue; } } }); cgb.CreateCommand("av").Alias("avatar") .Parameter("mention", ParameterType.Required) .Description("Shows a mentioned person's avatar. **Usage**: ~av @X") .Do(async e => { var usr = e.Channel.FindUsers(e.GetArg("mention")).FirstOrDefault(); if (usr == null) { await e.Send("Invalid user specified."); return; } string av = usr.AvatarUrl; await e.Send(Searches.ShortenUrl(av)); }); //TODO add eval /* * cgb.CreateCommand(">") * .Parameter("code", ParameterType.Unparsed) * .Do(async e => * { * if (e.Message.User.Id == NadekoBot.OwnerId) * { * var result = await CSharpScript.EvaluateAsync(e.Args[0]); * await e.Send( result?.ToString() ?? "null"); * return; * } * });*/ }); }
public static Task Run(Common.BackendHandler backend, Options options, Common.DatabaseCommon database, BackupResults results, Common.ITaskReader taskreader, StatsCollector stats) { return(AutomationExtensions.RunTask(new { Input = Channels.BackendRequest.ForRead, }, async self => { var inProgress = new Queue <KeyValuePair <int, Task> >(); var max_pending = options.AsynchronousUploadLimit == 0 ? long.MaxValue : options.AsynchronousUploadLimit; var noIndexFiles = options.IndexfilePolicy == Options.IndexFileStrategy.None; var active = 0; var lastSize = -1L; while (!await self.Input.IsRetiredAsync && await taskreader.ProgressAsync) { try { var req = await self.Input.ReadAsync(); if (!await taskreader.ProgressAsync) { continue; } var task = default(KeyValuePair <int, Task>); if (req is VolumeUploadRequest) { lastSize = ((VolumeUploadRequest)req).BlockVolume.SourceSize; if (noIndexFiles || ((VolumeUploadRequest)req).IndexVolume == null) { task = new KeyValuePair <int, Task>(1, backend.UploadFileAsync(((VolumeUploadRequest)req).BlockVolume, null)); } else { task = new KeyValuePair <int, Task>(2, backend.UploadFileAsync(((VolumeUploadRequest)req).BlockVolume, name => ((VolumeUploadRequest)req).IndexVolume.CreateVolume(name, options, database))); } } else if (req is FilesetUploadRequest) { task = new KeyValuePair <int, Task>(1, backend.UploadFileAsync(((FilesetUploadRequest)req).Fileset)); } else if (req is IndexVolumeUploadRequest) { task = new KeyValuePair <int, Task>(1, backend.UploadFileAsync(((IndexVolumeUploadRequest)req).IndexVolume)); } else if (req is FlushRequest) { try { while (inProgress.Count > 0) { await inProgress.Dequeue().Value; } active = 0; } finally { ((FlushRequest)req).SetFlushed(lastSize); } } if (task.Value != null) { inProgress.Enqueue(task); active += task.Key; } } catch (Exception ex) { if (!ex.IsRetiredException()) { throw; } } while (active >= max_pending) { var top = inProgress.Dequeue(); // See if we are done if (await Task.WhenAny(top.Value, Task.Delay(500)) != top.Value) { try { stats.SetBlocking(true); await top.Value; } finally { stats.SetBlocking(false); } } active -= top.Key; } } results.OperationProgressUpdater.UpdatePhase(OperationPhase.Backup_WaitForUpload); try { stats.SetBlocking(true); while (inProgress.Count > 0) { await inProgress.Dequeue().Value; } } finally { stats.SetBlocking(false); } })); }
private void ParseInfolog(string text, bool isCrash) { if (string.IsNullOrEmpty(text)) { Trace.TraceWarning("Infolog is empty"); return; } try { var hasError = false; var modName = battleResult.Mod; var mapName = battleResult.Map; var isCheating = false; int? score = null; int scoreFrame = 0; string gameId = null; string demoFileName = null; string missionVars = ""; foreach (var cycleline in text.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { var line = cycleline; var gameframe = 0; if (line.StartsWith("[DedicatedServer]")) { line = line.Replace("[DedicatedServer] ", ""); } if (line.StartsWith("[")) { var idx = line.IndexOf("] "); if (idx > 0) { int.TryParse(line.Substring(1, idx - 1), out gameframe); if (idx >= 0) { line = line.Substring(idx + 2); } } } // FIXME: why are these even null in the first place? if (mapName == null && line.StartsWith("Using map")) { mapName = line.Substring(10).Trim(); } if (modName == null && line.StartsWith("Using game")) { modName = line.Substring(11).Trim(); } if (line.StartsWith("recording demo")) { demoFileName = Path.GetFileName(line.Substring(15).Trim()); // 91.0 } else if (line.StartsWith("[DedicatedServer] recording demo")) { demoFileName = Path.GetFileName(line.Substring(33).Trim()); // 95.0 and later } if (line.StartsWith("Using demofile")) { return; // do nothing if its demo } if (line.StartsWith("GameID: ") && gameId == null) { gameId = line.Substring(8).Trim(); } if (line.StartsWith("STATS:")) { statsData.Add(line.Substring(6)); } if (line.Contains("SCORE: ") && !isCheating && battleResult.IsMission) { var match = Regex.Match(line, "SCORE: ([^ ]+)"); if (match.Success) { // game score var data = match.Groups[1].Value; //Trace.TraceInformation("Score data (raw) : " + data); data = Encoding.ASCII.GetString(Convert.FromBase64String(match.Groups[1].Value)); //Trace.TraceInformation("Score data (decoded) : " + data); var parts = data.Split('/'); score = 0; if (parts.Length > 1) { score = Convert.ToInt32(parts[1]); gameframe = Convert.ToInt32(parts[0]); } else { score = Convert.ToInt32(data); } scoreFrame = gameframe; } } if (line.Contains("MISSIONVARS:") && battleResult.IsMission) { var match = Regex.Match(line, "MISSIONVARS: ([^ ]+)"); missionVars = match.Groups[1].Value.Trim(); Trace.TraceInformation(string.Format("Mission variables: {0} (original line: {1})", missionVars, line)); } // obsolete, hanlded by pm messages //if (line.StartsWith("STATS:")) statsData.Add(line.Substring(6)); if (line.StartsWith("Cheating!") || line.StartsWith("Cheating is enabled!")) { isCheating = true; } if (line.StartsWith("Error") || line.StartsWith("LuaRules") || line.StartsWith("Internal error") || line.StartsWith("LuaCOB") || (line.StartsWith("Failed to load") && !line.Contains("duplicate name"))) { hasError = true; } } if (score != null || !String.IsNullOrEmpty(missionVars)) { Trace.TraceInformation("Submitting score for mission " + modName); try { using (var service = new ContentService { Proxy = null }) { service.SubmitMissionScoreCompleted += (s, e) => { if (e.Error != null) { if (e.Error is WebException) { Trace.TraceWarning("Error sending score: {0}", e.Error); } else { Trace.TraceError("Error sending score: {0}", e.Error); } } }; service.SubmitMissionScoreAsync(lobbyUserName, Utils.HashLobbyPassword(lobbyPassword), modName, score ?? 0, scoreFrame / 30, missionVars); } } catch (Exception ex) { Trace.TraceError(string.Format("Error sending mission score: {0}", ex)); } } var modOk = GlobalConst.IsZkMod(modName); // submit main stats if (!isCheating && !isCrash && modOk && gameEndedOk) { if (isHosting) { var service = new SpringieService() { Proxy = null }; var mis = new ContentService() { Proxy = null }; try { battleResult.EngineBattleID = gameId; battleResult.ReplayName = demoFileName; // set victory team for all allied with currently alive foreach (var p in statsPlayers.Values.Where(x => !x.IsSpectator && x.LoseTime == null)) { foreach (var q in statsPlayers.Values.Where(x => !x.IsSpectator && x.AllyNumber == p.AllyNumber)) { q.IsVictoryTeam = true; } } if (StartContext != null) { var result = service.SubmitSpringBattleResult(StartContext, lobbyPassword, battleResult, Enumerable.ToArray(statsPlayers.Values), statsData.ToArray()); if (result != null) { foreach (var line in result.Split('\n')) { client.Say(TasClient.SayPlace.Battle, "", line, true); } } } } catch (Exception ex) { Trace.TraceError("Error sending game result: {0}", ex); } } if (statsData.Count > 1) { // must be more than 1 line - 1 is player list var statsService = new StatsCollector { Proxy = null }; try { statsService.SubmitGameEx(gameId, modName, mapName, statsData.ToArray()); } catch (Exception ex) { Trace.TraceError("Error sending game stats: {0}", ex); } } } } catch (Exception ex) { Trace.TraceError("Error processing spring log: {0}", ex); } }
public SimpleStringHandler(StatsCollector statsCollector) => _statsCollector = statsCollector;
public FileProgressThrottler(StatsCollector stats, long maxBytesPerSecond) { m_Stats = stats; m_MaxBytesPerSecond = maxBytesPerSecond; }
private Program(string pathToRulesInExcelFormat) { _statsCollector = new StatsCollector(); _ruleTester = new RuleTester(pathToRulesInExcelFormat, _statsCollector); }
public RuleTester(string pathToRulesInExcelFormat, StatsCollector statsCollector) { _pathToRulesInExcelFormat = pathToRulesInExcelFormat; _statsCollector = statsCollector; UpdateRules(); }