public string DisplayMessage(gbMessage loMessage, string lsPath, string csPath) { string lsTemplate = ""; string lsError = String.Empty; lsTemplate = GetFileContents(csPath + "\\Templates\\Guestbook\\message_box.html", lsError); lsTemplate = lsTemplate.Replace("{TPLPATH}", lsPath + "/Templates/Guestbook"); // + "/"); lsTemplate = lsTemplate.Replace("{ID}", loMessage.ID.ToString()); lsTemplate = lsTemplate.Replace("{SUBMITDATE}", loMessage.SubmitDate); lsTemplate = lsTemplate.Replace("{NAME}", loMessage.Name); lsTemplate = lsTemplate.Replace("{EMAIL}", loMessage.Email); lsTemplate = lsTemplate.Replace("{MESSAGE}", loMessage.Message); return lsTemplate; }
public gbMessage DeserializeMessage(string lsId, ref string lsError) { string loResponse = ""; var gbMessage = new gbMessage(); try { var loMessage = new XmlSerializer(typeof(gbMessage)); var loStreamReader = new StreamReader(csPath + "\\" + lsId); gbMessage = (gbMessage)loMessage.Deserialize(loStreamReader); loResponse = "Message Retrieved Successfully!"; loStreamReader.Close(); } catch (Exception ex) { loResponse = "Error: " + ex.Message; } return gbMessage; }
public string SerializeMessage(gbMessage loMessage) { string loResponse = ""; try { var loMessageSerialize = new XmlSerializer(typeof(gbMessage)); var loWriteStream = new StreamWriter(csPath + "\\" + loMessage.ID + ".xml"); loMessageSerialize.Serialize(loWriteStream, loMessage); loResponse = "Message Stored Successfully!"; loWriteStream.Close(); } catch (Exception ex) { loResponse = "Error: " + ex.Message; } return loResponse; }