Ejemplo n.º 1
0
 private void SetMode(ModeDefinitions mode)
 {
     using (var seekiosEntities = new seekios_dbEntities())
     {
         // set device
         //var deviceDb = seekiosEntities.device.FirstOrDefault(x => x.iddevice == ID_DEVICE);
         //if (deviceDb != null)
         //{
         //    deviceDb = new device()
         //    {
         //        countryCode = "fr",
         //        deviceName = "deviceUnitTest",
         //        doNotDisturb = 1,
         //        macAdress = string.Empty,
         //        notificationPlayerId = string.Empty,
         //        os = "iOS",
         //        plateform = "iOS",
         //        uidDevice = Guid.NewGuid().ToString(),
         //        user_iduser =
         //    };
         //}
         // update the mode
         if (seekiosEntities.mode.Any(x => x.seekios_idseekios == ID_SEEKIOS))
         {
             seekiosEntities.mode
             .Where(x => x.seekios_idseekios == ID_SEEKIOS)
             .OrderBy(x => x.idmode)
             .Take(1)
             .Update(x => new mode()
             {
                 modeDefinition_idmodeDefinition = (int)mode
             });
         }
         else
         {
             // add the mode
             var modeToAdd = new mode
             {
                 device_iddevice                     = ID_DEVICE,
                 countOfTriggeredAlert               = 0,
                 dateModeCreation                    = DateTime.UtcNow,
                 lastTriggeredAlertDate              = null,
                 modeDefinition_idmodeDefinition     = (int)mode,
                 seekios_idseekios                   = ID_SEEKIOS,
                 statusDefinition_idstatusDefinition = (int)StatusDefinition.RAS,
                 trame = "1"
             };
             seekiosEntities.mode.Add(modeToAdd);
             seekiosEntities.SaveChanges();
         }
     }
 }
Ejemplo n.º 2
0
 private void RemoveAllSeekiosInstructions()
 {
     using (var seekiosEntities = new seekios_dbEntities())
     {
         // remove all seekios instruction
         seekiosEntities.seekiosInstruction
         .Where(x => x.seekiosProduction_idseekiosProduction == ID_SEEKIOS)
         .Delete(x => x.BatchSize = 1000);
         // add a new seekios instruction (it's require because of this line in the SES :
         // if (onDemandInstructionDate == null || onDemandInstructionDate.Add(_onDemandResponseTimeout) < DateTime.UtcNow)
         var seekiosInstructionToAdd = new seekiosInstruction()
         {
             dateCreation    = DateTime.UtcNow,
             instructionType = (int)InstructionType.OnDemand,
             instruction     = "#M02&",
             seekiosProduction_idseekiosProduction = ID_SEEKIOS
         };
         seekiosEntities.seekiosInstruction.Add(seekiosInstructionToAdd);
         seekiosEntities.SaveChanges();
     }
 }