Beispiel #1
0
        public UserModel AddUserData(RegistRequestDto request)
        {
            //rsa解密
            var code = SecurityRsa.Decrypt(request.Password);

            if (code is null)
            {
                return(null);
            }
            //查找用户
            if (_context.User.Find(request.UserName) != null)
            {
                return(null);
            }
            var newUser = new UserModel
            {
                UserName = request.UserName,
                Email    = request.Email,
                Password = SecurityAes.Encrypt(code),
                Role     = request.Role.ToLower()
            };

            _context.User.Add(newUser);
            _context.SaveChanges();
            return(newUser);
        }
Beispiel #2
0
        public bool InitRoom(string deviceEUI)
        {
            Context.Measurement measurement = null;
            try
            {
                measurement = context.Measurement.AsEnumerable().Where(r => r.DeviceEui.Equals(deviceEUI)).Last();
            }
            catch (InvalidOperationException e)
            {
            }

            if (measurement != null)
            {
                Context.Room roomForDevice = null;

                try {
                    roomForDevice = context.Room.AsEnumerable().Where(r => r.DeviceEui.Equals(deviceEUI)).Last();
                }
                catch (InvalidOperationException e) {
                }

                if (roomForDevice == null)
                {
                    Context.Settings newSettings = new Context.Settings();
                    newSettings.TemperatureSetpoint = temperatureSetPoint;
                    newSettings.PpmMax      = ppmMax;
                    newSettings.PpmMin      = ppmMin;
                    newSettings.LastUpdated = DateTime.UtcNow;

                    context.Settings.Add(newSettings);
                    context.SaveChanges();

                    Context.Room newRoom = new Context.Room();
                    newRoom.DeviceEui  = deviceEUI;
                    newRoom.Name       = "New device";
                    newRoom.SettingsId = newSettings.SettingsId;
                    context.Room.Add(newRoom);
                    context.SaveChanges();
                }
                return(true);
            }
            return(false);
        }
Beispiel #3
0
 public EnvironmentMockupRepository(EnvironmentContext context)
 {
     _context = context;
     if (context.Environments.Count() == 0)
     {
         EnvDeployment env = new EnvDeployment {
             Ticket     = "69311",
             Type       = "44423",
             Env        = "Test_Environment 3",
             Start_time = "6/30/2016 9:13:32 AM",
             User_id    = "*****@*****.**",
             Shortdes   = "Test - RFC 332260 - WI 10377"
         };
         EnvDeployment env2 = new EnvDeployment
         {
             Ticket     = "69309",
             Type       = "44419",
             Env        = "Test_Environment 2",
             Start_time = "6/30/2017 9:13:32 AM",
             User_id    = "*****@*****.**",
             Shortdes   = "Test_Environment Update launcher"
         };
         EnvDeployment curEnv1 = new EnvDeployment
         {
             Ticket     = "69300",
             Id         = "44423",
             Env        = "Test_Environment",
             Start_time = "6/30/2016 9:13:32 AM",
             User_id    = "*****@*****.**",
             Shortdes   = "Test_Environment (CS 154377)"
         };
         EnvDeployment curEnv2 = new EnvDeployment
         {
             Ticket     = "69309",
             Id         = "44419",
             Env        = "Test_Environment2",
             Start_time = "6/30/2017 9:13:32 AM",
             User_id    = "*****@*****.**",
             Shortdes   = "Test_Environment RFC 233245 WI 45674 Update launcher reference for monitoring"
         };
         _context.Environments.AddRange(env);
         _context.Environments.AddRange(env2);
         _context.CurrentEnvironments.AddRange(curEnv1);
         _context.CurrentEnvironments.AddRange(curEnv2);
         _context.SaveChanges();
     }
 }
Beispiel #4
0
        public Context.Settings PostSettings(Context.Settings settings)
        {
            var entity = context.Settings.FirstOrDefault(item => item.SettingsId == settings.SettingsId);

            if (entity != null)
            {
                entity.PpmMax = settings.PpmMax;
                entity.PpmMin = settings.PpmMin;
                entity.TemperatureSetpoint = settings.TemperatureSetpoint;
                entity.LastUpdated         = DateTime.UtcNow;
                entity.SettingsId          = settings.SettingsId;
                entity.SentToDevice        = null;
                context.Settings.Update(entity);
                context.SaveChanges();
            }
            Context.Settings student = context.Settings.FirstOrDefault(item => item.SettingsId == settings.SettingsId);
            return(student);
        }
 public void AddEnvironment(Repository.Models.Environment environment)
 {
     _context.Environments.Add(environment);
     _context.SaveChanges();
 }