private static void DeleteInformationenFromDataBase (Informationen ActuallInformation) { DeleteEntity ("Informationen", ActuallInformation.ID); }
private static void DeleteDeleteteAbleTableEntriesFromDataBase(Informationen ActuallInformation) { WCFStandards DataAccess = new WCFStandards (); DataTable ExistingInformationenAddOn = DataAccess.GetCommonDataSet ("Select * from InformationenAddOn where InformationenID = '" + ActuallInformation.ID.ToString () + "'").Tables ["InformationenAddOn"]; foreach (DataRow InfoAddOn in ExistingInformationenAddOn.Rows) { if ((String.IsNullOrEmpty (InfoAddOn ["Tabelle"].ToString ())) || (InfoAddOn ["TabelleID"] == Convert.DBNull) || (InfoAddOn["Tabelle"].ToString() == "Timings")) continue; DataRowCollection ExistingReferences = DataAccess.GetCommonDataSet ("Select * from InformationenAddOn where not InformationenID = '" + ActuallInformation.ID.ToString() + "' and Tabelle = '" + InfoAddOn["Tabelle"].ToString() + "' and TabelleID = '" + InfoAddOn["TabelleID"].ToString () + "'").Tables["InformationenAddOn"].Rows; if (ExistingReferences.Count > 0) continue; String DeleteStatement = "Delete from " + InfoAddOn ["Tabelle"].ToString () + " where ID = '" + InfoAddOn ["TabelleID"].ToString () + "'"; RunSQLBatch(DeleteStatement); } }
private static void DeleteInformationenAddOnFromDataBase (Informationen ActuallInformation) { String SQLCommand = "Delete from InformationenAddOn where InformationenID = '" + ActuallInformation.ID.ToString () + "'"; RunSQLBatch (SQLCommand); }
public static bool DoInformationenAddOnUpdate (Informationen ActuallInformation, List<ITemplateElementeBackgroundFunctions> 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 (ITemplateElementeBackgroundFunctions 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 ) { InsertOrModifyEntity (null, ElementManagement.InfoAddOn); } ProcessingHasBeenDone.Add (ElementManagement.InfoAddOn.ID); } } } foreach (InformationenAddOn IAddOn in ExistingEntriesToDelete) { DeleteEntity ("InformationenAddOn", IAddOn.ID); } foreach (ITemplateElementeBackgroundFunctions 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; } InsertOrModifyEntity (ElementManagement, ElementManagement.InfoAddOn, true); } return true; }
private static void DeleteTimingsFromDataBase (Informationen ActuallInformation) { // Deleteion of Google Entries should be implemented in the future, // actuall Google Entries deleted with central Batch funtion String SQLCommand = "Delete Timings where ConnectedType = 'Informationen' and ConnectedID = '" + ActuallInformation.ID.ToString() + "'"; RunSQLBatch(SQLCommand); }
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; }
public static bool DoTableEntriesUpdate (Informationen ActuallInformation, List<ITemplateElementeBackgroundFunctions> EntriesTProcess) { foreach (ITemplateElementeBackgroundFunctions ElementManagement in EntriesTProcess) { if ((ElementManagement.LocallyModifiedZielGruppen != null) && (MandatoryAddOns.ContainsKey(ElementManagement.InfoAddOn.ActuallBezeichner))) { DoZielGruppenUpdate (ActuallInformation, ElementManagement.LocallyModifiedZielGruppen); } if ((ElementManagement.LocallyModifiedTableEntry == null) || ((ElementManagement.InfoAddOn != null) && (MandatoryAddOns.ContainsKey (ElementManagement.InfoAddOn.ActuallBezeichner))) && (ElementManagement.ParentTemplateRuntime_AnythingInTheWholeEntryHasBeenModified == false)) continue; if ((ElementManagement.LocallyModifiedTableEntry != null) && (ElementManagement.TabelleEntryHasBeenChanged == true)) { Guid TabelleID = ElementManagement.ReadWriteInterfaceActuallyInstatiated .InsertOrModifyEntity (ElementManagement.LocallyModifiedTableEntry); ElementManagement.InfoAddOn.TabelleID = TabelleID; } } return true; }
public static bool DoCompleteDelete(Informationen ActuallInformation) { if (ActuallInformation == null) return false; DeleteTimingsFromDataBase (ActuallInformation); DeleteZielGruppenFromDataBase (ActuallInformation); DeleteDeleteteAbleTableEntriesFromDataBase (ActuallInformation); DeleteInformationenAddOnFromDataBase (ActuallInformation); DeleteInformationenFromDataBase (ActuallInformation); return true; }
public static bool DoInformationenUpdate (Informationen ActuallInformation, ITemplateElementeBackgroundFunctions EntryToProcess) { //if (EntryToProcess.InfoAddOn.Informationen != ActuallInformation) // throw new Exception ("EntryToProcess.InfoAddOn.Informationen != ActuallInformation"); WCFStandards ExistenceCheck = new WCFStandards (); DataTable InformationenTable = ExistenceCheck.GetCommonDataSet ("Select * from Informationen where ID = '" + ActuallInformation.ID.ToString () + "'").Tables ["Informationen"]; if (InformationenTable.Rows.Count == 0) { ExistenceCheck.RunSQLBatch ("Insert into Informationen (ID, NameID, TypID, ModifyTimeStamp) values ('" + ActuallInformation.ID.ToString () + "', 'Empty ActiveInformationen', '" + ActuallInformation.TypID.ToString () + "', '" + DateTime.Now.ToString (WMB.Basics.ISO_DATE_TIME_FORMAT) + "')"); } try { System.Guid? ProcessedEntityID = InsertOrModifyEntity (EntryToProcess, ActuallInformation); if (ProcessedEntityID == null) return false; return true; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DoInformationenUpdate", "Beim Add/Modify für ActuallInformation \"" + ActuallInformation.ID.ToString () + "\" kam es zu folgendem Problem:\r\n" + Excp.ToString ()); return false; } }
public static List<String> GetMaterialElementeForThisInformation(Informationen Information) { List<String> TechnicalElementeForThisInformation = new List<String>(); foreach (InformationenAddOn PictureElementAddOn in Information.InformationenAddOn_Additional) { if (String.IsNullOrEmpty (PictureElementAddOn.TechnicalAddOn)) continue; String[] SingleTechnicalAddOn = PictureElementAddOn.TechnicalAddOn.Split(';'); foreach (String Entry in SingleTechnicalAddOn) TechnicalElementeForThisInformation.Add(Entry.Trim()); } return TechnicalElementeForThisInformation; }
public static bool DoCompleteUpdate (Informationen ActuallInformation, List<ITemplateElementeBackgroundFunctions> EntriesToProcess) { bool InformationenReturn = DoInformationenUpdate (ActuallInformation, EntriesToProcess [0]); bool TableEntriesReturn = DoTableEntriesUpdate (ActuallInformation, EntriesToProcess); bool InformationenAddOnReturn = DoInformationenAddOnUpdate (ActuallInformation, EntriesToProcess); RemoveAllUpdateCaches (EntriesToProcess); return TableEntriesReturn & InformationenReturn & InformationenAddOnReturn; }
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 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; }
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; }
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.Parent_Additional = Info; InfoAddOnHelp.FreiText = GetInterface ["Informationen"]. GetFreitext (Info, FreiTextFormat.Full); return InfoAddOnHelp; }
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 { InformationenZuZielGruppen NewEntry = new InformationenZuZielGruppen (); NewEntry.InformationenID = ActuallInformation.ID; NewEntry.ZielgruppenID = ZielGruppenID; InsertOrModifyEntity (null, NewEntry); } } foreach (InformationenZuZielGruppen DeleteableEntry in OldAssignedZielGruppen) { Guid ID = DeleteableEntry.ID; DeleteEntity ("InformationenZuZielGruppen", ID); } return true; }
private String FormatFreitext (Informationen InformationenDaten, TemplateHandling.FreiTextFormat Format) { if (InformationenDaten == null) return String.Empty; StringBuilder Elemente = new StringBuilder (); Elemente.Append ("Typ = " + TemplateManagement.GetTextForTypID ((System.Guid) InformationenDaten.TypID) + " - " + InformationenDaten.Titel); String ZielGruppenText = String.Empty; if ((ConnectedTemplateElementManagement != null) && (ConnectedTemplateElementManagement.LocallyModifiedZielGruppen != null)) ZielGruppenText = TemplateManagement.GetZielgruppenForInformationID ((System.Guid) InformationenDaten.ID, ConnectedTemplateElementManagement. LocallyModifiedZielGruppen); else ZielGruppenText = TemplateManagement.GetZielgruppenForInformationID ((System.Guid) InformationenDaten.ID, null); if (!String.IsNullOrEmpty (ZielGruppenText)) { Elemente.AppendLine (); Elemente.Append ("Zielgruppen - " + ZielGruppenText); } return Elemente.ToString ().Replace (" ", " "); }
public static bool DoCompleteDelete (Informationen ActuallInformation) { DeleteZielGruppenFromDataBase (ActuallInformation); DeleteInformationenAddOnFromDataBase (ActuallInformation); DeleteInformationenFromDataBase (ActuallInformation); return true; }