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"); } }
//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> /// sends the command to the server /// <param name="commandEnum"> represents the command</param> /// <param name="handler">the handler to remove</param> /// </summary> public void SendCommandToServer(CommandsEnum commandEnum, string handler) { string[] args = new string[1]; args[0] = handler; client.sendCommand((int)CommandsEnum.RemoveDirCommand, args); //CommandReceivedEventArgs e = new CommandReceivedEventArgs((int)CommandsEnum.GetConfigCommand, args, "Empty"); }
public void HandlerToDelete(string handler) { string[] args = new string[1]; args[0] = handler; client.sendCommand((int)CommandsEnum.RemoveDirCommand, args); }