Пример #1
0
        public void Fake()
        {
            sconnAuthorizedDevice zone = new sconnAuthorizedDevice();

            zone.Fake();
            Devices.Add(zone);
        }
Пример #2
0
 public void Deserialize(byte[] buffer)
 {
     try
     {
         Devices = new List <sconnAuthorizedDevice>();
         if (buffer.Length >= ipcDefines.SYS_ALARM_DEV_AUTH_MEM_SIZE)
         {
             for (int i = 0; i < ipcDefines.SYS_ALARM_DEV_AUTH_MAX_RECORDS; i++)
             {
                 byte[] authRecord = new byte[ipcDefines.SYS_ALRM_DEV_AUTH_LEN];
                 for (int j = 0; j < ipcDefines.SYS_ALRM_DEV_AUTH_LEN; j++)
                 {
                     authRecord[j] = buffer[i * ipcDefines.SYS_ALRM_DEV_AUTH_LEN + j];
                 }
                 sconnAuthorizedDevice dev = new sconnAuthorizedDevice(authRecord);
                 if (dev._Serial.Length > 0)
                 {
                     Devices.Add((dev));
                 }
             }
         }
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
     }
 }
Пример #3
0
        public void Test_AlarmSys_AuthConfig_WhenAskedCanNavigateForDifferentQuery_ThenReturnsFalse()
        {
            var email = new sconnAuthorizedDevice();

            var emailServiceMock = new Mock <AuthorizedDevicesConfigurationService>();
            //emailServiceMock
            //    .Setup(svc => svc.GetEmailDocument(email.Id))
            //   .Returns(email)
            //   .Verifiable();

            var viewModel = new AlarmAuthConfigViewModel();

            NavigationContext context = new NavigationContext(new Mock <IRegionNavigationService>().Object, new Uri("location", UriKind.Relative));

            context.Parameters.Add("EmailId", email.Id);

            ((INavigationAware)viewModel).OnNavigatedTo(context);

            context = new NavigationContext(new Mock <IRegionNavigationService>().Object, new Uri("location", UriKind.Relative));
            context.Parameters.Add("EmailId", new Guid());

            bool canNavigate =
                ((INavigationAware)viewModel).IsNavigationTarget(context);

            Assert.IsFalse(canNavigate);
        }
        public ActionResult Remove(sconnAuthorizedDevice Device)
        {
            AlarmSystemAddAuthorizedDeviceModel model = new AlarmSystemAddAuthorizedDeviceModel();

            this._provider = new AuthorizedDevicesConfigurationService(DomainSession.GetAlarmConfigForContextSession(this.HttpContext));
            var remRes = this._provider.Remove(Device);

            model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(remRes);
            return(View(model));
        }
Пример #5
0
 public bool Add(sconnAuthorizedDevice device)
 {
     try
     {
         ConfigManager.Config.AuthorizedDevices.Devices.Add(device);
         return(true);    //no adding -  filled with empty objects
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
         return(false);
     }
 }
Пример #6
0
 public sconnAuthorizedDevice GetById(int Id)
 {
     try
     {
         if (Online)
         {
             EntityManager.Download();
         }
         sconnAuthorizedDevice dev = ConfigManager.Config.AuthorizedDevices.Devices.FirstOrDefault(d => d.Id == Id);
         return(dev);
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
         return(null);
     }
 }
Пример #7
0
 public bool RemoveById(int Id)
 {
     try
     {
         sconnAuthorizedDevice dev = this.GetById(Id);
         if (dev != null)
         {
             return(this.Remove(dev));
         }
         return(false);
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
         return(false);
     }
 }
Пример #8
0
 public bool Update(sconnAuthorizedDevice device)
 {
     try
     {
         ConfigManager.Config.AuthorizedDevices.Devices
         .Where(z => z.Id == device.Id)
         .ToList()
         .ForEach(x =>
         {
             x._Serial       = device._Serial;
             x._Enabled      = device._Enabled;
             x._AllowedFrom  = device._AllowedFrom;
             x._AllowedUntil = device._AllowedUntil;
         }
                  );
         return(SaveChanges());
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
         return(false);
     }
 }
Пример #9
0
 public bool Remove(sconnAuthorizedDevice device)
 {
     try
     {
         if (Online)
         {
             // 'Remove' clears static record instead - replace with new empty record with the same Id
             sconnAuthorizedDevice stub = new sconnAuthorizedDevice();
             stub.Id = device.Id;
             this.Update(stub);
             return(SaveChanges());
         }
         else
         {
             this.ConfigManager.Config.AuthorizedDevices.Devices.Remove(device);
             return(true);
         }
     }
     catch (Exception e)
     {
         _logger.Error(e, e.Message);
         return(false);
     }
 }
Пример #10
0
 public AlarmSystemAddAuthorizedDeviceModel(sconnAuthorizedDevice Device)
 {
     this.AuthorizedDevice = Device;
 }