コード例 #1
0
        static void TestFoeMessageToXml()
        {
            PrintTitle("Testing FoeMessage.ToXml()");

            FoeMessage message = new FoeMessage();

            string[,] data = new string[3, 2] { { "RequestId", "12345" }, { "UserId", "ABCDE" }, { "Request", "RFACHINESE" } };
            for (int i = 0; i < 3; i++)
            {
                FoeMessageItem item = new FoeMessageItem(data[i, 0], data[i, 1]);
                message.Add(item);
            }

            Console.WriteLine(message.ToXml());

            // test send email
            Console.WriteLine("Sending message to [email protected]...");
            SmtpServer server = new SmtpServer();
            server.ServerName = "smtp.gmail.com";
            server.Port = 587;
            server.AuthRequired = true;
            server.SslEnabled = true;
            server.UserName = "******";
            server.Password = "******";
            MessageManager.SendMessage(server, "*****@*****.**", "*****@*****.**", "Test Message", message);
            Console.WriteLine("Message sent");
        }
コード例 #2
0
        static void TestFoeMessageImportXml()
        {
            PrintTitle("Testing FoeMessage.ImportXml()");

            FoeMessage message = new FoeMessage();

            string[,] data = new string[3, 2] { { "RequestId", "12345" }, { "UserId", "ABCDE" }, { "Request", "RFACHINESE" } };
            for (int i = 0; i < 3; i++)
            {
                FoeMessageItem item = new FoeMessageItem(data[i, 0], data[i, 1]);
                message.Add(item);
            }

            message.ImportXml(message.ToXml());
            Console.WriteLine(message.ToXml());
        }
コード例 #3
0
        /// <summary>
        /// Import XML
        /// </summary>
        /// <param name="xml">XML containing all the FoeMessageItem objects</param>
        public void ImportXml(string xml)
        {
            // delete all existing items
            _items.Clear();

            // import xml
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XmlNodeList nodes = doc.GetElementsByTagName("Message");

            foreach (XmlNode node in nodes)
            {
                XmlNodeList children = node.ChildNodes;
                foreach (XmlNode child in children)
                {
                    FoeMessageItem item = new FoeMessageItem(child.Name, child.InnerText);
                    _items.Add(item);
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Add a new FoeMessageItem
 /// </summary>
 /// <param name="item">FoeMessageItem</param>
 public void Add(FoeMessageItem item)
 {
     _items.Add(item);
 }
コード例 #5
0
ファイル: Types.cs プロジェクト: gcode-mirror/foe-project
 /// <summary>
 /// Add a new FoeMessageItem
 /// </summary>
 /// <param name="item">FoeMessageItem</param>
 public void Add(FoeMessageItem item)
 {
     _items.Add(item);
 }
コード例 #6
0
ファイル: Types.cs プロジェクト: gcode-mirror/foe-project
        /// <summary>
        /// Import XML
        /// </summary>
        /// <param name="xml">XML containing all the FoeMessageItem objects</param>
        public void ImportXml(string xml)
        {
            // delete all existing items
            _items.Clear();

            // import xml
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            XmlNodeList nodes = doc.GetElementsByTagName("Message");
            foreach (XmlNode node in nodes)
            {
                XmlNodeList children = node.ChildNodes;
                foreach (XmlNode child in children)
                {
                    FoeMessageItem item = new FoeMessageItem(child.Name, child.InnerText);
                    _items.Add(item);
                }
            }
        }