Example #1
0
        public async Task <IActionResult> CreateSmartApp(OauthInfo authInfo)
        {
            if (ModelState.IsValid == false)
            {
                return(View(authInfo));
            }

            var conn = new SmartThingsConnection();

            if (await conn.Login(authInfo.STUserId, authInfo.STPassword) == false)
            {
                ModelState.AddModelError("STPassword", "Could not connect to smart things using the supplied credentials");
                return(View("Index", authInfo));
            }

            var cs = new DeviceTypeRepository(conn, "j64 Alarm", $"{myEnv.WebRootPath}/../SmartThingApps/j64AlarmDevice.groovy");
            var ss = new DeviceTypeRepository(conn, "j64 Contact Zone", $"{myEnv.WebRootPath}/../SmartThingApps/j64ContactZoneDevice.groovy");
            var mz = new DeviceTypeRepository(conn, "j64 Motion Zone", $"{myEnv.WebRootPath}/../SmartThingApps/j64MotionZoneDevice.groovy");
            var pd = new DeviceTypeRepository(conn, "j64 Partition", $"{myEnv.WebRootPath}/../SmartThingApps/j64PartitionDevice.groovy");

            var jal = new SmartAppRepository(conn, "j64 Alarm", $"{myEnv.WebRootPath}/../SmartThingApps/j64AlarmSmartApp.groovy");

            // Save the client/secret keys
            var oauth = OauthRepository.Get();

            oauth.clientKey = jal.clientKey;
            oauth.secretKey = jal.secretKey;
            OauthRepository.Save(oauth);

            return(View("Index", oauth));
        }
        public AddEquipment(FormStatus status)
        {
            _status     = status;
            _equipment  = new EquipmentRepository();
            _devicetype = new DeviceTypeRepository();

            InitializeComponent();
        }
Example #3
0
        public void GetAllTest()
        {
            // arrange

            // act
            var repository = new DeviceTypeRepository().GetAll();

            // assert
            Assert.IsTrue(repository.Count > 0);
        }
Example #4
0
 public UnitOfWork(FuzionDbContext ctx)
 {
     _ctx              = ctx;
     Devices           = new DeviceRepository(_ctx);
     DeviceTypes       = new DeviceTypeRepository(_ctx);
     Manufacturers     = new ManufacturerRepository(_ctx);
     Models            = new ModelRepository(_ctx);
     Notes             = new NoteRepository(_ctx);
     OS                = new OSRepository(_ctx);
     Purposes          = new PurposeRepository(_ctx);
     AssignmentHistory = new AssignmentRepository(_ctx);
 }
        public DeviceTypeIdentifier(string connectionString)
        {
            // Get device types from the database
            DeviceTypeRepository _dtRepo = new DeviceTypeRepository(connectionString);

            _deviceTypes = _dtRepo.GetAllDictionary();

            DeviceTypeMappingRepository _dtmRepo = new DeviceTypeMappingRepository(connectionString);

            _modelMappings.Clear();
            foreach (DeviceTypeMapping dtm in _dtmRepo.GetAll())
            {
                _modelMappings.Add(dtm.ModelString.ToLower(), dtm.DeviceTypeID);
            }
        }
Example #6
0
        public async Task <IActionResult> CreateSmartApp(OauthViewModel authInfo)
        {
            if (ModelState.IsValid == false)
            {
                return(View(authInfo));
            }

            var conn = new SmartThingsConnection();

            if (await conn.Login(authInfo.STUserId, authInfo.STPassword) == false)
            {
                ModelState.AddModelError("STPassword", "Could not connect to smart things using the supplied credentials");
                return(View("Index", authInfo));
            }

            var cs = new DeviceTypeRepository(conn, "j64 Channel Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64ChannelSwitchDevice.groovy");
            var ss = new DeviceTypeRepository(conn, "j64 Surfing Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64SurfingSwitchDevice.groovy");
            var vs = new DeviceTypeRepository(conn, "j64 VCR Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64VcrSwitchDevice.groovy");
            var os = new DeviceTypeRepository(conn, "j64 Volume Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64VolumeSwitchDevice.groovy");
            var cc = new DeviceTypeRepository(conn, "j64 Custom Command Switch", $"{myEnv.WebRootPath}/../SmartThingApps/j64CustomCommandSwitchDevice.groovy");

            var har = new SmartAppRepository(conn, "j64 Harmony", $"{myEnv.WebRootPath}/../SmartThingApps/j64HarmonySmartApp.groovy");

            // Save the client/secret keys
            var oauth = OauthRepository.Get();

            oauth.clientKey = har.clientKey;
            oauth.secretKey = har.secretKey;
            OauthRepository.Save(oauth);

            var ovm = new OauthViewModel()
            {
                ClientKey = oauth.clientKey,
                SecretKey = oauth.secretKey
            };

            return(View("Index", ovm));
        }
Example #7
0
 public DeviceTypeService()
 {
     _deviceTypeRepository = new DeviceTypeRepository();
 }
Example #8
0
 public DeviceTypeList()
 {
     _devicetype = new DeviceTypeRepository();
     InitializeComponent();
 }
Example #9
0
 public DeviceTypeController(DeviceTypeRepository deviceTypeRepository)
 {
     this.deviceTypeRepository = deviceTypeRepository;
 }