/// <summary> /// Gets the potential cows. /// </summary> /// <param name="filter">The filter.</param> /// <param name="avgLimit">The avg limit.</param> /// <returns></returns> public List <Cow> GetPotentialCows(LevelFilter filter, decimal avgLimit) { var command = connection.CreateCommand(commandTextCowsPotentialSelect); command.AddParameter(filter); return(ReadObjects <Cow>(command, CreateCow).Where(e => e.AverageBenefit > avgLimit).ToList()); }
public void should_print_if_higher_2() { string formatted; var res = LevelFilter.ShouldPrint(sample, LogLevel.Trace, out formatted); Assert.That(res, Is.True); }
public MainViewModel(IDataService dataService) { InitializeCommands(); MainWindowTitle = "EventLook" + (ProcessHelper.IsElevated ? " (Administrator)" : ""); DataService = dataService; Events = new ObservableCollection <EventItem>(); logSourceMgr = new LogSourceMgr(); SelectedLogSource = LogSources.FirstOrDefault(); rangeMgr = new RangeMgr(); SelectedRange = Ranges.FirstOrDefault(r => r.DaysFromNow == 3); sourceFilter = new Model.SourceFilter(); levelFilter = new LevelFilter(); MsgFilter = new MessageFilter(); IdFilter = new IdFilter(); filters = new List <FilterBase> { sourceFilter, levelFilter, MsgFilter, IdFilter }; progress = new Progress <ProgressInfo>(ProgressCallback); // Needs to instantiate in UI thread stopwatch = new Stopwatch(); Messenger.Default.Register <ViewCollectionViewSourceMessageToken>(this, Handle_ViewCollectionViewSourceMessageToken); Messenger.Default.Register <FileToBeProcessedMessageToken>(this, Handle_FileToBeProcessedMessageToken); Messenger.Default.Register <DetailWindowMessageToken>(this, Handle_DetailWindowMessageToken); }
public SelectLogLevelControl(LevelFilter levelFilter) { this.levelFilter = levelFilter; levelFilter.OnChanged += LevelFilter_OnChanged; InitializeComponent(); }
private void AddPotentioal(LevelFilter filter) { try { var poterial = ObjectProvider.Instance.GetPotentialCows(filter, AppCore.AttackSettings.MinBenefit). Where(e => e.AverageBenefit > AppCore.AttackSettings.MinBenefit).ToArray(); var cowsIds = (from p in Cows select p.UserID).ToList(); var toUpdate = (from p in poterial where cowsIds.Contains(p.UserID) select p).ToArray(); foreach (var cowU in toUpdate) { var updated = (from c in Cows where c.UserID == cowU.UserID select c).FirstOrDefault(); if (updated != null) { updated.AverageBenefit = (updated.AverageBenefit + cowU.AverageBenefit) / 2; } } var toAdd = (from p in poterial where !cowsIds.Contains(p.UserID) select p).ToArray(); Cows.AddRange(toAdd); } catch (Exception ex) { AppCore.LogSystem.Warn("Проблемы в инициалиции фермы", ex); } }
public void With_composite_AND_filter_no_result() { PluginBase plugin = new Plugin(); ((Plugin)plugin).AddMinutes(100); ((Plugin)plugin).SetCategory(Guid.NewGuid().ToString()); ((Plugin)plugin).SetLevel(Guid.NewGuid().ToString()); IFilterExpression filter1 = new TimeFilter() { Operator = "<=", Operand = "15" }; IFilterExpression filter2 = new CategoryFilter() { Operator = "in", Operand = "group" }; IFilterExpression filter3 = new LevelFilter() { Operator = "in", Operand = "debug" }; IFilterComposite filter = new AndFilterComposite(); filter.Add(filter1, filter2, filter3); var days = plugin.GetDays(); foreach (var day in days) { var logs = plugin.GetLogs(day); logs = filter.Filter(logs); Assert.True(logs.Count() == 0); } }
/// <summary> /// Gets the cristal owners. /// </summary> /// <param name="filter">The filter.</param> /// <returns></returns> public List <string> GetCristalOwners(LevelFilter filter) { var command = connection.CreateCommand(commandTextCristalOwners); command.AddParameter(filter); return(ReadString(command)); }
/// <summary> /// Gets the fights. /// </summary> /// <param name="filter">The filter.</param> /// <returns></returns> public List <Cow> GetCows(LevelFilter filter) { var command = connection.CreateCommand(commandTextCowsSelect); command.AddParameter(filter); return(ReadObjects <Cow>(command, CreateCow)); }
public StructuredLogViewModel() { DateFilter = new DateFilter(); DateFilter.OnChanged += DateFilter_OnChanged; LevelFilter = new LevelFilter(); LevelFilter.OnChanged += LevelFilter_OnChanged; }
public void should_not_print_if_lower() { string formatted; Assert.That( LevelFilter.ShouldPrint(sample, LogLevel.Warn, out formatted), Is.False); }
public void TestInRangeLowerLimit() { var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning); var actual = filter.CanLog(new LogEntry { LogLevel = LogLevel.Info }); Assert.True(actual); }
public void TestMoreThanUpperLimit() { var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning); var actual = filter.CanLog(new LogEntry { LogLevel = LogLevel.Error }); Assert.False(actual); }
public void TestLessThanLowerLimit() { var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning); var actual = filter.CanLog(new LogEntry { LogLevel = LogLevel.Debug }); Assert.False(actual); }
/// <summary> /// Gets the guild users. /// </summary> /// <param name="guild">The guild.</param> /// <param name="filter">The filter.</param> /// <returns></returns> public List <string> GetGuildUsers(GuildType guild, LevelFilter filter) { var command = connection.CreateCommand(@"SELECT Users.Name FROM Users WHERE ((Users.Level) Between @LevelFrom AND @LevelTo) And Guild=@Guild"); command.AddParameter(filter); command.AddParameter("Guild", (byte)guild); return(ReadString(command)); }
public void With_composite_OR_Can_filter() { PluginBase plugin = new Plugin(); var now = DateTime.Now; ((Plugin)plugin) .Clear() .Add(new LogRow() { Level = Guid.NewGuid().ToString(), Logger = Guid.NewGuid().ToString(), Time = now.AddMinutes(10) }, new LogRow() { Level = Guid.NewGuid().ToString(), Logger = "group", Time = now.AddMinutes(100) }, new LogRow() { Level = "debug", Logger = Guid.NewGuid().ToString(), Time = now.AddMinutes(100) }).Commit(); IFilterExpression filter1 = new TimeFilter() { Operator = ">=", Operand = "9" }; IFilterExpression filter2 = new CategoryFilter() { Operator = "in", Operand = "group" }; IFilterExpression filter3 = new LevelFilter() { Operator = "in", Operand = "debug" }; IFilterComposite filter = new OrFilterComposite(); filter.Add(filter1, filter2, filter3); var days = plugin.GetDays(); Assert.Single(days); var logs = plugin.GetLogs(days.ElementAt(0)); logs = filter.Filter(logs); Assert.Equal(3, logs.Count()); }
/// <summary> /// Checks, whether a given entry matches the filter defined in this subscription /// </summary> /// <param name="Entry">The entry to validate</param> /// <returns>Whether the subscription should react to this entry</returns> public bool Applies(LogEntry Entry) { if (MessageFilterSet && !UtilityHost.IsLike(Entry.Message, MessageFilter)) { return(false); } if (ModuleNameFilterSet && !UtilityHost.IsLike(Entry.ModuleName, ModuleNameFilter)) { return(false); } if (FunctionNameFilterSet && !UtilityHost.IsLike(Entry.FunctionName, FunctionNameFilter)) { return(false); } if (TargetFilterSet && (Entry.TargetObject != TargetFilter)) { return(false); } if (LevelFilterSet && !LevelFilter.Contains(Entry.Level)) { return(false); } if (TagFilterSet) { bool test = false; foreach (string tag in TagFilter) { foreach (string tag2 in Entry.Tags) { if (tag == tag2) { test = true; } } } if (!test) { return(false); } } if (RunspaceFilterSet && RunspaceFilter != Entry.Runspace) { return(false); } return(true); }
public void TestGetOriginalIndicesFrom3() { var filter = new LevelFilter(LevelFlags.Info); using (var file = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, _logFile.Object, filter, null)) { _entries.Add(new LogLine(0, 0, "This is a test", LevelFlags.Debug)); _entries.Add(new LogLine(1, 1, "This is a test", LevelFlags.Info)); _entries.Add(new LogLine(2, 2, "This is a test", LevelFlags.Error)); _entries.Add(new LogLine(3, 3, "This is a test", LevelFlags.Info)); file.OnLogFileModified(_logFile.Object, new LogFileSection(0, 4)); _taskScheduler.RunOnce(); var originalIndices = file.GetColumn(new LogFileSection(0, 2), LogFileColumns.OriginalIndex); originalIndices.Should().Equal(new LogLineIndex(1), new LogLineIndex(3)); } }
public void On_level_inclusive_no_result() { PluginBase plugin = new Plugin(); IFilterExpression filter = new LevelFilter() { Operator = "in", Operand = Guid.NewGuid().ToString() }; ((Plugin)plugin).SetLevel("category"); var days = plugin.GetDays(); foreach (var day in days) { var logs = plugin.GetLogs(day); logs = filter.Filter(logs); Assert.True(logs.Count() == 0); } }
public void On_level_exclusive_no_result_case_insensitive() { PluginBase plugin = new Plugin(); IFilterExpression filter = new LevelFilter() { Operator = "not in", Operand = "level" }; ((Plugin)plugin).SetLevel("lEvEl"); var days = plugin.GetDays(); foreach (var day in days) { var logs = plugin.GetLogs(day); logs = filter.Filter(logs); Assert.True(logs.Count() == 0); } }
public void TestGetTimestamp2() { var filter = new LevelFilter(LevelFlags.Error); var source = new InMemoryLogFile(); using (var logFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null)) { var timestamp1 = new DateTime(2017, 12, 11, 20, 46, 0); source.AddEntry("", LevelFlags.Warning, timestamp1); var timestamp2 = new DateTime(2017, 12, 11, 20, 50, 0); source.AddEntry("", LevelFlags.Error, timestamp2); _taskScheduler.RunOnce(); var timestamps = logFile.GetColumn(new LogFileSection(0, 1), LogFileColumns.Timestamp); timestamps.Should().NotBeNull(); timestamps.Should().Equal(new object[] { timestamp2 }, "because the first entry doesn't match the filter and thus the timestamp of the 2nd one should've been returned"); } }
public void TestGetLogLineIndexOfOriginalLineIndex1() { var filter = new LevelFilter(LevelFlags.Info); using (var file = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, _logFile.Object, filter, null)) { _entries.Add(new LogLine(0, 0, "This is a test", LevelFlags.Debug)); _entries.Add(new LogLine(1, 1, "This is a test", LevelFlags.Info)); _entries.Add(new LogLine(2, 2, "This is a test", LevelFlags.Error)); _entries.Add(new LogLine(3, 3, "This is a test", LevelFlags.Info)); file.OnLogFileModified(_logFile.Object, new LogFileSection(0, 4)); _taskScheduler.RunOnce(); file.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(0)).Should().Be(LogLineIndex.Invalid); file.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(1)).Should().Be(new LogLineIndex(0)); file.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(2)).Should().Be(LogLineIndex.Invalid); file.GetLogLineIndexOfOriginalLineIndex(new LogLineIndex(3)).Should().Be(new LogLineIndex(1)); } }
public void TestGetDeltaTime3() { var filter = new LevelFilter(LevelFlags.Info); var source = new InMemoryLogFile(); using (var logFile = new FilteredLogFile(_taskScheduler, TimeSpan.Zero, source, filter, null)) { source.AddEntry("", LevelFlags.Info, new DateTime(2017, 12, 11, 19, 34, 0)); source.AddEntry("", LevelFlags.Debug, new DateTime(2017, 12, 11, 19, 35, 0)); source.AddEntry("", LevelFlags.Info, new DateTime(2017, 12, 11, 19, 36, 0)); _taskScheduler.RunOnce(); var deltas = logFile.GetColumn(new LogFileSection(0, 2), LogFileColumns.DeltaTime); deltas.Should().NotBeNull(); deltas.Should().HaveCount(2); deltas[0].Should().BeNull(); deltas[1].Should().Be(TimeSpan.FromMinutes(2), "because the delta time should be calculated based on events which match the filter"); } }
public LogPage() { InitializeComponent(); Loaded += LogPageLoaded; LevelFilter.ItemsSource = Enum.GetValues(typeof(common.LogLevel)).Cast <common.LogLevel>().ToList(); SelfUpdate = true; LevelFilter.SelectAll(); foreach (int lv in LevelFilter.SelectedItems.Cast <byte>()) { FilterLevels.Set(lv, true); } SelfUpdate = false; SourceFilter.ItemsSource = FilterFrom; common.Logger.OnLog += OnNewLog; logListView.ItemsSource = LogItems; LogsView = (CollectionView)CollectionViewSource.GetDefaultView(logListView.ItemsSource); LogsView.Filter = LogFilter; }
/// <summary> /// Adds the parameter. /// </summary> /// <param name="command">The command.</param> /// <param name="filter">The filter.</param> public static void AddParameter(this DbCommand command, LevelFilter filter) { command.AddParameter("@LevelFrom", filter.LevelFrom); command.AddParameter("@LevelTo", filter.LevelTo); }
public void Initialize(IManager manager, string ipcIdentifier) { IPCIdentifier = ipcIdentifier; if (Instance != null) { Console.WriteLine("Attempt to create a second Entry"); throw new Exception("There should only be one Entry"); } Instance = this; GeneralUtilities.logExceptions(() => { var levelFilters = new LevelFilter[] { new LevelFilterAll(), new LevelFilterAuthor(), new LevelFilterCreated(), new LevelFilterDifficulty(), new LevelFilterIndex(), new LevelFilterIsNew(), new LevelFilterIsUpdated(), new LevelFilterLast(), new LevelFilterMode(), new LevelFilterName(), new LevelFilterPage(), new LevelFilterPlaylist(), new LevelFilterRegex(), new LevelFilterSaved(), new LevelFilterStars(), new LevelFilterTime(), new LevelFilterUpdated(), new LevelSortFilterAuthor(), new LevelSortFilterCreated(), new LevelSortFilterDifficulty(), new LevelSortFilterIndex(), new LevelSortFilterMode(), new LevelSortFilterName(), new LevelSortFilterShuffle(), new LevelSortFilterStars(), new LevelSortFilterTime(), new LevelSortFilterUpdated() }; foreach (var filter in levelFilters) { FilteredPlaylist.AddFilterType(filter); } }); load(); // load existing data save(); // save defaults that were not loaded // player data list stuff Events.Player.AddRemovePlayerData.Subscribe((data) => { if (data.added_) { playerInfos.Add(new PlayerInfo(data.player_)); } else { playerInfos.RemoveAll((info) => info.playerData == data.player_); } }); // chat stuff Events.Local.ChatSubmitMessage.Subscribe(data => { GeneralUtilities.logExceptions(() => { Chat_MessageSent(data); }); }); var sendingClientToAllClientsMessage = false; AddMessage.Subscribe(data => { if (!sendingClientToAllClientsMessage && (MessageUtilities.currentState == null || !MessageUtilities.currentState.forPlayer)) { chatReplicationManager.AddPublic(data.message_); } }); ChatMessage.Subscribe(data => { GeneralUtilities.logExceptions(() => { sendingClientToAllClientsMessage = true; var author = MessageUtilities.ExtractMessageAuthor(data.message_); if (!MessageUtilities.IsSystemMessage(data.message_) && !sendingLocalChat && !string.IsNullOrEmpty(author)) { Chat_MessageReceived(author, MessageUtilities.ExtractMessageBody(data.message_), data); } else { addMessageFromRemote(data); chatReplicationManager.AddPublic(data.message_); } sendingLocalChat = false; sendingClientToAllClientsMessage = false; }); }); Events.Network.ServerInitialized.Subscribe(data => { chatReplicationManager.Clear(); G.Sys.GameManager_.StartCoroutine(serverInit()); }); replicateLocalChatFunc = PrivateUtilities.removeParticularSubscriber <ChatSubmitMessage.Data>(PrivateUtilities.getComponent <ClientLogic>()); addMessageFromRemote = PrivateUtilities.removeParticularSubscriber <ChatMessage.Data>(G.Sys.NetworkingManager_); chatReplicationManager = new ChatReplicationManager(); chatReplicationManager.Setup(); Events.Game.LevelLoaded.Subscribe(data => { UnstuckCmd.PatchLoadSequence(); }); }
/// <summary> /// Initializes a new instance of the <see cref="RivalSourceSettings"/> class. /// </summary> public RivalSourceSettings() { LevelFilter = new LevelFilter(); Coulomb = Coulomb.Undefined; }