public void TCPNetworkMonitor_RawSocket_SendAndReceiveData()
        {
            TCPNetworkMonitor monitor = new TCPNetworkMonitor();

            monitor.ProcessID       = (uint)Process.GetCurrentProcess().Id;
            monitor.MonitorType     = TCPNetworkMonitor.NetworkMonitorType.RawSocket;
            monitor.DataReceived   += (string connection, byte[] data) => DataReceived(connection, data);
            monitor.DataSent       += (string connection, byte[] data) => DataSent(connection, data);
            monitor.UseSocketFilter = false;

            monitor.Start();
            // start a dummy async download
            System.Net.WebClient client = new System.Net.WebClient();
            Task t = client.DownloadStringTaskAsync("http://www.google.com");

            t.Wait();

            t = client.DownloadStringTaskAsync("http://www.google.com");
            t.Wait();

            for (int i = 0; i < 100; i++)
            {
                if (dataSentCount > 1 && dataReceivedCount > 1)
                {
                    break;
                }

                System.Threading.Thread.Sleep(10);
            }

            monitor.Stop();

            Assert.IsTrue(dataReceivedCount >= 1);
            Assert.IsTrue(dataSentCount >= 1);
        }
Exemple #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            utxos.Clear();
            comboUtxo.Items.Clear();
            System.Net.WebClient wc = new System.Net.WebClient();
            listUTXO.Items.Clear();
            Dictionary <string, decimal> count = new Dictionary <string, decimal>();

            var str    = MakeRpcUrl(this.texturl.Text, "getutxo", new MyJson.JsonNode_ValueString(textaddress.Text));
            var result = await wc.DownloadStringTaskAsync(str);

            var json1 = MyJson.Parse(result).AsDict();

            if (json1.ContainsKey("error"))
            {
                return;
            }
            var json = json1["result"].AsList();

            foreach (var item in json)
            {
                UTXO txio = new UTXO();
                //var use = item.GetDictItem("vinTx").AsString();
                var hextxid = item.GetDictItem("txid").AsString();
                txio.txid = ThinNeo.Helper.HexString2Bytes(hextxid).Reverse().ToArray();

                txio.n = item.GetDictItem("n").AsInt();

                var hexasset = item.GetDictItem("asset").AsString();
                txio.asset = ThinNeo.Helper.HexString2Bytes(hexasset).Reverse().ToArray();
                var coolasset = ThinNeo.Helper.Bytes2HexString(txio.asset);
                var value     = decimal.Parse(item.GetDictItem("value").AsString());
                txio.value = value;
                //if (use == "")
                {
                    if (count.ContainsKey(coolasset) == false)
                    {
                        count[coolasset] = 0;
                    }
                    count[coolasset] += value;

                    listUTXO.Items.Add(txio.txid + "[" + txio.n + "] " + value + ":" + ThinNeo.Helper.Bytes2HexString(txio.asset));
                    comboUtxo.Items.Add(txio);
                }
                utxos.Add(txio);
                //else
                //{
                //    listUTXO.Items.Add("[已花费]" + value + ":" + asset);
                //}
            }
            listMoney.Items.Clear();
            foreach (var m in count)
            {
                listMoney.Items.Add("资产:" + m.Value + "  " + m.Key);
            }
            if (comboUtxo.Items.Count > 0)
            {
                comboUtxo.SelectedIndex = 0;
            }
        }
Exemple #3
0
        public static async Task <string[]> DownloadChannels()
        {
            var webClient = new System.Net.WebClient();
            var text      = await webClient.DownloadStringTaskAsync(new System.Uri("https://overrustlelogs.net/api/v1/channels.json"));

            return(JsonConvert.DeserializeObject <string[]>(text));
        }
        /// <summary>
        /// Returns short term forecast for location specified. Short term forecast returns
        /// weather forecast in 3 hour intervals. Forecast has entries until today's midnight
        /// and then next 4 days.
        /// </summary>
        /// <param name="location">Location</param>
        /// <returns>Short term forecast for location</returns>
        public async Task <ForecastShortTerm> GetForecastShortTerm(Location location)
        {
            CultureInfo ci  = CultureInfo.CreateSpecificCulture("en-US");
            Uri         uri = new Uri
                              (
                string.Format(ci, WEATHER_API_URI_SHORT, location.Latitude, location.Longitude)
                              );

            using (var webClient = new System.Net.WebClient())
            {
                try
                {
                    log.Debug(uri);
                    var json = await webClient.DownloadStringTaskAsync(uri);

                    return(JsonConvert.DeserializeObject <ForecastShortTerm>(json));
                }
                catch (Exception ex)
                {
                    string msg = "Problem retrieving short term forecasts";
                    log.Error(msg, ex);
                    throw new Exception(msg, ex);
                }
            }
        }
Exemple #5
0
        public static async Task <HealthCheckResult> RouteTimingHealthCheck(string routePath)
        {
            using (var client = new System.Net.WebClient())
            {
                var watch = new Stopwatch();
                watch.Start();
                var url    = $"{BaseUrl}{routePath}";
                var result = await client.DownloadStringTaskAsync(url);

                watch.Stop();
                var milliseconds    = watch.ElapsedMilliseconds;
                var healthCheckData = new Dictionary <string, object>();
                healthCheckData.Add("TimeInMS", milliseconds);
                if (milliseconds <= 1000)
                {
                    return(HealthCheckResult.Healthy($"call to  the route {routePath}", healthCheckData));
                }
                else if (milliseconds >= 1001 && milliseconds <= 2000)
                {
                    return(HealthCheckResult.Degraded($"call to  the route {routePath}", null, healthCheckData));
                }
                else
                {
                    return(HealthCheckResult.Unhealthy($"call to  the route {routePath}", null, healthCheckData));
                }
            }
        }
        public async Task <IActionResult> Index(string eventId, int puzzleId)
        {
            Event currentEvent = await EventHelper.GetEventFromEventId(context, eventId);

            PuzzleUser user = await PuzzleUser.GetPuzzleUserForCurrentUser(context, User, userManager);

            Team team = await UserEventHelper.GetTeamForPlayer(context, currentEvent, user);

            Puzzle thisPuzzle = await context.Puzzles.FirstOrDefaultAsync(m => m.ID == puzzleId);

            // Find the material file with the latest-alphabetically ShortName that contains the substring "customPage".
            var materialFile = await(from f in context.ContentFiles
                                     where f.Puzzle == thisPuzzle && f.FileType == ContentFileType.PuzzleMaterial && f.ShortName.Contains("customPage")
                                     orderby f.ShortName descending
                                     select f).FirstOrDefaultAsync();

            if (materialFile == null)
            {
                return(Content("ERROR:  There's no custom page uploaded for this puzzle"));
            }

            var materialUrl = materialFile.Url;

            // Download that material file.
            string fileContents;

            using (var wc = new System.Net.WebClient())
            {
                fileContents = await wc.DownloadStringTaskAsync(materialUrl);
            }

            // Return the file contents to the user.
            return(Content(fileContents, "text/html"));
        }
Exemple #7
0
 private async Task <string> GetUrlContents(string url)
 {
     using (var client = new System.Net.WebClient())
     {
         return(await client.DownloadStringTaskAsync(url));
     }
 }
        private async Task CanUploadRemoveFiles(ServerController controller)
        {
            var fileContent          = "content";
            var uploadFormFileResult = Assert.IsType <RedirectToActionResult>(await controller.CreateFile(TestUtils.GetFormFile("uploadtestfile.txt", fileContent)));

            Assert.True(uploadFormFileResult.RouteValues.ContainsKey("fileId"));
            var fileId = uploadFormFileResult.RouteValues["fileId"].ToString();

            Assert.Equal("Files", uploadFormFileResult.ActionName);

            var viewFilesViewModel =
                Assert.IsType <ViewFilesViewModel>(Assert.IsType <ViewResult>(await controller.Files(fileId)).Model);

            Assert.NotEmpty(viewFilesViewModel.Files);
            Assert.Equal(fileId, viewFilesViewModel.SelectedFileId);
            Assert.NotEmpty(viewFilesViewModel.DirectFileUrl);


            var net  = new System.Net.WebClient();
            var data = await net.DownloadStringTaskAsync(new Uri(viewFilesViewModel.DirectFileUrl));

            Assert.Equal(fileContent, data);

            Assert.Equal(StatusMessageModel.StatusSeverity.Success, new StatusMessageModel(Assert
                                                                                           .IsType <RedirectToActionResult>(await controller.DeleteFile(fileId))
                                                                                           .RouteValues["statusMessage"].ToString()).Severity);

            viewFilesViewModel =
                Assert.IsType <ViewFilesViewModel>(Assert.IsType <ViewResult>(await controller.Files(fileId)).Model);

            Assert.Null(viewFilesViewModel.DirectFileUrl);
            Assert.Null(viewFilesViewModel.SelectedFileId);
        }
Exemple #9
0
        public async Task GetRaces()
        {
            IsRefreshing = true;

            Races.Clear();

            string url = "http://itweb.fvtc.edu/wetzel/marathon/races/";
            string json;

            using (System.Net.WebClient webClient = new System.Net.WebClient())
            {
                json = await webClient.DownloadStringTaskAsync(url);
            }

            GetRacesApiResult result =
                Newtonsoft.Json.JsonConvert.DeserializeObject <GetRacesApiResult>(json);

            foreach (Race race in result.races)
            {
                RaceViewModel vm = new RaceViewModel(this.Navigation)
                {
                    Race = race
                };

                this.Races.Add(vm);
            }

            IsRefreshing = false;
        }
Exemple #10
0
        public static async Task <bool> CheckIfNewArtist(string add)
        {
            var data = "";

            using (System.Net.WebClient wc = new System.Net.WebClient()) {
                try {
                    data = await wc.DownloadStringTaskAsync("https://us-central1-known-origin-io.cloudfunctions.net/main/api/network/1/accounts/" + add + "/profile/simple");
                }
                catch (Exception e) {
                    Console.WriteLine(e.Message);
                    return(false);
                }
            }
            var json = JObject.Parse(data);

            if (json.Count == 1)
            {
                return(false);
            }
            if (json["enabledTimestamp"] == null)
            {
                return(false);
            }
            var enabledTS = (int)(((long)json["enabledTimestamp"]) / 1000);
            var now       = Convert.ToInt32(((DateTimeOffset)(DateTime.UtcNow)).ToUnixTimeSeconds());
            var delta     = now - enabledTS;
            var t         = 90 * 24 * 3600;

            return(delta < t);
        }
        public static async Task <string> GetHash(string address)
        {
            var webClient = new System.Net.WebClient();
            var request   = await webClient.DownloadStringTaskAsync(address);

            return(request);
        }
Exemple #12
0
        private async Task <bool> Validate(string encodedResponse, string action)
        {
            var client = new System.Net.WebClient();

            try
            {
                var googleReply = await client.DownloadStringTaskAsync(string.Format(
                                                                           "https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}",
                                                                           ReCaptchaClass.SecretKey,
                                                                           encodedResponse
                                                                           )
                                                                       );

                GoogleCaptchaResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <ReCaptchaClass>(googleReply);
                if (GoogleCaptchaResponse.Success && action == GoogleCaptchaResponse.Action)
                {
                    return(true);
                }
                else
                {
                    _logger.Log(LogLevel.Warning, "Captcha validation failed:", GoogleCaptchaResponse);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, ex, "Google Recaptcha validate failed");
                return(false);
            }
        }
Exemple #13
0
        /// <summary>
        /// rpc指令,退出electron
        /// </summary>
        /// <returns></returns>
        public async Task app_exit()
        {
            var wc  = new System.Net.WebClient();
            var str = await wc.DownloadStringTaskAsync("http://localhost:" + this.httpport_electron + "/?method=quit");

            Console.WriteLine(str);
        }
Exemple #14
0
        public async Task <SiteProdInfo> RetrieveProdInfo(Uri uri)
        {
            var url = new Uri("http://api.pouet.net/v1/prod/?id=" + uri.Segments[2]);

            using (var wc = new System.Net.WebClient())
            {
                string contents = await wc.DownloadStringTaskAsync(url);

                if (contents != null && contents.Length > 0)
                {
                    var response = JsonConvert.DeserializeObject <Response>(contents);
                    if (response.success)
                    {
                        SiteProdInfo info = new SiteProdInfo()
                        {
                            ID           = response.prod.id,
                            Name         = response.prod.name,
                            Group        = response.prod.groups?.FirstOrDefault()?.name,
                            DownloadLink = response.prod.download,
                            ReleaseDate  = response.prod.releaseDate,
                        };
                        return(info);
                    }
                }
            }
            return(null);
        }
Exemple #15
0
        public async Task <SiteProdInfo> RetrieveProdInfo(Uri uri)
        {
            var url = new Uri("http://demozoo.org/api/v1/productions/" + uri.Segments[2] + "/?format=json");

            using (var wc = new System.Net.WebClient())
            {
                string contents = await wc.DownloadStringTaskAsync(url);

                if (contents != null && contents.Length > 0)
                {
                    var response = JsonConvert.DeserializeObject <Response>(contents);
                    if (response != null && response.title != null)
                    {
                        SiteProdInfo info = new SiteProdInfo()
                        {
                            ID           = response.id,
                            Name         = response.title,
                            Group        = response.author_nicks?.FirstOrDefault()?.name,
                            DownloadLink = response.download_links?.FirstOrDefault()?.url,
                            ReleaseDate  = response.release_date,
                        };
                        return(info);
                    }
                }
            }
            return(null);
        }
Exemple #16
0
        public async void DownloadArtifactsList()
        {
            string data = await webClient.DownloadStringTaskAsync($"http://{this.Hostname}/artifacts");

            this.artifacts = JArray.Parse(data).ToList();
            if (!File.Exists($@"{this.RootPath}artifacts.json"))
            {
                this.WriteFile(data, "artifacts", "json");
            }
            else
            {
                JArray local_artifacts = JArray.Parse(File.ReadAllText($@"{this.RootPath}artifacts.json"));
                foreach (JObject obj in local_artifacts)
                {
                    JToken found    = artifacts.Find(e => e["id"].Equals(obj["id"]));
                    string filePath = $"{this.RootPath}{obj["location"].ToString()}{obj["name"].ToString()}";
                    if (found is null)
                    {
                        File.Delete(filePath);
                    }
                    else if (found["version"].Equals(obj["version"]) && File.Exists(filePath))
                    {
                        artifacts.Remove(found);
                    }
                }
                if (artifacts.Count > 0)
                {
                    this.WriteFile(data, "artifacts", "json");
                }
            }
        }
Exemple #17
0
 public async Task window_hide(int id)
 {
     Newtonsoft.Json.Linq.JArray _params = new JArray();
     _params.Add(id);
     var url = "http://localhost:" + this.httpport_electron + "/?method=window.hide&params=" + _params.ToString().Replace("\r\n", "");
     var wc  = new System.Net.WebClient();
     var str = await wc.DownloadStringTaskAsync(url);
 }
        // System.Web.Extensions.dll
        // http://localhost:1234/MyService.svc/json/4
        // http://localhost:1234/MyService.svc/xml/4
        static void Main(string[] args)
        {
            Action action = async () =>
             {
                 var stopwatch = new System.Diagnostics.Stopwatch();

                 Console.WriteLine("JSON (JavaScriptSerializer)");
                 {
                     // fetch data (as JSON string)
                     var url = new Uri("http://localhost:1234/MyService.svc/json/4");
                     var client = new System.Net.WebClient();
                     var json = await client.DownloadStringTaskAsync(url);

                     // deserialize JSON into objects
                     var serializer = new JavaScriptSerializer();
                     var data = serializer.Deserialize<JSONSAMPLE.Data>(json);

                     // use the objects
                     Console.WriteLine(data.Number);
                     foreach (var item in data.Multiples)
                         Console.Write("{0}, ", item);
                 }

                 Console.WriteLine();
                 Console.WriteLine("JSON (DataContractJsonSerializer)");
                 {
                     var url = new Uri("http://localhost:1234/MyService.svc/json/4");
                     var client = new System.Net.WebClient();
                     var json = await client.OpenReadTaskAsync(url);
                     var serializer = new DataContractJsonSerializer(typeof(DATACONTRACT.Data));
                     var data = serializer.ReadObject(json) as DATACONTRACT.Data;
                     Console.WriteLine(data.Number);
                     foreach (var item in data.Multiples)
                         Console.Write("{0}, ", item);
                 }

                 Console.WriteLine();
                 Console.WriteLine("XML");
                 {
                     var url = new Uri("http://localhost:1234/MyService.svc/xml/4");
                     var client = new System.Net.WebClient();
                     var xml = await client.DownloadStringTaskAsync(url);
                     var bytes = Encoding.UTF8.GetBytes(xml);
                     using (MemoryStream stream = new MemoryStream(bytes))
                     {
                         var serializer = new XmlSerializer(typeof(XMLSAMPLE.Data));
                         var data = serializer.Deserialize(stream) as XMLSAMPLE.Data;
                         Console.WriteLine(data.Number);
                         foreach (var item in data.Multiples)
                             Console.Write("{0}, ", item);
                     }
                 }
             };

            action.Invoke();
            Console.Read();
        }
Exemple #19
0
        /// <summary>
        /// 定义这个方法用来进行Rest调用
        /// </summary>
        /// <param name="url"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        static async Task <string> InvokeRestReqeust(string url, string token)
        {
            var client = new System.Net.WebClient();

            client.Headers.Add("Authorization", $"Bearer {token}");
            var result = await client.DownloadStringTaskAsync(url);

            return(result);//请注意,这里直接返回字符串型的结果,它是Json格式的,有兴趣的可以继续在这个基础上进行处理
        }
Exemple #20
0
        static async void DownloadBlogger()
        {
            Console.Out.WriteLine("MainProgram 下載前 on Thread No {0}", Thread.CurrentThread.ManagedThreadId);
            var client             = new System.Net.WebClient();
            var webContentHomePage = await client.DownloadStringTaskAsync("https://mylabtw.blogspot.com/");

            Console.Out.WriteLine("下載 {0} 字元", webContentHomePage.Length);
            Console.Out.WriteLine("MainProgram 下載完後 on Thread No {0} ", Thread.CurrentThread.ManagedThreadId);
        }
Exemple #21
0
        public async Task <BasicResponse <string> > PasswordReset(string code)
        {
            using (var client = new System.Net.WebClient())
            {
                var text1 = await client.DownloadStringTaskAsync(string.Format("{0}?code={1}", Urls.PasswordReset, code));

                return(Newtonsoft.Json.JsonConvert.DeserializeObject <BasicResponse <string> >(text1));
            }
        }
Exemple #22
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            System.Net.WebClient wc = new System.Net.WebClient();
            var str    = MakeRpcUrl(this.texturl_node.Text, "getblockcount");
            var result = await wc.DownloadStringTaskAsync(str);

            var json = MyJson.Parse(result).AsDict()["result"].AsInt();

            labelHeight.Content = json;
        }
Exemple #23
0
        protected async Task <JObject> GetUrl(string url)
        {
            using (var client = new System.Net.WebClient())
            {
                client.Encoding = Encoding.UTF8;
                var response = await client.DownloadStringTaskAsync(url);

                return(JObject.Parse(response));
            }
        }
Exemple #24
0
        async Task <int> api_getHeight()
        {
            System.Net.WebClient wc = new System.Net.WebClient();
            var str    = WWW.MakeRpcUrl(this.labelApi.Text, "getblockcount");
            var result = await wc.DownloadStringTaskAsync(str);

            var json   = MyJson.Parse(result).AsDict()["result"].AsList();
            var height = json[0].AsDict()["blockcount"].AsInt() - 1;

            return(height);
        }
Exemple #25
0
        /// <summary>
        /// Производит проверку введеной гугловской капчи.
        /// </summary>
        /// <param name="token">Гугловский токен.</param>
        /// <returns>Признак успеха.</returns>
        public async Task <bool> Validate(string token)
        {
            var client = new System.Net.WebClient();

            string privateKey = StartEnumServer.Instance.GetSettings <IRecaptchaSettings>().SecretKey;

            var reply = await client.DownloadStringTaskAsync($"https://www.google.com/recaptcha/api/siteverify?secret={privateKey}&response={token}");

            var captchaResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <RecaptchaResponse>(reply);

            return(captchaResponse.Success);
        }
Exemple #26
0
        public async Task DownloadHTML(string url)
        {
            var webclient = new System.Net.WebClient();
            var html      = await webclient.DownloadStringTaskAsync(url);


            using (var streamwriter = new StreamWriter("C://Users//sruth//source//repos//webapi//async.txt"))
            {
                //  streamwriter.WriteLine(html);
                MessageBox.Show(html);
            }
        }
Exemple #27
0
        private async void Button_Click_5(object sender, RoutedEventArgs e)
        {
            if (lastTran == null || lastTran.witnesses == null || lastTran.witnesses.Length == 0)
            {
                return;
            }
            System.Net.WebClient wc = new System.Net.WebClient();
            var str    = MakeRpcUrl(this.texturl_node.Text, "sendrawtransaction", new MyJson.JsonNode_ValueString(textTran.Text));
            var result = await wc.DownloadStringTaskAsync(str);

            MessageBox.Show(result);
        }
Exemple #28
0
        public static async Task <List <Repository> > getAsync(String username)
        {
            using (var webClient = new System.Net.WebClient())
            {
                webClient.Encoding = Encoding.UTF8;
                webClient.Headers.Add(System.Net.HttpRequestHeader.UserAgent, "request");
                var json = await webClient.DownloadStringTaskAsync($"https://api.github.com/users/{username}/repos");

                List <Repository> repositories = JsonConvert.DeserializeObject <List <Repository> >(json);
                return(repositories);
            }
        }
Exemple #29
0
        private async Task <T> GetAPIJSON <T>(string url) where T : class
        {
            using (var wc = new System.Net.WebClient())
            {
                string contents = await wc.DownloadStringTaskAsync(new Uri(url));

                if (contents != null && contents.Length > 0)
                {
                    return(JsonConvert.DeserializeObject <T>(contents));
                }
            }
            return(null);
        }
Exemple #30
0
        async void yourMethod()
        {
            string placeholder;

            using (var wc = new System.Net.WebClient())
                placeholder = await wc.DownloadStringTaskAsync("https://datastatic.bricktale.xyz/devchat/chat.chat");


            string test   = placeholder.ToLower();
            string censor = test.Replace("f**k", "****").Replace("fak", "****").Replace("shit", "****").Replace("go commit sucidie", "****").Replace("bitch", "****").Replace("b!tch", "****").Replace("bidch", "****").Replace("f*g", "****").Replace("ffff", "****").Replace("mother", "****").Replace("shit", "****").Replace("sheet", "****").Replace("fu ck", "****").Replace("f uck", "****").Replace("fuc k", "****").Replace("$hit", "****").Replace("nigger", "I AM AN RACIST!!!").Replace("Wigger", "well still im an racist").Replace("Koyim", "Ban yedin gerizekalığğğğğğ").Replace("sik", "olmaz olsun böyle yazı").Replace("corona", "cough cough");

            richTextBox2.Text = censor;
        }
Exemple #31
0
        static async Task TaskBasedAsyncPattern()
        {
            var Url = "https://solishealthplans.com";

            using (var client = new System.Net.WebClient())
            {
                Console.WriteLine("A");
                var content = await client.DownloadStringTaskAsync(Url);

                Console.WriteLine("B");
                Console.WriteLine(content.Substring(0, 100));
            }
        }
		public async Task<string> DownloadStringAsync() {
			if (string.IsNullOrEmpty( RequestUrl )) {
				throw new ArgumentNullException( "reuqest url" );
			}

			var result = string.Empty;

			try {
				using (System.Net.WebClient client = new System.Net.WebClient()) {
					result = await client.DownloadStringTaskAsync( new Uri( RequestUrl ) );
				}
			} catch (Exception e) {
				_logger.Error( e.Message );
				throw;
			}

			return result;
		}
Exemple #33
0
        private void BTNOpenJsonFromURL_Click(object sender, RoutedEventArgs e)
        {
            WindowWithStringResult w = new WindowWithStringResult(async (path) =>
            {
                var result = string.Empty;
                using (var webClient = new System.Net.WebClient())
                {
                    try
                    {
                        result = await webClient.DownloadStringTaskAsync(new Uri(path));
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Nepodarilo sa stiahnut json");
                        return;
                    }

                    if (!string.IsNullOrEmpty(result))
                    {
                        jsonBase = await Task.Factory.StartNew(() => 
                            {
                                JsonBase b;
                                try
                                {
                                    b = JsonConvert.DeserializeObject<JsonBase>(result, settings);
                                }
                                catch(Exception)
                                {
                                    MessageBox.Show("Neplatny json");
                                    return null;
                                }
                                return b;
                            });

                        TXTSkyboxpath.Text = jsonBase.SkyboxPath;
                        ButtonSaveFile.IsEnabled = true;
                        ButtonManageDW.IsEnabled = true;
                        ButtonAddInterior.IsEnabled = true;
                        ButtonManageManufacturers.IsEnabled = true;
                        ButtonManageRooms.IsEnabled = true;
                        BTNEditProducts.IsEnabled = true;
                    }
                }
            });
            w.ShowDialog();
        }
Exemple #34
0
        protected override async Task<bool> IsStreamOnlineAsync()
        {
            try
            {
                using (System.Net.WebClient wc = new System.Net.WebClient())
                {
                    string RequestString;
                    RequestString = await wc.DownloadStringTaskAsync(new Uri("https://api.twitch.tv/kraken/streams/" + Username)).ConfigureAwait(false);

                    if (!RequestString.Contains("\"stream\":null"))
                    {
                        return true;
                    }
                }
            }
            catch (Exception)
            {
#if DEBUG
                // Outside of debug mode, we're willing to completely ignore stream retrieval failures.
                throw;
#endif
            }

            return false;
        }