Example #1
0
        public JsonResult SaveLotBays(ParkingBay lotBaysData)
        {
            string resultmsg = string.Empty;

            try
            {
                resultmsg = lotsDAL_obj.SaveLotBays(lotBaysData, Convert.ToString(Session["UserID"]));
                return(Json(resultmsg, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(resultmsg, JsonRequestBehavior.AllowGet));
            }
        }
        public List <ParkingBay> GetLocationLotBayNumbers(LocationParkingLot obj)
        {
            List <ParkingBay> lstParkingBayNumbers = new List <ParkingBay>();
            string            resultMsg            = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_GetLocationLotBayNumbers", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@LocationParkingLotID", obj.LocationParkingLotID);
                        sqlcmd_obj.Parameters.AddWithValue("@LocationID", obj.LocationID.LocationID);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            for (var i = 0; i < resultdt.Rows.Count; i++)
                            {
                                ParkingBay objparkingbay = new ParkingBay();
                                objparkingbay.ParkingBayID                  = resultdt.Rows[i]["ParkingBayID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[i]["ParkingBayID"]);
                                objparkingbay.ParkingBayName                = Convert.ToString(resultdt.Rows[i]["ParkingBayName"]);
                                objparkingbay.ParkingBayRange               = Convert.ToString(resultdt.Rows[i]["ParkingBayRange"]);
                                objparkingbay.VehicleTypeID.VehicleTypeID   = resultdt.Rows[i]["VehicleTypeID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[i]["VehicleTypeID"]);
                                objparkingbay.VehicleTypeID.VehicleTypeCode = Convert.ToString(resultdt.Rows[i]["VehicleTypeCode"]);
                                lstParkingBayNumbers.Add(objparkingbay);
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALCheckIn", "Proc: " + "OPAPP_PROC_GetLocationLotBayNumbers", "GetLocationLotBayNumbers");
                throw;
            }
            return(lstParkingBayNumbers);
        }
        private async void BtnCheckIn_Clicked(object sender, EventArgs e)
        {
            MasterHomePage masterPage      = null;
            string         msg             = string.Empty;
            string         existingCheckIn = string.Empty;

            btnCheckIn.IsVisible = false;
            try
            {
                ShowLoading(true);
                if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken") && objCustomerPass != null)
                {
                    if (SelectedVehicle != string.Empty)
                    {
                        // Pass holder vehicle Check In
                        ParkingBay objselectedbay = (ParkingBay)pickerBayNumers.SelectedItem;
                        if (objselectedbay != null)
                        {
                            await Task.Run(() =>
                            {
                                existingCheckIn = VerifyVehicleCheckInStatus();
                                if (existingCheckIn == string.Empty)
                                {
                                    VehicleCheckIn objPassVehicle       = new VehicleCheckIn();
                                    User objloginuser                   = (User)App.Current.Properties["LoginUser"];
                                    objPassVehicle.UserID               = objloginuser.UserID;
                                    objPassVehicle.LocationID           = objloginuser.LocationParkingLotID.LocationID.LocationID;
                                    objPassVehicle.LocationParkingLotID = objloginuser.LocationParkingLotID.LocationParkingLotID;
                                    objPassVehicle.VehicleTypeCode      = SelectedVehicle;
                                    objPassVehicle.BayNumberID          = objselectedbay.ParkingBayID;
                                    objPassVehicle.RegistrationNumber   = entryRegistrationNumber.Text;
                                    objPassVehicle.CustomerID           = objCustomerPass.CustomerVehicleID.CustomerID.CustomerID;
                                    msg = dal_DALCheckIn.SavePassVehicleCheckIn(Convert.ToString(App.Current.Properties["apitoken"]), objPassVehicle);
                                    if (msg == "Success")
                                    {
                                        masterPage = new MasterHomePage();
                                    }
                                }
                            });

                            if (existingCheckIn == string.Empty)
                            {
                                if (msg == "Success")
                                {
                                    await Navigation.PushAsync(masterPage);
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Unable to Check In, Please contact Admin", "Ok");
                                }
                            }
                            else
                            {
                                await DisplayAlert("Alert", "Vehicle Checked In as Violation at " + existingCheckIn, "Ok");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Alert", "Please select Bay Number", "Ok");
                        }
                    }
                    else

                    {
                        await DisplayAlert("Alert", "Please select vehicle type and Registration Number- minimum 6 digits", "Ok");
                    }
                }
                else
                {
                    await DisplayAlert("Alert", "Unable to Check In, Please contact Admin", "Ok");
                }
                ShowLoading(false);
                btnCheckIn.IsVisible = true;
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "ViolationPage.xaml.cs", "", "BtnCheckIn_Clicked");
                ShowLoading(false);
                btnCheckIn.IsVisible = true;
            }
        }
        private async void BtnViolation_Clicked(object sender, EventArgs e)
        {
            string         resultmsg       = string.Empty;
            string         existingCheckIn = string.Empty;
            MasterHomePage masterPage      = null;

            BtnViolation.IsVisible = false;
            ShowLoading(true);
            try
            {
                int number;
                if (DeviceInternet.InternetConnected())
                {
                    if (SelectedVehicle != string.Empty)
                    {
                        if (entryRegistrationNumber.Text != null && (!entryRegistrationNumber.Text.Contains(" ") && (entryRegistrationNumber.Text.Length >= 6 && entryRegistrationNumber.Text.Length <= 10)))
                        {
                            string regNumber = entryRegistrationNumber.Text;
                            string regFormat = regNumber.Substring(regNumber.Length - 4);
                            if (int.TryParse(regFormat, out number))
                            {
                                if (pickerBayNumers.SelectedItem != null)
                                {
                                    if ((checkBoxClampVehicle.IsChecked) || (chkWarning.IsChecked))
                                    {
                                        if (pickerVehicleReason.SelectedItem != null)
                                        {
                                            ParkingBay      objselectedbay    = (ParkingBay)pickerBayNumers.SelectedItem;
                                            ViolationReason objselectedreason = (ViolationReason)pickerVehicleReason.SelectedItem;
                                            if (imgCameraByteData != null)
                                            {
                                                if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                                                {
                                                    await Task.Run(() =>
                                                    {
                                                        existingCheckIn = VerifyVehicleCheckInStatus();
                                                        if (existingCheckIn == string.Empty)
                                                        {
                                                            ViolationAndClamp objViolationAndClamp = new ViolationAndClamp();
                                                            User objloginuser                         = (User)App.Current.Properties["LoginUser"];
                                                            objViolationAndClamp.UserID               = objloginuser.UserID;
                                                            objViolationAndClamp.UserTypeID           = objloginuser.UserTypeID.UserTypeID;
                                                            objViolationAndClamp.LocationID           = objloginuser.LocationParkingLotID.LocationID.LocationID;
                                                            objViolationAndClamp.LocationParkingLotID = objloginuser.LocationParkingLotID.LocationParkingLotID;
                                                            objViolationAndClamp.LocationName         = objloginuser.LocationParkingLotID.LocationID.LocationName;
                                                            objViolationAndClamp.RegistrationNumber   = entryRegistrationNumber.Text;
                                                            objViolationAndClamp.BayNumberID          = objselectedbay.ParkingBayID;
                                                            objViolationAndClamp.BayNumber            = objselectedbay.ParkingBayName;
                                                            objViolationAndClamp.IsClamp              = checkBoxClampVehicle.IsChecked;
                                                            objViolationAndClamp.ReasonID             = objselectedreason.ViolationReasonID;
                                                            objViolationAndClamp.ReasonName           = objselectedreason.Reason;
                                                            objViolationAndClamp.VehicleTypeCode      = SelectedVehicle;
                                                            DateTime openTime                         = DateTime.Parse(objloginuser.LocationParkingLotID.LotOpenTime);
                                                            if (DateTime.Now < openTime)
                                                            {
                                                                objViolationAndClamp.ViolationStartTime = openTime;
                                                                objViolationAndClamp.ViolationTime      = openTime.ToString("MM/dd/yyyy HH:mm tt");
                                                            }
                                                            else
                                                            {
                                                                objViolationAndClamp.ViolationStartTime = violationTime;
                                                                objViolationAndClamp.ViolationTime      = violationTime.ToString("MM/dd/yyyy HH:mm tt");
                                                            }

                                                            objViolationAndClamp.IsWarning             = Convert.ToBoolean(chkWarning.IsChecked);
                                                            objViolationAndClamp.VehicleImageLottitude = Convert.ToDecimal(Latitude);
                                                            objViolationAndClamp.VehicleImageLongitude = Convert.ToDecimal(Longitude);
                                                            if (imgCameraByteData != null)
                                                            {
                                                                objViolationAndClamp.ViolationImage = ByteArrayCompressionUtility.Compress(imgCameraByteData);
                                                            }
                                                            resultmsg = dal_ViolationClamp.SaveViolationAndClamp(Convert.ToString(App.Current.Properties["apitoken"]), objViolationAndClamp);
                                                            if (resultmsg == "Success")
                                                            {
                                                                masterPage = new MasterHomePage();
                                                            }
                                                        }
                                                    });

                                                    if (existingCheckIn == string.Empty)
                                                    {
                                                        if (resultmsg == "Success")
                                                        {
                                                            await Navigation.PushAsync(masterPage);
                                                        }
                                                        else
                                                        {
                                                            await DisplayAlert("Alert", "Violation Check In failed,Please contact Admin.", "Ok");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        await DisplayAlert("Alert", "Vehicle Checked In as Violation at " + existingCheckIn, "Ok");
                                                    }
                                                }
                                                else
                                                {
                                                    await DisplayAlert("Alert", "User details and API token unavailable. Login again", "Ok");
                                                }
                                            }
                                            else
                                            {
                                                await DisplayAlert("Alert", "Please select Vehicle Image.", "Ok");
                                            }
                                        }
                                        else
                                        {
                                            await DisplayAlert("Alert", "Please select Reason.", "Ok");
                                        }
                                    }
                                    else
                                    {
                                        await DisplayAlert("Alert", "Please check Clamp or Warning ", "Ok");
                                    }
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Please select Bay Number.", "Ok");
                                }
                            }
                            else
                            {
                                await DisplayAlert("Alert", "Please enter valid Registration Number", "Ok");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Alert", "Please enter valid Registration Number.", "Ok");
                        }
                    }
                    else
                    {
                        await DisplayAlert("Alert", "Please select Vehicle type", "Ok");
                    }
                    BtnViolation.IsVisible = true;
                }
                else
                {
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");

                    ShowLoading(false);
                    BtnViolation.IsVisible = true;
                }
            }
            catch (Exception ex)
            {
            }
            ShowLoading(false);
            BtnViolation.IsVisible = true;
        }