Exemple #1
0
        /**
         * Loads Poi media data: media files and main details.
         */
        public void loadMedia(Poi poi, string poiSubDir)
        {
            //Debug.WriteLine("loadMedia: poi sub dir: " + poiSubDir, ToString());
            // load xml document
            XmlDocument poiXmlDoc  = new XmlDocument();
            string      poiXmlPath = getPoiXmlPath(poiSubDir);

            poiXmlDoc.Load(poiXmlPath);
            // get media files
            XmlNode mediaFilesNode = poiXmlDoc.SelectSingleNode("/poi/media_files");

            if (mediaFilesNode != null)
            {
                MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(poi.getMediaFiles());
                mfxa.parse(mediaFilesNode);
            }
            // get main details
            XmlNode mainDetailsNode = poiXmlDoc.SelectSingleNode("/poi/details");

            if (mainDetailsNode != null)
            {
                MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(poi.getMainDetails());
                mdxa.parse(mainDetailsNode);
            }
            string poiMediaFilesPath = getPoiMediaFilesPath(poiSubDir);

            if (poiMediaFilesPath != null)
            {
                loadMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath);
            }
        }
Exemple #2
0
        public void save(Poi poi, string poiSubDir)
        {
            Debug.WriteLine("save: poi: " + poi, ToString());
            string poiXmlFilePath    = createPoiXmlPath(poiSubDir);
            string poiMediaFilesPath = createPoiMediaFilesPath(poiSubDir);
            // serialize poi
            PoiXmlAdapter pxa    = new PoiXmlAdapter();
            string        poiXml = pxa.serialize(poi);

            // save poi's xml
            saveXml(poiXml, poiXmlFilePath);
            // save poi's media
            saveMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath);
        }
Exemple #3
0
 public void downloadPoiMedia(Poi p)
 {
     foreach (MediaFile m in p.getAllMediaFiles())
     {
         Debug.WriteLine("downloading media file: uri: " + m.getUrl().ToString(), ToString());
         try
         {
             byte[] mediaData = this.portal.download(m.getUrl());
             m.setMedia(mediaData);
         }
         catch (PortalException e)
         {
             Debug.WriteLine("loadPoiMedia: portal error: " + e.Message, ToString());
         }
     }
 }