Esempio n. 1
0
        /************** Site ************/

        public bool SiteAdd(Site site)
        {
            try
            {
                iotContext db = new iotContext();

                iotDomain targetDomain = (from d in db.Domains
                                          where site.Domain.Id == d.Id
                                          select d).First();
                Location siteLocation = (from l in db.Locations
                                         where l.Id == site.siteLocation.Id
                                         select l).First();

                Site nsite = new Site();
                nsite.SiteName     = site.SiteName;
                nsite.Domain       = targetDomain;
                nsite.siteLocation = siteLocation;
                db.Sites.Add(nsite);
                db.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 2
0
        public iotRepository()
        {
            iotContext dbContext = new iotContext();

            DbContext = dbContext;
            DbSet     = DbContext.Set <T>();
        }
Esempio n. 3
0
        /************** Type ************/
        public ParameterType TypeForName(string name)
        {
            try
            {
                iotContext           db    = new iotContext();
                List <ParameterType> types = (from d in db.ParamTypes
                                              where d.Name.Equals(name)
                                              select d).ToList();

                if (types.Count == 0)
                {
                    //add type
                    ParameterType type = new ParameterType();
                    type.Name = name;
                    ParameterType storedType = db.ParamTypes.Add(type);
                    db.SaveChanges();
                    return(storedType);
                }
                else
                {
                    return(types.First());
                }
            }
            catch (Exception e)
            {
                return(new ParameterType());
            }
        }
Esempio n. 4
0
        /************** Site ************/
        public List <Site> SiteList()
        {
            iotContext db = new iotContext();

            List <Site> sites = (from d in db.Sites
                                 select d).ToList();

            return(sites);
        }
Esempio n. 5
0
        /************** Device ************/
        public List <Device> DeviceList()
        {
            iotContext db = new iotContext();

            List <Device> devs = (from d in db.Devices
                                  select d).ToList();

            return(devs);
        }
Esempio n. 6
0
        /************** Device types ************/
        public List <DeviceType> DevTypesList()
        {
            iotContext db = new iotContext();

            List <DeviceType> mappers = (from d in db.Types
                                         select d).ToList();

            return(mappers);
        }
Esempio n. 7
0
        /************** Action params ************/
        public List <ActionParameter> ActionParamList()
        {
            iotContext db = new iotContext();

            List <ActionParameter> types = (from d in db.ActionParameters
                                            select d).ToList();

            return(types);
        }
Esempio n. 8
0
        /************** Mapper ************/
        public List <sconnActionResultMapper> MappersList()
        {
            iotContext db = new iotContext();

            List <sconnActionResultMapper> mappers = (from d in db.ActionResultMappers
                                                      select d).ToList();

            return(mappers);
        }
Esempio n. 9
0
        public List <ParameterType> ParamTypeList()
        {
            iotContext db = new iotContext();

            List <ParameterType> types = (from d in db.ParamTypes
                                          select d).ToList();

            return(types);
        }
Esempio n. 10
0
        /************** Action ************/
        public List <DeviceAction> ActionList()
        {
            iotContext db = new iotContext();

            List <DeviceAction> actions = (from d in db.Actions
                                           select d).ToList();

            return(actions);
        }
Esempio n. 11
0
        /************** Endpoint ************/
        public List <EndpointInfo> EndpInfoList()
        {
            iotContext db = new iotContext();

            List <EndpointInfo> endp = (from d in db.Endpoints
                                        select d).ToList();

            return(endp);
        }
Esempio n. 12
0
        /************** Location ************/
        public List <Location> LocationList()
        {
            iotContext db = new iotContext();

            List <Location> locs = (from d in db.Locations
                                    select d).ToList();

            return(locs);
        }
Esempio n. 13
0
        /************** Parameter ************/
        public List <DeviceParameter> ParameterList()
        {
            iotContext db = new iotContext();

            List <DeviceParameter> devparams = (from d in db.Parameters
                                                select d).ToList();

            return(devparams);
        }
Esempio n. 14
0
        /************** Property ************/
        public List <DeviceProperty> PropertyList()
        {
            iotContext db = new iotContext();

            List <DeviceProperty> props = (from d in db.Properties
                                           select d).ToList();

            return(props);
        }
Esempio n. 15
0
        public List <iotDomain> DomainList()
        {
            iotContext db = new iotContext();

            List <iotDomain> domains = (from d in db.Domains
                                        select d).ToList();

            return(domains);
        }
Esempio n. 16
0
        static public void ClearIotRepository()
        {
            iotContext dbContext  = new iotContext();
            var        tableNames = dbContext.Database.SqlQuery <string>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME NOT LIKE '%Migration%'").ToList();

            foreach (var tableName in tableNames)
            {
                dbContext.Database.ExecuteSqlCommand(string.Format("DELETE FROM {0}", tableName));
            }
            dbContext.SaveChanges();
        }
Esempio n. 17
0
        protected override void Seed(iotDbConnector.DAL.iotContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
        }
Esempio n. 18
0
 public iotDomain DomainForDomainId(int domainId)
 {
     try
     {
         iotContext db     = new iotContext();
         iotDomain  domain = (from d in db.Domains
                              where d.Id.Equals(domainId)
                              select d).First();
         return(domain);
     }
     catch (Exception e)
     {
         return(new iotDomain());
     }
 }
Esempio n. 19
0
        /**************************** Query ****************************/


        /************** Domain ************/
        public iotDomain DomainForDomainName(string name)
        {
            try
            {
                iotContext db = new iotContext();

                iotDomain domain = (from d in db.Domains
                                    where d.DomainName == name
                                    select d).First();
                return(domain);
            }
            catch (Exception e)
            {
                return(new iotDomain());
            }
        }
Esempio n. 20
0
        /**************************** Execute ****************************/



        /************** Domain ************/
        public bool DomainAdd(iotDomain domain)
        {
            try
            {
                if (domain != null)
                {
                    iotContext db = new iotContext();

                    db.Domains.Add(domain);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 21
0
        /************** Device ************/
        public bool DeviceAdd(Device device)
        {
            try
            {
                if (device != null)
                {
                    iotContext db = new iotContext();

                    db.Devices.Add(device);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 22
0
        /************** Action ************/
        public bool ActionAdd(DeviceAction action)
        {
            try
            {
                if (action != null)
                {
                    iotContext db = new iotContext();

                    db.Actions.Add(action);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 23
0
        /************** Action param ************/
        public bool ActionParamAdd(ActionParameter param)
        {
            try
            {
                if (param != null)
                {
                    iotContext db = new iotContext();

                    db.ActionParameters.Add(param);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 24
0
        /************** Mapper ************/
        public bool MapperAdd(sconnActionResultMapper param)
        {
            try
            {
                if (param != null)
                {
                    iotContext db = new iotContext();

                    db.ActionResultMappers.Add(param);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 25
0
        /************** Type ************/
        public bool TypeAdd(DeviceType param)
        {
            try
            {
                if (param != null)
                {
                    iotContext db = new iotContext();

                    db.Types.Add(param);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 26
0
        /************** Endpoint ************/
        public bool EndpointAdd(EndpointInfo edp)
        {
            try
            {
                if (edp != null)
                {
                    iotContext db = new iotContext();

                    db.Endpoints.Add(edp);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 27
0
        /************** Location ************/
        public bool LocationAdd(Location loc)
        {
            try
            {
                if (loc != null)
                {
                    iotContext db = new iotContext();

                    db.Locations.Add(loc);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 28
0
        /************** Property ************/
        public bool PropertyAdd(DeviceProperty property)
        {
            try
            {
                if (property != null)
                {
                    iotContext db = new iotContext();

                    db.Properties.Add(property);
                    db.SaveChanges();
                    //TODO verify save
                }
            }
            catch (Exception e)
            {
            }
            return(true);
        }
Esempio n. 29
0
 public iotConnector()
 {
     context = new iotContext();
 }