private static void StartServer() { repositoryType = ConfigHelper.GetRepositorySetting(); generatorType = ConfigHelper.GetGeneratorSetting(); Console.WriteLine("Initializing system..."); system = Factory.GenerateOMS(repositoryType, generatorType); Console.WriteLine("System ready."); Console.WriteLine("Creating connection..."); connection = new Connection(system); Console.WriteLine("Connection ready."); Console.WriteLine("Starting server..."); bool result = connection.Open(); if (result) { Console.WriteLine("Server online."); Console.ReadKey(true); Console.WriteLine("Shutting down server..."); connection.Close(); Console.WriteLine("Server offline."); } else { Console.WriteLine("Server failed to start."); Console.ReadKey(true); } }
private void XPDF_Click(object sender, RoutedEventArgs e) { try { Response <PDFReport> response = oms.GenerateReport(((Outage)XOutages.SelectedItem).Id); if (response.Status == ResponseStatus.OK) { SaveFileDialog dialog = new SaveFileDialog(); dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.Title = "Generate PDF Report"; dialog.AddExtension = true; dialog.DefaultExt = ".pdf"; dialog.Filter = "PDF files(*.pdf)|*.pdf"; dialog.FileName = response.Data.FileName; if (dialog.ShowDialog() == true) { File.WriteAllBytes(dialog.FileName, response.Data.BinaryData); } } else { MessageBox.Show($"Error: {response.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show($"Server error: {ex.Message}", "Server error", MessageBoxButton.OK, MessageBoxImage.Error); oms = Connection.GenerateChannel(); } }
public OutageWindow(IOutageManagementSystem oms, WindowMode mode, int id) { this.oms = oms; this.mode = mode; this.id = id; InitializeComponent(); InitializeWindow(); DataContext = Outage; }
private void CreateOutage() { try { Response <int> response = oms.Insert(Outage); if (response.Status == ResponseStatus.OK) { Close(); } else { MessageBox.Show($"Error: {response.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show($"Server error: {ex.Message}", "Server error", MessageBoxButton.OK, MessageBoxImage.Error); oms = Connection.GenerateChannel(); } }
private void GetOutage() { try { Response <Outage> response = oms.Get(id); if (response.Status == ResponseStatus.OK) { Outage = response.Data; Outage.Actions = new List <ExecutedAction>(response.Data.Actions); } else { MessageBox.Show($"Error: {response.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Close(); } } catch (Exception ex) { MessageBox.Show($"Server error: {ex.Message}", "Server error", MessageBoxButton.OK, MessageBoxImage.Error); oms = Connection.GenerateChannel(); Close(); } }
private void XSearch_Click(object sender, RoutedEventArgs e) { try { string startDate = XStartDate.SelectedDate.HasValue ? XStartDate.SelectedDate.ToString() : string.Empty; string endDate = XEndDate.SelectedDate.HasValue ? XEndDate.SelectedDate.ToString() : string.Empty; Response <IEnumerable <Outage> > response = oms.FindByDate(startDate, endDate); if (response.Status == ResponseStatus.OK) { XStatus.Content = $"Search returned {response.Data.Count()} results"; XOutages.ItemsSource = response.Data; } else { MessageBox.Show($"Information: {response.Message}", "Information", MessageBoxButton.OK, MessageBoxImage.Information); XOutages.ItemsSource = null; } } catch (Exception ex) { MessageBox.Show($"Server error: {ex.Message}", "Server error", MessageBoxButton.OK, MessageBoxImage.Error); oms = Connection.GenerateChannel(); } }
public Connection(IOutageManagementSystem outageManagementSystem) { host = new ServiceHost(outageManagementSystem); }