Exemple #1
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();
        }
Exemple #2
0
        private void UCReminders_DragDrop(object sender, DragEventArgs e)
        {
            object source = e.Data.GetData("DragSource");

            if (source != null && source.ToString() == "lvReminders")
            {
                if (RemindMeBox.Show("Do you want to copy the selected reminders?\n\nYou just dragged reminders and dropped them in RemindMe again.", RemindMeBoxReason.YesNo) == DialogResult.No)
                {
                    return;
                }
                //If the user said no, return; else just continue
            }
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            BLIO.Log("File(s) dropped into RemindMe! ( " + files.Length + " file(s) )");
            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");
                }
            }
            //finally, refresh the listview
            UpdateCurrentPage();
        }
Exemple #3
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            BLIO.Log("Import button pressed. Loading reminders into listview");
            remindersFromRemindMeFile.Clear();
            ToggleButton(sender);
            lvReminders.Items.Clear();

            string remindmeFile = FSManager.Files.GetSelectedFileWithPath("RemindMe backup file", "*.remindme");

            if (remindmeFile == null || remindmeFile == "")
            {//user pressed cancel
                btnImport.selected = false;
                return;
            }
            BLIO.Log("Valid .remindme file selected");

            try
            {
                List <object> toImportReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile).Cast <object>().ToList();


                if (toImportReminders != null)
                {
                    BLIO.Log(toImportReminders.Count - 1 + " reminders in this .remindme file");
                    transferType = ReminderTransferType.IMPORT;

                    foreach (object rem in toImportReminders)
                    {
                        if (rem.GetType() == typeof(Reminder))
                        {
                            BLFormLogic.AddReminderToListview(lvReminders, (Reminder)rem);
                            remindersFromRemindMeFile.Add((Reminder)rem);
                        }
                    }
                }
            }
            catch
            {
                RemindMeMessageFormManager.MakeMessagePopup("Error loading reminder(s)", 6);
            }
        }
        private void RemindMeImporter_Load(object sender, EventArgs e)
        {
            BLIO.Log("RemindmeImporter_load");
            this.MaximumSize = this.Size;


            if (!HasFileAccess(this.remindmeFile)) //Do not attempt to launch the importer form if we can't open the file
            {
                BLIO.Log("Error opening .remindme file, no rights");
                RemindMeBox.Show("Can not open this .remindme file from " + Path.GetDirectoryName(this.remindmeFile) + ". Insufficient rights.", RemindMeBoxReason.OK);
                this.Close();
            }
            else
            {
                try
                {
                    BLIO.Log("Deserializing reminders.....");
                    List <object> deSerializedReminders = BLReminder.DeserializeRemindersFromFile(remindmeFile);
                    BLIO.Log(deSerializedReminders.Count - 1 + " reminders deserialized!");
                    lblAmountOfReminders.Text = deSerializedReminders.Count - 1 + " Reminders"; //-1 because of country code
                    foreach (object rem in deSerializedReminders)
                    {
                        if (rem.GetType() == typeof(Reminder))
                        {
                            Reminder reminder = (Reminder)rem;
                            BLIO.Log(reminder.Name + " Loaded into RemindMeImporter from the .remindme file.");
                            remindersFromRemindMeFile.Add((Reminder)rem);
                        }
                        else
                        {
                            BLIO.Log("Language code" + languageCode + " read from the .remindme file!");
                            languageCode = rem.ToString(); //The language code stored in the .remindme file, "en-Us" for example
                        }
                    }

                    if (languageCode != "") //Don't need to do this when exporting.
                    {
                        BLIO.Log("Going through the reminder list once more....");
                        foreach (object rem in remindersFromRemindMeFile)
                        {
                            if (rem.GetType() == typeof(Reminder))
                            {
                                Reminder remm = (Reminder)rem;
                                //Fix the date if the .remindme file has a different time format than the current system
                                BLIO.Log("(" + remm.Name + ") Fixing the date to match the language code " + languageCode);
                                remm.Date = BLDateTime.ConvertDateTimeStringToCurrentCulture(remm.Date, languageCode);
                            }
                        }
                    }

                    if (remindersFromRemindMeFile != null)
                    {
                        BLIO.Log("Adding the reminders from the .remindme file to the listview....");
                        BLFormLogic.AddRemindersToListview(lvReminders, remindersFromRemindMeFile);
                        BLIO.Log("Done!");
                    }
                    else
                    {
                        BLIO.Log("Failed to load reminders.");
                        lblTitle.Text = "Failed to load reminders.";
                    }
                }
                catch (Exception ex)
                {
                    RemindMeBox.Show("Something has gone wrong loading reminders from this .remindme file.\r\nThe file might be corrupt", RemindMeBoxReason.OK);
                    BLIO.Log("Error loading reminders from .remindme file written to error log");
                    BLIO.WriteError(ex, "Error loading reminders from .remindme file");
                    Application.Exit();
                }
            }
            BLIO.Log("RemindmeImporter loaded !");
        }