public IActionResult GatewayEthernet(EthernetGatewayViewModel model) { //prevent start wizard if already passed if (!bool.Parse(configuration["FirstRun"])) { return(View("Error", ALREADY_PASSED_MESSAGE)); } //redirect to first step if user came this url directly if (SystemController.dataBaseConfig == null) { return(RedirectToAction("Index")); } dynamic json = ReadConfig(); json.Gateway.EthernetGateway.GatewayIP = model.Ip; json.Gateway.EthernetGateway.GatewayPort = model.Port; json.Gateway.SerialGateway.Enable = false; json.Gateway.EthernetGateway.Enable = true; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.ReadConfig(); SystemController.ConnectToGateway(); return(RedirectToAction("UserProfile")); }
public IActionResult Gateway(string id) { //prevent start wizard if already passed if (!bool.Parse(configuration["FirstRun"])) { return(View("Error", ALREADY_PASSED_MESSAGE)); } //redirect to first step if user came this url directly if (SystemController.dataBaseConfig == null) { return(RedirectToAction("Index")); } if (id == "None") { dynamic json = ReadConfig(); json.Gateway.SerialGateway.Enable = false; json.Gateway.EthernetGateway.Enable = false; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.ReadConfig(); SystemController.ConnectToGateway(); return(RedirectToAction("UserProfile")); } if (id == "Serial") { ViewBag.ports = SerialConnectionPort.GetAvailablePorts(); return(View("GatewaySerial", new SerialGatewayViewModel { PortName = configuration["Gateway:SerialGateway:SerialPortName"], Boudrate = Int32.Parse(configuration["Gateway:SerialGateway:Boudrate"]) })); } if (id == "Ethernet") { return(View("GatewayEthernet", new EthernetGatewayViewModel { Ip = configuration["Gateway:EthernetGateway:GatewayIP"], Port = Int32.Parse(configuration["Gateway:EthernetGateway:GatewayPort"]) })); } return(View()); }
public IActionResult EthernetGateway(EthernetGatewayViewModel model) { dynamic json = ReadConfig(); json.Gateway.EthernetGateway.GatewayIP = model.Ip; json.Gateway.EthernetGateway.GatewayPort = model.Port; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.gatewayConfig.EthernetGateway.GatewayIP = model.Ip; SystemController.gatewayConfig.EthernetGateway.GatewayPort = model.Port; return(RedirectToAction("Index")); }
public bool DisconnectGateway() { dynamic json = ReadConfig(); json.Gateway.SerialGateway.Enable = false; json.Gateway.EthernetGateway.Enable = false; WriteConfig(json); configuration.Reload(); SystemController.gatewayConfig.SerialGateway.Enable = false; SystemController.gatewayConfig.EthernetGateway.Enable = false; SystemController.DisconnectGateway(); return(true); }
public IActionResult SerialGateway(SerialGatewayViewModel model) { if (String.IsNullOrEmpty(model.PortName)) { return(RedirectToAction("SerialGateway")); } dynamic json = ReadConfig(); json.Gateway.SerialGateway.SerialPortName = model.PortName; json.Gateway.SerialGateway.Boudrate = model.Boudrate; WriteConfig(json); configuration.Reload(); SystemController.DisconnectGateway(); SystemController.gatewayConfig.SerialGateway.SerialPortName = model.PortName; SystemController.gatewayConfig.SerialGateway.Boudrate = model.Boudrate; return(RedirectToAction("Index")); }
public async Task <bool> ConnectEthernetGateway() { SystemController.DisconnectGateway(); dynamic json = ReadConfig(); json.Gateway.SerialGateway.Enable = false; json.Gateway.EthernetGateway.Enable = true; WriteConfig(json); configuration.Reload(); SystemController.gatewayConfig.SerialGateway.Enable = false; SystemController.gatewayConfig.EthernetGateway.Enable = true; await Task.Run((() => { SystemController.ConnectToGateway(); })); return(true); }