public Byte[] ModifyMaterialContentViaName(Materialien Material, MemoryStream NewMemoryStreamContentToUse, String NameOfTheNewContentToStore = "", String TypOfTheContentToStore = "") { if ((Material == null) || (Material.ID == Guid.Empty)) return null; if (String.IsNullOrEmpty(NameOfTheNewContentToStore)) NameOfTheNewContentToStore = Material.NameID; if (String.IsNullOrEmpty(TypOfTheContentToStore)) TypOfTheContentToStore = Material.Typ; CacheStoreMaterialBlobContentDataBaseCommand(Material, NameOfTheNewContentToStore, NewMemoryStreamContentToUse, TypOfTheContentToStore); String ModifyAfterBlobChanged = "Update Materialien set BlobLength = " + Convert.ToString(Material.BlobLength) + ", NameID = '" + NameOfTheNewContentToStore + "', Typ = '" + TypOfTheContentToStore + "', ModifyTimeStamp = " + Basics.GetSQLFormattedDateTime(DateTime.Now) + " where ID = '" + Material.ID.ToString() + "'"; WCFStandards WCFAccess = new WCFStandards(); WCFAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString"; WCFAccess.RunSQLBatch(ModifyAfterBlobChanged); return LoadFileContent(Material); }
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 void SetInformationenStatus(Guid InformationenID, String NewStatusToSet) { String UpdateStatement = "Update Informationen set Status = '" + NewStatusToSet + "' where ID = '" + InformationenID.ToString() + "'"; WCFStandards WCFAccess = new WCFStandards(); WCFAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString"; WCFAccess.RunSQLBatch(UpdateStatement); }
public static void ClearConnectorRow (DataRow ConnectorRow) { String UpdateStatement = "Update " + ConnectorRow.Table.TableName + " set TableID = NULL where ID = '" + ConnectorRow ["ID"].ToString () + "'"; WCFStandards DataAccess = new WCFStandards (); DataAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString"; DataAccess.RunSQLBatch (UpdateStatement); }
public static void ClearInfoAddOnRow (DataRow InfoAddOnRow) { String NewFreiText = InfoAddOnRow ["FreiText"].ToString ().Replace (" - angelegt", ""); String UpdateStatement = "Update InformationenAddOn set FreiText = '" + NewFreiText + "' where ID = '" + InfoAddOnRow ["ID"].ToString () + "'"; WCFStandards DataAccess = new WCFStandards (); DataAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString"; DataAccess.RunSQLBatch (UpdateStatement); }
public static bool DeleteEntity (String TableName, System.Guid ID) { try { String DeleteCommand = "Delete from " + TableName + " where ID = '" + ID.ToString () + "'"; if (TableName == "Timings") DeleteCommand = DeleteCommand.Replace (" ID ", " TimingsID "); WCFStandards DataAccess = new WCFStandards (); DataAccess.RunSQLBatch (DeleteCommand); return true; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.DeleteEntity", "Delete \"" + TableName + "\" ID = \"" + ID.ToString( ) + "\"\r\n" + Excp.ToString ()); return false; } }
public static System.Guid? InsertOrModifyEntity (ITemplateElementeBackgroundFunctions ConnectedITemplateElementeBackgroundFunctions, Object EntityToProcess, bool CheckForPreExistence = false) { if (EntityToProcess == null) { Basics.ReportErrorToEventViewer ("TemplateManagement.InsertOrModifyEntity", "EntityToProcess == null\r\n" + (new Exception ("EntityToProcess == null")).ToString ()); return null; } Type ObjectType = EntityToProcess.GetType (); String TableName = ObjectType.Name; String IDName = "ID"; PropertyInfo IDPropInfo = ObjectType.GetProperty (IDName); if (IDPropInfo == null) { IDName = "TimingsID"; IDPropInfo = ObjectType.GetProperty (IDName); } if (IDPropInfo == null) { Basics.ReportErrorToEventViewer ("TemplateManagement.InsertOrModifyEntity", "Keine ID (TimingsID) bei EntityToProcess\r\n" + (new Exception ("Keine ID (TimingsID) bei EntityToProcess")).ToString ()); return null; } Object IDValue = IDPropInfo.GetValue (EntityToProcess, null); bool InsertIsTrueModifyIsFalse = true; if (IDValue != null) { if (IDValue is System.Guid) { InsertIsTrueModifyIsFalse = ((Guid) IDValue == Guid.Empty); } else if (IDValue is System.Guid?) InsertIsTrueModifyIsFalse = ((Guid?) IDValue == Guid.Empty); } DoTabelleDefaultModifications (ConnectedITemplateElementeBackgroundFunctions, EntityToProcess, InsertIsTrueModifyIsFalse); WCFStandards DataAccess = new WCFStandards (); if ((CheckForPreExistence) && (IDValue != null)) { DataTable CheckTable = DataAccess.GetCommonDataSet ("Select * from " + TableName + " where " + IDName + " = '" + (Guid) IDValue + "'").Tables [TableName]; if (CheckTable.Rows.Count == 0) InsertIsTrueModifyIsFalse = true; } String SQLCommand = String.Empty; if (InsertIsTrueModifyIsFalse) { SQLCommand = WMB.Basics.CreateInsertStatement (TableName, EntityToProcess, EntityToProcess.GetType ().GetProperties()); } else { SQLCommand = WMB.Basics.CreateModifyStatement (TableName, EntityToProcess, EntityToProcess.GetType ().GetProperties ()); } IDValue = IDPropInfo.GetValue (EntityToProcess, null); DataAccess.RunSQLBatch (SQLCommand); return (System.Guid?) IDValue; }
public static bool RunSQLBatch (String SQLCommand) { try { WCFStandards DataAccess = new WCFStandards (); DataAccess.RunSQLBatch (SQLCommand); return true; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.RunSQLBatch", "Der Command \"" + SQLCommand + "\"\r\nbrachte folgenden Fehler\r\n" + Excp.ToString ()); return false; } }
public static void ProcessAddOnDeletion (ITemplateElementeBackgroundFunctions ConnectedITemplateElementeBackgroundFunctions) { if (ConnectedITemplateElementeBackgroundFunctions.InfoAddOn == null) return; WCFStandards DataAccess = new WCFStandards (); if (ConnectedITemplateElementeBackgroundFunctions.DataTemplatesDescriptionEntry.DeleteEntryIfNotUsed == "Yes") { if ((ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID != null) && (ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID != Guid.Empty)) { try { String IDName = "ID"; if (ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.Tabelle == "Timings") IDName = "TimingsID"; String TableEntryDeleteStatement = "Delete from " + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.Tabelle + " where " + IDName + " = '" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID.ToString () + "'"; DataAccess.RunSQLBatch (TableEntryDeleteStatement); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.ProcessAddOnDeletion", "Fehler bei Delete from " + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.Tabelle + " von ID \"" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID.ToString () + "\":\r\n" + Excp.ToString()); } ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID = null; ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.FreiText = String.Empty; } } if (ConnectedITemplateElementeBackgroundFunctions.IAddOnHandling_AsObject != null) ConnectedITemplateElementeBackgroundFunctions.IAddOnHandling_DoDelete (); int NumberOfEqualInfoAddOn = 0; foreach (ITemplateElementeBackgroundFunctions Element in ConnectedITemplateElementeBackgroundFunctions.ParentTemplateRuntime_AllITemplateElementeBackgroundFunctionsEntries) if (Element.ActuallBezeichner == ConnectedITemplateElementeBackgroundFunctions.ActuallBezeichner) NumberOfEqualInfoAddOn++; if (NumberOfEqualInfoAddOn < 2) { ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.FreiText = String.Empty; try { String AddOnUpdateLastEntryStatement = "Update InformationenAddOn set FreiText = '', TabelleID = NULL where ID = '" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.ID.ToString () + "'"; DataAccess.RunSQLBatch (AddOnUpdateLastEntryStatement); } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.ProcessAddOnDeletion", "Fehler bei Update from InformationenAddOn von ID \"" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID.ToString () + "\":\r\n" + Excp.ToString()); } return; } try { String AddOnDeleteStatement = "Delete from InformationenAddOn where ID = '" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.ID.ToString () + "'"; DataAccess.RunSQLBatch (AddOnDeleteStatement); ConnectedITemplateElementeBackgroundFunctions.InfoAddOn = null; } catch (Exception Excp) { Basics.ReportErrorToEventViewer ("TemplateManagement.ProcessAddOnDeletion", "Fehler bei Delete from InformationenAddOn von ID \"" + ConnectedITemplateElementeBackgroundFunctions.InfoAddOn.TabelleID.ToString () + "\":\r\n" + Excp.ToString()); } }
private void SetNumberOfPages (String TableName, String TableID, DataRow UsedTableRow, int NumberOfPages) { if (UsedTableRow.Table.Columns ["NumberOfPages"] == null) return; WCFStandardsNS.WCFStandards DataBase = new WCFStandardsNS.WCFStandards (); DataBase.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; DataTable ExistingEntryTable = DataBase.GetCommonDataSet ("Select * from " + TableName + " where ID = '" + TableID + "'").Tables [TableName]; UsedTableRow ["NumberOfPages"] = NumberOfPages; if (ExistingEntryTable.Rows.Count != 1) { Basics.ReportErrorToEventViewer ("StandBildRedaktionInstance.SetNumberOfPages", TableName + " mit der ID " + TableID + " brachte Rows.Count != 1"); return; } String UpdateStatement = "Update " + TableName + " set NumberOfPages = " + Convert.ToString (NumberOfPages) + " where ID = '" + TableID + "'"; DataBase.RunSQLBatch (UpdateStatement); }
public static bool CreateOrModifyAsStandBildLayout (String TableName, System.Guid ID, String StandBildLayoutNameID) { WCFStandardsNS.WCFStandards DataAccess = new WCFStandards (); DataAccess.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; CVM.GraphicsHandling GraphicsHandler = new GraphicsHandling(Basics.GetLocalWPMediaRoot ()); Object Pkg = GraphicsHandler.GetInstatiatedPackage (TableName, ID.ToString ()); List<BitmapSource> CreatedPictures = GraphicsHandler.GetFinalPictures (); int SubEntryIndex = 0; DataSet ExistingMaterials = DataAccess.GetCommonDataSet ("Select " + MATERIALIEN_ITEM_LIST + " from Materialien " + "where Tabelle = '" + TableName + "' and TabelleID = '" + ID.ToString () + "' order by SubEntryID"); if (ExistingMaterials.Tables ["Materialien"].Rows.Count > 0) { int PictureIndex = 0; List<DataRow> RowsToDelete = new List<DataRow> (); foreach (DataRow Existing in ExistingMaterials.Tables ["Materialien"].Rows) { PictureIndex = Convert.ToInt32 (Existing ["SubEntryID"].ToString ().Replace (LAYOUT_PICTURE_PREFIX, "")); if ((PictureIndex - 1) < CreatedPictures.Count) { Byte [] JpegContent = GetJpgByteArrayFromBitmapSource (CreatedPictures [PictureIndex - 1]); String UpdateStatement = String.Format ("Update Materialien " + "set NameID = '{0}', Tabelle = '{1}', TabelleID = '{2}', Typ = '{3}', SubEntryID = '{4}', " + "BlobLength = {5}, BlobContent = @BlobParam, " + "ModifyTimeStamp = '{6}', ProcessingStatus = '{7}', CreatedBy = '{8}' where ID = '{9}'", StandBildLayoutNameID, TableName, ID.ToString (), "", String.Format (LAYOUT_PICTURE_PREFIX_FORMAT, PictureIndex), JpegContent.Length, DateTime.Now.ToString (Basics.ISO_DATE_TIME_FORMAT), "", WMB.WPMediaApplicationState.Instance.Properties ["UserName"].ToString (), Existing ["ID"].ToString ()); DataAccess.SetCommonBlob (UpdateStatement, JpegContent); } else { RowsToDelete.Add (Existing); } } foreach (DataRow ToDelete in RowsToDelete) { String DeleteStatement = "Delete Materialien where ID = '" + ToDelete ["ID"].ToString () + "'"; DataAccess.RunSQLBatch (DeleteStatement); } while ((PictureIndex) < CreatedPictures.Count) { System.Guid PictureID = System.Guid.NewGuid (); Byte [] JpegContent = GetJpgByteArrayFromBitmapSource (CreatedPictures [PictureIndex]); String InsertStatement = String.Format ("Insert into Materialien " + "(ID, NameID, Tabelle, TabelleID, Typ, SubEntryID, BlobLength, BlobContent, ModifyTimeStamp, ProcessingStatus, CreatedBy) " + "Values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, @BlobParam, '{7}', '{8}', '{9}')", PictureID.ToString (), StandBildLayoutNameID, TableName, ID.ToString (), "", String.Format (LAYOUT_PICTURE_PREFIX_FORMAT, PictureIndex), JpegContent.Length, DateTime.Now.ToString (Basics.ISO_DATE_TIME_FORMAT), "", WMB.WPMediaApplicationState.Instance.Properties ["UserName"].ToString ()); DataAccess.SetCommonBlob (InsertStatement, JpegContent); PictureIndex++; } } else { foreach (BitmapSource Picture in CreatedPictures) { System.Guid PictureID = System.Guid.NewGuid (); Byte [] JpegContent = GetJpgByteArrayFromBitmapSource (Picture); String InsertStatement = String.Format ("Insert into Materialien " + "(ID, NameID, Tabelle, TabelleID, Typ, SubEntryID, BlobLength, BlobContent, ModifyTimeStamp, ProcessingStatus, CreatedBy) Values (" + "'{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, @BlobParam, '{7}', '{8}', '{9}')", PictureID.ToString (), StandBildLayoutNameID, TableName, ID.ToString (), "", String.Format (LAYOUT_PICTURE_PREFIX_FORMAT, SubEntryIndex + 1), JpegContent.Length, DateTime.Now.ToString (Basics.ISO_DATE_TIME_FORMAT), "", WMB.WPMediaApplicationState.Instance.Properties ["UserName"].ToString ()); DataAccess.SetCommonBlob (InsertStatement, JpegContent); SubEntryIndex++; } } return true; }
static public bool RemoveTemplateFromDataBase (String ToRemoveTemplateID) { WCFStandardsNS.WCFStandards DataAccess = new WCFStandards (); DataAccess.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; String DeleteStatement = "Delete from Materialien where ID = '" + ToRemoveTemplateID + "'"; if (DataAccess.RunSQLBatch (DeleteStatement) == "1") return true; return false; }