Beispiel #1
0
        /// <summary>
        /// Web request for string data to the Rovio API 
        /// </summary>
        /// <param name="cmd">Command of the Rovio API to execute</param>
        /// <returns></returns>
        internal string DownloadString(string relativeUri, int timeout = 5000)
        {
            string responseString = null;
            WebDownload wc = null;
            try
            {
                wc = new WebDownload(timeout);
                wc.Credentials = this.rovioCredentials;
                wc.BaseAddress = this.rovioAddress;
                wc.Encoding = this.encoding;
                Uri targetUri = new Uri(new Uri(wc.BaseAddress), relativeUri);

                System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                responseString = wc.DownloadString(targetUri);
                stopwatch.Stop();
                if (stopwatch.ElapsedMilliseconds > 5000)
                {
                }
            }
            catch (WebException ex)
            {
                throw ex;
            }
            finally
            {
                if (wc != null)
                {
                    wc.Dispose();
                    wc = null;
                }
            }

            return responseString;
        }