Exemplo n.º 1
0
        public void GetLotOccupancy(User objloginUserLot)
        {
            try
            {
                ShowLoading(true);
                lvLotOccupancyReport.ItemsSource = null;

                labelTwoWheelerLotCapcity.Text   = string.Empty;
                labelThreeWheelerLotCapcity.Text = string.Empty;
                labelFourWheelerLotCapacity.Text = string.Empty;
                labelHVWheelerLotCapcity.Text    = string.Empty;

                labelTwoWheelerLotOccupancyPer.Text   = string.Empty;
                labelThreeWheelerLotOccupancyPer.Text = string.Empty;
                labelFourWheelerLotOccupancyPer.Text  = string.Empty;
                labelHeavyWheelerLotOccupancyPer.Text = string.Empty;

                List <VMLocationLotOccupancyReport> lstOccupancy = new List <VMLocationLotOccupancyReport>();
                if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                {
                    DALReport dal_Report = new DALReport();

                    objloginUserLot.LoginTime  = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 06, 00, 00);
                    objloginUserLot.LogoutTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                    VMLocationLotOccupancyReport objOccupancy = dal_Report.VMGetLocationLotOccupancyReport(Convert.ToString(App.Current.Properties["apitoken"]), objloginUserLot);
                    if (objOccupancy != null && objOccupancy.LocationLotOccupancyReportID.Count > 0)
                    {
                        lvLotOccupancyReport.ItemsSource = objOccupancy.LocationLotOccupancyReportID;

                        labelTwoWheelerLotCapcity.Text   = objOccupancy.TotalTwoWheelerLotCapacity;
                        labelThreeWheelerLotCapcity.Text = objOccupancy.TotalThreeWheelerLotCapacity;
                        labelFourWheelerLotCapacity.Text = objOccupancy.TotalFourWheelerLotCapacity;
                        labelHVWheelerLotCapcity.Text    = objOccupancy.TotalHeavyWheelerLotCapacity;

                        labelTwoWheelerLotOccupancyPer.Text   = objOccupancy.TotalTwoWheelerPercentage;
                        labelThreeWheelerLotOccupancyPer.Text = objOccupancy.TotalThreeWheelerPercentage;
                        labelFourWheelerLotOccupancyPer.Text  = objOccupancy.TotalFourWheelerPercentage;
                        labelHeavyWheelerLotOccupancyPer.Text = objOccupancy.TotalHeavyWheelerPercentage;
                    }
                }
                ShowLoading(false);
            }
            catch (Exception ex)
            {
                ShowLoading(false);
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "LotOccupancy.xaml.cs", "", "GetLotOccupancy");
            }
        }
Exemplo n.º 2
0
        public VMLocationLotOccupancyReport VMGetLocationLotOccupancyReport(string accessToken, User objSelectedUser)
        {
            VMLocationLotOccupancyReport result = 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/postLotOccupancyReport";
                    // make the request
                    var json    = JsonConvert.SerializeObject(objSelectedUser);
                    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)
                            {
                                result = JsonConvert.DeserializeObject <VMLocationLotOccupancyReport>(Convert.ToString(apiResult.Object));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }