Пример #1
0
        /// <summary>
        /// Aktualisiert einen Auftrag oder legt einen Auftrag neu an.
        /// </summary>
        /// <param name="job">Der neue oder veränderte Auftrag.</param>
        /// <param name="scheduleIdentifier">Die eindeutige Kennung der veränderten Aufzeichnung.</param>
        public void Update(VCRJob job, Guid?scheduleIdentifier)
        {
            // Report
            if (job != null)
            {
                Tools.ExtendedLogging("Updating Job {0}", job.UniqueID);
            }

            // Load default profile name
            job.SetProfile();

            // Validate
            job.Validate(scheduleIdentifier);

            // Cleanup schedules
            job.CleanupExceptions();

            // Remove from archive - if job has been recovered
            job.Delete(ArchiveDirectory);

            // Try to store to disk - actually this is inside the lock because the directory virtually is part of our map
            lock (m_Jobs)
                if (job.Save(JobDirectory).GetValueOrDefault())
                {
                    m_Jobs[job.UniqueID.Value] = job;
                }
                else
                {
                    throw new ArgumentException(string.Format(Properties.Resources.SaveJobFailed, job.UniqueID), "job");
                }
        }
Пример #2
0
        /// <summary>
        /// Löscht einen aktiven oder archivierten Auftrag.
        /// </summary>
        /// <param name="job">Der zu löschende Auftrag.</param>
        public void Delete(VCRJob job)
        {
            // Check unique identifier
            if (!job.UniqueID.HasValue)
            {
                throw new InvalidJobDataException(Properties.Resources.BadUniqueID);
            }

            // Report
            Tools.ExtendedLogging("Deleting Job {0}", job.UniqueID);

            // Must synchronize
            lock (m_Jobs)
            {
                // Load from the map
                var internalJob = this[job.UniqueID.Value];

                // See if this is active
                if (internalJob != null)
                {
                    // Delete it
                    internalJob.Delete(JobDirectory);

                    // Remove from map
                    m_Jobs.Remove(internalJob.UniqueID.Value);

                    // Save to file
                    internalJob.Save(ArchiveDirectory);
                }
                else
                {
                    // Report
                    Tools.ExtendedLogging("Job not found in Active Directory - trying Archive");

                    // Must be archived
                    job.Delete(ArchiveDirectory);
                }
            }
        }