private bool RunLocalStartup () { String ErrorPlace = String.Empty; try { m_CVM = new CVM.CommonValues (); m_XAMLHandling = new CVM.XAMLHandling (m_CVM); m_CommonBasics = new CommonBasics (); //String MainModuleName = Process.GetCurrentProcess ().MainModule.FileName; //String ProgrammRoot= System.IO.Path.GetDirectoryName (System.IO.Path.GetDirectoryName // (MainModuleName)); String ProgrammDirectory = WMB.Basics.GetProgrammDirectory (); try { if (String.Compare(System.IO.Path.GetFileName(ProgrammDirectory), "InstallSystem") == 0) WMB.Basics.RegisterAllExeNamesForEventLogWriting(Path.Combine(System.IO.Path.GetFileName(ProgrammDirectory), "WPTV")); else WMB.Basics.RegisterAllExeNamesForEventLogWriting(); } catch (Exception Excp) { WMB.Basics.ReportErrorToEventViewer ("Fehler bei RegisterAllExeNamesForEventLogWriting\r\n" + " mit dem ProgrammDirectory: \"" + ProgrammDirectory + "\"\r\n" + Excp.ToString ()); } ErrorPlace = "After RegisterAllExeNamesForEventLogWriting"; m_ComputerName = WMB.Basics.GetComputerName(); String CentralServerName = WMB.Basics.GetConfigValue (CVM.CommonValues.CONFIG_COMMON_CONTROL_SERVER); String LocalCheckTimeSpanName = WMB.Basics.GetConfigValue (CVM.CommonValues.CONFIG_MANAGER_LOCAL_CHECK_TIMESPAN); if (!String.IsNullOrEmpty (LocalCheckTimeSpanName)) { this.START_LOCAL_FOLLOW_UP_ACTIVITY = Convert.ToDouble (LocalCheckTimeSpanName); this.START_LOCAL_ROOT_ACTIVITY = START_LOCAL_FOLLOW_UP_ACTIVITY / 10; } String RemoteCheckTimeSpanName = WMB.Basics.GetConfigValue (CVM.CommonValues.CONFIG_MANAGER_REMOTE_CHECK_TIMESPAN); if (!String.IsNullOrEmpty (LocalCheckTimeSpanName)) { this.START_NETWORK_FOLLOW_UP_ACTIVITY = Convert.ToDouble (LocalCheckTimeSpanName); this.START_NETWORK_ROOT_ACTIVITY = START_NETWORK_FOLLOW_UP_ACTIVITY / 10; } if (String.IsNullOrEmpty (CentralServerName)) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "Entweder kein Config File vorhanden oder kein Eintrag für \"" + CVM.CommonValues.CONFIG_COMMON_CONTROL_SERVER + "\" vorhanden"); return false; } ErrorPlace = "After CentralServerName"; String ComputerName = WMB.Basics.GetComputerName(); String LocalWPMediaDirectory = CommonDataBase.DataBase.GetLocalWPMediaRoot (); if (!Directory.Exists (LocalWPMediaDirectory)) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "WPMedia Root Directory nicht angelegt (\"" + LocalWPMediaDirectory + "\")"); return false; } String SystemManagementDirectory = Path.Combine (LocalWPMediaDirectory, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_DIRECTORY); if (!Directory.Exists (SystemManagementDirectory)) { try { Directory.CreateDirectory (SystemManagementDirectory); } catch (Exception SMExcp) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "SystemManagementDirectory Root Directory konnte nicht angelegt werden (\"" + SystemManagementDirectory + "\"):\r\n" + SMExcp.ToString()); return false; } } ErrorPlace = "After SystemManagementDirectory"; m_LocalCommandSourcePath = Path.Combine(SystemManagementDirectory, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_COMMAND_ROOT); if (!Directory.Exists (m_LocalCommandSourcePath)) { try { Directory.CreateDirectory (m_LocalCommandSourcePath); } catch (Exception LCExcp) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "LocalCommandSourcePath Root Directory konnte nicht angelegt werden (\"" + m_LocalCommandSourcePath + "\"):\r\n" + LCExcp.ToString()); return false; } } m_LocalProcessedCommandSourcePath = Path.Combine (SystemManagementDirectory, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_PROCESSED_COMMAND_ROOT); if (!Directory.Exists (m_LocalProcessedCommandSourcePath)) { try { Directory.CreateDirectory (m_LocalProcessedCommandSourcePath); } catch (Exception LCExcp) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "m_LocalProcessedCommandSourcePath Root Directory konnte nicht angelegt werden (\"" + m_LocalProcessedCommandSourcePath + "\"):\r\n" + LCExcp.ToString()); return false; } } ErrorPlace = "After m_LocalProcessedCommandSourcePath"; m_LocalProtokollSourcePath = Path.Combine (SystemManagementDirectory, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_LOGGING_DIRECTORY); if (!Directory.Exists (m_LocalProtokollSourcePath)) { try { Directory.CreateDirectory (m_LocalProtokollSourcePath); } catch (Exception LPExcp) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "LocalCommandSourcePath Root Directory konnte nicht angelegt werden (\"" + m_LocalProtokollSourcePath + "\"):\r\n" + LPExcp.ToString()); return false; } } ErrorPlace = "After m_LocalProtokollSourcePath"; String RemoteCommands = Path.Combine(Path.Combine("\\\\" + CentralServerName, CVM.CommonValues.XML_SENDER_ROOT_DIRECTORY), CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_DIRECTORY); m_RemoteCommandSourcePath = Path.Combine (RemoteCommands, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_COMMAND_ROOT); m_RemoteProtokollSourcePath = Path.Combine (RemoteCommands, CVM.CommonValues.CONFIG_COMMON_SYSTEM_MANAGER_LOGGING_DIRECTORY); return true; } catch (Exception Excp) { WMB.Basics.ReportErrorToEventViewer ("WPMediaSystemManager.RunLocalStartup", "Fehler bei Error Place " + ErrorPlace + ":\r\n" + Excp.ToString()); return false; } }
public void StartProcessTheCopyToServerQueue () { CommonDataBase.CommonBasics DoFileCopyToServerBasics = new CommonBasics (); String NextCopyOrderToProcess = ProcessCopyQueue (null, null); if (!String.IsNullOrEmpty (NextCopyOrderToProcess)) { DoFileCopyToServerBasics.SendFileBlockEventCall += new SendFileBlockEvent (m_DoFileCopyToServerBasics_SendFileBlockEventCall); DoFileCopyToServerBasics.CopyToServerListFinishedCall += new CopyToServerListFinished (m_DoFileCopyToServerBasics_SendFileListFinishedCall); } else { return; } while (!String.IsNullOrEmpty (NextCopyOrderToProcess)) { XDocument Order = XDocument.Load (NextCopyOrderToProcess); DataCollection<CopyInfoBlock> CopyList = new DataCollection<CopyInfoBlock>(); String From = String.Empty; String To = String.Empty; DateTime SourceLastWriteTime = DateTime.MinValue; foreach (XElement HeadEntry in Order.Document.Nodes ()) { if (HeadEntry.Name != CommonDataBase.CommonBasics.XML_AUTO_COPY_LIST) continue; foreach (XElement Entry in HeadEntry.Nodes ()) { if (Entry.Name != CommonDataBase.CommonBasics.XML_AUTO_FILE) continue; foreach (XElement FileEntry in Entry.Nodes ()) { if (FileEntry.Name == CommonDataBase.CommonBasics.XML_AUTO_FROM) From = FileEntry.Value; if (FileEntry.Name == CommonDataBase.CommonBasics.XML_AUTO_TO) To = FileEntry.Value; if (FileEntry.Name == CommonDataBase.CommonBasics.XML_AUTO_SOURCE_LAST_MODIFIED) SourceLastWriteTime = DateTime.Parse (FileEntry.Value); } } } CopyInfoBlock InfoBlock = new CopyInfoBlock (From, To, SourceLastWriteTime); InfoBlock.m_CleanupInformation = NextCopyOrderToProcess; CopyList.Add (InfoBlock); DoFileCopyToServerBasics.CopyToServer (CopyList, true); if (CopyList [0].m_Status != "Ok") { MessageBox.Show ("!!Der Übertragungsvorgang Zum Server von\r\n\"" + InfoBlock.m_From + "\"\r\nauf \"" + InfoBlock.m_To + "\"\r\nist fehlgeschlagen!!\r\nDer Status war\r\n\"" + CopyList [0].m_Status + "\"\r\nBitte Fehler beheben und ggf. wiederholen"); } else { FileInfo FInfo = new FileInfo (From); FInfo.LastWriteTime = DateTime.Now.AddSeconds (-30); } ProcessCopyQueue (null, NextCopyOrderToProcess); Basics.DoEvents (); NextCopyOrderToProcess = ProcessCopyQueue (null, null); } }
void m_CacheSynchronizationWorker_DoWork (object sender, DoWorkEventArgs e) { // Wait until UpLoad has been finished m_DownLoadFilesEvent = new ManualResetEvent (false); TableSyncParameter Param = (TableSyncParameter) e.Argument; NameValueCollection TableNames = Param.TablesToProcess; //CommonStatusMessage = "Directories werden überprüft"; BackgroundWorker LocalCacheSynchronizationWorker = sender as BackgroundWorker; CommonDataBase.CommonBasics m_CacheSynchronizationBasics = new CommonBasics (); m_CacheSynchronizationBasics.ReadFileBlockEventCall += new ReadFileBlockEvent (m_CacheSynchronizationBasics_ReadFileBlockEventCall); m_CacheSynchronizationBasics.CopyFromServerListFinishedCall += new CopyFromServerListFinished (m_CacheSynchronizationBasics_ReadFileListFinishedCall); m_CacheSynchronizationBasics.GetRemoteFileDataEventCall += new GetRemoteFileDataEvent (m_CacheSynchronizationBasics_GetRemoteFileDataEventCall); m_CacheSynchronizationBasics.DoSpecialNamingCall += new DoSpecialNamingEvent (m_Basics_DoSpecialNamingCall); m_CacheSynchronizationBasics.CopyFromServerListFinishedCall += new CopyFromServerListFinished (m_CacheSynchronizationBasics_CopyFromServerListFinishedCall); int MatchIndex = 0; foreach (String TableName in TableNames.Keys) { DataCollection<CopyInfoBlock> CopyBlock = new DataCollection<CopyInfoBlock>(); String TargetDirectory = Path.Combine (Path.Combine (CommonDataBase.DataBase.GetLocalWPMediaRoot (), "Source"), TableName); String SourceDirectory = Path.Combine (Path.Combine (CommonDataBase.DataBase.GetRemoteWPMediaRoot (), "Source"), TableName); if (TableNames [TableName] != "Gallerie") { if ((Param.CopyOnlyWhenElementNameMatchOneEntryPerTable != null) && (Param.CopyOnlyWhenElementNameMatchOneEntryPerTable [MatchIndex].Count > 0)) { DataCollection<CopyInfoBlock> HelpCopyBlock = new DataCollection<CopyInfoBlock>(); m_CacheSynchronizationBasics.SynchronizeNetworkDirectory (SourceDirectory, TargetDirectory, new String [] { ".sca", ".xml", ".auto", ".ppt", ".png", ".jpg", ".bmp", ".tiff", ".jpeg", ".db" }, TableName, TableNames [TableName].Replace (FORCE_DOWNLOAD_INDICATOR, ""), HelpCopyBlock, 30); foreach (CopyInfoBlock HelpEntry in HelpCopyBlock) { String Extension = Path.GetExtension (HelpEntry.m_From); String MatchString = String.Empty; if (String.Compare (Extension, ".stb", true) == 0) { MatchString = Path.GetFileNameWithoutExtension (HelpEntry.m_From); } else { MatchString = Path.GetFileName (Path.GetDirectoryName (HelpEntry.m_From)); } if (Param.CopyOnlyWhenElementNameMatchOneEntryPerTable [MatchIndex].Contains (MatchString) == true) { CopyBlock.Add (HelpEntry); } } } else { m_CacheSynchronizationBasics.SynchronizeNetworkDirectory (SourceDirectory, TargetDirectory, new String [] { ".sca", ".xml", ".auto", ".ppt", ".png", ".jpg", ".bmp", ".tiff", ".jpeg", ".db" }, TableName, TableNames [TableName].Replace ( FORCE_DOWNLOAD_INDICATOR, ""), CopyBlock, 30); } } if (CopyBlock.Count > 0) { CopyInfoBlock RunInfoBlock = new CopyInfoBlock (String.Empty, String.Empty, DateTime.MinValue); RunInfoBlock.m_Status = "Für \"" + TableName + "\" sind " + CopyBlock.Count.ToString () + " Updates erforderlich"; LocalCacheSynchronizationWorker.ReportProgress (0, RunInfoBlock); m_CacheSynchronizationBasics.RunCopyFromServerListSynchron (LocalCacheSynchronizationWorker, CopyBlock); foreach (CopyInfoBlock Block in CopyBlock) { if (Block.m_Status != "Ok") { Basics.ReportErrorToEventViewer ("WPMediaDataBase.m_CacheSynchronizationWorker_DoWork", "Der File\r\n\"" + Block.m_To + "\"\r\nkonnte nicht übertragen werden"); } } } CopyInfoBlock InfoBlock = new CopyInfoBlock (String.Empty, String.Empty, DateTime.MinValue); InfoBlock.m_Status = "Processed " + TableName; LocalCacheSynchronizationWorker.ReportProgress (101, InfoBlock); MatchIndex++; } }
private void DoFileCopyFromServer (string RemoteFileName, string LocalFileName, ref DateTime RemoteFileLastWriteTime) { CommonDataBase.CommonBasics DoFileCopyFromServerBasics = new CommonBasics (); DoFileCopyFromServerBasics.ReadFileBlockEventCall += new ReadFileBlockEvent (m_DoFileCopyFromServerBasics_ReadFileBlockEventCall); DoFileCopyFromServerBasics.CopyFromServerListFinishedCall += new CopyFromServerListFinished (m_DoFileCopyFromServerBasics_ReadFileListFinishedCall); DoFileCopyFromServerBasics.GetRemoteFileDataEventCall += new GetRemoteFileDataEvent (m_DoFileCopyFromServerBasics_GetRemoteFileDataEventCall); DoFileCopyFromServerBasics.DoSpecialNamingCall += new DoSpecialNamingEvent (m_DoFileCopyFromServerBasics_DoSpecialNamingCall); DataCollection<CopyInfoBlock> CopyList = new DataCollection<CopyInfoBlock>(); CopyList.Add (new CopyInfoBlock (RemoteFileName, LocalFileName, DateTime.MinValue)); DoFileCopyFromServerBasics.CopyFromServer (CopyList, true); if (CopyList [0].m_Status != "Ok") { //MessageBox.Show ("!!Dieser Übertragungsvorgang des Files \r\n\"" // + LocalFileName + "\"\r\nvom Server ist fehlgeschlagen!! Bitte wiederholen"); } RemoteFileLastWriteTime = CopyList [0].m_SourceLastWriteTime; }
CommonDataBase.CommonBasics GetCompleteAdjustedCommonBasics () { CommonDataBase.CommonBasics DoFileCopyFromServerBasics = new CommonBasics (); DoFileCopyFromServerBasics.ReadFileBlockEventCall += new ReadFileBlockEvent (m_DoFileCopyFromServerBasics_ReadFileBlockEventCall); DoFileCopyFromServerBasics.CopyFromServerListFinishedCall += new CopyFromServerListFinished (m_DoFileCopyFromServerBasics_ReadFileListFinishedCall); DoFileCopyFromServerBasics.GetRemoteFileDataEventCall += new GetRemoteFileDataEvent (m_DoFileCopyFromServerBasics_GetRemoteFileDataEventCall); DoFileCopyFromServerBasics.DoSpecialNamingCall += new DoSpecialNamingEvent (m_DoFileCopyFromServerBasics_DoSpecialNamingCall); return DoFileCopyFromServerBasics; }