private static void ManageScrollTextsForPresentation( FullPresentation fullPresentation, ScheduledBlockData scheduledBlockData) { List <ScrollRectArea> scrollRectAreas = scheduledBlockData.RectAreas.Where(ra => (ra as ScrollRectArea) != null).Select(ra => ra as ScrollRectArea).ToList(); scrollRectAreas.ForEach(scrollRectArea => { if (scrollRectArea.ScrollType == ScrollRectAreaTypes.Text) { fullPresentation.ScrollTexts.Add(scrollRectArea.Text); } else { try { List <RssFeedItem> items = RssTools.ParseToGetRssFeedItems(scrollRectArea.ApiUrl); fullPresentation.ScrollTexts.Add(String.Join("|", items.Take(7).Select(i => i.Title.Trim()).ToList())); } catch (Exception) { fullPresentation.ScrollTexts.Add($"Error reading from the provider { scrollRectArea.ApiType }."); } } }); }
public void SetValues(TPresentation presentation) { Id = presentation.Id; Name = presentation.Name; ScheduledBlockData = JsonConvert.DeserializeObject <ScheduledBlockData>(presentation.Data, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); }
private static void ManageWidgets( FullPresentation fullPresentation, ScheduledBlockData scheduledBlockData ) { List <WidgetRectArea> widgetRectAreas = scheduledBlockData.RectAreas.Where(ra => (ra as WidgetRectArea) != null).Select(ra => ra as WidgetRectArea).ToList(); widgetRectAreas.ForEach(widgetRectArea => { fullPresentation.WidgetsLists.Add(widgetRectArea.WidgetItems); }); }
private static void ManageStaticContent( FullPresentation fullPresentation, ScheduledBlockData scheduledBlockData, IDownloadService downloadService) { StaticRectArea staticRectArea = scheduledBlockData.RectAreas.Where(ra => (ra as StaticRectArea) != null).Select(ra => ra as StaticRectArea).FirstOrDefault(); if (staticRectArea != null) { fullPresentation.StaticImageLocalPath = downloadService.Download(staticRectArea.ImageUrl); } }
public static ScheduledBlockData CreateB() { ScheduledBlockData data = new ScheduledBlockData(); data.AddRectArea(new StaticRectArea { Id = 99, ImageUrl = "http://www.abc.com/e92w3i2hjk3js.jpg" }); data.AddRectArea(new WidgetRectArea() { Id = 7, WidgetItems = new List <WidgetItem> { new WidgetItem { Duration = 300, Type = "weather" }, } }); data.AddRectArea(new WidgetRectArea() { Id = 7, WidgetItems = new List <WidgetItem> { new WidgetItem { Duration = 300, Type = "ads" }, } }); data.AddRectArea(new MainContentRectArea { Id = 5, Videos = new List <MainContentVideo> { new MainContentVideo { Duration = 150, Name = "MRT 7 Complete", Tags = new List <string> { "metro", "infrastructure" }, Url = "http://www.abs-cbn.com/2391293199s929199.mp4" }, new MainContentVideo { Duration = 150, Name = "Aliens always existed", Tags = new List <string> { "conspiracy", "space" }, Url = "http://www.agt.com/2391293199s29.mp4" }, } }); return(data); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), Formatting = Formatting.Indented, DefaultValueHandling = DefaultValueHandling.Ignore }; ScheduledBlockData data = ScheduledBlockDataCreator.CreateA(); string serialized = JsonConvert.SerializeObject(data, jsonSerializerSettings); Console.WriteLine(serialized); FileProcessor fp = new FileProcessor(); fp.Write("C:/FrixxerFiles/sched1.json", serialized); ScheduledBlockData dataB = ScheduledBlockDataCreator.CreateB(); string serializedB = JsonConvert.SerializeObject(dataB, jsonSerializerSettings); Console.WriteLine(serializedB); fp.Write("C:/FrixxerFiles/sched2.json", serializedB); /* * We already know that this works, so we'll comment it out. * * ScheduledBlockData redeserialized = JsonConvert.DeserializeObject<ScheduledBlockData>(serialized, jsonSerializerSettings); * * string serialized2 = JsonConvert.SerializeObject(redeserialized, jsonSerializerSettings); * * Console.WriteLine(serialized2); */ Console.ReadLine(); }
public List <PresentationViewModel <Presentation> > GetPresentations(DateTime startTime, int durationInSeconds) { /* We'll later do the actual API call here. But for now, we're reading json files. */ int whichPresentation = startTime.Second % 2 + 1; string whichFile = $"{Configuration["FrixxerFilesRoot"]}/sched{whichPresentation}.json"; string fileContents = FileProcessor.ReadToString(whichFile); ScheduledBlockData data = JsonConvert.DeserializeObject <ScheduledBlockData>(fileContents, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore }); return(new List <PresentationViewModel <Presentation> > { new PresentationViewModel <Presentation> { Id = -1, Name = $"Presentation { whichPresentation.ToString() }", ScheduledBlockData = data } }); }
public static ScheduledBlockData CreateA() { ScheduledBlockData data = new ScheduledBlockData(); data.AddRectArea(new StaticRectArea { Id = 2, ImageUrl = "http://www.abc.com/e92w3i2hjk3js.jpg" }); data.AddRectArea(new WidgetRectArea() { Id = 7, WidgetItems = new List <WidgetItem> { new WidgetItem { Duration = 30, Type = "weather" }, new WidgetItem { Duration = 210, Type = "ads" }, new WidgetItem { Duration = 60, Type = "sports" } } }); data.AddRectArea(new ScrollRectArea { Id = 3, ScrollType = "text", Text = "this is what I want to say. " }); data.AddRectArea(new ScrollRectArea { Id = 3, ScrollType = "api", Text = "the market stock what drop i don't know." }); data.AddRectArea(new ScrollRectArea { Id = 3, ScrollType = "api", Text = "what is happening in the world today?" }); data.AddRectArea(new MainContentRectArea { Id = 5, Videos = new List <MainContentVideo> { new MainContentVideo { Duration = 30, Name = "Panda Wars", Tags = new List <string> { "animals", "zoo" }, Url = "http://www.cnn.com/2391293199s929199.mp4" }, new MainContentVideo { Duration = 30, Name = "Spelling Bee", Tags = new List <string> { "academics", "school", "talent" }, Url = "http://www.agt.com/2391293199s29.mp4" }, new MainContentVideo { Duration = 120, Name = "Moderate Network III", Tags = new List <string> { "reality", "truth" }, Url = "http://www.npr.com/1111129199.mp4" }, new MainContentVideo { Duration = 120, Name = "Cool Beans", Tags = new List <string> { "food", "health", "nutrition" }, Url = "http://www.food.com/222211111.mp4" }, } }); return(data); }