Exemplo n.º 1
0
        public TimeSpan GetTimeBetweenStations(int StatCode1, int StatCode2, int LineId)
        {
            TimeSpan sum = TimeSpan.Zero;

            if (StatCode1 == StatCode2)
            {
                sum = new TimeSpan(0, 0, 15);
            }
            BO.Line l     = GetLine(LineId);
            int     place = 0;

            if (l.StationsRoute.Count() > 1)
            {
                while (l.StationsRoute.ToList()[place].Station.Code != StatCode1)
                {
                    place++;
                }
                while (l.StationsRoute.ToList()[place].Station.Code != StatCode2 && place < l.StationsRoute.Count() - 1)
                {
                    sum += l.StationsRoute.ToList()[place].DrivingTime; place++;
                }
                if (l.StationsRoute.ToList()[place].Station.Code != StatCode2)
                {
                    return(TimeSpan.Zero);
                }
            }
            return(sum);
        }
Exemplo n.º 2
0
 public void AddLine(BO.Line line)
 {
     DO.Line doLine = LineBoDoAdapter(line);
     try
     {
         dl.AddLine(doLine);
     }
     catch (DO.BadLineCodeException exp)
     {
         throw new BO.BadLineCodeException(line.ID, line.LineCode, exp.Message);
     }
     catch (DO.BadLineStationKeyException ex)
     {
         throw new BO.BadStationKeyException(ex.Id);
     }
 }
Exemplo n.º 3
0
        public Double GetDistanceBetweenStations(int StatCode1, int StatCode2, int LineId)
        {
            double sum = 0;

            BO.Line l     = GetLine(LineId);
            int     place = 0;

            if (l.StationsRoute.Count() <= 1)
            {
                return(0);
            }
            while (l.StationsRoute.ToList()[place].Station.Code != StatCode1)
            {
                place++;
            }
            while (l.StationsRoute.ToList()[place].Station.Code != StatCode2 && place < l.StationsRoute.Count() - 1)
            {
                sum += l.StationsRoute.ToList()[place].Distance; place++;
            }
            return(sum);
        }
Exemplo n.º 4
0
        public void UpdateLine(BO.Line line)
        {
            if (line.StationsRoute != null && line.StationsRoute.Count() > 0)
            {
                int place = line.StationsRoute.Count() - 1;
                line.FirstStation = line.StationsRoute.ToList()[0].Station.Code;
                line.LastStation  = line.StationsRoute.ToList()[place].Station.Code;
            }
            else
            {
                line.FirstStation = 0;
                line.LastStation  = 0;
            }

            DO.Line doLine = LineBoDoAdapter(line);
            try
            {
                dl.UpdateLine(doLine);
            }
            catch (DO.BadLineCodeException exp)
            {
                throw new BO.BadLineCodeException(line.ID, line.LineCode, exp.Message);
            }
        }
Exemplo n.º 5
0
 private DO.Line LineBoDoAdapter(BO.Line boLine)
 {
     DO.Line doLine = new DO.Line();
     boLine.CopyPropertiesTo(doLine);
     return(doLine);
 }