Example #1
0
        public IHttpActionResult Get(int seriesId)
        {
            var series = new ContentChannelItemService(_rockContext).Get(seriesId);

            if (series != null && series.ContentChannelId == 10)
            {
                series.LoadAttributes();
                var seriesImageFile = _binaryFileService.Get(series.GetAttributeValue("PodcastImage").AsGuid());

                return(Ok(series.ChildItems
                          .Select(i => i.ChildContentChannelItem)
                          .Where(i => i.ContentChannelId == 11 && i.StartDateTime < DateTime.Now)
                          .OrderBy(i => i.StartDateTime)
                          .Select(item =>
                {
                    var archiveItem = GetArchiveObjectForMessage(item);

                    if (seriesImageFile != null)
                    {
                        archiveItem.AudioImage = seriesImageFile.Path;
                    }

                    return archiveItem;
                })
                          ));
            }
            else
            {
                return(NotFound());
            }
        }
        public IHttpActionResult GetById(int id)
        {
            var rockContext = new RockContext();

            var item = new ContentChannelItemService(rockContext).Get(id);

            if (item == null)
            {
                return(NotFound());
            }

            item.LoadAttributes();

            var binaryFileService = new BinaryFileService(rockContext);

            return(Ok(new TheDailyItem
            {
                Id = item.Id,
                Title = item.Title,
                Date = item.StartDateTime,
                Content = item.Content, //DotLiquid.StandardFilters.StripHtml(item.Content.Replace("<br", "\n<br").Replace("<p>", "\n<p>")),
                DailyPDF = GetFileUrlOrNull(binaryFileService, item, "PDF"),
                ScriptiureCards = GetFileUrlOrNull(binaryFileService, item, "ScriptureCards")
            }));
        }
Example #3
0
        protected void ShowDetail(int contentItemId)
        {
            var rockContext = new RockContext();
            var contentItem = new ContentChannelItem();

            if (contentItemId != 0)
            {
                contentItem = new ContentChannelItemService(rockContext)
                              .Queryable("ContentChannel,ContentChannelType")
                              .FirstOrDefault(t => t.Id == contentItemId);
            }

            if (contentItem == null || contentItem.Id == 0)
            {
                pnlVimeoSync.Visible  = false;
                pnlNewDetails.Visible = false;

                if (_contentChannelId > 0)
                {
                    contentItem = new ContentChannelItemService(rockContext)
                                  .Queryable("ContentChannel,ContentChannelType")
                                  .FirstOrDefault(t => t.ContentChannelId == _contentChannelId);

                    if (contentItem != null && contentItem.Attributes == null)
                    {
                        contentItem.LoadAttributes();
                    }

                    if (contentItem != null)
                    {
                        var attributeKeys = contentItem.Attributes.Select(a => a.Key).ToList();
                        if (!string.IsNullOrWhiteSpace(_vimeoIdKey) && attributeKeys.Contains(_vimeoIdKey))
                        {
                            pnlNewDetails.Visible = true;
                            pnlVimeoSync.Visible  = true;
                            litPreview.Visible    = false;

                            SetupSyncBoxes();
                        }
                    }
                }
            }
            else
            {
                if (contentItem.Attributes == null)
                {
                    contentItem.LoadAttributes();
                }
                _vimeoId = contentItem.GetAttributeValue(_vimeoIdKey).AsInteger();
                if (_vimeoId == 0)
                {
                    pnlVimeoSync.Visible = false;
                    var attributeKeys = contentItem.Attributes.Select(a => a.Key).ToList();
                    if (!string.IsNullOrWhiteSpace(_vimeoIdKey) && attributeKeys.Contains(_vimeoIdKey))
                    {
                        pnlNewDetails.Visible = true;
                        pnlVimeoSync.Visible  = true;
                        litPreview.Visible    = false;

                        SetupSyncBoxes();
                    }
                }
                else
                {
                    SetupSyncBoxes();

                    if (GetAttributeValue("Preview").AsBoolean())
                    {
                        litPreview.Text    = string.Format("<div class=\"{0}\"><div class=\"embed-responsive embed-responsive-16by9\"><iframe class=\"embed-responsive-item\" src=\"https://player.vimeo.com/video/{1}\"></iframe></div></div>", GetAttributeValue("PreviewWidth"), _vimeoId);
                        litPreview.Visible = true;
                    }
                    else
                    {
                        litPreview.Visible = false;
                    }
                }
            }

            if (contentItem != null)
            {
                dpStart.Label = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
            }
        }
        private void SyncVimeo()
        {
            var lookupContext       = new RockContext();
            var contentChannelItems = new List <ContentChannelItem>();
            var completed           = 0;

            var  client = new VimeoClient(_accessToken);
            var  vimeo  = new Video();
            var  width  = GetAttributeValue("ImageWidth").AsInteger();
            long userId = GetAttributeValue("VimeoUserId").AsInteger();
            var  videos = vimeo.GetVideos(client, userId, width);

            var vimeoIdKey = GetAttributeValue("VimeoIdKey");

            foreach (var video in videos)
            {
                var contentChannelItem = new ContentChannelItemService(lookupContext)
                                         .Queryable("ContentChannel,ContentChannelType")
                                         .WhereAttributeValue(lookupContext, vimeoIdKey, video.vimeoId.ToString())
                                         .FirstOrDefault(i => i.ContentChannelId == _contentChannelId);

                if (contentChannelItem != null && contentChannelItem.Id != 0)
                {
                    if (contentChannelItem.Attributes == null)
                    {
                        contentChannelItem.LoadAttributes();
                    }

                    var cbName = cblSyncOptions.Items.FindByValue("Name");
                    if (cbName != null && cbName.Selected == true)
                    {
                        contentChannelItem.Title = video.name;
                    }

                    var cbDescription = cblSyncOptions.Items.FindByValue("Description");
                    if (cbDescription != null && cbDescription.Selected == true)
                    {
                        contentChannelItem.Content = video.description;
                    }

                    var cbImage = cblSyncOptions.Items.FindByValue("Image");
                    if (cbImage != null && cbImage.Selected == true)
                    {
                        contentChannelItem.AttributeValues[_imageAttributeKey].Value = video.imageUrl;
                    }

                    var cbDuration = cblSyncOptions.Items.FindByValue("Duration");
                    if (cbDuration != null && cbDuration.Selected == true)
                    {
                        contentChannelItem.AttributeValues[_durationAttributeKey].Value = video.duration.ToString();
                    }

                    var cbHDVideo = cblSyncOptions.Items.FindByValue("HD Video");
                    if (cbHDVideo != null && cbHDVideo.Selected == true && !string.IsNullOrWhiteSpace(video.hdLink))
                    {
                        contentChannelItem.AttributeValues[_hdVideoAttributeKey].Value = video.hdLink;
                    }

                    var cbSDVideo = cblSyncOptions.Items.FindByValue("SD Video");
                    if (cbSDVideo != null && cbSDVideo.Selected == true && !string.IsNullOrWhiteSpace(video.sdLink))
                    {
                        contentChannelItem.AttributeValues[_sdVideoAttributeKey].Value = video.sdLink;
                    }

                    var cbHLSVideo = cblSyncOptions.Items.FindByValue("HLS Video");
                    if (cbHLSVideo != null && cbHLSVideo.Selected == true && !string.IsNullOrWhiteSpace(video.hlsLink))
                    {
                        contentChannelItem.AttributeValues[_hlsVideoAttributeKey].Value = video.hlsLink;
                    }

                    contentChannelItems.Add(contentChannelItem);
                    completed++;

                    if (completed % _batchSize < 1)
                    {
                        SaveContentChannelItems(contentChannelItems);
                        contentChannelItems.Clear();
                    }
                }
            }

            // Save leftovers
            if (contentChannelItems.Any())
            {
                SaveContentChannelItems(contentChannelItems);
                contentChannelItems.Clear();
            }
        }