async void OnClicked_DeleteLoadAllocation(object sender, EventArgs args) { try { var Action = await DisplayAlert("ATISMobile", "حذف تخصیص بار را تایید می کنید؟", "بله", "خیر"); if (Action) { var LoadAllocationId = (((StackLayout)((ImageButton)sender).Parent.Parent.FindByName("_StackLayoutInformation")).FindByName("_LabelLAId") as Label).Text.Split('-')[0].Split(':')[1].Trim(); await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/LoadAllocations/LoadAllocationCancelling"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce + ATISMobileWebApiMClassManagement.UserLast5Digit + LoadAllocationId) + ";" + LoadAllocationId; request.Content = new StringContent(JsonConvert.SerializeObject(Content), Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { ViewLoadAllocations(); await DisplayAlert("ATISMobile", "حذف تخصیص بار انجام شد", "تایید"); } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public async void ViewInformation() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/TruckDrivers/GetTruckDriver"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); 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(); var myTruckDriver = JsonConvert.DeserializeObject <TruckDriver>(content); LblNameFamily.Text = myTruckDriver.NameFamily; LblFatherName.Text = myTruckDriver.FatherName; LblSmartCardNo.Text = myTruckDriver.SmartCardNo; LblNationalCode.Text = myTruckDriver.NationalCode; LblTel.Text = myTruckDriver.Tel; LblDriverLicenceNo.Text = myTruckDriver.DrivingLicenceNo; LblDriverId.Text = myTruckDriver.DriverId; } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public async void ViewInformation() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/Turns/GetTurns"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); 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(); var _List = JsonConvert.DeserializeObject <List <Turns> >(content); if (_List.Count == 0) { _ListView.IsVisible = false; _StackLayoutEmptyTurns.IsVisible = true; } else { _StackLayoutEmptyTurns.IsVisible = false; _ListView.ItemsSource = _List; } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public async void ViewInformation() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/Trucks/GetTruck"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); 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(); Truck myTruck = JsonConvert.DeserializeObject <Truck>(content); LblTruckId.Text = myTruck.TruckId; LblLPString.Text = myTruck.LPString; LblLoaderTitle.Text = myTruck.LoaderTitle; LblSmartCardNo.Text = myTruck.SmartCardNo; LblAnnouncementHallSubGroups.Text = myTruck.AnnouncementHallSubGroups; } else { await DisplayAlert("ATISMobile-Failed", "HttpStatusCode:" + response.StatusCode.ToString(), "OK"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void ViewMoneyWalletReminderCharge() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/MoneyWalletReminderCharge/GetMoneyWalletReminderCharge"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); 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(); MessageStruct Result = JsonConvert.DeserializeObject <MessageStruct>(content); _LblReminderCharge.Text = Result.Message1; _LblReminderChargeHeader.IsVisible = true; } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void _PickerAnnouncementHallSubGroups_SelectedIndexChanged(object sender, EventArgs e) { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/Reports/GetLoadPermissionsIssuedOrderByPriorityReport"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce + _PickerAnnouncementHallSubGroups.SelectedItem.ToString().Split(' ')[0]) + ";" + _PickerAnnouncementHallSubGroups.SelectedItem.ToString().Split(' ')[0]; 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(); var Lst = JsonConvert.DeserializeObject <List <Models.PermissionsIssued> >(content); if (Lst.Count == 0) { _ListView.IsVisible = false; _StackLayoutEmptyPermissions.IsVisible = true; } else { _StackLayoutEmptyPermissions.IsVisible = false; _ListView.IsVisible = true; _ListView.ItemsSource = Lst; } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void _ButtonSend_ClickedEvent(Object sender, EventArgs e) { try { if ((_EntryMobileNumber.Text.Trim() == string.Empty) || (_EntryNameFamily.Text.Trim() == string.Empty)) { await DisplayAlert("ATISMobile-Error", "اطلاعات را به طور کامل وارد کنید", "تایید"); return; } _ButtonSend.IsEnabled = false; _ButtonSend.BackgroundColor = Color.Gray; string myMobileNumber = _EntryMobileNumber.Text.Trim(); string myNameFamily = _EntryNameFamily.Text.Trim(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri("/api/SoftwareUsers/RegisterMobileNumber")); request.Content = new StringContent(JsonConvert.SerializeObject(myMobileNumber), Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { VerificationCodeEntryPage _VerificationCodeEntryPage = new VerificationCodeEntryPage(); _VerificationCodeEntryPage.SetInf(myMobileNumber, _EntryMobileNumber.Text); await Navigation.PushAsync(_VerificationCodeEntryPage); } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } _ButtonSend.IsEnabled = true; _ButtonSend.BackgroundColor = Color.Green; }
private async void ShowPublicMessage() { try { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "/api/PublicMessages/GetPublicMessage"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); string PublicMessage = JsonConvert.DeserializeObject <String>(content); if (PublicMessage.Trim() != string.Empty) { Device.BeginInvokeOnMainThread(() => { DisplayAlert("ATISMobile", PublicMessage.Trim(), "تایید"); }); } } else { Device.BeginInvokeOnMainThread(() => { DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); }); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public async void ShowProcesses() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/MobileProcesses/GetMobileProcesses"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); request.Content = new StringContent(JsonConvert.SerializeObject(Content), Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { if (response.StatusCode == HttpStatusCode.OK) { var content = await response.Content.ReadAsStringAsync(); var _Lst = JsonConvert.DeserializeObject <List <MobileProcess> >(content); if (_Lst.Count == 0) { ; } else { _ListView.ItemsSource = _Lst; } return; } else if (response.StatusCode == HttpStatusCode.NonAuthoritativeInformation) { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); ActivateSoftwareUser(); return; } } else if (response.StatusCode == HttpStatusCode.InternalServerError) { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); return; } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); return; } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void _StartApplication_ClickedEvent(Object sender, EventArgs e) { try { _StartApplication.IsEnabled = false; var TargetPath = ATISMobileWebApiMClassManagement.GetTargetPath(); if (System.IO.File.Exists(TargetPath) == false) { System.IO.File.WriteAllText(TargetPath, ""); } string AMUStatus = System.IO.File.ReadAllText(TargetPath); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri("/api/DataBase/ConfirmAMUStatus")); request.Content = new StringContent(JsonConvert.SerializeObject(AMUStatus), Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); bool Confirmed = JsonConvert.DeserializeObject <bool>(content); if (!Confirmed) { ActivateSoftwareUser(); return; } else { MenuPage _MenuPage = new MenuPage(true); await Navigation.PushAsync(_MenuPage); return; } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
async void OnTapGestureRecognizerTapped(object sender, EventArgs args) { try { await Nonce.GetNonce(); string TargetMobileProcess = (((Label)sender).Parent.FindByName("_TargetMobileProcess") as Label).Text; string TargetMobileProcessId = (((Label)sender).Parent.FindByName("_TargetMobileProcessId") as Label).Text; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, new Uri("/api/Permissions/ExistPermission")); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce + TargetMobileProcessId) + ";" + TargetMobileProcessId; 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(); var ExistPermission = JsonConvert.DeserializeObject <bool>(content); if (ExistPermission) { var pageType = Type.GetType(TargetMobileProcess); var page = Activator.CreateInstance(pageType) as Page; await Navigation.PushAsync(page); } else { await DisplayAlert("ATISMobile", "مجوز دسترسی به این فرآیند را ندارید", "تایید"); } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void _BtnGotoCharge_ClickedEvent(object sender, EventArgs e) { try { Int64 Amount = System.Convert.ToInt64(_LblAmount.Text.Replace(",", string.Empty)); if (Amount.ToString() == "0" || Amount.ToString() == string.Empty) { throw new Exception("مبلغ مورد نظر خود را انتخاب کنید"); } await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/MoneyWalletChargingAPI/PaymentRequest"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce + ATISMobileWebApiMClassManagement.UserLast5Digit + Amount.ToString()) + ";" + Amount.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(); var myMS = JsonConvert.DeserializeObject <MessageStruct>(content); if (myMS.ErrorCode == false) { Device.OpenUri(new Uri(myMS.Message2 + myMS.Message1)); } else { } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public async void Initialize() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/AnnouncementHalls/GetAnnouncementHallsAnnouncementhAllSubGroupsJOINT"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); 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(); var ListAnnouncementHalls = JsonConvert.DeserializeObject <List <KeyValuePair <string, string> > >(content); if (ListAnnouncementHalls.Count == 0) { } else { List <string> Lst = new List <string>(); for (int Loopx = 0; Loopx <= ListAnnouncementHalls.Count - 1; Loopx++) { Lst.Add(ListAnnouncementHalls[Loopx].Key + " " + ListAnnouncementHalls[Loopx].Value); } _PickerAnnouncementHallSubGroups.ItemsSource = Lst; } } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
private async void WebApiConnect() { try { await ATISMobileWebApiMClassManagement.SetATISMobileWebApiHostUrl(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "/api/VersionControl/HaveNewerVersion"); Xamarin.Essentials.VersionTracking.Track(); string VersionNumber = Xamarin.Essentials.VersionTracking.CurrentBuild; string VersionName = Xamarin.Essentials.VersionTracking.CurrentVersion; request.Headers.Add("VersionNumber", VersionNumber); request.Headers.Add("VersionName", VersionName); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); bool AppVersionIsNew = JsonConvert.DeserializeObject <bool>(content); if (AppVersionIsNew) { Disable_StartApplicationButton(VersionNumber + "." + VersionName); } else { Enable_StartApplicationButton(VersionNumber + "." + VersionName); } } else { _LblExpander.IsVisible = true; ViewErrorMessage(JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result)); } } catch (System.Net.WebException ex) { ViewErrorMessage(ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage); } catch (Exception ex) { ViewErrorMessage(ex.Message); } }
public static async Task <HttpResponseMessage> GetNonce() { try { HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/SoftwareUsers/GetNonce"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey()); 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(); _CurrentNonce = JsonConvert.DeserializeObject <string>(content); } else { throw new Exception(JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result)); } return(response); } catch (Exception ex) { throw ex; } }