コード例 #1
0
        private void AddSlide(SlideFeedItem item, List <ChannelsSlide> channelssidesList)
        {
            string   title = item.Parameters["TitleText"].GetValue();
            string   url   = item.Parameters["ClickThroughUrl"].GetValue();
            DateTime date  = ((DateParameter)item.Parameters["PublishedDate"]).Date;
            Image    img   = ((ImageParameter)item.Parameters["MasterImage"]).GetImage();
            var      slide = new Slide(".swf");

            slide.SlideFolderID   = SlideFolder.Id;
            slide.Caption         = title.Length > 400 ? title.Substring(0, 400 - 3) + "..." : title;
            slide.ClickThroughURL = url;
            slide.Creator         = Publisher.DisplayName;
            slide.DisplayDuration = Template.DisplayDuration;
            slide.UserGivenDate   = date;
            slide.Name            = title.Length > 50 ? title.Substring(0, 50 - 3) + "..." : title;
            slide.PreviewType     = "Flash";
            slide.PlayerType      = "Flash";

            var slideFromTemplate = new SWAFile(Template.FileFullPathName);

            foreach (var parameter in item.Parameters.Values)
            {
                parameter.PassTo(slideFromTemplate);
            }

            //Aspose has a bug with getting thumbnail so use the asset content image for now
            //var image = slideFromTemplate.GetThumbnail();
            ImageUtilities.Crop(img, 100, 75, AnchorPosition.Center).Save(slide.ThumbnailFullPathName);
            slideFromTemplate.Save(slide.FileFullPathName);
            slide.Length = (int)new FileInfo(slide.FileFullPathName).Length;
            //Add slides in reverse order
            channelssidesList.Insert(0, new ChannelsSlide(Channel, slide));
        }
コード例 #2
0
ファイル: SlideFeedParser.cs プロジェクト: Oxigen2/Oxigen
        public SlideFeed Parse(string lastGuid)
        {
            if (_dom.DocumentElement.Name == "items")
            {
                return(ParseLegacy(lastGuid));
            }

            var slideFeed = new SlideFeed();
            var items     = _dom.SelectNodes(@"slidefeed/item");

            foreach (XmlNode item in items)
            {
                string guid = item.Attributes["guid"].Value;
                if (guid == lastGuid)
                {
                    break;
                }

                SlideFeedItem slideFeedItem = GetSlideFeedItem(item);
                if (slideFeedItem != null)
                {
                    slideFeed.Items.Add(slideFeedItem);
                }
            }

            return(slideFeed);
        }
コード例 #3
0
ファイル: SlideFeedParser.cs プロジェクト: Oxigen2/Oxigen
        private SlideFeed ParseLegacy(string lastGuid)
        {
            var slideFeed = new SlideFeed();

            foreach (XmlNode item in _dom.DocumentElement.ChildNodes)
            {
                string guid = item.SelectSingleNode("guid").InnerText;
                if (guid == lastGuid)
                {
                    break;
                }

                var slideFeedItem = new SlideFeedItem()
                {
                    Guid = item.SelectSingleNode("guid").InnerText
                };
                slideFeedItem.Add(new DateParameter("PublishedDate", item.SelectSingleNode("date").InnerText, "d MMMM yyyy HH:mm"));
                slideFeedItem.Add(new TextParameter("ClickThroughUrl", item.SelectSingleNode("url").InnerText));
                slideFeedItem.Add(new TextParameter("TitleText", item.SelectSingleNode("title").InnerText));
                slideFeedItem.Add(new ImageParameter("MasterImage", item.SelectSingleNode("image").InnerText));
                if (item.SelectSingleNode("credit") != null)
                {
                    slideFeedItem.Add(new TextParameter("ImageCreditText", item.SelectSingleNode("credit").InnerText));
                }
                slideFeed.Items.Add(slideFeedItem);
            }
            return(slideFeed);
        }
コード例 #4
0
ファイル: SlideFeedParser.cs プロジェクト: Oxigen2/Oxigen
        private SlideFeedItem GetSlideFeedItem(XmlNode item)
        {
            var slideFeedItem = new SlideFeedItem()
            {
                Guid = item.Attributes["guid"].Value
            };
            var parameterNodes = item.SelectNodes(@"./parameter");

            foreach (XmlNode parameterNode in parameterNodes)
            {
                string parameterData = null;
                string parametername = parameterNode.Attributes["name"].Value;

                //Check if we need to run a script to get the data
                var callScriptNode = parameterNode.SelectSingleNode(@"./call-script");
                if (callScriptNode != null)
                {
                    var paramObjects = new List <object>();

                    var paramList = callScriptNode.SelectNodes("./wih-param");
                    foreach (XmlNode paramnode in paramList)
                    {
                        paramObjects.Add(paramnode.InnerText.Trim());
                    }
                    string functionName = callScriptNode.Attributes["name"].Value;

                    parameterData = RunScript(_dom.SelectSingleNode(@"slidefeed/script").InnerText, functionName, paramObjects.ToArray());
                    if (parameterData == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    parameterData = parameterNode.InnerText.Trim();
                }
                Parameter parameter = null;


                switch (parameterNode.Attributes["type"].Value)
                {
                case "text":
                    parameter = new TextParameter(parametername, parameterData);
                    break;

                case "date":
                    parameter = new DateParameter(parametername, parameterData, parameterNode.Attributes["format"].Value);
                    break;

                case "image":
                    parameter = new ImageParameter(parametername, parameterData);
                    break;
                }

                slideFeedItem.Add(parameter);
            }
            return(slideFeedItem);
        }