Exemplo n.º 1
0
        private void skipToNextDateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Skip (" + rem.Id + ")");
            //The reminder object has now been altered. The first date has been removed and has been "skipped" to it's next date
            BLReminder.SkipToNextReminderDate(rem);
            //push the altered reminder to the database
            BLReminder.EditReminder(rem);

            //Refresh to show changes
            UCReminders.Instance.UpdateCurrentPage();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.SkipCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.SkipCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();
        }
Exemplo n.º 2
0
        private void MUCReminders_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            BLIO.Log(files.Length + " File(s) dropped into RemindMe!");
            BLIO.Log(".remindme files: " + files.Where(file => Path.GetExtension(file) == ".remindme").ToList().Count);
            //Loop through each file that is dragged into RemindMe
            foreach (string file in files.Where(file => Path.GetExtension(file) == ".remindme").ToList())
            {
                List <object> remindersFromFile = BLReminder.DeserializeRemindersFromFile(file); //Objects from the .remindme file

                foreach (object rem in remindersFromFile.Where(rem => rem.GetType() == typeof(Reminder)).ToList())
                {
                    BLReminder.PushReminderToDatabase((Reminder)rem);
                    BLIO.Log("Deserialized reminder and inserted it into RemindMe");
                }
            }

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.ImportCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ MUCReminders.cs . -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();

            //finally, refresh the listview
            UpdateCurrentPage();
        }
Exemplo n.º 3
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Permanentely delete (" + rem.Id + ")");
            if (RemindMeBox.Show("Are you really sure you wish to permanentely delete \"" + rem.Name + "\" ?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
            {
                BLIO.Log("Permanentely deleting reminder with id " + rem.Id + " ...");
                BLReminder.PermanentelyDeleteReminder(rem);
                BLIO.Log("Reminder permanentely deleted.");

                this.Reminder = null;
                UCReminders.Instance.UpdateCurrentPage();

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.PermanentelyDeleteCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.PermanentelyDeleteCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                }).Start();
            }
            else
            {
                BLIO.Log("Permanent deletion of reminder " + rem.Id + " cancelled.");
            }
        }
Exemplo n.º 4
0
 private void numericUpDown_ValueChange(object sender, EventArgs e)
 {
     if (currentTimerItem == null)
     {
         return;
     }
     try
     {
         int secondsRemaining = Convert.ToInt32((Convert.ToInt32(numHours.Text) * 60 * 60) + (Convert.ToInt32(numMinutes.Text) * 60) + Convert.ToInt32(numSeconds.Text));
         if (secondsRemaining < -5)
         {
             BLIO.Log("Woah there.. Let's not assign this new time to this timer ;)");
             numHours.Text = numHours.Text.Substring(0, numHours.Text.Length - 2);
             return;
         }
         currentTimerItem.SecondsRemaining = secondsRemaining;
     }
     catch (OverflowException ex)
     {
         BLIO.Log("That number is a bit too large for this timer ;)");
         numHours.Text = numHours.Text.Substring(0, numHours.Text.Length - 2);
         numericUpDown_ValueChange(null, null);
     }
     catch (Exception ex)
     {
         BLIO.Log("numericUpDown_valuechange collection FAILED. -> " + ex);
         BLIO.WriteError(ex, "Failed to add time to this timer");
     }
 }
Exemplo n.º 5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvReminders.CheckedItems.Count > 0)
                {
                    foreach (Reminder rem in GetSelectedRemindersFromListview())
                    {
                        if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it.
                        {
                            rem.SoundFilePath = "";
                        }

                        BLIO.Log("Pushing reminder with id " + rem.Id + " To the database");
                        BLReminder.PushReminderToDatabase(rem);
                    }

                    //Let remindme know that the listview should be refreshed
                    BLIO.Log("Sending message WM_RELOAD_REMINDERS ....");
                    PostMessage((IntPtr)HWND_BROADCAST, WM_RELOAD_REMINDERS, new IntPtr(0xCDCD), new IntPtr(0xEFEF));
                    this.Close();
                }
                else
                {
                    RemindMeMessageFormManager.MakeMessagePopup("Please select at least one reminder.", 3);
                }
            }
            catch (Exception ex)
            {
                ErrorPopup pop = new ErrorPopup("Error inserting reminders", ex);
                pop.Show();
                BLIO.WriteError(ex, "Error inserting reminders");
            }
        }
Exemplo n.º 6
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            if (e.Exception is DirectoryNotFoundException)
            {
                DirectoryNotFoundException theException = (DirectoryNotFoundException)e.Exception;
                BLIO.WriteError(theException, "Folder not found.");
                ShowError(e.Exception, e.Exception.GetType().ToString(), theException.Message);
            }

            if (e.Exception is UnauthorizedAccessException)
            {
                UnauthorizedAccessException theException = (UnauthorizedAccessException)e.Exception;
                BLIO.WriteError(e.Exception, "Unauthorized!");
                ShowError(e.Exception, "Unauthorized!", "not authorized for this action.\r\nThis can be resolved by running in administrator-mode.");
            }

            //Here we just filter out some type of exceptions and give different messages, at the bottom is the super Exception, which can be anything.
            else if (e.Exception is FileNotFoundException)
            {
                FileNotFoundException theException = (FileNotFoundException)e.Exception; //needs in instance to call .FileName
                BLIO.WriteError(theException, "converteruld not find the file located at \"" + theException.FileName);
                ShowError(e.Exception, "File not found.", "Could not find the file located at \"" + theException.FileName + "\"\r\nHave you moved,renamed or deleted the file?");
            }

            else if (e.Exception is System.Data.Entity.Core.EntityException)
            {
                BLIO.WriteError(e.Exception, "System.Data.Entity.Core.EntityException");
                ShowError(e.Exception, "System.Data.Entity.Core.EntityException", "There was a problem executing SQL!");
            }

            else if (e.Exception is ArgumentNullException)
            {
                BLIO.WriteError(e.Exception, "Null argument");
                ShowError(e.Exception, "Null argument", "Null argument exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is NullReferenceException)
            {
                BLIO.WriteError(e.Exception, "Null reference");
                ShowError(e.Exception, "Null reference", "Null reference exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is SQLiteException)
            {
                BLIO.WriteError(e.Exception, "SQLite Database exception");
                ShowError(e.Exception, "SQLite Database exception", "encountered a database error!\r\nThis might or might not be on your end. It can be on your end if you modified the database file");
            }

            else if (e.Exception is PathTooLongException)
            {
                BLIO.WriteError(e.Exception, "The path to the file is too long.");
                ShowError(e.Exception, "File Path too long.", "The path to the file is too long!.");
            }


            else if (e.Exception is Exception)
            {
                BLIO.WriteError(e.Exception, "Unknown exception in main.");
            }
        }
Exemplo n.º 7
0
        private void Cleanup()
        {
            try
            {
                BLIO.Log("Starting Cleanup...");
                //RemindMe loaded, if an old system log/temp reminders still exists, delete it
                string oldSystemLog      = IOVariables.systemLog;
                string oldTempReminders  = System.IO.Path.GetTempPath() + "Exported Reminders.remindme";
                string oldUpdateFilesZip = IOVariables.rootFolder + "UpdateFiles.zip";

                if (System.IO.File.Exists(oldSystemLog))
                {
                    System.IO.File.Delete(oldSystemLog);
                    BLIO.Log("- Deleted   " + Path.GetFileName(oldSystemLog));
                }
                if (System.IO.File.Exists(oldTempReminders))
                {
                    System.IO.File.Delete(oldTempReminders);
                    BLIO.Log("- Deleted   " + Path.GetFileName(oldTempReminders));
                }
                if (System.IO.File.Exists(oldUpdateFilesZip))
                {
                    System.IO.File.Delete(oldUpdateFilesZip);
                    BLIO.Log("- Deleted   " + Path.GetFileName(oldUpdateFilesZip));
                }
                if (Directory.Exists(IOVariables.applicationFilesFolder + "\\old"))
                {
                    Directory.Delete(IOVariables.applicationFilesFolder + "\\old", true);
                    BLIO.Log("- Deleted   \\old Folder");
                }

                //If the errorlog is >= 5mb , clear it. That's a bit big..
                if (System.IO.File.Exists(IOVariables.errorLog) && new FileInfo(IOVariables.errorLog).Length / 1024 >= 5000)
                {
                    BLIO.Log("Clearing error log that is too large... [" + new FileInfo(IOVariables.errorLog).Length / 1024 + ".mb ]");

                    if (System.IO.File.Exists(IOVariables.errorLog))
                    {
                        System.IO.File.WriteAllText(IOVariables.errorLog, "");
                    }
                }

                BLIO.Log("Cleanup complete.");
            }
            catch (UnauthorizedAccessException ex)
            {
                BLIO.Log("Cleanup() FAILED. Unauthorized");
                //BLIO.WriteError(ex, "Error in Cleanup()"); //don't write this one to the db
            }
            catch (IOException ex)
            {
                BLIO.Log("Cleanup() FAILED. IOException");
                BLIO.WriteError(ex, "Error in Cleanup()");
            }
            catch (Exception ex)
            {
                BLIO.Log("Cleanup() FAILED. Global exception");
                BLIO.WriteError(ex, "Error in Cleanup()");
            }
        }
Exemplo n.º 8
0
        private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Duplicate (" + rem.Id + ")");
            BLIO.Log("Setting up the duplicating process...");
            BLIO.Log("duplicating reminder with id " + rem.Id);
            long oldRemId = rem.Id;
            long newRemId = BLReminder.PushReminderToDatabase(rem);

            AdvancedReminderProperties props = BLLocalDatabase.AVRProperty.GetAVRProperties(rem.Id);

            if (props != null)
            {
                props.Remid = newRemId;
                BLLocalDatabase.AVRProperty.InsertAVRProperties(props);
            }

            HttpRequests req = BLLocalDatabase.HttpRequest.GetHttpRequestById(oldRemId);

            if (req != null)
            {
                long oldHttpId = req.Id;
                req.reminderId = newRemId;
                long newHttpId = BLLocalDatabase.HttpRequest.InsertHttpRequest(req);
                List <HttpRequestCondition> conditions = BLLocalDatabase.HttpRequestConditions.GetConditions(oldHttpId);
                foreach (HttpRequestCondition cond in conditions)
                {
                    cond.RequestId = newHttpId;
                    BLLocalDatabase.HttpRequestConditions.InsertCondition(cond);
                }

                //Now update the duplicated reminder with the httprequest
                Reminder dup = BLReminder.GetReminderById(newRemId);
                dup.HttpId = req.Id;
                BLReminder.EditReminder(dup);
            }

            BLIO.Log("reminder duplicated.");
            MUCReminders.Instance.UpdateCurrentPage();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.DuplicateCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.DuplicateCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
                finally
                {
                    GC.Collect();
                }
            }).Start();
        }
Exemplo n.º 9
0
        private void tmrCheckRemindMeMessages_Tick(object sender, EventArgs e)
        {
            new Thread(() =>
            {
                try
                {
                    //Check for messages sent by me every minute
                    foreach (RemindMeMessages message in BLOnlineDatabase.RemindMeMessages)
                    {
                        //first, check if this user has already read this message.
                        if (BLLocalDatabase.ReadMessage.Messages.Where(m => m.ReadMessageId == message.Id).Count() == 0)
                        {
                            this.BeginInvoke(new MethodInvoker(delegate //This is required to show windows forms (the messages) on a new thread
                            {
                                BLIO.Log("RemindMe detected an unread message!");
                                //User hasn't read it yet. great! Mark the message as read
                                BLLocalDatabase.ReadMessage.MarkMessageRead(message);
                                BLIO.Log("Message marked as read.");

                                if (!string.IsNullOrWhiteSpace(message.MeantForSpecificPerson))
                                {
                                    BLIO.Log("This message is specifically for me!");
                                    //This message is meant for a specific user.

                                    if (BLLocalDatabase.Setting.Settings.UniqueString == message.MeantForSpecificPerson)
                                    {
                                        PopupRemindMeMessage(message);
                                    }
                                }
                                else if (!string.IsNullOrWhiteSpace(message.MeantForSpecificVersion))
                                {
                                    BLIO.Log("This message is specifically for the currently running RemindMe version (" + message.MeantForSpecificVersion + ")");
                                    //This message is meant for a specific RemindMe version. Only show this message if the user: Hasn't read this message AND: has this RemindMe version
                                    if (IOVariables.RemindMeVersion == message.MeantForSpecificVersion)
                                    {
                                        //Show the message
                                        PopupRemindMeMessage(message);
                                    }
                                }
                                else
                                {
                                    BLIO.Log("This is a global message. creating popup...");
                                    //A global message, not meant for a specific RemindMe version nor user
                                    PopupRemindMeMessage(message);
                                    BLIO.Log("popup created");
                                }
                            }));
                        }
                    }
                }
                catch (Exception ex)
                {
                    BLIO.Log("CheckRemindMeMessages FAILED. " + ex.GetType().ToString());
                    BLIO.WriteError(ex, "Error in tmrCheckRemindMeMessages_Tick");
                }
            }).Start();
        }
Exemplo n.º 10
0
        private async void PreviewReminder(int delay = 0)
        {
            //Set the reminder first, so that switching pages doesn't preview a different reminder.
            Reminder previewRem = CopyReminder(rem);

            if (delay > 0)
            {
                await Task.Delay(delay);
            }

            if (previewRem == null)
            {
                BLIO.Log("Reminder in PreviewReminder() is null. Interesting... ;)");
                MaterialMessageFormManager.MakeMessagePopup("Could not preview that reminder. It doesn't exist anymore!", 4, "Error");
                return;
            }

            BLIO.Log("Previewing reminder with id " + previewRem.Id);
            previewRem.Id = -1; //give the >temporary< reminder an invalid id, so that the real reminder won't be altered

            MaterialPopup p = new MaterialPopup(previewRem);

            MaterialSkin.MaterialSkinManager.Instance.AddFormToManage(p);
            p.TopMost  = true;
            p.TopLevel = true;
            p.Show();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    try
                    {
                        BLOnlineDatabase.PreviewCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                    finally
                    {
                        GC.Collect();
                    }
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();

            this.Invalidate();
            this.Refresh();
        }
Exemplo n.º 11
0
 private void tmrCheckForVersion_Tick(object sender, EventArgs e)
 {
     try
     {
         SetUpdateText();
         tmrCheckForVersion.Stop();
     }
     catch (Exception ex)
     {
         BLIO.Log("CheckForVersion FAILED. " + ex.GetType().ToString());
         BLIO.WriteError(ex, "Error in tmrCheckForVersion_Tick");
     }
 }
Exemplo n.º 12
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            BLIO.Log("CurrentDomain_UnhandledException [ " + e.ExceptionObject.ToString() + " ]");

            Exception ex = (Exception)e.ExceptionObject;

            if (ex != null)
            {
                BLIO.WriteError(ex, "Special CurrentDomain Error! " + ex.GetType());
                ShowError(ex, "Unknown error!", ex.Message);
                UCReminders.Instance.UpdateCurrentPage();
            }
        }
Exemplo n.º 13
0
        public void AddTimer(int seconds, string text)
        {
            BLIO.Log("Attempting to add a timer for " + seconds + " seconds.");
            TimerItem tmrItem = new TimerItem(DateTime.Now.AddSeconds(seconds), text, timerIdCounter, "material");

            tmrItem.updateAllowed = true;
            tmrItem.StartTimer();
            timers.Add(tmrItem);

            //Generate a new MaterialButton, but with the template markup
            MaterialButton timerButton = CloneButton();


            timerButton.Text = "[" + timerIdCounter + "] " + tmrItem.TimerText;

            //Shorten text
            if (timerButton.Text.Length > 11)
            {
                timerButton.Text = timerButton.Text.Remove(10, timerButton.Text.Length - 10);
            }

            //Link every new button click to this event.
            timerButton.Click += TimerButton_Click;
            BLIO.Log("Button cloned & event listener linked");

            //Add the new button to top panel
            pnlRunningTimers.Controls.Add(timerButton);

            currentTimerItem = tmrItem;

            //Up the Id so that the next timer has a higher id
            timerIdCounter++;

            EnableButton(timerButton);

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.TimersCreated++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.TimersCreated++ . -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();
            BLIO.Log("Timer added!");
            TimerButton_Click(timerButton, null);
        }
Exemplo n.º 14
0
 private void tmrEnableDatabaseAccess_Tick(object sender, EventArgs e)
 {
     try
     {
         //If we could not connect to the database, the Data Access Layer will no longer try to connect to the database again.
         //This timer will re-enable this every 10 minutes, just in case the database is no longer available. Then, if it is available again, continue as usual.
         BLOnlineDatabase.ReAllowDatabaseAccess();
     }
     catch (Exception ex)
     {
         BLIO.Log("EnableDatabaseAccess FAILED. " + ex.GetType().ToString());
         BLIO.WriteError(ex, "Error in tmrEnableDatabaseAccess_Tick");
     }
 }
Exemplo n.º 15
0
 private void btnPlusHours_Click(object sender, EventArgs e)
 {
     try
     {
         if (pnlRunningTimers.Controls.Count > 1)
         {
             numHours.Text = "" + (Convert.ToInt32(numHours.Text) + 1);
         }
     }
     catch (Exception ex)
     {
         BLIO.Log("btnPlusHours FAILED. -> " + ex);
         BLIO.WriteError(ex, "Failed to add another hour to this timer");
     }
 }
Exemplo n.º 16
0
 private void tmrDumpLogTxtContents_Tick(object sender, EventArgs e)
 {
     try
     {
         if (BLIO.systemLog.Count != currentLogCount)
         {
             currentLogCount = BLIO.DumpLogTxt();
         }
     }
     catch (Exception ex)
     {
         BLIO.Log("DumpLogTxT FAILED. " + ex.GetType().ToString());
         BLIO.WriteError(ex, "Error in tmrDumpLogTxtContents_Tick");
     }
 }
Exemplo n.º 17
0
 private void tmrUpdateRemindMe_Tick(object sender, EventArgs e)
 {
     new Thread(() =>
     {
         try
         {
             updater.UpdateRemindMe();
         }
         catch (Exception ex)
         {
             BLIO.Log("UpdateRemindMe FAILED. " + ex.GetType().ToString());
             BLIO.WriteError(ex, "Error in tmrUpdateRemindMe_Tick");
         }
     }).Start();
 }
Exemplo n.º 18
0
        private bool RecoverReminders()
        {
            int             remindersRecovered = 0;
            List <Reminder> selectedReminders  = GetSelectedRemindersFromListview();

            if (selectedReminders.Count == 0)
            {
                return(false);
            }

            BLIO.Log("Attempting to recover " + selectedReminders.Count + " reminders ...");
            foreach (Reminder rem in selectedReminders)
            {
                if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it.
                {
                    rem.SoundFilePath = "";
                }

                if (rem.Deleted == 1 || rem.Deleted == 2) //The user wants to recover reminders, instead of importing new ones
                {
                    BLIO.Log("Reminder deleted: " + rem.Deleted + ". Setting deleted,enabled and hidden to 0");
                    rem.Deleted = 0;
                    rem.Enabled = 0; //Disable it so the user doesnt instantly get the reminder as an popup, as the reminder was in the past
                    rem.Hide    = 0; //Make sure it isn't hidden, since you cant easily re-enable hidden reminders, you first have to unhide all reminders first
                    BLReminder.EditReminder(rem);
                    BLIO.Log("Reminder with id " + rem.Id + " edited");
                }
                remindersRecovered++;
            }

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.RecoverCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.RecoverCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();

            BLIO.Log(remindersRecovered + " Reminders recovered");
            SetStatusTexts(remindersRecovered, selectedReminders.Count);
            return(true);
        }
Exemplo n.º 19
0
 private void tmrCheckForUpdates_Tick(object sender, EventArgs e)
 {
     try
     {
         if (showUpdateMessage && Directory.Exists(IOVariables.applicationFilesFolder + "\\old") && Directory.GetFiles(IOVariables.applicationFilesFolder + "\\old").Count() > 0)
         {
             MaterialMessageFormManager.MakeMessagePopup("RemindMe has updated!\r\nRestart RemindMe to load these changes directly.", 0);
             tmrCheckForUpdates.Stop();
         }
     }
     catch (Exception ex)
     {
         BLIO.Log("CheckForUpdates FAILED. " + ex.GetType().ToString());
         BLIO.WriteError(ex, "Error in tmrCheckForUpdates_Tick");
     }
 }
Exemplo n.º 20
0
        private bool ImportReminders()
        {
            int             remindersInserted = 0;
            List <Reminder> selectedReminders = GetSelectedRemindersFromListview();

            if (selectedReminders.Count == 0)
            {
                return(false);
            }



            if (remindersFromRemindMeFile != null)
            {
                BLIO.Log("Attempting to import " + selectedReminders.Count + " reminders ...");
                foreach (Reminder rem in selectedReminders)
                {
                    if (!File.Exists(rem.SoundFilePath)) //when you import reminders on another device, the path to the file might not exist. remove it.
                    {
                        rem.SoundFilePath = "";
                    }


                    BLReminder.PushReminderToDatabase(rem);
                    BLIO.Log("Pushed reminder with id " + rem.Id + " to the database");
                    remindersInserted++;
                }

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.ImportCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ UCImportexport.cs . -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                }).Start();

                BLIO.Log(remindersInserted + " Reminders inserted");
            }
            SetStatusTexts(remindersInserted, selectedReminders.Count);
            return(true);
        }
Exemplo n.º 21
0
        private void tmrPingActivity_Tick(object sender, EventArgs e)
        {
            try
            {
                if (BLIO.LastLogMessage != null && !BLIO.LastLogMessage.Contains("Updating user"))
                {
                    BLIO.Log("Pinging online status");
                }

                //Update LastOnline
                BLOnlineDatabase.InsertOrUpdateUser(BLLocalDatabase.Setting.Settings.UniqueString);
            }
            catch (Exception ex)
            {
                BLIO.Log("PingActivity FAILED. " + ex.GetType().ToString());
                BLIO.WriteError(ex, "Error in tmrPingActivity_Tick");
            }
        }
Exemplo n.º 22
0
        private void Cleanup()
        {
            //RemindMe loaded, if an old system log/temp reminders still exists, delete it
            string oldSystemLog     = System.IO.Path.GetTempPath() + "SystemLog.txt";
            string oldTempReminders = System.IO.Path.GetTempPath() + "Exported Reminders.remindme";

            try
            {
                if (File.Exists(oldSystemLog))
                {
                    File.Delete(oldSystemLog);
                }
                if (File.Exists(oldTempReminders))
                {
                    File.Delete(oldTempReminders);
                }
            }
            catch (IOException ex) { BLIO.WriteError(ex, "Error in Cleanup()"); }
        }
Exemplo n.º 23
0
        private void btnPostpone_Click(object sender, EventArgs e)
        {
            BLIO.Log("RemindMeMessageForm option clicked: Postpone (" + theReminder.Id + ")");
            isDialog = true;
            int minutes = MaterialRemindMePrompt.ShowMinutes("Select your postpone time", "(in minutes or in xhxxm format (1h20m) )");

            if (minutes <= 0)
            {
                BLIO.Log("Postponing reminder with " + minutes + " minutes DENIED.");
                return;
            }

            if (theReminder.PostponeDate == null)//No postpone yet, create it
            {
                theReminder.PostponeDate = Convert.ToDateTime(theReminder.Date.Split(',')[0]).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(theReminder.Date.Split(',')[0]).AddMinutes(minutes).ToShortTimeString();
            }
            else//Already a postponedate, add the time to that date
            {
                theReminder.PostponeDate = Convert.ToDateTime(theReminder.PostponeDate).AddMinutes(minutes).ToShortDateString() + " " + Convert.ToDateTime(theReminder.PostponeDate).AddMinutes(minutes).ToShortTimeString();
            }

            BLReminder.EditReminder(theReminder);//Push changes

            MUCReminders.Instance.UpdateCurrentPage();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.PostponeCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.PostponeCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();

            this.Close();
            this.Dispose();
        }
Exemplo n.º 24
0
        /*This was testing a custom color scheme
         * private void SetColorScheme()
         * {
         *
         *  string t = BLLocalDatabase.Setting.Settings.RemindMeTheme;
         *  RemindMeColorScheme colorTheme = BLLocalDatabase.Setting.GetColorTheme(BLLocalDatabase.Setting.Settings.RemindMeTheme);
         *  BLIO.Log("Setting RemindMe Color scheme \"" + BLLocalDatabase.Setting.Settings.RemindMeTheme + "\"");
         *  pnlSide.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomLeft.Split(',')[2]));
         *  pnlSide.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryBottomRight.Split(',')[2]));
         *  pnlSide.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopLeft.Split(',')[2]));
         *  pnlSide.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.PrimaryTopRight.Split(',')[2]));
         *
         *
         *  pnlMain.GradientBottomLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomLeft.Split(',')[2]));
         *  pnlMain.GradientBottomRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryBottomRight.Split(',')[2]));
         *  pnlMain.GradientTopLeft = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopLeft.Split(',')[2]));
         *  pnlMain.GradientTopRight = Color.FromArgb(Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[0]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[1]), Convert.ToInt16(colorTheme.SecondaryTopRight.Split(',')[2]));
         * }*/

        protected override void WndProc(ref Message m)
        {
            //This message will be sent when the RemindMeImporter imports reminders.
            if (m.Msg == WM_RELOAD_REMINDERS)
            {
                BLIO.Log("Reloading reminders after import from .remindme file");
                int currentReminderCount = BLReminder.GetReminders().Count;

                BLReminder.NotifyChange();

                if (MUCReminders.Instance != null)
                {
                    MUCReminders.Instance.UpdateCurrentPage();
                }

                if (!this.Visible) //don't make this message if RemindMe is visible, the user will see the changes if it is visible.
                {
                    MaterialMessageFormManager.MakeMessagePopup(BLReminder.GetReminders().Count - currentReminderCount + " Reminder(s) succesfully imported!", 3);
                    BLIO.Log("Created reminders succesfully imported message popup (WndProc)");
                }

                if ((BLReminder.GetReminders().Count - currentReminderCount) > 0)
                {
                    new Thread(() =>
                    {
                        //Log an entry to the database, for data!
                        try
                        {
                            BLOnlineDatabase.ImportCount++;
                        }
                        catch (ArgumentException ex)
                        {
                            BLIO.Log("Exception at BLOnlineDatabase.ImportCount++ Form1.cs . -> " + ex.Message);
                            BLIO.WriteError(ex, ex.Message, true);
                        }
                    }).Start();
                }
            }

            base.WndProc(ref m);
        }
Exemplo n.º 25
0
        private void hideReminderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Hide (" + rem.Id + ")");

            string message = "You can hide reminders with this option. The reminder will not be deleted, you just won't be able to see it"
                             + " in the list of reminders. This creates a sense of surprise.\r\n\r\nDo you wish to hide this reminder?";

            BLIO.Log("Attempting to hide reminder(s)");
            if (BLLocalDatabase.Setting.HideReminderOptionEnabled || MaterialRemindMeBox.Show(message, RemindMeBoxReason.YesNo, true) == DialogResult.Yes)
            {
                //Enable the hide flag here
                rem.Hide = 1;
                BLIO.Log("Marked reminder with id " + rem.Id + " as hidden");
                BLReminder.EditReminder(rem);
                this.Reminder = null;
                MUCReminders.Instance.UpdateCurrentPage();

                new Thread(() =>
                {
                    //Log an entry to the database, for data!
                    try
                    {
                        BLOnlineDatabase.HideCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.HideCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                    finally
                    {
                        GC.Collect();
                    }
                }).Start();
            }
            else
            {
                BLIO.Log("Attempting to hide reminder(s) failed.");
            }
        }
Exemplo n.º 26
0
        private void PreviewReminder()
        {
            if (rem == null)
            {
                BLIO.Log("Reminder in PreviewReminder() is null. Interesting... ;)");
                RemindMeMessageFormManager.MakeMessagePopup("Could not preview that reminder. It doesn't exist anymore!", 4, "Error");
                return;
            }

            BLIO.Log("Previewing reminder with id " + rem.Id);
            Reminder previewRem = CopyReminder(rem);

            previewRem.Id = -1; //give the >temporary< reminder an invalid id, so that the real reminder won't be altered
            Popup p = new Popup(previewRem);

            p.Show();
            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    try
                    {
                        BLOnlineDatabase.PreviewCount++;
                    }
                    catch (ArgumentException ex)
                    {
                        BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message);
                        BLIO.WriteError(ex, ex.Message, true);
                    }
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.PreviewCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Subtracts a second from the numeric updown every second, a minute if seconds = 0, an hour if minutes = 0
        /// </summary>
        private void TickDownTime()
        {
            try
            {
                if (Convert.ToInt32(numSeconds.Text) > 0)
                {
                    numSeconds.Text = "" + (Convert.ToInt32(numSeconds.Text) - 1);
                }
                else
                {
                    if (Convert.ToInt32(numMinutes.Text) > 0)
                    {
                        numMinutes.Text = "" + (Convert.ToInt32(numMinutes.Text) - 1);
                        numSeconds.Text = "59";
                    }
                    else
                    {
                        if (Convert.ToInt32(numHours.Text) > 0)
                        {
                            numHours.Text   = "" + (Convert.ToInt32(numHours.Text) - 1);
                            numMinutes.Text = "59";
                            numSeconds.Text = "59";
                        }//Else probably no time left.
                    }
                }


                if (currentTimerItem == null || (currentTimerItem.PopupDate - DateTime.Now).TotalSeconds <= 0)
                {
                    tmrCountdown.Stop();
                }
            }
            catch (Exception ex)
            {
                BLIO.Log("TickDownTime FAILED. -> " + ex);
                BLIO.WriteError(ex, "Failed to tick down time on this timer");
            }
        }
Exemplo n.º 28
0
        private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BLIO.Log("Toolstrip option clicked: Duplicate (" + rem.Id + ")");
            BLIO.Log("Setting up the duplicating process...");
            BLIO.Log("duplicating reminder with id " + rem.Id);
            BLReminder.PushReminderToDatabase(rem);
            BLIO.Log("reminder duplicated.");
            UCReminders.Instance.UpdateCurrentPage();

            new Thread(() =>
            {
                //Log an entry to the database, for data!
                try
                {
                    BLOnlineDatabase.DuplicateCount++;
                }
                catch (ArgumentException ex)
                {
                    BLIO.Log("Exception at BLOnlineDatabase.DuplicateCount++. -> " + ex.Message);
                    BLIO.WriteError(ex, ex.Message, true);
                }
            }).Start();
        }
Exemplo n.º 29
0
        //All uncaught exceptions will go here instead. We will replace the default windows popup with our own custom one and filter out what kind of exception is being thrown
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            if (e.Exception is ReminderException)
            {
                ReminderException theException = (ReminderException)e.Exception;
                BLIO.WriteError(e.Exception, "Error with this reminder (" + theException.Reminder.Name + ") !");
                ShowError(e.Exception, "Reminder error!", theException.Message);
                UCReminders.GetInstance().UpdateCurrentPage();
            }
            else if (e.Exception is DirectoryNotFoundException)
            {
                DirectoryNotFoundException theException = (DirectoryNotFoundException)e.Exception;
                BLIO.WriteError(theException, "Folder not found.");
                ShowError(e.Exception, e.Exception.GetType().ToString(), theException.Message);
            }

            else if (e.Exception is UnauthorizedAccessException)
            {
                UnauthorizedAccessException theException = (UnauthorizedAccessException)e.Exception;
                BLIO.WriteError(e.Exception, "Unauthorized!");
                ShowError(e.Exception, "Unauthorized!", "RemindMe is not authorized for this action.\r\nThis can be resolved by running RemindMe in administrator-mode.");
            }

            //Here we just filter out some type of exceptions and give different messages, at the bottom is the super Exception, which can be anything.
            else if (e.Exception is FileNotFoundException)
            {
                FileNotFoundException theException = (FileNotFoundException)e.Exception; //needs in instance to call .FileName
                BLIO.WriteError(theException, "Could not find the file located at \"" + theException.FileName);
                ShowError(e.Exception, "File not found.", "Could not find the file located at \"" + theException.FileName + "\"\r\nHave you moved,renamed or deleted the file?");
            }

            else if (e.Exception is System.Data.Entity.Core.EntityException)
            {
                BLIO.WriteError(e.Exception, "System.Data.Entity.Core.EntityException");
                ShowError(e.Exception, "System.Data.Entity.Core.EntityException", "There was a problem executing SQL!");
            }

            else if (e.Exception is ArgumentNullException)
            {
                BLIO.WriteError(e.Exception, "Null argument");
                ShowError(e.Exception, "Null argument", "Null argument exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is NullReferenceException)
            {
                BLIO.WriteError(e.Exception, "Null reference");
                ShowError(e.Exception, "Null reference", "Null reference exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is SQLiteException)
            {
                BLIO.WriteError(e.Exception, "SQLite Database exception");
                ShowError(e.Exception, "SQLite Database exception", "Remindme has encountered a database error!\r\nThis might or might not be on your end. It can be on your end if you modified the database file");
            }

            else if (e.Exception is PathTooLongException)
            {
                BLIO.WriteError(e.Exception, "The path to the file is too long.");
                ShowError(e.Exception, "File Path too long.", "The path to the file is too long!.");
            }

            else if (e.Exception is StackOverflowException)
            {
                BLIO.WriteError(e.Exception, "StackOverFlowException");
                ShowError(e.Exception, "StackOverFlowException", "RemindMe has encountered a stackoverflow! This is probably not your fault. Sorry!");
            }

            else if (e.Exception is OutOfMemoryException)
            {
                BLIO.WriteError(e.Exception, "Out of Memory");
                ShowError(e.Exception, "Out of Memory", "RemindMe is out of memory!");
            }
            else if (e.Exception is DbUpdateConcurrencyException)
            {
                BLIO.WriteError(e.Exception, "Database error.");
                ShowError(e.Exception, "Database error!", "Database error encountered!");
            }

            else if (e.Exception is Exception)
            {
                BLIO.WriteError(e.Exception, "Unknown exception in main.");
                ShowError(e.Exception, "Unknown", "Unknown exception in main.");
            }
        }
Exemplo n.º 30
0
        private void btnDeleteTimer_Click(object sender, EventArgs e)
        {
            try
            {
                BLIO.Log("Attempting to delete timer...");
                //First, see what button is pressed
                MaterialButton button = null;
                foreach (Control c in pnlRunningTimers.Controls)
                {
                    if (c is MaterialButton)
                    {
                        button = (MaterialButton)c;

                        if (button.Type == MaterialButton.MaterialButtonType.Contained)
                        {
                            break;
                        }
                    }
                }

                //Now that we have the selected button stored in the "button" variable, let's work with it
                //Get the id
                BLIO.Log("Getting the ID of the button..");
                int id = GetTimerButtonId(button);
                BLIO.Log("Done! -> " + id + ". Getting the associated TimerItem...");
                //Use the id to get the correct TimerItem from the "timers" collection, and delete it
                TimerItem toRemoveItem = timers.Where(t => t.ID == id).ToList()[0];
                BLIO.Log("Deleting TimerItem with popup date " + toRemoveItem.PopupDate + " ...");
                RemoveTimer(toRemoveItem);
                toRemoveItem.Dispose();
                BLIO.Log("Successfully removed & disposed the TimerItem");
                //Set the current timer to the first one in the list
                if (timers.Count > 0)
                {
                    currentTimerItem = timers[0];

                    BLIO.Log("Setting values of (UCTimer) numericupdowns");
                    TimeSpan time = TimeSpan.FromSeconds((double)currentTimerItem.SecondsRemaining);
                    numSeconds.Text = "" + time.Seconds;
                    numMinutes.Text = "" + time.Minutes;
                    numHours.Text   = "" + time.Hours;
                }
                else  //Nothing left
                {
                    numSeconds.Text          = "0";
                    numMinutes.Text          = "0";
                    numHours.Text            = "0";
                    btnPauseResumeTimer.Icon = Properties.Resources.pause_2x1;
                    currentTimerItem         = null;
                }

                //Set the pause/resume icon image depending on the current timer
                if (currentTimerItem == null || currentTimerItem.Disposed)
                {
                    return;
                }

                tmrCountdown.Enabled = currentTimerItem.Running;

                if (currentTimerItem.Running)
                {
                    btnPauseResumeTimer.Icon = Properties.Resources.pause_2x1;
                }
                else
                {
                    btnPauseResumeTimer.Icon = Properties.Resources.Play;
                }

                //Now make the current TimerItem button selected
                foreach (Control c in pnlRunningTimers.Controls)
                {
                    if (c is MaterialButton)
                    {
                        button = (MaterialButton)c;

                        if (GetTimerButtonId(button) == currentTimerItem.ID)
                        {
                            button.Type = MaterialButton.MaterialButtonType.Contained; //This is our button
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                BLIO.Log("Deleting timer FAILED. -> " + ex);
                BLIO.WriteError(ex, "Failed to delete this timer");
            }
        }