Exemple #1
0
        public dto.sm.AttachmentTO addAttachment(string pwd, Int32 messageId, Int32 messageOplock, string fileName, string mimeType, byte[] attachment)
        {
            AttachmentTO result = new AttachmentTO();

            if (String.IsNullOrEmpty(pwd))
            {
                result.fault = new FaultTO("Missing pwd");
            }
            else if (messageId <= 0)
            {
                result.fault = new FaultTO("Invalid message 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 newAttachment = dao.attachToMessage(
                        new MessageAttachment() { AttachmentName = fileName, MimeType = mimeType, SmFile = attachment },
                        new Message() { Id = messageId, Oplock = messageOplock });
                    result = new AttachmentTO(newAttachment);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return result;
        }
Exemple #2
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 #3
0
        public dto.sm.AttachmentTO getAttachment(string pwd, Int32 attachmentId)
        {
            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");
            }

            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;
        }