예제 #1
0
 public List <Trip> GetTrips(GPS gps, string gpxFileName)
 {
     return(TripCollection
            .Where(t => t.GPS.DeviceID == gps.DeviceID)
            .Where(t => t.GPXFileName == gpxFileName)
            .ToList());
 }
예제 #2
0
 public void Visit(TripCollection trips)
 {
     using (var textReader = GetTextReader <Trip>())
     {
         Feed.Trips = new TripCollection(GetEntityParser <Trip>().Parse(textReader).Cast <Trip>());
     }
 }
        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);
        }
예제 #4
0
 public void MarkAllNotShownInMap()
 {
     foreach (var item in TripCollection.Where(t => t.ShownInMap))
     {
         item.ShownInMap = false;
     }
 }
예제 #5
0
 public List <Trip> GetTrips(GPS gps, DateTime dateOfTrip)
 {
     return(TripCollection
            .Where(t => t.GPS.DeviceID == gps.DeviceID)
            .Where(t => t.DateTimeDeparture > dateOfTrip)
            .Where(t => t.DateTimeDeparture < dateOfTrip.AddDays(1))
            .ToList());
 }
예제 #6
0
 public List <Trip> TripsUsingGPSByMonth(GPS gps, DateTime month)
 {
     return(TripCollection
            .Where(t => t.GPS.DeviceID == gps.DeviceID)
            .Where(t => t.DateTimeDeparture > month)
            .Where(t => t.DateTimeDeparture < month.AddMonths(1))
            .OrderBy(t => t.DateTimeDeparture).ToList());
 }
        private void BindTripDate()
        {
            TripController tripController = new TripController();
            TripCollection tripCollection = tripController.SelectDateByRouteID(this.cboTrip.SelectedValue.ToString());

            this.cboDate.DisplayMember = "TripDate";
            this.cboDate.ValueMember   = "TripDate";
            this.cboDate.DataSource    = tripCollection;
        }
예제 #8
0
        public Dictionary <DateTime, List <Trip> > TripArchivesByMonth(GPS gps)
        {
            var d = TripCollection
                    .Where(g => g.GPS.DeviceID == gps.DeviceID)
                    .OrderBy(m => m.DateTimeDeparture)
                    .GroupBy(o => o.MonthYear)
                    .ToDictionary(g => g.Key, g => g.ToList());

            return(d);
        }
예제 #9
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);
        }
        private void BindTime()
        {
            TripController tripController = new TripController();
            TripCollection tripCollection = tripController.SelectTime(this.cboTrip.SelectedValue.ToString(), Convert.ToDateTime(this.cboDate.SelectedValue.ToString()));

            TripInfo tripInfo = new TripInfo();

            tripInfo.Time   = "-Select One-";
            tripInfo.TimeID = null;
            tripCollection.Insert(0, tripInfo);

            this.cboTime.DisplayMember = "Time";
            this.cboTime.ValueMember   = "TimeID";
            this.cboTime.DataSource    = tripCollection;
            this.cboTime.SelectedIndex = 0;
        }
        private void BindTripID()
        {
            TripController tripController = new TripController();
            TripCollection tripCollection = tripController.SelectList();

            TripInfo tripInfo = new TripInfo();

            tripInfo.TripCode = " - Select One - ";
            tripInfo.TripID   = null;
            tripCollection.Insert(0, tripInfo);

            this.cboTrip.DisplayMember = "TripCode";
            this.cboTrip.ValueMember   = "TripID";
            this.cboTrip.DataSource    = tripCollection;
            this.cboTrip.SelectedIndex = 0;
        }
        private void BindToTripCode()
        {
            TripController tripController = new TripController();
            TripCollection tripCollection = tripController.SelectListRecord();

            TripInfo info = new TripInfo();

            info.TripCode = " - Select One - ";
            info.TripID   = null;
            tripCollection.Insert(0, info);

            cboToTripCode.DisplayMember = "TripCode";
            cboToTripCode.ValueMember   = "TripID";
            cboToTripCode.DataSource    = tripCollection;

            cboToTripCode.SelectedIndex = 0;
        }
예제 #15
0
        public bool DeleteRecordFromRepo(int tripID)
        {
            if (tripID == 0)
            {
                throw new Exception("Trip ID cannot be null");
            }

            int index = 0;

            while (index < TripCollection.Count)
            {
                if (TripCollection[index].TripID == tripID)
                {
                    TripCollection.RemoveAt(index);
                    break;
                }
                index++;
            }

            return(_operationSucceeded);
        }
예제 #16
0
 public void Visit(TripCollection trips)
 {
     SetValidity(trips);
 }
예제 #17
0
 public List <Trip> GetAllTrips()
 {
     return(TripCollection.ToList());
 }
예제 #18
0
        public EntityValidationResult ValidateTrip(Trip trip, bool isNew)
        {
            EntityValidationResult evr = new EntityValidationResult();

            if (trip.OperatorName == null || trip.OperatorName.Length < 3)
            {
                evr.AddMessage("Operator name must be at least 3 letters long");
            }

            if (trip.VesselName == null || trip.VesselName.Length < 3)
            {
                evr.AddMessage("Vessel name 3 letters long");
            }

            if (trip.Gear == null && trip.OtherGear == null)
            {
                evr.AddMessage("Gear or gear other name cannnot be both empty");
            }

            if (trip.DateTimeDeparture == null || trip.DateTimeDeparture > DateTime.Now)
            {
                evr.AddMessage("Date and time of departure cannot be empty and cannot be in the future");
            }
            else if (trip.DateTimeArrival == null || trip.DateTimeArrival > DateTime.Now)
            {
                evr.AddMessage("Date and time of arrival cannot be empty and cannot be in the future");
            }
            else if (trip.DateTimeDeparture >= trip.DateTimeArrival)
            {
                evr.AddMessage("Date and time of departure must be before date and time of arrival");
            }


            int?overlapID = null;

            foreach (var tripItem in TripCollection
                     .Where(t => t.TripID != trip.TripID)
                     .Where(t => t.DeviceID == trip.DeviceID))
            {
                if (trip.DateTimeDeparture >= tripItem.DateTimeDeparture && trip.DateTimeDeparture <= tripItem.DateTimeArrival)
                {
                    overlapID = tripItem.TripID;
                    break;
                }
                else if (trip.DateTimeArrival >= tripItem.DateTimeDeparture && trip.DateTimeArrival <= tripItem.DateTimeArrival)
                {
                    overlapID = tripItem.TripID;
                    break;
                }
                else if (trip.DateTimeDeparture <= tripItem.DateTimeDeparture && trip.DateTimeArrival >= tripItem.DateTimeArrival)
                {
                    overlapID = tripItem.TripID;
                    break;
                }
            }
            if (overlapID != null)
            {
                evr.AddMessage($"This trip overlaps with trip ID {overlapID}");
            }


            return(evr);
        }
예제 #19
0
 public string VesselOfTrip(int tripID)
 {
     return(TripCollection.FirstOrDefault(t => t.TripID == tripID).VesselName);
 }
예제 #20
0
 public Fisher GetFisherOfTrip(int tripID)
 {
     return(TripCollection.FirstOrDefault(t => t.TripID == tripID).Operator);
 }
예제 #21
0
 public Trip GetLatestAdded()
 {
     return(TripCollection.OrderByDescending(t => t.DateAdded).FirstOrDefault());
 }
예제 #22
0
 public Trip GetTrip(int tripID)
 {
     CurrentEntity = TripCollection.FirstOrDefault(n => n.TripID == tripID);
     return(CurrentEntity);
 }
예제 #23
0
 /// <summary>
 /// A method called by the UI to start generating the paths
 /// </summary>
 public void StartGeneration()
 {
     TripCollection.Clear();
     Task.Run(() => { CSolver.GetShortestPath(); });
 }
예제 #24
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();
 }
예제 #25
0
 public List <Trip> GetAllTrips(string deviceID)
 {
     return(TripCollection.Where(t => t.DeviceID == deviceID).ToList());
 }
예제 #26
0
 protected virtual void OnTripsChecked(TripCollection trips, ValidationEventArgs e)
 {
     TripsChecked?.Invoke(trips, e);
 }
예제 #27
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);
            }
        }
예제 #28
0
 public Trip GetLastTripOfDevice(string deviceID)
 {
     return(TripCollection
            .Where(t => t.DeviceID == deviceID)
            .OrderByDescending(t => t.TripID).FirstOrDefault());
 }
예제 #29
0
 public void Visit(TripCollection trips)
 {
     OnTripsChecked(trips, new ValidationEventArgs(CheckValidity(trips)));
 }