DownloadStringAsync() public method

public DownloadStringAsync ( System address ) : void
address System
return void
Example #1
1
 //public void LoadMovies()
 //{
 //    Thread.Sleep(5000);
 //    var handler = OnLoadMovies;
 //    if (handler != null)
 //        handler(new LoadMoviesEventArgs {MultiplexId = _multiplexId});
 //}
 public void LoadMovies()
 {
     var client = new WebClient();
     client.DownloadStringCompleted += GetMoviesCompleted;
     var path = string.Format(Movie.MoviesUri, _multiplexId);
     client.DownloadStringAsync(new Uri(path, UriKind.Absolute));
 }
 //方法
 public void Initialize()
 {
     WebClient wc = new WebClient();
     wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
     if (Credential.CREDENTIAL.GetUrlParameters() != null)
     {
         string s = string.Format("{0}.json" +"?"+ Credential.CREDENTIAL.GetUrlParameters(), MapServiceUrl);
         wc.DownloadStringAsync(new Uri(s, UriKind.Absolute), this);
     }
     else {
         wc.DownloadStringAsync(new Uri(string.Format("{0}.json", MapServiceUrl), UriKind.Absolute), this);
     }
 }
 public void UpdatePACFromGFWList(Configuration config)
 {
     WebClient http = new WebClient();
     http.Proxy = new WebProxy(IPAddress.Loopback.ToString(), config.localPort);
     http.DownloadStringCompleted += http_DownloadStringCompleted;
     http.DownloadStringAsync(new Uri(GFWLIST_URL));
 }
 /// <summary>
 /// Method to call webservice
 /// </summary>
 public void RequestData()
 {
     string url = RxConstants.ConditionSearchUrl + App.ConditionSearchName + RxConstants.ApiKey;
     WebClient webClient = new WebClient();
     webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
     webClient.DownloadStringAsync(new Uri(url));
 }
 public Checker(string name, string twitch, string youtube, string facebook)
 {
     this.name = name;
     this.twitch = twitch;
     this.youtube = youtube;
     this.facebook = facebook;
     defaultImage = "Image/unknown.png";
     try
     {
         using (WebClient webClient = new WebClient())
         {
             webClient.DownloadStringCompleted += (a, b) =>
             {
                 if (!b.Cancelled)
                 {
                     string xmlString = b.Result;
                     XmlReader reader = XmlReader.Create(new StringReader(xmlString));
                     reader.ReadToFollowing("media:thumbnail");
                     defaultImage = reader["url"];
                 };
             };
             webClient.DownloadStringAsync(new Uri("http://gdata.youtube.com/feeds/api/users/" + youtube));
         }
     }
     catch
     {
         defaultImage = "Image/unknown.png";
     }
     Check(0, "", true);
 }
Example #6
0
    private static async Task <String> AwaitWebClient(Uri uri)
    {
        // The System.Net.WebClient class supports the Event-based Asynchronous Pattern
        var wc = new System.Net.WebClient();

        // Create the TaskCompletionSource and its underlying Task object
        var tcs = new TaskCompletionSource <String>();

        // When a string completes downloading, the WebClient object raises the
        // DownloadStringCompleted event which completes the TaskCompletionSource
        wc.DownloadStringCompleted += (s, e) => {
            if (e.Cancelled)
            {
                tcs.SetCanceled();            // Easy to use.
            }
            else if (e.Error != null)
            {
                tcs.SetException(e.Error);
            }
            else
            {
                tcs.SetResult(e.Result); // Here is that's why we use TaskCompletionSource.
            }
        };

        // Start the asynchronous operation
        wc.DownloadStringAsync(uri);

        // Now, we can the TaskCompletionSource’s Task and process the result as usual
        String result = await tcs.Task;

        // Process the resulting string (if desired)...

        return(result);
    }
Example #7
0
        public static void GetStationCollectionAsync(IQueryBuilder url, RealTimeDataDelegate callback)
        {
            try
            {
                if (url == null) throw new Exception("Cannot work with null-objects");
                if (String.IsNullOrEmpty(url.Url)) throw new Exception("Url cannot be empty");

                var client = new WebClient();

                client.DownloadStringCompleted += (s, e) =>
                {
                    if (e.Error != null) throw e.Error;
                    if (e.Result == null) return;

                    var collection = JsonHelper.Deserialize<
                        IList<Station>>(e.Result);

                    callback(new ObservableCollection<Station>(collection));
                };

                client.DownloadStringAsync(new Uri(url.Url));
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #8
0
        public void Run()
        {
            WebClient wc = new System.Net.WebClient();

            wc.DownloadStringCompleted += ObtindreRss;
            wc.DownloadStringAsync(new Uri(sURL));
        }
 private void GetVEServiceKey()
 {
     WebClient wc = new WebClient();
     wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
     Uri keyURI = new Uri(System.Windows.Browser.HtmlPage.Document.DocumentUri, "VEKey.txt");
     wc.DownloadStringAsync(keyURI);
 }
        void do_it(string getLink)
        {
            string url = getLink;

            url = "_YOUR_API_URL_HERE_" + url;

            Wait.Enabled = true;
            Wait.MarqueeAnimationSpeed = 10;
            loadingGIF.Visible         = true;
            GetURL.Enabled             = false;
            ResultBox.Text             = "";
            System.Net.WebClient wc = new System.Net.WebClient();
            try
            {
                wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
                wc.DownloadStringAsync(new Uri(url));
            }
            catch (Exception)
            {
                ResultBox.Text             = "\n\nError";
                Wait.MarqueeAnimationSpeed = 0;
                Wait.Enabled       = false;
                loadingGIF.Visible = false;
            }
        }
Example #11
0
 private void getTweet()
 {
     WebClient wc=new WebClient();
     wc.DownloadStringCompleted+=wc_DownloadStringCompleted;
     wc.DownloadStringAsync(new Uri("https://search.twitter.com/search.atom?q=to:twitter%20geocode:37.781157,-122.398720,25mi", UriKind.Absolute));
     
 }
Example #12
0
 private void addUsrBtn_Click(object sender, RoutedEventArgs e)
 {
     this.loginStatus.Text = "Please wait while we try to log you in...";
     WebClient client = new WebClient();
     client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
     client.DownloadStringAsync(new Uri(string.Format(SyncContextInstance.LoginUriFormat, this.unameTxt.Text)));
 }
 private void GetVEServiceKey()
 {
     WebClient wc = new WebClient();
     wc.DownloadStringCompleted += this.WebClientDownloadStringCompleted;
     Uri keyURI = new Uri(URIHelper.CurrentApplicationURL, "VEKey.txt");
     wc.DownloadStringAsync(keyURI);
 }
Example #14
0
 static ServerSettings()
 {
     using ( var client = new WebClient() ) {
         client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
         client.DownloadStringAsync(new Uri(UrlsUrl));
     }
 }
Example #15
0
        public static void RefreshLocalSpeakers()
        {
            var url    = "http://itpalooza.com/api/request.php?action=getSpeakers";
            var getUrl = new System.Uri(url);

            var wc = new System.Net.WebClient();

            wc.Headers ["USER-AGENT"]   = "Eventarin ITPalooza HTTP client";
            wc.DownloadStringCompleted += (sender, e) =>
            {
                var v = e.Result;


                Eventarin.Core.App.Database.DeleteSpeakers();
                var json = Newtonsoft.Json.JsonConvert.DeserializeObject <Data.Speakers.RootObject> (v);
                foreach (Data.Speakers.Result speakerJSON in json.result)
                {
                    Speaker newSpeaker = new Speaker();
                    newSpeaker.Id          = int.Parse(speakerJSON.speaker_id);
                    newSpeaker.Name        = speakerJSON.firstname + ' ' + speakerJSON.lastname;;
                    newSpeaker.HeadshotUrl = speakerJSON.avatar;
                    newSpeaker.Position    = speakerJSON.position;
                    newSpeaker.BioSummary  = "";
                    newSpeaker.Bio         = speakerJSON.bio;
                    //newSpeaker.Website = speakerJSON.website_url;
                    newSpeaker.Company = speakerJSON.company_name;
                    //newSpeaker.LinkedIn = speakerJSON.linkedin_url;
                    Eventarin.Core.App.Database.AddSpeaker(newSpeaker);
                    //App.Database.AddSession(newSession);
                    //	Eventarin.Core.App.Database.SaveSession(newSession);
                }
            };

            wc.DownloadStringAsync(getUrl);
        }
Example #16
0
 private void appbar_button1_Click(object sender, EventArgs e)
 {
     listdata.Visibility = Visibility.Collapsed;
     listdata2.Visibility = Visibility.Collapsed;
     listdata3.Visibility = Visibility.Collapsed;
     loadtext.Visibility = Visibility.Visible;
     pgbar.Visibility = Visibility.Visible;
     var item = (PivotItem)title.SelectedItem;
     string header = (string)item.Header;
     if (header == "recent")
     {
         string url = String.Format("https://graph.facebook.com/me/home?access_token={0}", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
     else if (header == "inbox")
     {
         string url = String.Format("https://api.facebook.com/method/message.getThreadsInFolder?access_token={0}&format=json", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler2);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
     else if (header == "my")
     {
         string url = String.Format("https://graph.facebook.com/me/feed?access_token={0}", (string)settings["facebook_token"]);
         WebClient wc = new WebClient();
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_openHandler3);
         wc.DownloadStringAsync(new Uri(url), UriKind.Absolute);
     }
 }
        public void DownloadFeedsAsync(ICollection<FeedSource> feedSources, 
                                   Action<DownloadFeedResults> downloadCompletedCallback)
        {
            if (feedSources == null)
            throw new ArgumentNullException("feedSources");
              if (downloadCompletedCallback == null)
            throw new ArgumentNullException("downloadCompletedCallback");

              this._FeedSources = feedSources;
              this._DownloadCompletedCallback = downloadCompletedCallback;

              ObservableCollection<FeedItem> retFeeds = new ObservableCollection<FeedItem>();
              foreach (var source in feedSources)
              {
            if (source.Downloaded)
              continue;
            try
            {
              WebClient wc = new WebClient();
              wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
              wc.DownloadStringAsync(new Uri(source.UriString), source); //pass the source itself as the token
            }
            catch (UriFormatException e)
            {
              //todo left off here.  almost got "add" working.  throwing bad uri exception.
              Services.Log("Uri Format Exception: " + source.UriString,
                       LogPriority.Medium,
                       LogCategory.Exception);
              source.Downloaded = true;
            }
              }
        }
Example #18
0
 /// <summary>
 /// при нажатии происходит отправка сообщения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UIElement_OnTap(object sender, GestureEventArgs e)
 {
     var message = box.Text;
     WebClient wc = new WebClient();
     string uri = string.Format("https://api.vk.com/method/wall.post.xml?owner_id={0}&message={1}&access_token={2}", App.IdUser, message, App.AccessToken);
     wc.DownloadStringAsync(new Uri(uri));
 }
Example #19
0
        public void MakeRequest(Uri url, Action <HttpResponse> onSuccess, Action <ApiException> onError)
        {
            var client = new HttpClient();

            //client.Headers[HttpRequestHeader.UserAgent] = "Stacky";
#if !SILVERLIGHT
            client.Headers[HttpRequestHeader.AcceptEncoding] = "gzip";
            client.Encoding = Encoding.UTF8;
            client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
            client.DownloadDataAsync(url, new RequestContext {
                Url = url, OnSuccess = onSuccess, OnError = onError
            });
#else
#if WINDOWSPHONE
            client.OpenReadAsync(url, new RequestContext {
                Url = url, OnSuccess = onSuccess, OnError = onError
            });
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(client_OpenReadCompleted);
#else
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
            client.DownloadStringAsync(url, new RequestContext {
                Url = url, OnSuccess = onSuccess, OnError = onError
            });
#endif
#endif
        }
Example #20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        /// <param name="toLan"></param>
        public static void TranslateText(string text)
        {
            string url = String.Format("https://translate.yandex.net/api/v1.5/tr/translate?key=trnsl.1.1.20130705T160728Z.596402f47ebcdea5.4ead85cdbf60447496e060a9c48dd9dd11867621&lang=es-en&text={0}",text);

            WebClient client = new WebClient();
            client.DownloadStringCompleted += (sender,e) =>
                {
                    string traducedTextXml = e.Result;
                    XDocument xDoc = XDocument.Parse(traducedTextXml);

                    var traducedText =
                        (
                            from t in xDoc.Descendants("text")
                            select t.Value
                        ).FirstOrDefault();

                    if (TranslationService.TranslationCompleted != null)
                    {
                        string[] result = { traducedText, text };
                        TranslationService.TranslationCompleted(null, new GenericEventArgs(result));
                    }

                };

            client.DownloadStringAsync(new Uri(url));
        }
        private void ui_pregas_LostFocus(object sender, RoutedEventArgs e)
        {
            ui_chargeBusy.IsBusy = true;
            string userid = f_userid.Text;
            string pregas = ui_pregas.Text;
            string usertype = f_usertype.Text;
            string f_filiale = ui_filiale.Text;
            if (userid.Equals(""))
            {
                MessageBox.Show("请先读卡!");
                ui_chargeBusy.IsBusy = false;
                return;
            }
            else if (pregas.Equals(""))
            {
                MessageBox.Show("请输入预购气量!");
                ui_chargeBusy.IsBusy = false;
                return;
            }
            WebClientInfo wci = (WebClientInfo)Application.Current.Resources["chargeserver"];
            string str = wci.BaseAddress + "/num/" + userid + "/" + pregas + "/" + f_filiale + "?uuid=" + System.Guid.NewGuid().ToString();
            Uri uri = new Uri(str);
            WebClient client = new WebClient();
            client.DownloadStringCompleted += client_DownloadStringCompleted;
            client.DownloadStringAsync(uri);

        }
Example #22
0
 public void downloadContent(string url)
 {
     WebClient contentDownloader = new WebClient();
     contentDownloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(contentDownloader_DownloadStringCompleted);
     contentDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     contentDownloader.DownloadStringAsync(new Uri(url));
 }
Example #23
0
 public void downloadGuide(string url)
 {
     WebClient guideDownloader = new WebClient();
     guideDownloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(guideDownloader_DownloadStringCompleted);
     guideDownloader.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
     guideDownloader.DownloadStringAsync(new Uri(url));
 }
Example #24
0
        public static string GetSessionDetail(int sessionId)
        {
            var url = "http://itpalooza.com/api/request.php?action=getSessionDetails&id=3519";
            //var url = "http://itpalooza.com/api/request.php?action=getSessions";
            var sesionDetails = "Details for " + url;
            var getUrl        = new System.Uri(url);

            var wc = new System.Net.WebClient();

            wc.Headers ["USER-AGENT"]   = "Eventarin ITPalooza HTTP client";
            wc.DownloadStringCompleted += (sender, e) =>
            {
                var v = e.Result;

                //	EventRepository.ClearSessions();
                var json = Newtonsoft.Json.JsonConvert.DeserializeObject <Data.Sessions.RootObject> (v);
                foreach (Data.Sessions.Result session in json.result)
                {
                    Session newSession = new Session();
                    newSession.Title  = session.title;
                    newSession.Begins = session.start;
                    newSession.Ends   = session.end;
                    //	newSession.Location = "Main Hall";
                    //		newSession.Abstract = "abstract for session";

                    //		App.Database.AddSession(newSession);
                }
            };

            wc.DownloadStringAsync(getUrl);

            return(sesionDetails);
        }
 private void LoadUrl()
 {
     WebClient clientlistrapot = new WebClient();
     clientlistrapot.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadRapot);
     clientlistrapot.DownloadStringAsync(new Uri(URL.BASE3 + "api/rapotanakasuh/rapotanakasuh.php?id_donatur=" + Navigation.navIdLogin));
     string id = Navigation.navIdLogin;
 }
 public void GetProjects(string rootUrl, string userName, string password, GetProjectsCompleteDelegate complete, Action<Exception> onError)
 {
     WebClient webClient = new WebClient
     {
         Credentials = new NetworkCredential(userName, password)
     };
     rootUrl = GetRootUrl(rootUrl);
     var projectUrl = new Uri(rootUrl + "/json/builders");
     webClient.DownloadStringCompleted += (s, e) =>
     {
         try
         {
             JavaScriptSerializer serializer = new JavaScriptSerializer();
             Dictionary<string, BuildBotBuildersJSONQuery> builders = serializer.Deserialize<Dictionary<string, BuildBotBuildersJSONQuery>>(e.Result);
             var builds = new List<BuildBotBuildDefinition>();
             foreach (KeyValuePair<string, BuildBotBuildersJSONQuery> kvp in builders)
             {
                 var buildurl = new Uri(rootUrl + "/json/builders/" + kvp.Key );
                 builds.Add( new BuildBotBuildDefinition(buildurl.ToString(), kvp.Key ) );
             }
             complete(builds.ToArray());
         }
         catch (Exception ex)
         {
             _log.Error("Error connecting to server", ex);
             onError(ex);
         }
     };
     webClient.DownloadStringAsync(projectUrl);
 }
Example #27
0
        public void read_api(string content_id)
        {
            WebClient myService = new WebClient();
            url = null;
            try
            {
                if (content_id != null)
                {
                    SetLoadingPanelVisibility(true);

                    url = "http://mstage.truelife.com/api_movietv/drama/music?method=getinfo&content_id=";


                    Debug.WriteLine(url + content_id);

                    myService.DownloadStringAsync(new Uri(url + content_id));
                    myService.DownloadStringCompleted += new DownloadStringCompletedEventHandler(GetTotal_Completed);
                }
                else
                {
                    throw new Exception("Content id is NULL !");
                }

            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
Example #28
0
        /// <summary>
        /// Download text from a URL.
        /// A promise is returned that is resolved when the download has completed.
        /// The promise is rejected if an error occurs during download.
        /// </summary>
        static IPromise<string> Download(string url)
        {
            Console.WriteLine("Downloading " + url + " ...");

            var promise = new Promise<string>();
            using (var client = new WebClient())
            {
                client.DownloadStringCompleted +=
                    (s, ev) =>
                    {
                        if (ev.Error != null)
                        {
                            Console.WriteLine("An error occurred... rejecting the promise.");

                            // Error during download, reject the promise.
                            promise.Reject(ev.Error);
                        }
                        else
                        {
                            Console.WriteLine("... Download completed.");

                            // Downloaded completed successfully, resolve the promise.
                            promise.Resolve(ev.Result);
                        }
                    };

                client.DownloadStringAsync(new Uri(url), null);
            }
            return promise;
        }
Example #29
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     //När knappen "Sök" trycks så skickas en GET request
     WebClient webClient = new WebClient();
     webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
     webClient.DownloadStringAsync(new Uri("http://yourmoneyisnowmymoney.com/api/zipcodes/?zipcode=" + TextBoxSearch.Text));
 }
Example #30
0
        private void LoadIsolatedStorage()
        {
            if (isoData.Contains("lstSessions"))
            {
                lstSessions = (List<Models.Sessions>)isoData["lstSessions"];
                Dispatcher.BeginInvoke(DisplaySessions);
            }
            else
            {
                lstSessions = new List<Models.Sessions>();
                isoData.Add("lstSessions", lstSessions);
            }

            if (isoData.Contains("lastPulledSessions"))
            {
                lastPulled = (DateTime)isoData["lastPulledSessions"];
            }

            isoData.Save();

            if (NetworkInterface.GetIsNetworkAvailable() && lastPulled.AddDays(1) <= DateTime.Now)
            {
                var wc = new WebClient();
                wc.DownloadStringCompleted += this.DownloadStringCompleted;
                wc.DownloadStringAsync(new Uri("http://www.chicagocodecamp.com/api/Sessions/" + EventId + "?json=true", UriKind.RelativeOrAbsolute));
            }
        }
Example #31
0
        private async void checkForUpdates()
        {
            using (WebClient wc = new WebClient())
            {
                wc.DownloadStringCompleted += (sender, e) =>
                {
                    if (e.Error != null)
                    {
                        processTooltip.Text = "Update Checker Timed Out :(";
                    }
                    else
                    {
                        string versionString = e.Result;
                        string[] versions = versionString.Split('.');
                        int[] intver = new int[versions.Length];

                        for (int i = 0; i < versions.Length; i++)
                        {
                            string ver = versions[i];
                            int veri;
                            if (Int32.TryParse(ver, out veri))
                            {
                                intver[i] = veri;
                            }
                            else
                            {
                                intver[i] = 0;
                            }
                        }
                        newVersionAvailableToolStripMenuItem.Visible = compareVersionAndCheckIfNewer(intver);
                    }
                };
                wc.DownloadStringAsync(new Uri("http://android.itachi1706.com/apps/updates/MoodleHelper"));
            }
        }
 public void RegisterUser(string Name)
 {
     Uri xmlUri = new Uri(srvStr + "AddUser?u=" + Name);
     WebClient uFeed = new WebClient();
     uFeed.DownloadStringCompleted += new DownloadStringCompletedEventHandler(uFeed_DownloadStringCompleted);
     uFeed.DownloadStringAsync(xmlUri);
 }
 public void AddQuestion(string Question)
 {
     Uri xmlUri = new Uri(srvStr + "AddQuestion?q=" + Question);
     WebClient aqFeed = new WebClient();
     aqFeed.DownloadStringCompleted += new DownloadStringCompletedEventHandler(aqFeed_DownloadStringCompleted);
     aqFeed.DownloadStringAsync(xmlUri);
 }
Example #34
0
        public void LookupProduct(string upc, Action<Models.ScanditProduct> onComplete)
        {
            var wc = new WebClient();
            wc.DownloadStringCompleted += (s, e) =>
            {
                Models.ScanditProduct product = null;

                try { product =	Newtonsoft.Json.JsonConvert.DeserializeObject<Models.ScanditProduct>(e.Result); }
                catch { }

                if (onComplete != null)
                    onComplete(product);
            };

            string data = string.Empty;

            try
            {
                wc.DownloadStringAsync(new Uri(string.Format("https://api.scandit.com/v1/products/{0}?key={1}", upc, SCANDIT_API_KEY)));
            }
            catch
            {
                if (onComplete != null)
                    onComplete(null);
            }
        }
Example #35
0
        //download note
        private void DoWebClient()
        {
            if (ezNoteID.Text == "")
            {

                MessageBoxResult res = MessageBox.Show(" Please fill in ezNote ID first", "ezNote ID Not found", MessageBoxButton.OK);

                if (res == MessageBoxResult.OK)
                {
                    
                }

                
            }
            else
            {
                showProgress();

                WebClient webClient = new WebClient();
                webClient.DownloadStringAsync(new Uri("http://www.thisco.de/eznote/decoderxml.php?decode=" + ezNoteID.Text));
                webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_OpenReadCompleted);

                
                Debug.WriteLine("http://www.thisco.de/eznote/decoderxml.php?decode=" + ezNoteID.Text);
                Debug.WriteLine("Do Web Client()");
            }

        }
Example #36
0
        public void LookupProduct(string upc, Action<ScanditProduct> onComplete)
        {
            var wc = new WebClient();
            wc.DownloadStringCompleted += (s, e) =>
                {
                    ScanditProduct product = null;

                    try
                    {
                        product = JsonConvert.DeserializeObject<ScanditProduct>(e.Result);
                    }
                    catch (Exception)
                    {
                    }

                    if (onComplete != null)
                        onComplete(product);
                };

            try
            {
                wc.DownloadStringAsync(
                    new Uri(string.Format("https://api.scandit.com/v1/products/{0}?key={1}", upc, Config.SCANDIT_API_KEY)));
            }
            catch
            {
                if (onComplete != null)
                    onComplete(null);
            }
        }
Example #37
0
 public void GETAsync(string url, Action <string> callback)
 {
     using (System.Net.WebClient client = new System.Net.WebClient()) {
         client.Headers[HttpRequestHeader.UserAgent] = UserAgent;
         client.DownloadStringCompleted += (s, e) => callback.Invoke(e.Result);
         client.DownloadStringAsync(new Uri(url));
     }
 }
Example #38
0
        private void FillSampleChartData()
        {
            Uri dataURI = new Uri(System.Windows.Browser.HtmlPage.Document.DocumentUri, "DataSources/telemetry.csv");

            System.Net.WebClient dataRetriever = new System.Net.WebClient();
            dataRetriever.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(dataRetriever_DownloadStringCompleted);
            dataRetriever.DownloadStringAsync(dataURI);
        }
Example #39
0
        public void RSPEC_WebClient(string address, Uri uriAddress, byte[] data,
                                    NameValueCollection values)
        {
            System.Net.WebClient webclient = new System.Net.WebClient();

            // All of the following are Questionable although there may be false positives if the URI scheme is "ftp" or "file"
            //webclient.Download * (...); // Any method starting with "Download"
            webclient.DownloadData(address);                            // Noncompliant
            webclient.DownloadDataAsync(uriAddress, new object());      // Noncompliant
            webclient.DownloadDataTaskAsync(uriAddress);                // Noncompliant
            webclient.DownloadFile(address, "filename");                // Noncompliant
            webclient.DownloadFileAsync(uriAddress, "filename");        // Noncompliant
            webclient.DownloadFileTaskAsync(address, "filename");       // Noncompliant
            webclient.DownloadString(uriAddress);                       // Noncompliant
            webclient.DownloadStringAsync(uriAddress, new object());    // Noncompliant
            webclient.DownloadStringTaskAsync(address);                 // Noncompliant

            // Should not raise for events
            webclient.DownloadDataCompleted   += Webclient_DownloadDataCompleted;
            webclient.DownloadFileCompleted   += Webclient_DownloadFileCompleted;
            webclient.DownloadProgressChanged -= Webclient_DownloadProgressChanged;
            webclient.DownloadStringCompleted -= Webclient_DownloadStringCompleted;


            //webclient.Open * (...); // Any method starting with "Open"
            webclient.OpenRead(address);
//          ^^^^^^^^^^^^^^^^^^^^^^^^^^^   {{Make sure that this http request is sent safely.}}
            webclient.OpenReadAsync(uriAddress, new object());              // Noncompliant
            webclient.OpenReadTaskAsync(address);                           // Noncompliant
            webclient.OpenWrite(address);                                   // Noncompliant
            webclient.OpenWriteAsync(uriAddress, "STOR", new object());     // Noncompliant
            webclient.OpenWriteTaskAsync(address, "POST");                  // Noncompliant

            webclient.OpenReadCompleted  += Webclient_OpenReadCompleted;
            webclient.OpenWriteCompleted += Webclient_OpenWriteCompleted;

            //webclient.Upload * (...); // Any method starting with "Upload"
            webclient.UploadData(address, data);                           // Noncompliant
            webclient.UploadDataAsync(uriAddress, "STOR", data);           // Noncompliant
            webclient.UploadDataTaskAsync(address, "POST", data);          // Noncompliant
            webclient.UploadFile(address, "filename");                     // Noncompliant
            webclient.UploadFileAsync(uriAddress, "filename");             // Noncompliant
            webclient.UploadFileTaskAsync(uriAddress, "POST", "filename"); // Noncompliant
            webclient.UploadString(uriAddress, "data");                    // Noncompliant
            webclient.UploadStringAsync(uriAddress, "data");               // Noncompliant
            webclient.UploadStringTaskAsync(uriAddress, "data");           // Noncompliant
            webclient.UploadValues(address, values);                       // Noncompliant
            webclient.UploadValuesAsync(uriAddress, values);               // Noncompliant
            webclient.UploadValuesTaskAsync(address, "POST", values);
//          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

            // Should not raise for events
            webclient.UploadDataCompleted   += Webclient_UploadDataCompleted;
            webclient.UploadFileCompleted   += Webclient_UploadFileCompleted;
            webclient.UploadProgressChanged -= Webclient_UploadProgressChanged;
            webclient.UploadStringCompleted -= Webclient_UploadStringCompleted;
            webclient.UploadValuesCompleted -= Webclient_UploadValuesCompleted;
        }
Example #40
0
 private static void DownloadAsStringASync(string url, Action <object, DownloadStringCompletedEventArgs> callback)
 {
     SetCertificate();
     using (var wc = new System.Net.WebClient())
     {
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(callback);
         wc.DownloadStringAsync(new Uri(url));
     }
 }
Example #41
0
        private void CheckUpdate()
        {
            string url = @"https://github.com/Dnawrkshp/ty-1-tools/wiki/update";

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var client = new System.Net.WebClient();

            client.DownloadStringCompleted += Client_DownloadStringCompleted;
            client.DownloadStringAsync(new Uri(url));
        }
Example #42
0
 private static void DownloadAsStringASync(string url, Action <object, DownloadStringCompletedEventArgs> callback)
 {
     SetCertificate();
     using (var wc = new System.Net.WebClient())
     {
         wc.Headers["User-Agent"]    = "Mozilla/4.0 (Compatible; Windows NT 5.1; MSIE 6.0)";
         wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(callback);
         wc.DownloadStringAsync(new Uri(url));
     }
 }
        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            dateTime.Text = "Last Time Updated: " + DateTime.Now.ToShortTimeString();

            if (!App.ViewModel.IsDataLoaded)
            {
                string hungryHokieLink      = "http://hungryhokie.com/api/retrieve.php?pid=ajn123&password=uGyaH4ob068Qs4V";
                System.Net.WebClient client = new System.Net.WebClient();
                client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                client.DownloadStringAsync(new Uri(hungryHokieLink));
            }
        }
Example #44
0
 public static void Trigger()
 {
     try
     {
         var uri = new Uri(baseUrl + "GUILocator");
         using (var client = new System.Net.WebClient())
             client.DownloadStringAsync(uri);
     }
     catch
     {
     }
 }
Example #45
0
        private void Button1_Click(object sender, EventArgs e)
        {
            Button1.Image = ESA_AC.Properties.Resources.login_active;

            if (TextBox1.Text.Equals("e-mail") || TextBox1.Text.Length == 0 || TextBox1.Text.Equals("") || TextBox1.Text.Equals(" "))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Please insert a e-mail!";
                ef.Show();
                return;
            }

            if (TextBox2.Text.Equals("password") || TextBox2.Text.Length == 0 || TextBox2.Text.Equals("") || TextBox2.Text.Equals(" "))
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "Please insert a password!";
                ef.Show();
                return;
            }

            if (File.Exists(Core.AppPath + "mymail.txt") == true)
            {
                File.Delete(Core.AppPath + "mymail.txt");
            }

            File.WriteAllText(Core.AppPath + "mymail.txt", TextBox1.Text);

            if (checkBox1.Checked == true)
            {
                byte[] tobytes  = ASCIIEncoding.ASCII.GetBytes(TextBox2.Text);
                string tobase64 = System.Convert.ToBase64String(tobytes);
                File.WriteAllText(Core.AppPath + "mypassword.txt", tobase64);
            }

            try
            {
                WebProxy proxy = WebProxy.GetDefaultProxy();
                proxy.UseDefaultCredentials = true;
                System.Net.WebClient WC = new System.Net.WebClient();
                WC.Proxy = proxy;
                string hash          = Core.SHA1Encoder.EncodeHash(TextBox2.Text);
                string requestString = GlobalSettings.Website_URL + "/login.php?email=" + TextBox1.Text + "&password="******"Unable to login!";
                ef.Show();
            }
        }
Example #46
0
        void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                switch (TextHandling.Parse(e.Result)) // todo again later on
                {
                case 0:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Invalid username/password!";
                    ef.Show();
                    break;
                }

                case 1:     // Login successful
                {
                    WebProxy proxy = WebProxy.GetDefaultProxy();
                    proxy.UseDefaultCredentials = true;
                    System.Net.WebClient WC = new System.Net.WebClient();
                    string requestString    = GlobalSettings.Website_URL + "/getuser.php?email=" + TextBox1.Text;
                    WC.Proxy = proxy;
                    ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                    WC.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WC_DownloadStringCompleted2);
                    WC.DownloadStringAsync(new Uri(requestString));
                    break;
                }

                case 3:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "Database not found.";
                    ef.Show();
                    break;
                }

                case 4:
                {
                    ErrorForm ef = new ErrorForm();
                    ef.label2.Text = "User table not found.";
                    ef.Show();
                    break;
                }
                }
            }

            catch (Exception)
            {
                ErrorForm ef = new ErrorForm();
                ef.label2.Text = "A unknown error occurred!";
                ef.Show();
            }
        }
Example #47
0
        internal void createFolder(int arg, string username, string game, string matchid)
        {
            WebProxy proxy = WebProxy.GetDefaultProxy();

            proxy.UseDefaultCredentials = true;
            System.Net.WebClient WC = new System.Net.WebClient();
            string requestString    = GlobalSettings.Website_URL + "/folders.php?arg=" + arg + "&username="******"&game=" + game + "&matchid=" + matchid;

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            WC.Proxy = proxy;
            WC.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WC_DownloadStringCompleted);
            WC.DownloadStringAsync(new Uri(requestString));
        }
 public void LoadTelemetry()
 {
     if (TelemetryInfo.TelemetryUri == null)
     {
         return;
     }
     if (!IsTelemetryLoaded && !IsTelemetryLoading)
     {
         var _telemetry = new List <Telemetry>();
         IsTelemetryLoading = true;
         var dataRetriever = new System.Net.WebClient();
         dataRetriever.DownloadStringCompleted += (sender, e) =>
         {
             ThreadPool.QueueUserWorkItem(new WaitCallback(obj =>
             {
                 using (var reader = new StringReader(e.Result))
                 {
                     string line;
                     while ((line = reader.ReadLine()) != null)
                     {
                         try
                         {
                             _telemetry.Add(Models.Telemetry.Parse(line));
                         }
                         catch
                         {
                             continue;
                         }
                     }
                 }
                 IsTelemetryLoading = false;
                 Telemetry          = _telemetry;
                 IsTelemetryLoaded  = true;
                 if (TelemetryLoaded != null)
                 {
                     TelemetryLoaded(this, EventArgs.Empty);
                 }
             }));
         };
         dataRetriever.DownloadStringAsync(TelemetryInfo.TelemetryUri);
     }
     else
     {
         if (TelemetryLoaded != null)
         {
             TelemetryLoaded(this, EventArgs.Empty);
         }
         FirePropertyChanged("Telemetry");
     }
 }
    static void setGitVersion()
    {
        ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); });

        string siteURL = @"https://raw.githubusercontent.com/DeathGameDev/Unity-Utils/master/Assets/Utils/Etc/version.txt";

        System.Net.WebClient wc = new System.Net.WebClient();
        gitVersion = "Pinging...";
        //Download the file to a temp dir
        wc.DownloadStringAsync(new System.Uri(siteURL));
        wc.DownloadStringCompleted += (sender, args) =>
        {
            gitVersion = args.Result;
            wc.Dispose();
        };
    }
Example #50
0
        static void Test0104()
        {
            var client = new System.Net.WebClient();

            //IObservable<EventPattern<object>> downloadString = Observable.FromEventPattern(client, nameof(client.DownloadStringCompleted));
            //downloadString.Subscribe(
            //    data =>
            //    {
            //        var eventArgs = (DownloadStringCompletedEventArgs)data.EventArgs;
            //        Console.WriteLine("Call Someone I download");
            //    },
            //    ex => Console.WriteLine("OnError:" + ex.Message),
            //    () => { Console.WriteLine("=============================================================Completed"); }
            //    );
            client.DownloadStringCompleted += (e, s) => { Console.WriteLine("hhh"); };
            client.DownloadStringAsync(new Uri("http://www.baidu.com"));
        }
Example #51
0
 public _DownloadText(string uri, double timeout, Fun2 <Exception, string, Unit> cb)
 {
     entry     = Primitive.GetEventloopEntry();
     webClient = new System.Net.WebClient();
     try {
         webClient.DownloadStringCompleted += (object sender, System.Net.DownloadStringCompletedEventArgs e) => {
             if (entry != null)
             {
                 entry.Post(() => cb.Call(e.Error, (e.Error != null ? "" : e.Result)));
                 entry = null;
             }
             Dispose();
         };
         webClient.DownloadStringAsync(new Uri(uri));
     }
     catch (Exception exn) {
         Dispose();
         throw exn;
     }
 }
        private void btnGet_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Uri uri = null;

            try{ uri = new System.Uri(host.UI.tbUri.Text); }
            catch (Exception) { MessageBox.Show("Bad URI format!"); return; }

            host.UI.tagLst.Items.Clear();
            host.UI.favUri.Text = "";

            uSite = uri;
            host.UI.tbUri.Text = uSite.ToString();

            host.UI.tip3.Visibility = System.Windows.Visibility.Collapsed;

            System.Net.WebClient client = new System.Net.WebClient();
            client.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(client_DownloadStringCompleted);

            client.DownloadStringAsync(uSite);

            host.UI.prsBar.Visibility = System.Windows.Visibility.Visible;
        }
Example #53
0
        public static void RefreshLocalSessions()
        {
            var url    = "http://itpalooza.com/api/request.php?action=getSessions";
            var getUrl = new System.Uri(url);

            var wc = new System.Net.WebClient();

            wc.Headers ["USER-AGENT"]   = "Eventarin ITPalooza HTTP client";
            wc.DownloadStringCompleted += (sender, e) =>
            {
                var v = e.Result;


                Eventarin.Core.App.Database.DeleteSessions();
                var json = Newtonsoft.Json.JsonConvert.DeserializeObject <Data.Sessions.RootObject> (v);
                foreach (Data.Sessions.Result sessionJSON in json.result)
                {
                    Session newSession = new Session();
                    newSession.Id       = int.Parse(sessionJSON.id);
                    newSession.Title    = sessionJSON.title;
                    newSession.Begins   = sessionJSON.start;
                    newSession.Ends     = sessionJSON.end;
                    newSession.Location = sessionJSON.location;
                    newSession.Abstract = sessionJSON.content;


                    newSession.Track      = sessionJSON.track;
                    newSession.Sponsor    = sessionJSON.sponsor;
                    newSession.Speakers   = sessionJSON.speakers;
                    newSession.Speaker_Id = sessionJSON.speaker_id;

                    Eventarin.Core.App.Database.AddSession(newSession);
                    //App.Database.AddSession(newSession);
                    //	Eventarin.Core.App.Database.SaveSession(newSession);
                }
            };

            wc.DownloadStringAsync(getUrl);
        }
 // Get public IP from ipify.org.
 private void GetPublicIP()
 {
     publicIP_Text.Text = "...";
     webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(PublicIP_DownloadStringCompleted);
     webClient.DownloadStringAsync(new Uri("https://api.ipify.org"));
 }
        public void StartScript(int intScriptLine)
        {
            string strUri = string.Format("{0}script?run{1:000}", DeviceUri, intScriptLine);

            WebRequest.DownloadStringAsync(new Uri(strUri), null);
        }
        void checkForDataChange()
        {
            try
            {
                bool update = false;

                if (appSettings.useBing)
                {
                    System.Diagnostics.Debug.WriteLine(DateTime.Now.Subtract(lastbing).Hours);

                    if (DateTime.Now.Subtract(lastbing).Hours > 6)
                    {
                        lastbing = DateTime.Now;
                        updateBingWallpaper();
                        bingUpdateStatePending = true;
                    }
                }


                if (bingUpdateStatePending)
                {
                    return;
                }

                if (appSettings.chkSMS)
                {
                    int count = 0;
                    instance.getUnreadSMSCount(out count);

                    if (count != lastSMSCount)
                    {
                        string data = instance.getLatestSMS();
                        lastSMSBody = data.Substring(data.IndexOf(":") + 1);
                        string number = data.Substring(0, data.IndexOf(":"));

                        Microsoft.Phone.UserData.Contacts cc = new Microsoft.Phone.UserData.Contacts();
                        cc.SearchCompleted += new EventHandler <Microsoft.Phone.UserData.ContactsSearchEventArgs>((object o, Microsoft.Phone.UserData.ContactsSearchEventArgs e) =>
                        {
                            if (e.Results.Count() > 0)
                            {
                                lastSMSFrom = e.Results.First().DisplayName;
                            }
                            else
                            {
                                lastSMSFrom = number;
                            }
                            updateWidgets();
                        });
                        cc.SearchAsync(number, Microsoft.Phone.UserData.FilterKind.PhoneNumber, null);

                        lastSMSCount = count;
                    }
                }

                if (appSettings.chkWeather)
                {
                    if (weatherdata == 1)
                    {
                        weatherdata = 0;

                        string query = "http://weather.yahooapis.com/forecastrss?w=" + appSettings.woeid + "&nocache=" + DateTime.Now.Millisecond.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString();

                        System.Diagnostics.Debug.WriteLine(query);

                        WebClient cl = new System.Net.WebClient();
                        cl.DownloadStringAsync(new Uri(query));
                        cl.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(cl_DownloadStringCompleted);

                        return;
                    }
                }


                if (counter > 400)
                {
                    updateWidgets();
                    counter = 1;
                    if (weatherdata == 0)
                    {
                        weatherdata = 1;
                    }
                }

                if (lastSMSCount == 0 && counter == 0 && appSettings.chkWeather == false) // first time thing
                {
                    updateWidgets();
                }

                counter++;
            }
            catch (Exception ex)
            {
                msgbox("Actual Exception in checkForDataChange(): " + ex.Message);
            }
        }
Example #57
0
        private void Processing(bool signinoffice, List <DocumentAttributes> listd, string selecteddoctype, string includestd, string mergesurcharge, string selectedrecipientsname, string selectedrecipientsemail, string selectedOrder, string actionstring, string selectedsortorder)
        {
            string methodid  = (cboMethod.SelectedItem as DocuSignMethod).MethodID.ToString();
            string emailbody = txtbody.Text.Replace(Environment.NewLine, "~!~").Replace("\n", "~!~").Replace("\r", "~!~");

            try
            {
                if (signinoffice)
                {
                    MessageBoxResult result = MessageBox.Show("Are you sure you want to sign the document now?", "Confirmation", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        foreach (DocumentAttributes da in listd)
                        {
                            if ((da.EnvelopeID == null || da.EnvelopeID == "" || da.EnvelopeID == Guid.Empty.ToString()) && da.IntegrationID != "0" && !da.Status.ToLower().Contains("voided"))
                            {
                                BusyIndicator1.IsBusy = false;
                                MessageBox.Show("Please wait until the document has been integrated to Docusign.");
                            }
                            else
                            {
                                if (da.VersionType.ToUpper().Contains("CUSTOMER"))
                                {
                                    Uri uri = new Uri("../PrintEstimateNewTemplate.aspx?merge=" + mergesurcharge + "&type=customer&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=signinoffice" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&methods=" + actionstring + "&envelopeid=" + da.EnvelopeID + "&sortorder=" + selectedsortorder + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                    BusyIndicator1.IsBusy = false;
                                    System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank", "toolbar=0,menubar=1,location=0,status=0,top=0,left=0,resizable=1");
                                }
                                else if (da.VersionType.ToUpper().Contains("STUDIO"))
                                {
                                    BusyIndicator1.IsBusy = true;
                                    Uri uri = new Uri("../PrintEstimateStudioMTemplate.aspx?merge=" + mergesurcharge + "&type=studiom&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=signinoffice" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&sortorder=" + selectedsortorder + "&methods=" + actionstring + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                    BusyIndicator1.IsBusy = false;
                                    System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank", "toolbar=0,menubar=1,location=0,status=0,top=0,left=0,resizable=1");
                                }
                                else if (da.VersionType.ToUpper().Contains("VARIATION"))
                                {
                                    BusyIndicator1.IsBusy = true;
                                    Uri uri = new Uri("../PrintVariation.aspx?merge=" + mergesurcharge + "&type=variation&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=signinoffice" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&sortorder=" + selectedsortorder + "&methods=" + actionstring + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                    BusyIndicator1.IsBusy = false;
                                    System.Windows.Browser.HtmlPage.Window.Navigate(uri, "_blank", "toolbar=0,menubar=1,location=0,status=0,top=0,left=0,resizable=1");
                                }
                                else
                                {
                                    BusyIndicator1.IsBusy = false;
                                }
                            }
                        }
                        CloseRadWindow();
                    }
                    else
                    {
                        BusyIndicator1.IsBusy = false;
                    }
                }
                else
                {
                    foreach (DocumentAttributes da in listd)
                    {
                        //if (!ValidateSginRemote(da, methodid, out errormessage))
                        //{
                        //    MessageBox.Show(errormessage);
                        //    return;
                        //}
                        //else
                        //{
                        foreach (var item2 in ((DocuSignViewModel)LayoutRoot.DataContext).DocuSignStatus)
                        {
                            if (item2.Selected)
                            {
                                if (methodid == "0")
                                {
                                    item2.status = "Sent";
                                }
                                else if (methodid == "1")
                                {
                                    item2.status = "Voided";
                                }
                                item2.statusChangedDateTime = DateTime.Now.ToString("dd/MM/yyyy");
                            }
                        }
                        //}
                        if (methodid == "0")
                        {
                            if (da.VersionType.ToUpper().Contains("CUSTOMER"))
                            {
                                BusyIndicator1.IsBusy = true;
                                Uri uri = new Uri("../PrintEstimateNewTemplate.aspx?merge=" + mergesurcharge + "&type=customer&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=SendViaDocuSign" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&sortorder=" + selectedsortorder + "&methods=" + actionstring + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                System.Net.WebClient client = new System.Net.WebClient();
                                client.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                                client.DownloadStringAsync(uri);
                            }
                            else if (da.VersionType.ToUpper().Contains("STUDIO"))
                            {
                                BusyIndicator1.IsBusy = true;
                                Uri uri = new Uri("../PrintEstimateStudioMTemplate.aspx?merge=" + mergesurcharge + "&type=studiom&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=SendViaDocuSign" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&sortorder=" + selectedsortorder + "&methods=" + actionstring + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                System.Net.WebClient client = new System.Net.WebClient();
                                client.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                                client.DownloadStringAsync(uri);
                            }
                            else if (da.VersionType.ToUpper().Contains("VARIATION"))
                            {
                                BusyIndicator1.IsBusy = true;
                                Uri uri = new Uri("../PrintVariation.aspx?merge=" + mergesurcharge + "&type=variation&version=" + da.PrintType + "&documenttype=" + selecteddoctype + "&EstimateRevisionId=" + _estimateRevisionId.ToString() + "&includestd=" + includestd + "&userid=" + ((App)App.Current).CurrentUserId.ToString() + "&action=SendViaDocuSign" + "&recipients=" + selectedrecipientsname + "&recipientsemail=" + selectedrecipientsemail + "&routingorder=" + selectedOrder + "&sortorder=" + selectedsortorder + "&methods=" + actionstring + "&docusignintegration=1&emailsubject=" + txtsubject.Text + "&emailbody=" + emailbody, UriKind.Relative);
                                System.Net.WebClient client = new System.Net.WebClient();
                                client.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                                client.DownloadStringAsync(uri);
                            }
                            else
                            {
                                BusyIndicator1.IsBusy = false;
                            }
                        }
                        else
                        {
                            BusyIndicator1.IsBusy = true;

                            if (da.EnvelopeID != null && da.EnvelopeID != "" && da.EnvelopeID != Guid.Empty.ToString())
                            {
                                Uri uri = new Uri("../DocuSignVoidEnvelope.aspx?integrationid=" + da.IntegrationID.ToString() + "&envelopeid=" + da.EnvelopeID + "&username="******"&voidreason=" + txtvoidreason.Text.Replace(Environment.NewLine, "~!~").Replace("\n", "~!~").Replace("\r", "~!~"), UriKind.Relative);
                                System.Net.WebClient client = new System.Net.WebClient();
                                client.DownloadStringCompleted += new System.Net.DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                                client.DownloadStringAsync(uri);
                            }
                            else
                            {
                                DocuSignViewModel dmv = this.DataContext as DocuSignViewModel;
                                dmv.RemoveDocuSignDocumentsFromQueue(da.IntegrationID);
                                BusyIndicator1.IsBusy = false;
                                MessageBox.Show("The document has been successfully voided.");
                                CloseRadWindow();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }