/// <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) { ToggleMainWindowButtons(false); ProgressBarDialog progressBar = GetInput.ShowProgressBarDialog("Getting Device Info", 5, "Searching for devices..."); 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."; progressBar.Close(); return; } //outputField.Text = GAM.GetDeviceId(deviceInputField.Text); BasicDeviceInfo deviceInfo = GAM.GetDeviceId(deviceInputField.Text); Globals.ClearGlobals(); // clear the globals before adding new ones Globals.SetGlobalsFromBasicDeviceInfo(deviceInfo); if (deviceInfo.Error) { outputField.Text = deviceInfo.ErrorText; progressBar.Close(); return; } await progressBar.UpdateBarAndText(30, "Getting more device info..."); BasicDeviceInfo fullDeviceInfo = GAM.GetAllDeviceInfo(deviceInfo.DeviceId); fullDeviceInfo.LastSync = !string.IsNullOrEmpty(deviceInfo.LastSync) ? deviceInfo.LastSync : null; fullDeviceInfo.DeviceId = deviceInfo.DeviceId; fullDeviceInfo.SerialNumber = !string.IsNullOrEmpty(deviceInfo.SerialNumber) ? deviceInfo.SerialNumber : null; fullDeviceInfo.Status = !string.IsNullOrEmpty(deviceInfo.Status) ? deviceInfo.Status : null; fullDeviceInfo.User = !string.IsNullOrEmpty(deviceInfo.User) ? deviceInfo.User : null; await progressBar.UpdateBarAndText(40, "Saving variables..."); Globals.SetGlobalsFromBasicDeviceInfo(fullDeviceInfo); await progressBar.UpdateBarAndText(55, "Populating fields..."); if (!String.IsNullOrEmpty(fullDeviceInfo.Notes)) { NoteField.Text = fullDeviceInfo.Notes; } else { NoteField.Text = ""; } if (!String.IsNullOrEmpty(fullDeviceInfo.AssetId)) { AssetIdField.Text = fullDeviceInfo.AssetId; } else { AssetIdField.Text = ""; } if (!String.IsNullOrEmpty(fullDeviceInfo.Location)) { LocationField.Text = fullDeviceInfo.Location; } else { LocationField.Text = ""; } if (!String.IsNullOrEmpty(fullDeviceInfo.User)) { UserField.Text = fullDeviceInfo.User; } else { UserField.Text = ""; } if (!String.IsNullOrEmpty(fullDeviceInfo.OrgUnitPath)) { OrganizationalUnitField.Text = fullDeviceInfo.OrgUnitPath; } else { OrganizationalUnitField.Text = ""; } if (!String.IsNullOrEmpty(fullDeviceInfo.Status)) { switch (fullDeviceInfo.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; } } await progressBar.UpdateBarAndText(85, "Filling in output box..."); outputField.Text = "Found device. ID: " + fullDeviceInfo.DeviceId + "."; if (!String.IsNullOrEmpty(fullDeviceInfo.SerialNumber)) { outputField.Text += "\nSerial Number: " + fullDeviceInfo.SerialNumber; } if (!String.IsNullOrEmpty(fullDeviceInfo.LastSync)) { outputField.Text += "\nLast Sync: " + fullDeviceInfo.LastSync; } await progressBar.UpdateBarAndText(100, "Done!"); ToggleMainWindowButtons(true); progressBar.Close(); //deviceInputField.Text = deviceId; }