Ejemplo n.º 1
0
        private SdnList CreateModel(string xml)
        {
            SdnList sdn = new SdnList();

            // convert our xml string to xml //
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xml);

            /**
             * loop through the nodes
             * Again here i probably would have prefered to use recursion.
             */
            var nodes = xmlDoc.GetElementsByTagName("sdnEntry");

            foreach (XmlNode node in nodes)
            {
                SdnEntry entry = new SdnEntry();

                foreach (XmlNode child in node.ChildNodes)
                {
                    // find out what node type it is and handle //
                    switch (child.Name)
                    {
                    case "uid":
                        entry.uid = Convert.ToInt32(child.InnerText);
                        break;

                    case "lastName":
                        entry.lastName = child.InnerText;
                        break;

                    case "sdnType":
                        entry.sdnType = child.InnerText;
                        break;

                    case "addressList":
                        entry.addressList = CreateAddressList(child.ChildNodes);
                        break;

                    case "programList":
                        entry.programList = CreateProgramList(child.ChildNodes);
                        break;

                    case "akaList":
                        entry.akaList = CreateAkaList(child.ChildNodes);
                        break;

                    default:
                        break;
                    }
                }
                SdnEntry t = entry;
                sdn.sdnEntries.Add(entry);
            }

            return(sdn);
        }
Ejemplo n.º 2
0
        private bool EntriesAreDifferent(SdnEntry entry1, SdnEntry entry2)
        {
            /**
             * compare entities
             * this is long winded and i would have liked to use recursion, however i'm not brilliant with reflection and i think it' sneeded here
             */

            // first check scalar //
            if (entry1.uid != entry2.uid)
            {
                return(true);
            }
            if (entry1.lastName != entry2.lastName)
            {
                return(true);
            }
            if (entry1.sdnType != entry2.sdnType)
            {
                return(true);
            }
            if (entry1.addressList.Count() != entry2.addressList.Count())
            {
                return(true);
            }
            if (entry1.programList.Count() != entry2.programList.Count())
            {
                return(true);
            }
            if (entry1.akaList.Count() != entry2.akaList.Count())
            {
                return(true);
            }

            // now check the collections //
            for (int a = 0; a < entry1.addressList.Count(); a++)
            {
                if (entry1.addressList[a].city != entry2.addressList[a].city)
                {
                    return(true);
                }
                if (entry1.addressList[a].address1 != entry2.addressList[a].address1)
                {
                    return(true);
                }
                if (entry1.addressList[a].country != entry2.addressList[a].country)
                {
                    return(true);
                }
                if (entry1.addressList[a].uid != entry2.addressList[a].uid)
                {
                    return(true);
                }
                if (entry1.addressList[a].postalCode != entry2.addressList[a].postalCode)
                {
                    return(true);
                }
            }

            for (int ak = 0; ak < entry1.akaList.Count(); ak++)
            {
                if (entry1.akaList[ak].uid != entry2.akaList[ak].uid)
                {
                    return(true);
                }
                if (entry1.akaList[ak].type != entry2.akaList[ak].type)
                {
                    return(true);
                }
                if (entry1.akaList[ak].category != entry2.akaList[ak].category)
                {
                    return(true);
                }
            }

            for (int p = 0; p < entry1.programList.Count(); p++)
            {
                if (entry1.programList[p] != entry2.programList[p])
                {
                    return(true);
                }
            }

            // if nothings changed the retturn //
            return(false);
        }
Ejemplo n.º 3
0
 public void Add(DateTime dateTime, SdnEntry sdnEntry) => _sdnStorage.AddSdn(dateTime, sdnEntry);