Esempio n. 1
0
        private async void GetAllSkyJSONData()
        {
            Debug.WriteLine("GetAllSkyJSONData enter");
            if (IsBusy)
            {
                Debug.WriteLine("GetAllSkyJSONData: GetJSON already busy, return");
                return;
            }
            IsBusy = true;

            // Check network status
            if (NetworkServices.IsConnectedToInternet())
            {
                Tuple <AllSkyDataClass, DownloadResult> allskyret;
                allskyret = await Task.Run(() => NetworkServices.GetJSON <AllSkyDataClass>(Settings.AllskyStatusURL));

                //4. Data setting
                DateTime ASDT = DateTimeUtils.UnixTimeStampToDateTime(allskyret.Item1.timestamp);
                AllSkyDate = DateTimeUtils.ConvertToLocal(ASDT).ToString("HH:mm:ss");
            }
            else
            {
                await ParentPage.DisplayAlert("Get allsky data", "No network is available.", "Ok");
            }
            IsBusy = false;
        }
Esempio n. 2
0
        private async void GetAllSkyJSONData_old()
        {
            Debug.WriteLine("GetAllSkyJSONData enter");
            if (IsBusy)
            {
                Debug.WriteLine("GetAllSkyJSONData already busy, return");
                return;
            }
            IsBusy        = true;
            GetDataResult = DownloadResult.Undefined;
            Debug.WriteLine("GetAllSkyJSONData started, DownloadResult:" + GetDataResult);

            // Check network status
            if (NetworkServices.IsConnectedToInternet())
            {
                try
                {
                    //1. Download data
                    Uri                 geturi   = new Uri("http://astro.milantiev.com/allsky/stat.php"); //replace your xml url
                    HttpClient          client   = new HttpClient();
                    HttpResponseMessage response = await client.GetAsync(geturi);

                    Debug.WriteLine("GetAllSkyJSONData download completead, StatusCode:" + response.StatusCode);

                    //2. If data ok
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        //2.2. Read string
                        string responseSt = await response.Content.ReadAsStringAsync();

                        Debug.WriteLine("GetAllSkyJSONData DOWNLOAD DATA:" + responseSt);

                        try
                        {
                            //3.1 Set JSON parse options
                            JsonSerializerSettings JSONSettings = new JsonSerializerSettings();
                            JSONSettings.Culture = new CultureInfo("ru-RU");
                            JSONSettings.Culture.NumberFormat.NumberDecimalSeparator = ".";
                            JSONSettings.NullValueHandling = NullValueHandling.Ignore;

                            //3.2. JSON convert
                            AllSkyDataClass objResponse = JsonConvert.DeserializeObject <AllSkyDataClass>(responseSt, JSONSettings);

                            //4. Data setting
                            DateTime ASDT = DateTimeUtils.UnixTimeStampToDateTime(objResponse.timestamp);
                            AllSkyDate = DateTimeUtils.ConvertToLocal(ASDT).ToString("HH:mm:ss");
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine("Exception in GetAllSkyJSONData JSON parsing");
                            Debug.WriteLine(ex);
                            GetDataResult = DownloadResult.ParseError;
                        }
                    }
                    else
                    {
                        GetDataResult = DownloadResult.DownloadError;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Exception in GetAllSkyJSONData download");
                    Debug.WriteLine(ex);
                    GetDataResult = DownloadResult.DownloadError;
                }
            }
            else
            {
                await ParentPage.DisplayAlert("Get allsky data", "No network is available.", "Ok");
            }
            IsBusy = false;
        }
Esempio n. 3
0
 static public DateTime NautTwilightSetDateTime(int DayShift = 0)
 {
     return(DateTimeUtils.ConvertToLocal(AstroUtilsProp.NautTwilightSetDateTimeUtc(DayShift)));
 }
Esempio n. 4
0
 static public DateTime AstronTwilightRiseDateTime(int DayShift = 0)
 {
     return(DateTimeUtils.ConvertToLocal(AstroUtilsProp.AstronTwilightRiseDateTimeUtc(DayShift)));
 }
Esempio n. 5
0
 static public DateTime SunSetDateTime(int DayShift = 0)
 {
     return(DateTimeUtils.ConvertToLocal(AstroUtilsProp.SunSetDateTimeUtc(DayShift)));
 }