Exemple #1
0
        public List <Reminder> GetReminders()
        {
            using (var db = new RemindersContext())
            {
                if (db.Reminders == null || db.Reminders.Count() == 0)
                {
                    return(new List <Reminder>());
                }

                var list = db.Reminders.ToList();
                return(list.Select(r => new Reminder()
                {
                    Id = r.Id,
                    NotificationType = (NotificationType)r.NotificationType,
                    ReminderMessage = r.ReminderMessage,
                    Condition = r.ConditionAsString.Deserialize <AbstractCondition>(),
                    IsCompleted = r.IsCompleted,
                    CreatedOn = r.CreatedOn,
                    SnoozeUntil = r.SnoozeUntil,
                    SourcePath = r.SourcePath,
                    LineStart = r.LineStart,
                    CompletedOn = r.CompletedOn
                }).OrderBy(r => r.IsCompleted).ToList());
            }
        }
Exemple #2
0
        private void InitializeWithDTEAndSolutionReady()
        {
            m_dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE));

            if (m_dte == null)
            {
                ErrorHandler.ThrowOnFailure(1);
            }

            var solutionBase = "";
            var solutionName = "";

            if (m_dte.Solution != null)
            {
                solutionBase = System.IO.Path.GetDirectoryName(m_dte.Solution.FullName);
                solutionName = System.IO.Path.GetFileNameWithoutExtension(m_dte.Solution.FullName);
            }
            //string dbName = string.Format("Ganji.History-{0}.sdf", solutionName);

            var basePath     = PreparePath();
            var ganjiContext = new GanjiContext();

            ganjiContext.RepositoryPath = System.IO.Path.Combine(basePath, "LocalHistory");
            ganjiContext.SolutionPath   = solutionBase;

            CodeElementMagic.m_applicationObject = m_dte;

            HistoryContext.ConfigureDatabase(basePath);
            RemindersContext.ConfigureDatabase(basePath);
            SessionsContext.ConfigureDatabase(basePath);

            m_saveListener = new SaveListener();
            m_saveListener.Register(m_dte, ganjiContext);

            m_navigateListener = new NavigateListener();
            m_navigateListener.Register(m_dte, ganjiContext);

            m_exceptionListener = new ExceptionListener();
            m_exceptionListener.Register(m_dte, ganjiContext);
            //if (m_version != null)
            //{
            //    dbName = string.Format("ActivityDB{0}-{1}.sdf", m_version.ToString(),solutionName);
            //}

            //var basePath = PreparePath();
            //var path = System.IO.Path.Combine(basePath, dbName);
            //database = new Database(path);
            //database.OpenOrCreate();
        }
Exemple #3
0
        private void InitializeWithSolutionAndDTEReady()
        {
            string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);

            dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE));
            if (dte != null && dte.Solution != null)
            {
                path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
                path = System.IO.Path.Combine(path, "attachables", System.IO.Path.GetFileNameWithoutExtension(dte.Solution.FullName));
            }
            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }


            RemindersContext.ConfigureDatabase(path);
            Manager = new ReminderManager(this);

            // Check due reminders once during startup.
            Manager.CheckTodoBy();

            // Need to always have reference to avoid COM releasing.
            buildEvents = dte.Events.BuildEvents;

            buildEvents.OnBuildBegin += (scope, action) =>
            {
                // Check due reminders when building.
                Manager.CheckTodoBy();
            };

            buildEvents.OnBuildDone += (scope, action) =>
            {
            };


            buildEvents.OnBuildProjConfigBegin += (project, config, platform, solutionConfig) =>
            {
            };


            buildEvents.OnBuildProjConfigDone += (project, config, platform, solutionConfig, success) =>
            {
            };
        }
Exemple #4
0
        public void SaveReminder(Reminder reminder)
        {
            using (var db = new RemindersContext())
            {
                var dbReminder = db.Reminders.Where(r => r.Id == reminder.Id).SingleOrDefault();
                if (dbReminder == null)
                {
                    dbReminder = new ReminderContract()
                    {
                        ConditionAsString = reminder.Condition.Serialize(),
                        CreatedOn         = reminder.CreatedOn,
                        NotificationType  = (int)reminder.NotificationType,
                        ReminderMessage   = reminder.ReminderMessage,
                        IsCompleted       = reminder.IsCompleted,
                        SnoozeUntil       = reminder.SnoozeUntil,
                        SourcePath        = reminder.SourcePath,
                        LineStart         = reminder.LineStart,
                        CompletedOn       = reminder.CompletedOn
                    };
                    var updated = db.Reminders.Add(dbReminder);
                    db.SaveChanges();
                    reminder.Id = updated.Id;
                }
                else
                {
                    dbReminder.ConditionAsString = reminder.Condition.Serialize();
                    dbReminder.NotificationType  = (int)reminder.NotificationType;
                    dbReminder.ReminderMessage   = reminder.ReminderMessage;
                    dbReminder.IsCompleted       = reminder.IsCompleted;
                    dbReminder.SnoozeUntil       = reminder.SnoozeUntil;
                    dbReminder.SourcePath        = reminder.SourcePath;
                    dbReminder.LineStart         = reminder.LineStart;
                    dbReminder.CompletedOn       = reminder.CompletedOn;

                    db.SaveChanges();
                }

                if (RemindersUpdated != null)
                {
                    RemindersUpdated(this, EventArgs.Empty);
                }
            }
        }
Exemple #5
0
 public EventRepository(RemindersContext context)
 {
     _context = context;
 }
 public ReminderItemsController(RemindersContext context)
 {
     _context = context;
 }
 public ReminderService(RemindersContext remindersContext)
 {
     dataContext = remindersContext;
 }