コード例 #1
0
 static void initializLinesTripList()
 {
     LineTripsList = new List <DO.LineTrip>();
     foreach (var line in LinesList)
     {
         var time = RandomValues.getTime();
         LineTripsList.Add(
             new DO.LineTrip
         {
             Id               = DalApi.Counters.LineTripCounter,
             LineId           = line.Id,
             StartAtInHours   = time.Hours,
             StartAtInMinutes = time.Minutes
         });
     }
 }
コード例 #2
0
        //static void initializStations(int numOfStation = 100)
        //{
        //    StationsList = new List<DO.Station>();
        //    for (int i = 0; i < numOfStation; i++)
        //    {
        //        double latitude, longitude;
        //        RandomValues.getLocation(out latitude, out longitude);
        //        StationsList.Add(new DO.Station()
        //        {
        //            Code = RandomValues.getUniqueStationKey(),
        //            Latitude = latitude,
        //            Longitude = longitude,
        //            Area = RandomValues.getArea(longitude, latitude),
        //            IsDeleted = false
        //        });
        //    }
        //}

        static void initializLines(int numOfLins = 10)
        {
            LinesList        = new List <DO.Line>();
            LineStationsList = new List <DO.LineStation>();
            for (int i = 0; i < numOfLins; i++)
            {
                var newLine = new DO.Line()
                {
                    Id        = DalApi.Counters.LineCounter,
                    Code      = RandomValues.getLineCode(),
                    IsDeleted = false
                };
                var firstAndLastStationCode = initializLineStations(newLine.Id);
                newLine.FirstStation = firstAndLastStationCode[0];
                newLine.LastStation  = firstAndLastStationCode[1];
                newLine.Area         = StationsList.Find(s => s.Code == newLine.FirstStation).Area;
                LinesList.Add(newLine);
            }
        }
コード例 #3
0
 static void initializBuss(int numOfBuss = 20)
 {
     BussList = new List <DO.Bus>();
     for (int i = 0; i < numOfBuss; i++)
     {
         var dateFrom = RandomValues.randomDate();
         BussList.Add(new DO.Bus()
         {
             FromDate                 = dateFrom,
             LicenseNum               = RandomValues.randomLicenseNumber(dateFrom),
             Status                   = DO.BusStatus.READY,
             TotalTrip                = RandomValues.getKilometers(),
             LastTreatment            = RandomValues.randomDate(2018),
             KilometersAfterFueling   = RandomValues.getKilometers(0, DO.Bus.MAX_KILOMETER_AFTER_REFUELING),
             KilometersAfterTreatment = RandomValues.getKilometers(0, DO.Bus.KILOMETER_BEFORE_TREATMENT),
             FuelRemain               = RandomValues.getFuelLiters(),
             IsDeleted                = false
         });
     }
 }
コード例 #4
0
        static int[] initializLineStations(int lineId, int numOfLS = 10)
        {
            List <DO.LineStation> stationTemp = new List <DO.LineStation>();
            var first = new DO.LineStation()
            {
                LineId           = lineId,
                Station          = RandomValues.getStation(stationTemp),
                LineStationIndex = 0,
                PrevStation      = 0,
                IsDeleted        = false
            };
            var area = StationsList.Find(s => s.Code == first.Station).Area;

            stationTemp.Add(first);
            for (int i = 1; i < numOfLS; i++)
            {
                stationTemp.Add(new DO.LineStation()
                {
                    LineId           = lineId,
                    Station          = RandomValues.getStation(stationTemp, area),
                    LineStationIndex = i,
                    PrevStation      = stationTemp.ElementAt(i - 1).Station,
                    IsDeleted        = false
                });
            }
            foreach (var ls in stationTemp)
            {
                if (ls.LineStationIndex != stationTemp.Count - 1)
                {
                    ls.NextStation = stationTemp.ElementAt(ls.LineStationIndex + 1).Station;
                }
                else
                {
                    ls.NextStation = -1; // last station mark in -1
                }
            }
            LineStationsList.AddRange(stationTemp);

            return(new int[] { stationTemp.ElementAt(0).Station,
                               stationTemp.ElementAt(stationTemp.Count - 1).Station });
        }