public MessageTO sendReplyMessage(string pwd, Int32 replyingToMessageId, Int32 senderId, Int32 recipientId, string messageBody)
{
MessageTO result = new MessageTO();
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;
}