private void clickbutton(object sender, RoutedEventArgs e)
        {
            WebClient weather = new WebClient();

            weather.BaseAddress = "http://api.openweathermap.org/data/2.5/weather?zip=94040,us&appid=555fa8f3d3204ad49120a43f2479e7d4";
            string       weatherData     = weather.DownloadString(weather.BaseAddress);
            jsonResponse weathDataObject = JsonConvert.DeserializeObject <jsonResponse>(weatherData);

            textBox.Text = weathDataObject.name;
            textBox.AppendText(Environment.NewLine);
            textBox.AppendText(weathDataObject.coord.lat.ToString());
            textBox.AppendText(Environment.NewLine);
            textBox.AppendText(weathDataObject.coord.lat.ToString());
            textBox.AppendText(Environment.NewLine);
            textBox.AppendText(weathDataObject.main.temp.ToString());
            textBox.AppendText(Environment.NewLine);
            textBox.AppendText(DateTime.Now.ToString());
        }
Exemple #2
0
    private void JsonCheck(string data)
    {
        jsonResponse jsnData  = JsonUtility.FromJson <jsonResponse> (data);
        DateTime     dtLocal  = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        DateTime     dtServer = DateTime.Parse(jsnData.currentTime);
        TimeSpan     ts       = dtLocal - dtServer;

        if (ts.Duration() > new TimeSpan(0, 5, 0))
        {
            Debug.LogError("現在時刻が正常に設定されていません");
            ShowDialog(2, 0);
        }
        else if (thisVersion != jsnData.currentVersion)
        {
            foreach (versionList x in jsnData.supportedVersions)
            {
                if (thisVersion == x.version)
                {
                    dtLocal  = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                    dtServer = DateTime.Parse(x.expirationDate);
                    if (dtServer - dtLocal >= new TimeSpan(0, 0, 0))
                    {
                        Debug.LogError("最新版が更新されています.このバージョンの有効期限はあと" + (dtServer - dtLocal).Days + "日です.");
                        _playableFlag = true;
                        ShowDialog(0, (dtServer - dtLocal).Days);
                        break;
                    }
                    else
                    {
                        Debug.LogError("このバージョンのサポートは終了しています.");
                        ShowDialog(3, 0);
                        break;
                    }
                }
            }
        }
        else
        {
            this.showConnecting.text = "";
            ScreenTransition();
        }
    }