public TripCollection SelectList()
        {
            TripCollection collection = new TripCollection();
            IDataReader    Reader     = DataAccess.SelectList();

            while (Reader.Read())
            {
                TripInfo tripInfo = new TripInfo();
                tripInfo.TripID      = Convert.ToString(Reader["TripID"]);
                tripInfo.TripCode    = Convert.ToString(Reader["TripCode"]);
                tripInfo.TripDate    = Convert.ToDateTime(Reader["Date"]);
                tripInfo.TimeID      = Convert.ToString(Reader["TimeID"]);
                tripInfo.Time        = Convert.ToString(Reader["Time"]);
                tripInfo.RouteID     = Convert.ToString(Reader["RouteID"]);
                tripInfo.RouteName   = Convert.ToString(Reader["RouteName"]);
                tripInfo.BusID       = Convert.ToString(Reader["BusID"]);
                tripInfo.BusNo       = Convert.ToString(Reader["BusNo"]);
                tripInfo.Driver1ID   = Convert.ToString(Reader["Driver1ID"]);
                tripInfo.Driver1Name = Convert.ToString(Reader["DriverName"]);
                tripInfo.Driver2ID   = Convert.ToString(Reader["Driver2ID"]);
                tripInfo.Driver2Name = Convert.ToString(Reader["DriverName"]);
                tripInfo.Price       = Convert.ToDecimal(Reader["Price"]);
                collection.Add(tripInfo);
            }
            Reader.Close();
            return(collection);
        }
Beispiel #2
0
        public bool AddRecordToRepo(Trip trip)
        {
            if (trip == null)
            {
                throw new ArgumentNullException("Error: The argument is Null");
            }

            trip.DateAdded = DateTime.Now;
            TripCollection.Add(trip);

            return(_operationSucceeded);
        }
        public TripCollection SelectTime(string routeID, DateTime date)
        {
            TripCollection tripCollection = new TripCollection();
            IDataReader    reader         = DataAccess.SelectTime(routeID, date);

            while (reader.Read())
            {
                TripInfo tripInfo = new TripInfo();
                tripInfo.TimeID = Convert.ToString(reader["TimeID"]);
                tripInfo.Time   = Convert.ToString(reader["Time"]);
                tripCollection.Add(tripInfo);
            }
            reader.Close();
            return(tripCollection);
        }
        public TripCollection SelectDateByRouteID(string routeID)
        {
            TripCollection tripCollection = new TripCollection();
            IDataReader    Reader         = DataAccess.SelectDateByRouteID(routeID);

            while (Reader.Read())
            {
                TripInfo tripInfo = new TripInfo();
                tripInfo.TripDate = Convert.ToDateTime(Reader["Date"]);

                tripCollection.Add(tripInfo);
            }
            Reader.Close();
            return(tripCollection);
        }
Beispiel #5
0
        public void LoadFolder(string folder)
        {
            TripCollection.Clear();

            _folder = folder;
            DirectoryInfo dir = new DirectoryInfo(folder);

            DateTime currentDate = DateTime.MinValue;

            Trip trip = null;

            if (!Directory.Exists(folder))
            {
                return;
            }

            foreach (var file in dir.GetFiles("*.mp4"))
            {
                string fileName          = Path.GetFileNameWithoutExtension(file.FullName);
                var    fileStartDateTime = DateTime.ParseExact(fileName.Substring(0, fileName.LastIndexOf("_")), "yyyy_MMdd_HHmmss", null);

                if (currentDate.Date != fileStartDateTime.Date)
                {
                    if (trip != null)
                    {
                        TripCollection.Add(trip);
                    }
                    trip = new Trip();
                }
                else if (fileStartDateTime.Subtract(currentDate) > TimeSpan.FromMinutes(10))
                {
                    TripCollection.Add(trip);
                    trip = new Trip();
                }
                currentDate = fileStartDateTime;

                string jpg = Utils.GetFileNameWithoutExt(file.FullName) + ".jpg";

                if (!File.Exists(jpg))
                {
                    try
                    {
                        VideoFileReader reader = new VideoFileReader();
                        reader.Open(file.FullName);
                        Bitmap frame = reader.ReadVideoFrame();
                        reader.Close();

                        frame.Save(jpg, ImageFormat.Jpeg);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (trip.StartDateTime > currentDate)
                {
                    trip.StartDateTime = currentDate;
                }
                if (trip.EndDateTime < currentDate)
                {
                    trip.EndDateTime = currentDate;
                }

                Video video = new Video()
                {
                    FilePath = folder + file.Name, Date = fileStartDateTime, ThumbnailPath = jpg
                };

                trip.Videos.Add(video);
            }

            if (trip != null)
            {
                TripCollection.Add(trip);
            }
        }
Beispiel #6
0
 /// <summary>
 /// A method called when a new solution is generated
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void OnNewTripFound(object sender, TripAddedEventArgs args)
 {
     OnUIThread(() => { TripCollection.Add(args.NewTrip); });
     NotifyOfPropertyChange();
 }