Пример #1
0
        private void AddPropertyForMapperAndDevice(sconnConfigMapper maper, Device edited, int DevNo)
        {
            try
            {
                iotRepository <DeviceProperty> proprepo = new iotRepository <DeviceProperty>();
                DeviceProperty prop = new DeviceProperty();
                prop.PropertyName   = "Input" + maper.SeqNumber;  //TODO read from name cfg
                prop.Device         = edited;
                prop.LastUpdateTime = DateTime.Now;
                proprepo.Add(prop);
                List <DeviceProperty> storeprops = proprepo.GetAll().ToList();
                DeviceProperty        storedProp = (from s in storeprops
                                                    where s.PropertyName == prop.PropertyName
                                                    select s).First();

                //create parameter and bind mapper to it
                iotRepository <DeviceParameter> paramrepo = new iotRepository <DeviceParameter>();
                DeviceParameter param = new DeviceParameter();
                param.Value    = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[DevNo]);
                param.Type     = ParamTypeForSconnMapper(maper);
                param.Property = storedProp;
                paramrepo.Add(param);
                List <DeviceParameter> storeparams = paramrepo.GetAll().ToList();
                DeviceParameter        storedParam = (from p in storeparams
                                                      where p.Property == param.Property
                                                      select p).First();

                maper.Parameter = storedParam;
                iotRepository <sconnConfigMapper> mapperRepo = new iotRepository <sconnConfigMapper>();
                mapperRepo.Add(maper);
            }
            catch (Exception e)
            {
            }
        }
Пример #2
0
        /****  LOAD ****/

        public void TestEntityDbWriteLoad()
        {
            try
            {
                int       ReadTestInterations = 5;
                int       maxQueryTimeMs      = 25;
                Stopwatch watch = new Stopwatch();
                watch.Start();
                for (int i = 0; i < ReadTestInterations; i++)
                {
                    iotRepository <Location> locrepo = new iotRepository <Location>();
                    Location loc = new Location();
                    loc.LocationName = Guid.NewGuid().ToString();
                    loc.Lat          = 0;
                    loc.Lng          = 0;
                    locrepo.Add(loc);
                }
                watch.Stop();
                double TimePerQueryMs = watch.ElapsedMilliseconds / ReadTestInterations;
                Assert.IsTrue(TimePerQueryMs < maxQueryTimeMs);
            }
            catch (Exception ex)
            {
                Assert.Fail();
            }
        }
Пример #3
0
        public void TestRepoUpdate()
        {
            iotRepository <Location> repo = new iotRepository <Location>();
            //get
            List <Location> locs = repo.GetAll().ToList();
            //add if required
            Location loc = new Location();

            if (locs != null)
            {
                loc.LocationName = Guid.NewGuid().ToString();
                loc.Lat          = 0;
                loc.Lng          = 0;
                repo.Add(loc);
                //update
                locs = repo.GetAll().ToList();
                loc  = locs.Where(l => { return(l.LocationName == loc.LocationName); }).First();
                Location StoredBefore = repo.GetById(loc.Id);
                StoredBefore.Lat = 53.325241;
                repo.Update(StoredBefore);
                //verify
                Location stored = repo.GetById(loc.Id);
                Assert.IsTrue(loc.Lat == stored.Lat);
            }
        }
Пример #4
0
        public void TestConnectorRepo()
        {
            iotRepository <iotDomain> repo    = new iotRepository <iotDomain>();
            List <iotDomain>          domains = repo.GetAll().ToList();

            Assert.IsTrue(domains != null);
        }
Пример #5
0
 public void TestEntityDbReadLoad()
 {
     try
     {
         int  ReadTestInterations = 250;
         int  maxQueryTimeMs      = 25;
         bool ReadSuccess         = false;
         int  FailCount           = 0;
         TestRepoCreate();
         Stopwatch watch = new Stopwatch();
         iotRepository <iotDomain> repo    = new iotRepository <iotDomain>();
         List <iotDomain>          domains = repo.GetAll().ToList();
         iotDomain domain = domains.First();
         watch.Start();
         for (int i = 0; i < ReadTestInterations; i++)
         {
             ReadSuccess = TestRepoSingleRead(domain.Id);
             if (!ReadSuccess)
             {
                 FailCount++;
             }
         }
         watch.Stop();
         double TimePerQueryMs = watch.ElapsedMilliseconds / ReadTestInterations;
         Assert.IsTrue(TimePerQueryMs < maxQueryTimeMs);
     }
     catch (Exception ex)
     {
         Assert.Fail();
     }
 }
Пример #6
0
        public void TestRepoRead()
        {
            iotRepository <Location> repo = new iotRepository <Location>();
            List <Location>          locs = repo.GetAll().ToList();

            Assert.IsTrue(locs != null);
        }
Пример #7
0
 public List <Device> GetAllDevice()
 {
     try
     {
         iotRepository <Device> repo = new iotRepository <Device>();
         return(repo.GetAll().ToList());
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #8
0
 public EndpointInfo EndpointWithId(int id)
 {
     try
     {
         iotRepository <EndpointInfo> repo = new iotRepository <EndpointInfo>();
         return(repo.GetById(id));
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(new EndpointInfo());
     }
 }
Пример #9
0
 public DeviceCredentials DeviceCredentialWithId(int id)
 {
     try
     {
         iotRepository <DeviceCredentials> repo = new iotRepository <DeviceCredentials>();
         return(repo.GetById(id));
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(new DeviceCredentials());
     }
 }
Пример #10
0
 public ActionParameter ActionParamWithId(int id)
 {
     try
     {
         iotRepository <ActionParameter> repo = new iotRepository <ActionParameter>();
         return(repo.GetById(id));
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(new ActionParameter());
     }
 }
Пример #11
0
 public iotDomain DomainWithId(int id)
 {
     try
     {
         iotRepository <iotDomain> repo = new iotRepository <iotDomain>();
         return(repo.GetById(id));
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(new iotDomain());
     }
 }
Пример #12
0
 public int AddDevice(Device Device)
 {
     try
     {
         iotRepository <Device> repo = new iotRepository <Device>();
         repo.Add(Device);
         return(Device.Id);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #13
0
 public bool UpdateDevice(Device Device)
 {
     try
     {
         iotRepository <Device> repo = new iotRepository <Device>();
         repo.Update(Device);
         return(true);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #14
0
 public Device GetDevice(string id)
 {
     try
     {
         int DeviceId = Convert.ToInt32(id);
         iotRepository <Device> repo = new iotRepository <Device>();
         return(repo.GetById(DeviceId));
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #15
0
 public bool TestRepoSingleRead(int id)
 {
     try
     {
         iotRepository <Location> repo = new iotRepository <Location>();
         Location locs = repo.GetById(id);
         return(locs != null);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Пример #16
0
        public void TestRepoCreate()
        {
            iotRepository <iotDomain> locrepo = new iotRepository <iotDomain>();
            iotDomain dm = new iotDomain();

            dm.DomainName = Guid.NewGuid().ToString();
            dm.Sites      = new List <Site>();
            locrepo.Add(dm);
            List <iotDomain> locs = locrepo.GetAll().ToList();

            Assert.IsTrue(locs.Contains(dm));
            locrepo.Delete(dm);
        }
Пример #17
0
 public DeviceType DeviceTypeWithId(int id)
 {
     try
     {
         iotRepository <DeviceType> repo = new iotRepository <DeviceType>();
         return(repo.GetById(id));
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(new DeviceType());
     }
 }
Пример #18
0
 public bool SiteUpdate(Site domain)
 {
     try
     {
         iotRepository <Site> repo = new iotRepository <Site>();
         repo.Update(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #19
0
 public bool ActionUpdate(DeviceAction domain)
 {
     try
     {
         iotRepository <DeviceAction> repo = new iotRepository <DeviceAction>();
         repo.Update(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #20
0
 public bool ResParamUpdate(DeviceParameter domain)
 {
     try
     {
         iotRepository <DeviceParameter> repo = new iotRepository <DeviceParameter>();
         repo.Update(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #21
0
        /******************* Add ***********************/

        public bool DeviceAdd(Device dev)
        {
            try
            {
                iotRepository <Device> repo = new iotRepository <Device>();
                repo.Add(dev);
                return(true);
            }
            catch (Exception e)
            {
                nlogger.ErrorException(e.Message, e);
                return(false);
            }
        }
Пример #22
0
 public bool PropertyRemove(DeviceProperty domain)
 {
     try
     {
         iotRepository <DeviceProperty> repo = new iotRepository <DeviceProperty>();
         repo.Delete(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #23
0
        public String GetSomeJson()
        {
            try
            {
            }
            catch (Exception ex)
            {
                _logger.ErrorException(ex.Message, ex);
            }
            iotRepository <Device> repo = new iotRepository <Device>();
            Device dev = repo.GetById(52);

            return(JsonConvert.SerializeObject(dev));
        }
Пример #24
0
 public bool ReqParamRemove(ActionParameter domain)
 {
     try
     {
         iotRepository <ActionParameter> repo = new iotRepository <ActionParameter>();
         repo.Delete(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #25
0
 public bool LocationRemove(Location domain)
 {
     try
     {
         iotRepository <Location> repo = new iotRepository <Location>();
         repo.Delete(domain);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #26
0
 public bool ActionAdd(DeviceAction action)
 {
     try
     {
         iotRepository <DeviceAction> repo = new iotRepository <DeviceAction>();
         repo.Add(action);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #27
0
 public bool DeviceCredentialsRemove(DeviceCredentials creds)
 {
     try
     {
         iotRepository <DeviceCredentials> repo = new iotRepository <DeviceCredentials>();
         repo.Delete(creds);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #28
0
 public bool DeviceTypeRemove(DeviceType type)
 {
     try
     {
         iotRepository <DeviceType> repo = new iotRepository <DeviceType>();
         repo.Delete(type);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #29
0
 public bool EndpointRemove(EndpointInfo endp)
 {
     try
     {
         iotRepository <EndpointInfo> repo = new iotRepository <EndpointInfo>();
         repo.Delete(endp);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #30
0
 public bool SiteAdd(Site site)
 {
     try
     {
         iotRepository <Site> repo = new iotRepository <Site>();
         repo.Add(site);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }