Changeset 2624


Ignore:
Timestamp:
05/11/12 07:46:10 (2 years ago)
Author:
lowjoel
Message:

First set of changes to allow implementation as a service.

Location:
branches/eraser6/EraserService
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/EraserService/Eraser.Manager/DirectExecutor.cs

    r2606 r2624  
    532532            } 
    533533 
     534            private new DirectExecutor Owner 
     535            { 
     536                get 
     537                { 
     538                    return (DirectExecutor)base.Owner; 
     539                } 
     540            } 
     541 
    534542            /// <summary> 
    535543            /// The data store for this object. 
  • branches/eraser6/EraserService/Eraser.Manager/Eraser.Manager.csproj

    r2514 r2624  
    6161    <Reference Include="System.Drawing" /> 
    6262    <Reference Include="System.Security" /> 
     63    <Reference Include="System.ServiceModel" /> 
    6364    <Reference Include="System.Windows.Forms" /> 
    6465    <Reference Include="System.Xml" /> 
  • branches/eraser6/EraserService/Eraser.Manager/Executor.cs

    r2610 r2624  
    2424using System.Text; 
    2525using System.IO; 
     26 
     27using System.ServiceModel; 
    2628 
    2729namespace Eraser.Manager 
     
    3234    /// abstract as they each will have their own ways of dealing with tasks. 
    3335    /// </summary> 
    34     public abstract class Executor : IDisposable 
     36    [ServiceContract(Namespace="http://eraser.sourceforge.net/", SessionMode=SessionMode.Required)] 
     37    public interface IExecutor : IDisposable 
    3538    { 
    36         #region IDisposable members 
    37         ~Executor() 
    38         { 
    39             Dispose(false); 
    40         } 
    41  
    42         protected virtual void Dispose(bool disposing) 
    43         { 
    44         } 
    45  
    46         public void Dispose() 
    47         { 
    48             Dispose(true); 
    49             GC.SuppressFinalize(this); 
    50         } 
    51         #endregion 
    52  
    53         /// <summary> 
    54         /// Starts the execution of tasks queued. 
    55         /// </summary> 
    56         public abstract void Run(); 
    57  
    5839        /// <summary> 
    5940        /// Queues the task for execution. 
    6041        /// </summary> 
    6142        /// <param name="task">The task to queue.</param> 
    62         public abstract void QueueTask(Task task); 
     43        [OperationContract] 
     44        void QueueTask(Task task); 
    6345 
    6446        /// <summary> 
     
    6648        /// </summary> 
    6749        /// <param name="task">The task to schedule</param> 
    68         public abstract void ScheduleTask(Task task); 
     50        [OperationContract] 
     51        void ScheduleTask(Task task); 
    6952 
    7053        /// <summary> 
     
    7457        /// remove requested tasks and not the scheduled ones</remarks> 
    7558        /// <param name="task">The task to cancel.</param> 
    76         public abstract void UnqueueTask(Task task); 
    77  
    78         /// <summary> 
    79         /// Gets whether a task is currently queued for execution, outside of the 
    80         /// scheduled time. 
    81         /// </summary> 
    82         /// <param name="task">The task to query.</param> 
    83         /// <returns>True if the task is currently queued, false otherwise.</returns> 
    84         internal abstract bool IsTaskQueued(Task task); 
     59        [OperationContract] 
     60        void UnqueueTask(Task task); 
    8561 
    8662        /// <summary> 
     
    9167        /// restart. Therefore this fuction has to be explicitly called by clients. 
    9268        /// </summary> 
     69        [OperationContract] 
     70        void QueueRestartTasks(); 
     71 
     72        /// <summary> 
     73        /// Retrieves the current task list for the executor. 
     74        /// </summary> 
     75        /// <returns>A list of tasks which the executor has registered.</returns> 
     76        [OperationContract] 
     77        ExecutorTasksCollection GetTasks(); 
     78    } 
     79 
     80    public abstract class Executor : IExecutor, IDisposable 
     81    { 
     82        #region IDisposable members 
     83        ~Executor() 
     84        { 
     85            Dispose(false); 
     86        } 
     87 
     88        protected virtual void Dispose(bool disposing) 
     89        { 
     90        } 
     91 
     92        public void Dispose() 
     93        { 
     94            Dispose(true); 
     95            GC.SuppressFinalize(this); 
     96        } 
     97        #endregion 
     98 
     99        /// <summary> 
     100        /// Starts the execution of tasks queued. 
     101        /// </summary> 
     102        public abstract void Run(); 
     103 
     104        /// <summary> 
     105        /// Queues the task for execution. 
     106        /// </summary> 
     107        /// <param name="task">The task to queue.</param> 
     108        public abstract void QueueTask(Task task); 
     109 
     110        /// <summary> 
     111        /// Schedules the given task for execution. 
     112        /// </summary> 
     113        /// <param name="task">The task to schedule</param> 
     114        public abstract void ScheduleTask(Task task); 
     115 
     116        /// <summary> 
     117        /// Removes the given task from the execution queue. 
     118        /// </summary> 
     119        /// <remarks>If the task given runs a recurring schedule, the task will only 
     120        /// remove requested tasks and not the scheduled ones</remarks> 
     121        /// <param name="task">The task to cancel.</param> 
     122        public abstract void UnqueueTask(Task task); 
     123 
     124        /// <summary> 
     125        /// Gets whether a task is currently queued for execution, outside of the 
     126        /// scheduled time. 
     127        /// </summary> 
     128        /// <param name="task">The task to query.</param> 
     129        /// <returns>True if the task is currently queued, false otherwise.</returns> 
     130        internal abstract bool IsTaskQueued(Task task); 
     131 
     132        /// <summary> 
     133        /// Queues all tasks in the task list which are meant for restart execution. 
     134        /// This is a separate function rather than just running them by default on 
     135        /// task load because creating a new instance and loading the task list 
     136        /// may just be a program restart and may not necessarily be a system 
     137        /// restart. Therefore this fuction has to be explicitly called by clients. 
     138        /// </summary> 
    93139        public abstract void QueueRestartTasks(); 
    94140 
     
    100146 
    101147        /// <summary> 
     148        /// Retrieves the current task list for the executor. 
     149        /// </summary> 
     150        /// <returns>A list of tasks which the executor has registered.</returns> 
     151        public ExecutorTasksCollection GetTasks() 
     152        { 
     153            return Tasks; 
     154        } 
     155 
     156        /// <summary> 
    102157        /// The task added event object. 
    103158        /// </summary> 
     
    133188        /// Constructor. 
    134189        /// </summary> 
    135         /// <param name="executor">The <seealso cref="Executor"/> object owning 
     190        /// <param name="executor">The <seealso cref="IExecutor"/> object owning 
    136191        /// this task list.</param> 
    137         protected ExecutorTasksCollection(Executor executor) 
     192        protected ExecutorTasksCollection(IExecutor executor) 
    138193        { 
    139194            Owner = executor; 
     
    200255        /// The owner of this task list. 
    201256        /// </summary> 
    202         protected Executor Owner { get; private set; } 
     257        protected IExecutor Owner { get; private set; } 
    203258    } 
    204259} 
  • branches/eraser6/EraserService/Eraser.Manager/RemoteExecutor.cs

    r2516 r2624  
    560560                throw new NotSupportedException(); 
    561561            } 
     562 
     563            private new RemoteExecutorClient Owner 
     564            { 
     565                get 
     566                { 
     567                    return (RemoteExecutorClient)base.Owner; 
     568                } 
     569            } 
    562570        } 
    563571    } 
  • branches/eraser6/EraserService/Eraser.Manager/Task.cs

    r2611 r2624  
    289289        /// The Executor object which is managing this task. 
    290290        /// </summary> 
    291         public Executor Executor 
     291        public IExecutor Executor 
    292292        { 
    293293            get 
     
    500500        } 
    501501 
    502         private Executor executor; 
     502        private IExecutor executor; 
    503503        private Schedule schedule; 
    504504        private SteppedProgressManager progress; 
  • branches/eraser6/EraserService/Eraser/Program.cs

    r2617 r2624  
    761761        /// The global Executor instance. 
    762762        /// </summary> 
    763         public static Executor eraserClient; 
     763        public static IExecutor eraserClient; 
    764764 
    765765        /// <summary> 
Note: See TracChangeset for help on using the changeset viewer.