public static List<InformationenAddOn> GetMultiMediaEntries (Guid InformationenID) { AltErlaaInfoEntities InformationmenAddOnContext = new AltErlaaInfoEntities (); return (from InAdd in InformationmenAddOnContext.InformationenAddOn where InAdd.InformationenID == InformationenID && InAdd.ActuallBezeichner.IndexOf ("MultiMedia") != -1 orderby InAdd.SortOrder select InAdd).ToList (); }
//public static InformationenAddOn GetInformationAddOnForRootEntry (Guid ID, String ActuallBezeichnerToCreate) // { // AltErlaaInfoEntities InformationmenContext = new AltErlaaInfoEntities (); // Informationen InfoData = (from Info in InformationmenContext.Informationen // where Info.ID == ID // select Info).FirstOrDefault (); // return GetInformationAddOnForRootEntry (InfoData, ActuallBezeichnerToCreate); // } public static Timings GetTerminEntry (Guid InformationenID) { AltErlaaInfoEntities TimingsContext = new AltErlaaInfoEntities (); return (from Tim in TimingsContext.Timings where Tim.ConnectedID == InformationenID && Tim.TimingTypID == "EventVonBis" select Tim).FirstOrDefault (); }
public static Guid InsertOrModifyInformationenAddOn (Guid ID, Guid InformationenID, String TabellenName, Guid TabelleID, DataTemplatesDescription Desc, String FreiText, bool MultipleEntriesAllowed) { AltErlaaInfoEntities WebAccess = new AltErlaaInfoEntities (); InformationenAddOn InfoAO = null; IQueryable<InformationenAddOn> OldEntries = from ExistingINF in WebAccess.InformationenAddOn where ExistingINF.InformationenID == InformationenID && ExistingINF.DataDependencyID == Desc.ID select ExistingINF; int ExistingCounter = OldEntries.Count (); if (MultipleEntriesAllowed == false) { InfoAO = OldEntries.First (); ID = InfoAO.ID; } if (ID != Guid.Empty) { try { InfoAO.InformationenID = InformationenID; InfoAO.Tabelle = TabellenName; InfoAO.TabelleID = TabelleID; InfoAO.ActuallBezeichner = Desc.ActuallBezeichner; if (InfoAO.SortOrder == null) { if (MultipleEntriesAllowed) InfoAO.SortOrder = Desc.SortOrder + ExistingCounter; else InfoAO.SortOrder = Desc.SortOrder; } InfoAO.DataDependencyID = Desc.ID; InfoAO.FreiText = FreiText; InfoAO.ModifyTimeStamp = DateTime.Now; InfoAO.LastModifiedBy = CurrentUserName; WebAccess.MergeOption = MergeOption.AppendOnly; WebAccess.UpdateObject (InfoAO); DataServiceResponse Response = WebAccess.SaveChanges (); return ID; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.InsertOrModifyInformationenAddOn", "Fehler bei UpdateObject von ID \"" + ID.ToString () + "\":\r\n" + Excp.Message); } } else { try { InfoAO = new InformationenAddOn (); InfoAO.ID = Guid.NewGuid (); InfoAO.InformationenID = InformationenID; InfoAO.Tabelle = TabellenName; InfoAO.TabelleID = TabelleID; InfoAO.ActuallBezeichner = Desc.ActuallBezeichner; if (InfoAO.SortOrder == null) { if (MultipleEntriesAllowed) InfoAO.SortOrder = Desc.SortOrder + ExistingCounter; else InfoAO.SortOrder = Desc.SortOrder; } InfoAO.DataDependencyID = Desc.ID; InfoAO.FreiText = FreiText; InfoAO.ModifyTimeStamp = DateTime.Now; InfoAO.LastModifiedBy = CurrentUserName; WebAccess.MergeOption = MergeOption.AppendOnly; WebAccess.AddObject ("InformationenAddOn", InfoAO); DataServiceResponse Response = WebAccess.SaveChanges (); return InfoAO.ID; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.InsertOrModifyInformationenAddOn", "Fehler bei AddObject von ID \"" + ID.ToString () + "\":\r\n" + Excp.Message); } } return Guid.Empty; }
public static List<InformationenAddOn> GetAllInformationenAddOnForInformation (Guid InformationenID) { AltErlaaInfoEntities InformationmenAddOnContext = new AltErlaaInfoEntities (); return (from InAdd in InformationmenAddOnContext.InformationenAddOn where InAdd.InformationenID == InformationenID orderby InAdd.SortOrder select InAdd).ToList (); }
private static void DeleteInformationenFromDataBase (Informationen ActuallInformation) { AltErlaaInfoEntities AllInformationenContext = new AltErlaaInfoEntities (ServiceSource); IQueryable<Informationen> DeleteInformationen = from del in AllInformationenContext.Informationen where del.ID == ActuallInformation.ID select del; foreach (Informationen DeleteableEntry in DeleteInformationen) { Guid ID = ActuallInformation.ID; try { AllInformationenContext.DeleteObject (DeleteableEntry); AllInformationenContext.SaveChanges (); } catch (DataServiceRequestException Excp ) { Basics.ReportErrorToEventViewer ("AltErlaaInfoRootControl.DeleteInformationenFromDataBase", "Fehler bei Delete von ID = \"" + ID.ToString () + "\":\r\n" + Excp.Message); } } }
public static bool SetFreitext (Guid ID, String FreiText) { AltErlaaInfoEntities WebAccess = new AltErlaaInfoEntities (); InformationenAddOn ExistingEntry = (from ExistingINF in WebAccess.InformationenAddOn where ExistingINF.ID == ID select ExistingINF).FirstOrDefault (); if ((ExistingEntry == null) || (ExistingEntry.ID == null) || (ExistingEntry.ID == Guid.Empty)) return false; try { ExistingEntry.FreiText = FreiText; ExistingEntry.ModifyTimeStamp = DateTime.Now; ExistingEntry.LastModifiedBy = CurrentUserName; WebAccess.MergeOption = MergeOption.AppendOnly; WebAccess.UpdateObject (ExistingEntry); DataServiceResponse Response = WebAccess.SaveChanges (); return true; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.SetFreitext", "Fehler bei UpdateObject von ID \"" + ID.ToString () + "\":\r\n" + Excp.Message); } return false; }
public static bool DoInformationenAddOnUpdate (Informationen ActuallInformation, List<TemplateElementManagement> EntriesTProcess) { AltErlaaInfoEntities InformationmenAddOnContext = new AltErlaaInfoEntities (ServiceSource); IQueryable<InformationenAddOn> OldInformationenAddOn = from InAdd in InformationmenAddOnContext.InformationenAddOn where InAdd.InformationenID == ActuallInformation.ID select InAdd; List<Guid> ProcessingHasBeenDone = new List<Guid> (); List<InformationenAddOn> ExistingEntriesToDelete = new List<InformationenAddOn> (); foreach (InformationenAddOn IAddOn in OldInformationenAddOn) { bool FoundInNew = false; foreach (TemplateElementManagement ElementManagement in EntriesTProcess) { if (ElementManagement.InfoAddOn == null) continue; if (IAddOn.ID == ElementManagement.InfoAddOn.ID) { if (((ElementManagement.InfoAddOn.TabelleID == null) || (ElementManagement.InfoAddOn.TabelleID == Guid.Empty)) && (String.IsNullOrEmpty (ElementManagement.InfoAddOn.FreiText))) { ExistingEntriesToDelete.Add (IAddOn); break; // delete this Entry } if (ElementManagement.ParentTemplateRuntime.AnythingInTheWholeEntryHasBeenModified == true) { AltErlaaInfoEntities UpdateContext = new AltErlaaInfoEntities (ServiceSource); try { InformationenAddOn ExistingInformationAddOn = (from InAddToUpdate in UpdateContext.InformationenAddOn where InAddToUpdate.ID == ElementManagement.InfoAddOn.ID select InAddToUpdate).FirstOrDefault (); UpdateContext.MergeOption = MergeOption.AppendOnly; ElementManagement.InfoAddOn.LastModifiedBy = CurrentUserName; ElementManagement.InfoAddOn.ModifyTimeStamp = DateTime.Now; Type TargetType = IAddOn.GetType (); foreach (PropertyInfo Prop in TargetType.GetProperties ()) { Prop.SetValue (ExistingInformationAddOn, Prop.GetValue (ElementManagement.InfoAddOn, null), null); } CheckForMaxLengthExceeded (ExistingInformationAddOn); UpdateContext.UpdateObject (ExistingInformationAddOn); DataServiceResponse Response = UpdateContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoInformationenAddOnUpdate", "Beim UpdateObject für IAddOn \"" + ElementManagement.InfoAddOn.ID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } ProcessingHasBeenDone.Add (ElementManagement.InfoAddOn.ID); } } } foreach (InformationenAddOn IAddOn in ExistingEntriesToDelete) { try { InformationmenAddOnContext.MergeOption = MergeOption.AppendOnly; InformationmenAddOnContext.DeleteObject (IAddOn); DataServiceResponse Response = InformationmenAddOnContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoInformationenAddOnUpdate", "Beim DeleteObject für AddOns \"" + IAddOn.ID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } foreach (TemplateElementManagement ElementManagement in EntriesTProcess) { if (ElementManagement.InfoAddOn == null) continue; if (MandatoryAddOns.ContainsKey(ElementManagement.InfoAddOn.ActuallBezeichner)) continue; Guid ProcessedBeforeID = ElementManagement.InfoAddOn.ID; if (ProcessingHasBeenDone.Contains (ProcessedBeforeID)) continue; if (((ElementManagement.InfoAddOn.TabelleID == null) || (ElementManagement.InfoAddOn.TabelleID == Guid.Empty)) && (String.IsNullOrEmpty (ElementManagement.InfoAddOn.FreiText))) { continue; } try { InformationmenAddOnContext.MergeOption = MergeOption.AppendOnly; ElementManagement.InfoAddOn.LastModifiedBy = CurrentUserName; ElementManagement.InfoAddOn.ModifyTimeStamp = DateTime.Now; if ((ElementManagement.InfoAddOn.ID == null) || (ElementManagement.InfoAddOn.ID == Guid.NewGuid ())) ElementManagement.InfoAddOn.ID = Guid.NewGuid (); CheckForMaxLengthExceeded (ElementManagement.InfoAddOn); InformationmenAddOnContext.AddObject ("InformationenAddOn", ElementManagement.InfoAddOn); DataServiceResponse Response = InformationmenAddOnContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoCompleteUpdate", "Beim AddObject für AddOns \"" + ProcessedBeforeID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } return true; }
public static Guid? GetTypIDForInfoAddOn (Guid? InformationenID) { AltErlaaInfoEntities InformationenContext = new AltErlaaInfoEntities (ServiceSource); Informationen ParentInformation = (from Info in InformationenContext.Informationen where Info.ID == InformationenID select Info).FirstOrDefault (); return ParentInformation.TypID; }
public static bool DoInformationenUpdate (Informationen ActuallInformation, TemplateElementManagement EntryToProcess) { //if (EntryToProcess.InfoAddOn.Informationen != ActuallInformation) // throw new Exception ("EntryToProcess.InfoAddOn.Informationen != ActuallInformation"); AltErlaaInfoEntities UpdateContext = new AltErlaaInfoEntities (ServiceSource); Informationen StoredInformationen = (from Inf in UpdateContext.Informationen where Inf.ID == ActuallInformation.ID select Inf).FirstOrDefault (); if ((StoredInformationen == null) || (StoredInformationen.ID == Guid.Empty)) { try { DoTabelleDefaultModifications (EntryToProcess, ActuallInformation, true); UpdateContext.MergeOption = MergeOption.AppendOnly; UpdateContext.AddObject ("Informationen", ActuallInformation); DataServiceResponse Response = UpdateContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoCompleteUpdate", "Beim AddObject für ActuallInformation \"" + ActuallInformation.ID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } else { try { DoTabelleDefaultModifications (EntryToProcess, ActuallInformation, false); UpdateContext.MergeOption = MergeOption.AppendOnly; Type TargetType = StoredInformationen.GetType (); foreach (PropertyInfo Prop in TargetType.GetProperties ()) { Prop.SetValue (StoredInformationen, Prop.GetValue (ActuallInformation, null), null); } UpdateContext.UpdateObject (StoredInformationen); DataServiceResponse Response = UpdateContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoCompleteUpdate", "Beim UpdateObject für ActuallInformation \"" + ActuallInformation.ID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } return true; }
private static bool DoZielGruppenUpdate (Informationen ActuallInformation, List<Guid> TargetZielgruppenSetting) { AltErlaaInfoEntities ZielGruppenAssignmentContext = new AltErlaaInfoEntities (ServiceSource); List<InformationenZuZielGruppen> OldAssignedZielGruppen = (from ZielGrp in ZielGruppenAssignmentContext.InformationenZuZielGruppen where ZielGrp.InformationenID == ActuallInformation.ID select ZielGrp).ToList (); foreach (Guid ZielGruppenID in TargetZielgruppenSetting) { int RemoveIndex = 0; bool Exists = false; foreach (InformationenZuZielGruppen Entry in OldAssignedZielGruppen) { if (Entry.ZielgruppenID == ZielGruppenID) { Exists = true; break; } RemoveIndex++; } if (Exists == true) { OldAssignedZielGruppen.RemoveAt (RemoveIndex); } else { try { ZielGruppenAssignmentContext.MergeOption = MergeOption.AppendOnly; InformationenZuZielGruppen NewEntry = new InformationenZuZielGruppen (); NewEntry.ID = Guid.NewGuid (); NewEntry.InformationenID = ActuallInformation.ID; NewEntry.ZielgruppenID = ZielGruppenID; ZielGruppenAssignmentContext.AddObject ("InformationenZuZielGruppen", NewEntry); DataServiceResponse Response = ZielGruppenAssignmentContext.SaveChanges (); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoZielGruppenUpdate", "Beim AddObject für InformationenZuZielGruppen \"" + ZielGruppenID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.Message); return false; } } } foreach (InformationenZuZielGruppen DeleteableEntry in OldAssignedZielGruppen) { Guid ID = DeleteableEntry.ID; try { ZielGruppenAssignmentContext.DeleteObject (DeleteableEntry); ZielGruppenAssignmentContext.SaveChanges (); } catch (DataServiceRequestException Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoZielGruppenUpdate", "Fehler bei Delete von ID = \"" + ID.ToString () + "\":\r\n" + Excp.Message.ToString ()); } } return true; }
private static Dictionary<string, FullDataElementeTemplates> LoadFullElementeTemplates () { AltErlaaInfoEntities LoadTemplates = new AltErlaaInfoEntities (ServiceSource); return (from Descript in LoadTemplates.FullDataElementeTemplates select Descript) .ToDictionary (P => P.ActuallBezeichner); }
private static Dictionary<Guid, DataTemplatesDescription> LoadTemplateDescription () { AltErlaaInfoEntities LoadTemplates = new AltErlaaInfoEntities (ServiceSource); return (from Descript in LoadTemplates.DataTemplatesDescription orderby Descript.SortOrder select Descript).ToDictionary (P => P.ID); }
private static Dictionary<Guid, string> LoadOrganisationsSubTypen () { AltErlaaInfoEntities LoadSubTypen = new AltErlaaInfoEntities (ServiceSource); IQueryable<OrganisationsSubTypen> SubTypen = from OSubTyp in LoadSubTypen.OrganisationsSubTypen select OSubTyp; Dictionary<Guid, string> Result = new Dictionary<Guid, string> (); foreach (OrganisationsSubTypen OSubTypEntry in SubTypen) { Result.Add (OSubTypEntry.ID, OSubTypEntry.OrganisationsSubTyp); } return Result; }
public static String GetZielgruppenForInformationID (Guid InformationenID, List<Guid> LocallyModifiedZielGruppen) { List<FullInformationenZuZielGruppen> AllZG; AltErlaaInfoEntities FullZielGruppenContext = new AltErlaaInfoEntities (); if (LocallyModifiedZielGruppen != null) { AllZG = new List<FullInformationenZuZielGruppen> (); foreach (Guid ZielGruppe in LocallyModifiedZielGruppen) { AllZG.Add ((from Ziel in FullZielGruppenContext.FullInformationenZuZielGruppen where Ziel.ZielgruppenID == ZielGruppe select Ziel).FirstOrDefault ()); } } else { AllZG = (from ZG in FullZielGruppenContext.FullInformationenZuZielGruppen where ZG.InformationenID == InformationenID orderby ZG.ZielGruppe select ZG).ToList (); } List<string> Texte = new List<string> (); foreach (FullInformationenZuZielGruppen ZG in AllZG) { Texte.Add (ZG.ZielGruppe); } return String.Join ("; ", Texte.ToArray ()); }
public static void DeleteOneInformationenAddOnFromDataBase (Guid? InformationenAddOnID) { AltErlaaInfoEntities DeleteInformationenAddOnContext = new AltErlaaInfoEntities (ServiceSource); InformationenAddOn DeleteInformationenAddOn = (from del in DeleteInformationenAddOnContext.InformationenAddOn where del.ID == InformationenAddOnID select del).FirstOrDefault (); if ((DeleteInformationenAddOn == null) || (DeleteInformationenAddOn.ID == Guid.Empty)) return; try { DeleteInformationenAddOnContext.DeleteObject (DeleteInformationenAddOn); DeleteInformationenAddOnContext.SaveChanges (); } catch (DataServiceRequestException Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DeleteOneInformationenAddOnFromDataBase", "Fehler bei Delete von ID = \"" + InformationenAddOnID.ToString () + "\":\r\n" + Excp.Message); } }
public static Object GetEntity (String TableName, Guid ID) { AltErlaaInfoEntities GetEntityContext = new AltErlaaInfoEntities (); if (TableName == "Informationen") { Informationen Result = (from Ent in GetEntityContext.Informationen where Ent.ID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "InformationenAddOn") { InformationenAddOn Result = (from Ent in GetEntityContext.InformationenAddOn where Ent.ID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Adressen") { Adressen Result = (from Ent in GetEntityContext.Adressen where Ent.ID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Personen") { Personen Result = (from Ent in GetEntityContext.Personen where Ent.ID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Organisationen") { Organisationen Result = (from Ent in GetEntityContext.Organisationen where Ent.ID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Timings") { Timings Result = (from Ent in GetEntityContext.Timings where Ent.TimingsID == ID select Ent).FirstOrDefault (); if ((Result == null) || (Result.TimingsID == null) || (Result.TimingsID == Guid.Empty)) return null; return Result; } if (TableName == "Events") { Events Result = (from Eve in GetEntityContext.Events where Eve.ID == ID select Eve).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Remarks") { Remarks Result = (from Rem in GetEntityContext.Remarks where Rem.ID == ID select Rem).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "ProcessConnector") { ProcessConnector Result = (from PC in GetEntityContext.ProcessConnector where PC.ID == ID select PC).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } if (TableName == "Materialien") { Materialien Result = (from Mat in GetEntityContext.Materialien where Mat.ID == ID select Mat).FirstOrDefault (); if ((Result == null) || (Result.ID == null) || (Result.ID == Guid.Empty)) return null; return Result; } return null; }
//private TemplateManagement () // { // LoadLateBindings (); // } #region startup and common environment private static void LoadLateBindings () { AltErlaaInfoEntities LateBindingContext = new AltErlaaInfoEntities (ServiceSource); IQueryable<DataElement> AllDEs = from DE in LateBindingContext.DataElement select DE; foreach (DataElement DataElementEntry in AllDEs) { if (String.IsNullOrEmpty (DataElementEntry.ControlAdressing)) continue; if (DataElementEntry.TabellenName == "Personen") { PersonenInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Adressen") { AdressenInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Organisationen") { OrganisationenInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Timings") { TimingsInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Informationen") { InformationenInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Remarks") { RemarksInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Events") { EventsInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "ProcessConnector") { ProcessConnectorInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } if (DataElementEntry.TabellenName == "Materialien") { MaterialienInterface = Basics.GetLateBindingInstance (DataElementEntry.ControlAdressing) as ITemplateReadWrite; } } }