示例#1
0
            private static string FormatLogEntry(LogEntry entry, bool includeKeyValues = false)
            {
                StringBuilder entryText = new StringBuilder();

                if (!string.IsNullOrWhiteSpace(entry.loggerName))
                {
                    entryText.AppendFormat("{0} - ", entry.loggerName);
                }

                entryText.Append(entry.message);
                entryText.AppendFormat(" ({0})", LogFilters.GetFilterString(entry.filter.Flags));

                if (entry.errorCode != 0)
                {
                    entryText.AppendFormat(" - error code {0}", entry.errorCode);
                }

                if (!string.IsNullOrWhiteSpace(entry.location))
                {
                    entryText.AppendFormat(" @ {0}", entry.location);
                }

                if (includeKeyValues && entry.keyValues.Count > 0)
                {
                    entryText.AppendLine();
                    entryText.AppendFormat("Key Values = {0}", entry.keyValues.JoinKeyValuePairs());
                }

                return(entryText.ToString());
            }
示例#2
0
        [TestMethod()] public void IngoreDupErrorFilter()
        {
            Log.WriteDelay = 0;
            Log.Filters.Add(LogFilters.IgnoreDuplicateExceptions());

            Exception subject = new Exception();

            Log.Error(subject);
            Assert.IsTrue(LogContent.Contains("Exception"), "Exception is logged");
            long len = LogSize;

            Log.Error(subject);
            Assert.IsTrue(LogSize == len, "Duplicate is suppressed");

            Log.Error(subject.ToString());
            Assert.IsTrue(LogSize > len, "Non exceptions are allowed");
            len = LogSize;

            Log.Filters.Add(LogFilters.AddPrefix("ABC"));
            Log.Filters.Add(LogFilters.AddPostfix("DEF"));
            Log.Error(subject);
            Assert.IsTrue(LogSize == len, "Duplicate is suppressed with pre post");

            Log.Error(new FormatException());
            Assert.IsTrue(LogContent.Contains("FormatException"), "New exception is logged");
            len = LogSize;

            Log.Error(subject);
            Assert.IsTrue(LogSize == len, "Duplicate is still suppressed");

            Assert.AreEqual(null, Error, "OnError");
        }
示例#3
0
        [TestMethod()] public void MultipleFilters()
        {
            var Logger  = new LoggerProxy(Log);
            var filters = Logger.Filters;

            filters.Add(LogFilters.AddPrefix("Pre>"));

            Log.WriteDelay = 0;
            Log.Filters.Add(LogFilters.IgnoreDuplicateExceptions());
            Log.Filters.Add(LogFilters.AutoMultiParam);
            Log.Filters.Add(LogFilters.FormatParams);
            Log.Filters.Add(LogFilters.ResolveLazy);
            Log.Filters.Add(LogFilters.AddPostfix("<Post"));

            Logger.Info("ARST");
            Assert.IsTrue(LogContent.Contains("Pre>ARST"), "Simple Log");

            Logger.Info("A", "R", null, "S", "T");
            Assert.IsTrue(LogContent.Contains(">A R null S T<"), "Format multi params");

            Logger.Info((Func <string>)(() => "QWFP"));
            Assert.IsTrue(LogContent.Contains(">QWFP"), "Resolve lazy");

            Exception subject = new Exception();

            Logger.Error(subject);
            Assert.IsTrue(LogContent.Contains("Pre>System.Exception:"), "Exception is logged");
            var len = LogSize;

            Logger.Error("Error: {0}", subject);
            Assert.IsTrue(LogSize == len, "Duplicate is suppressed");
        }
示例#4
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            // setup the export filters
            LogFilters          filterhelper = new LogFilters();
            frmLogFilters       frmfilters   = new frmLogFilters();
            LogFilterCollection filters      = filterhelper.GetFiltersFromRegistry();

            Console.WriteLine("filters: " + filters.Count);
            frmfilters.SetFilters(filters);
            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    DataRowView dv = (DataRowView)gridView1.GetRow(rowhandle);
                    if (dv != null)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = dv.Row["SYMBOLNAME"].ToString();
                        sh.Color   = Color.FromArgb(Convert.ToInt32(dv.Row["COLOR"]));
                        _sc.Add(sh);
                    }
                }
            }
            frmfilters.SetSymbols(_sc);
            if (frmfilters.ShowDialog() == DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
            }
        }
示例#5
0
文件: Logger.cs 项目: NHxD/NHxD
        public Logger(string fileName, LogFilters level)
        {
            FileName = fileName;
            Level    = level;

            Create();
        }
示例#6
0
文件: Logger.cs 项目: NHxD/NHxD
        private void WriteLine(LogFilters filters, string contents)
        {
            if (!Level.HasFlag(filters))
            {
                return;
            }

            WriteLine(string.Format(CultureInfo.InvariantCulture, "[{0}] ({1}) {2}", DateTime.Now.ToString(CultureInfo.InvariantCulture), filters, contents));
        }
示例#7
0
        public void Log(string component, string message, params object[] parm)
        {
            if (!(LogFilters?.Contains(component) ?? true))
            {
                return;
            }

            System.Diagnostics.Trace.WriteLine($"DEBUGGER [{component}]: " + String.Format(message, parm));
        }
示例#8
0
文件: Logger.cs 项目: NHxD/NHxD
        private void WriteLineFormat(LogFilters filters, string format, params object[] args)
        {
            if (!Level.HasFlag(filters))
            {
                return;
            }

            WriteLineFormat(string.Format(CultureInfo.InvariantCulture, "[{0}] ({1}) {2}", DateTime.Now.ToString(CultureInfo.InvariantCulture), filters, format), args);
        }
 private void CreateFilters()
 {
     foreach (var logLevel in Enum.GetValues(typeof(LogLevel)).Cast <LogLevel>())
     {
         LogFilters.Add(new LogFilter
         {
             FilterType = logLevel,
             IsEnabled  = true
         });
     }
 }
        private async Task OnAddCommandExecuteAsync()
        {
            var logFilter = new LogFilter();

            if (await _uiVisualizerService.ShowDialogAsync <LogFilterEditorViewModel>(logFilter) ?? false)
            {
                LogFilters.Add(logFilter);
                SelectedLogFilter = logFilter;

                Validate(true);
            }
        }
示例#11
0
            private static string FormatLogEntry(LogEntry entry)
            {
                StringBuilder entryText = new StringBuilder();

                entryText.Append(entry.message);
                entryText.AppendFormat(" ({0})", LogFilters.GetFilterString(entry.filter.Flags));

                if (!string.IsNullOrWhiteSpace(entry.location))
                {
                    entryText.AppendFormat(" @ {0}", entry.location);
                }

                return(entryText.ToString());
            }
示例#12
0
        void ILogHandler.Log(LogEntry entry)
        {
            var hint = GetDisplayHint(entry.filter);

            if (DisplayTimestamp(entry.filter))
            {
                proxy.Log(hint, "");
                proxy.LogFull(hint, LogFilters.GetFilterString(entry.filter.Flags), entry.alias, entry.message);
            }
            else
            {
                proxy.Log(hint, entry.message);
            }
        }
示例#13
0
 internal void CheckSetup()
 {
     lock (this) {
         if (ModLoader.NeedSetup)
         {
             App.Log("Initiating ModLoader");
             var logger = new GuiLogger();
             ModLoader.SetLog(logger);
             logger.Filters.Add(LogFilters.AddPrefix("Loader┊"));
             App.Log("Setup ModLoader");
             ModLoader.Setup();
             Sandbox.EnqueueSandbox();
         }
     }
 }
示例#14
0
 public Logger Log()
 {
     lock (this) {
         if (Logger != null)
         {
             return(Logger);
         }
         Logger = new LoggerProxy(ModLoader.Log)
         {
             Level = LogLevel ?? ModLoader.Settings.LogLevel
         };
     }
     Logger.Filters.Add(LogFilters.IgnoreDuplicateExceptions());
     Logger.Filters.Add(PrefixFilter);
     return(Logger);
 }
示例#15
0
        [TestMethod()] public void PrefixPostfixFilter()
        {
            Log.WriteDelay = 0;
            Log.Filters.Add(LogFilters.AddPrefix("A"));
            Log.Filters.Add(LogFilters.AddPostfix("Z"));

            Exception subject = new Exception();

            Log.Info(null);
            Assert.IsTrue(LogContent.Contains("AZ"), "Added to null");

            Log.Info("BC XY");
            Assert.IsTrue(LogContent.Contains("ABC XYZ"), "Added to message");

            Assert.AreEqual(null, Error, "OnError");
        }
示例#16
0
        private void CreateDefaultFilter()
        {
            var uiFilter = LogFilters.FirstOrDefault(filter => filter.FilterType == LogLevel.Error);

            if (uiFilter != null)
            {
                uiFilter.IsSelected = true;
                AppliedFilterList.Add(uiFilter);
            }

            uiFilter = LogFilters.FirstOrDefault(filter => filter.FilterType == LogLevel.Fatal);
            if (uiFilter != null)
            {
                uiFilter.IsSelected = true;
                AppliedFilterList.Add(uiFilter);
            }
        }
示例#17
0
        private Control ConstructApplyButton(LogFilters filters, CompositionFilters filterSnapshot)
        {
            var applyButton = new Button {
                Text    = "Apply",
                Enabled = !Equals(filters.CompositionFilters, filterSnapshot)
            };

            applyButton.Click += (_, _) => {
                filters.CompositionFilters = filterSnapshot.DeepClone();
                applyButton.Enabled        = !Equals(filters.CompositionFilters, filterSnapshot);
            };

            filterSnapshot.PropertyChanged += (_, _) => {
                applyButton.Enabled = !Equals(filters.CompositionFilters, filterSnapshot);
            };

            return(applyButton);
        }
示例#18
0
        public AdvancedFilterPanel(ImageProvider imageProvider, LogFilters filters)
        {
            Filters = filters;

            BeginVertical(new Padding(5));
            {
                BeginGroup("Squad composition", new Padding(5));
                {
                    Add(new SquadCompositionFilterPanel(imageProvider, filters));
                }
                EndGroup();
            }
            EndVertical();

            var unparsedCheckBox = new CheckBox {
                Text = "Unprocessed"
            };

            unparsedCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowParseUnparsedLogs);
            var parsingCheckBox = new CheckBox {
                Text = "Processing"
            };

            parsingCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowParseParsingLogs);
            var parsedCheckBox = new CheckBox {
                Text = "Processed"
            };

            parsedCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowParseParsedLogs);
            var failedCheckBox = new CheckBox {
                Text = "Failed"
            };

            failedCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowParseFailedLogs);
            BeginVertical(new Padding(5));
            {
                BeginGroup("Processing status", new Padding(5), new Size(6, 0));
                {
                    AddRow(unparsedCheckBox, parsingCheckBox, parsedCheckBox, failedCheckBox);
                }
                EndGroup();
            }
            EndVertical();
        }
示例#19
0
        /// <summary>
        /// 获取访问日志
        /// </summary>
        /// <param name="filters">过滤器</param>
        /// <returns></returns>
        public async Task <PagedResult <VisitDto> > SearchVisitLogsAsync(LogFilters filters)
        {
            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var query = db.PageViews
                            .WhereIf(filters.keywords.IsNotBlank(), x => x.LoginName.Contains(filters.keywords));

                return(await query.OrderByCustom(filters.sidx, filters.sord)
                       .Select(item => new VisitDto
                {
                    Id = item.Id,
                    UserId = item.UserId,
                    LoginName = item.LoginName,
                    IP = item.IP,
                    Url = item.Url,
                    VisitDate = item.CreateDateTime
                }).PagingAsync(filters.page, filters.rows));
            }
        }
示例#20
0
        /// <summary>
        /// 获取访问日志
        /// </summary>
        /// <param name="filters">过滤器</param>
        /// <returns></returns>
        public async Task <PagedResult <VisitDto> > SearchVisitLogsAsync(LogFilters filters)
        {
            var dbSet = _context.PageViews;
            var query = dbSet.AsQueryable();

            if (filters.keywords.IsNotBlank())
            {
                query = query.Where(item => item.LoginName.Contains(filters.keywords));
            }

            return(await query.OrderByDescending(item => item.CreateDateTime)
                   .Select(item => new VisitDto
            {
                Id = item.Id,
                UserId = item.UserId,
                LoginName = item.LoginName,
                Ip = item.IP,
                Url = item.Url,
                VisitDate = item.CreateDateTime
            }).PagingAsync(filters.page, filters.rows));
        }
示例#21
0
 public static void SetLog(Logger logger, bool clear = false)
 {
     lock ( MOD_PATH ) {
         if (Log != null)
         {
             throw new InvalidOperationException();
         }
         Log = logger ?? throw new NullReferenceException(nameof(logger));
         logger.Filters.Clear();
         Log.Filters.Add(LogFilters.IgnoreDuplicateExceptions("(same stacktrace as before)"));
         Log.Filters.Add(LogFilters.AutoMultiParam);
         Log.Filters.Add(LogFilters.FormatParams);
         Log.Filters.Add(LogFilters.ResolveLazy);
         if (clear)
         {
             Log.Clear();
         }
         LoaderVersion = Assembly.GetExecutingAssembly().GetName().Version;
         Log.Info("{0}/{1}; {2}", typeof(ModLoader).FullName, LoaderVersion, DateTime.Now.ToString("u"));
         Json.JsonLogger.Masters.Clear();
         Json.JsonLogger.Masters.Add(Log);
     }
 }
示例#22
0
        /// <summary>
        /// 获取登录日志
        /// </summary>
        /// <param name="filters">过滤器</param>
        /// <returns></returns>
        public async Task <PagedResult <LoginLogDto> > SearchLoginLogsAsync(LogFilters filters)
        {
            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var query = db.LoginLogs.AsQueryable();
                if (filters.keywords.IsNotBlank())
                {
                    query = query.Where(item => item.LoginName.Contains(filters.keywords));
                }

                return(await query.OrderByCustom(filters.sidx, filters.sord)
                       .Select(item => new LoginLogDto
                {
                    Id = item.Id,
                    UserId = item.UserId,
                    LoginName = item.LoginName,
                    IP = item.IP,
                    Mac = item.Mac,
                    CreateDateTime = item.CreateDateTime
                }).PagingAsync(filters.page, filters.rows));
            }
        }
示例#23
0
        private IEnumerable <TypeRegistration> GetRegistrationsCore(IConfigurationSource configurationSource)
        {
            var registrations = new List <TypeRegistration>();

            registrations.Add(CreateLoggingInstrumentationProviderRegistration(configurationSource));
            registrations.Add(CreateLoggingUpdateCoordinatorRegistration());
            registrations.Add(CreateLogWriterRegistration());
            registrations.Add(CreateDefaultLoggingEventLoggerRegistration(configurationSource));
            registrations.AddRange(TraceListeners.SelectMany(tld => tld.GetRegistrations()));
            registrations.AddRange(LogFilters.SelectMany(lfd => lfd.GetRegistrations()));
            registrations.AddRange(Formatters.SelectMany(fd => fd.GetRegistrations()));
            registrations.AddRange(TraceSources.Select(tsd => tsd.GetRegistrations()));
            registrations.Add(
                CreateLogSourceRegistration(SpecialTraceSources.AllEventsTraceSource, AllTraceSourceKey));
            registrations.Add(
                CreateLogSourceRegistration(SpecialTraceSources.NotProcessedTraceSource, NoMatchesTraceSourceKey));
            registrations.Add(
                CreateLogSourceRegistration(SpecialTraceSources.ErrorsTraceSource, ErrorsTraceSourceKey));
            registrations.Add(CreateLogWriterStructureHolderRegistration());
            registrations.Add(CreateTraceManagerRegistration());
            registrations.Add(CreateTracerInstrumentationProviderRegistration(configurationSource));

            return(registrations);
        }
示例#24
0
        /// <summary>
        /// 获取访问日志
        /// </summary>
        /// <param name="filters">过滤器</param>
        /// <returns></returns>
        public PagedResult <VisitDto> SearchVisitLogs(LogFilters filters)
        {
            using (var scope = _dbContextScopeFactory.CreateReadOnly())
            {
                var db    = scope.DbContexts.Get <JuCheapContext>();
                var dbSet = db.Set <PageViewEntity>();
                var query = dbSet.AsQueryable();
                if (filters.keywords.IsNotBlank())
                {
                    query = query.Where(item => item.LoginName.Contains(filters.keywords));
                }

                return(query.OrderBy(item => item.CreateDateTime)
                       .Select(item => new VisitDto
                {
                    Id = item.Id,
                    UserId = item.UserId,
                    LoginName = item.LoginName,
                    IP = item.IP,
                    Url = item.Url,
                    VisitDate = item.CreateDateTime
                }).Paging(filters.page, filters.rows));
            }
        }
示例#25
0
        public async Task <JsonResult> VisitsList(LogFilters filters)
        {
            var result = await _logService.SearchVisitLogsAsync(filters);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#26
0
        public ManagerForm(LogCache logCache, ApiData apiData)
        {
            LogCache = logCache ?? throw new ArgumentNullException(nameof(logCache));
            ApiData  = apiData ?? throw new ArgumentNullException(nameof(apiData));

            // Background processors
            var dpsReportUploader = new DpsReportUploader();

            UploadProcessor   = new UploadProcessor(dpsReportUploader, LogCache);
            ApiProcessor      = new ApiProcessor(ApiData, new Gw2Client());
            LogDataProcessor  = new LogDataProcessor(LogCache, ApiProcessor, LogAnalytics);
            LogNameProvider   = new TranslatedLogNameProvider(GameLanguage.English);
            LogCacheAutoSaver = LogCacheAutoSaver.StartNew(logCache, LogCacheAutoSavePeriod);

            LogDataProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for logs has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            ApiProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for API requests has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            UploadProcessor.StoppingWithError += (sender, args) =>
            {
                Application.Instance.InvokeAsync(() => MessageBox.Show(this,
                                                                       $"The background processor for log uploads has failed critically. " +
                                                                       $"Please report the following error:\n\nException: {args.Exception}", "Error", MessageBoxType.Error));
            };

            Filters = new LogFilters(new SettingsFilters());
            Filters.PropertyChanged += (sender, args) => logsFiltered.Refresh();

            if (Settings.UseGW2Api)
            {
                ApiProcessor.StartBackgroundTask();
            }

            Settings.UseGW2ApiChanged += (sender, args) =>
            {
                if (Settings.UseGW2Api)
                {
                    ApiProcessor.StartBackgroundTask();
                }
                else
                {
                    ApiProcessor.StopBackgroundTask();
                }
            };

            Settings.DpsReportDomainChanged += (sender, args) => { dpsReportUploader.Domain = Settings.DpsReportDomain; };

            // Form layout
            Icon       = Resources.GetProgramIcon();
            Title      = "arcdps Log Manager";
            ClientSize = new Size(1300, 768);
            var formLayout = new DynamicLayout();

            Content = formLayout;

            Menu = ConstructMenuBar();

            formLayout.BeginVertical(new Padding(5), yscale: false);
            {
                formLayout.Add(ConstructMainSplitter(), yscale: true);
                formLayout.Add(ConstructStatusPanel());
            }
            formLayout.EndVertical();

            // Event handlers
            ApiProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;

                if (last)
                {
                    ApiData.SaveDataToFile();
                }
            };

            Settings.LogRootPathChanged += (sender, args) => Application.Instance.Invoke(ReloadLogs);

            Closing += (sender, args) =>
            {
                if (LogCache?.ChangedSinceLastSave ?? false)
                {
                    LogCache?.SaveToFile();
                }

                ApiData?.SaveDataToFile();
            };
            LogSearchFinished += (sender, args) =>
            {
                var updates = LogDataUpdater.GetUpdates(logs).ToList();
                if (updates.Count > 0)
                {
                    new ProcessingUpdateDialog(LogDataProcessor, updates).ShowModal(this);
                }
            };

            // Collection initialization
            logsFiltered = new FilterCollection <LogData>(logs);
            logsFiltered.CollectionChanged += (sender, args) => FilteredLogsUpdated?.Invoke(this, EventArgs.Empty);
            logsFiltered.Filter             = Filters.FilterLog;
            LogCollectionsInitialized?.Invoke(this, EventArgs.Empty);
            LogDataProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;
                if (last)
                {
                    Application.Instance.AsyncInvoke(logsFiltered.Refresh);
                }
            };

            Shown += (sender, args) => ReloadLogs();
            Shown += (sender, args) => CheckUpdates();
        }
示例#27
0
        public LogFilterPanel(ImageProvider imageProvider, LogFilters filters)
        {
            Filters = filters;

            encounterTree = new LogEncounterFilterTree(imageProvider, Filters);

            var successCheckBox = new CheckBox {
                Text = "Success"
            };

            successCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowSuccessfulLogs);
            var failureCheckBox = new CheckBox {
                Text = "Failure"
            };

            failureCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowFailedLogs);
            var unknownCheckBox = new CheckBox {
                Text = "Unknown"
            };

            unknownCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowUnknownLogs);

            var normalModeCheckBox = new CheckBox {
                Text = "Normal"
            };

            normalModeCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowNormalModeLogs);
            var challengeModeCheckBox = new CheckBox {
                Text = "CM"
            };

            challengeModeCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowChallengeModeLogs);

            var nonFavoritesCheckBox = new CheckBox {
                Text = "☆ Non-favorites"
            };

            nonFavoritesCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowNonFavoriteLogs);
            var favoritesCheckBox = new CheckBox {
                Text = "★ Favorites"
            };

            favoritesCheckBox.CheckedBinding.Bind(this, x => x.Filters.ShowFavoriteLogs);

            // TODO: This is currently only a one-way binding
            var tagText = new TextBox();

            tagText.TextChanged += (source, args) =>
            {
                var tags = tagText.Text.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(tag => tag.Trim()).ToList();
                filters.RequiredTags = tags;
            };

            var startDateTimePicker = new DateTimePicker {
                Mode = DateTimePickerMode.DateTime
            };

            startDateTimePicker.ValueBinding.Bind(this, x => x.Filters.MinDateTime);
            var endDateTimePicker = new DateTimePicker {
                Mode = DateTimePickerMode.DateTime
            };

            endDateTimePicker.ValueBinding.Bind(this, x => x.Filters.MaxDateTime);

            var lastDayButton = new Button {
                Text = "Last day"
            };

            lastDayButton.Click += (sender, args) =>
            {
                startDateTimePicker.Value = DateTime.Now - TimeSpan.FromDays(1);
                endDateTimePicker.Value   = null;
            };

            var lastWeekButton = new Button {
                Text = "Last week"
            };

            lastWeekButton.Click += (sender, args) =>
            {
                startDateTimePicker.Value = DateTime.Now - TimeSpan.FromDays(7);
                endDateTimePicker.Value   = null;
            };

            var allTimeButton = new Button {
                Text = "All time"
            };

            allTimeButton.Click += (sender, args) => {
                startDateTimePicker.Value = null;
                endDateTimePicker.Value   = null;
            };

            var advancedFiltersButton = new Button {
                Text = "Advanced filters"
            };

            advancedFiltersButton.Click += (sender, args) =>
            {
                var form = new Form
                {
                    Title   = "Advanced filters - arcdps Log Manager",
                    Content = new AdvancedFilterPanel(imageProvider, filters)
                };
                form.Show();
            };

            BeginVertical(new Padding(0, 0, 0, 4), spacing: new Size(4, 4));
            {
                BeginGroup("Result", new Padding(4, 0, 4, 2), spacing: new Size(6, 0));
                {
                    BeginHorizontal();
                    {
                        Add(successCheckBox);
                        Add(failureCheckBox);
                        Add(unknownCheckBox);
                    }
                    EndHorizontal();
                }
                EndGroup();
                BeginGroup("Mode", new Padding(4, 0, 4, 2), spacing: new Size(6, 0));
                {
                    BeginHorizontal();
                    {
                        Add(normalModeCheckBox);
                        Add(challengeModeCheckBox);
                    }
                    EndHorizontal();
                }
                EndGroup();
                BeginGroup("Time", new Padding(4, 0, 4, 2), spacing: new Size(4, 4));
                {
                    BeginVertical(spacing: new Size(4, 2));
                    {
                        BeginHorizontal();
                        {
                            Add(new Label
                            {
                                Text = "Between",
                                VerticalAlignment = VerticalAlignment.Center
                            });
                            Add(startDateTimePicker);
                            Add(null, xscale: true);
                        }
                        EndHorizontal();
                        BeginHorizontal();
                        {
                            Add(new Label {
                                Text = "and", VerticalAlignment = VerticalAlignment.Center
                            });
                            Add(endDateTimePicker);
                            Add(null, xscale: true);
                        }
                        EndHorizontal();
                    }
                    EndVertical();
                    BeginVertical(spacing: new Size(4, 0));
                    {
                        BeginHorizontal();
                        {
                            Add(allTimeButton, xscale: false);
                            Add(lastWeekButton, xscale: false);
                            Add(lastDayButton, xscale: false);
                            Add(null, xscale: true);
                        }
                        EndHorizontal();
                    }
                    EndVertical();
                }
                EndGroup();
                BeginGroup("Favorites", new Padding(4, 0, 4, 2), spacing: new Size(6, 4));
                {
                    BeginHorizontal();
                    {
                        Add(nonFavoritesCheckBox);
                        Add(favoritesCheckBox);
                    }
                    EndHorizontal();
                }
                EndGroup();
                BeginGroup("Tags (comma-separated)", new Padding(4, 0, 4, 2), spacing: new Size(6, 4));
                {
                    BeginVertical();
                    {
                        BeginHorizontal();
                        {
                            Add(tagText);
                        }
                        EndHorizontal();
                    }
                    EndVertical();
                }
                EndGroup();

                Add(encounterTree, yscale: true);
                Add(advancedFiltersButton);
            }
            EndVertical();
        }
示例#28
0
 private void SetupLogFilters()
 {
     // setup the export filters
     LogFilters filterhelper = new LogFilters();
     frmLogFilters frmfilters = new frmLogFilters();
     LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
     frmfilters.SetFilters(filters);
     SymbolCollection sc = new SymbolCollection();
     foreach (SymbolHelper sh in m_symbols)
     {
         //if (!sh.Varname.Contains("!")) sc.Add(sh);
         if (!IsSymbolCalibration(sh.Varname)) sc.Add(sh);
     }
     frmfilters.SetSymbols(sc);
     if (frmfilters.ShowDialog() == DialogResult.OK)
     {
         filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
     }
 }
示例#29
0
        public async Task <IActionResult> VisitsList(LogFilters filters)
        {
            var result = await _logService.SearchVisitLogsAsync(filters);

            return(Json(result));
        }
示例#30
0
        public LogEncounterFilterTree(ImageProvider imageProvider, LogFilters filters)
        {
            this.imageProvider = imageProvider;
            Filters            = filters;

            AllowMultipleSelection = true;

            Columns.Add(new GridColumn()
            {
                HeaderText = "Category",
                DataCell   = new ImageTextCell
                {
                    TextBinding  = Binding.Property <GroupFilterTreeItem, string>(x => x.LogGroup.Name),
                    ImageBinding = Binding.Property <GroupFilterTreeItem, Image>(x => x.Icon),
                },
            });

            Columns.Add(new GridColumn()
            {
                HeaderText = "Count",
                DataCell   = new ImageTextCell
                {
                    TextBinding = Binding.Property <GroupFilterTreeItem, string>(x => x.LogCount.ToString())
                },
            });

            RowHeight = 22;

            SelectionChanged += (sender, args) =>
            {
                Filters.LogGroups = SelectedItems.Select(x => ((GroupFilterTreeItem)x).LogGroup).ToList();
            };

            var expandAll = new ButtonMenuItem {
                Text = "Expand all"
            };

            expandAll.Click += (sender, args) =>
            {
                DoForAllItems(item =>
                {
                    item.Expanded = true;
                });
                ReloadData();
            };
            var collapseAll = new ButtonMenuItem {
                Text = "Collapse all"
            };

            collapseAll.Click += (sender, args) =>
            {
                DoForAllItems(item =>
                {
                    item.Expanded = false;
                });
                ReloadData();
            };
            ContextMenu = new ContextMenu();
            ContextMenu.Items.Add(expandAll);
            ContextMenu.Items.Add(collapseAll);
        }
示例#31
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            // setup the export filters
            LogFilters filterhelper = new LogFilters();
            frmLogFilters frmfilters = new frmLogFilters();
            LogFilterCollection filters = filterhelper.GetFiltersFromRegistry();
            logger.Debug("filters: " + filters.Count);
            frmfilters.SetFilters(filters);
            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                int[] selrows = gridView1.GetSelectedRows();
                foreach (int rowhandle in selrows)
                {
                    DataRowView dv = (DataRowView)gridView1.GetRow(rowhandle);
                    if (dv != null)
                    {
                        SymbolHelper sh = new SymbolHelper();
                        sh.Varname = dv.Row["SYMBOLNAME"].ToString();
                        sh.Color = Color.FromArgb(Convert.ToInt32(dv.Row["COLOR"]));
                        _sc.Add(sh);
                    }
                }

            }
            frmfilters.SetSymbols(_sc);
            if (frmfilters.ShowDialog() == DialogResult.OK)
            {
                DialogResult = DialogResult.None;
                filterhelper.SaveFiltersToRegistry(frmfilters.GetFilters());
            }
        }
示例#32
0
        private void ConvertFileToDif(string filename, bool AutoExport)
        {
            System.Windows.Forms.Application.DoEvents();
            DateTime startDate = DateTime.MaxValue;
            DateTime endDate = DateTime.MinValue;
            try
            {
                SymbolCollection sc = new SymbolCollection();
                string[] alllines = File.ReadAllLines(filename);
                //using (StreamReader sr = new StreamReader(filename))
                {
                    //string line = string.Empty;
                    char[] sep = new char[1];
                    char[] sep2 = new char[1];
                    //int linecount = 0;
                    sep.SetValue('|', 0);
                    sep2.SetValue('=', 0);
                    //while ((line = sr.ReadLine()) != null)

                    foreach(string line in alllines)
                    {
                        string[] values = line.Split(sep);
                        if (values.Length > 0)
                        {
                            try
                            {
                                //dd/MM/yyyy HH:mm:ss
                                //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                string dtstring = (string)values.GetValue(0);
                                DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                if (dt > endDate) endDate = dt;
                                if (dt < startDate) startDate = dt;
                                for (int t = 1; t < values.Length; t++)
                                {
                                    string subvalue = (string)values.GetValue(t);
                                    string[] subvals = subvalue.Split(sep2);
                                    if (subvals.Length == 2)
                                    {
                                        string varname = (string)subvals.GetValue(0);
                                        bool sfound = false;
                                        foreach (SymbolHelper sh in sc)
                                        {
                                            if (sh.Varname == varname || sh.Userdescription == varname)
                                            {
                                                sfound = true;
                                            }
                                        }
                                        SymbolHelper nsh = new SymbolHelper();
                                        nsh.Varname = varname;
                                        if (!sfound) sc.Add(nsh);
                                    }
                                }
                            }
                            catch (Exception pE)
                            {
                                logger.Debug(pE.Message);
                            }
                        }
                    }
                }

                if (AutoExport)
                {
                    foreach (SymbolHelper sh in sc)
                    {
                        sh.Color = GetColorFromRegistry(sh.Varname);
                    }
                    DifGenerator difgen = new DifGenerator();
                    difgen.AppSettings = m_appSettings;

                    //difgen.LowAFR = m_appSettings.WidebandLowAFR;
                    //difgen.HighAFR = m_appSettings.WidebandHighAFR;
                    //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage;
                    //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage;
                    difgen.WidebandSymbol = m_appSettings.WideBandSymbol;
                    //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                    difgen.UseWidebandInput = false;

                    difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                    frmProgressLogWorks = new frmProgress();
                    frmProgressLogWorks.SetProgress("Exporting to LogWorks");
                    frmProgressLogWorks.Show();
                    System.Windows.Forms.Application.DoEvents();
                    try
                    {
                        difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale);
                    }
                    catch (Exception expE1)
                    {
                        logger.Debug(expE1.Message);
                    }
                    frmProgressLogWorks.Close();
                }
                else
                {

                    // show selection screen
                    frmPlotSelection plotsel = new frmPlotSelection();
                    foreach (SymbolHelper sh in sc)
                    {
                        plotsel.AddItemToList(sh.Varname);
                    }
                    plotsel.Startdate = startDate;
                    plotsel.Enddate = endDate;
                    plotsel.SelectAllSymbols();
                    if (plotsel.ShowDialog() == DialogResult.OK)
                    {
                        sc = plotsel.Sc;
                        endDate = plotsel.Enddate;
                        startDate = plotsel.Startdate;
                        DifGenerator difgen = new DifGenerator();
                        LogFilters filterhelper = new LogFilters();
                        difgen.SetFilters(filterhelper.GetFiltersFromRegistry());
                        difgen.AppSettings = m_appSettings;
                        //difgen.LowAFR = m_appSettings.WidebandLowAFR;
                        //difgen.HighAFR = m_appSettings.WidebandHighAFR;
                        //difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage;
                        //difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage;
                        difgen.WidebandSymbol = m_appSettings.WideBandSymbol;
                        //difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                        difgen.UseWidebandInput = false;

                        difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                        frmProgressLogWorks = new frmProgress();
                        frmProgressLogWorks.SetProgress("Exporting to LogWorks");
                        frmProgressLogWorks.Show();
                        System.Windows.Forms.Application.DoEvents();
                        try
                        {
                            if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, m_appSettings.InterpolateLogWorksTimescale))
                            {
                                StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif");
                            }
                            else
                            {
                                frmInfoBox info = new frmInfoBox("No data was found to export!");
                            }
                        }
                        catch (Exception expE2)
                        {
                            logger.Debug(expE2.Message);
                        }
                        frmProgressLogWorks.Close();
                    }
                    TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks);
                    //MessageBox.Show("LogFile should be " + ts.ToString());
                }
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
示例#33
0
        public ManagerForm(LogCache logCache, ApiData apiData)
        {
            LogCache = logCache ?? throw new ArgumentNullException(nameof(logCache));
            ApiData  = apiData ?? throw new ArgumentNullException(nameof(apiData));

            // Background processors
            var dpsReportUploader = new DpsReportUploader();

            UploadProcessor  = new UploadProcessor(dpsReportUploader, LogCache);
            ApiProcessor     = new ApiProcessor(ApiData, new Gw2Client());
            LogDataProcessor = new LogDataProcessor(LogCache, ApiProcessor, LogAnalytics);
            LogNameProvider  = new TranslatedLogNameProvider(GameLanguage.English);

            Filters = new LogFilters(new SettingsFilters());
            Filters.PropertyChanged += (sender, args) => logsFiltered.Refresh();

            if (Settings.UseGW2Api)
            {
                ApiProcessor.StartBackgroundTask();
            }

            Settings.UseGW2ApiChanged += (sender, args) =>
            {
                if (Settings.UseGW2Api)
                {
                    ApiProcessor.StartBackgroundTask();
                }
                else
                {
                    ApiProcessor.StopBackgroundTask();
                }
            };

            Settings.DpsReportDomainChanged += (sender, args) => { dpsReportUploader.Domain = Settings.DpsReportDomain; };

            // Form layout
            Icon       = Resources.GetProgramIcon();
            Title      = "arcdps Log Manager";
            ClientSize = new Size(1024, 768);
            var formLayout = new DynamicLayout();

            Content = formLayout;

            Menu = ConstructMenuBar();

            formLayout.BeginVertical(new Padding(5), yscale: false);
            {
                formLayout.Add(ConstructMainSplitter(), yscale: true);
                formLayout.Add(ConstructStatusPanel());
            }
            formLayout.EndVertical();

            // Event handlers
            ApiProcessor.Processed += (sender, args) =>
            {
                bool last = args.CurrentScheduledItems == 0;

                if (last)
                {
                    ApiData.SaveDataToFile();
                }
            };

            Settings.LogRootPathChanged += (sender, args) => Application.Instance.Invoke(ReloadLogs);

            Shown   += (sender, args) => ReloadLogs();
            Closing += (sender, args) =>
            {
                if (LogCache?.ChangedSinceLastSave ?? false)
                {
                    LogCache?.SaveToFile();
                }

                ApiData?.SaveDataToFile();
            };
            LogCollectionsRecreated += (sender, args) =>
            {
                logsFiltered.Filter = Filters.FilterLog;
                logsFiltered.Refresh();
            };
            LogSearchFinished += (sender, args) =>
            {
                var updates = LogDataUpdater.GetUpdates(logs).ToList();
                if (updates.Count > 0)
                {
                    new UpdateDialog(LogDataProcessor, updates).ShowModal(this);
                }
            };

            // Collection initialization
            RecreateLogCollections(new ObservableCollection <LogData>(logs));
        }