Exemple #1
0
		void FillProgrammBlock(MMProgrammBlock programmBlock, Dictionary<MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> activeMMUnitsPerMMSlotAndDateTime)
			{
			double blockStartSecond = (programmBlock.MMProgrammBlockTimings
						.First().TimeA.GetValueOrDefault()).TimeOfDay.TotalSeconds;

			double blockEndSecond = (programmBlock.MMProgrammBlockTimings
				.First().TimeB.GetValueOrDefault()).TimeOfDay.TotalSeconds - 5;




			int numberOfPlaylistEntries = -1;
			double runningStartSecond = blockStartSecond;


			while ((runningStartSecond < blockEndSecond) && (numberOfPlaylistEntries != 0))
				{
				if (numberOfPlaylistEntries == -1)
					numberOfPlaylistEntries = 0;


				foreach (MMProgrammBlockToMMSlot mmProgrammBlockToMMSlot in programmBlock.Get_MMSlotsZuMMProgrammBlockOrdered)
					{
					//Entering Slot level
					if (!DistributionRootInstance.ToDayAndTomorrowInvolvedMMUnitsPerMMSlot.ContainsKey(mmProgrammBlockToMMSlot.MMSlot))
						{
						//skipping slots which have no MMUnits
						continue;
						}


					List<PageSchedule> slotPageSchedules = new List<PageSchedule>();
					switch (mmProgrammBlockToMMSlot.MMProgrammBlockToMMSlotsPlayingTyp.TypNameId)
						{
						case "Balanced":
								{
								double timeLimit = runningStartSecond + (double)mmProgrammBlockToMMSlot.MaximalDurationInSeconds;
								List<PageSchedule> balancedPageSchedules = new List<PageSchedule>();
								while ((runningStartSecond < blockEndSecond)
									&& (runningStartSecond < timeLimit))
									{
									TimeSpan RemainingToBlockEnd = (blockEndSecond < timeLimit)
										? TimeSpan.FromSeconds(blockEndSecond - runningStartSecond)
										: TimeSpan.FromSeconds(timeLimit - runningStartSecond);
									MMUnit toPlayMMUnit = BalancerUsageInstance.TodaysBalancersPerSender
										[SourceSender][mmProgrammBlockToMMSlot.MMSlot].GetNextItem(RemainingToBlockEnd);
									runningStartSecond = CreateScheduledPagesFromMMUnit
										(toPlayMMUnit, runningStartSecond, ref slotPageSchedules);
									}
								break;
								}
						case "Standard":
							foreach (MMUnit toPlay in DistributionRootInstance.TodayActiveMMUnitsPerMMSlot[mmProgrammBlockToMMSlot.MMSlot].Keys)
								{
								if (!activeMMUnitsPerMMSlotAndDateTime[mmProgrammBlockToMMSlot.MMSlot]
									.Keys.Contains(toPlay))
									continue;

								//Debug.WriteLine($"\t\t\t{toPlay.NameId} - aus {toPlay.TableName}");
								if (runningStartSecond > blockEndSecond)
									break;


								runningStartSecond = CreateScheduledPagesFromMMUnit(toPlay, runningStartSecond, ref slotPageSchedules);
								numberOfPlaylistEntries++;
								}
							break;
						case "TimeLimited":
							break;
						default:
							throw new Exception($"Playing Typ {mmProgrammBlockToMMSlot.MMProgrammBlockToMMSlotsPlayingTyp.TypNameId} ist fehlerhaft");
						}
					if (runningStartSecond >= blockEndSecond)
						break;
					}
				}
			}
		private void ProgrammBloeckeDeleteRequested (MMProgrammBlock programmBlockToChange)
			{
			if (MessageBox.Show("Wollen Sie wirklich den ProgrammBlock\r\n\""
								 + programmBlockToChange.NameId
								 + "\"\r\nund seine Verknüpfungen zu Sendern\r\nsowie die Verbindungen zu Sendungen löschen?") != MessageBoxResult.OK)
				return;
			}
		int FillProgrammBlock(MMSender sender, RingMetaData ringMetaData, MMProgrammBlock programmBlock,
			Dictionary<MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> activeMMUnitsPerMMSlotAndDateTime,
			Dictionary<MMSlot, DbEntities.CustomClasses.StandardModelle.StatisticalBalancer<MMUnit>> actuallBalancers, DateTime programmDate,
			double runningStartSecond, double runningEndSeconds)
			{
			double blockStartSecond = ((DateTime)programmBlock.MMProgrammBlockTimings
						.FirstOrDefault().TimeA).TimeOfDay.TotalSeconds;
			double blockEndSecond = ((DateTime)programmBlock.MMProgrammBlockTimings
				.FirstOrDefault().TimeB).TimeOfDay.TotalSeconds - 5;
			if (runningStartSecond > blockEndSecond)
				return 0;
			if (runningStartSecond < blockStartSecond)
				return 0;
			if (runningStartSecond < 0)
				runningStartSecond = blockStartSecond;
			if (runningEndSeconds > blockEndSecond)
				runningEndSeconds = blockEndSecond;
			int numberOfPlaylistEntries = -1;
			while ((runningStartSecond < blockEndSecond)
					&& (numberOfPlaylistEntries != 0))
				{
				if (numberOfPlaylistEntries == -1)
					numberOfPlaylistEntries = 0;
				//					Debug.WriteLine($"\t{programmBlock.NameId}");
				foreach (MMProgrammBlockToMMSlot mmProgrammBlockToMMSlot in programmBlock.Get_MMSlotsZuMMProgrammBlockOrdered)
					{
					//Debug.WriteLine($"\t\t{mmProgrammBlockToMMSlot.MMSlot.NameId} (MMSlot), Typ = {mmProgrammBlockToMMSlot.MMProgrammBlockToMMSlotsPlayingTyp.TypNameId}");
					if (!activeMMUnitsPerMMSlotAndDateTime.ContainsKey(mmProgrammBlockToMMSlot.MMSlot))
						{
						//							Debug.WriteLine($"\t\t\t-------- nothing to Play ------------------");
						continue;
						}
					List<PageSchedule> slotPageSchedules = new List<PageSchedule>();
					switch (mmProgrammBlockToMMSlot.MMProgrammBlockToMMSlotsPlayingTyp.TypNameId)
						{
						case "Balanced":
								{
								//if (DistributionRootInstance.TodaysBalancersPerSender.Keys.Count == 0)
								//	DistributionRootInstance.LoadActuallBalancers(SourceSender);
								double timeLimit = runningStartSecond + (double)mmProgrammBlockToMMSlot.MaximalDurationInSeconds;
								List<PageSchedule> balancedPageSchedules = new List<PageSchedule>();
								while ((runningStartSecond < blockEndSecond)
									&& (runningStartSecond < timeLimit))
									{
									TimeSpan RemainingToBlockEnd = (blockEndSecond < timeLimit)
										? TimeSpan.FromSeconds(blockEndSecond - runningStartSecond)
										: TimeSpan.FromSeconds(timeLimit - runningStartSecond);
									runningStartSecond = AddPlayerScreenGroupToPlayList(ringMetaData, mmProgrammBlockToMMSlot.Id,
										 actuallBalancers[mmProgrammBlockToMMSlot.MMSlot].GetNextItem(RemainingToBlockEnd),
										runningStartSecond, ref balancedPageSchedules);
									}
								break;
								}
						case "Standard":
							foreach (MMUnit toPlay in activeMMUnitsPerMMSlotAndDateTime[mmProgrammBlockToMMSlot.MMSlot].Keys)
								{
								//Debug.WriteLine($"\t\t\t{toPlay.NameId} - aus {toPlay.TableName}");
								if (runningStartSecond > blockEndSecond)
									break;
								runningStartSecond = AddPlayerScreenGroupToPlayList(ringMetaData,
									mmProgrammBlockToMMSlot.Id, toPlay,
									runningStartSecond, ref slotPageSchedules);
								numberOfPlaylistEntries++;
								}
							break;
						case "TimeLimited":
							break;
						default:
							throw new Exception($"Playing Typ {mmProgrammBlockToMMSlot.MMProgrammBlockToMMSlotsPlayingTyp.TypNameId} ist fehlerhaft");
						}
					if (runningStartSecond >= blockEndSecond)
						break;
					//						Debug.WriteLine($"");
					}
				}
			return numberOfPlaylistEntries;
			}
		private void ProgrammBloeckeChangeRequested (MMProgrammBlock programmBlockToChange)
			{
			Window ProgrammBlockWindow = new Window();
			ProgrammBlockWindow.SizeToContent = SizeToContent.WidthAndHeight;
			ProgrammBlockWindow.Content = new MMProgrammBlockControl();
			if (programmBlockToChange != MMProgrammBlockManagementModellInstance.ProgrammBlockInstance)
				throw new Exception("programmBlockToChange != SchedulingDataModellInstance.SelectedProgrammBloecke");
			(ProgrammBlockWindow.Content as MMProgrammBlockControl).MMProgrammBlockManagementModellInstance =
				MMProgrammBlockManagementModellInstance;
			ProgrammBlockWindow.Title = $"Daten des ProgrammBlockes " +
										$"\"{programmBlockToChange.NameId}\" des Senders " +
										$"\"{programmBlockToChange.MMSender.NameId}\"";
			ProgrammBlockWindow.ShowDialog();
			if ((ProgrammBlockWindow.Content as MMProgrammBlockControl).Return == true)
				{
				MMProgrammBlockManagementModellInstance.DataContext.MultiMedia.MMProgrammBlocks.SaveChanges(new Object ());
				MMProgrammBlockManagementModellInstance.DataContext.MultiMedia.MMProgrammBlocks.AcceptChanges();
				}
			else
				{
				MMProgrammBlockManagementModellInstance.DataContext.MultiMedia.MMProgrammBlocks.LoadThenFind(programmBlockToChange.Id);
				MMProgrammBlockManagementModellInstance.DataContext.MultiMedia.MMProgrammBlocks.AcceptChanges();
				}
			}