示例#1
0
        public static bool Initialize()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(OutputPath) ||
                    OutputDirectory == null)
                {
                    throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Directory.");
                }
                if (string.IsNullOrWhiteSpace(WorkingPath) ||
                    WorkingDirectory == null)
                {
                    throw new ArgumentException("An empty or otherwise invalid path was detected for the Working Directory.");
                }
                if (string.IsNullOrWhiteSpace(LogPath))
                {
                    throw new ArgumentException("An empty or otherwise invalid path was detected for the Log directory.");
                }
                if (LogFile == null)
                {
                    throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Log file.");
                }
                if (ErrorFile == null)
                {
                    throw new ArgumentException("An empty or otherwise invalid path was detected for the Output Error file.");
                }

                if (!OutputDirectory.Exists)
                {
                    OutputDirectory.Create();
                }
                if (!WorkingDirectory.Exists)
                {
                    WorkingDirectory.Create();
                }
                if (!LogDirectory.Exists)
                {
                    LogDirectory.Create();
                }
                if (!LogFile.Exists)
                {
                    LogFile.Create();
                }
                if (!ErrorFile.Exists)
                {
                    ErrorFile.Create();
                }

                return(OutputDirectory.Exists && WorkingDirectory.Exists && LogFile.Exists && ErrorFile.Exists);
            }
            catch (Exception e)
            {
                Console.WriteLine($"\r\n{e.Message}\r\n{e}");
                throw;
            }
        }
示例#2
0
 private static void VerifyTargetDirectory()
 {
     if (LogDirectory != null)
     {
         LogDirectory.Refresh();
         if (!LogDirectory.Exists)
         {
             LogDirectory.Create();
         }
     }
 }
示例#3
0
        /// <summary>
        /// Erzeugt eine neue Verwaltungsinstanz und lädt die aktuellen Auftragsliste.
        /// </summary>
        /// <param name="rootDirectory">Meldet das Verzeichnis, unterhalb dessen alle
        /// Aufträge und Protokolle angelegt werden.</param>
        /// <param name="server">Die VCR.NET Instanz, der diese Verwaltung zugeordnet ist.</param>
        internal JobManager(DirectoryInfo rootDirectory, VCRServer server)
        {
            // Remember
            RootDirectory = rootDirectory;
            Server        = server;

            // Create root directory
            RootDirectory.Create();

            // Create working directories
            CollectorDirectory.Create();
            ArchiveDirectory.Create();
            JobDirectory.Create();
            LogDirectory.Create();

            // Load all jobs
            foreach (var job in VCRJob.Load(JobDirectory))
            {
                if (job.UniqueID.HasValue)
                {
                    m_Jobs[job.UniqueID.Value] = job;
                }
            }
        }