public async void AddVehicleViolation(ViolationAndClamp objViolationVehicle)
        {
            try
            {
                await firebase.Child("CustomerParkingSlot")
                .PostAsync(objViolationVehicle);

                await firebase.Child("CustomerParkingSlotHistory")
                .PostAsync(objViolationVehicle);
            }
            catch (Exception ex)
            {
                string exmsg = ex.Message;
            }
        }
Beispiel #2
0
        public string SaveVehicleViolationAndClamp(ViolationAndClamp objViolationanClamp)
        {
            string resultmsg = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_SaveVehicleViolationAndClamp", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@UserID", objViolationanClamp.UserID);
                        sqlcmd_obj.Parameters.AddWithValue("@LocationID", objViolationanClamp.LocationID);
                        sqlcmd_obj.Parameters.AddWithValue("@LocationParkingLotID", objViolationanClamp.LocationParkingLotID);
                        sqlcmd_obj.Parameters.AddWithValue("@BayNumberID", objViolationanClamp.BayNumberID);
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleTypeCode", objViolationanClamp.VehicleTypeCode);
                        sqlcmd_obj.Parameters.AddWithValue("@RegistrationNumber", objViolationanClamp.RegistrationNumber);
                        sqlcmd_obj.Parameters.AddWithValue("@ViolationImage", objViolationanClamp.ViolationImage);
                        sqlcmd_obj.Parameters.AddWithValue("@ReasonID", objViolationanClamp.ReasonID);
                        sqlcmd_obj.Parameters.AddWithValue("@IsClamp", objViolationanClamp.IsClamp);
                        sqlcmd_obj.Parameters.AddWithValue("@IsWarning", objViolationanClamp.IsWarning);
                        sqlcmd_obj.Parameters.AddWithValue("@ViolationStartTime", objViolationanClamp.ViolationTime);
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleImageLottitude", objViolationanClamp.VehicleImageLottitude == null || objViolationanClamp.VehicleImageLottitude == 0 ? (Object)DBNull.Value : objViolationanClamp.VehicleImageLottitude);
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleImageLongitude", objViolationanClamp.VehicleImageLongitude == null || objViolationanClamp.VehicleImageLongitude == 0 ? (Object)DBNull.Value : objViolationanClamp.VehicleImageLongitude);
                        sqlconn_obj.Open();
                        int resultid = sqlcmd_obj.ExecuteNonQuery();
                        if (resultid > 0)
                        {
                            resultmsg = "Success";
                        }
                        else
                        {
                            resultmsg = "Fail";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALViolation", "Proc: " + "OPAPP_PROC_SaveVehicleViolationAndClamp", "SaveVehicleViolationAndClamp");
            }
            return(resultmsg);
        }
Beispiel #3
0
        public ViolationAndClamp GetVehicleViolationWarningCount(CustomerVehicle objInput)
        {
            ViolationAndClamp objViolationAndClamp = new ViolationAndClamp();
            string            resultMsg            = string.Empty;

            try
            {
                using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString()))
                {
                    using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_GetVehicleViolationWarning", sqlconn_obj))
                    {
                        sqlcmd_obj.CommandType = CommandType.StoredProcedure;
                        sqlcmd_obj.Parameters.AddWithValue("@VehicleTypeCode", objInput.VehicleTypeID.VehicleTypeCode);
                        sqlcmd_obj.Parameters.AddWithValue("@RegistrationNumber", objInput.RegistrationNumber);
                        sqlconn_obj.Open();
                        SqlDataAdapter sqldap   = new SqlDataAdapter(sqlcmd_obj);
                        DataTable      resultdt = new DataTable();
                        sqldap.Fill(resultdt);
                        if (resultdt.Rows.Count > 0)
                        {
                            int warningCount = resultdt.Rows[0]["WarningCount"] == DBNull.Value?0:Convert.ToInt32(resultdt.Rows[0]["WarningCount"]);
                            if (warningCount >= 3)
                            {
                                objViolationAndClamp.IsWarning = true;
                            }
                            else
                            {
                                objViolationAndClamp.IsWarning = false;
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                objExceptionlog.InsertException("WebAPI", ex.Message, "DALViolation", "Proc: " + "OPAPP_PROC_GetVehicleViolationWarning", "GetVehicleViolationWarningCount");
            }
            return(objViolationAndClamp);
        }
Beispiel #4
0
        public string SaveViolationAndClamp(string accessToken, ViolationAndClamp objviolationandclamp)
        {
            string apirespone = string.Empty;

            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/postOPAPPSaveVehicleViolationAndClamp";
                    // make the request
                    var json    = JsonConvert.SerializeObject(objviolationandclamp);
                    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);
                            apirespone = apiResult.Message;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(apirespone);
        }
        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;
        }