Ejemplo n.º 1
0
		private Information CheckOrCreateInformation(BannerData bannerData)
			{
			Information relatedInformation = null;
			ProcessConnector[] relatedConnectoren = BannerConnectoren.Where(whe => whe.TableId == bannerData.Id).ToArray();
			foreach (ProcessConnector processConnector in relatedConnectoren)
				{
				if (relatedInformation == null)
					relatedInformation = processConnector.Information;
				else
					{
					if (relatedInformation != processConnector.Information)
						throw new Exception($"Multiple Informationen-Fehler bei {bannerData.NameId} ({bannerData.Id})");
					}
				}
			if (relatedInformation == null)
				{
				relatedInformation = Data.DbServer3.AltErlaaInfo.CreateDummyInformation(bannerData.Id,
					"Banner", "BannerData", bannerData.NameId, (DateTime)  bannerData.ModifyTimeStamp, true);
				}
			if (MMInformationenWithBannerConnectoren
					.Where(whe => whe.Id == relatedInformation.Id)?.FirstOrDefault() == null)
				{
				MMInformation mmRelatedInformation = CreateNewDummyBannerInformation(relatedInformation);
				}
			return relatedInformation;
			}
Ejemplo n.º 2
0
		private List<MMUnitTiming> CheckOrCreateMMUnitTimings(List<MMUnit> checkedBannerMMUnits,
					BannerData bannerData)
			{
			DbEntities.dbserver3.wpmediaaddondata.rows.Timing[] relatedBannerTimings = AllBannerTimings
				.Where(whe => whe.ConnectedId == bannerData.Id).ToArray();
			List<MMUnitTiming> existingMMUnitTimingPerBanner = InvolvedBannerMMUnitTimings
				.Where(whe => checkedBannerMMUnits.Contains(whe.MMUnit)).ToList();
			//Data.DbServer3.MultiMedia.MMUnitTimings.ShowListOfMMUnitTimings
			//			("Before", existingMMUnitTimingPerBanner);
			foreach (DbEntities.dbserver3.wpmediaaddondata.rows.Timing timing in AllBannerTimings
				.Where(whe => whe.ConnectedId == bannerData.Id))
				{
				if ((timing.TimingTypId == "VonBis")
					&& (checkedBannerMMUnits.Count == 2))
					{
					Data.DbServer3.MultiMedia.MMUnitTimings.InsertIfNotExist(BannerMMSlot,
						checkedBannerMMUnits[0], timing.TimingTypId, 
						timing.TimeA, timing.TimeB.AddDays(-1), existingMMUnitTimingPerBanner);
					Data.DbServer3.MultiMedia.MMUnitTimings.InsertIfNotExist(BannerMMSlot,
						checkedBannerMMUnits[1], timing.TimingTypId,
						timing.TimeB.AddDays(-1), timing.TimeB, existingMMUnitTimingPerBanner);
					continue;
					}
				Data.DbServer3.MultiMedia.MMUnitTimings.InsertIfNotExist(BannerMMSlot,
					checkedBannerMMUnits[0], timing.TimingTypId,
					timing.TimeA, timing.TimeB, existingMMUnitTimingPerBanner);

				}
			//Data.DbServer3.MultiMedia.MMUnitTimings.ShowListOfMMUnitTimings
			//			("After", existingMMUnitTimingPerBanner);
			return existingMMUnitTimingPerBanner;
			}
Ejemplo n.º 3
0
		private List<MMUnit> CheckOrCreateMMUnits(Guid relatedInformationId, BannerData bannerData)
			{
			List<MMUnit> result = new List<MMUnit>();
			MMUnit[] BannerRelatedMMUnits = InvolvedBannerMMUnits
					.Where(whe => whe.ForeignUnitId == bannerData.Id).ToArray();
			if (BannerRelatedMMUnits.Length > 2)
				throw new Exception($"mehr als 2 MMUnits bei Banner {bannerData.NameId} ({bannerData.Id})");
			MMUnit rootBannerMMUnit = BannerRelatedMMUnits.Where(whe =>
					whe.ForeignUnitTypId.Value == ForeignBannerTyp.Id)?.FirstOrDefault();
			MMUnit lastDayBannerMMUnit = BannerRelatedMMUnits.Where(whe =>
					whe.ForeignUnitTypId.Value == ForeignLastDayBannerTyp.Id)?.FirstOrDefault();
			if (!String.IsNullOrWhiteSpace(bannerData.TextForTheLastSendingDay))
				{
				if (lastDayBannerMMUnit == null)
					{
					lastDayBannerMMUnit = Data.DbServer3.MultiMedia.MMUnits.NewRow();
					lastDayBannerMMUnit.Id = Guid.NewGuid();
					lastDayBannerMMUnit.NameId = bannerData.NameId + "_LastDay";
					lastDayBannerMMUnit.ForeignUnitId = bannerData.Id;
					lastDayBannerMMUnit.TypId = mmUnitTypForBannerData.Id;
					lastDayBannerMMUnit.ForeignUnitTypId = ForeignLastDayBannerTyp.Id;
					lastDayBannerMMUnit.ModifyTimeStamp = bannerData.ModifyTimeStamp;
					lastDayBannerMMUnit.MMInformationenId = relatedInformationId;
					lastDayBannerMMUnit.Table.Rows.Add(lastDayBannerMMUnit);
					Data.DbServer3.MultiMedia.MMUnits.SaveChanges();
					Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
					}
				if (lastDayBannerMMUnit.PagingType != DirectPlayerPage)
					{
					lastDayBannerMMUnit.PagingType = DirectPlayerPage;
					Data.DbServer3.MultiMedia.MMUnits.SaveChanges();
					Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
					InsertSimplePagedText(lastDayBannerMMUnit, bannerData.TextForTheLastSendingDay, false);
					}
				}
			if (!String.IsNullOrWhiteSpace(bannerData.Text))
				{
				if (rootBannerMMUnit == null)
					{
					rootBannerMMUnit = Data.DbServer3.MultiMedia.MMUnits.NewRow();
					rootBannerMMUnit.Id = Guid.NewGuid();
					rootBannerMMUnit.NameId = bannerData.NameId;
					rootBannerMMUnit.ForeignUnitId = bannerData.Id;
					rootBannerMMUnit.TypId = mmUnitTypForBannerData.Id;
					rootBannerMMUnit.ForeignUnitTypId = ForeignBannerTyp.Id;
					rootBannerMMUnit.ModifyTimeStamp = bannerData.ModifyTimeStamp;
					rootBannerMMUnit.MMInformationenId = relatedInformationId;
					rootBannerMMUnit.PagingType = DirectPlayerPage;
					rootBannerMMUnit.Table.Rows.Add(rootBannerMMUnit);
					Data.DbServer3.MultiMedia.MMUnits.SaveChanges();
					Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
					}
				if (rootBannerMMUnit.PagingType != DirectPlayerPage)
					{
					rootBannerMMUnit.PagingType = DirectPlayerPage;
					Data.DbServer3.MultiMedia.MMUnits.SaveChanges();
					Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
					InsertSimplePagedText(rootBannerMMUnit, bannerData.Text, true);
					}
				}
			if (rootBannerMMUnit != null)
				{
				result.Add(rootBannerMMUnit);
				}
			if (lastDayBannerMMUnit != null)
				{
				result.Add(lastDayBannerMMUnit);
				}

			//foreach (MMUnit bannerRelatedMMUnit in result)
			//	{
			//	Debug.WriteLine($"{bannerData.NameId} - {bannerRelatedMMUnit.Id} - " +
			//					$"{bannerRelatedMMUnit.NameId}");
			//	}
			//Debug.WriteLine($"\r\n");
			return result;
			}
Ejemplo n.º 4
0
		public void CheckOrCreateMMUnitsAndTimings(BannerData bannerData)
			{
			Information relatedInformation = CheckOrCreateInformation(bannerData);
			List<MMUnit> checkedBannerMMUnits = CheckOrCreateMMUnits(relatedInformation.Id, bannerData);
			foreach (MMUnit bannerMMUnit in checkedBannerMMUnits)
				{
				Data.DbServer3.AltErlaaInfo.CheckOrInsertProcessConnector(relatedInformation, 
					bannerMMUnit.Id, "Banner", (DateTime) bannerData.ModifyTimeStamp, DbBasics.UserName);
				}
			List<MMUnitTiming> checkedMMUnitTimings = CheckOrCreateMMUnitTimings
					(checkedBannerMMUnits, bannerData);
			DateTime earliestFrom = DateTime.MaxValue;
			DateTime latestTo = DateTime.MinValue;
			foreach (MMUnitTiming checkedMMUnitTiming in checkedMMUnitTimings)
				{
				if (checkedMMUnitTiming.TimingTypId != "VonBis")
					continue;
				if (checkedMMUnitTiming.TimeA < earliestFrom)
					earliestFrom = checkedMMUnitTiming.TimeA;
				if (checkedMMUnitTiming.TimeB > latestTo)
					latestTo = checkedMMUnitTiming.TimeB;
				}
			if (!relatedInformation.CheckOrCreateBasicTimings(earliestFrom, latestTo))
				Debug.WriteLine($"+++++++++++++++ {++MissingTimingsCounter}");
			}