private void Window_Loaded(object sender, RoutedEventArgs e) { if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeployment.CurrentDeployment; this.Title += " (v. " + ad.CurrentVersion.ToString() + ")"; } this.varsCache.BindWithTextBox("consumer_key", this.consumerKeyTextbox); this.varsCache.BindWithTextBox("consumer_secret", this.consumerSecretTextbox); this.varsCache.BindWithTextBox("token", this.tokenTextbox); this.varsCache.BindWithTextBox("token_secret", this.tokenSecretTextbox); /* We use a "mother installation" for the first USOS API request. We need to * get a list of all USOS API installations. */ var motherInstallation = new ApiInstallation { base_url = "http://apps.usos.edu.pl/" // will change when out of Beta! }; this.apiConnector = new ApiConnector(motherInstallation); this.apiConnector.BeginRequest += new EventHandler(apiConnector_BeginRequest); this.apiConnector.EndRequest += new EventHandler(apiConnector_EndRequest); /* Fill up the installations list. */ try { this.installationsComboBox.Items.Clear(); var installations = this.apiConnector.GetInstallations(); installations.Add(new ApiInstallation() { base_url = "http://127.0.0.1:8000/" }); foreach (var installation in installations) { this.installationsComboBox.Items.Add(new ComboBoxItem { Content = installation.base_url, Tag = installation }); } } catch (WebException) { MessageBox.Show("Error occured when trying to access USOS API mother server. Could not populate USOS API installations list.", "Network error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } if (this.installationsComboBox.Items.Count > 0) { /* Now we have a list of all installations in a combo box. We choose * one of them. */ this.installationsComboBox.SelectedIndex = 0; this.ReloadInstallation(); } }
private void ReloadInstallation() { this.methodsTreeView.Items.Clear(); this.quickFillButton.IsEnabled = false; /* Checking which installation is selected in a combo box. */ if (this.apiConnector.currentInstallation.base_url != this.installationsComboBox.Text) { this.apiConnector.SwitchInstallation(new ApiInstallation { base_url = this.installationsComboBox.Text }); } if (!this.RefreshTree()) { return; } this.RefreshScopes(); /* We did retrieve the list of methods, so the installation URL is OK. If it was * entered manually (was not on the installation list in a combo box), then we add * it to the list. */ var onthelist = false; foreach (object item in this.installationsComboBox.Items) { ApiInstallation itemapi = (ApiInstallation)((ComboBoxItem)item).Tag; if (itemapi.base_url == this.apiConnector.currentInstallation.base_url) { onthelist = true; } } if (!onthelist) { this.installationsComboBox.Items.Add(new ComboBoxItem { Content = this.apiConnector.currentInstallation.base_url, Tag = this.apiConnector.currentInstallation }); } this.quickFillButton.IsEnabled = true; }
/// <summary> /// Switch connector to a different USOS API installation. /// </summary> public void SwitchInstallation(ApiInstallation apiInstallation) { this.currentInstallation = apiInstallation; }
/// <summary> /// Create new USOS API connector. /// </summary> /// <param name="installation"> /// USOS API Installation which to initally use. This can be /// switched later. /// </param> public ApiConnector(ApiInstallation installation) { this.currentInstallation = installation; }
/// <summary> /// Create new USOS API connector. /// </summary> /// <param name="installation"> /// USOS API Installation which to initally use. This can be /// switched later. /// </param> public ApiConnector(ApiInstallation installation) { this.currentInstallation = installation; }
/// <summary> /// Switch connector to a different USOS API installation. /// </summary> public void SwitchInstallation(ApiInstallation apiInstallation) { this.currentInstallation = apiInstallation; }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeployment.CurrentDeployment; this.Title += " (v. " + ad.CurrentVersion.ToString() + ")"; } this.varsCache.BindWithTextBox("consumer_key", this.consumerKeyTextbox); this.varsCache.BindWithTextBox("consumer_secret", this.consumerSecretTextbox); this.varsCache.BindWithTextBox("token", this.tokenTextbox); this.varsCache.BindWithTextBox("token_secret", this.tokenSecretTextbox); /* We use a "mother installation" for the first USOS API request. We need to * get a list of all USOS API installations. */ var motherInstallation = new ApiInstallation { base_url = "http://apps.usos.edu.pl/" // will change when out of Beta! }; this.apiConnector = new ApiConnector(motherInstallation); this.apiConnector.BeginRequest += new EventHandler(apiConnector_BeginRequest); this.apiConnector.EndRequest += new EventHandler(apiConnector_EndRequest); /* Fill up the installations list. */ try { this.installationsComboBox.Items.Clear(); var installations = this.apiConnector.GetInstallations(); installations.Add(new ApiInstallation() { base_url = "http://127.0.0.1:8000/" }); foreach (var installation in installations) { this.installationsComboBox.Items.Add(new ComboBoxItem { Content = installation.base_url, Tag = installation }); } } catch (WebException) { MessageBox.Show("Error occured when trying to access USOS API mother server. Could not populate USOS API installations list.", "Network error", MessageBoxButton.OK, MessageBoxImage.Exclamation); } if (this.installationsComboBox.Items.Count > 0) { /* Now we have a list of all installations in a combo box. We choose * one of them. */ this.installationsComboBox.SelectedIndex = 0; this.ReloadInstallation(); } }