コード例 #1
0
 private async void ViewProvinces(LoadCapacitorLoadsListType YourLoadCapacitorLoadsListType)
 {
     try
     {
         ProvincesManagement.ProvinceSelectionPage _ProvinceSelectionPage = new ProvincesManagement.ProvinceSelectionPage();
         _ProvinceSelectionPage.ViewInformation(_AHId, _AHSGId, YourLoadCapacitorLoadsListType);
         await Navigation.PushAsync(_ProvinceSelectionPage);
     }
     catch (Exception ex)
     { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); }
 }
コード例 #2
0
        public async void ViewInformation(Int64 YourAHId, Int64 YourAHSGId, LoadCapacitorLoadsListType YourLoadCapacitorLoadsListType)
        {
            _AHId = YourAHId; _AHSGId = YourAHSGId;
            _LoadCapacitorLoadsListType = YourLoadCapacitorLoadsListType;
            try
            {
                await Nonce.GetNonce();

                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/Provinces/GetProvinces");
                var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce + _AHId.ToString() + _AHSGId.ToString() + ((int)_LoadCapacitorLoadsListType).ToString()) + ";" + _AHId.ToString() + ";" + _AHSGId.ToString() + ";" + ((int)_LoadCapacitorLoadsListType).ToString();
                request.Content = new StringContent(JsonConvert.SerializeObject(Content), Encoding.UTF8, "application/json");
                HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request);

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

                    List <Province> _List = new List <Province>();
                    _List = JsonConvert.DeserializeObject <List <Province> >(content);
                    if (_List.Count == 0)
                    {
                        _ListView.IsVisible = false; _StackLayoutEmptyProvince.IsVisible = true;
                    }
                    else
                    {
                        _ListView.ItemsSource = _List;
                    }
                }
                else
                {
                    await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید");

                    _ListView.IsVisible = false; _StackLayoutEmptyProvince.IsVisible = true;
                }
            }
            catch (System.Net.WebException ex)
            { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); }
            catch (Exception ex)
            { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); }
        }