public string ToJsonString()
        {
            WindowsTelemetryDataContract.DesiredProperties desiredProperties = new WindowsTelemetryDataContract.DesiredProperties();

            switch (LevelComboBox.SelectedIndex)
            {
            case 0:
                desiredProperties.level = WindowsTelemetryDataContract.JsonSecurity;
                break;

            case 1:
                desiredProperties.level = WindowsTelemetryDataContract.JsonBasic;
                break;

            case 2:
                desiredProperties.level = WindowsTelemetryDataContract.JsonEnhanced;
                break;

            case 3:
                desiredProperties.level = WindowsTelemetryDataContract.JsonFull;
                break;

            default:
                MessageBox.Show("Not implemented! Selected 'security'.");
                break;
            }
            return(desiredProperties.ToJsonString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set windows telemetry setting via device twin.
        /// </summary>
        private async void SetDesiredButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            WindowsTelemetryDataContract.DesiredProperties desiredProperties = new WindowsTelemetryDataContract.DesiredProperties();

            switch (DesiredCombobox.SelectedIndex)
            {
            case 0:
                desiredProperties.level = WindowsTelemetryDataContract.JsonSecurity;
                break;

            case 1:
                desiredProperties.level = WindowsTelemetryDataContract.JsonBasic;
                break;

            case 2:
                desiredProperties.level = WindowsTelemetryDataContract.JsonEnhanced;
                break;

            case 3:
                desiredProperties.level = WindowsTelemetryDataContract.JsonFull;
                break;

            default:
                _mainPage.ShowDialogAsync("Invaid Input", "Desired value not selected! Selected 'security'.");
                break;
            }

            string refreshingValue = "\"refreshing\"";
            string finalValue      = "{" + desiredProperties.ToJsonString() + "}";
            await _mainPage.UpdateTwinData(refreshingValue, finalValue);
        }