Пример #1
0
 public static void SaveToXml(string path, Conversation conv)
 {
     XmlSerializer x = new XmlSerializer(typeof(Conversation));
     TextWriter w = new StreamWriter(path);
     x.Serialize(w, conv);
     w.Close();
 }
Пример #2
0
 public static void SaveToHtml(string path, Conversation conv)
 {
     TextWriter w = new StreamWriter(path);
     w.WriteLine("<html>\n\t<head>\n\t\t<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">");
     w.WriteLine("\t\t<title>Conversation log: "+conv.log[0].time.ToShortDateString()+"</title>");
     w.WriteLine("\t\t<style type=\"text/css\">");
     w.WriteLine("\t\t\tbody {\n\t\t\t\tcolor: black;\n\t\t\t\tbackground-color: white;\n\t\t\t}");
     foreach (Individual usr in conv.people) {
         w.WriteLine("\t\t\t.usr-"+conv.people.IndexOf(usr).ToString()+" span {\n\t\t\t\tcolor: "+usr.colorHtml+";\n\t\t\t\tfont-weight: bold;\n\t\t\t}");
     }
     w.WriteLine("\t\t</style>");
     w.WriteLine("\t</head>\n\t<body>");
     w.WriteLine("\t\t<h1>Conversation on "+conv.log[0].time.ToShortDateString()+"</h1>");
     w.WriteLine("\t\t<p>");
     foreach (Individual usr in conv.people) {
         w.WriteLine("\t\t\t<span class=\"usr-"+conv.people.IndexOf(usr).ToString()+"\"><span>"+usr.name+"</span></span>");
     }
     w.WriteLine("\t\t</p>");
     w.WriteLine("\t\t<p>");
     foreach (Message msg in conv.log) {
         w.WriteLine("\t\t\t<div class=\"usr-"+conv.people.IndexOf(msg.user).ToString()+"\">"+msg.time.ToLongTimeString()+": <span>"+msg.user.name+": </span>"+msg.body+"</div>");
     }
     w.WriteLine("\t\t</p>");
     w.WriteLine("\t</body>\n</html>");
     w.Close();
 }