コード例 #1
0
        public static IMiramarScheduleProvider ParseSchedule(IMiramarPublisher publisher, string path)
        {
            var visitor = new MiramarVisitor();
            var parser  = new MiramarSchedulingParser(visitor);

            return(parser.CreateScheduleProvider(publisher, path));
        }
コード例 #2
0
        public static IMiramarTaskProvider ParseConfiguration(IMiramarPublisher publisher, string path)
        {
            var visitor = new MiramarVisitor();
            var parser  = new MiramarConfigurationParser(visitor);

            return(parser.CreateTaskProvider(publisher, path));
        }
コード例 #3
0
        public MiramarController()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["BillingAdmin"].ConnectionString;

            adminDataAccess = new AdminDataAccess(connectionString);

            logger = InfrastructureFactory.CreateLogger("Controller");

            publisher     = new MiramarPublisher();
            allowMetaData = false;
        }
コード例 #4
0
        public MiramarScheduleProvider(TaskScheduleModel[] collection)
        {
            this.collection = new List <TaskScheduleModel>(collection);

            logger    = InfrastructureFactory.CreateLogger("Scheduler");
            publisher = new MiramarPublisher();

            schedules      = new Dictionary <string, DateTime>();
            executionPlans = new Dictionary <string, List <string> >();

            PushTasksForInitialConsideration(collection);
        }
コード例 #5
0
        public IMiramarScheduleProvider CreateScheduleProvider(IMiramarPublisher publisher, ExecutionElement element)
        {
            if (element == null)
            {
                return(new MiramarScheduleProvider(publisher, new TaskScheduleModel[0]));
            }

            var collection = element.ExecutionTypes
                             .Select(CreateModel)
                             .ToArray();

            return(new MiramarScheduleProvider(publisher, collection));
        }
コード例 #6
0
        public IMiramarTaskProvider CreateTaskProvider(IMiramarPublisher publisher, ConfigurationElement element)
        {
            if (element == null)
            {
                return(new MiramarTaskProvider(publisher, new TaskConfigurationModel[0]));
            }

            var collection = element.Tasks
                             .Select(CreateModel)
                             .ToArray();

            return(new MiramarTaskProvider(publisher, collection));
        }
コード例 #7
0
        public IMiramarScheduleProvider CreateScheduleProvider(IMiramarPublisher publisher, string path)
        {
            var fileInfo = new FileInfo(path);

            if (!fileInfo.Exists)
            {
                return(new MiramarScheduleProvider(publisher, new TaskScheduleModel[0]));
            }

            using (var stream = fileInfo.OpenRead())
            {
                var document = XDocument.Load(stream);
                var element  = visitor.VisitExecution(document);

                return(CreateScheduleProvider(publisher, element));
            }
        }
コード例 #8
0
        protected override void OnStart(string[] args)
        {
            logger.Debug("Starting up service.");

            queueFactory = CreateMessageFactory(logger);
            if (!queueFactory.IsActive)
            {
                logger.InfoFormat("RabbitMQ is not active. Messaging will not be available.");
            }

            queuePublisher = new MiramarPublisher(queueFactory);

            var directory = AppDomain.CurrentDomain.BaseDirectory;
            var path      = Path.Combine(directory, "miramar.config");

            var contextProvider  = new MiramarContextProvider();
            var taskProvider     = MiramarConfigurationParser.ParseConfiguration(queuePublisher, path);
            var scheduleProvider = MiramarSchedulingParser.ParseSchedule(queuePublisher, path);

            serviceTask = new Task(() =>
            {
                logger.Info("Starting Miramar Controller.");

                var controller = new MiramarController(queuePublisher, taskProvider, scheduleProvider, contextProvider);
                controller.ThreadRun(serviceSource.Token);
            });
            serviceTask.ContinueWith(x => logger.Info("Controller is shutting down."));

            messageTask = new Task(() =>
            {
                logger.Info("Starting Miramar Scheduler.");

                var scheduler = new ScheduleService(queueFactory, taskProvider, scheduleProvider, contextProvider);
                scheduler.ThreadRun(serviceSource.Token);
            });
            messageTask.ContinueWith(x => logger.Info("Scheduler is shutting down."));

            AddMiramarAdapter(queueFactory);

            serviceTask.Start();
            messageTask.Start();

            logger.Info("Miramar Controller is now running.");
        }
コード例 #9
0
 public MiramarScheduleProvider(IMiramarPublisher publisher, TaskScheduleModel[] collection)
     : this(collection)
 {
     this.publisher = publisher;
 }
コード例 #10
0
 public MiramarController(IMiramarPublisher publisher, IMiramarTaskProvider taskProvider, IMiramarScheduleProvider scheduleProvider, IMiramarContextProvider contextProvider, bool allowMetaData)
     : this(publisher, taskProvider, scheduleProvider, contextProvider)
 {
     this.allowMetaData = allowMetaData;
 }
コード例 #11
0
 public MiramarController(IMiramarPublisher publisher, IMiramarTaskProvider taskProvider, IMiramarScheduleProvider scheduleProvider, IMiramarContextProvider contextProvider)
     : this(taskProvider, scheduleProvider, contextProvider)
 {
     this.publisher = publisher;
 }
コード例 #12
0
 public MiramarTaskProvider(IMiramarPublisher publisher, TaskConfigurationModel[] collection)
     : this(collection)
 {
     this.publisher = publisher;
 }
コード例 #13
0
        public MiramarTaskProvider(TaskConfigurationModel[] collection)
        {
            this.collection = collection;

            publisher = new MiramarPublisher();
        }