示例#1
0
        private bool Exportreminders()
        {
            if (GetSelectedRemindersFromListview().Count > 0)
            {
                string selectedPath = FSManager.Folders.GetSelectedFolderPath();

                if (selectedPath != null)
                {
                    BLIO.Log("User selected a valid path");

                    Exception possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), selectedPath);
                    if (possibleException == null)
                    {
                        BLIO.Log("No problems encountered (exception null)");
                        SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count);
                    }
                    else if (possibleException is UnauthorizedAccessException)
                    {
                        BLIO.Log("Problem encountered: Unauthorized");
                        if (RemindMeBox.Show("Could not save reminders to \"" + selectedPath + "\"\r\nDo you wish to place them on your desktop instead?", RemindMeBoxReason.YesNo) == DialogResult.Yes)
                        {
                            BLIO.Log("Trying to save to desktop instead...");
                            possibleException = BLReminder.ExportReminders(GetSelectedRemindersFromListview(), Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                            if (possibleException != null)
                            {//Did saving to desktop go wrong, too?? just show a message
                                BLIO.Log("Trying to save to desktop didnt work either");
                                RemindMeBox.Show("Something went wrong. Could not save the reminders to your desktop.", RemindMeBoxReason.OK);
                                return(false);
                            }
                            else
                            {//Saving to desktop did not throw an exception
                                BLIO.Log("Saved to desktop");
                                SetStatusTexts(GetSelectedRemindersFromListview().Count, BLReminder.GetReminders().Count);
                            }
                        }
                    }
                    else
                    {
                        RemindMeMessageFormManager.MakeMessagePopup("Backup failed.", 6);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                RemindMeMessageFormManager.MakeMessagePopup("Please select one or more reminder(s)", 6);
            }
            return(true);
        }