示例#1
0
        public static SMessage TextToMessage(string text)
        {
            SMessage msg = new SMessage();

            string[] msgString = text.Split('|');
            Console.WriteLine(msgString[0]);
            msg.Author = msgString[0];
            Console.WriteLine(msgString[1]);
            msg.CryptMethod = msgString[1];
            msg.Text        = msgString[2];

            return(msg);
        }
示例#2
0
        static SMessage ProcessMessage(RMessage m)
        {
            Console.WriteLine("id = " + m.Parameters["id"]);
            Console.WriteLine("name = " + m.Parameters["name"]);

            using (FileStream s = File.Create("山水.jpg"))
            {
                m.Content.CopyTo(s);
            }

            SMessage sMsg = new SMessage();

            sMsg.Parameters.Add(new Para("Result", "Success"));

            return(sMsg);
        }
示例#3
0
        public static void SaveInXml(SMessage msg)
        {
            XmlDocument doc = new XmlDocument();

            while (true)
            {
                try
                {
                    doc.Load(@"C:\Users\filip.eriksson4\source\repos\Server\messages.xml");

                    XmlNode message = doc.CreateElement("Message");

                    //Skapa de element som meddelandet ska innehålla
                    XmlElement author = doc.CreateElement("Author");
                    author.InnerText = msg.Author;
                    XmlElement cryptMethod = doc.CreateElement("CryptationMethod");
                    cryptMethod.InnerText = msg.CryptMethod;
                    XmlElement text = doc.CreateElement("Text");
                    text.InnerText = msg.Text;

                    //Lägg in alla egenskaper på meddelandet
                    message.AppendChild(author);
                    message.AppendChild(cryptMethod);
                    message.AppendChild(text);

                    //Söker dokumentet efter huvudet messages sedan lägger in meddelande
                    doc.SelectSingleNode("Messages").AppendChild(message);
                    doc.Save(@"C:\Users\filip.eriksson4\source\repos\Server\messages.xml");
                    break;
                }

                catch
                {
                    CreateXmlfile(doc);
                }
            }
        }