Пример #1
0
        static async Task StartAsync(string[] args)
        {
            Logger.LogDebug("Starting service monitor...");
            var client = new ServiceMonitorWebAPIClient();
            var serviceWatcherItemsResponse = default(ServiceWatchResponse);

            try
            {
                serviceWatcherItemsResponse = await client.GetServiceWatcherItemsAsync();
            }
            catch (Exception ex)
            {
                Logger.LogError("Error on retrieve watch items: {0}", ex);
                return;
            }

            foreach (var item in serviceWatcherItemsResponse.Model)
            {
                var watcherType     = Assembly.GetEntryAssembly().GetType(item.TypeName);
                var watcherInstance = Activator.CreateInstance(watcherType) as IWatcher;
                await Task.Factory.StartNew(async() =>
                {
                    var controller = new MonitorController(Logger, watcherInstance, client, AppSettings);
                    await controller.ProcessAsync(item);
                });
            }
        }
Пример #2
0
        public MonitorView()
        {
            _controller = new MonitorController(this);
            _controller.OnProcessCreate += OnProcessCreate;

            InitializeComponent();

            PaintTabControl();
        }
Пример #3
0
        public MonitorView()
        {
            _controller = new MonitorController(this);
            _controller.OnProcessCreate += OnProcessCreate;

            InitializeComponent();

            PaintTabControl();
        }
Пример #4
0
        static async Task StartAsync(string[] args)
        {
            logger.LogDebug("Starting application...");

            var initializer = new ServiceMonitorInitializer(appSettings);

            try
            {
                await initializer.LoadResponseAsync();
            }
            catch (Exception ex)
            {
                logger.LogError("Error on retrieve watch items: {0}", ex);
                return;
            }

            try
            {
                initializer.DeserializeResponse();
            }
            catch (Exception ex)
            {
                logger.LogError("Error on deserializing object: {0}", ex);
                return;
            }

            foreach (var item in initializer.Response.Model)
            {
                var watcherType = Type.GetType(item.TypeName, true);

                var watcherInstance = Activator.CreateInstance(watcherType) as IWatcher;

                var task = Task.Factory.StartNew(async() =>
                {
                    var controller = new MonitorController(appSettings, logger, watcherInstance, initializer.RestClient);

                    await controller.ProcessAsync(item);
                });
            }
        }