Exemple #1
0
        public void LoadCustomerPassPaymentDetails(CustomerVehiclePass objReceipt)
        {
            try
            {
                string vehicleType = string.Empty;
                string stations    = string.Empty;

                labelParkingReceiptTitle.Text = "InstaParking-" + objReceipt.PassPriceID.PassTypeID.PassTypeName;
                labelParkingLot.Text          = objReceipt.LocationID.LocationName + "-" + objReceipt.PassPriceID.StationAccess;
                labelValidFrom.Text           = Convert.ToDateTime(objReceipt.StartDate).ToString("dd MMM yyyy");
                labelValidTo.Text             = Convert.ToDateTime(objReceipt.ExpiryDate).ToString("dd MMM yyyy");

                if (objReceipt.PassPriceID.PassTypeID.PassTypeCode == "MP")
                {
                    if (objReceipt.PassPriceID.StationAccess == "Single Station")
                    {
                        labelParkingLot.Text = objReceipt.LocationID.LocationName + "-" + objReceipt.PassPriceID.StationAccess;
                        stations             = objReceipt.LocationID.LocationName;
                    }
                    else if (objReceipt.PassPriceID.StationAccess == "Multi Station" || objReceipt.PassPriceID.StationAccess == "Multi Stations")
                    {
                        if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                        {
                            List <VMMultiLocations> lstpasslocations = dal_home.GetAllPassLocationsByVehicleType(Convert.ToString(App.Current.Properties["apitoken"]), objReceipt.CustomerVehicleID.VehicleTypeID.VehicleTypeCode, objReceipt.CustomerVehiclePassID);
                            if (lstpasslocations.Count > 0)
                            {
                                for (var s = 0; s < lstpasslocations.Count; s++)
                                {
                                    stations = stations + lstpasslocations[s].LocationName + ",";
                                }
                                labelParkingLot.Text = "Multi Stations:" + stations + ".";
                            }
                        }
                    }
                    else if (objReceipt.PassPriceID.StationAccess == "All Station" || objReceipt.PassPriceID.StationAccess == "All Stations")
                    {
                        labelParkingLot.Text = "All Metro Stations";
                        stations             = "All Metro Stations";
                    }
                    labelValidFrom.Text = Convert.ToDateTime(objReceipt.StartDate).ToString("dd MMM yyyy");
                    labelValidTo.Text   = Convert.ToDateTime(objReceipt.ExpiryDate).ToString("dd MMM yyyy");
                }
                imageVehicleImage.Source     = objReceipt.CustomerVehicleID.VehicleTypeID.VehicleIcon;
                labelCustomerName.Text       = objReceipt.CustomerVehicleID.CustomerID.Name;
                labelVehicleDetails.Text     = objReceipt.CustomerVehicleID.RegistrationNumber;
                labelParkingFeesDetails.Text = objReceipt.CardAmount.ToString("N2") + "/-";
                labelParkingPaymentType.Text = "Paid - By " + objReceipt.NFCCardPaymentID.PaymentTypeCode;

                if (objReceipt.CreatedBy.UserName != "")
                {
                    labelOperatorName.Text         = objReceipt.CreatedBy.UserName;
                    labelOperatorID.Text           = "- #" + Convert.ToString(objReceipt.CreatedBy.UserCode);
                    labelOrderID.Text              = "#" + objReceipt.CustomerVehiclePassID;
                    imageOperatorProfile.IsVisible = true;
                }
                else
                {
                    imageOperatorProfile.IsVisible = false;
                }
                labelGSTNumber.Text = objReceipt.GSTNumber;

                try
                {
                    if (receiptlines != null && receiptlines.Length > 0)
                    {
                        receiptlines[0]  = "\x1B\x21\x08" + "          " + "HMRL PARKING" + "\x1B\x21\x00" + "\n";
                        receiptlines[1]  = "\x1B\x21\x01" + "          " + objReceipt.CreatedBy.LocationParkingLotID.LocationID.LocationName + "\x1B\x21\x00\n";
                        receiptlines[3]  = "" + "\n";
                        receiptlines[4]  = "\x1B\x21\x08" + vehicleType + "     " + objReceipt.CustomerVehicleID.RegistrationNumber + "\x1B\x21\x00\n";
                        receiptlines[5]  = "\x1B\x21\x01" + "Valid From:" + Convert.ToDateTime(objReceipt.StartDate).ToString("dd MMM yyyy") + "\x1B\x21\x00" + "\n";
                        receiptlines[6]  = "\x1B\x21\x01" + "Valid Till:" + Convert.ToDateTime(objReceipt.ExpiryDate).ToString("dd MMM yyyy") + "\x1B\x21\x00" + "\n";
                        receiptlines[7]  = "\x1B\x21\x01" + "(Pass Type :" + objReceipt.PassPriceID.PassTypeID.PassTypeName + ")" + "\x1B\x21\x00\n";
                        receiptlines[8]  = "\x1B\x21\x01" + "Station(s):" + stations + "\x1B\x21\x01" + "\n";
                        receiptlines[9]  = "\x1B\x21\x01" + "Paid: Rs" + objReceipt.PassPriceID.CardPrice.ToString("N2") + "\x1B\x21\x01" + "\n";
                        receiptlines[10] = "\x1B\x21\x06" + "Operator Id:" + objReceipt.CreatedBy.UserCode + "\x1B\x21\x00\n";
                        receiptlines[11] = "\x1B\x21\x01" + "(Supervisor Mobile:" + objReceipt.SuperVisorID.PhoneNumber + ")" + "\x1B\x21\x00\n";
                        receiptlines[12] = "\x1B\x21\x01" + "We are not responsible for your valuable items like laptop,       wallet,helmet etc." + "\x1B\x21\x00\n";
                        receiptlines[13] = "\x1B\x21\x06" + "GST Number 36AACFZ1015E1ZL" + "\x1B\x21\x00\n";
                        receiptlines[14] = "\x1B\x21\x06" + "Amount includes 18% GST" + "\x1B\x21\x00\n";
                        receiptlines[15] = "" + "\n";
                        receiptlines[16] = "" + "\n";
                    }
                }
                catch (Exception ex)
                {
                    dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "NFCCardPaymentReceiptPagae.xaml.cs", "", "receiptlines");
                }


                try
                {
                    //SMS Sending
                    string        ParkingAmount = string.Empty;
                    StringBuilder sbSMS         = new StringBuilder();
                    if (DeviceInternet.InternetConnected())
                    {
                        sbSMS.AppendLine("  HMRL PARKING  ");
                        sbSMS.AppendLine(objReceipt.LocationID.LocationName + "-" + objReceipt.PassPriceID.StationAccess);
                        sbSMS.AppendLine(vehicleType + ": " + objReceipt.CustomerVehicleID.RegistrationNumber);
                        sbSMS.AppendLine("Valid From: " + Convert.ToDateTime(objReceipt.StartDate).ToString("dd MMM yyyy"));
                        sbSMS.AppendLine("Valid Till: " + Convert.ToDateTime(objReceipt.ExpiryDate).ToString("dd MMM yyyy"));
                        sbSMS.AppendLine("Pass Type: " + objReceipt.PassPriceID.PassTypeID.PassTypeName);
                        sbSMS.AppendLine("Station(s): " + stations);
                        ParkingAmount = objReceipt.PassPriceID.CardPrice.ToString("N2");
                        decimal GSTPercentage  = 18;
                        decimal GSTAmount      = (Convert.ToDecimal(objReceipt.PassPriceID.CardPrice) * GSTPercentage) / 100;
                        decimal AmountAfterGST = (Convert.ToDecimal(objReceipt.PassPriceID.CardPrice)) - GSTAmount;
                        string  GSTString      = "Rs" + AmountAfterGST.ToString("N2") + "," + " GST " + GSTPercentage + "%" + " Rs" + GSTAmount.ToString("N2");
                        sbSMS.AppendLine("Paid: Rs" + ParkingAmount + " " + "(" + GSTString + ")");
                        sbSMS.AppendLine("ID: " + objReceipt.CreatedBy.UserCode);
                        sbSMS.AppendLine("Ph: " + objReceipt.SuperVisorID.PhoneNumber + ")");
                        if (App.Current.Properties.ContainsKey("LoginUser"))
                        {
                            User objLoginUser = (User)App.Current.Properties["LoginUser"];
                            sbSMS.AppendLine("Security " + objLoginUser.LocationParkingLotID.LotOpenTime + "-" + objLoginUser.LocationParkingLotID.LotCloseTime);
                        }
                        sbSMS.AppendLine("GST " + objReceipt.GSTNumber + "");
                        sbSMS.AppendLine("SPRV Technologies (INSPRK)");
                        string resultsmsmsg = sbSMS.ToString();

                        SendSMS(objReceipt.CustomerVehicleID.CustomerID.PhoneNumber, resultsmsmsg);
                    }
                }
                catch (Exception ex)
                {
                    dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "NFCCardPaymentReceiptPagae.xaml.cs", "", " SMS Sending Text");
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "NFCCardPaymentReceiptPagae.xaml.cs", "", "LoadCustomerPassPaymentDetails");
            }
        }
        public RazorPayment(CustomerParkingSlot customerParkingSlot, CustomerVehiclePass customerVehiclePass)
        {
            InitializeComponent();
            dal_Customer            = new DALCustomer();
            dal_Pass                = new DALPass();
            obj_CustomerParkingSlot = customerParkingSlot;
            obj_CustomerVehiclePass = customerVehiclePass;

            if (App.Current.Properties.ContainsKey("UserName"))
            {
                UserName = Convert.ToString(App.Current.Properties["UserName"]);
            }
            if (App.Current.Properties.ContainsKey("Email"))
            {
                Email = Convert.ToString(App.Current.Properties["Email"]);
            }
            if (App.Current.Properties.ContainsKey("PhoneNumber"))
            {
                PhoneNumber = Convert.ToString(App.Current.Properties["PhoneNumber"]);
            }

            if (obj_CustomerParkingSlot != null && obj_CustomerVehiclePass == null)
            {
                string Source = "http://35.202.198.25:81/RazorPayAPI/Payment.aspx?" +
                                "name=" + UserName + "" +
                                "&email=" + Email +
                                "&contact=" + PhoneNumber + "" +
                                "&description=" + Convert.ToString(obj_CustomerParkingSlot.LocationParkingLotName) +
                                "&amount=" + Convert.ToString(obj_CustomerParkingSlot.PaidAmount) +
                                "&receiptID=" + 0 + "";

                CookieContainer cookieContainer = new CookieContainer();
                Uri             uri             = new Uri(Source, UriKind.RelativeOrAbsolute);

                Cookie cookie = new Cookie
                {
                    Name    = "CustomerID",
                    Expires = DateTime.Now.AddDays(1),
                    Value   = Convert.ToString(obj_CustomerParkingSlot.CustomerID),
                    Domain  = uri.Host,
                    Path    = "/"
                };
                cookieContainer.Add(uri, cookie);
                webView.Cookies = cookieContainer;
                webView.Source  = new UrlWebViewSource {
                    Url = uri.ToString()
                };
            }
            else if (obj_CustomerParkingSlot == null && obj_CustomerVehiclePass != null)
            {
                string Source = "http://35.202.198.25:81/RazorPayAPI/Payment.aspx?" +
                                "name=" + UserName + "" +
                                "&email=" + Email +
                                "&contact=" + PhoneNumber + "" +
                                "&description=" + Convert.ToString(obj_CustomerVehiclePass.StationAccess) +
                                "&amount=" + Convert.ToString(obj_CustomerVehiclePass.TotalAmount + obj_CustomerVehiclePass.PaidDueAmount) +
                                "&receiptID=" + 0 + "";

                CookieContainer cookieContainer = new CookieContainer();
                Uri             uri             = new Uri(Source, UriKind.RelativeOrAbsolute);

                Cookie cookie = new Cookie
                {
                    Name    = "CustomerID",
                    Expires = DateTime.Now.AddDays(1),
                    Value   = Convert.ToString(obj_CustomerVehiclePass.CustomerID),
                    Domain  = uri.Host,
                    Path    = "/"
                };
                cookieContainer.Add(uri, cookie);
                webView.Cookies = cookieContainer;
                webView.Source  = new UrlWebViewSource {
                    Url = uri.ToString()
                };
            }
        }
        public CustomerVehiclePass SaveCustomerVehiclePassNewNFCCard(string accessToken, CustomerVehiclePass objvehicle)
        {
            dal_DALExceptionManagment = new DALExceptionManagment();
            CustomerVehiclePass objActivatedCustomerVehiclePass = null;

            try
            {
                string baseUrl = Convert.ToString(App.Current.Properties["BaseURL"]);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    // Add the Authorization header with the AccessToken.
                    client.DefaultRequestHeaders.Add("Authorization", "bearer  " + accessToken);
                    // create the URL string.
                    string url = "api/InstaOperator/postSaveCustomerVehiclePassNewNFCCard";
                    // make the request

                    var json    = JsonConvert.SerializeObject(objvehicle);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.PostAsync(url, content).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        string jsonString = response.Content.ReadAsStringAsync().Result;
                        if (jsonString != null)
                        {
                            APIResponse apiResult = JsonConvert.DeserializeObject <APIResponse>(jsonString);

                            if (apiResult.Result)
                            {
                                objActivatedCustomerVehiclePass = JsonConvert.DeserializeObject <CustomerVehiclePass>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dal_DALExceptionManagment.InsertException(accessToken, "OperatarAPP", ex.Message, "DALPass", "", "GetCustomerVehicleDetailsByVehicle");
            }
            return(objActivatedCustomerVehiclePass);
        }
        private async void BtnGeneratePass_Clicked(object sender, EventArgs e)
        {
            try
            {
                ShowLoading(true);
                btnGeneratePass.IsVisible = false;

                string existingnfcCardVehcile = string.Empty;
                if (DeviceInternet.InternetConnected())
                {
                    CustomerVehiclePass resultPass = null;
                    if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                    {
                        existingnfcCardVehcile = dal_CustomerPass.IsValidNFCCard(Convert.ToString(App.Current.Properties["apitoken"]), labelNFCCard.Text, objInputMonthlyPass.CustomerVehicleID.RegistrationNumber);
                        if (existingnfcCardVehcile == string.Empty)
                        {
                            if (App.Current.Properties.ContainsKey("MultiSelectionLocations"))
                            {
                                List <Model.APIOutPutModel.Location> lstMultiLication = (List <Model.APIOutPutModel.Location>)App.Current.Properties["MultiSelectionLocations"];
                                await Task.Run(() =>
                                {
                                    objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    if (!string.IsNullOrEmpty(labelNFCCard.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    }
                                    else if (!string.IsNullOrEmpty(labelBARCode.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelBARCode.Text;
                                    }
                                    objInputMonthlyPass.IsMultiLot = true;
                                    VMMultiStationCustomerVehiclePass objvmMultiStations = new VMMultiStationCustomerVehiclePass();
                                    objvmMultiStations.CustomerVehiclePassID             = objInputMonthlyPass;
                                    objvmMultiStations.LocationID = lstMultiLication;
                                    resultPass = dal_CustomerPass.CreateMultiStationCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objvmMultiStations);
                                });

                                if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                                {
                                    StopNFCListening();
                                    await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                    var passPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                                    await Navigation.PushAsync(passPaymentReceiptPage);
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                                }
                            }
                            else
                            {
                                await Task.Run(() =>
                                {
                                    objInputMonthlyPass.BarCode = labelBARCode.Text;
                                    if (!string.IsNullOrEmpty(labelNFCCard.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    }
                                    else if (!string.IsNullOrEmpty(labelBARCode.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelBARCode.Text;
                                    }
                                    resultPass = dal_CustomerPass.CreateCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objInputMonthlyPass);
                                });

                                if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                                {
                                    await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                    var passPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                                    await Navigation.PushAsync(passPaymentReceiptPage);
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                                }
                            }
                        }
                        else
                        {
                            ShowLoading(false);
                            await DisplayAlert("Alert", "NFC Card already assigned to " + existingnfcCardVehcile + "", "Ok");
                        }

                        ShowLoading(false);
                        btnGeneratePass.IsVisible = true;
                    }
                }
                else
                {
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");

                    ShowLoading(false);
                    btnGeneratePass.IsVisible = true;
                }
            }
            catch (Exception ex)
            {
                btnGeneratePass.IsVisible = true;
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "MonthlyPassCashPaymentPage.xaml.cs", "", "BtnGeneratePassReceipt_Clicked");
            }
        }