protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); ImageWebModel model = ImageWebModel.GetModel(); CommandsController cc = new CommandsController(model); ComunicationClient client = ComunicationClient.GetClient(8000); client.CommandReceived += delegate(object senderObj, CommandReceivedEventArgs args) { JsonCommand jCommand = args.JsonCommand; cc.ExecuteCommand(jCommand.CommandID, jCommand.Args, jCommand.JsonData); }; try { client.ConnectToServer(); client.sendCommand((int)CommandsEnum.GetConfigCommand, null); client.sendCommand((int)CommandsEnum.LogsCommand, null); } catch { Console.WriteLine("failed to connect to server"); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (this.IsEnabled == true) { ComunicationClient.GetClient(8000).sendCommand((int)CommandsEnum.CloseCommand, null); } }
//important!!!!!!!!!!!! //we are sorry we didn't implement the mvvm for the main window as we should, we didn't have enough time to fix it. //we are aware of this mistake //but we implemented the mvvm for the other modules public MainWindow() { InitializeComponent(); this.DataContext = new ViewModels.MainWindowViewModel(); ComunicationClient client = ComunicationClient.GetClient(8000); Controller controller = new Controller(LogModel.getModel(), SettingsModel.getModel()); try { client.ConnectToServer(); string[] strs = { }; client.CommandReceived += delegate(object senderObj, CommandReceivedEventArgs args) { App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { JsonCommand jCommand = args.JsonCommand; controller.ExecuteCommand(jCommand.CommandID, jCommand.Args, jCommand.JsonData); }); }; client.sendCommand((int)CommandsEnum.GetConfigCommand, strs); client.sendCommand((int)CommandsEnum.LogsCommand, strs); } catch { this.Background = Brushes.Gray; this.IsEnabled = false; } }
/// <summary> /// the constructor /// </summary> private SettingsModel() { outputDirectory = "Output Directory:"; sourceName = "Source Name:"; logName = "Log Name:"; thumbnailSize = "Thumbnail Size:"; directoriesCollection = new ObservableCollection <string>(); client = ComunicationClient.GetClient(8000); //Object locker = new object(); //BindingOperations.EnableCollectionSynchronization(directoriesCollection, locker); }
public string GetServiceStatus() { ComunicationClient client = ComunicationClient.GetClient(8000); if (client.isConnected()) { return("active"); } else { return("inactive"); } }
private ImageWebModel() { client = ComunicationClient.GetClient(8000); }