Esempio n. 1
0
        public StaticIPViewModel()
        {
            _saveButtonCommand = new DelegateCommand<string>(SaveButtonCommandExecute);
            _closeButtonCommand = new DelegateCommand<string>(CloseButtonCommandExecute);

            _configService = ConfigService.Instance;
            StaticIP = _configService.GetConfig("IpAddress", ConfigTypes.General) ?? "";
        }
Esempio n. 2
0
        private async void InitiliseServices()
        {
            try
            {
                _appTry++;
                _configService = ConfigService.Instance;
                //_configService.OnGeneralConfigUpdated += OnGeneralConfigUpdated;
                //_configService.OnRefreshDataConfigUpdated += OnRefreshDataConfigUpdated;

                _ipService = new IpService();
                var storedIp = _configService.GetConfig("IpAddress", ConfigTypes.General);
                var gatewayIp = "";
                if (string.IsNullOrEmpty(storedIp))
                {
                    gatewayIp = await _ipService.GetGatewayIp();
                    _configService.AppendConfig("IpAddress", gatewayIp, ConfigTypes.General);
                    _configService.CommitConfig(ConfigTypes.General);
                }
                else
                {
                    gatewayIp = await _ipService.ValidateIpAsync(storedIp);
                    _configService.AppendConfig("IpAddress", gatewayIp, ConfigTypes.General);
                    _configService.CommitConfig(ConfigTypes.General);

                }
                GatewayIp = gatewayIp;
                SearchingForIp = Visibility.Collapsed;
                ConnectionStatus = "Connected";
                ConnectedColor = Brushes.Green;
                _gatewayService = new GatewayService(gatewayIp);

                _gatewayService.OnZigbitUpdated += OnZigbitUpdated;

                await Task.Run(() => _gatewayService.StartDataCollection());

            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.BeginInvoke(
                   DispatcherPriority.Background,
                   new Action(() => AutoMeasurement.Client.TrackException("Initial execption: " + ex)));

                if (_appTry < 4)
                {
                    Application.Current.Dispatcher.BeginInvoke(
                       DispatcherPriority.Background,
                       new Action(InitiliseServices));
                }
                else
                {
                    Application.Current.Dispatcher.BeginInvoke(
                     DispatcherPriority.Background,
                     new Action(InitError));

                }

            }
        }