示例#1
0
            /// <summary>
            /// Insert advanced Reminder properties into the database
            /// </summary>
            /// <param name="avr">The avr object</param>
            /// <returns></returns>
            public static long InsertAVRProperties(AdvancedReminderProperties avr)
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    if (db.AdvancedReminderProperties.Where(r => r.Remid == avr.Remid).Count() > 0)
                    {
                        //Exists already. update.
                        db.AdvancedReminderProperties.Attach(avr);
                        var entry = db.Entry(avr);
                        entry.State = System.Data.Entity.EntityState.Modified; //Mark it for update
                        db.SaveChanges();
                        db.Dispose();
                    }
                    else
                    {
                        if (db.AdvancedReminderProperties.Count() > 0)
                        {
                            avr.Id = db.AdvancedReminderProperties.Max(i => i.Id) + 1;
                        }

                        db.AdvancedReminderProperties.Add(avr);
                        db.SaveChanges();
                        db.Dispose();
                    }
                }
                return(avr.Id);
            }
示例#2
0
            /// <summary>
            /// Insert advanced Reminder HttpRequest into the database
            /// </summary>
            /// <param name="http">The avr object</param>
            /// <returns></returns>
            public static long InsertHttpRequest(HttpRequests http)
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    if (db.HttpRequests.Where(r => r.reminderId == http.reminderId).Count() > 0)
                    {
                        //Exists already. update.
                        db.HttpRequests.Attach(http);
                        var entry = db.Entry(http);
                        entry.State = System.Data.Entity.EntityState.Modified; //Mark it for update
                        db.SaveChanges();
                        db.Dispose();
                    }
                    else
                    {
                        if (db.HttpRequests.Count() > 0)
                        {
                            http.Id = db.HttpRequests.Max(i => i.Id) + 1;
                        }

                        db.HttpRequests.Add(http);
                        db.SaveChanges();
                        db.Dispose();
                    }
                }
                return(http.Id);
            }
示例#3
0
 /*This was testing a custom color scheme
  *
  * public static RemindMeColorScheme GetColorTheme(string themeName)
  * {
  *  RemindMeColorScheme theme;
  *  using (RemindMeDbEntities db = new RemindMeDbEntities())
  *  {
  *      theme = (from t in db.RemindMeColorScheme select t).Where(t => t.ThemeName == themeName).ToList().FirstOrDefault();
  *      db.Dispose();
  *  }
  *  return theme;
  * }*/
 private static void RefreshSettings()
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         int count = db.Settings.Where(o => o.Id >= 0).Count();
         if (count == 0)
         {
             settings             = new Settings();
             settings.AlwaysOnTop = 1;
             settings.StickyForm  = 0;
             settings.EnableReminderCountPopup = 1;
             settings.EnableHourBeforeReminder = 1;
             settings.HideReminderConfirmation = 0;
             settings.EnableQuickTimer         = 1;
             settings.DefaultTimerSound        = "";
             settings.EnableAdvancedReminders  = 0;
             settings.RemindMeTheme            = "Default";
             UpdateSettings(settings);
         }
         else
         {
             settings = (from s in db.Settings select s).ToList().FirstOrDefault();
         }
         db.Dispose();
     }
 }
示例#4
0
            /// <summary>
            /// Gets the amount of button spaces for 1 button, right now that's the same for all, but maybe that could change in the future
            /// </summary>
            /// <returns></returns>
            public static int GetButtonSpacing()
            {
                int spacing = -1;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    int count = db.ButtonSpaces.Where(o => o.Id >= 0).Count();
                    if (count == 0)
                    {
                        ButtonSpaces spaceObj = new ButtonSpaces();
                        spaceObj.Id        = 0;
                        spaceObj.Reminders = 5;
                        //spaceObj.MessageCenter = 5;
                        //more buttons possibly

                        spacing = 5;

                        db.ButtonSpaces.Add(spaceObj);
                        db.SaveChanges();
                    }
                    else
                    {
                        spacing = Convert.ToInt32((from b in db.ButtonSpaces select b.Reminders).SingleOrDefault());
                    }



                    db.Dispose();
                }

                return(spacing);
            }
示例#5
0
            /// <summary>
            /// Marks an message as read.
            /// </summary>
            /// <param name="message">The message to be marked</param>
            /// <returns></returns>
            public static bool MarkMessageRead(Database.Entity.RemindMeMessages message)
            {
                try
                {
                    ReadMessages msg = new ReadMessages();
                    msg.ReadMessageId = message.Id;
                    msg.MessageText   = message.Message;
                    msg.ReadDate      = message.DateOfCreation.Value.ToString();

                    using (RemindMeDbEntities db = new RemindMeDbEntities())
                    {
                        if (db.ReadMessages.Count() > 0)
                        {
                            msg.Id = db.ReadMessages.Max(i => i.Id) + 1;
                        }
                        else
                        {
                            msg.Id = 0;
                        }

                        db.ReadMessages.Add(msg);
                        db.SaveChanges();
                        db.Dispose();
                        return(true);
                    }
                }
                catch
                {
                    return(false);
                }
            }
示例#6
0
 private static void RefreshCacheList()
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         localSongs = (from s in db.Songs select s).ToList();
         db.Dispose();
     }
 }
示例#7
0
 /// <summary>
 /// Gives the localReminders list a new value after the database has changed.
 /// </summary>
 private static void RefreshCacheList()
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         localReminders = (from g in db.Reminder select g).ToList();
         db.Dispose();
     }
 }
示例#8
0
            /// <summary>
            /// Get the http-request (advanced reminder) for a reminder
            /// </summary>
            /// <param name="remId">The id of the reminder</param>
            /// <returns></returns>
            public static HttpRequests GetHttpRequest(long remId)
            {
                HttpRequests http = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    http = (from g in db.HttpRequests select g).Where(r => r.reminderId == remId).SingleOrDefault();
                    db.Dispose();
                }
                return(http);
            }
示例#9
0
        public static void DeleteAvrProperties(AdvancedReminderProperties prop)
        {
            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                db.AdvancedReminderProperties.Attach(prop);
                db.AdvancedReminderProperties.Remove(prop);

                db.SaveChanges();
                db.Dispose();
            }
        }
示例#10
0
            public static List <Themes> GetThemes()
            {
                List <Themes> themes = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    themes = (from g in db.Themes select g).ToList();
                    db.Dispose();
                }
                return(themes);
            }
示例#11
0
            public static Themes GetThemeById(long id)
            {
                Themes theme = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    theme = (from g in db.Themes select g).Where(i => i.Id == id).SingleOrDefault();
                    db.Dispose();
                }
                return(theme);
            }
示例#12
0
            /// <summary>
            /// Get the HttpRequest conditions for a HttpRequest
            /// </summary>
            /// <param name="requestId">The id of the parent HttpRequest</param>
            /// <returns></returns>
            public static HttpRequestCondition GetCondition(long id)
            {
                HttpRequestCondition condition = new HttpRequestCondition();

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    condition = (from g in db.HttpRequestCondition select g).Where(r => r.Id == id).SingleOrDefault();
                    db.Dispose();
                }
                return(condition);
            }
示例#13
0
            /// <summary>
            /// Get the HttpRequest conditions for a HttpRequest
            /// </summary>
            /// <param name="requestId">The id of the parent HttpRequest</param>
            /// <returns></returns>
            public static List <HttpRequestCondition> GetConditions(long requestId)
            {
                List <HttpRequestCondition> conditions = new List <HttpRequestCondition>();

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    conditions = (from g in db.HttpRequestCondition select g).Where(r => r.RequestId == requestId).ToList();
                    db.Dispose();
                }
                return(conditions);
            }
示例#14
0
            /// <summary>
            /// Get all http-requests (advanced reminder)
            /// </summary>
            /// <param name="remId">The id of the reminder</param>
            /// <returns></returns>
            public static List <HttpRequests> GetHttpRequests()
            {
                List <HttpRequests> http = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    http = (from g in db.HttpRequests select g).ToList();
                    db.Dispose();
                }
                return(http);
            }
示例#15
0
            /// <summary>
            /// Get the advanced Reminder files/folders
            /// </summary>
            /// <param name="remId">The id of the reminder</param>
            /// <returns></returns>
            public static List <AdvancedReminderFilesFolders> GetAVRFilesFolders(long remId)
            {
                List <AdvancedReminderFilesFolders> avr = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    avr = (from g in db.AdvancedReminderFilesFolders select g).Where(r => r.Remid == remId).ToList();
                    db.Dispose();
                }
                return(avr);
            }
示例#16
0
            /// <summary>
            /// Get the advanced Reminder properties for a reminder
            /// </summary>
            /// <param name="remId">The id of the reminder</param>
            /// <returns></returns>
            public static AdvancedReminderProperties GetAVRProperties(long remId)
            {
                AdvancedReminderProperties avr = null;

                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    avr = (from g in db.AdvancedReminderProperties select g).Where(r => r.Remid == remId).SingleOrDefault();
                    db.Dispose();
                }
                return(avr);
            }
示例#17
0
 /// <summary>
 /// Checks wether the table x has column x
 /// </summary>
 /// <param name="columnName">The column you want to check on</param>
 /// <param name="table">The table you want to check on</param>
 /// <returns></returns>
 public static bool HasColumn(string columnName, string table)
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         try
         {
             var t = db.Database.SqlQuery <object>("SELECT " + columnName + " FROM [" + table + "]").ToList();
             db.Dispose();
             return(true);
         }
         catch (SQLiteException ex)
         {
             db.Dispose();
             //if (ex.Message.ToLower().Contains("no such column"))
             //{
             return(false);
             //}
         }
     }
 }
示例#18
0
        /// <summary>
        /// Gets all "deleted" reminders. Deleted reminders are reminders that are marked as deleted, but still exist.
        /// </summary>
        /// <returns>A list of reminders that are marked as deleted</returns>
        public static List <Reminder> GetDeletedReminders()
        {
            List <Reminder> toReturnList = new List <Reminder>();

            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                toReturnList = localReminders.Where(r => r.Deleted == 1 && r.Corrupted == 0).ToList();
                db.Dispose();
            }
            return(toReturnList);
        }
示例#19
0
        /// <summary>
        /// Gets an reminder with the matching unique id.
        /// </summary>
        /// <param name="id">The unique id</param>
        /// <returns>Reminder that matches the given id. null if no reminder was found</returns>
        public static Reminder GetReminderById(long id)
        {
            Reminder rem = null;

            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                rem = (from g in db.Reminder select g).Where(i => i.Id == id).SingleOrDefault();
                db.Dispose();
            }
            return(rem);
        }
示例#20
0
 /// <summary>
 /// Update an existing hotkey combination in the SQLite database
 /// </summary>
 /// <param name="hotkey">The hotkey object</param>
 private static void UpdateHotkey(Hotkeys hotkey)
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         var count = db.Hotkeys.Where(o => o.Id >= hotkey.Id).Count();
         if (count == 1)
         {
             db.Hotkeys.Attach(hotkey);
             var entry = db.Entry(hotkey);
             entry.State = System.Data.Entity.EntityState.Modified; //Mark it for update
             db.SaveChanges();                                      //push to database
             db.Dispose();
         }
         else
         {//The settings table is still empty
             db.Hotkeys.Add(hotkey);
             db.SaveChanges();
             db.Dispose();
         }
     }
 }
示例#21
0
        /// <summary>
        /// Gets all "deleted" reminders. Deleted reminders are reminders that are marked as deleted, but still exist.
        /// </summary>
        /// <returns>A list of reminders that are marked as deleted</returns>
        public static List <Reminder> GetArchivedReminders()
        {
            //TODO: GetDeletedReminders() is too similair, somehow clean it up
            List <Reminder> toReturnList = new List <Reminder>();

            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                toReturnList = localReminders.Where(r => r.Deleted == 2 && r.Corrupted == 0).ToList();
                db.Dispose();
            }
            return(toReturnList);
        }
示例#22
0
 public static void UpdateHttpRequest(HttpRequestCondition cond)
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         var count = db.HttpRequestCondition.Where(o => o.Id >= 0).Count();
         if (count > 0)
         {
             db.HttpRequestCondition.Attach(cond);
             var entry = db.Entry(cond);
             entry.State = System.Data.Entity.EntityState.Modified; //Mark it for update
             db.SaveChanges();                                      //push to database
             db.Dispose();
         }
         else
         {//The settings table is still empty
             db.HttpRequestCondition.Add(cond);
             db.SaveChanges();
             db.Dispose();
         }
     }
 }
示例#23
0
 public static void UpdateButtonSpacing(ButtonSpaces btn)
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         var count = db.ButtonSpaces.Where(o => o.Id >= 0).Count();
         if (count == 1)
         {
             db.ButtonSpaces.Attach(btn);
             var entry = db.Entry(btn);
             entry.State = System.Data.Entity.EntityState.Modified; //Mark it for update
             db.SaveChanges();                                      //push to database
             db.Dispose();
         }
         else
         {//The settings table is still empty
             db.ButtonSpaces.Add(btn);
             db.SaveChanges();
             db.Dispose();
         }
     }
 }
示例#24
0
        /// <summary>
        /// Insert a hotkey combination into the SQLite database
        /// </summary>
        /// <param name="hotkey">The hotkey object</param>
        public static void InsertHotkey(Hotkeys hotkey)
        {
            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                if (db.Hotkeys.Count() > 0)
                {
                    hotkey.Id = db.Reminder.Max(i => i.Id) + 1;
                }

                db.Hotkeys.Add(hotkey);
                db.SaveChanges();
                db.Dispose();
            }
        }
示例#25
0
 /// <summary>
 /// Removes a message that is marked as read from the local database
 /// </summary>
 /// <param name="onlineMessageId">the Id of the online message in the database</param>
 public static void DeleteMessage(int onlineMessageId)
 {
     using (RemindMeDbEntities db = new RemindMeDbEntities())
     {
         ReadMessages readMess = db.ReadMessages.Where(rm => rm.ReadMessageId == onlineMessageId).FirstOrDefault();
         if (readMess != null)
         {
             db.ReadMessages.Attach(readMess);
             db.ReadMessages.Remove(readMess);
             db.SaveChanges();
             db.Dispose();
         }
     }
 }
示例#26
0
            /// <summary>
            /// Delete all conditions that are paired to a HttpRequest
            /// </summary>
            /// <param name="httpRequestId"></param>
            public static void DeleteConditionsForHttpRequest(long httpRequestId)
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    foreach (HttpRequestCondition cond in db.HttpRequestCondition.Where(r => r.RequestId == httpRequestId).ToList())
                    {
                        db.HttpRequestCondition.Attach(cond);
                        db.HttpRequestCondition.Remove(cond);
                    }

                    db.SaveChanges();
                    db.Dispose();
                }
            }
示例#27
0
        public static void ResetToDefaults()
        {
            using (RemindMeDbEntities db = new RemindMeDbEntities())
            {
                sizes           = new ListviewColumnSizes();
                sizes.Title     = DEFAULT_TITLE_WIDTH;
                sizes.Date      = DEFAULT_DATE_WIDTH;
                sizes.Repeating = DEFAULT_REPEAT_WIDTH;
                sizes.Enabled   = DEFAULT_ENABLED_WIDTH;

                UpdateListviewSizes(sizes);
                db.Dispose();
            }
        }
示例#28
0
            /// <summary>
            /// Insert a hotkey combination into the SQLite database
            /// </summary>
            /// <param name="hotkey">The hotkey object</param>
            public static void InsertTheme(Themes theme)
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    if (db.Themes.Count() > 0)
                    {
                        theme.Id = db.Themes.Max(i => i.Id) + 1;
                    }

                    db.Themes.Add(theme);
                    db.SaveChanges();
                    db.Dispose();
                }
            }
示例#29
0
            /// <summary>
            /// Delete advanced reminder file(s)/folder(s) options (delete/open) for a specific reminder
            /// </summary>
            /// <param name="id">The ID of the avr record in the SQLite database</param>
            public static void DeleteAvrFilesFoldersById(long id)
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    foreach (AdvancedReminderFilesFolders avr in db.AdvancedReminderFilesFolders.Where(r => r.Remid == id).ToList())
                    {
                        db.AdvancedReminderFilesFolders.Attach(avr);
                        db.AdvancedReminderFilesFolders.Remove(avr);
                    }

                    db.SaveChanges();
                    db.Dispose();
                }
            }
示例#30
0
            public static void ResetToDefaults()
            {
                using (RemindMeDbEntities db = new RemindMeDbEntities())
                {
                    dimensions               = new PopupDimensions();
                    dimensions.FormWidth     = DEFAULT_FORM_WIDTH;
                    dimensions.FormHeight    = DEFAULT_FORM_HEIGHT;
                    dimensions.FontTitleSize = DEFAULT_FONT_TITLE_SIZE;
                    dimensions.FontNoteSize  = DEFAULT_FONT_NOTE_SIZE;

                    UpdatePopupDimensions(dimensions);
                    db.Dispose();
                }
            }