Esempio n. 1
0
        private void testSaveList()
        {
            ShutdownMembers test       = new ShutdownMembers();
            List <Member>   MemberList = new List <Member>();
            Member          mem1       = new Member();

            mem1.IP   = "1.2.3.4";
            mem1.Name = "DRStestSQL";
            MemberList.Add(mem1);

            Member mem2 = new Member();

            mem2.IP   = "8.8.8.8";
            mem2.Name = "google";
            MemberList.Add(mem2);

            test.MemberList = MemberList;

            //TestSerializeToFile(test, "Hej");
            XmlSerializer xsSubmit = new XmlSerializer(typeof(ShutdownMembers));
            var           subReq   = test;
            var           xml      = "";

            using (var sww = new StringWriter())
            {
                using (XmlWriter writer = XmlWriter.Create(sww))
                {
                    xsSubmit.Serialize(writer, subReq);
                    xml = sww.ToString(); // Your XML
                }
            }
        }
Esempio n. 2
0
        public ShutdownMembers GetMemberList()
        {
            ShutdownMembers mem  = null;
            string          path = @"C:\SMS_temp\members.xml";

            XmlSerializer serializer = new XmlSerializer(typeof(ShutdownMembers));

            StreamReader reader = new StreamReader(path);

            mem = (ShutdownMembers)serializer.Deserialize(reader);
            reader.Close();

            return(mem);
        }
Esempio n. 3
0
        public void ShutdownAll()
        {
            //testSaveList();


            ShutdownMembers mem  = null;
            string          path = @"C:\SMS_temp\members.xml";

            XmlSerializer serializer = new XmlSerializer(typeof(ShutdownMembers));

            StreamReader reader = new StreamReader(path);

            mem = (ShutdownMembers)serializer.Deserialize(reader);
            reader.Close();

            foreach (var member in mem.MemberList)
            {
                ShutdownPC(member.Name);
                //Console.WriteLine("Shutdown " + member.Name);
            }
        }