예제 #1
0
        public string DisplayData(NAL pNal)
        {
            NameAuthorityList myData       = new NameAuthorityList();
            string            storedString = myData.LoadXmlData(pNal);

            return(storedString);
        }
예제 #2
0
        public List <Timeperiod> FillList(NAL pNal)
        {
            //NameAuthorityList myData = new NameAuthorityList();
            //string storedString = (myData.LoadXmlData(NAL.Countries));
            List <Timeperiod> myTimePeriods = new List <Timeperiod>();
            XmlDocument       doc           = new XmlDocument();
            //load à partir d'un string
            //doc.Load(storedString);

            //load à partir d'une URL
            string url = "http://publications.europa.eu/mdr/resource/authority/";

            url += "timeperiod/xml/timeperiods.xml";
            doc.Load(url);

            // XmlNode node = doc.DocumentElement.SelectSingleNode("record");
            // string timeperiodID = node.Attributes["id"].InnerText;

            foreach (XmlNode recordNode in doc.DocumentElement.ChildNodes)
            {
                Timeperiod mytp = new Timeperiod(recordNode);
                myTimePeriods.Add(mytp);
            }


            return(myTimePeriods);
        }
예제 #3
0
        public List <T> FillList(NAL pNal)
        {
            NameAuthorityList myData       = new NameAuthorityList();
            string            storedString = (myData.LoadXmlData(pNal));
            List <T>          myList       = new List <T>();
            int  startIndex = 0;
            bool inSequence = true;

            while (inSequence == true)
            {
                Caption myCaption = getRecord(storedString, "<record ", "</record>", startIndex);
                int     a         = storedString.Length;
                if (myCaption.inSequence == true)
                {
                    T myT = (T)Activator.CreateInstance(typeof(T), myCaption.sequence);
                    myList.Add(myT);
                    startIndex = myCaption.index;
                }
                inSequence = myCaption.inSequence;
            }
            return(myList);
        }
예제 #4
0
        public string LoadXmlData(NAL pNal)
        {
            string url = "http://publications.europa.eu/mdr/resource/authority/";

            switch (pNal)
            {
            case NAL.Countries:
                url += "country/xml/countries.xml";
                break;

            case NAL.Languages:
                url += "language/xml/languages.xml";
                break;

            case NAL.Honorifics:
                url += "honorific/xml/honorifics.xml";
                break;

            case NAL.Places:
                url += "place/xml/places.xml";
                break;

            case NAL.Sexes:
                url += "human-sex/xml/humansexes.xml";
                break;

            case NAL.ATU_Types:
                url += " atu-type/xml/atu-type.xml";
                break;

            case NAL.TimePeriods:
                url += "timeperiod/xml/timeperiods.xml";
                break;

            case NAL.Currencies:
                url += "currency/xml/currencies.xml";
                break;

            case NAL.Continents:
                url += "continent/xml/continents.xml";
                break;

            case NAL.AdressTypes:
                url += "address-type/xml/addresstypes.xml";
                break;

            case NAL.ATU:
                url += "atu/xml/atu.xml";
                break;

            default:
                break;
            }

            WebRequest  wReq  = WebRequest.Create(url);;
            WebResponse wResp = wReq.GetResponse();

            // Get a readable stream from the server
            using (StreamReader sr = new StreamReader(wResp.GetResponseStream(), Encoding.UTF8))
            {
                int    length    = 512;
                char[] Buffer    = new char[length];
                int    bytesread = 0;
                //Read from the stream and write data to console
                StringBuilder mySB = new StringBuilder();
                bytesread = sr.Read(Buffer, 0, length);
                while (bytesread > 0)
                {
                    mySB.Append(Buffer, 0, bytesread);
                    bytesread = sr.Read(Buffer, 0, length);
                }
                return(mySB.ToString());
            }
        }