Exemple #1
0
		public RingUpdater(MMSender senderToWorkFor, RingMetaData ring, DateTime todayDate)
			{
			SenderToWorkFor = senderToWorkFor;
			Ring = ring;
			TodayDate = todayDate;
			Init();
			}
Exemple #2
0
		public RingGenerator(MMSender targetSender, RingMetaData targetRing, DateTime targetDate)
			{
			SourceSender = targetSender;
			TargetRing = targetRing;
			TargetDate = targetDate;

			Init();
			}
		public MMSender CloneSender(MMSender mMSenderToClone, String newSenderName)
			{
			if (String.IsNullOrEmpty(newSenderName))
				newSenderName = "Clone von " + mMSenderToClone.NameId;
			MMSender newMMSender = DataContext.MultiMedia.MMSenders.NewRow();
			Guid savedSenderId = newMMSender.Id;
			DbBasics.CopyRowContent((DataRow)mMSenderToClone, (DataRow) newMMSender);

			newMMSender.Id = savedSenderId;
			newMMSender.NameId = newSenderName;
			newMMSender.IsActive = false;
			DataContext.MultiMedia.MMSenders.Rows.Add(newMMSender);
			DataContext.MultiMedia.MMSenders.SaveChanges(new Object());
			DataContext.MultiMedia.MMSenders.AcceptChanges();

			foreach (MMProgrammBlock oldMMProgrammBlock in mMSenderToClone.MMProgrammBlocks)
				{
				MMProgrammBlock newMMProgrammBlock = DataContext.MultiMedia.MMProgrammBlocks.NewRow();
				Guid savedBlockId = newMMProgrammBlock.Id;
				DbBasics.CopyRowContent(oldMMProgrammBlock, newMMProgrammBlock);

				newMMProgrammBlock.Id = savedBlockId;
				newMMProgrammBlock.MMSenderId = newMMSender.Id;
				MMProgrammBlockTiming newMMProgrammBlockTiming = DataContext.MultiMedia.MMProgrammBlockTimings.NewRow();
				Guid savedTimingId = newMMProgrammBlockTiming.Id;
				DbBasics.CopyRowContent(oldMMProgrammBlock.NamingTiming, newMMProgrammBlockTiming);
				newMMProgrammBlockTiming.Id = savedTimingId;
				newMMProgrammBlockTiming.MMProgrammBlockId = newMMProgrammBlock.Id;

				DataContext.MultiMedia.MMProgrammBlocks.Rows.Add(newMMProgrammBlock);
				DataContext.MultiMedia.MMProgrammBlocks.SaveChanges(new Object());
				DataContext.MultiMedia.MMProgrammBlocks.AcceptChanges();

				DataContext.MultiMedia.MMProgrammBlockTimings.Rows.Add(newMMProgrammBlockTiming);
				DataContext.MultiMedia.MMProgrammBlockTimings.SaveChanges();
				DataContext.MultiMedia.MMProgrammBlockTimings.AcceptChanges();
				List<MMProgrammBlockToMMSlot> listToAdd = new List<MMProgrammBlockToMMSlot>();
				foreach (MMProgrammBlockToMMSlot oldMMProgrammBlockToMMSlot in oldMMProgrammBlock.MMProgrammBlockToMMSlots)
					{
					MMProgrammBlockToMMSlot newMMProgrammBlockToMMSlot = DataContext
								.MultiMedia.MMProgrammBlockToMMSlots.NewRow();
					Guid savedSendungZuProgrammBlock = (Guid)newMMProgrammBlockToMMSlot.MMProgrammBlockId;
					DbBasics.CopyRowContent(oldMMProgrammBlockToMMSlot, newMMProgrammBlockToMMSlot);
					newMMProgrammBlockToMMSlot.MMProgrammBlockId = savedSendungZuProgrammBlock;
					newMMProgrammBlockToMMSlot.Id = savedSendungZuProgrammBlock;
					newMMProgrammBlockToMMSlot.MMProgrammBlockId = newMMProgrammBlock.Id;
					listToAdd.Add(newMMProgrammBlockToMMSlot);
					}
				foreach (MMProgrammBlockToMMSlot mMProgrammBlockToMMSlot in listToAdd)
					{
					DataContext.WPMedia.SendungenZuProgrammBloecke.Rows.Add(mMProgrammBlockToMMSlot);
					}
				DataContext.WPMedia.SendungenZuProgrammBloecke.SaveChanges();
				DataContext.WPMedia.SendungenZuProgrammBloecke.AcceptChanges();
				}
			DataContext.WPMedia.Senders.Get_AllSender = null;
			return newMMSender;
			}
Exemple #4
0
		public BalancerUsage(MMSender sender, RingMetaData ring,
			DateTime targetDate)
			{
			Sender = sender;
			this.MultiMediaDb = sender.DataSet;
			Ring = ring;
			PlayerDb = Ring.DataSet;
			TodaysDate = targetDate;
			TomorrowsDate = TodaysDate.AddDays(1);
			}
Exemple #5
0
		public RingGenerator(MMSender targetSender, DateTime targetDate)
			{
			RingPlayerDb playerDb = new RingPlayerDb();
			playerDb.Set_DbProxy(new DirectHsServerSqlConnector() {Catalog = RingPlayerDb.NativeName});
			playerDb.LoadSchema();

			TargetRing = playerDb.RingMetaDatas.NewRow();
			TargetRing.SenderId = targetSender.Id;
			//TargetRing.ComputerId = Guid.NewGuid();
			//TargetRing.ComputerName = Environment.MachineName;
			//TargetRing.RingId = 1;
			//TargetRing.CreatorNameId = CsGlobal.Os.Info.ComputerName + " " + CsGlobal.Os.Info.CurrentUser;
			TargetRing.CreationDate = DateTime.Now;
//			TargetRing.TransferTime = null;
			//TargetRing.Status = RingMetaDataStates.Created;
			TargetRing.Table.Rows.Add(TargetRing);

			SourceSender = targetSender;
			TargetDate = targetDate;

			Init();
			}
Exemple #6
0
		private Dictionary<MMSlot, StatisticalBalancer<MMUnit>> LoadActuallBalancers
			(MMSender mmSender, DateTime dateTimeToCheck)
			{
			Dictionary<MMSlot, StatisticalBalancer<MMUnit>> entriesActuallInBalancer
				= new Dictionary<MMSlot, StatisticalBalancer<MMUnit>>();
			List<MMSlot> balancedMMSlotsToCheck = new List<MMSlot>();
			foreach (MMProgrammBlock programmBlock in mmSender.Get_OrderedProgrammBloecke)
				{
				foreach (MMProgrammBlockToMMSlot mmProgrammBlockToMMSlot in programmBlock.Get_MMSlotsZuMMProgrammBlockOrdered
					.Where(whe => whe.MMProgrammBlockToMMSlotsPlayingTyp.Id == Guid.Parse("F173BC3B-F8B4-407D-90B5-1B717219C444")))
					if (!balancedMMSlotsToCheck.Contains(mmProgrammBlockToMMSlot.MMSlot))
						balancedMMSlotsToCheck.Add(mmProgrammBlockToMMSlot.MMSlot);
				}
			foreach (MMSlot mmSlot in balancedMMSlotsToCheck)
				{
				if (!entriesActuallInBalancer.Keys.Contains(mmSlot))
					{
					if (dateTimeToCheck.Date == TodaysDate.Date)
						{
/*
//TODO
						PlayerDb.SetHasBeenLoaded();
						RingUpdater ringUpdater = new RingUpdater(mmSender, Ring, Ring.TargetDate);
						ringUpdater.Load();
						if (ringUpdater.BalancerPerBalancerId.ContainsKey(mmSlot.Id))
							entriesActuallInBalancer[mmSlot]
								= ringUpdater.BalancerPerBalancerId[mmSlot.Id];
						else
*/
							entriesActuallInBalancer[mmSlot]
								= new StatisticalBalancer<MMUnit>();
						}
					else
						{
						entriesActuallInBalancer[mmSlot]
							= new StatisticalBalancer<MMUnit>();
						}
					}
				//TODO Actualice the balancer content
				//Debug.WriteLine($"Vor dem Ergänzen der Balancer - {dateTimeToCheck} für den Sender {mmSender.NameId}");
				//Debug.WriteLine($"\tSlot = {mmSlot.NameId}");
				//foreach (MMUnit mmUnit in TodayActiveMMUnitsPerMMSlot[mmSlot].Keys)
				//	{
				//	Debug.WriteLine($"\t\t{mmUnit.NameId} - {((IContainTimingAttributes)mmUnit.MMUnitTimings.FirstOrDefault()).FreiText}");
				//	

				ActualizeBalancers(entriesActuallInBalancer[mmSlot],
					TodaysActiveMMUnitsPerMMSlot[mmSlot].Keys.ToArray());
				
				//Debug.WriteLine($"Actuelle Entries in Balancer nach dem Aktualisieren");
				//foreach (MMUnit entriesKey in entriesActuallInBalancer[mmSlot].Entries.Keys)
				//	{
				//	Debug.WriteLine($"\t{entriesKey.NameId}");
				//	}
				}
			return entriesActuallInBalancer;
			}
Exemple #7
0
		public void LoadActuallBalancers(MMSender mmSender)
			{
			Dictionary<MMSlot, StatisticalBalancer<MMUnit>> actuallBalancerForSender
				= LoadActuallBalancers(mmSender, TodaysDate);

			if (actuallBalancerForSender.Keys.Count > 0)
				{
				foreach (MMSlot mmSlot in actuallBalancerForSender.Keys)
					{
					TodaysBalancers[mmSlot] = actuallBalancerForSender[mmSlot];
					TodaysBalancersPerSender[mmSender] = _todaysBalancers;
					}
				}
			actuallBalancerForSender
				= LoadActuallBalancers(mmSender, TomorrowsDate);
			if (actuallBalancerForSender.Keys.Count > 0)
				{
				foreach (MMSlot mmSlot in actuallBalancerForSender.Keys)
					{
					TomorrowBalancers[mmSlot] = actuallBalancerForSender[mmSlot];
					TomorrowsBalancersPerSender[mmSender] = _tomorrowBalancers;
					}
				}
			}
		public void SetActuallPlayerDb(MMSender mmSender)
			{

			FileInfo actuallDBFileInfo = new FileInfo(VisualBasics.GetSenderPlaylistName(mmSender.NameId));
			if ((actuallDBFileInfo.Exists)
				&& (actuallDBFileInfo.Length > 2000))
				{
				String Message = String.Empty;
				try
					{
					RingPlayerDb CommonDataSet= actuallDBFileInfo.LoadAs_Object_From_SerializedBinary<RingPlayerDb>();
					ActualRing = CreateNewRingInstance();
					ActualRing.DataSet.Merge(CommonDataSet);
					ActualRing.DataSet.SetHasBeenLoaded();
					}
				catch (Exception Excp)
					{
					Message = Excp.ToString();
					
					ActualRing = CreateNewRingInstance();
					}
				}
			else
				{
				ActualRing = CreateNewRingInstance();
				ActualRing.DataSet.SaveAs_SerializedBinary(actuallDBFileInfo);
				}
			if (ActualRing != null)
				{
				ActualRing.SourceFileName = actuallDBFileInfo.FullName;
				ActualRing.SourceCreationDateTime = actuallDBFileInfo.LastWriteTime;
				_selectedPageGroupSchedule = ActualRing.ScheduledPageGroups;
				}
			else
				{
				_selectedPageGroupSchedule = null;
				}
			}
		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;
			}
Exemple #10
0
		public int CreateActuallProgrammForSender(MMSender mmSender, RingMetaData ringMetaData,
			Dictionary<MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> activeMMUnitsPerMMSlot,
			
			bool isToday, double runningStartSeconds, double runningEndSeconds)
			{
			int numberOfPlaylistEntries = 0;
			Dictionary<MMSlot, DbEntities.CustomClasses.StandardModelle.StatisticalBalancer<MMUnit>> balancersToUse = null;
			if (isToday)
				{
				if (BalancerUsageInstance.TodaysBalancersPerSender.Keys.Contains(mmSender))
					balancersToUse = BalancerUsageInstance.TodaysBalancersPerSender[mmSender];
				}
			else
				{
				if (BalancerUsageInstance.TomorrowsBalancersPerSender.Keys.Contains(mmSender))
					balancersToUse = BalancerUsageInstance.TomorrowsBalancersPerSender[mmSender];
				}
			foreach (MMProgrammBlock programmBlock in mmSender.Get_OrderedProgrammBloecke)
				{
				numberOfPlaylistEntries += FillProgrammBlock(mmSender, ringMetaData, programmBlock,
					activeMMUnitsPerMMSlot, balancersToUse,
					(isToday) ? dataContext.DefaultRangeFrom : dataContext.DefaultRangeTo,
					runningStartSeconds, runningEndSeconds);
				}
			Debug.WriteLine($"Für den Sender {mmSender.NameId} wurden {numberOfPlaylistEntries} erzeugt");

			return numberOfPlaylistEntries;
			}
		private void SenderDeleteRequested (MMSender SenderToDelete)
			{
			if (MessageBox.Show ("Wollen Sie wirklich den Sender\r\n\""
								 + SenderToDelete.NameId
								 + "\"\r\nund seine Verknüpfungen zu\r\nden ProgrammBlöcken und den Sendungen löschen?") != MessageBoxResult.OK)
				return;
			if (SenderToDelete.IsActive != false)
				{
				MessageBox.Show($"Sie können Sender nur dann löschen,\r\nwenn Sie nicht aktiv sind!!");
				return;
				}
			MMSenderManagementModellInstance.DeleteMMSender(SenderToDelete);
			}
		private void SenderChangeRequested(MMSender SenderToChange)
			{
			Window SenderWindow = new Window ();
			SenderWindow.SizeToContent = SizeToContent.WidthAndHeight;
			SenderWindow.Content = new MMSenderControl();
			if (SenderToChange != MMSenderManagementModellInstance.MMSenderInstance)
				throw new Exception ("SenderToChange != SchedulingDataModellInstance.SelectedSender");
			(SenderWindow.Content as MMSenderControl).MMSenderManagementModellInstance.MMSenderInstance = SenderToChange;
			SenderWindow.Title = "Daten des Senders \"" + SenderToChange.NameId + "\"";
			SenderWindow.ShowDialog ();
			if ((SenderWindow.Content as MMSenderControl).Return == true)
				{
				}
			}
		public void DeleteMMSender(MMSender senderToDelete)
			{
			foreach (MMProgrammBlock programmBlock in senderToDelete.MMProgrammBlocks)
				{
				foreach (MMProgrammBlockTiming timing in DataContext.MultiMedia.MMProgrammBlockTimings.LoadThenFind_By_MMProgrammBlockId(programmBlock.Id))
					{
					timing.Delete();
					}
				}
			DataContext.MultiMedia.MMProgrammBlockTimings.SaveChanges();
			DataContext.MultiMedia.MMProgrammBlockTimings.AcceptChanges();
			senderToDelete.Delete();
			DataContext.MultiMedia.MMSenders.SaveChanges(new Object ());
			DataContext.MultiMedia.MMSenders.AcceptChanges();
			DataContext.MultiMedia.MMSenders.Get_AllSender = null;
			}