Exemplo n.º 1
0
		public void LoadBeitragDistribution(DateTime? StartDate)
			{
			DistributionRootInstance = new DistributionRoot (Data.DbServer3.MultiMedia, (DateTime)StartDate,
				((DateTime)StartDate).AddDays(14));
			NextDaysActiveMMUnits = DistributionRootInstance.LoadFromToInvolvedMMUnitsPerMMSlot
				((DateTime)StartDate, ((DateTime)StartDate).AddDays(14));
			}
Exemplo n.º 2
0
		/// <summary>
		///     Generates a complete new ring into the provided <paramref name="ring" /> dataset. This should produce a complete 24 hour active ring which has no
		///     other logic then playing the right things at the right time, independet of the past.
		/// </summary>
		/// <param name="server">The source database</param>
		/// <param name="computerName">The name of the computer this ring is generated for.</param>
		/// <param name="ring">The target ring where all the generated data should be inserted at.</param>
		/// <remarks>
		///     Things which need to be done:
		///     <para>Set <see cref="RingMetaData.SenderId" /> to the targeting sender id.</para>
		///     <para>Generate <see cref="PageGroup" />s inside the database.</para>
		///     <para>
		///         Generate <see cref="Page" />s with the associated content (<see cref="Text" />, <see cref="Image" /> <see cref="Video" />,
		///         <see cref="DoubleTransition" />).
		///     </para>
		///     <para>
		///         Generate <see cref="PageSchedule" />s. <see cref="PageSchedule" />s in sequence which belongs to the same <see cref="PageGroup" /> needs to
		///         have the same <see cref="PageSchedule.PageGroupScheduleId" />.
		///     </para>
		/// </remarks>

		public void Generate(IServer server, string computerName, RingMetaData ring)
			{
			//if (DateTime.Now - server.Load<DateTime>("LastRefresh") > TimeSpan.FromDays(1))
			//	server.Save(StorageEnum.MultiMedia, null);

			//server.Save(StorageEnum.MultiMedia, null); //TODO Clears the current multimedia db


			MultiMedia db = GetMultiMedia(server);
			MMSender sender = GetMMSenderFromSenderOrComputerName(db, computerName);
			ring.Occasion = sender.NameId;
			ring.SenderId = sender.Id;
			sender.DataSet.SetHasBeenLoaded();
			DistributionRoot DistributionRootInstance = new DistributionRoot(db,ring.TargetDate);
			DistributionRootInstance.PreloadAllForAllTodayAndTomorrowMMunitsIfNotHasBeenLoaded();
			BalancerUsage balancerUsage = new BalancerUsage(sender, ring, ring.TargetDate)
				{
				TodaysActiveMMUnitsPerMMSlot = DistributionRootInstance.TodayActiveMMUnitsPerMMSlot
				};
			balancerUsage.LoadActuallBalancers(sender);
			RingGenerator ringGenerator = new RingGenerator(sender, ring, ring.TargetDate)
				{
				DistributionRootInstance = DistributionRootInstance,
				TodaysBalancers = (balancerUsage.TodaysBalancersPerSender.ContainsKey(sender))
						? balancerUsage.TodaysBalancersPerSender[sender] : null
				};

			ringGenerator.Generate();
			}
Exemplo n.º 3
0
		public void RefreshDistributionRoot(DateTime? from = null, DateTime? to = null)
			{
			if (from != null)
				DefaultRangeFrom = (DateTime)from;
			if (to != null)
				DefaultRangeTo = (DateTime)to;
			DistributionRoot = new DistributionRoot(this, DefaultRangeFrom, DefaultRangeTo);
			}
Exemplo n.º 4
0
		public void Init()
			{
			SourceDb.LoadAll_IfHasNotBeenLoaded();
			SourceDb.LoadAllForScheduling_IfHasNotBeenLoaded();
			TargetDb.LoadSchema();
			foreach (CsDbTable table in TargetDb.Tables)
				{
				table.HasBeenLoaded = true;
				}
			DistributionRootInstance = new DistributionRoot(SourceSender.DataSet);
			//DistributionRootInstance.LoadActuallBalancers(SourceSender);
			}
Exemplo n.º 5
0
	    /// <summary>
		///     Generates a complete new ring into the provided <paramref name="ring" /> dataset. This should produce a complete 24 hour active ring which has no
		///     other logic then playing the right things at the right time, independet of the past.
		/// </summary>
		/// <param name="db">The source database</param>
		/// <param name="computerName">The name of the computer this ring is generated for.</param>
		/// <param name="ring">The target ring where all the generated data should be inserted at.</param>
		/// <remarks>
		///     Things which need to be done:
		///     <para>Set <see cref="RingMetaData.SenderId" /> to the targeting sender id.</para>
		///     <para>Generate <see cref="PageGroup" />s inside the database.</para>
		///     <para>
		///         Generate <see cref="Page" />s with the associated content (<see cref="Text" />, <see cref="Image" /> <see cref="Video" />,
		///         <see cref="DoubleTransition" />).
		///     </para>
		///     <para>
		///         Generate <see cref="PageSchedule" />s. <see cref="PageSchedule" />s in sequence which belongs to the same <see cref="PageGroup" /> needs to
		///         have the same <see cref="PageSchedule.PageGroupScheduleId" />.
		///     </para>
		/// </remarks>
		public void Generate(MultiMedia db, string computerName, RingMetaData ring)
			{
			MMSender sender = GetMMSenderFromSenderOrComputerName(db, computerName);
			ring.SenderId = sender.Id;
			sender.DataSet.SetHasBeenLoaded();
			DistributionRoot DistributionRootInstance = new DistributionRoot(db,ring.TargetDate);
			DistributionRootInstance.PreloadAllForAllTodayAndTomorrowMMunitsIfNotHasBeenLoaded();
			BalancerUsage balancerUsage = new BalancerUsage(sender, ring, ring.TargetDate)
				{
				TodaysActiveMMUnitsPerMMSlot = DistributionRootInstance.TodayActiveMMUnitsPerMMSlot
				};
			balancerUsage.LoadActuallBalancers(sender);
			RingGenerator ringGenerator = new RingGenerator(sender, ring, ring.TargetDate)
				{
				DistributionRootInstance = DistributionRootInstance,
				TodaysBalancers = balancerUsage.TodaysBalancersPerSender[sender]
				};

			ringGenerator.Generate();
			}
Exemplo n.º 6
0
	    public void Update(IServer server, string computerName, RingMetaData ring)
			{
			MultiMedia db = GetMultiMedia(server);
			MMSender sender = GetMMSenderFromSenderOrComputerName(db, computerName);
			ring.SenderId = sender.Id;
			sender.DataSet.SetHasBeenLoaded();
			DistributionRoot DistributionRootInstance = new DistributionRoot(db, ring.TargetDate);
			DistributionRootInstance.PreloadAllForAllTodayAndTomorrowMMunitsIfNotHasBeenLoaded();
			BalancerUsage balancerUsage = new BalancerUsage(sender, ring, ring.TargetDate)
				{
				TodaysActiveMMUnitsPerMMSlot = DistributionRootInstance.TodayActiveMMUnitsPerMMSlot,
				TomorrowsActiveMMUnitsPerMMSlot = DistributionRootInstance.TomorrowActiveMMUnitsPerMMSlot
				};
			balancerUsage.LoadActuallBalancers(sender);
			RingUpdater ringUpdater = new RingUpdater(sender, ring, ring.TargetDate)
				{
				DistributionRootInstance = DistributionRootInstance,
				TodaysBalancers = (balancerUsage.TodaysBalancersPerSender.ContainsKey(sender))
						? balancerUsage.TodaysBalancersPerSender[sender] : null,
				TomorrowsBalancers = (balancerUsage.TomorrowsBalancersPerSender.ContainsKey(sender))
						? balancerUsage.TodaysBalancersPerSender[sender] : null,
				};
			ringUpdater.Update();
			}
Exemplo n.º 7
0
		public void TesMMUnitTimingFunctions()
			{
			Data.DbServer3.MultiMedia.LoadAll_IfHasNotBeenLoaded();
			DistributionRoot DistributionRootInstance 
				= new DistributionRoot
				(Data.DbServer3.MultiMedia, DateTime.Now);
			DistributionRootInstance.PreloadAllForAllTodayAndTomorrowMMunitsIfNotHasBeenLoaded();
			Dictionary<MMSlot, Dictionary<MMUnit, List<MMUnitTiming>>> ToDayAndTomorrowInvolvedMMUnitsPerMMSlot
				= DistributionRootInstance.ToDayAndTomorrowInvolvedMMUnitsPerMMSlot;
			Debug.WriteLine($"");
			Debug.WriteLine($"ToDayAndTomorrowInvolvedMMUnitsPerMMSlot");

			foreach (MMSlot mmSlot in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot.Keys)
				{
				if (!mmSlot.NameId.Contains("Kauf"))
					continue;
				Debug.WriteLine($"{mmSlot.NameId}");
				foreach (MMUnit mmUnit in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot].Keys)
					{
					Debug.WriteLine($"\t{mmUnit.NameId}");
					foreach (MMUnitTiming mmUnitTiming in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot][mmUnit])
						{
						Debug.WriteLine($"\t\t{mmUnitTiming.FreiText}");						}
						}
				}

			Debug.WriteLine($"");
			Debug.WriteLine($"TodayActiveMMUnitsPerMMSlo");

			foreach (MMSlot mmSlot in DistributionRootInstance.TodayActiveMMUnitsPerMMSlot.Keys)
				{
				if (!mmSlot.NameId.Contains("Kauf"))
					continue;
				Debug.WriteLine($"{mmSlot.NameId}");
				foreach (MMUnit mmUnit in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot].Keys)
					{
					Debug.WriteLine($"\t{mmUnit.NameId}");
					foreach (MMUnitTiming mmUnitTiming in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot][mmUnit])
						{
						Debug.WriteLine($"\t\t{mmUnitTiming.FreiText}");
						}
					}
				}

			Debug.WriteLine($"");
			Debug.WriteLine($"TomorrowActiveMMUnitsPerMMSlot");

			foreach (MMSlot mmSlot in DistributionRootInstance.TomorrowActiveMMUnitsPerMMSlot.Keys)
				{
				if (!mmSlot.NameId.Contains("Kauf"))
					continue;
				Debug.WriteLine($"{mmSlot.NameId}");
				foreach (MMUnit mmUnit in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot].Keys)
					{
					Debug.WriteLine($"\t{mmUnit.NameId}");
					foreach (MMUnitTiming mmUnitTiming in ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlot][mmUnit])
						{
						Debug.WriteLine($"\t\t{mmUnitTiming.FreiText}");
						}
					}
				}
			MMSender mmSender = Data.DbServer3.MultiMedia.MMSenders.FindOrLoad_via_NameId("Haus");
			RingPlayerDb ActuallPlayerDb = new RingPlayerDb();
			ActuallPlayerDb.Set_DbProxy(new DirectHsServerSqlConnector(){ Catalog = RingPlayerDb.NativeName });
			ActuallPlayerDb.LoadSchema();
			ActuallPlayerDb.SetHasBeenLoaded();

			RingMetaData testRingMetaData = ActuallPlayerDb.RingMetaDatas.NewRow();
			testRingMetaData.SenderId = mmSender.Id;
			//ringMetaData.ComputerId = Guid.NewGuid();
			//ringMetaData.ComputerName = Environment.MachineName;
			testRingMetaData.TargetDate = DateTime.Now;
			testRingMetaData.CreationDate = DateTime.Now;
			testRingMetaData.Id = 1;

			//AddOnRingDistribution.DataCollector.BalancerUsage balancerUsage
			//	= new AddOnRingDistribution.DataCollector.BalancerUsage(mmSender, testRingMetaData, DateTime.Now)
			//	{
			//	TodaysActiveMMUnitsPerMMSlot = DistributionRootInstance.TodayActiveMMUnitsPerMMSlot,
			//	TomorrowsActiveMMUnitsPerMMSlot = DistributionRootInstance.TomorrowActiveMMUnitsPerMMSlot
			//	};
			//balancerUsage.LoadActuallBalancers(mmSender);
			//RingUpdater ringUpdater = new RingUpdater(mmSender, testRingMetaData, DateTime.Now)
			//	{
			//	DistributionRootInstance = DistributionRootInstance,
			//	TodaysBalancers = balancerUsage.TodaysBalancersPerSender[mmSender]
			//	};

			}
Exemplo n.º 8
0
		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");
			}
Exemplo n.º 9
0
		public String LoadTimedMMUnitsForDefinedTables(DateTime DateTimeToCheckFrom, DateTime DateTimeToCheckTo,
					List<String> TableNames, ref String AdditionalMessage)
			{
			DistributionRoot = new DistributionRoot(dataContext.MultiMedia,
				DateTimeToCheckFrom, DateTimeToCheckTo);
			List<MMSlot> mmSlots = new List<MMSlot>();
			AdditionalMessage = String.Empty;
			foreach (string tableName in TableNames)
				{
				TableDefinition tableDefinition = dataContext.WPMediaAddOnData
						.TableDefinitions.Find_via_TableName(tableName);
				mmSlots.Add(dataContext.MultiMedia.MMSlots.Find_via_NameId(tableName));
				if (tableDefinition == null)
					{
					return $"Mit dem TabellenName \"{tableName}\" " +
										$"konnte keine Tabelle lokalsiert werden";
					}

				}
			Dictionary <MMUnit, List<MMUnitTiming>>  IvolvedMMUnits = DistributionRoot.ToDayAndTomorrowInvolvedMMUnitsPerMMSlot[mmSlots[0]];
			List<Guid> mMUnitsIds = new List<Guid>();
			foreach (DbEntities.dbserver3.wpmediaaddondata.rows.Timing timing in 
					dataContext.WPMediaAddOnData.Timings.Load_Between
						(DateTimeToCheckFrom, DateTimeToCheckTo, TableNames, true))
				{
				if (!mMUnitsIds.Contains((Guid)timing.ConnectedId))
					mMUnitsIds.Add((Guid)timing.ConnectedId);
				}
			AdditionalMessage = $"Mit der Tabellenauswahl \"{String.Join(", ", TableNames)}\" " +
								$"konnten {mMUnitsIds.Count} aktive Einträge gefunden werden";
			int SortOrder = 0;
			List<Guid> MMInformationIdsToPreload = new List<Guid>();
			dataContext.MultiMedia.PreLoadAllForAllMMUnits(mMUnitsIds);
			foreach (MMUnit mMUnit in dataContext.MultiMedia.MMUnits.Load_via_MMUnitIds(mMUnitsIds))
				{
				UnitsToProcess.Add(new ActiveMMUnitInTime(mMUnit, SortOrder++) as SearchBase);
				MMInformationIdsToPreload.Add((Guid)mMUnit.MMInformationenId);
				}
			dataContext.MultiMedia.MMInformationen.Load_via_Ids(MMInformationIdsToPreload);
			return String.Empty;
			}