public void HandleInput(string json) { try { JObject data = JObject.Parse(json); switch ((string)data.GetValue("message_type")) { case "start_app": TableApp app = TableAppManager.GetAppById((string)data.GetValue("app")); Program.tableAppManager.LaunchApp(app); CustomInterface customInterface = app.GetCustomInterface(); Send("{\"message_type\": \"show_interface\", \"app\": {\"name\": \"" + app.GetName().Replace("TableApp", "") + "\", \"id\": \"" + app.GetName() + "\"}, \"interface\": {\"items\": " + customInterface.toJson() + "}}"); break; case "input": JObject input = JObject.Parse(data["input"].ToString()); Program.tableAppManager.GetCurrentApp() .OnCustomInterfaceInput((string)input.GetValue("id"), (string)input.GetValue("value")); break; } } catch (Exception e) { Program.LogFullLength(TAG, "Parsing received message failed! " + e.ToString()); } }
public FBase() { InitializeComponent(); try { FactoryConnection = new RepositoryInjection().GetClass <IFactoryConnection>(); _tableApp = new TableApp(FactoryConnection); AutomaticNumberingApp = new AutomaticNumberingApp(FactoryConnection); } catch (Exception) { } }
public static void TriggerInput(string key) { TableApp.InputKey inputKey = TableApp.GetCorrespondingKey(key); if (inputKey != TableApp.InputKey.Unknown) { tableAppManager.GetCurrentApp().OnInputMade(inputKey); } else if (key.Contains("custom")) { string[] keyValue = key.Split('.')[1].Split('='); tableAppManager.GetCurrentApp().OnCustomInterfaceInput(keyValue[0], keyValue[1]); } else { tableAppManager.GetCurrentApp().OnRawInput(key); } }
protected override void Configure() { _kernel = new StandardKernel(); _kernel.Bind<IPasswordManager>().To<PasswordManager>().InSingletonScope(); _kernel.Bind<IAccessProvider>().To<AccessProvider>().InSingletonScope(); _kernel.Bind<ILogInStrategy>().To<LogInStrategy>().InSingletonScope(); _kernel.Bind<ITableConnectionProvider>().To<TableConnectionProvider>().InSingletonScope(); RegisterViewModels(); var tableApp = new TableApp(); _kernel.Bind<ITableApp>().ToConstant(tableApp); _kernel.Bind<ITableAppSubscriber>().ToConstant(tableApp); _kernel.Bind<ICurrentOrder>().To<CurrentOrder>().InSingletonScope(); UseViewAttribute.ConfigureViewLocator(); }
public void UpdateAppList(TableApp[] apps) { string json = string.Empty; json += "{\"message_type\": \"app_list\", \"apps\": ["; for (int i = 0; i < apps.Length; i++) { TableApp app = apps[i]; if (!app.selectable) { continue; } var name = app.GetName().Replace("TableApp", ""); StringBuilder newText = new StringBuilder(name.Length * 2); newText.Append(name[0]); for (int j = 1; j < name.Length; j++) { if (char.IsUpper(name[j]) && name[j - 1] != ' ') { newText.Append(' '); } newText.Append(name[j]); } name = newText.ToString(); json += "{\"id\": \"" + app.GetName() + "\", \"name\": \"" + name + "\", \"features\": " + JObject.FromObject(app.GetFeatures()).ToString() + "}"; if (i < apps.Length - 1) { json += ","; } } json += "]}"; Send(json); }
public void ExecuteCommand(string command) { command = command.Trim(); string argument = string.Empty; if (command.Contains(' ')) { argument = command.Substring(command.IndexOf(' ')); command = command.Substring(0, command.IndexOf(' ')); } if (command.StartsWith("GET")) { string key = ""; string[] headerLines = argument.Split('\n'); foreach (string line in headerLines) { if (line.Contains("Sec-WebSocket-Key:")) { key = line.Replace("Sec-WebSocket-Key: ", "").Trim(); break; } } Program.LogFullLength("MAGIC", "The WebSocket Sec-Key is: '" + key + "'"); Send("HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Accept: " + AcceptKey(ref key) + "\r\n\r\n"); } else if (command.Contains("stop")) { ShutdownServer(); } else if (command.Contains("serial") && !string.IsNullOrWhiteSpace(argument)) { Program.serialController.Write(argument.Trim()); } else if (command.Contains("init")) { Program.tableAppManager.LaunchApp(new TableAppIdle()); string appList = string.Empty; for (int i = 0; i < TableAppManager.apps.Length; i++) { TableApp a = TableAppManager.apps[i]; if (a.selectable) { appList += a.GetName() + ":" + (int)a.userInterface + "|"; } } Send("setup " + appList.Trim('|').Trim()); } else if (command.Contains("input") && !string.IsNullOrWhiteSpace(argument)) { Program.TriggerInput(argument.Trim()); } else if (command.Contains("app") && !string.IsNullOrWhiteSpace(argument)) { Program.tableAppManager.LaunchApp(Apps.TableAppManager.GetAppById(argument.Trim())); } else if (command.Contains("renderer") && !string.IsNullOrWhiteSpace(argument)) { Program.CreateRenderer(argument.Trim()); } else if (command.Contains("help")) { Send("Help - List of commands\n"); Send("stop - Shutdown the server\n"); Send("serial [command] - Run a serial command\n"); Send("init - Get a list of apps\n"); Send("input [input] - Triggers an input event. e.g. pad_start\n"); Send("app [name] - Starts an app. e.g. TableAppIdle\n"); Send("renderer [name] - Changes the renderer. e.g. remote\n"); Send("help - Shows this list of commands\n"); Send("#######################"); } else { Send("Command " + command + " not found. Run 'help' for a list of commands"); } }
public TableController(IFactoryConnection connection) { _connection = connection; _TableApp = new TableApp(connection); }
public FLogin(SplashScreen splash) { _splashScreen = splash; var ri = new RepositoryInjection(); var conn = ri.GetClass <IFactoryConnection>(); _userApp = new UserApp(conn); _companyApp = new CompanyApp(conn); _translateApp = new TranslateApp(conn); _tableApp = new TableApp(conn); _dbTableApp = new DbTableApp(conn); _automaticNumberingApp = new AutomaticNumberingApp(conn); _userController = new UserController(conn); GlobalUser.Forms = _tableApp.Search().ToList(); GlobalUser.Translates = _translateApp.Search().ToList(); GlobalUser.Tables = _dbTableApp.Search().ToList(); GlobalUser.AutomaticNumberings = _automaticNumberingApp.Search().ToList(); InitializeComponent(); Unidade.ObjetoApp = new InvokeMethod(typeof(CompanyController), TypeExecute.SearchAll, "ListCompany", typeof(Company)); Unidade.DisplayMember = "PersonName"; Unidade.ValueMember = "Id"; Unidade.Enabled = false; Unidade.Refresh(); Unidade.SComponent.DropDown += SComponentOnDropDown; Unidade.Caption = "Unidade"; EntrarButton.SComponent.BackColor = Color.DarkSlateGray; EntrarButton.SComponent.ForeColor = Color.White; EntrarButton.SComponent.Text = @"Entrar"; EntrarButton.SComponent.Click += EntrarButton_Click; EntrarButton.Enabled = false; SenhaTextBox.SComponent.PasswordChar = '*'; SenhaTextBox.Caption = "Senha"; SenhaTextBox.SComponent.TextChanged += SenhaComponentOnTextChanged; UsuarioTextBox.SComponent.TextChanged += UsuarioComponentOnTextChanged; UsuarioTextBox.Caption = "Login"; var cont = false; if (_companyApp.Search().Any()) { if (!_userApp.Search().Any()) { MessageBox.Show(@"Necessário cadastrar um usuário", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); var fuser = new FUser { StateForm = StateForm.Inserting, ClosedAfterSave = true }; fuser.RefreshControls(); ((User)fuser.CurrentControl).IsAdministrator = true; _splashScreen.Close(); fuser.ShowDialog(); } return; } ; MessageBox.Show(@"Este é o seu primeiro acesso ao sistema, por favor, cadastre sua empresa.", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); do { var fcompany = new FCompany() { StateForm = StateForm.Inserting, ClosedAfterSave = true }; fcompany.RefreshControls(); _splashScreen.Close(); fcompany.ShowDialog(); if (!_companyApp.Search().Any()) { cont = MessageBox.Show(@"Necessário cadastrar uma empresa, deseja continuar ?", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; } } while (cont); if (!_companyApp.Search().Any()) { Close(); } else { if (_userApp.Search().Any()) { return; } MessageBox.Show(@"Necessário cadastrar um usuário", @"BEM VINDO AO ESR SOFTWARES", MessageBoxButtons.OK); var fuser = new FUser { ClosedAfterSave = true, StateForm = StateForm.Inserting, }; ((User)fuser.CurrentControl).IsAdministrator = true; _splashScreen.Close(); fuser.ShowDialog(); } }