コード例 #1
0
ファイル: ObjectProvider.cs プロジェクト: minskowl/MY
        /// <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());
        }
コード例 #2
0
        public void should_print_if_higher_2()
        {
            string formatted;
            var    res = LevelFilter.ShouldPrint(sample, LogLevel.Trace, out formatted);

            Assert.That(res, Is.True);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public SelectLogLevelControl(LevelFilter levelFilter)
        {
            this.levelFilter       = levelFilter;
            levelFilter.OnChanged += LevelFilter_OnChanged;

            InitializeComponent();
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
ファイル: Can_filter.cs プロジェクト: jibedoubleve/log-reader
        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);
            }
        }
コード例 #7
0
ファイル: ObjectProvider.cs プロジェクト: minskowl/MY
        /// <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));
        }
コード例 #8
0
ファイル: ObjectProvider.cs プロジェクト: minskowl/MY
        /// <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));
        }
コード例 #9
0
 public StructuredLogViewModel()
 {
     DateFilter             = new DateFilter();
     DateFilter.OnChanged  += DateFilter_OnChanged;
     LevelFilter            = new LevelFilter();
     LevelFilter.OnChanged += LevelFilter_OnChanged;
 }
コード例 #10
0
        public void should_not_print_if_lower()
        {
            string formatted;

            Assert.That(
                LevelFilter.ShouldPrint(sample, LogLevel.Warn, out formatted),
                Is.False);
        }
コード例 #11
0
        public void TestInRangeLowerLimit()
        {
            var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning);
            var actual = filter.CanLog(new LogEntry {
                LogLevel = LogLevel.Info
            });

            Assert.True(actual);
        }
コード例 #12
0
        public void TestMoreThanUpperLimit()
        {
            var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning);
            var actual = filter.CanLog(new LogEntry {
                LogLevel = LogLevel.Error
            });

            Assert.False(actual);
        }
コード例 #13
0
        public void TestLessThanLowerLimit()
        {
            var filter = new LevelFilter(LogLevel.Info, LogLevel.Warning);
            var actual = filter.CanLog(new LogEntry {
                LogLevel = LogLevel.Debug
            });

            Assert.False(actual);
        }
コード例 #14
0
ファイル: ObjectProvider.cs プロジェクト: minskowl/MY
        /// <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));
        }
コード例 #15
0
ファイル: Can_filter.cs プロジェクト: jibedoubleve/log-reader
        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());
        }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        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));
            }
        }
コード例 #18
0
ファイル: Can_filter.cs プロジェクト: jibedoubleve/log-reader
        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);
            }
        }
コード例 #19
0
ファイル: Can_filter.cs プロジェクト: jibedoubleve/log-reader
        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);
            }
        }
コード例 #20
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");
            }
        }
コード例 #21
0
        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));
            }
        }
コード例 #22
0
        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");
            }
        }
コード例 #23
0
        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;
        }
コード例 #24
0
ファイル: DbHelper.cs プロジェクト: minskowl/MY
 /// <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);
 }
コード例 #25
0
ファイル: Entry.cs プロジェクト: Corecii/ServerMod
        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();
            });
        }
コード例 #26
0
ファイル: RivalSourceSettings.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Initializes a new instance of the <see cref="RivalSourceSettings"/> class.
 /// </summary>
 public RivalSourceSettings()
 {
     LevelFilter = new LevelFilter();
     Coulomb     = Coulomb.Undefined;
 }