Пример #1
0
        public async Task <OrgInfo> LoadPortalDataAsync()
        {
            try
            {
                using (var client = new HttpClient())
                {
                    if (ApplicationData.Current.LocalSettings.Values["OrgPortalApi"] == null)
                    {
                        ApplicationData.Current.LocalSettings.Values["OrgPortalApi"] = DefaultServiceUri;
                    }
                    var serviceURI = ApplicationData.Current.LocalSettings.Values["OrgPortalApi"].ToString();

                    var response = await client.GetAsync(serviceURI + "OrgPortal");

                    if (response.IsSuccessStatusCode)
                    {
                        var data = await response.Content.ReadAsStringAsync();

                        var info = JsonConvert.DeserializeObject <List <string> >(data);
                        if (info.Count > 1)
                        {
                            var org = new OrgInfo()
                            {
                                Name = info[0], FeatureURL = info[1]
                            };

                            return(org);
                        }
                    }
                }
            }
            catch (Exception)
            {
                // do nothing
            }

            return(new OrgInfo());
        }