Beispiel #1
0
        private static List <AvrDevice> GetAvrDevices(string query, bool getTunnelInfo)
        {
            List <AvrDevice> avrDevices = new List <AvrDevice>();

            foreach (var avrDevice in pgSqlSingleManager.ExecuteSQL(query))
            {
                AvrDevice newAvrDevice = new AvrDevice()
                {
                    id          = Int32.Parse(avrDevice["id"]),
                    ip          = avrDevice["ip"],
                    last_update = null
                };

                if (getTunnelInfo)
                {
                    newAvrDevice.tunnel = Tunnel.GetTunnel(Int32.Parse(avrDevice["tunnel"]));
                }

                if (avrDevice["last_update"] != "")
                {
                    newAvrDevice.last_update = DateTime.Parse(avrDevice["last_update"]);
                }

                avrDevices.Add(newAvrDevice);
            }
            return(avrDevices);
        }
Beispiel #2
0
        public static AvrDevice CreateAvrDevice(string ip, int tunnel)
        {
            AvrDevice lastAvrDevice = new AvrDevice()
            {
                id = GetMax("devices.avr_device")
            };

            pgSqlSingleManager.ExecuteSQL($"insert into devices.avr_device (id,ip,tunnel) " +
                                          $"values ({lastAvrDevice.id + 1},'{ip}',{tunnel})");

            return(AvrDevice.GetAvrDevice(lastAvrDevice.id + 1));
        }