Example #1
0
        /// <summary>
        /// Reloads the message from the persistence storage medium.
        /// </summary>
        /// <returns>true if this instance was reloaded successfully; otherwise, false.</returns>
        public bool Reload()
        {
            CmoMessage current = CmoProviders.DataProvider.GetCmoMessage(_candidateID, _id);

            if (current != null)
            {
                _attachments.Clear();
                foreach (byte id in current.Attachments.Keys)
                {
                    _attachments[id] = current.Attachments[id];
                }
                this.ArchiveDate       = current.ArchiveDate;
                this.Archiver          = current.Archiver;
                this.AuditReviewNumber = current.AuditReviewNumber;
                this.Body                         = current.Body;
                this.Category                     = current.Category;
                this.Creator                      = current.Creator;
                this.ElectionCycle                = current.ElectionCycle;
                this.FollowUpDate                 = current.FollowUpDate;
                this.FollowUpFlagger              = current.FollowUpFlagger;
                this.NeedsFollowUp                = current.NeedsFollowUp;
                this.OpenDate                     = current.OpenDate;
                this.Opener                       = current.Opener;
                this.OpenReceiptEmail             = current.OpenReceiptEmail;
                this.PostDate                     = current.PostDate;
                this.PostElectionAuditRequestType = current.PostElectionAuditRequestType;
                this.Title                        = current.Title;
                this.TollingEventNumber           = current.TollingEventNumber;
                this.TollingLetter                = current.TollingLetter;
                this.Version                      = current.Version;
                return(true);
            }
            return(false);
        }
Example #2
0
 /// <summary>
 /// Retrieves the full system file path to a CMO message's file attachments folder.
 /// </summary>
 /// <param name="message">The message to find.</param>
 /// <returns>The full system file path to the message's attachments folder.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
 internal string GetMessageFolderName(CmoMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message", "The message cannot be null.");
     }
     return(GetMessageFolderName(message.CandidateID, message.ID));
 }
Example #3
0
 /// <summary>
 /// Creates a new instance of the <see cref="CmoAttachmentStream"/> class.
 /// </summary>
 /// <param name="message">The source <see cref="CmoMessage"/> that the current <see cref="CmoAttachmentStream"/> is for.</param>
 /// <param name="data">The sequence of bytes that the current <see cref="CmoAttachmentStream"/> will encapsulate.</param>
 /// <exception cref="ArgumentNullException"><paramref name="message"/> is null.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="data"/> is null.</exception>
 public CmoAttachmentStream(CmoMessage message, byte[] data)
     : base(data, 0, data.Length, false, true)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message", "Source message cannot be null.");
     }
     //if (data == null)
     //    throw new ArgumentNullException("data", "Source data cannot be null.");
     _candidateID = message.CandidateID;
     _messageID   = message.ID;
 }
Example #4
0
        /// <summary>
        /// Locks down the attachments folder for a message to prevent any further modifications as a records-retention/integrity measure.
        /// </summary>
        /// <param name="message">The message to lock down.</param>
        internal void LockDown(CmoMessage message)
        {
            string path = GetMessageFolderName(message);

            if (Directory.Exists(path))
            {
                DirectorySecurity ds     = Directory.GetAccessControl(path);
                FileSystemRights  rights = FileSystemRights.Write | FileSystemRights.ChangePermissions | FileSystemRights.Delete | FileSystemRights.TakeOwnership | FileSystemRights.DeleteSubdirectoriesAndFiles | FileSystemRights.CreateDirectories | FileSystemRights.CreateFiles;
                ds = Directory.GetAccessControl(path);
                // needs two rules - first is for "This folder"
                ds.AddAccessRule(new FileSystemAccessRule("Everyone", rights, InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Deny));
                // second rule is for "Subfolders and files"
                ds.AddAccessRule(new FileSystemAccessRule("Everyone", rights, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Deny));
                Directory.SetAccessControl(path, ds);
            }
        }
Example #5
0
        /// <summary>
        /// Retrieves a message from the mailbox by unique message ID.
        /// </summary>
        /// <param name="uniqueID">The unique ID of the message to retrieve.</param>
        /// <returns>A <see cref="CmoMessage"/> representing the requested message if found; otherwise, null.</returns>
        /// <remarks>Retrieving the message will also mark it as "opened".</remarks>
        public CmoMessage OpenMessage(string uniqueID)
        {
            CmoMessage message = CmoMessage.GetMessage(uniqueID);

            if (message != null)
            {
                // BUGFIX #52: Fixed loophole where other campaign users can mark other campaigns' unread messages as "open", by adding a check to see if the candidate ID context matches before opening a message in a mailbox.
                if (!string.IsNullOrEmpty(this.Username) && message.IsPosted && _electionCycles.Contains(message.ElectionCycle) && string.Equals(message.CandidateID, _candidateID, StringComparison.InvariantCultureIgnoreCase))
                {
                    if (message.Open(this.Username))
                    {
                        return(message);
                    }
                }
            }
            return(null);
        }
Example #6
0
        /// <summary>
        /// Clears a message's follow-up flag.
        /// </summary>
        /// <param name="messageID">The ID of the message to unflag for follow-up.</param>
        /// <returns>true if the message's follow-up flag was cleared successfully; otherwise, false.</returns>
        public bool ClearFlag(int messageID)
        {
            CmoMessage m = CmoMessage.GetMessage(_candidateID, messageID);

            return(m != null?m.ClearFlag(this.Username) : false);
        }
Example #7
0
        /// <summary>
        /// Unarchives a message.
        /// </summary>
        /// <param name="messageID">The ID of the message to unarchive.</param>
        /// <returns>true if the message was unarchived successfully; otherwise, false.</returns>
        public bool Unarchive(int messageID)
        {
            CmoMessage m = CmoMessage.GetMessage(_candidateID, messageID);

            return(m != null?m.Unarchive(this.Username) : false);
        }