Ejemplo n.º 1
0
        public async void GenerateAppReport()
        {
            try
            {
                objlot = null;
                if (DeviceInternet.InternetConnected())
                {
                    objReportUser = new User();
                    VMLocationLots objselectedlot = (VMLocationLots)pickerLocationLot.SelectedItem;
                    if (objselectedlot != null)
                    {
                        objReportUser.LocationParkingLotID.LocationID.LocationID   = objselectedlot.LocationID;
                        objReportUser.LocationParkingLotID.LocationParkingLotID    = objselectedlot.LocationParkingLotID;
                        objReportUser.LocationParkingLotID.LocationParkingLotName  = objselectedlot.LocationParkingLotName;
                        objReportUser.LocationParkingLotID.LocationID.LocationName = objselectedlot.LocationName;

                        if (pickerOperator.SelectedItem != null)
                        {
                            var objselectedOperator = (User)pickerOperator.SelectedItem;
                            if (objselectedOperator.UserCode.Contains("ALL"))
                            {
                                var userobj = (User)App.Current.Properties["LoginUser"];
                                objReportUser.UserID   = 0;
                                objReportUser.UserCode = userobj.UserCode;
                            }
                            else
                            {
                                objReportUser.UserID   = objselectedOperator.UserID;
                                objReportUser.UserCode = objselectedOperator.UserCode;
                            }
                        }
                        else
                        {
                            var userobj = (User)App.Current.Properties["LoginUser"];
                            objReportUser.UserID   = userobj.UserID;
                            objReportUser.UserCode = userobj.UserCode;
                        }

                        if (objselectedlot.LocationID == 0 && objselectedlot.LocationParkingLotID == 0 && objselectedlot.LotName == "ALL")
                        {
                            var userobj = (User)App.Current.Properties["LoginUser"];
                            objReportUser.UserID   = userobj.UserID;
                            objReportUser.UserCode = "ALL";
                        }
                    }
                    ShowLoading(true);
                    await Task.Run(() =>
                    {
                        if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                        {
                            DateTime fromDate        = new DateTime(datePickerFromDate.Date.Year, datePickerFromDate.Date.Month, datePickerFromDate.Date.Day, datePickerFromTime.Time.Hours, datePickerFromTime.Time.Minutes, 0);
                            objReportUser.LoginTime  = fromDate;
                            objReportUser.LogoutTime = new DateTime(datePickerToDate.Date.Year, datePickerToDate.Date.Month, datePickerToDate.Date.Day, datePickerToTime.Time.Hours, datePickerToTime.Time.Minutes, 0);;
                            objlot = new LocationLotParkingReport(Convert.ToString(App.Current.Properties["apitoken"]), objReportUser);
                        }
                    });

                    if (objlot != null)
                    {
                        lvSummaryReports.BindingContext            = objlot;
                        lstvwStationPassesReport.BindingContext    = objlot.GetLocationLotPassesReport();
                        lstvwStationViolationReport.BindingContext = objlot.GetLocationLotViolationReport();
                        StationVehicles objStationVehicles = objlot.GetLocationLotTotalRevenue();
                        TotalStationVehicleCash.Text = objStationVehicles.StationVehicleCash.ToString("N2");
                        TotalStationVehicleEpay.Text = objStationVehicles.StationVehicleEPay.ToString("N2");
                    }
                    ShowLoading(false);
                }
                else
                {
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");

                    ShowLoading(false);
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "ReportPage.xaml.cs", "", "ButtonGenerateReport_Clicked");
            }
        }
        public LocationLotParkingReport(string apitoken, User objLoginUser)
        {
            SelectedRowItem      = null;
            LotParkingReportList = null;
            try
            {
                DALReport       dal_Report = new DALReport();
                VMReportSummary result     = dal_Report.GetLocationLotReport(apitoken, objLoginUser);
                var             VMLocationLotParkingReportID = result.VMLocationLotParkingReportID;

                #region Parking Report
                if (VMLocationLotParkingReportID != null)
                {
                    LotTotalCheckIn      = VMLocationLotParkingReportID.LotTotalCheckIn;
                    LotTotalCheckOut     = VMLocationLotParkingReportID.LotTotalCheckOut;
                    LotTotalFOC          = VMLocationLotParkingReportID.LotTotalFOC;
                    LotRevenueCash       = VMLocationLotParkingReportID.LotRevenueCash;
                    LotRevenueEpay       = VMLocationLotParkingReportID.LotRevenueEpay;
                    LotParkingReportList = VMLocationLotParkingReportID.LotParkingReportList;
                }


                #endregion

                #region Pass Report
                try
                {
                    objVMVehiclePassReport = result.VMLocationLotPassReportID;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion

                #region Violation Report
                try
                {
                    objVMClampedVehiclesSummary = result.VMLocationLotViolationsID;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                #endregion
                try
                {
                    #region Total Cash and Epay
                    objStationVehicleReport = new StationVehicles();
                    objStationVehicleReport.StationVehicleCash = result.Cash;
                    objStationVehicleReport.StationVehicleEPay = result.EPay;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }