public PageGroup GeneratePageGroup(IServer server, Guid mmUnitId, RingMetaData ring) { MultiMedia db = GetMultiMedia(server); MMUnit mmUnit = db.MMUnits.FindOrLoad(mmUnitId); PageGroupGenerator pageGroupGenerator = new PageGroupGenerator(mmUnit, ring.DataSet); return pageGroupGenerator.Generate(); }
double AddPlayerScreenGroupToPlayList(RingMetaData ringMetaData, Guid slotId, MMUnit mmUnit, double relativeStartSecond, ref List<PageSchedule> lastInsertedSchedules) { PageGroup pageGroup = ActualRing.DataSet.PageGroups.Find(mmUnit.Id); if (pageGroup == null) { pageGroup = new PageGroupGenerator(mmUnit, ActualRing.DataSet).Generate(); if (pageGroup.DurationInSeconds == 0) throw new Exception($"screenGroup.DurationInSeconds == 0 bei {pageGroup.Name} ({pageGroup.Id})"); } //Debug.WriteLine($"PlayListTime = {playList.RelativeStartSeconds} CurentStartTime = {currentStartTime.TotalSeconds}"); Guid pageGroupScheduledId = Guid.NewGuid(); TimeSpan currentStartTime = TimeSpan.FromSeconds(relativeStartSecond); Page[] pages = pageGroup.Pages.OrderBy(x=>x.SortOrder).ToArray(); for (int i = 0; i < pages.Length; i++) { Page page = pages[i]; if (currentStartTime > TimeSpan.FromDays(1)) continue; PageSchedule pageSchedule = pageGroup.DataSet.PageSchedules.NewRow(); pageSchedule.Id = Guid.NewGuid(); pageSchedule.StartTime = DateTime.Now.Date.Add(currentStartTime); pageSchedule.DiagnosticText = $"{pageGroup.Name} Seite {i+1}"; pageSchedule.PageGroupScheduleId = pageGroupScheduledId; pageSchedule.Page = page; pageSchedule.RingMetaData = ringMetaData; pageSchedule.SlotId = slotId; currentStartTime = currentStartTime.Add(TimeSpan.FromSeconds((double)pageSchedule.Page.ExpectedDuration)); pageSchedule.Table.Rows.Add(pageSchedule); if (lastInsertedSchedules != null) lastInsertedSchedules.Add(pageSchedule); } if (pageGroup.DurationInSeconds == 0) Debug.WriteLine($"Duration = 0 Beitrag SchreenGroup {pageGroup.Name} ({pageGroup.Id})"); return currentStartTime.TotalSeconds; }
double CreateScheduledPagesFromMMUnit(MMUnit mmunit, double relativeStartSecond, ref List<PageSchedule> lastInsertedSchedules, MMSlot slot) { PageGroup pageGroup = new PageGroupGenerator(mmunit, PlayerDb).Generate(); Guid pageGroupScheduledId = Guid.NewGuid(); TimeSpan currentStartTime = TimeSpan.FromSeconds(relativeStartSecond); Page[] pages = pageGroup.Pages.OrderBy(x => x.SortOrder).ToArray(); for (int i = 0; i < pages.Length; i++) { Page page = pages[i]; if (currentStartTime > TimeSpan.FromDays(1)) continue; PageSchedule pageSchedule = PlayerDb.PageSchedules.NewRow(); pageSchedule.Id = Guid.NewGuid(); pageSchedule.StartTime = TodayDate.Date.Add(currentStartTime); pageSchedule.DiagnosticText = $"{pageGroup.Name} Seite {i + 1}"; pageSchedule.PageGroupScheduleId = pageGroupScheduledId; pageSchedule.Page = page; pageSchedule.RingMetaData = Ring; pageSchedule.SlotId = slot.Id; currentStartTime = currentStartTime.Add(TimeSpan.FromSeconds((double)pageSchedule.Page.ExpectedDuration)); pageSchedule.Table.Rows.Add(pageSchedule); if (lastInsertedSchedules != null) lastInsertedSchedules.Add(pageSchedule); } if (pageGroup.DurationInSeconds == 0) Debug.WriteLine($"Duration = 0 Beitrag SchreenGroup {pageGroup.Name} ({pageGroup.Id})"); return currentStartTime.TotalSeconds; }
public void CreateActuallProgrammForAllSender() { DateTime programmDate = DateTime.Now; String protokollFileName = @""; DistributionRootInstance = new DistributionRoot(Data.DbServer3.MultiMedia, programmDate, programmDate.AddDays(1)); DistributionRootInstance.ClearAllForPlayListGeneration(); DistributionRootInstance.PrepareAllForPlayListGenerationIfHasNotBeenDone(); #if DEBUG #endif foreach (MMSender mmSender in Data.DbServer3.MultiMedia.MMSenders .Where(sel => sel.IsActive == true).OrderByDescending(ord => ord.NameId)) { Debug.WriteLine($"Start Playlisten Befüllung für {mmSender.NameId}"); SetActuallPlayerDb(mmSender); foreach (Dictionary<MMUnit, List<MMUnitTiming>> dictionary in DistributionRootInstance.ToDayAndTomorrowInvolvedMMUnitsPerMMSlot.Values) { foreach (MMUnit mmUnit in dictionary.Keys) { PageGroup pageGroup = new PageGroupGenerator(mmUnit,ActualRing.DataSet).Generate(); if (pageGroup.DurationInSeconds == 0) throw new Exception($"screenGroup.DurationInSeconds == 0 bei {pageGroup.Name} ({pageGroup.Id})"); } } ActualRing.SenderId = mmSender.Id; ActualRing.TargetDate = DateTime.Now.Date; // start first Part from Now to EndOfDay - with balancer status BalancerUsageInstance = new BalancerUsage(mmSender, ActualRing, ActualRing.TargetDate); BalancerUsageInstance.LoadActuallBalancers(mmSender); Dictionary<MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> activeMMUnitsPerMMSlotAndDateTimeToday = DistributionRootInstance.SelectActiveMMUnitsPerMMSlotAndDateTime(dataContext.DefaultRangeFrom); int numberOfActuallDayPlaylistEntries = CreateActuallProgrammForSender (mmSender, ActualRing, DistributionRootInstance.TodayActiveMMUnitsPerMMSlot, true, programmDate.TimeOfDay.TotalSeconds, TimeSpan.FromDays(1).Subtract(TimeSpan.FromSeconds(1)).TotalSeconds); Debug.WriteLine($"Für den Sender {mmSender.NameId} wurden für heute {numberOfActuallDayPlaylistEntries} Einträgeerzeugt"); Debug.WriteLine($"In der Datenbank sind für heute {ActualRing.PageSchedules.Count()} PageSchedules eingetragen"); // Start second Part from midnight to Now on next Day Dictionary < MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> activeMMUnitsPerMMSlotAndDateTimeTomorrow = DistributionRootInstance.SelectActiveMMUnitsPerMMSlotAndDateTime(dataContext.DefaultRangeTo); int numberOfNextDayPlaylistEntries = CreateActuallProgrammForSender (mmSender, ActualRing, DistributionRootInstance.TomorrowActiveMMUnitsPerMMSlot, false, 0, programmDate.AddDays(1).TimeOfDay.TotalSeconds); // midnight -> next Day nowTimeOfDay Debug.WriteLine($"Für den Sender {mmSender.NameId} wurden für morgen {numberOfNextDayPlaylistEntries} erzeugt"); Debug.WriteLine($"In der Datenbank sind für heute und morgen {ActualRing.PageSchedules.Count()} PageSchedules eingetragen"); FileInfo senderFileInfo = new FileInfo(VisualBasics.GetSenderPlaylistName(mmSender.NameId)); ActualRing.SaveAs_SerializedBinary(senderFileInfo); } Debug.WriteLine($"fertig mit dem Erzeugen der SerializedPlaylist für alle Sender"); }