public static InformationenAddOn GetInformationAddOnForRootEntry (Informationen Info, DataTemplatesDescription Desc) { InformationenAddOn InfoAddOnHelp = new InformationenAddOn (); InfoAddOnHelp.ActuallBezeichner = "Ereignis"; InfoAddOnHelp.Tabelle = "Informationen"; InfoAddOnHelp.InformationenID = Info.ID; InfoAddOnHelp.TabelleID = Info.ID; InfoAddOnHelp.FreiText = GetInterface ["Informationen"].GetFreitext (Info, FreiTextFormat.Full); return InfoAddOnHelp; }
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; }