Exemplo n.º 1
0
        public override DispatcherOperation LoadEntries(uint startFromID)
        {
            if (startFromID > Log9KEntry.Counter)
            {
                return(null);
            }
            startFromID--;
            if (IsAddingNewestEntries)
            {
                IsAddingNewestEntries = false;
            }
            if (ScrollToLastLog)
            {
                ScrollToLastLog = false;
            }

            uint lineNumber;

            if (startFromID == 0)
            {
                return(null);
            }

            if (Application.Current == null)
            {
                return(null);
            }

            DispatcherOperation a = Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                if (!FindLineNumber(startFromID, out lineNumber))
                {
                    Log9KCore.Instance.InnerLog("Ошибка: при загрузке логов метод FindLineNumber вернул false");
                    return;
                }

                LineNumberTopTempFile = lineNumber;
                LogEntryCollection.Clear();
                for (int i = 0; i < LogEntryCollection.MaxCollectionSize; i++)
                {
                    Log9KEntry entry = ReadEntry(lineNumber);
                    if (entry == null)
                    {
                        break;
                    }
                    LogEntryCollection.Add(entry);
                    lineNumber++;
                }
            }), DispatcherPriority.Background);

            return(a);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load most recent logs from temporary file
        /// </summary>
        public override void LoadLastLogs()
        {
            LogEntryCollection.StartRemovingFromTop();
            LogEntryCollection.Clear();

            uint entriesNumber;
            bool success = Log9KUtil.GetEntriesNumberInFile(
                FilenameTempFile, Log9KEntry.ENTRY_SIZE, out entriesNumber
                );

            if (!success)
            {
                Log9KCore.Instance.InnerLog("Ошибка: метод Log9KUtil.GetEntriesNumberInFile вернул false");
                return;
            }

            if (Application.Current == null)
            {
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(
                new Action(() => {
                bool notEnd = true;
                uint z      = 0;
                for (uint i = entriesNumber; notEnd; i--)
                {
                    Log9KEntry e = ReadEntry(i);
                    if (e != null)
                    {
                        LogEntryCollection.Insert(0, e);
                    }
                    if (i == 0 || z >= LogEntryCollection.MaxCollectionSize)
                    {
                        notEnd = false;
                    }
                    z++;
                }
            }),
                DispatcherPriority.Background
                );
        }
Exemplo n.º 3
0
        private void FilterApplyToCollection(uint lineStart, uint lineEnd)
        {
            IsAddingNewestEntries = false;
            LogEntryCollection.Clear();
            uint i = 0;

            for (uint j = lineStart; j < lineEnd; j++)
            {
                Log9KEntry entry = ReadEntry(j);
                if (entry != null)
                {
                    CollectionAdd(entry);
                    i++;
                }
                if (i >= LogEntryCollection.MaxCollectionSize)
                {
                    break;
                }
            }
            LineNumberTopTempFile = lineStart;
        }