Ejemplo n.º 1
0
        //
        // Summary:
        //     Generates the drivers trip reports.
        //
        private async void OnRunDriverDetails()
        {
            try
            {
                DriverTripReport.Clear();
                DriverList.Clear();
                DriverTripDetails.Clear();
                var inputValue = DriverInfoText.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                foreach (string val in inputValue)
                {
                    var commands = val.Split(' ');
                    switch (commands[0].ToUpperInvariant())
                    {
                    case "DRIVER":
                        if (commands.Length == 2)
                        {
                            DriverList.Add(commands[1]);
                        }
                        break;

                    case "TRIP":
                        try
                        {
                            if (commands.Length == 5)
                            {
                                DriverTripDetails.Add(new DriverTripModel(commands));
                            }
                        }
                        catch (Exception ex) {}
                        break;
                    }
                }

                List <DriverTripReportModel> driverTripReport = DriverServiceManager.GetDriverTripReports(DriverList, DriverTripDetails);
                if (driverTripReport.Any())
                {
                    DriverTripReport = new ObservableCollection <DriverTripReportModel>(driverTripReport);
                }
                ShowResults = DriverTripReport.Any();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
            }
        }
Ejemplo n.º 2
0
 public async void Initialize()
 {
     try
     {
         var inputStream = FileServiceManager.GetInputStream("driversinfo.txt");
         if (inputStream != null)
         {
             using (var reader = new StreamReader(inputStream))
             {
                 DriverInfoText = reader.ReadToEnd();
             }
         }
         ShowResults = false;
         DriverTripReport.Clear();
     }
     catch (Exception ex)
     {
         await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Ok");
     }
 }