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