Esempio n. 1
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();
			}
Esempio 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="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();
			}
Esempio n. 3
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();
			}
Esempio n. 4
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]
			//	};

			}