Example #1
0
        public virtual OxiteModelItem <Area> ItemEdit(Area areaInput)
        {
            Area area = areaInput.ID != Guid.Empty ? areaService.GetArea(areaInput.ID) : null;

            return(new OxiteModelItem <Area> {
                Item = area
            });
        }
Example #2
0
        public virtual OxiteModelList <Post> ListByArea(int?pageNumber, int pageSize, Area areaInput, DateTime?ifModifiedSince)
        {
            int pageIndex = pageNumber.HasValue ? pageNumber.Value - 1 : 0;

            Area area = areaService.GetArea(areaInput.Name);

            if (area == null)
            {
                return(null);
            }

            return(GetPostList(area, () => postService.GetPosts(pageIndex, pageSize, area, ifModifiedSince)));
        }
Example #3
0
        public virtual OxiteModelList <ParentAndChild <PostBase, Comment> > ListByArea(Area areaInput)
        {
            Area area = areaService.GetArea(areaInput.Name);

            if (area == null)
            {
                return(null);
            }

            return(new OxiteModelList <ParentAndChild <PostBase, Comment> >
            {
                List = postService.GetComments(area),
                Container = area
            });
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            OxiteModel model = filterContext.Controller.ViewData.Model as OxiteModel;

            if (model == null)
            {
                return;
            }

            IList <KeyValuePair <ArchiveData, int> > archives;
            string       areaName = filterContext.RouteData.Values["areaName"] as string;
            INamedEntity container;

            if (!string.IsNullOrEmpty(areaName))
            {
                archives = postService.GetArchives(new Area {
                    Name = areaName
                });
                container = areaService.GetArea(areaName);
            }
            else
            {
                archives  = postService.GetArchives();
                container = new HomePageContainer();
            }

            model.AddModelItem(new ArchiveViewModel(archives, container));
        }
Example #5
0
        private void FilterComponentIds()
        {
            if (!_currentContext.IdentifiedComponentIds.Any())
            {
                return;
            }

            if (_currentContext.IdentifiedComponentIds.Count == 1)
            {
                _currentContext.FilteredComponentIds.Add(_currentContext.IdentifiedComponentIds.First());
                return;
            }

            foreach (var componentId in _currentContext.IdentifiedComponentIds)
            {
                foreach (var areaId in _currentContext.IdentifiedAreaIds)
                {
                    var area = _areaService.GetArea(areaId);

                    if (area.ContainsComponent(componentId))
                    {
                        _currentContext.FilteredComponentIds.Add(componentId);
                        break;
                    }
                }
            }
        }
Example #6
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            OxiteModel model = filterContext.Controller.ViewData.Model as OxiteModel;

            if (model != null)
            {
                string      areaName = filterContext.RouteData.Values["areaName"] as string;
                Area        area     = !string.IsNullOrEmpty(areaName) ? areaService.GetArea(areaName) : null;
                Post        post     = null;
                List <Post> posts    = new List <Post>();

                if (area != null && string.Compare(area.Name, "IE8", true) == 0)
                {
                    posts.AddRange(postService.GetPosts(0, 50, area, (DateTime?)null));
                }

                if (area != null && string.Compare(area.Name, "MIX09", true) == 0)
                {
                    post = postService.GetPosts(0, 1, area, (DateTime?)null).FirstOrDefault();
                }
                else
                {
                    post = postService.GetRandomPost();
                }

                model.AddModelItem(new SidebarViewModel(post, posts));
            }
        }
Example #7
0
        public string NewPost(string blogId, string username, string password, Post post, bool publish)
        {
            Oxite.Model.User user = getUser(username, password);

            Oxite.Model.Area area = areaService.GetArea(new Guid(blogId));

            Oxite.Model.Post newPost = new Oxite.Model.Post
            {
                Title     = post.title,
                Body      = post.description,
                Created   = post.dateCreated == default(DateTime) ? DateTime.Now : post.dateCreated,
                Slug      = string.IsNullOrEmpty(post.mt_basename) ? expressions.Slugify(post.title) : post.mt_basename,
                BodyShort = post.mt_excerpt,
                Creator   = user,
                State     = Oxite.Model.EntityState.Normal
            };

            if (publish)
            {
                newPost.Published = DateTime.Now;
            }

            if (post.categories != null)
            {
                newPost.Tags = new List <Oxite.Model.Tag>(post.categories.Select(s => new Oxite.Model.Tag()
                {
                    Name = s
                }));
            }

            postService.AddPost(area, newPost);

            Oxite.Model.Post createdPost = postService.GetPost(area, newPost.Slug);
            return(createdPost.ID.ToString());
        }
Example #8
0
        public static IArea GetArea(this IAreaService areaService, Enum id)
        {
            if (areaService == null)
            {
                throw new ArgumentNullException(nameof(areaService));
            }

            return(areaService.GetArea(AreaIdGenerator.Generate(id)));
        }
Example #9
0
        public void Apply()
        {
            var hsrel8LowerHeatingValves = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.LowerHeatingValvesHSREL8, new I2CSlaveAddress(16));
            var hsrel5UpperHeatingValves = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.UpperHeatingValvesHSREL5, new I2CSlaveAddress(56));

            var hsrel5Stairway = _deviceService.GetDevice <HSREL5>(InstalledDevice.StairwayHSREL5);
            var input3         = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3);

            var room = _areaService.CreateArea(Room.Storeroom);

            _actuatorFactory.RegisterLamp(room, Storeroom.LightCeiling, hsrel5Stairway[HSREL5Pin.GPIO1]);

            _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetector, input3.GetInput(12));
            _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetectorCatLitterBox, input3.GetInput(11).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Storeroom.CatLitterBoxFan, hsrel5Stairway[HSREL5Pin.GPIO2]);
            _actuatorFactory.RegisterSocket(room, Storeroom.CirculatingPump, hsrel5UpperHeatingValves[HSREL5Pin.Relay3]);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.LightCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetector))
            .WithTarget(room.GetLamp(Storeroom.LightCeiling));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CatLitterBoxFan)
            .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox))
            .WithTarget(room.GetSocket(Storeroom.CatLitterBoxFan));

            // Both relays are used for water source selection (True+True = Lowerr, False+False = Upper)
            // Second relays is with capacitor. Disable second with delay before disable first one.
            hsrel5UpperHeatingValves[HSREL5Pin.GPIO0].Write(BinaryState.Low);
            hsrel5UpperHeatingValves[HSREL5Pin.GPIO1].Write(BinaryState.Low);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CirculatingPumpAutomation)
            .WithTrigger(_areaService.GetArea(Room.Kitchen).GetMotionDetector(KitchenConfiguration.Kitchen.MotionDetector))
            .WithTrigger(_areaService.GetArea(Room.LowerBathroom).GetMotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector))
            .WithTarget(room.GetSocket(Storeroom.CirculatingPump))
            .WithPauseAfterEveryTurnOn(TimeSpan.FromHours(1))
            .WithEnabledAtDay();

            _catLitterBoxTwitterSender =
                new CatLitterBoxTwitterSender(_timerService, _twitterClientService).WithTrigger(
                    room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox));

            _synonymService.AddSynonymsForArea(Room.Storeroom, "Abstellkammer", "Storeroom");
        }
Example #10
0
        public virtual OxiteModelList <KeyValuePair <Tag, int> > CloudForArea(Area areaInput)
        {
            Area area = areaService.GetArea(areaInput.Name);

            if (area == null)
            {
                return(null);
            }

            return(getTagList(area, () => tagService.GetTagsUsedIn(area)));
        }
Example #11
0
        public OxiteModelList <Post> ListAll()
        {
            Area area = areaService.GetArea("MIX09");

            if (area == null)
            {
                return(null);
            }

            return(new OxiteModelList <Post>
            {
                Container = area,
                List = postService.GetPosts(0, 500, area, null)
            });
        }
Example #12
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            OxiteModel model = filterContext.Controller.ViewData.Model as OxiteModel;

            if (model != null)
            {
                string areaName = filterContext.RouteData.Values["areaName"] as string;
                if (areaName != null)
                {
                    Area area = areaService.GetArea(areaName);
                    model.AddModelItem(new TagCloudViewModel(tagService.GetTagsUsedIn(area)));
                }
                else
                {
                    model.AddModelItem(new TagCloudViewModel(tagService.GetTagsWithPostCount()));
                }
            }
        }
        public IHttpActionResult Get(int areaID)
        {
            var response = service.GetArea(areaID);

            return(Ok(response));
        }