コード例 #1
0
 public bool CreateStation(Station station)
 {
     try
     {
         _stationRepository.Insert(station);
         return true;
     }
     catch (Exception ex)
     {
         HandleLogging.LogMessage(ex, "CreateStation", 1, WebOperationContext.Current);
         return false;
     }
 }
コード例 #2
0
        public void Update(Station station)
        {
            Station rStation = GetStationById(station.ID);

            if (rStation == null)
                return;

            rStation.Title = station.Title;
            rStation.Description = station.Description;
            rStation.StationLat = station.StationLat;
            rStation.StationLong = station.StationLong;
            rStation.IsActive = station.IsActive;
            rStation.IsOperational = station.IsOperational;
            db.SaveChanges();
        }
コード例 #3
0
        public List<Edge> GetEdgesByStartStation(Station station)
        {
            var edges = db.Edges.Where(x => x.StartStationId.Equals(station.ID));
            var returnList = new List<Edge>();
            foreach (var edge in edges)
            {
                edge.EndStation = db.Stations.AsNoTracking().FirstOrDefault(x => x.ID.Equals(edge.EndStationId));
                if (edge.EndStation != null)
                {
                    var batteryStorage =
                        db.BatteryStorages.AsNoTracking().FirstOrDefault(
                            x => x.StationId.Equals(edge.EndStationId) && x.IsActive);
                    if(batteryStorage != null)
                        if((batteryStorage.Available - batteryStorage.Reserved - batteryStorage.Charging) > 0)
                            returnList.Add(edge);
                }
            }

            return returnList;
        }
コード例 #4
0
 public void Insert(Station station)
 {
     db.Stations.Add(station);
     db.SaveChanges();
 }
コード例 #5
0
 private void ReconstructPath(Station current)
 {
     Station temp;
     if (_cameFrom.TryGetValue(current, out temp))
     {
         Edge e = _edgeRepository.GetEdgeByStartEndStation(temp, current);
         current.Edges = new List<Edge> { e };
         ReconstructPath(temp);
         _path.Add(current);
     }
     else
     {
         current.Edges = new List<Edge>();
         _path.Add(current);
     }
 }
コード例 #6
0
 private void InsertVertex(Station vert, List<Station> path, decimal fScore)
 {
     vert.Edges = _edgeRepository.GetEdgesByStartStation(vert);
     _openSet.Insert(vert, path, fScore);
 }
コード例 #7
0
 private decimal Heuristic(Station start, Station end)
 {
     var endEdge = _edgeRepository.GetEdgeByStartEndStation(start, end);
     return endEdge != null ? endEdge.Distance : -1;
 }
コード例 #8
0
 protected bool Equals(Station other)
 {
     return ID == other.ID;
 }
コード例 #9
0
 public bool CreateStation(Station station)
 {
     return new StationService().CreateStation(station);
 }
コード例 #10
0
 public bool UpdateStation(Station station)
 {
     return new StationService().UpdateStation(station);
 }
コード例 #11
0
 public Edge GetEdgeByStartEndStation(Station start, Station end)
 {
     return db.Edges.AsNoTracking().FirstOrDefault(x => x.StartStationId.Equals(start.ID) && x.EndStationId.Equals(end.ID));
 }
コード例 #12
0
        public IQueryable<Edge> GetEdgesByStation(Station station)
        {
            var edges = db.Edges.Where(x => x.StartStationId.Equals(station.ID) || x.EndStationId.Equals(station.ID));
            foreach (var edge in edges)
            {
                edge.EndStation = db.Stations.FirstOrDefault(x => x.ID.Equals(edge.EndStationId));
            }

            return edges;
        }