/// <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); }
/// <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); }
/*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(); } }
/// <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); }
/// <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); } }
private static void RefreshCacheList() { using (RemindMeDbEntities db = new RemindMeDbEntities()) { localSongs = (from s in db.Songs select s).ToList(); db.Dispose(); } }
/// <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(); } }
/// <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); }
public static void DeleteAvrProperties(AdvancedReminderProperties prop) { using (RemindMeDbEntities db = new RemindMeDbEntities()) { db.AdvancedReminderProperties.Attach(prop); db.AdvancedReminderProperties.Remove(prop); db.SaveChanges(); db.Dispose(); } }
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); }
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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); //} } } }
/// <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); }
/// <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); }
/// <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(); } } }
/// <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); }
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(); } } }
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(); } } }
/// <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(); } }
/// <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(); } } }
/// <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(); } }
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(); } }
/// <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(); } }
/// <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(); } }
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(); } }