Пример #1
0
            /// <summary>
            /// Verändert eine Aufzeichnung.
            /// </summary>
            /// <param name="scheduleIdentifier">Die eindeutige Kennung der Aufzeichnung.</param>
            /// <param name="newEnd">Der neue Endzeitpunkt der Aufzeichnung.</param>
            /// <returns>Gesetzt, wenn die Veränderung möglich ist.</returns>
            public bool Modify(Guid scheduleIdentifier, DateTime newEnd)
            {
                // Locate and validate
                var index = this.FindIndex(scheduleIdentifier);

                // Keep current recording settings
                var recording = m_Recordings[index];

                // Validate
                if (newEnd <= recording.Time.Start)
                {
                    throw new ArgumentOutOfRangeException("newEnd");
                }

                // Remove it
                m_Recordings[index] = new ResourceAllocationInformation(recording.Resource, recording.Source, recording.UniqueIdentifier, recording.Name, recording.Time.Start, newEnd - recording.Time.Start);

                // Create a new plan
                try
                {
                    // Try to apply the change
                    var plan = CreateSchedulePlan();
                    if (plan != null)
                    {
                        // Remember the new situation
                        m_CurrentPlan = plan;

                        // Confirm
                        return(true);
                    }
                }
                catch
                {
                    // Recover
                    m_Recordings[index] = recording;

                    // Forward
                    throw;
                }

                // Recover
                m_Recordings[index] = recording;

                // Back to normal
                return(false);
            }
Пример #2
0
            /// <summary>
            /// Verändert eine Aufzeichnung.
            /// </summary>
            /// <param name="scheduleIdentifier">Die eindeutige Kennung der Aufzeichnung.</param>
            /// <param name="newEnd">Der neue Endzeitpunkt der Aufzeichnung.</param>
            /// <returns>Gesetzt, wenn die Veränderung möglich ist.</returns>
            public bool Modify( Guid scheduleIdentifier, DateTime newEnd )
            {
                // Locate and validate
                var index = this.FindIndex( scheduleIdentifier );

                // Keep current recording settings
                var recording = m_Recordings[index];

                // Validate
                if (newEnd <= recording.Time.Start)
                    throw new ArgumentOutOfRangeException( "newEnd" );

                // Remove it
                m_Recordings[index] = new ResourceAllocationInformation( recording.Resource, recording.Source, recording.UniqueIdentifier, recording.Name, recording.Time.Start, newEnd - recording.Time.Start );

                // Create a new plan
                try
                {
                    // Try to apply the change
                    var plan = CreateSchedulePlan();
                    if (plan != null)
                    {
                        // Remember the new situation
                        m_CurrentPlan = plan;

                        // Confirm
                        return true;
                    }
                }
                catch
                {
                    // Recover
                    m_Recordings[index] = recording;

                    // Forward
                    throw;
                }

                // Recover
                m_Recordings[index] = recording;

                // Back to normal
                return false;
            }