public static bool CreateOrModifyAsStandBildLayout (String FileNameToImport) { CVM.GraphicsHandling GraphicsHandler = new GraphicsHandling(Basics.GetLocalWPMediaRoot ()); Object Pkg = GraphicsHandler.GetInstatiatedPackage (FileNameToImport); String TableName = GraphicsHandler.ActuallTableName; System.Guid ID = System.Guid.Parse (GraphicsHandler.ActuallReadableContentRow ["ID"].ToString ()); String NameID = GraphicsHandler.ActuallReadableContentRow ["NameID"].ToString (); GraphicsHandler.Close (); return CreateOrModifyAsStandBildLayout (TableName, ID, NameID); }
private bool CopyPkgEntrysFormat (String TableName, String OldID, String NewID) { String OldPkgFileName = GraphicsSingleton.Instance.GraphicsHandler.GetPackageName (TableName, OldID); String NewPkgFileName = Path.Combine (Path.GetDirectoryName (OldPkgFileName), NewID + Path.GetExtension (OldPkgFileName)); File.Copy (OldPkgFileName, NewPkgFileName); GraphicsHandling NewHandler = new GraphicsHandling (WMB.Basics.GetLocalWPMediaRoot ()); NewHandler.RemoteWPMediaRoot = WMB.Basics.GetRemoteWPMediaRoot (); NewHandler.DoSQLBatchCall += new DoSQLBatchEvent (LocalGraphicsHandling_DoSQLBatchCall); NewHandler.GetInstatiatedPackage (TableToProcess, NewID); NewHandler.ActualizeInstanceDataIntoFrameDataSet (m_DataBase, TableToProcess, NewID); NewHandler.Close (); String RemoteFileName = WMB.Basics.GetRemoteFileNameFromLocalFileName(NewPkgFileName); DoCentralFileUpdate(NewPkgFileName, RemoteFileName); NewHandler.GetInstatiatedPackage (NewPkgFileName); return true; }
private void Window_Loaded (object sender, RoutedEventArgs e) { WMB.WPMediaApplicationState.Instance.Properties ["DataBase"] = DataAccess; DoSpecialCorrection (); return; DoDefaultCreationForOldPackages (); DoPictureRenaming (); TestDefaultFilling (); //LoadPkgs (); PackageFileNames = WMB.Basics.GetFilesFromDirectory (IntermediateStorageDirectory, new string [] {"*.pkg"}, 3); foreach (String PackageToProcessName in PackageFileNames) { m_GraphicsHandling = new GraphicsHandling (IntermediateStorageDirectory); Pkg = new PackagingHandler (); if (Pkg.OpenReadWrite (PackageToProcessName) == null) continue; m_GraphicsHandling.DoStartupProcessing (Pkg); ListViewItem Entry = new ListViewItem (); Entry.Tag = PackageToProcessName; Entry.Content = PackageToProcessName.Replace (IntermediateStorageDirectory, ""); AvailableEntries.Items.Add (Entry); // Copy Loop List<String> DocumentNames = Pkg.GetOriginalDocumentNamesInPackage (); foreach (String DocumentName in DocumentNames) { if (DocumentName.IndexOf ("BauchBinde") != -1) { Pkg.CopyFileElement (DocumentName, DocumentName.Replace ("\\\\", "\\") .Replace ("BauchBinde", "Content_KP_P03_Frame_02")); Pkg.FlushPackage (); } if (DocumentName.IndexOf ("Bauchbinde") != -1) { Pkg.CopyFileElement (DocumentName, DocumentName.Replace ("\\\\", "\\") .Replace ("Bauchbinde", "Content_KP_P03_Frame_02")); Pkg.FlushPackage (); } if (DocumentName.IndexOf ("StandardBackGround") != -1) { Pkg.DeleteFileElement (DocumentName); Pkg.FlushPackage (); } if (DocumentName.IndexOf ("Intern_Kalender") != -1) { Pkg.DeleteFileElement (DocumentName); Pkg.FlushPackage (); } } // Rename Loop DocumentNames = Pkg.GetOriginalDocumentNamesInPackage (); foreach (String DocumentName in DocumentNames) { String NewName = DocumentName.Replace ("\\\\", "\\"); int SearchIndex = 0; while (SearchIndex < ReplaceFileNames.Length) { NewName = NewName.Replace (ReplaceFileNames [SearchIndex], ReplaceFileNames [SearchIndex + 1]); SearchIndex += 2; } if (NewName != DocumentName) Pkg.RenameFileElement (DocumentName, NewName); } m_GraphicsHandling.RevertEntryToFileDefault (); m_GraphicsHandling.Close (); } CheckAllFunctionality (); }
void CorrectThisEntry (String PackageName) { GraphicsHandling Handler = new GraphicsHandling (); Handler.GetInstatiatedPackage (PackageName, true); DataSet FrameDataSet = Handler.FrameDataDataSetReader; bool UpdateRequired = false; foreach (DataRow ContentRow in FrameDataSet.Tables ["FrameContent"].Select ("", "FrameOrder")) { String FrameContentID = "421156b1-f009-47c7-a6c6-913d7ab7dbd7"; if (ContentRow ["ID"].ToString () == FrameContentID) UpdateRequired = true; if (!UpdateRequired) continue; String NameID = ContentRow ["NameID"].ToString (); String ItemName = ContentRow ["ItemName"].ToString (); if ((NameID == "KurzText") && (ItemName == "LangTextSeite1")) { ContentRow ["NameID"] = "LangTextSeite1"; ContentRow ["ItemName"] = "LangTextSeite1"; continue; } if ((NameID == "LangtextSeite1") && (ItemName == "LangTextSeite2")) { ContentRow ["NameID"] = "LangTextSeite2"; continue; } if ((NameID == "LangtextSeite2") && (ItemName == "LangTextSeite3")) { ContentRow ["NameID"] = "LangTextSeite3"; continue; } if ((NameID == "LangtextSeite3") && (ItemName == "LangTextSeite4")) { ContentRow ["NameID"] = "LangTextSeite4"; continue; } if ((NameID == "LangtextSeite4") && (ItemName == "LangTextSeite4")) { ContentRow ["NameID"] = "LangTextSeite5"; ContentRow ["ItemName"] = "LangTextSeite5"; continue; } String PictureName = ContentRow ["PictureName"].ToString (); } if (UpdateRequired == true) { Handler.RenewFrameDataSet (FrameDataSet); } Handler.Close (); }
void CheckAllEntries (List<String> PackageList) { DataSet PageEntriesDataSet = m_DataBase.GetCommonDataSet ( "Select * from Pages where NameID > 'DefaultKarteiPage01' and NameID < 'DefaultKarteiPage10'"); if (PageEntriesDataSet.Tables ["Pages"].Rows.Count != 8) throw new Exception ("Alles im Eimer bei \"PageEntriesDataSet\""); foreach (String PackageName in PackageList) { GraphicsHandling Handler = new GraphicsHandling (); Handler.GetInstatiatedPackage (PackageName, true); DataSet FrameDataSet = Handler.FrameDataDataSetReader; if (FrameDataSet.Tables ["FrameContent"].Select( "FormattingTemplate = 'DefaultKartei'").Length == 0) continue; bool UpdateRequired = false; foreach (DataRow PageRow in PageEntriesDataSet.Tables ["Pages"].Rows) { String PageID = PageRow ["ID"].ToString (); if (FrameDataSet.Tables ["Pages"].Select ("ID = '" + PageID + "'").Length == 0) { FrameDataSet.Tables ["Pages"].ImportRow (PageRow); UpdateRequired = true; } } String IDForOldEntry = FrameDataSet.Tables ["Pages"].Select ("NameID = 'DefaultKarteiPage01'") [0] ["ID"].ToString (); int PageIndex = 2; while (PageIndex < 10) { String PageSearchString = "DefaultKarteiPage0" + Convert.ToString (PageIndex); String IDForNewEntry = FrameDataSet.Tables ["Pages"].Select ("NameID = '" + PageSearchString + "'") [0] ["ID"].ToString (); foreach (DataRow ContentRow in FrameDataSet.Tables ["FrameContent"].Select ("PageID = '" + IDForOldEntry + "' and MultiPageIndex = " + Convert.ToString (PageIndex), "FrameOrder")) { String NameID = ContentRow ["NameID"].ToString (); String ItemName = ContentRow ["ItemName"].ToString (); ContentRow ["PageID"] = IDForNewEntry; UpdateRequired = true; } PageIndex++; } if (UpdateRequired == true) { Handler.RenewFrameDataSet (FrameDataSet); Handler.Close (); } WMB.Basics.DoEvents (); } }
void BulkImport_Click (object sender, RoutedEventArgs e) { MenuItem ActivatedEntry = sender as MenuItem; if (ActivatedEntry == null) return; String TableNameToProcess = ActivatedEntry.Tag as String; OpenFileDialog OFD = new OpenFileDialog (); OFD.Filter = "Alle Bilder|*.jpg;*.png;*.tiff;*.bmp"; OFD.Title = "Bitte selektieren Sie Bilder für \"" + TableNameToProcess + "\""; OFD.Multiselect = true; if (OFD.ShowDialog () != true) { return; } if (OFD.FileNames.Length == 0) return; CVM.IFullTimingsInterface FullManagedTimingsInterface = new ManagedTimingsWindow () as CVM.IFullTimingsInterface ; DataSet TimingsTemplateDataSet = m_DataBase.GetCommonMultiDataSet (new string [] { "Select * from Timings where ConnectedID = '" + System.Guid.NewGuid ().ToString () + "'", "Select * from TimingTypen order by ProcessingOrder" }); FullManagedTimingsInterface.TimingsTemplateDataSet = TimingsTemplateDataSet; FullManagedTimingsInterface.WindowsHeadLine = "Bitte geben sie die zu generierenden Timings ein"; FullManagedTimingsInterface.FillStoreableTimingsDataSetViaUI (TableNameToProcess); Cursor = Cursors.Wait; Window ProgressWindow = new Window (); ProgressWindow.Height = 50; ProgressWindow.Width = 700; ProgressBar ProgressControl = new ProgressBar (); ProgressWindow.Content = ProgressControl; ProgressControl.Minimum = 0; ProgressControl.Maximum = OFD.FileNames.Length; ProgressWindow.Title = "Upload wird vorbereitet"; ProgressWindow.Show (); ManagedFileHandling.FileHandlingModell FileHandlingModellInstance = new FileHandlingModell (); //CommonDataBase.CommonBasics CopyInstance = new CommonBasics (); //CopyInstance.SendFileBlockEventCall += new SendFileBlockEvent (CopyInstance_SendFileBlockEventCall); //CopyInstance.CopyToServerListFinishedCall +=new CopyToServerListFinished(CopyInstance_CopyToServerListFinishedCall); String InsertSqlStatement = m_DataBase.GetTableDefinitionEntry (TableNameToProcess, WCFStandardsNS.WCFStandardClientSchema.SQL_TABLE_PROPERTY_SQL_INSERT); if (String.IsNullOrEmpty (InsertSqlStatement)) InsertSqlStatement = "Insert into " + TableNameToProcess + " (ID, NameID, Titel) values ('{0}', '{1}', '{2}')"; int LoopCounter = 0; foreach (String PictureFileName in OFD.FileNames) { String NewID = System.Guid.NewGuid ().ToString (); String NewEntryName = Path.GetFileName (Path.GetDirectoryName (PictureFileName)) + ":" + Path.GetFileNameWithoutExtension (PictureFileName); if (ProgressWindow.IsLoaded == false) break; ProgressControl.Value = LoopCounter++; ProgressWindow.Title = "Upload von " + PictureFileName; WMB.Basics.DoEvents (); String FinalInsertSqlStatement = String.Format (InsertSqlStatement, NewID, NewEntryName, ""); m_DataBase.RunSQLBatch (FinalInsertSqlStatement); DataSet StoredEntry = m_DataBase.GetCommonDataSet ("Select * from " + TableNameToProcess + " where ID = '" + NewID + "'"); StoredEntry.Tables [0].Rows [0] ["ModifyTimeStamp"] = DateTime.Now; StoredEntry.Tables [0].Rows [0] ["ProcessingStatus"] = CVM.CommonValues.TABLE_PROCESSING_STATUS_INTERNET_PUBLISHING_PENDING + ";" + CVM.CommonValues.TABLE_PROCESSING_STATUS_TV_PUBLISHING_PENDING; m_DataBase.SetCommonDataSet (StoredEntry); DataSet StoreableTimingsDataSet = FullManagedTimingsInterface.GetStoreableTimingsDataSet (NewID); m_DataBase.SetCommonDataSet (StoreableTimingsDataSet); CVM.GraphicsHandling GraphicHandler = new GraphicsHandling (CommonDataBase.DataBase.GetLocalWPMediaRoot ()); GraphicHandler.RemoteWPMediaRoot = CommonDataBase.DataBase.GetRemoteWPMediaRoot (); Object Pkg = GraphicHandler.GetInstatiatedPackage (m_DataBase, TableNameToProcess, NewID); String Extension = Path.GetExtension (PictureFileName); GraphicHandler.AddFileFromElementname ("BackGround" + Extension, PictureFileName); String LocalFileName = GraphicHandler.Close (); String RemoteFileName = CommonDataBase.DataBase.GetRemoteArchivFileNameFromLocalFileName (LocalFileName); FileInfo FInfo = new FileInfo (LocalFileName); FileHandlingModellInstance.DoCentralFileUpdateCall(TableNameToProcess, LocalFileName, RemoteFileName); //CopyInfoBlock CopyBlock = new CopyInfoBlock (LocalFileName, RemoteFileName, FInfo.LastWriteTime); //CopyInstance.CopyToServer (new List<CopyInfoBlock> {CopyBlock}, true); } ProgressWindow.Close (); Cursor = Cursors.Arrow; }
public List<BitmapSource> GetPicturesFromPackage (String originalPackageFileName, Size TargetSize, bool FullAndThumbMixed = false) { String packageFileName = GetCorrectPackageFileName(originalPackageFileName); if (String.IsNullOrEmpty(packageFileName)) { return new List<BitmapSource>() ; } GraphicsHandling GraphicsHandler = new GraphicsHandling(); GraphicsHandler.GetInstatiatedPackage(packageFileName, false); GraphicsHandler.CreateAndStoreFinalPictures(); List<BitmapSource> Result = GraphicsHandler.GetResizedPictures(GraphicsHandler.FinalPictures, TargetSize, FullAndThumbMixed); GraphicsHandler.Close(); return Result; }
public BitmapSource GetPictureFromPackage (String PackageFileName, int PageIndex, int TargetHeight = -1) { PackageFileName = GetCorrectPackageFileName (PackageFileName); if (String.IsNullOrEmpty (PackageFileName)) return null; GraphicsHandling GraphicsHandler = new GraphicsHandling (); GraphicsHandler.GetInstatiatedPackage (PackageFileName, false); BitmapSource Result = GraphicsHandler.GetCreatedFrameBitmapSource (PageIndex); GraphicsHandler.Close(); if (TargetHeight == -1) return Result; return Basics.ResizeBitmapSourceToNewHeight(Result, TargetHeight); }
private String CreateLocalPackage (String TableName, String TableID, out int NumberOfPlayablePages) { GraphicsHandling PackageHandler = new GraphicsHandling (Basics.GetLocalWPMediaRoot ()); PackageHandler.RemoteWPMediaRoot = Basics.GetRemoteWPMediaRoot (); PackageHandler.DoSQLBatchCall += new DoSQLBatchEvent (LayoutHandler_DoSQLBatchCall); WCFStandards DataBase = new WCFStandards (); DataBase.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; PackageHandler.GetInstatiatedPackage (DataBase, TableName, TableID); NumberOfPlayablePages = PackageHandler.PageDurations.Count; return PackageHandler.Close (); }
private bool CheckAndDoPictureImportIfRequired (DataRow CreatedTableRow, List<String> MaterialElementeForThisInformation) { GraphicsHandling LayoutHandler = new GraphicsHandling (Basics.GetLocalWPMediaRoot ()); LayoutHandler.RemoteWPMediaRoot = Basics.GetRemoteWPMediaRoot (); LayoutHandler.DoSQLBatchCall += new DoSQLBatchEvent (LayoutHandler_DoSQLBatchCall); WCFStandards DataBase = new WCFStandards (); DataBase.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; String TableName = CreatedTableRow.Table.TableName; String ID = CreatedTableRow ["ID"].ToString (); LayoutHandler.GetInstatiatedPackage (DataBase, TableName, ID); foreach (String MaterialEntry in MaterialElementeForThisInformation) { if (MaterialEntry.IndexOf ("StandBildPicture") == 0) { String MaterialLink = MaterialEntry.Replace ("StandBildPicture", "").Trim ('(').Trim (')'); Byte [] PictureContent = GetMaterialElementContent (MaterialLink); if ((PictureContent == null) || (PictureContent.Length == 0)) continue; String[] Controller = MaterialLink.Split (','); String PackageElementName = Controller [(int) WMB.DataWrapper.MaterialElementIndex.UsedSubEntryID]; LayoutHandler.AddFileFromStream (new MemoryStream (PictureContent), PackageElementName); } if (MaterialEntry.IndexOf ("_Bild1") != -1) { String MaterialLink = MaterialEntry.Replace ("BackGround", "").Trim ('(').Trim (')'); Byte [] PictureContent = GetMaterialElementContent (MaterialLink); if ((PictureContent == null) || (PictureContent.Length == 0)) continue; String [] Controller = MaterialLink.Split (','); String PackageElementName = Controller [(int) WMB.DataWrapper.MaterialElementIndex.UsedSubEntryID]; LayoutHandler.AddFileFromStream (new MemoryStream (PictureContent), PackageElementName + "." + Controller [(int)WMB.DataWrapper.MaterialElementIndex.UsedType]); } } LayoutHandler.CheckPackageConsistence (); String CreatedPackageFileName = LayoutHandler.Close (); return true; }
public int CreateOrCheckInternetJPGPicturesFor (String WPMediaRoot, String TableName, String ID) { GraphicsHandling GraphicsHandler = new GraphicsHandling (WPMediaRoot); String PackageName = GraphicsHandler.GetPackageName (TableName, ID); if (!File.Exists (PackageName)) { String ArchivedPackageName = PackageName.Replace ("\\" + CVM.CommonValues.XML_AUTO_CONTENT_SOURCE + "\\", "\\" + CVM.CommonValues.XML_AUTO_CONTENT_OLD_SOURCE + "\\"); if (File.Exists (ArchivedPackageName)) PackageName = ArchivedPackageName; else { WMB.Basics.ReportErrorToEventViewer("Es würde ein neues Package angelegt:\r\n" + PackageName + "\r\nAus Sicherheitsgründen wird die Neuanlage abgebrochen"); return 0; Object Pkg = GraphicsHandler.CreateNewPackage(m_DataBase, TableName, ID); GraphicsHandler.RemoteWPMediaRoot = WPMediaRoot; GraphicsHandler.InsertDefaultPackageMaterials (m_DataBase, Pkg); GraphicsHandler.ActualizeInstanceDataIntoFrameDataSet (m_DataBase, TableName, ID); GraphicsHandler.DoStartupProcessing (m_DataBase, Pkg); if (Convert.ToInt32 (GraphicsHandler.ActuallReadableContentRow ["NumberOfPages"]) != GraphicsHandler.PageIDsToPlay.Count) { String UpdateStatement = "Update " + TableName + " set NumberOfPages = " + Convert.ToString (GraphicsHandler.PageIDsToPlay.Count) + " where ID = '" + ID + "'"; m_DataBase.RunSQLBatch (UpdateStatement); } PackageName = GraphicsHandler.Close (); if ((!File.Exists (PackageName)) && (!File.Exists (ArchivedPackageName))) { WMB.Basics.ReportErrorToEventViewer ("WPMediaCentralServices.WriteOrRewritePicturesFor", "Weder der File\r\n\"" + PackageName + "\" noch der File\r\n\"" + ArchivedPackageName + "\" wurden vorerst nicht gefunden und " + "konnten danach auch nicht erzeugt werden"); return 0; } GraphicsHandler = new GraphicsHandling (WPMediaRoot); } } GraphicsHandler.GetInstatiatedPackage (PackageName); int NumberOfCreatedPictures = 0; if (GraphicsHandler.CheckPackageConsistence () == true) { NumberOfCreatedPictures = CreateOrCheckInternetJPGPicturesFor (WPMediaRoot, GraphicsHandler); } GraphicsHandler.Close (); return NumberOfCreatedPictures; }
/* public void CreateGalleriePlayingData (String PictureElementsFileRootDirectory, String TableName, DataRow TableTableRow) { CVM.CommonValues m_CVM = new CVM.CommonValues (); XAMLHandling m_XAMLHandling = new XAMLHandling (m_CVM); LocalWPMediaRoot = CommonDataBase.DataBase.GetLocalWPMediaRoot (); String TableDirectory = Path.Combine (PictureElementsFileRootDirectory, TableName); List<FileInfo> ExistingFiles = WMB.Basics.GetFileInfoEntriesFromDirectory (TableDirectory, new string [] { ControlFileExtension }, 1); return; } */ public void CreateStandbildPlayingData (String WPMediaServerRootDirectory, String PackageFilesRootDirectory, String TableName, DataRow tableDefinitionRow) { if (WMB.Basics.IsTestRun) { int NumberOfFiles = WMB.Basics.GetFilesFromDirectory (Path.Combine(PackageFilesRootDirectory, TableName), new string[] { "*.pkg" }, 1).Count; WMB.Basics.ReportInformationToEventViewer("WPMediaCentralServices.CreateStandbildPlayingData", "PackageFilesRootDirectory =\r\n\"" + PackageFilesRootDirectory + "\" Tabelle =\r\n\"" + TableName + "\" " + Convert.ToString(NumberOfFiles) + " Files"); } DateTime DateTimeToHandle = DateTime.Now; CVM.CommonValues m_CVM = new CVM.CommonValues(); XAMLHandling m_XAMLHandling = new XAMLHandling (m_CVM); LocalWPMediaRoot = CommonDataBase.DataBase.GetLocalWPMediaRoot (); String TableDirectory = Path.Combine (PackageFilesRootDirectory, TableName); List<FileInfo> ExistingFiles = WMB.Basics.GetFileInfoEntriesFromDirectory (TableDirectory, new string [] { ControlFileExtension }, 1); if (ExistingFiles == null) return; WPMediaStandbildPlayingData Description = new WPMediaStandbildPlayingData(); //ToDo Checking for IsActive on this day - new Implementation List<MMUnitUsageData> PossibleDataFromDataBase = Data.DbServer3.WPMediaAddOnData.GetWPMediaAddOnDataStandBildUsagePerTabelle (TableName, Data.DbServer3.WPMediaAddOnData.Timings .GetPossiblyInvolvedConnectedIds(DateTimeToHandle)[TableName]); Dictionary<DateTime, List<MMUnitUsageData>> AvtiveThisDayParameter = new Dictionary<DateTime, List<MMUnitUsageData>>() { { DateTimeToHandle, GetDayMMUnitUsageData (PossibleDataFromDataBase, DateTimeToHandle) } }; //TODO //MMUnitUsageTreeEntry Root = MMUnitUsageTreeEntry.GetUsageTree (null, null, null, null); //int WeekDay = (int) DateTime.Now.DayOfWeek; //List<MMUnitUsageData> DownloadEntriesStandBildUsageData = Root.Childs[MMUnitUsageTreeEntry.ALL_ACTIVE_ENTRIES].ContentList; // MMUnitUsageTreeEntry RootsChilds = Root.Childs [MMUnitUsageTreeEntry.ALL_ACTIVE_ENTRIES]; //List<MMUnitUsageData> AllDayUsageData = RootsChilds.Childs[MMUnitUsageTreeEntry.ALL_DAY_ENTRIES].ContentList; //List<MMUnitUsageData> ThisWeekDayUsageData = RootsChilds.Childs[WMB.Basics.ShortWeekDayNames[WeekDay]].ContentList; //Description.NamesOfLocalToDownloadDescriptions = new List<string> (); //foreach (MMUnitUsageData UsageData in DownloadEntriesStandBildUsageData) // { // Description.NamesOfLocalToDownloadDescriptions.Add(UsageData.PackageFileNamePart); // } //foreach (MMUnitUsageData UsageData in AllDayUsageData) // { // Description.NamesOfTodayActiveDescriptions.Add(UsageData.PackageFileNamePart); // } //foreach (MMUnitUsageData UsageData in ThisWeekDayUsageData) // { // Description.NamesOfTodayActiveDescriptions.Add(UsageData.PackageFileNamePart); // } Description.NamesOfTodayActiveDescriptions = new List<string>(); foreach (MMUnitUsageData UsageData in AvtiveThisDayParameter[DateTimeToHandle]) { Description.NamesOfTodayActiveDescriptions.Add(UsageData.PackageFileNamePart); } foreach (String PackageFileName in Description.NamesOfTodayActiveDescriptions) { bool Found = false; foreach (FileInfo FInfo in ExistingFiles) { if (FInfo.Name.ToLower () == Path.GetFileName (PackageFileName).ToLower ()) Found = true; } if (!Found) { WMB.Basics.ReportErrorToEventViewer("WPMediaCentralService.CreateStandbildPlayingData", "Der PackageFile \"" + PackageFileName + "\" fehlt"); } } int SkipLength = PackageFilesRootDirectory.Length + 1 - "Source\\".Length; if (WMB.Basics.IsTestRun) WMB.Basics.ReportInformationToEventViewer ("WPMediaCentralServices.CreateStandbildPlayingData", "NamesOfLocalToDownloadDescriptions = " + Convert.ToString (Description.NamesOfLocalToDownloadDescriptions.Count) + "\r\nNamesOfTodayActiveDescriptions = " + Convert.ToString (Description.NamesOfTodayActiveDescriptions.Count)); String EntryTimingType = tableDefinitionRow[CVM.CommonValues.WPMEDIA_ENTRY_TIMING_TYPE].ToString(); String PlayingOrder = tableDefinitionRow [CVM.CommonValues.WPMEDIA_ENTRY_PLAYING_ORDER].ToString (); double EntryDuration = 8; if (tableDefinitionRow [CVM.CommonValues.WPMEDIA_ENTRY_ENTRY_DURATION] != null) { if (!String.IsNullOrEmpty (tableDefinitionRow [CVM.CommonValues.WPMEDIA_ENTRY_ENTRY_DURATION].ToString ())) EntryDuration = Convert.ToDouble (tableDefinitionRow [CVM.CommonValues.WPMEDIA_ENTRY_ENTRY_DURATION]); } double OutsideSetDuration = -1; if (tableDefinitionRow [CVM.CommonValues.WPMEDIA_OUTSIDE_SET_DURATION] != null) { if (!String.IsNullOrEmpty (tableDefinitionRow [CVM.CommonValues.WPMEDIA_OUTSIDE_SET_DURATION].ToString ())) OutsideSetDuration = Convert.ToDouble (tableDefinitionRow [CVM.CommonValues.WPMEDIA_OUTSIDE_SET_DURATION]); } String MeaningOfOutsideSetDuration = tableDefinitionRow [CVM.CommonValues.WPMEDIA_MEANING_OF_OUTSIDE_SET_DURATION].ToString (); Description.TableName = TableName; Description.TableDefinitionTable = tableDefinitionRow.Table.Clone (); DataRow TableDefinitionRow = Description.TableDefinitionTable.NewRow (); TableDefinitionRow.ItemArray = tableDefinitionRow.ItemArray; Description.TableDefinitionTable.Rows.Add (TableDefinitionRow); Description.NameOfProcessingModule = tableDefinitionRow ["Type"].ToString (); Description.NamesOfActiveDescriptions = new List<string> (); Description.SortFields = new List<string> (); Description.LastWriteTimesOfNamesOfActiveDescriptions = new List<DateTime> (); Description.PlayLengthOfEachDescription = new List<TimeSpan> (); Description.NumberOfPagesOfEachDescription = new List<int> (); Description.NameOfPlayingDataDescription = TableName; Description.OverallPlayLength = 0; int OverallNumberOfPictures = 0; String TableType = tableDefinitionRow [CVM.CommonValues.WPMEDIA_ENTRY_TYPE_OF_TABLE].ToString (); ManagedTimingsControl TimingsCheckerClass = new ManagedTimingsControl (); CVM.ITimingsInterface TimingsCheckerInterface = TimingsCheckerClass as ITimingsInterface; TimingsCheckerInterface.m_TimingsTypenDataSet = m_DataBase.GetCommonDataSet ("Select * from TimingTypen"); foreach (String PackageFileName in Description.NamesOfTodayActiveDescriptions) { FileInfo Entry = new FileInfo(Path.Combine(PackageFilesRootDirectory, PackageFileName)); String ID = Path.GetFileNameWithoutExtension (Entry.FullName); DataTable UsedTimings; if (TimingsCheckerInterface.IsActive (ID, out UsedTimings) == false) continue; int NumberOfPages = 0; String SortField = PlayingOrder; TimeSpan PlayLengthForThisEntry = TimeSpan.Zero; List <double> PageDurations = new List<double> (); GraphicsHandling GraphicsHandler = new GraphicsHandling (LocalWPMediaRoot); if (GraphicsHandler.GetInstatiatedPackage (Entry.FullName) == null) { WMB.Basics.ReportErrorToEventViewer("WPMediaCentralServices.CreateStandbildPlayingData", "Der File\r\n\"" + Entry.FullName + "\"\r\nkonnte nicht als gültiges Package aufgelöst werden.\r\n" + "In der Folge werden damit Fehler auftreten"); continue; } List<TimeSpan> DurationForEachPage = new List<TimeSpan> (); foreach (double PageDuration in GraphicsHandler.PageDurations) { PlayLengthForThisEntry += TimeSpan.FromSeconds(PageDuration); DurationForEachPage.Add(TimeSpan.FromSeconds(PageDuration)); } SortField = GraphicsHandler.GetFilledSortField (SortField); NumberOfPages = GraphicsHandler.PageDurations.Count; GraphicsHandler.Close (); Description.StandBildTVVersion = "PKG_Version"; Description.DurationOfEachPageInEachDescription.Add (DurationForEachPage); Description.FillTimingsForEachDescription (ID, UsedTimings); if ((NumberOfPages == 0) || (PlayLengthForThisEntry == TimeSpan.Zero)) { WMB.Basics.ReportErrorToEventViewer ("WPMediaCentralServices.CreateStandbildPlayingData", Entry.FullName + " in der Table \"" + TableName + "\" hat eine PlayLength von 0"); continue; } Description.NamesOfActiveDescriptions.Add (Entry.FullName.Substring (SkipLength)); if (String.IsNullOrEmpty(Description.SubDirectoryWhereTheDescriptionsAreLocated)) { Description.SubDirectoryWhereTheDescriptionsAreLocated = Path.GetDirectoryName (Entry.FullName.Substring (SkipLength)); } Description.LastWriteTimesOfNamesOfActiveDescriptions.Add (Entry.LastWriteTime); Description.SortFields.Add (SortField); Description.NumberOfPagesOfEachDescription.Add (NumberOfPages); OverallNumberOfPictures += NumberOfPages; Description.OverallPlayLength += PlayLengthForThisEntry.TotalSeconds; Description.PlayLengthOfEachDescription.Add (PlayLengthForThisEntry); } if (OutsideSetDuration > 0) { if (MeaningOfOutsideSetDuration == CVM.CommonValues.WPMEDIA_MEANING_OF_OUTSIDE_SET_DURATION_MAX) if (OutsideSetDuration < Description.OverallPlayLength) Description.OverallPlayLength = OutsideSetDuration; if (MeaningOfOutsideSetDuration == CVM.CommonValues.WPMEDIA_MEANING_OF_OUTSIDE_SET_DURATION_FIX) Description.OverallPlayLength = OutsideSetDuration; } Description.OverallNumberOfPicturesToShow = OverallNumberOfPictures; String ControlFileName = Description.TableName; if (tableDefinitionRow ["DefinitionNameToCreate"] != Convert.DBNull) if (!String.IsNullOrEmpty (tableDefinitionRow ["DefinitionNameToCreate"].ToString ())) ControlFileName = tableDefinitionRow ["DefinitionNameToCreate"].ToString (); //TODO String PlayingDataDirectory = Path.Combine(LocalWPMediaRoot, XML_SENDER_AUTO_CONTROL_DIRECTORY); String PlayingDataDirectory = Path.Combine(WPMediaServerRootDirectory, XML_SENDER_AUTO_CONTROL_DIRECTORY); if (!Directory.Exists (PlayingDataDirectory)) Directory.CreateDirectory (PlayingDataDirectory); String FileName = Path.Combine (PlayingDataDirectory, ControlFileName + AUTO_CONTROL_FILE_EXT_EXTENSION_SHORT); Description.FillIndexIndizess (); WPMediaStandbildPlayingData EarlierDescription = GetWPMediaStandbildPlayingDataFromAssembledFile (FileName); // EarlierDescription.ClearAllRandomElements(); if (PlayingDataObjectsAreEqual(EarlierDescription, Description)) return; MemoryStream ContentOfPlayingData = AssembleContentOfPlayingData(Description, Convert.ToString(Description.OverallPlayLength), Description.TableName, "StandbildTV"); bool CorrectDeleted = true; if (File.Exists (FileName)) { CorrectDeleted = CommonDataBase.CommonBasics.SecureFileDelete (FileName, null); } if (CorrectDeleted) { FileStream TargetFile = File.Open (FileName, FileMode.Create, FileAccess.Write); ContentOfPlayingData.WriteTo(TargetFile); TargetFile.Close (); } ContentOfPlayingData.Close (); }
private static String CheckLoadAndGetFileNameOfTemplate (String TableName, String TemplateID) { WCFStandards m_DataBase = new WCFStandards(); m_DataBase.DefaultConnectionStringName = "WPMediaAddOnDataConnectionString"; CVM.GraphicsHandling TemplateHelperGraphicsHandler = new GraphicsHandling (Basics.GetLocalWPMediaRoot ()); TemplateHelperGraphicsHandler.RemoteWPMediaRoot = Basics.GetRemoteWPMediaRoot (); TemplateHelperGraphicsHandler.GetLastWriteTimeForServerFileCall += new WMB.GetLastWriteTimeForServerFileEvent (GraphicsHandler_GetLastWriteTimeForServerFileCall); TemplateHelperGraphicsHandler.DoCentralFileDownloadCall += new WMB.DoCentralFileDownloadEvent (GraphicsHandler_DoCentralFileDownloadCall); TemplateHelperGraphicsHandler.DoCentralStreamDownloadCall +=new WMB.DoCentralStreamDownloadEvent(GraphicsHandler_DoCentralStreamDownloadCall); TemplateHelperGraphicsHandler.DoSQLBatchCall +=new DoSQLBatchEvent(GraphicsHandler_DoSQLBatchCall); TemplateHelperGraphicsHandler.CheckAndGetInstatiatedPackage (m_DataBase, TableName, TemplateID); return TemplateHelperGraphicsHandler.Close (); }
public bool DoTemplating (Object Sender, String FileNameToTemplate, String TemplateTableName, String TemplateTableID) { String TemplateFileName = CheckLoadAndGetFileNameOfTemplate (TemplateTableName, TemplateTableID); CVM.GraphicsHandling ToTemplateGraphicsHandler = new GraphicsHandling (Basics.GetLocalWPMediaRoot ()); ToTemplateGraphicsHandler.GetInstatiatedPackage (FileNameToTemplate); ToTemplateGraphicsHandler.Close (); Basics.SecureFileDelete (FileNameToTemplate); File.Copy (TemplateFileName, FileNameToTemplate); CVM.GraphicsHandling TemplateGraphicsHandler = new GraphicsHandling (Basics.GetLocalWPMediaRoot ()); Object TemplatePkg = TemplateGraphicsHandler.GetInstatiatedPackage (FileNameToTemplate, true); DataRow ToTemplateFrameContentRow = ToTemplateGraphicsHandler.ActuallReadableContentRow; DataRow TemplateFrameContentRow = TemplateGraphicsHandler.ActuallReadableContentRow; Basics.ReplaceTableInDataSet (TemplateGraphicsHandler.FrameDataDataSetReader, TemplateFrameContentRow.Table, ToTemplateFrameContentRow.Table); Basics.CopyDataRowToDataRow (ToTemplateGraphicsHandler.FrameDataDataSetReader.Tables ["TableDefinitions"].Rows [0], TemplateGraphicsHandler.FrameDataDataSetReader.Tables ["TableDefinitions"].Rows [0]); TemplateGraphicsHandler.RenewFrameDataSet (); TemplateGraphicsHandler.Close (); return true; }
void CreatePkgIfNotExist (String TableName, DataRow RowToProcess) { String ID = RowToProcess ["ID"].ToString (); GraphicsHandling GraphicHandler = new GraphicsHandling (WPMediaRoot); GraphicHandler.DoCentralStreamDownloadCall += new DoCentralStreamDownloadEvent (GraphicHandler_DoCentralStreamDownloadCall); GraphicHandler.RemoteWPMediaRoot = CommonDataBase.DataBase.GetRemoteWPMediaRoot (); String ActuallPackageName = GraphicHandler.GetPackageName (TableName, ID); String ArchivedPackageName = ActuallPackageName.Replace ("\\" + CVM.CommonValues.XML_AUTO_CONTENT_SOURCE + "\\", "\\" + CVM.CommonValues.XML_AUTO_CONTENT_OLD_SOURCE + "\\"); if (File.Exists (ActuallPackageName)) return; if (File.Exists (ArchivedPackageName)) return; Object ResultedPackage = GraphicHandler.GetInstatiatedPackage (m_DataBase, TableName, ID); if (ResultedPackage == null) { WMB.Basics.ReportErrorToEventViewer ("CreateStandbildTVUnits.CreatePkgIfNotExist", "Bei der Tabelle \"" + TableName + "\" mit der ID \"" + ID + "\" (" + RowToProcess ["NameID"].ToString () + ") kam null beim ResultedPackage zurück"); return; } GraphicHandler.Close (); }
private int ReActivateStandBildsEntry (List<String> OldFiles, String TableName, DataRow RowToProcess) { String ID = RowToProcess ["ID"].ToString (); //GraphicsHandling GraphicHandler = new GraphicsHandling(WPMediaRoot); GraphicsHandling GraphicHandler = new GraphicsHandling(CommonDataBase.DataBase.GetRemoteWPMediaRoot()); GraphicHandler.DoCentralStreamDownloadCall += new DoCentralStreamDownloadEvent (GraphicHandler_DoCentralStreamDownloadCall); GraphicHandler.RemoteWPMediaRoot = CommonDataBase.DataBase.GetRemoteWPMediaRoot (); String ActuallPackageName = GraphicHandler.GetPackageName (TableName, ID); String ArchivedPackageName = ActuallPackageName.Replace ("\\" + CVM.CommonValues.XML_AUTO_CONTENT_SOURCE + "\\", "\\" + CVM.CommonValues.XML_AUTO_CONTENT_OLD_SOURCE + "\\"); if (!File.Exists (ActuallPackageName)) { if (File.Exists (ArchivedPackageName)) File.Move (ArchivedPackageName, ActuallPackageName); //else // { // WMB.Basics.ReportErrorToEventViewer ("CreateStandbildTVUnits.Create", // "Bei der Tabelle \"" + TableName + "\" bei der ID\r\n\"" // + ID + "\" gab es keinen Package File\r\nund keinen ArchivedPackageFile\r\n\"" // + ArchivedPackageName + "\""); // return 0; // } } Object ResultedPackage = GraphicHandler.GetInstatiatedPackage (m_DataBase, TableName, ID); if (ResultedPackage == null) { WMB.Basics.ReportErrorToEventViewer ("CreateStandbildTVUnits.Create", "Bei der Tabelle \"" + TableName + "\" kam null beim ResultedPackage zurück"); return 0; } RemoveControlFileFromFileList (OldFiles, ID); GraphicHandler.Close (); return 1; }