Example #1
0
        /// <remarks>
        /// This function retrieves the message ID from the row that is updated. It does this so as not to put the burden
        /// on the consuming client application to pass the message ID value. This should make it less confusing which identifier
        /// is which and therefore the service easier to consume
        /// </remarks>
        /// <summary>
        /// Mark a message as read in the Addressee table. Set the ReadDate property to current timestamp toggle the date on. Or,
        /// set the ReadDate property to a new DateTime() - year of 1 - to toggle the read date off
        /// </summary>
        /// <param name="addressee"></param>
        /// <returns></returns>
        public Addressee readMessage(Addressee addressee)
        {
            _cxn.beginTransaction();

            try
            {
                OracleQuery query       = buildReadMessageRequest(addressee);
                nonQuery    insertQuery = delegate() { return(query.Command.ExecuteNonQuery()); };
                if ((Int32)_cxn.query(query, insertQuery) != 1)
                {
                    throw new mdo.exceptions.MdoException("Unable to mark message as read");
                }

                Int32 msgId = ((Oracle.DataAccess.Types.OracleDecimal)query.Command.Parameters["outId"].Value).ToInt32();
                addressee.Oplock++;

                SecureMessageDao msgDao = new SecureMessageDao(_cxn);
                addressee.Message = msgDao.getSecureMessageBody(msgId);

                _cxn.commitTransaction();

                // TBD - any business rules around SECURE_MESSAGE.READ_RECEIPT and marking a message as read?
                return(addressee);
            }
            catch (Exception)
            {
                _cxn.rollbackTransaction();
                throw;
            }
        }
Example #2
0
        public Message deleteAttachmentFromMessage(Int32 messageId)
        {
            SecureMessageDao smDao = new SecureMessageDao(_cxn);
            Message          dbMsg = smDao.getMessage(messageId);

            if (dbMsg == null || dbMsg.Id <= 0 || !dbMsg.Attachment || dbMsg.AttachmentId <= 0)
            {
                throw new MdoException("Not a valid message ID");
            }

            try
            {
                _cxn.beginTransaction();

                OracleQuery request = buildUpdateMessageQuery(dbMsg, -1);
                nonQuery    qry     = delegate() { return((Int32)request.Command.ExecuteNonQuery()); };
                if ((Int32)_cxn.query(request, qry) != 1)
                {
                    throw new MdoException("Failed to update secure message record for attachment");
                }
                deleteAttachment(Convert.ToInt32(dbMsg.AttachmentId));
                dbMsg.AttachmentId = 0;
                dbMsg.Attachment   = false;
                dbMsg.Oplock++;
                _cxn.commitTransaction();
                return(dbMsg);
            }
            catch (Exception)
            {
                _cxn.rollbackTransaction();
                throw;
            }
        }
        internal MessageActivity createMessageActivity(MessageActivity activity)
        {
            OracleQuery query       = buildCreateMessageActivityQuery(activity);
            nonQuery    insertQuery = delegate() { return(query.Command.ExecuteNonQuery()); };

            _cxn.query(query, insertQuery);
            activity.Id = ((Oracle.DataAccess.Types.OracleDecimal)query.Command.Parameters["outId"].Value).ToInt32();
            return(activity);
        }
Example #4
0
        internal Addressee createAddressee(Addressee addressee, Int32 messageId)
        {
            OracleQuery query       = buildCreateAddresseeQuery(addressee, messageId);
            nonQuery    insertQuery = delegate() { return(query.Command.ExecuteNonQuery()); };

            _cxn.query(query, insertQuery);
            addressee.Id = ((Oracle.DataAccess.Types.OracleDecimal)query.Command.Parameters["outId"].Value).ToInt32();
            return(addressee);
        }
Example #5
0
        public void deleteAttachment(Int32 attachmentId)
        {
            OracleQuery request = buildDeleteAttachmentQuery(attachmentId);
            nonQuery    qry     = delegate() { return((Int32)request.Command.ExecuteNonQuery()); };

            if ((Int32)_cxn.query(request, qry) != 1)
            {
                throw new MdoException("Unable to delete message attachment");
            }
        }
Example #6
0
        internal void deleteAddressee(Int32 addresseeId)
        {
            OracleQuery request      = buildDeleteAddresseeQuery(addresseeId);
            nonQuery    qry          = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       rowsAffected = (Int32)_cxn.query(request, qry);

            if (rowsAffected != 1)
            {
                throw new MdoException("Unable to delete addressee");
            }
        }
Example #7
0
        public void deleteFolder(Int32 folderId)
        {
            OracleQuery request  = buildDeleteFolderQuery(folderId);
            nonQuery    qry      = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       response = (Int32)_cxn.query(request, qry);

            if (response != 1)
            {
                throw new MdoException("Unable to delete folder");
            }
        }
Example #8
0
        public domain.sm.MessageAttachment updateAttachment(MessageAttachment attachment)
        {
            OracleQuery request = buildUpdateAttachmentQuery(attachment);
            nonQuery    qry     = delegate() { return((Int32)request.Command.ExecuteNonQuery()); };

            if ((Int32)_cxn.query(request, qry) != 1)
            {
                throw new MdoException("Unable to update message attachment");
            }
            attachment.Oplock++;
            return(attachment);
        }
Example #9
0
        internal Addressee moveMessage(Addressee addressee)
        {
            OracleQuery request      = buildMoveMessageQuery(addressee);
            nonQuery    qry          = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       rowsAffected = (Int32)_cxn.query(request, qry);

            if (rowsAffected != 1)
            {
                throw new MdoException("Failed to move message");
            }
            addressee.Oplock++;
            return(addressee);
        }
Example #10
0
        public domain.sm.Folder updateFolder(domain.sm.Folder folder)
        {
            OracleQuery request  = buildUpdateFolderQuery(folder);
            nonQuery    qry      = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       response = (Int32)_cxn.query(request, qry);

            if (response != 1)
            {
                throw new MdoException("Unable to update folder");
            }
            folder.Oplock++;
            return(folder);
        }
Example #11
0
        public domain.sm.Folder createFolder(domain.sm.Folder folder)
        {
            OracleQuery request  = buildCreateFolderQuery(folder);
            nonQuery    qry      = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       response = (Int32)_cxn.query(request, qry);

            if (response != 1)
            {
                throw new MdoException("Unable to create folder");
            }
            folder.Id = ((Oracle.DataAccess.Types.OracleDecimal)request.Command.Parameters["outId"].Value).ToInt32();
            return(folder);
        }
Example #12
0
        internal Message updateMessageAttachmentFields(Message message, Int32 attachmentId)
        {
            OracleQuery request = buildUpdateMessageQuery(message, attachmentId);
            nonQuery    qry     = delegate() { return((Int32)request.Command.ExecuteNonQuery()); };

            if ((Int32)_cxn.query(request, qry) != 1)
            {
                throw new MdoException("Failed to update secure message record for attachment");
            }
            message.Attachment   = true;
            message.AttachmentId = attachmentId;
            message.Oplock++;
            return(message);
        }
Example #13
0
        public Addressee updateAddressee(Addressee addressee)
        {
            OracleQuery request      = buildUpdateAddresseeQuery(addressee);
            nonQuery    qry          = delegate() { return(request.Command.ExecuteNonQuery()); };
            Int32       rowsAffected = (Int32)_cxn.query(request, qry);

            if (rowsAffected != 1)
            {
                throw new MdoException("Unable to update addressee");
            }

            addressee.Oplock++;
            return(addressee);
        }
Example #14
0
        public domain.sm.MessageAttachment createAttachment(string attachmentName, byte[] attachment, string mimeType)
        {
            OracleQuery request = buildCreateAttachmentQuery(attachmentName, attachment, mimeType);
            nonQuery    qry     = delegate() { return((Int32)request.Command.ExecuteNonQuery()); };

            if ((Int32)_cxn.query(request, qry) != 1)
            {
                throw new MdoException("Unable to insert new message attachment");
            }
            MessageAttachment result = new MessageAttachment()
            {
                AttachmentName = attachmentName, MimeType = mimeType
            };

            result.Id = ((Oracle.DataAccess.Types.OracleDecimal)request.Command.Parameters["outId"].Value).ToInt32();
            return(result);
        }
Example #15
0
        /// <remarks>
        /// This function retrieves the message ID from the row that is updated. It does this so as not to put the burden
        /// on the consuming client application to pass the message ID value. This should make it less confusing which identifier
        /// is which and therefore the service easier to consume
        /// </remarks>
        /// <summary>
        /// Mark a message as read in the Addressee table. Set the ReadDate property to current timestamp toggle the date on. Or,
        /// set the ReadDate property to a new DateTime() - year of 1 - to toggle the read date off
        /// </summary>
        /// <param name="addressee"></param>
        /// <returns></returns>
        public Addressee readMessage(Addressee addressee)
        {
            _cxn.beginTransaction();

            try
            {
                Addressee original = getAddressee(addressee.Id);

                OracleQuery query       = buildReadMessageRequest(addressee);
                nonQuery    insertQuery = delegate() { return(query.Command.ExecuteNonQuery()); };
                if ((Int32)_cxn.query(query, insertQuery) != 1)
                {
                    throw new mdo.exceptions.MdoException("Unable to mark message as read");
                }

                Int32 msgId = ((Oracle.DataAccess.Types.OracleDecimal)query.Command.Parameters["outId"].Value).ToInt32();
                addressee.Oplock++;

                new MessageActivityDao(_cxn).createMessageActivity(
                    new MessageActivity()
                {
                    Action        = domain.sm.enums.ActivityEnum.MDWS_MESSAGE_READ,
                    Detail        = "MOBILE_APPS_ENTRY^MessageRead",
                    MessageId     = msgId,
                    PerformerType = domain.sm.enums.UserTypeEnum.PATIENT,
                    UserId        = original.Owner.Id
                });

                SecureMessageDao msgDao = new SecureMessageDao(_cxn);
                addressee.Message = msgDao.getSecureMessageBody(msgId);

                _cxn.commitTransaction();

                // TBD - any business rules around SECURE_MESSAGE.READ_RECEIPT and marking a message as read?
                return(addressee);
            }
            catch (Exception)
            {
                _cxn.rollbackTransaction();
                throw;
            }
        }
Example #16
0
        internal bool updateLastEmailNotification(domain.sm.User user)
        {
            // this function should attempt to update the user's last notification date and return true if successful
            // be sure to use the OPLOCK!!!
            try
            {
                OracleQuery query        = buildUpdateLastEmailNotificationQuery(user);
                nonQuery    update       = delegate() { return(query.Command.ExecuteNonQuery()); };
                Int32       rowsAffected = (Int32)_cxn.query(query, update);

                if (rowsAffected != 1)
                {
                    return(false);
                }
                user.Oplock++;
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }