/// <summary> /// Post a reply message to the server. The ConversationID field of the message must be set to /// a valid conversation ID for the thread to which the reply is being posted. /// </summary> /// <param name="message">The draft InboxMessage to be posted</param> private void Reply(InboxMessage message) { bool hasError = false; try { PMessageReply reply = new PMessageReply { Body = message.Body.EscapeXml(), ConID = RemoteID }; WebRequest request = APIRequest.Post("personalmessage/reply", APIRequest.APIFormat.XML, reply); Stream objStream = APIRequest.ReadResponse(request); if (objStream != null) { using (TextReader reader = new StreamReader(objStream)) { XmlDocument doc = new XmlDocument { InnerXml = reader.ReadLine() }; if (doc.DocumentElement != null) { string responseString = doc.DocumentElement.InnerText; int messageID; if (int.TryParse(responseString, out messageID)) { message.RemoteID = messageID; lock (CIX.DBLock) { CIX.DB.Update(message); } LogFile.WriteLine("Reply {0} posted to server and updated locally", message.RemoteID); } else { hasError = true; } } } } } catch (Exception e) { CIX.ReportServerExceptions("InboxConversation.Reply", e); hasError = true; } if (hasError) { Flags |= InboxConversationFlags.Error; lock (CIX.DBLock) { CIX.DB.Update(this); } } }
/// <summary> /// Handle the Send button. At this point we assume there are valid recipients and something /// in the message body. We really ought to do some validation of the recipient names here. /// </summary> /// <param name="sender">The new message form</param> /// <param name="e">Event arguments</param> private void nmSend_Click(object sender, EventArgs e) { if (_currentConversation == null) { _currentConversation = new InboxConversation { Subject = nmSubject.Text, Author = CIX.Username, Date = DateTime.UtcNow.UTCToGMTBST() }; } if (_currentMessage == null) { _currentMessage = new InboxMessage { Author = (_currentConversation.ID > 0) ? CIX.Username : nmRecipients.Text, Body = nmMessage.Text, ConversationID = _currentConversation.ID, Date = DateTime.UtcNow.UTCToGMTBST() }; CIX.ConversationCollection.Add(_currentConversation, _currentMessage); } DialogResult = DialogResult.OK; Close(); }
/// <summary> /// Post a reply message to the server. The ConversationID field of the message must be set to /// a valid conversation ID for the thread to which the reply is being posted. /// </summary> /// <param name="message">The draft InboxMessage to be posted</param> private void Reply(InboxMessage message) { try { PMessageReply reply = new PMessageReply { Body = message.Body.EscapeXml(), ConID = RemoteID }; WebRequest request = APIRequest.Post("personalmessage/reply", APIRequest.APIFormat.XML, reply); Stream objStream = APIRequest.ReadResponse(request); if (objStream != null) { using (TextReader reader = new StreamReader(objStream)) { XmlDocument doc = new XmlDocument { InnerXml = reader.ReadLine() }; if (doc.DocumentElement != null) { string responseString = doc.DocumentElement.InnerText; int messageID; if (int.TryParse(responseString, out messageID)) { message.RemoteID = messageID; lock (CIX.DBLock) { CIX.DB.Update(message); } LogFile.WriteLine("Reply {0} posted to server and updated locally", message.RemoteID); } } } } } catch (Exception e) { CIX.ReportServerExceptions("InboxConversation.Reply", e); } }