예제 #1
0
 public ICommand Create(int pin, int? value, string host, string type)
 {
     try
     {
         ICommand c = new Command(-1, pin, value, host, type, 0);
         if (value == null) return c;
         var cm = new command()
         {
             command_pin = pin,
             command_value = value,
             command_host = host,
             command_type = type
         };
         DbContext db = new DbContext();
         db.command.Add(cm);
         db.SaveChanges();
         c.CommandId = cm.commandid;
         return c;
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
     }
     return null;
 }
예제 #2
0
파일: Command.cs 프로젝트: skohub/Sh
 public void SetComplete()
 {
     using (var db = new DbContext())
     {
         var c = db.command.Find(CommandId);
         if (c == null) return;
         c.command_status = 1;
         db.SaveChanges();
     }
 }
예제 #3
0
 public ISensorValue Create(int pin, decimal value, string host, string type)
 {
     try
     {
         ISensorValue sv = new SensorValue() {sensorid = pin, sensor_value = value, host = host, tipe = type};
         using (var db = new DbContext())
         {
             var svm = new sensor_value() {sensorid = pin, sensor_value1 = value, host = host, tipe = type};
             db.sensor_value.Add(svm);
             db.SaveChanges();
         }
         return sv;
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
     }
     return null;
 }
예제 #4
0
 public void MarkAllComplete()
 {
     try
     {
         using (var db = new DbContext())
         {
             var r = db.command
                 .Where(n => n.command_status == 0)
                 .ToList();
             foreach (var c in r)
             {
                 c.command_status = 1;
             }
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Logger.Error(e.Message);
     }
 }