Exemple #1
0
 /// <summary>
 /// Permanentely deletes a single reminder from the database
 /// </summary>
 /// <param name="rem">The reminder you wish to remove</param>
 public static void PermanentelyDeleteReminder(Reminder rem)
 {
     if (rem != null && GetReminderById(rem.Id) != null) //Check if the reminder exists and isnt null
     {
         DLReminders.PermanentelyDeleteReminder(rem);
     }
 }
Exemple #2
0
 /// <summary>
 /// Permanentely deletes a single reminder from the database
 /// </summary>
 /// <param name="rem">The reminder you wish to remove</param>
 public static void PermanentelyDeleteReminder(int reminderId)
 {
     if (GetReminderById(reminderId) != null)
     {
         DLReminders.PermanentelyDeleteReminder(reminderId);
     }
 }
Exemple #3
0
 /// <summary>
 /// Deletes a single reminder from the database
 /// </summary>
 /// <param name="rem">The reminder you wish to remove</param>
 public static void DeleteReminder(Reminder rem)
 {
     if (rem != null)
     {
         DLReminders.DeleteReminder(rem);
     }
 }
Exemple #4
0
 /// <summary>
 /// Update an existing reminder.
 /// </summary>
 /// <param name="rem">The altered reminder</param>
 public static void EditReminder(Reminder rem)
 {
     if (rem != null && DLReminders.GetReminderById(rem.Id) != null) //Check if the reminder exists
     {
         DLReminders.EditReminder(rem);
     }
     // else
     ///throw new ReminderException("Could not edit that reminder, it doesn't exist.");
 }
Exemple #5
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)
        {
            //First check if the reminder exists
            if (DLReminders.GetReminderById(remId) == null)
            {
                return(null);
            }

            return(DLAVRProperties.GetAVRProperties(remId));
        }
Exemple #6
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)
            {
                //First check if the reminder exists
                if (DLReminders.GetReminderById(remId) == null)
                {
                    return(null);
                }

                return(DLLocalDatabase.AVRProperty.GetAVRFilesFolders(remId));
            }
Exemple #7
0
        /// <summary>
        /// Inserts Advanced reminder properties into the database, with a link to the reminder by it's ID
        /// </summary>
        /// <param name="avr"></param>
        /// <returns>The id of the newly inserted row. -1 if something went wrong</returns>
        public static long InsertAVRProperties(AdvancedReminderProperties avr)
        {
            //First check if the reminder exists
            if (DLReminders.GetReminderById(avr.Remid) == null)
            {
                return(-1);
            }

            return(DLAVRProperties.InsertAVRProperties(avr));
        }
Exemple #8
0
            /// <summary>
            /// Inserts file/folder actions into the database, with a link to the reminder by it's ID
            /// </summary>
            /// <param name="avr"></param>
            /// <returns>The id of the newly inserted row. -1 if something went wrong</returns>
            public static long InsertAVRFilesFolders(AdvancedReminderFilesFolders avr)
            {
                //First check if the reminder exists
                if (DLReminders.GetReminderById(avr.Remid) == null)
                {
                    return(-1);
                }

                return(DLLocalDatabase.AVRProperty.InsertAVRFilesFolders(avr));
            }
Exemple #9
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)
 {
     if (id != -1)
     {
         return(DLReminders.GetReminderById(id));
     }
     else
     {
         return(null);
     }
 }
Exemple #10
0
 /// <summary>
 /// Inserts the reminder into the database.
 /// </summary>
 /// <param name="rem">The reminder you want added into the database</param>
 public static long PushReminderToDatabase(Reminder rem)
 {
     if (rem != null)
     {
         return(DLReminders.PushReminderToDatabase(rem));
     }
     else
     {
         return(-1);
     }
 }
Exemple #11
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)
 {
     BLIO.Log("BLReminder.GetReminderById(" + id + ")");
     if (id != -1)
     {
         return(DLReminders.GetReminderById(id));
     }
     else
     {
         return(null);
     }
 }
Exemple #12
0
        /// <summary>
        /// Inserts a new reminder into the database
        /// </summary>
        /// <param name="name">The name of the reminder</param>
        /// <param name="date">The date the reminder should pop up</param>
        /// <param name="repeatingType"></param>
        /// <param name="dayOfWeek">The day of the week this reminder should pop up at each week. Use null if the reminder isn't weekly</param>
        /// <param name="everyXDays">The amount of x. example: every 5 days</param>
        /// <param name="commaSeperatedDays">a string with days seperated by a comma. example: monday,friday,sunday</param>
        /// <param name="note">The optional note of this reminder</param>
        /// <param name="enabled">Wether this reminder is enabled or not. 1 = enabled   0 = not enabled</param>
        /// <param name="soundPath">The path to the sound effect that should play when this reminder pops up</param>
        /// <returns>Returns the ID of the newly inserted reminder</returns>
        public static long InsertReminder(string name, string date, string repeatingType, long?everyXDays, string commaSeperatedDays, string note, bool enabled, string soundPath, int updateTime = 0)
        {
            Reminder rem = new Reminder();

            rem.Name = name;

            DateTime test;

            //If split by comma [1] (second value) is not a datetime, it means the date is a single date WITH a comma in it. we gotta fix that
            if (date.Split(',').Length > 1 && !DateTime.TryParse(date.Split(',')[1], out test))
            {
                //The date contains a ',' , no good! Try and convert it to en-us
                date = DateTime.Parse(date.ToString(), CultureInfo.CurrentCulture).ToString();

                if (date.Contains(","))//Still contains a comma? Let's just convert it to en-us then..
                {
                    date = DateTime.Parse(date.ToString(), new CultureInfo("en-US")).ToString();
                }
            }

            rem.Date = date;


            rem.RepeatType = repeatingType.ToString();

            //below are nullable parameters. a reminder can have a dayofmonth, if it does, it won't have a everyXDays.
            if (everyXDays.HasValue)
            {
                rem.EveryXCustom = everyXDays;
            }

            //will containall selected days. example: "monday,thursday,saturday"
            if (commaSeperatedDays != null && commaSeperatedDays != "")
            {
                rem.RepeatDays = commaSeperatedDays;
            }

            rem.Note          = note;
            rem.SoundFilePath = soundPath;
            if (enabled)
            {
                rem.Enabled = 1;
            }
            else
            {
                rem.Enabled = 0;
            }

            rem.UpdateTime = updateTime;

            return(DLReminders.PushReminderToDatabase(rem));
        }
Exemple #13
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)
 {
     BLIO.Log("BLReminder.GetReminderById(" + id + ")");
     if (id != -1)
     {
         Reminder reminder = DLReminders.GetReminderById(id);
         GC.Collect();
         return(reminder);
     }
     else
     {
         return(null);
     }
 }
Exemple #14
0
        /// <summary>
        /// Gets all (enabled) reminders which are happening today.
        /// </summary>
        /// <returns></returns>
        public static List <Reminder> GetTodaysReminders()
        {
            List <Reminder> returnList = new List <Reminder>();

            foreach (Reminder rem in DLReminders.GetReminders())
            {
                //No postpone date? Is at least the first date's day <= today?
                if (rem.PostponeDate == null && Convert.ToDateTime(rem.Date.Split(',')[0]).DayOfYear <= DateTime.Now.DayOfYear && Convert.ToDateTime(rem.Date.Split(',')[0]).Year <= DateTime.Now.Year && rem.Enabled == 1)
                {
                    returnList.Add(rem);
                }
                //Postpone date, is at least the first postpone date's day <= today?
                else if (rem.PostponeDate != null && Convert.ToDateTime(rem.PostponeDate.Split(',')[0]).DayOfYear <= DateTime.Now.DayOfYear && Convert.ToDateTime(rem.Date.Split(',')[0]).Year <= DateTime.Now.Year && rem.Enabled == 1)
                {
                    returnList.Add(rem);
                }
            }

            return(returnList);
        }
Exemple #15
0
 /// <summary>
 /// Get all reminders that are marked as deleted
 /// </summary>
 /// <returns></returns>
 public static List <Reminder> GetDeletedReminders()
 {
     return(DLReminders.GetDeletedReminders());
 }
Exemple #16
0
        /// <summary>
        /// Gives a new value to a reminder based on it's repeating type, and inserts it into the database
        /// </summary>
        /// <param name="rem"></param>
        public static void UpdateReminder(Reminder rem)
        {
            if (rem != null)
            {
                BLIO.Log("Updating reminder with id " + rem.Id);
                //Enable the reminder again
                rem.Enabled = 1;

                if (rem.RepeatType == ReminderRepeatType.WORKDAYS.ToString()) //Add days to the reminder so that the next date will be a new workday
                {
                    rem.Date = BLDateTime.GetNextReminderWorkDay(rem, true).ToString();
                }

                if (rem.RepeatType == ReminderRepeatType.DAILY.ToString())    //Add a day to the reminder
                {
                    UpdateReminderDateDaily(rem, true);
                }


                if (rem.RepeatType == ReminderRepeatType.MONTHLY.ToString())
                {
                    if (rem.Date.Split(',').Length > 1)
                    {
                        List <DateTime> reminderDates = new List <DateTime>();

                        foreach (string date in rem.Date.Split(','))     //go through each date. with monthly reminders, it can have multiple dates, seperated by comma's
                        {
                            if (Convert.ToDateTime(date) < DateTime.Now) //get the next day of the monthly day of the date. example: 10-6-2017 -> 10-7-2017 BUT 31-1-2017 -> 31-3-2017, since february doesnt have 31 days
                            {
                                reminderDates.Add(Convert.ToDateTime(BLDateTime.GetDateForNextDayOfMonth(Convert.ToDateTime(date)).ToShortDateString() + " " + Convert.ToDateTime(date).ToShortTimeString()));
                            }
                            else
                            {
                                reminderDates.Add(Convert.ToDateTime(date)); //Date in the future? good! do nothing with it.
                            }
                        }
                        //have to make sure the first date is in front.
                        reminderDates.Sort();

                        //Now, we're going to put the (sorted) dates in a string
                        string newDateString = "";
                        foreach (DateTime date in reminderDates)
                        {
                            if (rem.UpdateTime == 0)
                            {
                                newDateString += date.ToString() + ",";
                            }
                            else
                            {
                                newDateString += date.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ",";
                            }
                        }


                        rem.Date = newDateString.Remove(newDateString.Length - 1, 1);
                    }
                    else
                    {//There's only one date in this string.
                        if (rem.UpdateTime == 0)
                        {
                            rem.Date = BLDateTime.GetDateForNextDayOfMonth(Convert.ToDateTime(rem.Date)).ToShortDateString() + " " + Convert.ToDateTime(rem.Date).ToShortTimeString();
                        }
                        else
                        {
                            rem.Date = BLDateTime.GetDateForNextDayOfMonth(Convert.ToDateTime(rem.Date)).ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                        }
                    }
                }

                if (rem.RepeatType == ReminderRepeatType.MULTIPLE_DAYS.ToString())
                {
                    if (rem.UpdateTime == 0)
                    {
                        rem.Date = Convert.ToDateTime(BLDateTime.GetEarliestDateFromListOfStringDays(rem.RepeatDays)).ToShortDateString() + " " + Convert.ToDateTime(rem.Date).ToShortTimeString();
                    }
                    else
                    {
                        rem.Date = Convert.ToDateTime(BLDateTime.GetEarliestDateFromListOfStringDays(rem.RepeatDays)).ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                    }
                }

                if (rem.EveryXCustom != null)
                {
                    while (Convert.ToDateTime(rem.Date) < DateTime.Now)
                    {
                        //The user has a custom reminder, every x minutes,hours,days,weeks, or months
                        switch (rem.RepeatType.ToLower())
                        {
                        case "minutes":
                            rem.Date = Convert.ToDateTime(rem.Date).AddMinutes((double)rem.EveryXCustom).ToString();
                            break;

                        case "hours":
                            rem.Date = Convert.ToDateTime(rem.Date).AddHours((double)rem.EveryXCustom).ToString();
                            break;

                        case "days":
                            rem.Date = Convert.ToDateTime(rem.Date).AddDays((double)rem.EveryXCustom).ToString();
                            if (rem.UpdateTime == 1)
                            {
                                rem.Date = Convert.ToDateTime(rem.Date).ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                            }
                            break;

                        case "weeks":
                            rem.Date = Convert.ToDateTime(rem.Date).AddDays((double)rem.EveryXCustom * 7).ToString();
                            if (rem.UpdateTime == 1)
                            {
                                rem.Date = Convert.ToDateTime(rem.Date).ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                            }
                            break;

                        case "months":
                            rem.Date = Convert.ToDateTime(rem.Date).AddMonths((int)rem.EveryXCustom).ToString();
                            if (rem.UpdateTime == 1)
                            {
                                rem.Date = Convert.ToDateTime(rem.Date).ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
                            }
                            break;
                        }
                    }
                }
                if (rem.RepeatType == ReminderRepeatType.NONE.ToString())
                {
                    if (rem.Date.Split(',').Length > 1) //multiple dates seperated by comma's
                    {
                        string newDateString = "";      //The new date1,date2,date3 string that we will assign to the reminder

                        string[] dateArray = rem.Date.Split(',');

                        dateArray = dateArray.Where(s => Convert.ToDateTime(s) > DateTime.Now).ToArray(); //remove all elements from the array that already happened

                        if (dateArray.Length == 0)
                        {
                            DLReminders.ArchiveReminder(rem);
                            return;
                        }

                        foreach (string date in dateArray)
                        {
                            newDateString += date + ",";
                        }

                        newDateString = newDateString.Remove(newDateString.Length - 1, 1); //remove the last ','

                        rem.Date = newDateString;
                    }
                    else//it had one date, and that date caused this popup. Let's delete the reminder.
                    {
                        DLReminders.ArchiveReminder(rem);
                        return;
                    }
                }
                //finally, Write the changes to the database
                DLReminders.EditReminder(rem);
                BLIO.Log("Reminder updated");
            }
            else
            {
                throw new ArgumentNullException("parameter rem in UpdateReminder is null.");
            }
        }
Exemple #17
0
 /// <summary>
 /// Gets every reminder from the database
 /// </summary>
 /// <returns></returns>
 public static List <Reminder> GetAllReminders()
 {
     //currently no business logic
     return(DLReminders.GetAllReminders());
 }
Exemple #18
0
 /// <summary>
 /// forces the database to refresh the list
 /// </summary>
 public static void NotifyChange()
 {
     BLIO.Log("BLReminder.NotifyChange()");
     DLReminders.NotifyChange();
 }
Exemple #19
0
 public static void RefreshListview(ListView lv)
 {
     lv.Items.Clear();
     AddRemindersToListview(lv, DLReminders.GetReminders().Where(rem => rem.Hide == 0).ToList());
 }
Exemple #20
0
 /// <summary>
 /// Deletes multiple reminders from the database.
 /// </summary>
 /// <param name="rems"></param>
 public static void PermanentelyDeleteReminders(List <Reminder> rems)
 {
     DLReminders.PermanentelyDeleteReminders(rems);
 }
Exemple #21
0
 /// <summary>
 /// Marks a single reminder as deleted
 /// </summary>
 /// <param name="reminderId">The id of the reminder you wish to remove</param>
 public static void ArchiveReminder(int reminderId)
 {
     DLReminders.ArchiveReminder(reminderId);
 }
Exemple #22
0
 /// <summary>
 /// Marks a single reminder as archived
 /// </summary>
 /// <param name="rem">The reminder you wish to archive</param>
 public static void ArchiveReminder(Reminder rem)
 {
     DLReminders.ArchiveReminder(rem);
     GC.Collect();
 }
Exemple #23
0
 /// <summary>
 /// Get all reminders that are marked as deleted
 /// </summary>
 /// <returns></returns>
 public static List <Reminder> GetArchivedReminders()
 {
     return(DLReminders.GetArchivedReminders());
 }
Exemple #24
0
 /// <summary>
 /// Gets all "Corrupted" reminders. Corrupted reminders are reminders that are marked as corrupted, because they caused an exception. They can't be processed
 /// </summary>
 /// <returns></returns>
 public static List <Reminder> GetCorruptedReminders()
 {
     return(DLReminders.GetCorruptedReminders());
 }