/// <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) { 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; }
/// <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(); } }