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"); }
        }
Ejemplo n.º 2
0
        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"); }
        }
Ejemplo n.º 3
0
        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"); }
        }
Ejemplo n.º 4
0
        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 _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"); }
        }
Ejemplo n.º 6
0
        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"); }
        }
Ejemplo n.º 7
0
        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"); }
        }
Ejemplo n.º 8
0
        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"); }
        }
Ejemplo n.º 11
0
        public static Summary GetInfo(Flipper flipper)
        {
            Summary id = null;

            Nonce nonce = new Nonce();

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://ws.byu.edu/rest/v2.0/identity/person/PRO/personSummary.cgi/" + flipper.person_id);
            request.Headers.Add("Authorization", nonce.GetNonce(flipper.net_id));

            request.Method = "GET";
            request.Accept = "application/json";

            HttpWebResponse response = null;
            try
            {
                using (response = (HttpWebResponse)request.GetResponse())
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {

                        Stream ReceiveStream = response.GetResponseStream();
                        StreamReader readStream = new StreamReader(ReceiveStream);
                        string json = readStream.ReadToEnd();
                        id = jsSerializer.Deserialize<Summary>(json);
                    }
                }
            }
            catch (WebException wx)
            {
                if (response == null)
                {
                    System.Diagnostics.Debug.WriteLine(wx.Message);

                }
                return null;
            }

            return id;
        }