public void TestFixtureSetup()
 {
     _src = new DataSource()
     {
         ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=mhv.va.gov)(PORT=1))(CONNECT_DATA=(SERVICE_NAME=sid)));User ID=user;Password=password;"
     };
     _cxn = new MdoOracleConnection(_src);
 }
Exemple #2
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);
        }
Exemple #3
0
        public dto.sm.AttachmentTO updateAttachment(string pwd, Int32 attachmentId, Int32 attachmentOplock, string fileName, string mimeType, byte[] attachment)
        {
            AttachmentTO result = new AttachmentTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (attachmentId <= 0)
            {
                result.fault = new FaultTO("Invalid attachment ID");
            }
            else if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(mimeType) || attachment == null || attachment.Length <= 0)
            {
                result.fault = new FaultTO("Must supply all attachment properties");
            }

            if (result.fault != null)
            {
                return(result);
            }
            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource()
                {
                    ConnectionString = pwd
                }))
                {
                    AttachmentDao     dao = new AttachmentDao(cxn);
                    MessageAttachment updatedAttachment = dao.updateAttachment(new MessageAttachment()
                    {
                        Id = attachmentId, Oplock = attachmentOplock, AttachmentName = fileName, MimeType = mimeType, SmFile = attachment
                    });
                    updatedAttachment.SmFile = null; // don't pass back - client already has image so save the bandwidth
                    result = new AttachmentTO(updatedAttachment);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
0
        public SecureMessageThreadsTO getMessages(string pwd, Int32 userId, Int32 folderId, Int32 pageStart, Int32 pageSize)
        {
            SecureMessageThreadsTO result = new SecureMessageThreadsTO(null);

            if (userId <= 0)
            {
                result.fault = new dto.FaultTO("Must supply a user ID");
            }
            if (pageSize <= 0 || pageSize > 250)
            {
                result.fault = new FaultTO("Invalid pageSize argument");
            }
            if (result.fault != null)
            {
                return(result);
            }

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

                    if (folderId > 0 || Enum.IsDefined(typeof(gov.va.medora.mdo.domain.sm.enums.SystemFolderEnum), folderId))
                    {
                        return(new SecureMessageThreadsTO(dao.getMessagesInFolder(userId, folderId, pageStart, pageSize)));
                    }
                    else
                    {
                        return(new SecureMessageThreadsTO(dao.getSecureMessages(userId, pageStart, pageSize)));
                    }
                }
            }
            catch (Exception exc)
            {
                result.fault = new dto.FaultTO(exc);
            }

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

            pwd = getConnectionString(pwd);

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("No connection string specified or configured");
            }
            else if (messageId <= 0)
            {
                result.fault = new FaultTO("Must supply a valid message ID");
            }

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

            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);
        }
Exemple #8
0
        public TaggedText getMOSReport(string appPwd, string EDIPI)
        {
            TaggedText result = new TaggedText();

            if (String.IsNullOrEmpty(appPwd))
            {
                result.fault = new FaultTO("Missing appPwd");
            }
            else if (String.IsNullOrEmpty(EDIPI))
            {
                result.fault = new FaultTO("Missing EDIPI");
            }

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

            try
            {
                AbstractConnection cxn = new MdoOracleConnection(new DataSource()
                {
                    ConnectionString = mySession.MdwsConfiguration.MosConnectionString
                });
                PatientApi api = new PatientApi();
                Patient    p   = new Patient()
                {
                    EDIPI = EDIPI
                };
                TextReport rpt = api.getMOSReport(cxn, p);
                result.text = rpt.Text;
                result.tag  = "VADIR";
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }
            return(result);
        }
        public dto.sm.AttachmentTO getAttachment(string pwd, Int32 attachmentId)
        {
            AttachmentTO result = new AttachmentTO();

            pwd = getConnectionString(pwd);

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("No connection string specified or configured");
            }
            else if (attachmentId <= 0)
            {
                result.fault = new FaultTO("Invalid attachment ID");
            }

            if (result.fault != null)
            {
                return(result);
            }
            try
            {
                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource()
                {
                    ConnectionString = pwd
                }))
                {
                    AttachmentDao     dao        = new AttachmentDao(cxn);
                    MessageAttachment attachment = dao.getAttachment(attachmentId);
                    result = new AttachmentTO(attachment);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

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

            pwd = getConnectionString(pwd);

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("No connection string specified or configured");
            }
            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);
        }
 public VbacorpClaimsDao(AbstractConnection cxn)
 {
     myCxn = (MdoOracleConnection)cxn;
 }
Exemple #12
0
 public UserProfileDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #13
0
 public SecureMessageDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #14
0
        public SmUserTO getUser(string pwd, string userId, string idType)
        {
            SmUserTO result = new SmUserTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new dto.FaultTO("Must supply password");
            }
            else if (String.IsNullOrEmpty(userId))
            {
                result.fault = new dto.FaultTO("Must supply user ID");
            }
            else if (String.IsNullOrEmpty(idType) && !StringUtils.isNumeric(userId))
            {
                result.fault = new FaultTO("Invalid user ID");
            }
            else if (!String.IsNullOrEmpty(idType) && !String.Equals(idType, "SMID", StringComparison.CurrentCultureIgnoreCase) &&
                     !String.Equals(idType, "ICN", StringComparison.CurrentCultureIgnoreCase) && !String.Equals(idType, "SSN", StringComparison.CurrentCultureIgnoreCase))
            {
                result.fault = new FaultTO("Invalid id type", "Use one of the following: SMID, ICN, SSN");
            }

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

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

                    if (String.IsNullOrEmpty(idType) || String.Equals(idType, "SMID", StringComparison.CurrentCultureIgnoreCase))
                    {
                        result = new SmUserTO(dao.getUserDetail(Convert.ToInt32(userId)));
                    }
                    else if (String.Equals(idType, "ICN", StringComparison.CurrentCultureIgnoreCase))
                    {
                        result = new SmUserTO(dao.getUserDetail(dao.getUserByIcn(userId).Id));
                    }
                    else if (String.Equals(idType, "SSN", StringComparison.CurrentCultureIgnoreCase))
                    {
                        // TODO - write get user by SSN function
                        result.fault = new FaultTO("SSN lookup not currently enabled. Please try again later");
                        //result = new SmUserTO(dao.getUserDetail(dao.getUserBySsn(userId)));
                    }
                    else
                    {
                        throw new Exception("Invalid user type"); // should never get here with fault handling section but... just in case
                    }
                }
            }
            catch (Exception exc)
            {
                result.fault = new dto.FaultTO(exc);
            }

            return(result);
        }
        public MessageTO sendReplyMessage(string pwd, Int32 replyingToMessageId, Int32 senderId, Int32 recipientId, string messageBody)
        {
            MessageTO result = new MessageTO();

            pwd = getConnectionString(pwd);

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("No connection string specified or configured");
            }
            else 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);
        }
Exemple #16
0
        public ThreadTO updateMessageThread(string pwd, Int32 threadId, string threadSubject, Int32 messageCategory, Int32 threadOplock)
        {
            ThreadTO result = new ThreadTO();

            if (threadId <= 0)
            {
                result.fault = new FaultTO("Must specify a message thread");
            }
            else if (String.IsNullOrEmpty(threadSubject))
            {
                result.fault = new FaultTO("Missing thread subject");
            }
            else if (messageCategory > 0 && !Enum.IsDefined(typeof(gov.va.medora.mdo.domain.sm.enums.MessageCategoryTypeEnum), messageCategory))
            {
                result.fault = new FaultTO("That message category is not defined");
            }

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

            try
            {
                gov.va.medora.mdo.domain.sm.Thread thread = new gov.va.medora.mdo.domain.sm.Thread()
                {
                    Id                  = threadId,
                    Subject             = threadSubject,
                    MessageCategoryType = (gov.va.medora.mdo.domain.sm.enums.MessageCategoryTypeEnum)messageCategory,
                    Oplock              = threadOplock
                };

                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource()
                {
                    ConnectionString = pwd
                }))
                {
                    SecureMessageDao dao = new SecureMessageDao(cxn);
                    gov.va.medora.mdo.domain.sm.Thread dbThread = dao.getMessagesFromThread(threadId);

                    // we don't want to permit apps to change the mail group this way so just keep what's in the database which gets set through the proper channels
                    thread.MailGroup = dbThread.MailGroup;

                    if (dbThread == null || dbThread.Id <= 0 || dbThread.Messages == null || dbThread.Messages.Count <= 0)
                    {
                        throw new Exception("That thread does not exist in the database or appears malformed");
                    }

                    // make sure the thread hasn't been marked as completed
                    foreach (Message m in dbThread.Messages)
                    {
                        if (m.CompletedDate.Year > 1900)
                        {
                            throw new Exception("That message thread has already been completed. Unable to edit.");
                        }
                    }

                    result = new ThreadTO(dao.updateThread(thread));
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }
Exemple #17
0
        public ThreadTO sendNewMessage(string pwd, string threadSubject, Int32 groupId, Int32 messageCategory, Int32 senderId, Int32 recipientId, string messageBody)
        {
            ThreadTO result = new ThreadTO();

            if (String.IsNullOrEmpty(threadSubject))
            {
                result.fault = new FaultTO("Missing thread subject");
            }
            else if (messageCategory >= 0 && !Enum.IsDefined(typeof(gov.va.medora.mdo.domain.sm.enums.MessageCategoryTypeEnum), messageCategory))
            {
                result.fault = new FaultTO("That message category is not defined");
            }
            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
            {
                gov.va.medora.mdo.domain.sm.Thread thread = new Thread()
                {
                    MailGroup = new TriageGroup()
                    {
                        Id = groupId
                    },
                    MessageCategoryType = (mdo.domain.sm.enums.MessageCategoryTypeEnum)messageCategory,
                    Subject             = threadSubject
                };
                gov.va.medora.mdo.domain.sm.Message message = new Message()
                {
                    Body          = messageBody,
                    Checksum      = StringUtils.getMD5Hash(messageBody),
                    MessageThread = thread,
                    RecipientId   = recipientId,
                    SenderId      = senderId,
                    SentDate      = DateTime.Now
                };

                using (MdoOracleConnection cxn = new MdoOracleConnection(new mdo.DataSource()
                {
                    ConnectionString = pwd
                }))
                {
                    SecureMessageDao dao    = new SecureMessageDao(cxn);
                    Message          newMsg = dao.sendNewMessage(message);
                    result          = new ThreadTO(newMsg.MessageThread);
                    result.messages = new MessageTO[] { new MessageTO(newMsg) };
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }
Exemple #18
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);
        }
 public AttachmentDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #20
0
 public AttachmentDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #21
0
 public AddresseeDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #22
0
 public AddresseeDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
 public MessageActivityDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #24
0
 public VadirPatientDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #25
0
 public AdrClaimsDao(AbstractConnection cxn)
 {
     myCxn = (MdoOracleConnection)cxn;
 }
Exemple #26
0
 public SystemDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
Exemple #27
0
 public FolderDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }
 // this class should use it's own DB connection since the cxn passed in may be disposed when wrapped in a 'using(AbstractConnection)' block
 void setConnection(AbstractConnection cxn)
 {
     _cxn = new MdoOracleConnection(new DataSource() { ConnectionString = cxn.DataSource.ConnectionString });
 }
Exemple #29
0
 public UserDao(AbstractConnection cxn)
 {
     _cxn = (MdoOracleConnection)cxn;
 }