PageRenderTime 3ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/SyncServiceTestHarness/MainWindow.xaml.cs

https://bitbucket.org/SeanCole/trendtool
C# | 114 lines | 85 code | 16 blank | 13 comment | 2 complexity | d4e830cec14f776d9822f45ae0828cec MD5 | raw file
  1using System;
  2using System.Windows;
  3using System.Windows.Data;
  4using System.Configuration;
  5using TechneauxDataSyncService;
  6using Serilog;
  7using Serilog.Core;
  8using System.Reactive.Linq;
  9using TechneauxDataSyncService.Main;
 10
 11using System.Collections.Generic;
 12using System.ComponentModel;
 13using System.Configuration;
 14using System.IO;
 15using System.Linq;
 16using System.Reactive.Linq;
 17using System.Threading;
 18using System.Threading.Tasks;
 19using System.Xml.Serialization;
 20
 21namespace SyncServiceTestHarness
 22{
 23    /// <summary>
 24    /// Interaction logic for MainWindow.xaml
 25    /// </summary>
 26    public partial class MainWindow : Window
 27    {
 28        public MainWindow()
 29        {
 30            InitializeComponent();
 31            Loaded += MainWindow_Loaded;
 32            Closed += MainWindow_Closed;
 33        }
 34
 35        private void MainWindow_Closed(object sender, EventArgs e)
 36        {
 37            FileCheckSServ?.CancelAll();
 38        }
 39
 40        NewFileCheckService FileCheckSServ;
 41        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
 42        {
 43            TechneauxDataSyncService.ServiceOps.LogAllOpResults = true;
 44
 45            Observable.Interval(TimeSpan.FromMinutes(1))
 46              .ObserveOnDispatcher()
 47              .Subscribe(evt =>
 48              {
 49                  UpdatePointListView();
 50              });
 51            Observable.Interval(TimeSpan.FromMinutes(1))
 52                .ObserveOnDispatcher()
 53                .Subscribe(evt =>  {
 54                    UpdateSyncView();
 55                });
 56
 57            //var logLevelSwitch = new LoggingLevelSwitch(Serilog.Events.LogEventLevel.Warning);
 58            var LoggingLevelAttr = System.Configuration.ConfigurationManager.AppSettings.Get("LogLevelConfig");
 59            Serilog.Events.LogEventLevel newLevel = (Serilog.Events.LogEventLevel)Enum.Parse(typeof(Serilog.Events.LogEventLevel), LoggingLevelAttr);
 60            var logLevelSwitch = new LoggingLevelSwitch(newLevel);
 61            Log.Logger = new LoggerConfiguration()
 62                .MinimumLevel.ControlledBy(logLevelSwitch)
 63                .WriteTo
 64                .RollingFile($@"{AppDomain.CurrentDomain.BaseDirectory}\Logs\General Sync Service Log.txt", shared: true)
 65                .CreateLogger();
 66
 67            var ThisExePath = Environment.CurrentDirectory;
 68            var ThisConfigPath = $@"{ThisExePath}\ServiceConfigs\";
 69            FileCheckSServ = new NewFileCheckService(ThisConfigPath, true);
 70            DataContext = FileCheckSServ;
 71        
 72            await FileCheckSServ.RunNewFileCheck();
 73        }
 74
 75
 76        private void PointListForSelectedFile_TargetUpdated(object sender, DataTransferEventArgs e)
 77        {
 78            UpdatePointListView();
 79
 80        }
 81
 82        private void UpdatePointListView()
 83        {
 84            //for (int i = 0; i < ConfigGridView.Columns.Count; i++)
 85            //{
 86            //    PointViewGrid.Columns[i].Width = 0;
 87            //}
 88
 89            //for (int j = 0; j < PointViewGrid.Columns.Count; j++)
 90            //{
 91            //    PointViewGrid.Columns[j].Width = double.NaN;
 92            //}
 93        }
 94
 95        private void UpdateSyncView()
 96        {
 97            for (int i = 0; i < ConfigGridView.Columns.Count; i++)
 98            {
 99                ConfigGridView.Columns[i].Width = 0;
100            }
101            // ConfigGridView.
102
103            for (int j = 0; j < ConfigGridView.Columns.Count; j++)
104            {
105                ConfigGridView.Columns[j].Width = double.NaN;
106            }
107        }   
108
109        private void ListOfSyncFileUtility_TargetUpdated(object sender, DataTransferEventArgs e)
110        {
111            UpdateSyncView();
112        }
113    }
114}