private String CheckForTypCorrectDatDependencyIDs (AVEvent Event)
			{
			List<String> Errors = new List<string> ();
			String TypName = Event.InformationForThisEvent.Typ.NameId;
			foreach (AVEventEntry Entry in Event.AVEntries)
				{
				if (Data.DbServer3.AltErlaaInfo.DataDependencies.Find ((Guid) Entry.DataDependencyId) == null)
					{
					Errors.Add ($"Der DataDependency Eintrag \"{(Guid) Entry.DataDependencyId}\" für\r\n"
					       + Entry.OriginalToken + " ist nicht existent");
					continue;
					}
				bool Found = false;
				foreach (DbEntities.dbserver3.alterlaainfo.rows.DataDependency dataDependency in
										Event.InformationForThisEvent.Typ.Get_DataDependencies)
					{
					if ((dataDependency.Id == Entry.DataDependencyId)
						|| (Entry.DataDependency.DataElementeTemplate.PhysicalDataElement.TabellenName == "Informationen"))
						{
						Found = true;
						break;
						}
					}
				if (!Found)
					{
					Errors.Add ($"Der DataDependency Eintrag\r\n" +
							$"{Entry.DataDependency.ActuallBezeichner} \"{Entry.DataDependency.Id}\"\r\n" +
							$"{Entry.DataDependency.DataElementeTemplate.ActuallBezeichner} \"{Entry.DataDependency.DataElementeTemplate.Id}\"\r\n" +
							$"{Entry.DataDependency.DataElementeTemplate.PhysicalDataElement.Bezeichner} \"{Entry.DataDependency.DataElementeTemplate.PhysicalDataElement.TabellenName}\"\r\n" +
							$"für "
						   + Entry.OriginalToken + " ist für den Typ \"" + TypName + "\" nicht erlaubt");
					continue;
					}
				Entry.DataDependency = Data.DbServer3.AltErlaaInfo
							.DataDependencies.Find((Guid)Entry.DataDependencyId);
				}
			return String.Join ("\r\n", Errors);
			}
		public void CreateOrRefreshWorkListEntryOutOfLoadedFromWeb (AVEvent Event)
			{
			try
				{
				StandBildRedaktionDataModellInstance = new StandBildRedaktionDataModell();
				StandBildRedaktionDataModellInstance.CreateAndStoreAVBasisForOneEntry(Event);
				StandBildRedaktionDataModellInstance.InsertOrUpdateInformationenMaterial(Event,
                    DataDependencyEnums.RootFDDIDsForAVEvent.InformationenMaterialRoot);
				}
			catch (Exception Excp)
				{
				
				throw new Exception( "Bei Event \"" + Event.AVID + "\"\r\ntrat folgender Fehler auf:\r\n" + Excp.ToString ());
				} 
			Event.CheckAgainstStoredMaterial();
			}
		public void CreateAVEventDataRoot ()
			{
			AVEventDataRoot = new AVEventData ();
			AVEventDataRoot.XmlAddOnData = new XDocument(new XDeclaration("1.0", "utf-8", null),
					new XElement(AVEvent.ADD_INFO));
			foreach (AlpenVereinPlainTextDataEntry InputEntry in AlpenVereinPlainTextDataEntries)
				{
				AVEvent NewAVEvent = new AVEvent() { AktuellerStatus = EventStatus.NoAVID};
				AVEventDataRoot.Events.Add (NewAVEvent);
				NewAVEvent.ConnectedPlainTextContent = InputEntry;
				InputEntry.ConnectedAVEvent = NewAVEvent;
				if (!NewAVEvent.FillMeFromPlainTextData (AVEventDataRoot))
					{
					AVEventDataRoot.Events.Remove (NewAVEvent);
					}
				}
			}
		public void DoCreateOrRefreshForOneEntry(AVEvent EventToCreateInformationen)
			{
			AVModell.CreateOrRefreshWorkListEntryOutOfLoadedFromWeb(EventToCreateInformationen);

			}
		private int CreateInfoAddOnsAndConnectLocalObjectsToIt
			(AVEvent Event)
			{
			Dictionary<AVEventEntry, InformationAddOn> Result = new Dictionary<AVEventEntry, InformationAddOn>();
			foreach (AVEventEntry Entry in Event.AVEntries)
				{
				//if (Entry.DataDependency.Visibility == "Mandatory")
				//	continue;
				if (Entry.DataDependency.SortOrder == 100)
					continue;
				InformationAddOn LastFoundItem = null;
				foreach (InformationAddOn InfoAddOn in Event.InformationForThisEvent.InformationenAddOns)
					{
					if (InfoAddOn.DataDependencyId != Entry.DataDependencyId)
						continue;
					if (InfoAddOn.Tag == null)
						{
						Result[Entry] = InfoAddOn;
						InfoAddOn.Tag = Entry;
						Entry.ConnectedInformationenAddOn = InfoAddOn;
						break;
						}
					else
						{
						LastFoundItem = InfoAddOn;
						}
					}
				if (Result.ContainsKey(Entry))
					continue;
				if (LastFoundItem == null)
					throw new Exception("CreateInfoAddOnsAndConnectLocalObjectsToIt - LastFoundItem == null bei\r\n"
						+ $"Entry.DataDependencyID = \"{Entry.DataDependency.Id}\"\r\n" +
						$"{Entry.DataDependency.ActuallBezeichner}");
				InformationAddOn NewCreatedItem = DbDataContext.AltErlaaInfo
							.InformationenAddOns.InsertNewSibling(LastFoundItem);
				Result[Entry] = NewCreatedItem;
				NewCreatedItem.Tag = Entry;
				Entry.ConnectedInformationenAddOn = NewCreatedItem;
				}
			return Result.Keys.Count;
		}
		public void CreateAndStoreAVBasisForOneEntry(AVEvent Event)
			{
			bool IsNewOrModify = true;
			Guid TypID = Event.TypIDToCreate;
			if (TypID == System.Guid.Empty)
				throw new Exception("Event.TypIDToCreate) == null");
			if ((Event.InformationenID != null)
				&& (Event.InformationenID != Guid.Empty))
				{
				IsNewOrModify = false;
				}
//			Information information = null;
			List<String> SelectedStatementsForPreLoad;
			if (IsNewOrModify)
				{
				Event.InformationForThisEvent = DbDataContext.AltErlaaInfo.CreateNewInformation(TypID, DbBasics.UserName);
				Event.InformationForThisEvent.Titel = Event.Title;
				Event.InformationenID = Event.InformationForThisEvent.Id;
				}
			else
				{
				DbDataContext.AltErlaaInfo.PreLoadAddOnsForOneInformation
					((Guid)Event.InformationenID, out SelectedStatementsForPreLoad);
				Event.InformationForThisEvent = DbDataContext.AltErlaaInfo.Informationen.Find(Event.InformationenID);
				}
			DbDataContext.AltErlaaInfo.PreLoadTablesForOneInformation(Event.InformationForThisEvent, out SelectedStatementsForPreLoad);
			Event.InformationForThisEvent.BearbeitungsHinweis = Event.AVID;
			String ErrorMessage = CheckForTypCorrectDatDependencyIDs (Event);
			if (!String.IsNullOrEmpty (ErrorMessage))
				throw new Exception ("!CheckForTypCorrectDatDependencyIDs (Event)\r\n" + ErrorMessage);

			int NumberOfInfoAddOns = CreateInfoAddOnsAndConnectLocalObjectsToIt (Event);

			InformationAddOn NewStandBildConnectorItem = null;
			Timing NewStandBildTiming = null;
			InformationAddOn NewBannerConnectorItem = null;
			Timing NewBannerTiming = null;
			foreach (AVEventEntry Entry in Event.AVEntries)
				{
				if (Entry.DataDependency.Visibility == "Mandatory")
					continue;
				if (Entry.ConnectedInformationenAddOn == null)
					throw new Exception ("Entry.ConnectedInformationenAddOn");
				String TabellenName = Entry.DataDependency.DataElementeTemplate.PhysicalDataElement.TabellenName;
				InformationAddOn InfoAddOn = Entry.ConnectedInformationenAddOn;
				if (InfoAddOn.Tabelle != TabellenName)
					throw new Exception("Table != Table");
				if ((Entry.Token == "Treffpunkt")
					|| (Entry.Token == "Anmeldung")
					|| (Entry.Token == "Anmerkung")
					|| (Entry.Token == "Auskunft")
					|| (Entry.Token == "Programm")
					|| (Entry.Token == "Tour"))
					{
					StringBuilder Content = new StringBuilder();
					//						Content.AppendLine (Entry.OriginalToken);

					foreach (String Line in Entry.ContentLines)
						{
						if (Entry.Token == "Anmeldung")
							Content.AppendLine(Line.Replace("Tel.", "\r\nTel.").Trim());
						else
							Content.AppendLine(Line.Trim());
						}
					InfoAddOn.FreiText = Content.ToString();
					continue;
					}

				if (Entry.Token == "Veranstalter")
					{
					if (Entry.ContentLines.Count == 2)
						{
						if (String.IsNullOrEmpty(Entry.ContentLines[1]))
							{
							InfoAddOn.TabelleId = (System.Guid?) System.Guid.Empty;
							continue;
							}
						else
							{
							System.Guid TabelleID = System.Guid.Empty;
							if (System.Guid.TryParse(Entry.ContentLines[1], out TabelleID))
								InfoAddOn.TabelleId = TabelleID;
							if (TabelleID != Guid.Empty)
								InfoAddOn.FreiText = InfoAddOn.Get_ConnectedOrganisation.FreiText;
							}
						}
					}

				if ((Entry.Token == "Tourenführer")
					|| (Entry.Token == "TourenFuehrer"))
					{
					if (Entry.ContentLines.Count == 2)
						{
						if (String.IsNullOrEmpty(Entry.ContentLines[1]))
							{
							InfoAddOn.TabelleId = (System.Guid?)System.Guid.Empty;
							continue;
							}
						else
							{
							System.Guid TabelleID = System.Guid.Empty;
							if (System.Guid.TryParse(Entry.ContentLines[1], out TabelleID))
								InfoAddOn.TabelleId = TabelleID;
							
							}
						Person ConnectedPerson = InfoAddOn.Get_ConnectedPerson;
						if (ConnectedPerson != null)
							{
							InfoAddOn.FreiText = ConnectedPerson.FreiText;
							if ((System.Guid) InfoAddOn.TabelleId != System.Guid.Empty)
								{
								String MaterialLink = ConnectedPerson.MaterialConnector;
								if (!String.IsNullOrEmpty(MaterialLink))
									{
									if (String.IsNullOrEmpty(InfoAddOn.TechnicalAddOn))
										{
										InfoAddOn.TechnicalAddOn = "StandBildPicture(" + MaterialLink + ")";
										}
									else
										{
										InfoAddOn.TechnicalAddOn += ";" + "StandBildPicture(" + MaterialLink + ")";

										}
									}
								}
							}
						}
					else
						InfoAddOn.FreiText = "Kein " + Entry.Token + " gefunden";
					continue;
					}


				//InfoAddOn.FreiText = Interface.GetFreitext 
				//        ((System.Guid) InfoAddOn.TabelleID, FreiTextFormat.Full);

				if (Entry.Token == "Timings")
					{
					if (Entry.ContentLines.Count != 3)
						continue;
					Timing NewTiming = InfoAddOn.Get_ConnectedTiming;
					if (NewTiming == null)
						{
						NewTiming = DbEntities.CustomClasses.TimingsBasics.InsertNewTiming
								(DbDataContext.AltErlaaInfo.Timings, "Informationen",
								Event.InformationForThisEvent.Id, Entry.ContentLines [0], DateTime.Now, DateTime.Now);
						}

					NewTiming.ConnectedId = Event.InformationForThisEvent.Id;
					NewTiming.ConnectedType = "Informationen";
					NewTiming.TimingTypId = Entry.ContentLines[0];
					if (NewTiming.TimingTypId == "BannerVonBis")
						NewBannerTiming = NewTiming;
					if (NewTiming.TimingTypId == "AnzVonBis")
						NewStandBildTiming = NewTiming;

					NewTiming.TimeA = Convert.ToDateTime(Entry.ContentLines[1]);
					NewTiming.TimeB = Convert.ToDateTime(Entry.ContentLines[2]);
					InfoAddOn.TabelleId = NewTiming.TimingsId;
					InfoAddOn.FreiText = NewTiming.FreiText;
					continue;
					}

				if (Entry.Token == "TypID")
					{
					if (Entry.ContentLines.Count == 2)
						{
						InfoAddOn.TabelleId = System.Guid.Parse(Entry.ContentLines[1]);
						throw new Exception($"Tabelle für Token TypID = {InfoAddOn.Tabelle}");
						//InfoAddOn.FreiText = ((RootDataClass)InfoAddOn.ConnectedTableClass)
						//			.GetFreitext(FreiTextFormat.Full);
						}
					else
						InfoAddOn.FreiText = "Kein " + Entry.Token + " gefunden";
					continue;

					}
				}
			foreach (InformationAddOn Item in Event.InformationForThisEvent.InformationenAddOnsOrdered)
				{
				if (Item.DataDependencyId == DataDependencyEnums.RootFDDIDsForAVEvent.ConnectorStandBildRoot) //	EreignisMultiMedia - StandBild
					{
					ProcessConnector NewStandBildConnector = Item.GetOrCreate_ConnectedProcessConnector();
					NewStandBildConnector.TableName = "WohnParkInfo";
					NewStandBildConnector.Redaktion = "StandBild";
					NewStandBildConnector.ConnectionStringName = "WPMediaAddOnDataConnectionString";
					NewStandBildConnector.InformationenId = Item.InformationenId;
					NewStandBildConnector.InformationenAddOnId = Item.Id;
					if (!String.IsNullOrEmpty(Event.AVID))
						NewStandBildConnector.NameId = Event.AVID + "_"
														+ ((Event.Title.Length > 30) ? Event.Title.Substring(0, 30) : Event.Title)
																.Replace("\r\n", " ").Replace(" ", "_");
					else
						NewStandBildConnector.NameId = "AV" + ((DateTime)Event.EventBis).ToString("_yyyy_MM_")
													+ ((Event.Title.Length > 30) ? Event.Title.Substring(0, 30) : Event.Title)
															.Replace("\r\n", " ").Replace(" ", "_");
					NewStandBildConnector.TemplateId = Guid.Parse ("939228EE-4181-4DE4-A8D9-327DED6682DE");
					Item.FreiText = NewStandBildConnector.FreiText;
					NewStandBildConnectorItem = Item;
					}

				if (Item.DataDependencyId == DataDependencyEnums.RootFDDIDsForAVEvent.ConnectorBannerRoot) //	EreignisMultiMedia - Banner
					{
					ProcessConnector NewBannerConnector = Item.GetOrCreate_ConnectedProcessConnector();
					NewBannerConnector.TableName = "BannerData";
					NewBannerConnector.Redaktion = "Banner";
					NewBannerConnector.ConnectionStringName = "WPMediaAddOnDataConnectionString";
					NewBannerConnector.InformationenId = Item.InformationenId;
					NewBannerConnector.InformationenAddOnId = Item.Id;
					if (!String.IsNullOrEmpty(Event.AVID))
						NewBannerConnector.NameId = Event.AVID + "_"
												+ ((Event.Title.Length > 30) ? Event.Title.Substring(0, 30) : Event.Title)
														.Replace("\r\n", " ").Replace(" ", "_");
					else
						NewBannerConnector.NameId = "AV" + ((DateTime)Event.EventBis).ToString("_yyyy_MM_")
											+ ((Event.Title.Length > 30) ? Event.Title.Substring(0, 30) : Event.Title)
													.Replace("\r\n", " ").Replace(" ", "_");
					Item.FreiText = NewBannerConnector.FreiText;
					NewBannerConnectorItem = Item;
					}
				}

			if ((NewStandBildConnectorItem != null)
			    && (NewStandBildTiming != null))
				{
				NewStandBildConnectorItem.Get_ConnectedProcessConnector.ConnectedTimingsId = NewStandBildTiming.TimingsId;
				NewStandBildConnectorItem.FreiText = NewStandBildConnectorItem.Get_ConnectedProcessConnector.FreiText;
				}
			if ((NewBannerConnectorItem != null)
			    && (NewBannerTiming != null))
				{
				NewBannerConnectorItem.Get_ConnectedProcessConnector.ConnectedTimingsId = NewBannerTiming.TimingsId;
				NewBannerConnectorItem.FreiText = NewBannerConnectorItem.Get_ConnectedProcessConnector.FreiText;
				}
			Event.InformationForThisEvent.ModifyTimeStamp = DateTime.Now;
			Event.InformationForThisEvent.CheckForTechnicalConsistence();
			DbDataContext.AltErlaaInfo.SaveAnabolic(new Object());
			DbDataContext.AltErlaaInfo.AcceptChanges();
			Basics.DoEvents();
			}
		public void InsertOrUpdateInformationenMaterial(AVEvent Event, Guid dataDependencyId)
			{
			InformationAddOn InfoAddOn = InsertOrUpdateNewMaterial ((Guid)Event.InformationenID, dataDependencyId,
				Event.ConnectedPlainTextContent.CompleteContentString, Event.AVID, "txt");
			DbDataContext.AltErlaaInfo.SaveAnabolic(new Object());
			DbDataContext.AltErlaaInfo.AcceptChanges();
			}
		private void RunDirectInformationEntryCreation (AVEvent EventToCreateInformationen)
			{
			//TemplateRuntime CreationRuntime = new TemplateRuntime();
			//CreationRuntime.IsUIMode = false;
			//CreationRuntime.CreateAndStoreAVBasisForOneEntry (EventToCreateInformationen);
			}