internal DownloadStringCompletedEventArgs(System.Net.DownloadStringCompletedEventArgs e) { Result = e.Result; UserState = e.UserState; Error = e.Error; Cancelled = e.Cancelled; }
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { try { JObject json = JObject.Parse(e.Result); Version current = Assembly.GetExecutingAssembly().GetName().Version; Version latest = Version.Parse((string)json["win"]["version"]); Uri latestUrl = new Uri((string)json["win"]["url"], UriKind.Absolute); if(Completed != null) { Completed(this, new UpdateAvailableEventArgs() { UpdateAvailable = latest > current, CurrentVersion = current.ToString(), NewVersion = latest.ToString(), NewVersionUri = latestUrl }); } } catch (Exception ex) { OnException(ex); } } else { OnException(e.Error); } }
void Completed(object sender, System.Net.DownloadStringCompletedEventArgs e) { try { var dict = (JObject)JsonConvert.DeserializeObject(e.Result); foreach (var obj in dict["contents"]) { if (obj["domain"].ToString() == "music_album") { //music.Add(Convert.ToInt32(obj["identifier"].ToString())); WebClient WC = new WebClient(); WC.DownloadStringAsync(new Uri("http://me2day.net/api/get_content.json?domain=music_album&identifier=" + Convert.ToInt32(obj["identifier"].ToString()) + "&akey=3345257cb3f6681909994ea2c0566e80&asig=MTMzOTE2NDY1MiQkYnlidWFtLnEkJDYzZTVlM2EwOWUyYmI5M2Q0OGU4ZjlmNzA4ZjUzYjMz&locale=ko-KR")); WC.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(musicCompleted); } if (obj["domain"].ToString() == "movie") { //movie.Add(Convert.ToInt32(obj["identifier"].ToString())); WebClient WC = new WebClient(); WC.DownloadStringAsync(new Uri("http://me2day.net/api/get_content.json?domain=movie&identifier=" + Convert.ToInt32(obj["identifier"].ToString()) + "&akey=3345257cb3f6681909994ea2c0566e80&asig=MTMzOTE2NDY1MiQkYnlidWFtLnEkJDYzZTVlM2EwOWUyYmI5M2Q0OGU4ZjlmNzA4ZjUzYjMz&locale=ko-KR")); WC.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(movieCompleted); } if (obj["domain"].ToString() == "book") { WebClient WC = new WebClient(); WC.DownloadStringAsync(new Uri("http://me2day.net/api/get_content.json?domain=book&identifier=" + Convert.ToInt32(obj["identifier"].ToString()) + "&akey=3345257cb3f6681909994ea2c0566e80&asig=MTMzOTE2NDY1MiQkYnlidWFtLnEkJDYzZTVlM2EwOWUyYmI5M2Q0OGU4ZjlmNzA4ZjUzYjMz&locale=ko-KR")); WC.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(bookCompleted); } } } catch (Exception ex) { MessageBox.Show("No Internet Connection"); return; } }
void web_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { Progress.IsIndeterminate = false; ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true; try { PromoCardObject deserializedResponse = JsonConvert.DeserializeObject<PromoCardObject>(e.Result); if (deserializedResponse.error == null) { foreach (Image item in stampCanvas.Children) { item.Opacity = 0; } for (int i = 0; i < deserializedResponse.data[0].AvaliableCount; i++) { stampCanvas.Children[i].Opacity = 1; } } else { MessageBox.Show(deserializedResponse.error.Message); } } catch (Exception) { MessageBox.Show("İnternet bağlantınızla ilgili bir sorun var"); } }
private void web_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { try { html = e.Result; if (html != null) { string result = Regex.Match(html, "trans\":(\".*?\"),\"", RegexOptions.IgnoreCase).Groups[1].Value; if (string.IsNullOrEmpty(result)) { MessageBox.Show("Unable to Translate.", appName, MessageBoxButton.OK); } TextBoxTo.Text = result.Substring(1, result.LastIndexOf('"') - 1); } else { MessageBox.Show("Unable to Translate.", appName, MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show(ex.Message, appName, MessageBoxButton.OK); } finally { this.ButtonTranslate.IsEnabled = true; } }
// once we have received the XML file from Flickr private void flickr_DownloadStringCompleted( object sender, DownloadStringCompletedEventArgs e) { searchButton.Content = "Search"; searchButton.IsEnabled = true; if ( e.Error == null ) { // parse the data with LINQ XDocument flickrXML = XDocument.Parse( e.Result ); // gather information on all photos var flickrPhotos = from photo in flickrXML.Descendants( "photo" ) let id = photo.Attribute( "id" ).Value let secret = photo.Attribute( "secret" ).Value let server = photo.Attribute( "server" ).Value let farm = photo.Attribute( "farm" ).Value select string.Format( "http://farm{0}.static.flickr.com/{1}/{2}_{3}_t.jpg", farm, server, id, secret); // set thumbsListBox's item source to the URLs we received thumbsListBox.ItemsSource = flickrPhotos; } // end if }
private void DownloadRapot(object sender, DownloadStringCompletedEventArgs e) { try { JObject jresult = JObject.Parse(e.Result); JArray JItem = JArray.Parse(jresult.SelectToken("item").ToString()); foreach (JObject item in JItem) { ModelRapot modelRapot = new ModelRapot(); modelRapot.file_laporan = URL.BASE3 + "modul/mod_Laporan/laporan/" + item.SelectToken("file_laporan").ToString(); if (item.SelectToken("semester_pr").ToString() == "1") { modelRapot.semester_pr = item.SelectToken("semester_pr").ToString() + "st Semester"; } else if (item.SelectToken("semester_pr").ToString() == "2") { modelRapot.semester_pr = item.SelectToken("semester_pr").ToString() + "nd Semester"; } else if (item.SelectToken("semester_pr").ToString() == "3") { modelRapot.semester_pr = item.SelectToken("semester_pr").ToString() + "rd Semester"; } else { modelRapot.semester_pr = item.SelectToken("semester_pr").ToString() + "th Semester"; } collectionRapot.Add(modelRapot); } } catch { konek = false; } }
/// <summary> /// Web service completed event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error == null && e.Result != null && e.Result.Count() != 2) { conditionLeaflets = JsonHelper.Deserialize<ConditionSearchCollection>(e.Result); objConditionSearchViewModel.SearchCollection = conditionLeaflets; objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed; objConditionSearchViewModel.NoLeafletTextVisibility = Visibility.Collapsed; } else { objConditionSearchViewModel.NoLeafletTextVisibility = Visibility.Visible; objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed; } } catch (Exception) { objConditionSearchViewModel.ProgressBarVisibilty = Visibility.Collapsed; MessageBox.Show("Sorry, Unable to process your request."); } }
internal UploadStringCompletedEventArgs(System.Net.DownloadStringCompletedEventArgs e) //it is normal that the parameter is of type DownloadStringCompletedEventArgs instead of UploadStringCompletedEventArgs. { Result = e.Result; UserState = e.UserState; Error = e.Error; Cancelled = e.Cancelled; }
void verCheck_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); try { if (e.Result.ToString().Equals(fvi.FileVersion) == false) { if (MessageBox.Show("New version availible - " + e.Result.ToString() + ", do you want to visit the download site?", "Download new version?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string strTarget = "https://github.com/nccgroup/ncccodenavi"; try { System.Diagnostics.Process.Start(strTarget); } catch (System.ComponentModel.Win32Exception noBrowser) { if (noBrowser.ErrorCode == -2147467259) MessageBox.Show(noBrowser.Message); } catch (System.Exception other) { MessageBox.Show(other.Message); } } } } catch (Exception) { } }
/// <summary> /// Download is completed /// *Craate list /// *sent event /// </summary> /// <param name="sender"></param> /// <param name="e">arguments of download call</param> private void Downloaded(object sender, DownloadStringCompletedEventArgs e) { try { if (!e.Cancelled) { var xml = XElement.Parse(e.Result); var items = xml.Elements("channel").Elements("item").Select(element => new RssFeedItem { Description = (ReadElement(element, "description")), Title = ReadElement(element, "title"), Link = ReadElement(element, "link"), PublishDate = DateTime.Parse(ReadElement(element, "pubDate")) }).ToList(); if (ReadRssCompleted != null) ReadRssCompleted(this, new ReadFeedCallbackArguments {FeedItems = items}); } } catch (Exception) { if (ReadRssCompleted != null) ReadRssCompleted(this, new ReadFeedCallbackArguments {ErrorMessage = "Error occurred..."}); } }
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (!string.IsNullOrEmpty(e.Result)) //Om en string återfås { ListBox1.DataContext = null; //"Clearar" listboxen var root1 = JsonConvert.DeserializeObject<RootObject>(e.Result); if (root1.status_code == 100) //Om status-koden är 100 vilket betyder OK { SearchResult.Text = "Din sökning efter : " + TextBoxSearch.Text + " genererade " + root1.results.Count + " resultat."; ListBox1.DataContext = root1.results; //Sätt den tillbakafådda listan som data till listboxen } else if (root1.status_code == 900) //900 = inga träffar { SearchResult.Text = "Din sökning genererade 0 träffar."; } else //Vid annat error { SearchResult.Text = "Det uppstod ett fel vid din sökning, använd minst 3 siffror i din sökning."; } } } catch (Exception ex) //Om appen oväntat crashar skriv ut felmeddelande { MessageBox.Show(ex.ToString()); } }
private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { int itemsCount = 7; xmlReader = XmlReader.Create(new StringReader(e.Result)); feed = SyndicationFeed.Load(xmlReader); List<RSSItem> itemsList = new List<RSSItem>(); if (feed.Items.Count() < 7) { itemsCount = feed.Items.Count(); } for (int i = 0; i <= itemsCount; i++) { RSSItem rssitem = new RSSItem(); rssitem.RSSTitle = feed.Items.ToList()[i].Title.Text; rssitem.RSSLink = feed.Items.ToList()[i].Links[0].Uri; itemsList.Add(rssitem); } RSS.ItemsSource = itemsList; } }
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { XDocument doc = XDocument.Parse(e.Result); try { String defaut= "{http://www.w3.org/2005/Atom}"; List<Object> listObjects = (from c in doc.Descendants(defaut+"entry") select new Object() { Id = c.Element("{http://www.w3.org/2005/Atom}id").Value, Title = c.Element("{http://www.w3.org/2005/Atom}title").Value, SortTitle = c.Element("{http://schemas.zune.net/catalog/apps/2008/02}sortTitle").Value, Update = Convert.ToDateTime(c.Element("{http://www.w3.org/2005/Atom}updated").Value), ReleaseDate = Convert.ToDateTime(c.Element("{http://schemas.zune.net/catalog/apps/2008/02}releaseDate").Value), Version = c.Element("{http://schemas.zune.net/catalog/apps/2008/02}version").Value, AverageUserRating = Convert.ToDouble(c.Element("{http://schemas.zune.net/catalog/apps/2008/02}averageUserRating").Value), UserRatingCount = Convert.ToInt16(c.Element("{http://schemas.zune.net/catalog/apps/2008/02}userRatingCount").Value), Image = new MarketImage() { Id = c.Element("{http://schemas.zune.net/catalog/apps/2008/02}image").Element("{http://schemas.zune.net/catalog/apps/2008/02}id").Value } }).ToList<Object>(); } catch (NullReferenceException ne) { } }
private void WebClient_OnDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs downloadStringCompletedEventArgs) { // Pega a referência do resultado var result = downloadStringCompletedEventArgs.Result; // Deserializa o XML recebido do site latestVersion = SerializationHelper.ReadFromXml<VersionInfo>(result); // Libera o WebClient da memória ((WebClient)sender).Dispose(); // Atualiza as configurações, informando a data da última checagem de atualização Properties.Settings.Default.LastTimeCheckedUpdate = DateTime.Now; Properties.Settings.Default.Save(); // Atualiza as configurações Properties.Settings.Default.UpdateAvailable = UpdateAvailable; Properties.Settings.Default.Save(); // Atualização disponível if (!UpdateAvailable) return; // Define o local para salvar o arquivo downloadedFileName = downloadedFileDir + System.IO.Path.GetFileName(latestVersion.downloadURL); // Baixa atualização DownloadUpdate(latestVersion.downloadURL, downloadedFileName); }
void HandleCompletedDownload(object sender, DownloadStringCompletedEventArgs e, DownloadType type) { switch (type) { case DownloadType.RecentPlaylist: { Parsers.ParseRecentPlaylist(e.Result); break; } case DownloadType.MostPlayedPlaylist: { Parsers.ParseMostPlayed(e.Result); break; } case DownloadType.FavoritePlaylist: { Parsers.ParseFavorites(e.Result); break; } case DownloadType.BadgeList: { Parsers.ParseBadges(e.Result); break; } case DownloadType.FriendList: { Parsers.ParseFriends(e.Result); break; } } }
void _client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { XElement meetupElements = XElement.Parse(e.Result); var meetups = from meetup in meetupElements.Descendants("item") where meetup.Element("venue") != null select new MeetupViewModel { MeetupID = meetup.Element("id").Value, Name = meetup.Element("name").Value, Url = meetup.Element("event_url").Value, Description = meetup.Element("description").Value, CityState = meetup.Element("venue").Element("city").Value + ", " + meetup.Element("venue").Element("state").Value, Latitude = meetup.Element("venue").Element("lat").Value, Longitude = meetup.Element("venue").Element("lon").Value, LatLong = meetup.Element("venue").Element("lat").Value + ", " + meetup.Element("venue").Element("lon").Value }; var index = 0; foreach (MeetupViewModel meetupItem in meetups) { meetupItem.ID = index.ToString(); this.Items.Add(meetupItem); index++; } this.IsDataLoaded = true; }
private void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || e.Cancelled) { return; } try { var myDeserializedObjList = (List<Models.Sessions>)Newtonsoft.Json.JsonConvert.DeserializeObject(e.Result, typeof(List<Models.Sessions>)); lstSessions = myDeserializedObjList; if (!this.isoData.Contains("lastPulledSessions")) { this.lastPulled = DateTime.Now; this.isoData.Add("lastPulledSessions", this.lastPulled); } else { this.isoData["lastPulledSessions"] = DateTime.Now; } this.isoData["lstSessions"] = this.lstSessions; this.isoData.Save(); this.DisplaySessions(); } catch { } }
private void handleDownloadStringComplete(object sender, DownloadStringCompletedEventArgs e) { if (Microsoft.Phone.Net.NetworkInformation.DeviceNetworkInformation.IsNetworkAvailable) { XNamespace media = XNamespace.Get("http://search.yahoo.com/mrss/"); titles = System.Xml.Linq.XElement.Parse(e.Result).Descendants("title") .Where(m => m.Parent.Name == "item") .Select(m => m.Value) .ToArray(); descriptions = XElement.Parse(e.Result).Descendants("description") .Where(m => m.Parent.Name == "item") .Select(m => m.Value) .ToArray(); images = XElement.Parse(e.Result).Descendants(media + "thumbnail") .Where(m => m.Parent.Name == "item") .Select(m => m.Attribute("url").Value) .ToArray(); SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SpeakTextAsync(titles[0]).Completed += new AsyncActionCompletedHandler(delegate(IAsyncAction action, AsyncStatus status) { synth.SpeakTextAsync(descriptions[0]); }); UpdatePrimaryTile(titles[0], images[0]); } else { MessageBox.Show("No network is available..."); } }
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e != null && e.Error == null) { var data = e.Result; XmlDocument _doc = new XmlDocument(); _doc.LoadXml(data); if (_doc.GetElementsByTagName("zigbeeData").Count > 0) { string zigbeeData = _doc.GetElementsByTagName("zigbeeData")[0].InnerText; Zigbit zigbit = _zigbitService.CollectData(zigbeeData); if (zigbit != null) { UpdateZigbit(zigbit); } } } } catch (Exception ex) { ErrorHandlingService.PersistError("GatewayService - webClient_DownloadStringCompleted", ex); } }
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Cancelled) return; if (e.Error != null) { bool redownloadAttempted = WebClientFactory.RedownloadAttempted.Contains(wc); if (Utility.IsMessageLimitExceededException(e.Error) && !redownloadAttempted) { // Re-issue the request which should serve it out of cache // and helps us avoid the error which is caused by setting AllowReadStreamBuffering=false // which was used to workaround the problem of SL4 and gzipped content WebClientFactory.RedownloadStringAsync(wc, new Uri(File.Path, UriKind.RelativeOrAbsolute), e.UserState); } else { if (redownloadAttempted) WebClientFactory.RedownloadAttempted.Remove(wc); OnGetFileAsTextFailed(new ExceptionEventArgs(e.Error, e.UserState)); } return; } OnGetFileAsTextCompleted(new GetFileAsTextCompletedEventArgs() { FileContents = e.Result, UserState = e.UserState }); }
void ClientPlacesDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error == null) { using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result))) { //It doesn't work in Windows Phone, I should change the name of the properties y the models //DataContractJsonSerializerSettings settings = // new DataContractJsonSerializerSettings(); //settings.UseSimpleDictionaryFormat = true; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<Place>)); this.Places = serializer.ReadObject(stream) as List<Place>; } this.DownloadDataResult = Enumerations.Result.Successful; } else { this.DownloadDataResult = Enumerations.Result.ServiceError; } } catch (Exception) { this.DownloadDataResult = Enumerations.Result.ApplicationError; } }
void Completed(object sender, System.Net.DownloadStringCompletedEventArgs e) { string rssContent; rssContent = "hello"; try { rssContent = e.Result; } catch (Exception ex) { MessageBox.Show("No Internet Connection"); return; } XDocument rssParser = XDocument.Parse(rssContent); //LINQ var rssList = from rssTree in rssParser.Descendants("post") select new Post { name = rssTree.Element("author").Element("nickname").Value, body = rssTree.Element("textBody").Value // Img = new Uri(rssTree.Element("imgpath").Value, UriKind.Absolute), // Url = rssTree.Element("bookid").Value }; foreach (Post rss in rssList) { textBlock1.Text += rss.name + "님이 말하기를 : " + rss.body + "\n\n"; } }
private void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null || string.IsNullOrEmpty(e.Result)) return; // Deserialize the list of layouts XmlSerializer serializer = new XmlSerializer(typeof(LayoutInfoCollection)); LayoutInfoCollection layoutList = null; using (TextReader reader = new StringReader(e.Result)) { layoutList = (LayoutInfoCollection)serializer.Deserialize(reader); } // Update UI with layouts list if (layoutList != null && layoutList.Layouts != null) { LayoutsListBox.ItemsSource = Layouts.ItemsSource = layoutList.Layouts; if (layoutList.Layouts.Count > 0) { CurrentSelectedLayoutInfo = layoutList.Layouts.ElementAtOrDefault(0); if (CurrentSelectedLayoutInfo != null) LayoutsListBox.SelectedItem = Layouts.SelectedItem = CurrentSelectedLayoutInfo; } } }
private void LoadDescriptionCompleted(object sender, DownloadStringCompletedEventArgs e) { string html = e.Result; try { string one = html.Substring(html.IndexOf("Explanation:")); string two = one.Substring(one.IndexOf(">") + 1); string three = two.Substring(0, two.IndexOf(@"<p>")); Explanation.Text = three; } catch { Explanation.Text = "Visit the NASA web site for a description."; } string imgroot = "http://apod.nasa.gov/apod/"; try { string four = html.Substring(html.IndexOf("<IMG SRC=") + 10); string url = four.Substring(0, four.IndexOf('"')); _todayUrl = imgroot + url; } catch { _todayUrl = "http://apod.nasa.gov/apod/calendar/today.jpg"; } }
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { verifyAuth(e.Result); } }
void NewsDownloaded(object sender, DownloadStringCompletedEventArgs e) { if (e.Result == null || e.Error != null) { MessageBox.Show("There was an error downloading the XML-file!"); } else { // Deserialize if download succeeds XmlSerializer serializer = new XmlSerializer(typeof(Articles)); XDocument document = XDocument.Parse(e.Result); var news = from query in document.Descendants("item") select new Article { Title = (string)query.Element("title"), Description = (string)query.Element("description").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", "").Replace("<p>", "").Replace("</p>", "").Replace("\n", "").Replace("\t", "").Replace("<p style=", "").Replace("text-align: justify; ", "").Replace(">", "").Replace(@"""", "").Substring(0, 20) + "...", Description1 = (string)query.Element("description").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", ""), Pubdate = (string)query.Element("pubdate") //Title = (query.Element("title") == null) ? "" : (string)query.Element("title").Value.ToString().Replace("<![CDATA[", "").Replace("]]>", ""), //Pubdate = (query.Element("pubdate") == null) ? "" : (string)query.Element("pubdate").Value.ToString() }; newsList.ItemsSource = news; } }
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string xml = e.Result; StringReader sr = new StringReader(xml); XDocument voteFeed = XDocument.Load(sr); FeedItems = (from item in voteFeed.Descendants("item") select new FeedItem { Title = item.Element("title").Value, PubDate = DateTime.Parse(item.Element("pubDate").Value), Link = item.Element("link").Value, Description = item.Element("description").Value }).OrderByDescending(fi => fi.PubDate).ToList(); } catch (Exception) { if (FeedError != null) FeedError(this, null); return; } if (FeedCompleted != null) { FeedCompleted(this, new FeedCompletedEventArgs(FeedItems)); } }
private void WorldFileLoaded(object sender, DownloadStringCompletedEventArgs e) { //Checks to see if there was an error if (e.Error == null) { //grab the data from the world file string myData = e.Result; //split string into an array based on new line characters string[] lines = myData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); //convert the strings into doubles double[] coordValues = new double[6]; for(int i = 0; i < 6; i++) { coordValues[i] = Convert.ToDouble(lines[i]); } //calculate the pixel height and width in real world coordinates double pixelWidth = Math.Sqrt(Math.Pow(coordValues[0], 2) + Math.Pow(coordValues[1], 2)); double pixelHeight = Math.Sqrt(Math.Pow(coordValues[2], 2) + Math.Pow(coordValues[3], 2)); //Create a map point for the top left and bottom right MapPoint topLeft = new MapPoint(coordValues[4], coordValues[5]); MapPoint bottomRight = new MapPoint(coordValues[4] + (pixelWidth * imageWidth), coordValues[5] + (pixelHeight * imageHeight)); //create an envelope for the elmently layer Envelope extent = new Envelope(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y); ElementLayer.SetEnvelope(image, extent); //Zoom to the extent of the image MyMap.Extent = extent; } }
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { WebClient client = sender as WebClient; client.DownloadStringCompleted -= client_DownloadStringCompleted; // 没有出错 if (e.Error == null) { try { String retid = e.Result as String; if (!"noid".Equals(retid) && userid != null) { //产生要发送后台的JSON串 WebClientInfo wci1 = Application.Current.Resources["server"] as WebClientInfo; string uri1 = wci1.BaseAddress + "/iesgas/gascz/comand"; WebClient client1 = new WebClient(); client1.UploadStringCompleted += client1_UploadStringCompleted; client1.UploadStringAsync(new Uri(uri1), ("[{customer_code:\"" + userid + "\",id:\"" + retid + "\"}]")); } } catch (Exception ex) { } } busy.IsBusy = false; }
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { toolStripStatusLabel1.Text = ""; htmlSource = e.Result; initializeManga(); }
private void HandleFlickrResult(object sender, DownloadStringCompletedEventArgs e) { // Different branch for success than failure if (e.Error == null) { // Get XML from the result string XDocument xmlResults = XDocument.Parse(e.Result); // Process reults using LINQ to XML var enumResults = from result in xmlResults.Descendants("photo") select new SearchResult { DateTaken = (DateTime)result.Attribute("datetaken"), // Description = ?, Location = MakeFlickrUrl(result), Title = (string)result.Attribute("title"), }; // Create a new collection containing all results SearchResultCollection results = new SearchResultCollection(enumResults); // Notify of results NotifyResult(new SearchCompleteEventArgs(results)); } else { // Failure, notify NotifyResult(new SearchCompleteEventArgs(e.Error)); } }
static void WebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { ParseImages((e.UserState as String), XDocument.Parse(e.Result)); } }
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { var rootObject = JsonConvert.DeserializeObject<Rootobject>(e.Result); double lat, longitude; MapPolyline line = new MapPolyline(); line.StrokeColor = Colors.Green; line.StrokeThickness = 2; double[] coord = new double[2 * rootObject.direction[0].stop.Length]; for (int i = 0; i < rootObject.direction[0].stop.Length; i++) { lat = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lat); longitude = Convert.ToDouble(rootObject.direction[0].stop[i].stop_lon); line.Path.Add(new GeoCoordinate(lat, longitude)); Ellipse myCircle = new Ellipse(); myCircle.Fill = new SolidColorBrush(Colors.Green); myCircle.Height = 15; myCircle.Width = 15; myCircle.Opacity = 60; MapOverlay myLocationOverlay = new MapOverlay(); myLocationOverlay.Content = myCircle; myLocationOverlay.PositionOrigin = new Point(0.5, 0.5); myLocationOverlay.GeoCoordinate = new GeoCoordinate(lat, longitude, 200); MapLayer myLocationLayer = new MapLayer(); myLocationLayer.Add(myLocationOverlay); map.Layers.Add(myLocationLayer); } map.MapElements.Add(line); }
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { IEnumerable<IdentityProviderInformation> identityProviders = null; Exception error = e.Error; if (null == e.Error) { try { using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(e.Result))) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(IdentityProviderInformation[])); identityProviders = serializer.ReadObject(ms) as IEnumerable<IdentityProviderInformation>; IdentityProviderInformation windowsLiveId = identityProviders.FirstOrDefault(i => i.Name.Equals("Windows Live™ ID", StringComparison.InvariantCultureIgnoreCase)); if (windowsLiveId != null) { string separator = windowsLiveId.LoginUrl.Contains("?") ? "&" : "?"; windowsLiveId.LoginUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}pcexp=false", windowsLiveId.LoginUrl, separator); } } } catch(Exception ex) { error = ex; } } if (null != GetIdentityProviderListCompleted) { GetIdentityProviderListCompleted(this, new GetIdentityProviderListEventArgs( identityProviders, error )); } }
void client_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { string s = e.Result; byte[] b = Encoding.Unicode.GetBytes(s); MemoryStream st = new MemoryStream(b); DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(ServerInfo)); ServerInfo si = (ServerInfo)ds.ReadObject(st); loadFolders(si); }
private void PushMsgServiceDownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { try { this.OnDownloadReceived(e); } catch (WebException) { // Take appropriate action here return; } }
private void client_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { host.UI.prsBar.Visibility = System.Windows.Visibility.Collapsed; if (e.Error == null) { listTags(e.Result); } else { alert("error!"); } }
private void client_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { Deployment.Current.Dispatcher.BeginInvoke(() => { try { this.OnRequestComplete.Invoke(this, e.Result); } catch (Exception ex) { this.OnRequestComplete.Invoke(this, null); } }); }
public void ObtindreRss(object sender, System.Net.DownloadStringCompletedEventArgs e) { int i = 0; if (e.Error == null) { try { XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None); XElement xele = xdoc.Root; sTitle.Clear(); sValue.Clear(); //todo, extraure els elements entry a xele2 foreach (XElement xele2 in xele.Elements()) { if (xele2.Name.LocalName == "entry") { if (i++ <= nMaxElements) { foreach (XElement xele3 in xele2.Elements()) { if (xele3.Name.LocalName == "title") { sTitle.Add(xele3.Value); } if (xele3.Name.LocalName == "content") { sValue.Add(xele3.Value); } } } } } if (CarregarDades != null) { CarregarDades(); } } catch (Exception ex) { if (ErrorConnexio != null) { ErrorConnexio(); } } } }
void _wc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { if (e.Error == null) { leaderboard = JsonConvert.DeserializeObject <LeaderboardObject>(e.Result); foreach (var obj in leaderboard.board) { ldrbrd.Add(new LeaderboardAll(obj.bad, obj.good, obj.ratio, obj.id, obj.name, "t")); } foreach (var obj in leaderboard.bottom) { ldrbrd.Add(new LeaderboardAll(obj.bad, obj.good, obj.ratio, obj.id, obj.name, "b")); } lls.ItemsSource = ldrbrd; } }
private void GetEdgeCdnTimeCompleted(string results, System.Net.DownloadStringCompletedEventArgs e) { if (e.Error != null) { return; } StringReader stream = new StringReader(e.Result); XmlReader reader = XmlReader.Create(stream); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("tm")) { var cdnTime = reader.ReadElementContentAsLong(); this.xmlAssetsDataParser.ParseAssets(results, cdnTime); } } }
void On72HrForecastDownloaded(object sender, System.Net.DownloadStringCompletedEventArgs e) { if (e.Result == null || e.Error != null) { MessageBox.Show("無法下載最新的天氣資訊!請檢查網路連線。"); } else { Utils.saveXML(Utils.GetXmlFileName(Navigation.ForecastCity, XML_72HR_POSTFIX), e.Result); } try { Load72HrForecastData(); } catch (Exception ex) { MessageBox.Show("讀檔錯誤。"); } }
void wc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { if (e.Error != null) { return; } var type = JObject.Parse(e.Result).SelectToken("type").ToString(); var id = JObject.Parse(e.Result).SelectToken("id").ToString(); postAnswer.Add("access_token", App.AccessToken); postAnswer.Add("id", id); switch (type) { case "hometown": hometown = JsonConvert.DeserializeObject <HometownObject>(e.Result); setHometown(); break; case "music": music = JsonConvert.DeserializeObject <MusicObject>(e.Result); setMusic(); break; case "book": book = JsonConvert.DeserializeObject <BookObject>(e.Result); setBook(); break; case "movie": movie = JsonConvert.DeserializeObject <MovieObject>(e.Result); setMovie(); break; case "photo": photo = JsonConvert.DeserializeObject <PhotoObject>(e.Result); setPhoto(); break; } }
void bookCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { try { var dict = (JObject)JsonConvert.DeserializeObject(e.Result); Book abook = new Book(); abook.Title = dict["detail"]["title"].ToString(); abook.Contents = dict["detail"]["author"].ToString(); abook.Img = new Uri(dict["detail"]["image_url"].ToString()); abook.Url = dict["identifier"].ToString(); books.Add(abook); if (books.Count() == 10) { SecondListBox.ItemsSource = books; } } catch (Exception ex) { MessageBox.Show("No Internet Connection"); return; } }
/// <summary> /// обработка получения данных геолокации в асинх режиме /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cwc_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { OsmGeoLocationsInfoClient osmGeoClient = sender as OsmGeoLocationsInfoClient; try { if (!e.Cancelled) { string xml = e.Result; //парсим данные IEnumerable <GeoLocationBase> geoLocations = this._geoParser.ParseXmlGeoData(xml); osmGeoClient.CompleteAction(geoLocations, null); } } catch (Exception ex) { osmGeoClient.CompleteAction(null, ex); } finally { osmGeoClient.Dispose(); this._contentWebClient = null; } // return geoLocations.Cast<T>(); }
/// <summary> /// Handler for download complete of xml files from web server /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void webclient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { WebClient _webClient = sender as WebClient; String s = _webclient.Headers.Count.ToString(); // MessageBox.Show(s); if (e.Error == null) { Enqueue(e.Result); if (_firstChart || _currentDownloadingUri.IsForceRender) { RenderEngine(); } // Download next XML DownloadXML(); } else { throw e.Error; } }
void cl_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { try { string s = delimit(e.Result, "<item>", "</item>"); System.Diagnostics.Debug.WriteLine(s); current = delimit(s, "condition text=\"", "\""); currenttemp = delimit(s, "temp=\"", "\""); s = delimit(s, "yweather:forecast", "<guid"); s = delimit(s, "forecast", ">"); tomorrowCondition = delimit(s, "text=\"", "\""); tomorrowHigh = delimit(s, "high=\"", "\""); sender = null; GC.Collect(); updateWidgets(); } catch (Exception ex) { msgbox("Exception in weather downloader: " + ex.Message); } }
void MainWebClient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { MQOEvents.MainReady(true); }
void ChatWebClient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { MQOEvents.ChatReady(e.Result); }
protected virtual new void OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) { }
protected virtual void OnDownloadStringCompleted(DownloadStringCompletedEventArgs e) { throw new NotImplementedException(); }
private void Webclient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { throw new NotImplementedException(); }
private void dataRetriever_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e) { StringReader dataReader = new StringReader(e.Result); this.BindChart(dataReader); }