Пример #1
0
        public void Index()
        {
            var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");

            Assert.Fail("Need to put password here");
            g.setUserCredentials("*****@*****.**", "zzz");
            var entry = new AtomEntry();
            entry.Content.ExtensionFactories.Add(new MapsExtension());
            entry.Title.Text = "test";
               entry.Content.Type = "application/vnd.google-earth.kml+xml";
               XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
                   <name>Faulkner's Birthplace</name>
                   <description/>
                   <Point>
                     <coordinates>-89.520753,34.360902,0.0</coordinates>
                   </Point>
                 </Placemark>");
            entry.Content.ExtensionElements.Add(new XmlExtension((XmlNode)doc.DocumentElement));
                 //    doc.LoadXml(@"@"<m:Placemark>
                 //  <m:name>Faulkner's Birthplace</m:name>
                 //  <m:description/>
                 //  <m:Point>
                 //    <m:coordinates>-89.520753,34.360902,0.0</m:coordinates>
                 //  </m:Point>
                 //</m:Placemark>";

            //entry.Content.Content = ;
            //entry.AddExtension(new MapsExtension());
            var m = new MemoryStream();
            //var mapStuff = entry.Content.CreateExtension("PlaceMark", "http://www.opengis.net/kml/2.2");

               // entry.Update();
            try
            {
                entry.SaveToXml(m);
            }
            catch (Exception e)
            {
                var s = e.ToString();
                throw;
            }
            m.Position = 0;
            var mm = new StreamReader(m).ReadToEnd();
             var q = g.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);

            var p = g.Query(new Uri("http://maps.google.com/maps/feeds/maps/default/full"));

            var z = new StreamReader(p).ReadToEnd();

            //// Arrange
            //HomeController controller = new HomeController();

            //// Act
            //ViewResult result = controller.Index() as ViewResult;

            //// Assert
            //ViewDataDictionary viewData = result.ViewData;
            //Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////////





        //////////////////////////////////////////////////////////////////////
        /// <summary>WebResponse Update(Uri updateUri, Stream entryStream, ICredentials credentials)</summary> 
        /// <param name="entry">the old entry to update</param> 
        /// <returns> the new Entry, as returned from the server</returns>
        //////////////////////////////////////////////////////////////////////
        public AtomEntry Update(AtomEntry entry)
        {
            Tracing.Assert(entry != null, "entry should not be null");
            if (entry == null)
            {
                throw new ArgumentNullException("entry"); 
            }

            if (entry.ReadOnly == true)
            {
                throw new GDataRequestException("Can not update a read-only entry"); 
            }


            Uri target = new Uri(entry.EditUri.ToString());

            IGDataRequest request = this.RequestFactory.CreateRequest(GDataRequestType.Update,target);
            request.Credentials = this.Credentials;
            Stream outputStream = request.GetRequestStream();

            entry.SaveToXml(outputStream);
            request.Execute();
            outputStream.Close();

            AtomFeed returnFeed = createFeed(target);

            returnFeed.NewAtomEntry += new FeedParserEventHandler(this.OnParsedNewEntry); 
            returnFeed.NewExtensionElement += new ExtensionElementEventHandler(this.OnNewExtensionElement);

            Stream returnStream = request.GetResponseStream();

            returnFeed.Parse(returnStream, AlternativeFormat.Atom);
            // there should be ONE entry echoed back. 
            returnStream.Close(); 

            return returnFeed.Entries[0]; 

        }