/// <summary> /// Essentially, run GAM.GetDeviceId() on whatever is entered into the text field. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SubmitDeviceId_Click(object sender, RoutedEventArgs e) { ToggleMainWindowButtons(false); if (deviceInputField.Text.Length < 1 || deviceInputField.Text.ToLower() == "enter a device id, serial number, query string or email...") { outputField.Text = "You must enter something into the field at the top."; return; } //outputField.Text = GAM.GetDeviceId(deviceInputField.Text); IsLoading = true; string input = deviceInputField.Text; List <BasicDeviceInfo> possibleDevices = await Task.Run(() => GAM.GetDeviceId(input)); BasicDeviceInfo deviceInfo = BasicDeviceInfo.HandleGetDeviceId(possibleDevices); Globals.ClearGlobals(); // clear the globals before adding new ones Globals.SetGlobalsFromBasicDeviceInfo(deviceInfo); if (deviceInfo.Error) { outputField.Text = deviceInfo.ErrorText; return; } outputField.Text = "Found device. ID: " + deviceInfo.DeviceId + "."; if (!String.IsNullOrEmpty(deviceInfo.SerialNumber)) { outputField.Text += "\nSerial Number: " + deviceInfo.SerialNumber; } if (!String.IsNullOrEmpty(deviceInfo.Notes)) { outputField.Text += "\nNotes: " + deviceInfo.Notes; } if (!String.IsNullOrEmpty(deviceInfo.LastSync)) { outputField.Text += "\nLast Sync: " + deviceInfo.LastSync; } if (!String.IsNullOrEmpty(deviceInfo.AssetId)) { outputField.Text += "\nAsset ID: " + deviceInfo.AssetId; } if (!String.IsNullOrEmpty(deviceInfo.Location)) { outputField.Text += "\nLocation: " + deviceInfo.Location; } if (!String.IsNullOrEmpty(deviceInfo.User)) { outputField.Text += "\nUser: "******"\nStatus: " + deviceInfo.Status; } IsLoading = false; //deviceInputField.Text = deviceId; }
/// <summary> /// Essentially, run GAM.GetDeviceId() on whatever is entered into the text field. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async void SubmitDeviceId_Click(object sender, RoutedEventArgs e) { try { IsLoading = true; AutoComplete.Close(deviceInputFieldStack); if (deviceInputField.Text.Length < 1 || deviceInputField.Text.ToLower() == "enter a device id, asset id, serial number, query string or email...") { outputField.Text = "You must enter something into the field at the top."; return; } string input = deviceInputField.Text; List <BasicDeviceInfo> possibleDevices = await Task.Run(() => GAM.GetDeviceId(input)); BasicDeviceInfo deviceInfo = BasicDeviceInfo.HandleGetDeviceId(possibleDevices); Globals.ClearGlobals(); // clear the globals before adding new ones Globals.SetGlobalsFromBasicDeviceInfo(deviceInfo); if (deviceInfo.Error) { outputField.Text = deviceInfo.ErrorText; return; } Globals.SetGlobalsFromBasicDeviceInfo(deviceInfo); NoteField.Text = !string.IsNullOrEmpty(deviceInfo.Notes) ? deviceInfo.Notes : ""; AssetIdField.Text = !string.IsNullOrEmpty(deviceInfo.AssetId) ? deviceInfo.AssetId : ""; LocationField.Text = !string.IsNullOrEmpty(deviceInfo.Location) ? deviceInfo.Location : ""; UserField.Text = !string.IsNullOrEmpty(deviceInfo.User) ? deviceInfo.User : ""; OrganizationalUnitField.Text = !string.IsNullOrEmpty(deviceInfo.OrgUnitPath) ? deviceInfo.OrgUnitPath : ""; if (!String.IsNullOrEmpty(deviceInfo.Status)) { switch (deviceInfo.Status) { case "ACTIVE": StatusActiveRadio.IsChecked = true; StatusDisabledRadio.IsEnabled = true; StatusActiveRadio.IsEnabled = true; StatusDeprovisionedRadio.IsEnabled = true; break; case "DISABLED": StatusDisabledRadio.IsChecked = true; StatusDisabledRadio.IsEnabled = true; StatusActiveRadio.IsEnabled = true; StatusDeprovisionedRadio.IsEnabled = true; break; case "DEPROVISIONED": StatusDeprovisionedRadio.IsChecked = true; StatusDeprovisionedRadio.IsEnabled = false; StatusActiveRadio.IsChecked = false; StatusActiveRadio.IsEnabled = false; StatusDisabledRadio.IsChecked = false; StatusDisabledRadio.IsEnabled = false; break; } } outputField.Text = "Found device. ID: " + deviceInfo.DeviceId + "."; if (!String.IsNullOrEmpty(deviceInfo.SerialNumber)) { outputField.Text += "\nSerial Number: " + deviceInfo.SerialNumber; } if (!String.IsNullOrEmpty(deviceInfo.LastSync)) { outputField.Text += "\nLast Sync: " + deviceInfo.LastSync; } AutoComplete.AddItemToList(input); IsLoading = false; //deviceInputField.Text = deviceId; } catch (Exception err) { Debug.CaptureRichException(err, CollectFieldsForRichException()); Debug.ShowErrorMessage(); } }