Пример #1
0
        static void TestDb()
        {
            using (var db = new Database.RegistryContext())
            {
                db.Add(new Database.Device()
                {
                    comPort        = "COM2",
                    deviceCategory = "arduino",
                    deviceName     = "power management tool"
                });
                db.SaveChanges();

                db.Add(new Database.Event()
                {
                    dateTime  = DateTime.Now,
                    cathegory = "GREEN",
                    location  = "zone - 2",
                    _event    = "door closed",
                    telemetry = new Database.Telemetry()
                    {
                        temperature  = 30,
                        humidity     = 100,
                        illumination = 200
                    }
                });
                db.SaveChanges();

                db.Add(new Database.Error()
                {
                    dateTime = DateTime.Now,
                    _error   = "windows works fine!"
                });
                db.SaveChanges();
            }
        }
Пример #2
0
 public async void RecordToLog(string cathegory, string zone, string logMessage)
 {
     try
     {
         await using (var db = new Database.RegistryContext())
         {
             db.Add(new Database.Event()
             {
                 dateTime  = DateTime.Now,
                 cathegory = cathegory,
                 location  = zone,
                 _event    = logMessage,
                 telemetry = new Database.Telemetry()
                 {
                     temperature  = 30,
                     humidity     = 100,
                     illumination = 200
                 }
             });
             db.SaveChanges();
         }
     }
     catch
     {
         ;
     }
 }
Пример #3
0
 public async void RecordToLog(string errorMsg)
 {
     await using (var db = new Database.RegistryContext())
     {
         try
         {
             db.Add(new Database.Error()
             {
                 dateTime = DateTime.Now,
                 _error   = errorMsg
             });
             db.SaveChanges();
         }
         catch
         {
             ;
         }
     }
 }