Ejemplo n.º 1
0
        public static IMiramarScheduleProvider ParseSchedule(IMiramarPublisher publisher, string path)
        {
            var visitor = new MiramarVisitor();
            var parser  = new MiramarSchedulingParser(visitor);

            return(parser.CreateScheduleProvider(publisher, path));
        }
Ejemplo n.º 2
0
        public static IMiramarTaskProvider ParseConfiguration(IMiramarPublisher publisher, string path)
        {
            var visitor = new MiramarVisitor();
            var parser  = new MiramarConfigurationParser(visitor);

            return(parser.CreateTaskProvider(publisher, path));
        }
Ejemplo n.º 3
0
        public MiramarController()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["BillingAdmin"].ConnectionString;

            adminDataAccess = new AdminDataAccess(connectionString);

            logger = InfrastructureFactory.CreateLogger("Controller");

            publisher     = new MiramarPublisher();
            allowMetaData = false;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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.");
        }
Ejemplo n.º 9
0
 public MiramarScheduleProvider(IMiramarPublisher publisher, TaskScheduleModel[] collection)
     : this(collection)
 {
     this.publisher = publisher;
 }
Ejemplo n.º 10
0
 public MiramarController(IMiramarPublisher publisher, IMiramarTaskProvider taskProvider, IMiramarScheduleProvider scheduleProvider, IMiramarContextProvider contextProvider, bool allowMetaData)
     : this(publisher, taskProvider, scheduleProvider, contextProvider)
 {
     this.allowMetaData = allowMetaData;
 }
Ejemplo n.º 11
0
 public MiramarController(IMiramarPublisher publisher, IMiramarTaskProvider taskProvider, IMiramarScheduleProvider scheduleProvider, IMiramarContextProvider contextProvider)
     : this(taskProvider, scheduleProvider, contextProvider)
 {
     this.publisher = publisher;
 }
Ejemplo n.º 12
0
 public MiramarTaskProvider(IMiramarPublisher publisher, TaskConfigurationModel[] collection)
     : this(collection)
 {
     this.publisher = publisher;
 }
Ejemplo n.º 13
0
        public MiramarTaskProvider(TaskConfigurationModel[] collection)
        {
            this.collection = collection;

            publisher = new MiramarPublisher();
        }