Ejemplo n.º 1
0
        public void GetFilesTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null)
            {
                // Get reminder for first file
                TrackedFile file     = files[0];
                Reminder    reminder = file.GetReminder();

                // Get the count for all the files that
                // have this reminder.
                int reminderCount = 0;

                foreach (var f in files)
                {
                    if (f.ReminderID == reminder.ReminderID)
                    {
                        reminderCount++;
                    }
                }

                // Call reminder GetFiles for this reminder to get the
                // list of files with this reminder.
                List <TrackedFile> reminderfileList = reminder.GetFiles();

                // Verify the counts are the same
                Assert.AreEqual(reminderCount, reminderfileList.Count);
            }
        }
 private void FillListView()
 {
     ReminderlistView.Items.Clear();
     try {
         List <TrackedFile> remFiles = myRem.GetFiles();
         if (remFiles == null)
         {
             return;                   // No files attached to reminder
         }
         foreach (var file in remFiles)
         {
             string[] fileDetails = new string[6];
             fileDetails[0] = file.Filename;
             fileDetails[1] = file.FileExtension;
             fileDetails[2] = file.FilePath;
             fileDetails[3] = file.FileSize.ToString();
             fileDetails[4] = file.ModifiedOn.ToString();
             fileDetails[5] = (file.TrackingDisabledOn > new DateTime()) ? "X" : "";
             ListViewItem row = new ListViewItem(fileDetails);
             row.Tag = file.FileID;
             ReminderlistView.Items.Add(row);
         }
     }
     catch (SqlException) {
         Messenger.ShowDbMsg();
     }
 }
Ejemplo n.º 3
0
        public void RemoveFilesTest()
        {
            List <TrackedFile> files = FileManagerDAL.GetFiles();

            if (files != null && files.Count >= 3)
            {
                // Get reminder for third file
                TrackedFile file = files[2];

                if (file.ReminderID != -999)
                {
                    Reminder reminder = file.GetReminder();


                    // Call reminder GetFiles for this reminder to get the
                    // list of files with this reminder.
                    List <TrackedFile> reminderfileList = reminder.GetFiles();

                    // Create an int list containing the third file id to remove the reminder.
                    List <int> removeList = new List <int>()
                    {
                        file.FileID
                    };

                    // Remove the reminder for the files in the remove list.
                    reminder.RemoveFiles(removeList);

                    // Get the list of files assigned the reminder that was removed from the third file.
                    List <TrackedFile> reminderfileListAfterRemove = reminder.GetFiles();

                    // Verify the after remove file count list matches the before remove file
                    // count list minus the number of files in the remove list.
                    Assert.AreEqual(reminderfileListAfterRemove.Count, reminderfileList.Count - removeList.Count);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnAddReminder_Click(object sender, EventArgs e)
        {
            if (filesToLink.Count < 1)
            {
                return;                        // Need at least one file to create reminder
            }
            // Validate fields
            DateTime dueDate = ReminderdateTimePicker.Value;

            if (dueDate < DateTime.Today)
            {
                Messenger.Show("Due date must be greater than or equal to today.", caption);
                return;
            }
            string reminderName = txtReminderName.Text.Trim();

            if (string.IsNullOrEmpty(reminderName))
            {
                Messenger.Show("Reminder name is required.", caption);
                return;
            }

            // Add reminder
            List <int> memberIDs = new List <int>();

            foreach (var file in filesToLink)
            {
                memberIDs.Add(file.FileID);
            }
            if (memberIDs.Count < 1)
            {
                return;                      // Just in case
            }
            string   reminderMemo = txtDescription.Text.Trim();
            Reminder newRem       = null;

            if (string.IsNullOrEmpty(reminderMemo))
            {
                newRem = ReminderManager.AddReminder(memberIDs, reminderName, dueDate);
            }
            else
            {
                newRem = ReminderManager.AddReminder(memberIDs, reminderName, dueDate, reminderMemo);
            }
            if (newRem == null)
            {
                Messenger.Show("Could not create reminder.\n\n" +
                               "Check that chosen files do not have existing, unresolved reminders.", caption);
                return;
            }

            // Log, notify and close
            var files  = newRem.GetFiles();
            int nFiles = (files == null) ? 0 : files.Count;

            LogReminderCreation(newRem.ReminderID, nFiles, newRem.Name);
            LogReminderJoined(newRem, files);
            Messenger.Show($"New reminder created for {nFiles} file(s).", caption);
            DialogResult = DialogResult.OK;
            Close();
        }