static void Main(string[] args)
        {
            var processed = false;
            Console.Write("Initializing ChronoSpark Time Manager...");
            SparkLogic.Initialize();
            Console.WriteLine("DONE!");

            while (!processed)//!exit
            {
                Console.Write("ChronoSpark => ");
                processed = false;
                var cmd = "run-console";

                ReminderControl defaultController = new ReminderControl();
                NoActiveTaskListener noActiveTaskListener = new NoActiveTaskListener();
                IntervalPassedListener intervalPassedListener = new IntervalPassedListener();
                TimeToReportListener timeToReportListener = new TimeToReportListener();

                noActiveTaskListener.Suscribe(defaultController);
                intervalPassedListener.Suscribe(defaultController);
                timeToReportListener.Suscribe(defaultController);

                ThreadPool.QueueUserWorkItem(delegate { defaultController.ActivateReminders(); });

                String[] cdmArgs = cmd.Split(' ');
                var commands = GetCommands();
                ConsoleModeCommand consoleRunner = new ConsoleModeCommand(GetCommands);
                commands = commands.Concat(new[] { consoleRunner });
                ConsoleCommandDispatcher.DispatchCommand(commands, cdmArgs, Console.Out);
                processed = true;

            }
        }
 protected override void OnStart(string[] args)
 {
     ReminderControl defaultController = new ReminderControl();
     ServiceListener serviceListener = new ServiceListener();
     ThreadPool.QueueUserWorkItem(delegate { defaultController.ActivateReminders(); });
     ThreadPool.QueueUserWorkItem(delegate { serviceListener.ActivateListener(); });
     eventLog1.WriteEntry("The Service has started");
 }
        public override int Run(String[] RemainingArguments)
        {
            IRavenEntity reminderToFetch = new Reminder();
            var actualReminderId = "Reminders/" + ReminderId;
            reminderToFetch.Id = actualReminderId;

            Reminder reminderToSet= SparkLogic.fetch(reminderToFetch) as Reminder;

            if (reminderToSet != null)
            {
                ReminderControl reminderControl = new ReminderControl();
            }
            return 0;
        }
 public bool Suscribe(ReminderControl reminderControl)
 {
     reminderControl.EventIntervalPassed += new ReminderControl.ReminderHandler(NotifyIntervalPassed);
     return true;
 }
        public void ActivateReminders()
        {
            IRepository repo = new Repository();
            StartTime = DateTime.Now;
            ActiveTaskProcess taskProcessor = new ActiveTaskProcess();
            ReportWeekReminder reportWeekReminder = new ReportWeekReminder();
            DailyReminders dailyReminders = new DailyReminders();

            while (true)
            {

                Thread.Sleep(60000);
                SparkLogic.Initialize();
                var listOfReminders = SparkLogic.ReturnReminderList();

                var timeElapsed = DateTime.Now - StartTime;
                var activeTask = repo.GetActiveTask();

                if (activeTask != null)
                {
                    taskProcessor.AddElapsedTime();
                }

                foreach (Reminder reminder in listOfReminders)
                {

                    ReminderEventArgs eventArgs = new ReminderEventArgs(reminder, activeTask);
                    ReminderControl reminderControl = new ReminderControl();

                    if (timeElapsed.Minutes >= 1)
                    {
                        if (timeElapsed.Minutes % reminder.Interval == 0 && activeTask == null && reminder.Type == ReminderType.NoActiveTask)
                        {
                            reminderControl.OnEventNoActiveTask(eventArgs);
                        }
                        if (timeElapsed.Minutes % reminder.Interval == 0 && activeTask != null && reminder.Type == ReminderType.DefaultHourly)
                        {
                            reminderControl.OnEventIntervalPassed(eventArgs);
                        }
                        if (reminder.Type==ReminderType.EndOfWeek) { reportWeekReminder.RemindEndOfWeek(reminder); }
                        if (reminder.Type==ReminderType.StartOfWeek) { reportWeekReminder.RemindStartOfWeek(reminder); }
                        if (reminder.Type == ReminderType.StartOfDay) { dailyReminders.RemindStartOfDay(reminder); }
                        if (reminder.Type == ReminderType.EndOfDay) { dailyReminders.RemindEndOfDay(reminder); }
                    }
                }
            }
        }
 public bool Suscribe(ReminderControl reminderControl)
 {
     reminderControl.EventNoActiveTask += new ReminderControl.ReminderHandler(NotifyLackOfActiveTask);
     return true;
 }