internal void FillExpression(ViewModel.PropertyFilters propertyFiltersViewModel,
                                     TimeSpan startPeriodTime,
                                     TimeSpan endPeriodTime)
        {
            AddExpression <Filters.FilterAppCodes>(propertyFiltersViewModel.FilterAppCodes, "AppCode");
            AddExpression <Filters.FilterComputerCodes>(propertyFiltersViewModel.FilterComputerCodes, "ComputerCode");
            AddExpression <Filters.FilterEventCodes>(propertyFiltersViewModel.FilterEventCodes, "EventCode");
            AddExpression <Filters.FilterUserCodes>(propertyFiltersViewModel.FilterUserCodes, "UserCode");
            AddExpression <Filters.FilterMetadataCodes>(propertyFiltersViewModel.FilterMetadataCodes, "MetadataCodes", true);

            if (propertyFiltersViewModel.StartPeriodDate.Date != new DateTime(1, 1, 1))
            {
                AddExpression("Date",
                              ComparsionType.GreaterThanOrEqual,
                              GetDateSQLite(propertyFiltersViewModel.StartPeriodDate.Date, startPeriodTime));
            }

            if (propertyFiltersViewModel.EndPeriodDate.Date != new DateTime(1, 1, 1))
            {
                AddExpression("Date",
                              ComparsionType.LessThanOrEqual,
                              GetDateSQLite(propertyFiltersViewModel.EndPeriodDate.Date, endPeriodTime));
            }

            if (propertyFiltersViewModel.CommentIsFilled)
            {
                AddExpression("Comment", ComparsionType.NotEqual, "");
            }
        }
        private void InitializeProperties()
        {
            GridLoadData.DataContext        = this;
            ProgressBarLoadData.DataContext = this;

            _propertyFiltersViewModel       = new ViewModel.PropertyFilters();
            GridPropertyFilters.DataContext = _propertyFiltersViewModel;
            GridFilterEventLog.DataContext  = _propertyFiltersViewModel;

            _filterEventLogViewModel   = new ViewModel.FilterEventLog();
            GridEventLogs.DataContext  = _filterEventLogViewModel;
            GridTextFilter.DataContext = _filterEventLogViewModel;

            TimeControlStartPeriod.Value = new TimeSpan(0, 0, 0);
            TimeControlEndPeriod.Value   = new TimeSpan(23, 59, 59);

            GetDataDB(initializeReaderContext: false);
        }
        public async void GetEventLog(EF.ReaderContext readerContext,
                                      PropertyFilters propertyFilters,
                                      TimeSpan timeStart,
                                      TimeSpan timeEnd)
        {
            var filterExpression = GetExpressionFilterLogs(propertyFilters, timeStart, timeEnd);

            List <Filters.FilterEventLog> list = new List <Filters.FilterEventLog>();

            var repoEventLogs = new EF.Repository <Models.EventLog>(readerContext);
            List <Models.EventLog> eventLogs = await repoEventLogs.GetListTakeAsync(
                filterExpression,
                f => f.OrderBy(o => - o.RowID),
                propertyFilters.CountEventLogRows);

            foreach (Models.EventLog eventLog in eventLogs)
            {
                string appName      = propertyFilters.FilterAppCodesBase.FirstOrDefault(f => f.Code == eventLog.AppCode)?.Name;
                string computerName = propertyFilters.FilterComputerCodesBase.FirstOrDefault(f => f.Code == eventLog.ComputerCode)?.Name;
                string userName     = propertyFilters.FilterUserCodesBase.FirstOrDefault(f => f.Code == eventLog.UserCode)?.Name;
                string eventName    = propertyFilters.FilterEventCodesBase.FirstOrDefault(f => f.Code == eventLog.EventCode)?.Name;

                string metadataName = string.IsNullOrWhiteSpace(eventLog.MetadataCodes)
                    ? string.Empty
                    : propertyFilters.FilterMetadataCodesBase.FirstOrDefault(f => f.Code == int.Parse(eventLog.MetadataCodes))?.Name;

                list.Add(
                    new Filters.FilterEventLog(eventLog)
                {
                    ComputerName = computerName,
                    AppName      = appName,
                    UserName     = userName,
                    EventName    = eventName,
                    MetadataName = metadataName
                });
            }

            SetSource(list);
        }