private async Task DownLoadEventLogRecordsInBackground()
        {
            Part_OperationNameLbl.Content              = "Загрузка событий";
            Part_OperationNameLbl.Visibility           = Visibility.Visible;
            Part_OperationProgresPercentLbl.Visibility = Visibility.Visible;

            Part_OperationProgressProgBar.Visibility      = Visibility.Visible;
            Part_OperationProgressProgBar.IsIndeterminate = false;
            Part_OperationProgressProgBar.Value           = 0;
            Part_OperationProgressProgBar.Minimum         = 0;

            String dir = System.IO.Path.Combine(AppConfig.FolderPathOf.RootStorageFolder, AppConfig.FolderPathOf.EventLogRecordsFolder);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            DateTime currentDate = DateTime.Now.TruncateToDay() - TimeSpan.FromHours(2);
            DateTime endDate     = currentDate + TimeSpan.FromDays(2);
            DateTime?startDate   = null;
            Int32?   totalDays   = null;
            var      progress    = new Progress <int>(value => Part_OperationProgressProgBar.Value = value);

            await Task.Run(() =>
            {
                List <EventLogRecord> eventLogRecords = Client.GetEventLogRecords(offset: 0, limit: 1, orderDate: "asc").Items;
                if (eventLogRecords != null && eventLogRecords.Count > 0)
                {
                    startDate = eventLogRecords.First().DateTime;
                    totalDays = (Int32)Math.Floor((endDate - (DateTime)startDate).TotalDays);
                }
                if (totalDays == null)
                {
                    return;
                }
                for (int dayOffset = 0; dayOffset < totalDays;)
                {
                    DateTime timeIntervalStart = (DateTime)startDate + TimeSpan.FromDays(dayOffset);
                    LoadEventLogBy(timeIntervalStart, dir);
                    ((IProgress <int>)progress).Report(++dayOffset);
                    Dispatcher.Invoke(() =>
                    {
                        Part_OperationProgressProgBar.Maximum = (Int32)totalDays;
                        //Part_OperationProgressProgBar.Value = ;
                        Part_OperationNameLbl.Content = $"Загрузка событий ({totalDays - dayOffset})";
                        Double percent = (Double)dayOffset * 100.00 / (Double)totalDays;
                        Part_OperationProgresPercentLbl.Content = $"{percent:00.00} %";
                    });
                }
            });

            Part_OperationNameLbl.Content              = "Загрузка событий завершена";
            Part_OperationNameLbl.Visibility           = Visibility.Collapsed;
            Part_OperationProgressProgBar.Visibility   = Visibility.Collapsed;
            Part_OperationProgresPercentLbl.Visibility = Visibility.Collapsed;
        }
Exemple #2
0
        public static void ShowEventLogs(SkeliaClient client)
        {
            List <EventLogRecord> eventLogRecords = client.GetEventLogRecords(new DateTime(2019, 12, 21, 10, 09, 19), new DateTime(2019, 12, 21, 10, 09, 21)).Items;

            foreach (var r in eventLogRecords)
            {
                Console.WriteLine($"{r.DateTime:yyyy.MM.dd HH:mm:ss} - {r.Description}");
            }
        }