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
        /************** 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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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);
        }