Exemplo 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);
            }
        }
Exemplo n.º 2
0
        public iotRepository()
        {
            iotContext dbContext = new iotContext();

            DbContext = dbContext;
            DbSet     = DbContext.Set <T>();
        }
Exemplo 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());
            }
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 9
0
        public List <ParameterType> ParamTypeList()
        {
            iotContext db = new iotContext();

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

            return(types);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 15
0
        public List <iotDomain> DomainList()
        {
            iotContext db = new iotContext();

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

            return(domains);
        }
Exemplo 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();
        }
Exemplo 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" }
            //    );
            //
        }
Exemplo 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());
     }
 }
Exemplo 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());
            }
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo n.º 29
0
 public iotConnector()
 {
     context = new iotContext();
 }