Inheritance: BaseSmTO
Example #1
0
        public ThreadTO(gov.va.medora.mdo.domain.sm.Thread thread)
        {
            if (thread == null)
            {
                return;
            }

            id = thread.Id;
            oplock = thread.Oplock;
            mailGroup = new TriageGroupTO(thread.MailGroup);
            subject = thread.Subject;
            messageCategory = (Int32)thread.MessageCategoryType;

            if (thread.Annotations != null)
            {
                annotations = new AnnotationTO[thread.Annotations.Count];
                for (int i = 0; i < thread.Annotations.Count; i++)
                {
                    annotations[i] = new AnnotationTO(thread.Annotations[i]);
                }
            }
            if (thread.Messages != null)
            {
                messages = new MessageTO[thread.Messages.Count];
                for (int i = 0; i < thread.Messages.Count; i++)
                {
                    messages[i] = new MessageTO(thread.Messages[i]);
                }
            }
        }
Example #2
0
        public ThreadTO(gov.va.medora.mdo.domain.sm.Thread thread)
        {
            if (thread == null)
            {
                return;
            }

            id              = thread.Id;
            oplock          = thread.Oplock;
            mailGroup       = new TriageGroupTO(thread.MailGroup);
            subject         = thread.Subject;
            messageCategory = (Int32)thread.MessageCategoryType;

            if (thread.Annotations != null)
            {
                annotations = new AnnotationTO[thread.Annotations.Count];
                for (int i = 0; i < thread.Annotations.Count; i++)
                {
                    annotations[i] = new AnnotationTO(thread.Annotations[i]);
                }
            }
            if (thread.Messages != null)
            {
                messages = new MessageTO[thread.Messages.Count];
                for (int i = 0; i < thread.Messages.Count; i++)
                {
                    messages[i] = new MessageTO(thread.Messages[i]);
                }
            }
        }
Example #3
0
        public MessageTO sendReplyMessage(string pwd, Int32 replyingToMessageId, Int32 senderId, Int32 recipientId, string messageBody)
        {
            MessageTO result = new MessageTO();

            if (replyingToMessageId <= 0)
            {
                result.fault = new FaultTO("Missing reply message ID");
            }
            else if (senderId <= 0)
            {
                result.fault = new FaultTO("Missing sender ID");
            }
            //else if (recipientId <= 0)
            //{
            //    result.fault = new FaultTO("Missing recipient ID");
            //}
            else if (String.IsNullOrEmpty(messageBody))
            {
                result.fault = new FaultTO("Must supply a message body");
            }

            if (result.fault != null)
            {
                return result;
            }

            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    SecureMessageDao dao = new SecureMessageDao(cxn);
                    Message replyingTo = dao.getMessage(replyingToMessageId);
                    if (replyingTo == null || replyingTo.Id <= 0)
                    {
                        throw new Exception("No message found for that ID");
                    }

                    Message newReply = new Message()
                    {
                        SentDate = DateTime.Now,
                        SenderId = senderId,
                        RecipientId = recipientId,
                        Body = messageBody,
                        Checksum = StringUtils.getMD5Hash(messageBody),
                        MessageThread = replyingTo.MessageThread
                    };

                    result = new MessageTO(dao.sendReply(replyingTo, newReply));
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Example #4
0
        public dto.sm.MessageTO deleteAttachment(string pwd, Int32 messageId)
        {
            MessageTO result = new MessageTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (messageId <= 0)
            {
                result.fault = new FaultTO("Invalid message ID");
            }

            if (result.fault != null)
            {
                return result;
            }
            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    AttachmentDao dao = new AttachmentDao(cxn);
                    Message dbMsg = dao.deleteAttachmentFromMessage(messageId);
                    result = new MessageTO(dbMsg);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Example #5
0
        public MessageTO sendDraft(string pwd, Int32 messageId, Int32 messageOplock)
        {
            MessageTO result = new MessageTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (messageId <= 0)
            {
                result.fault = new FaultTO("Must supply a valid message ID");
            }

            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    SecureMessageDao dao = new SecureMessageDao(cxn);
                    gov.va.medora.mdo.domain.sm.Message msg = new Message() { Id = messageId, Oplock = messageOplock };
                    result = new MessageTO(dao.sendDraft(msg));
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Example #6
0
        public ThreadTO saveDraft(string pwd, Int32 replyingToMessageId, string threadSubject, Int32 messageCategory, 
            Int32 messageId, Int32 senderId, Int32 recipientId, string messageBody, Int32 messageOplock, Int32 threadOplock)
        {
            ThreadTO result = new ThreadTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (messageCategory > 0 && !Enum.IsDefined(typeof(gov.va.medora.mdo.domain.sm.enums.MessageCategoryTypeEnum), messageCategory))
            {
                result.fault = new FaultTO("Invalid message category");
            }
            else if (String.IsNullOrEmpty(messageBody))
            {
                result.fault = new FaultTO("Missing message body");
            }
            else if (messageId > 0 && messageOplock < 0)
            {
                result.fault = new FaultTO("Invalid message ID/message oplock");
            }
            else if (senderId <= 0 || recipientId <= 0)
            {
                result.fault = new FaultTO("Invalid sender/recipient");
            }
            if (result.fault != null)
            {
                return result;
            }

            try
            {
                Message message = new Message()
                {
                    Body = messageBody,
                    Checksum = StringUtils.getMD5Hash(messageBody),
                    Id = messageId,
                    MessageThread = new Thread(),
                    RecipientId = recipientId,
                    SenderId = senderId,
                    Oplock = messageOplock
                };
                message.MessageThread.Subject = threadSubject;
                if (Enum.IsDefined(typeof(mdo.domain.sm.enums.MessageCategoryTypeEnum), messageCategory))
                {
                    message.MessageThread.MessageCategoryType = (mdo.domain.sm.enums.MessageCategoryTypeEnum)messageCategory;
                }
                message.MessageThread.Oplock = threadOplock;

                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    SecureMessageDao dao = new SecureMessageDao(cxn);

                    if (replyingToMessageId > 0)
                    {
                        Message replyingToMsg = dao.getMessage(replyingToMessageId);
                        if (replyingToMsg == null || replyingToMsg.Id <= 0 || replyingToMsg.MessageThread == null || replyingToMsg.MessageThread.Id <= 0)
                        {
                            throw new Exception("Invalid reply to message ID");
                        }
                        message.MessageThread.Id = replyingToMsg.MessageThread.Id;
                    }

                    gov.va.medora.mdo.domain.sm.Message savedDraft = dao.saveDraft(message);
                    MessageTO msg = new MessageTO(savedDraft);
                    result = new ThreadTO(savedDraft.MessageThread);
                    result.messages = new MessageTO[] { msg };
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Example #7
0
        public dto.sm.MessageTO readMessage(string pwd, Int32 addresseeId, Int32 addresseeOplock)
        {
            MessageTO result = new MessageTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing appPwd");
            }
            else if (addresseeId <= 0)
            {
                result.fault = new FaultTO("Must supply addressee ID");
            }
            if (result.fault != null)
            {
                return result;
            }

            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    AddresseeDao dao = new AddresseeDao(cxn);
                    gov.va.medora.mdo.domain.sm.Addressee addressee = dao.readMessage(new Addressee() { Id = addresseeId, Oplock = addresseeOplock });
                    MessageTO message = new MessageTO(addressee.Message);
                    message.addressees = new AddresseeTO[1] { new AddresseeTO(addressee) };
                    result = message;
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Example #8
0
        public MessageTO moveMessage(string pwd, Int32 userId, Int32 messageId, Int32 newFolderId)
        {
            MessageTO result = new MessageTO();

            try
            {
                Message message = new Message();
                message.Id = messageId;
                message.Addressees = new List<Addressee>() { new Addressee() { FolderId = newFolderId, Owner = new User() { Id = userId } } };
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    AddresseeDao dao = new AddresseeDao(cxn);
                    message.Addressees[0] = dao.moveMessage(new Message() { Id = messageId }, new User() { Id = userId }, new Folder() { Id = newFolderId });
                    result = new MessageTO(message);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            return result;
        }
Example #9
0
        public MessageTO deleteDraft(string pwd, Int32 messageId)
        {
            MessageTO result = new MessageTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (messageId <= 0)
            {
                result.fault = new FaultTO("Missing message ID");
            }

            if (result.fault != null)
            {
                return result;
            }

            try
            {
                Message message = new Message() { Id = messageId };
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource() { ConnectionString = pwd }))
                {
                    SecureMessageDao dao = new SecureMessageDao(cxn);
                    dao.deleteDraft(message);
                }
                message.Addressees = null;
                message.MessageThread = null;
                message.Body = "OK";
                message.Id = -1;
                result = new MessageTO(message);
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }