//private static string password; static void Main(string[] args) { ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; RegistryTableItem registryTableItem = new RegistryTableItem(); registryTableItem.Id = 11; registryTableItem.Active = "false"; var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://localhost:8080/api/registry/lodgingRegistry"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; httpWebRequest.UseDefaultCredentials = true; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = "{\"id\" : \"11\",\"active\" : \"true\"}"; string json2 = registryTableItem.ToJSON(); streamWriter.Write(json2); streamWriter.Flush(); streamWriter.Close(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); Console.WriteLine(result); Console.ReadLine(); } }
private void RegistryDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { checkTime(); //RegistryItemActivationButton.IsEnabled = true; try { string content = "Activate"; RegistryTableItem registryTableItem = RegistryDataGrid.SelectedItem as RegistryTableItem; if (registryTableItem.Active.Equals("Yes")) { content = "Deactivate"; } RegistryItemActivationButton.Content = content; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { RegistryTableItem registryTableItem = new RegistryTableItem(); registryTableItem.Name = NewItemTextBox.Text; registryTableItem.Active = "true"; try { Client.AddToRegistry(registry, registryTableItem); parent.LoadRegistryTableItems(); this.Close(); }catch (Exception ex) { MessageBox.Show("Invalid new input"); Console.WriteLine(ex.ToString()); } }
private void RegistryItemActivation_Click(object sender, RoutedEventArgs e) { checkTime(); RegistryTableItem registryTableItem = null; try { registryTableItem = new RegistryTableItem(RegistryDataGrid.SelectedItem as RegistryTableItem); } catch (Exception ex) { return; } string registryName = registriesDictionary[RegistryNameCheckbox.Text]; Client.UpdateRegistry(registryName, registryTableItem); LoadRegistryTableItems(); }
public static void UpdateRegistry(String registryName, RegistryTableItem registryTableItem) { var httpWebRequest = (HttpWebRequest)WebRequest.Create(url + "/registry/" + registryName + "Registry"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; httpWebRequest.UseDefaultCredentials = true; httpWebRequest.Headers.Add("Authorization", "Bearer " + userToken); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(registryTableItem.ToJSON()); streamWriter.Flush(); streamWriter.Close(); } using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { Console.WriteLine(reader.ReadToEndAsync()); } }