GetOrInitConfigValue() public static method

public static GetOrInitConfigValue ( string napkinServerUri, string devicePath, string key, string defaultValue, NetworkCredential credential ) : string
napkinServerUri string
devicePath string
key string
defaultValue string
credential System.Net.NetworkCredential
return string
Beispiel #1
0
        public void UpdateDeviceLocation(bool force = false)
        {
            if (_deviceLocation != "???" && !force)
            {
                return;
            }

            _deviceLocation = ConfigUtil.GetOrInitConfigValue(_napkinServerUri, _deviceId, "device_location", "???", _credential);
            Debug.Print("Got device_location: " + _deviceLocation);
        }
Beispiel #2
0
        public void InitCycleDelayMilliseconds()
        {
            if (_cycleDelayMilliseconds != -1)
            {
                return;
            }

            string cycleDelayMillisecondsText = ConfigUtil.GetOrInitConfigValue(_napkinServerUri, _deviceId, "cycle_delay_milliseconds", _cycleDelayMillisecondsDefault.ToString(), _credential);

            try
            {
                _cycleDelayMilliseconds = int.Parse(cycleDelayMillisecondsText);
            }
            catch (Exception)
            {
                _cycleDelayMilliseconds = _cycleDelayMillisecondsDefault;
                Debug.Print("Error in InitCycleDelayMilliseconds: " + cycleDelayMillisecondsText);
            }
        }
Beispiel #3
0
        public void InitPostCycle()
        {
            if (_postCycle != -1)
            {
                return;
            }

            string postCycleText = ConfigUtil.GetOrInitConfigValue(_napkinServerUri, _deviceId, "post_cycle", _postCycleDefault.ToString(), _credential);

            try
            {
                _postCycle = int.Parse(postCycleText);
            }
            catch (Exception)
            {
                _postCycle = _postCycleDefault;
                Debug.Print("Error in InitPostCycle: " + postCycleText);
            }
        }
Beispiel #4
0
        public void UpdateDeviceStarts()
        {
            if (_deviceStartCountCurrent > -1)
            {
                return;
            }

            string deviceStartsText = ConfigUtil.GetOrInitConfigValue(_napkinServerUri, _deviceId, "device_start_count", "0", _credential);

            try
            {
                int deviceStartCountPrevious = int.Parse(deviceStartsText);
                _deviceStartCountCurrent = deviceStartCountPrevious + 1;

                ConfigUtil.PutConfigValue(_napkinServerUri + "/config/" + _deviceId, "device_start_count", _deviceStartCountCurrent.ToString(), _credential);
                Debug.Print("UpdateDeviceStarts updated device_start_count: " + _deviceStartCountCurrent);
            }
            catch (Exception)
            {
                Debug.Print("Error in UpdateDeviceStarts: " + deviceStartsText);
            }
        }