Ejemplo n.º 1
0
        /// <summary>
        /// Ermittelt alle Protokolleinträge für einen bestimmten Zeitraum.
        /// </summary>
        /// <param name="firstDate">Erster zu berücksichtigender Tag.</param>
        /// <param name="lastDate">Letzter zu berücksichtigender Tag.</param>
        /// <param name="profile">Profile, dessen Protokolle ausgelesen werden sollen.</param>
        /// <returns>Liste aller Protokolleinträge für den gewünschten Zeitraum.</returns>
        internal List <VCRRecordingInfo> FindLogEntries(DateTime firstDate, DateTime lastDate, ProfileState profile)
        {
            // Create list
            var logs = new List <VCRRecordingInfo>();

            // Create search patterns
            var last  = lastDate.AddDays(1).ToString(LogEntryDateFormat);
            var first = firstDate.ToString(LogEntryDateFormat);

            // Load all jobs
            foreach (var file in LogDirectory.GetFiles("*" + VCRRecordingInfo.FileSuffix))
            {
                // Skip
                if (file.Name.CompareTo(first) < 0)
                {
                    continue;
                }
                if (file.Name.CompareTo(last) >= 0)
                {
                    continue;
                }

                // Load item
                var logEntry = SerializationTools.Load <VCRRecordingInfo>(file);
                if (logEntry == null)
                {
                    continue;
                }

                // Check
                if (profile != null)
                {
                    if (!profile.IsResponsibleFor(logEntry.Source))
                    {
                        continue;
                    }
                }

                // Attach the name
                logEntry.LogIdentifier = file.Name.ToLower();

                // Remember
                logs.Add(logEntry);
            }

            // Sort by start time
            logs.Sort(VCRRecordingInfo.ComparerByStarted);

            // Report
            return(logs);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ermittelt einen Auftrag nach seiner eindeutigen Kennung.
        /// </summary>
        /// <param name="jobIdentifier">Die Kennung des Auftrags.</param>
        /// <returns>Der gewünschte Auftrag oder <i>null</i>, wenn kein derartiger
        /// Auftrag existiert.</returns>
        public VCRJob FindJob(Guid jobIdentifier)
        {
            // The result
            VCRJob result = null;

            // Synchronize
            lock (m_Jobs)
            {
                // Try map
                if (m_Jobs.TryGetValue(jobIdentifier, out result))
                {
                    return(result);
                }

                // Create file name
                var jobFile = new FileInfo(Path.Combine(ArchiveDirectory.FullName, jobIdentifier.ToString("N").ToUpper() + VCRJob.FileSuffix));
                if (!jobFile.Exists)
                {
                    return(null);
                }

                // Load
                result = SerializationTools.Load <VCRJob>(jobFile);
                if (result == null)
                {
                    return(null);
                }
            }

            // Check identifier and finalize settings - for pre-3.0 files
            if (!result.UniqueID.HasValue)
            {
                return(null);
            }
            if (!jobIdentifier.Equals(result.UniqueID.Value))
            {
                return(null);
            }

            // Finish
            result.SetProfile();

            // Found in archive
            return(result);
        }