Пример #1
0
        public static PcInfromations DeserializePcInformations(string xml, PcInfromations pcInformations)
        {
            using (StringReader sr = new StringReader(xml))
            {
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(pcInformations.GetType());
                pcInformations = (PcInfromations)x.Deserialize(sr);
            }

            return(pcInformations);
        }
Пример #2
0
        private void getPcInformations()
        {
            string xml = ConnectionManager.GetPcInformations(URI_GET_PCINFO);

            pcInformations = FileManager.DeserializePcInformations(xml, pcInformations);

            for (int i = 0; i < pcInformations.pc.Count; i++)
            {
                Pc pc = pcInformations.pc[i];

                ListViewItem lvi = new ListViewItem();
                lvi.Text = pc.name;
                lvi.Name = i.ToString();
                lvi.Tag  = pc.id;
                lvi.SubItems.Add(pc.ip);

                bool alredyExist = false;

                foreach (ListViewItem adressInfoList in adressinformation.Items)
                {
                    if (adressInfoList.Text == pc.name && adressInfoList.SubItems[1].Text == pc.ip)
                    {
                        alredyExist = true;
                    }
                }

                if (!alredyExist)
                {
                    int adressInfoId = -1;
                    foreach (ListViewItem adressInfoList in adressinformation.Items)
                    {
                        if (adressInfoList.Tag.ToString() == pc.id.ToString())
                        {
                            adressInfoId = adressInfoList.Index;
                        }
                    }

                    if (adressInfoId == -1)
                    {
                        adressinformation.Items.Add(lvi);
                    }
                    else
                    {
                        adressinformation.Items.RemoveAt(adressInfoId);
                        adressinformation.Items.Insert(adressInfoId, lvi);
                    }
                }
            }
        }