Ejemplo n.º 1
0
        public dto.sm.AttachmentTO addAttachment(string pwd, Int32 messageId, Int32 messageOplock, string fileName, string mimeType, AttachmentTO attachment)
        {
            AttachmentTO result = new AttachmentTO();

            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");
            }
            else if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(mimeType) || attachment == null || attachment.attachment == null || attachment.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.attachment
                    },
                        new Message()
                    {
                        Id = messageId, Oplock = messageOplock
                    });
                    result = new AttachmentTO(newAttachment);
                }
            }
            catch (Exception exc)
            {
                result.fault = new FaultTO(exc);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public dto.sm.AttachmentTO updateAttachment(string pwd, Int32 attachmentId, Int32 attachmentOplock, string fileName, string mimeType, AttachmentTO newAttachment)
        {
            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");
            }
            else if (String.IsNullOrEmpty(fileName) || String.IsNullOrEmpty(mimeType) || newAttachment == null || newAttachment.attachment == null || newAttachment.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 = newAttachment.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);
        }
Ejemplo n.º 3
0
        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);
        }