コード例 #1
0
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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>());
     }
 }
コード例 #3
0
        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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 public void MarkAllNotShownInMap()
 {
     foreach (var item in TripCollection.Where(t => t.ShownInMap))
     {
         item.ShownInMap = false;
     }
 }
コード例 #5
0
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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());
 }
コード例 #7
0
        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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
        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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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;
        }
コード例 #13
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;
        }
コード例 #14
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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
        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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 public List <Trip> GetAllTrips()
 {
     return(TripCollection.ToList());
 }
コード例 #18
0
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
        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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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
ファイル: TripViewModel.cs プロジェクト: radtek/GPXManager
 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)));
 }