コード例 #1
0
        /// <summary>
        /// StopApiController/PUT
        /// </summary>
        /// <param name="oStop"></param>
        /// <returns></returns>
        public async Task Update(Stop oStop)
        {
            var oCurrentStatus = oStop.CurrentStatus;

            if (oCurrentStatus == null)
            {
                throw new MissingMemberException("Stop", "Status");
            }

            var oCustomerRepository = new StopRepository();

            var oCustomer = oStop.Customer;

            if (oCustomer == null)
            {
                throw new MissingMemberException("Stop", "Customer");
            }

            try //update status
            {
                await oCustomerRepository.Update(oStop.Key, oCustomer.ID, oCurrentStatus.Code);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
 public SearchInputManualMapper(
     StopRepository stopRepository,
     SearchValidator searchValidator)
 {
     _stopRepository  = stopRepository;
     _searchValidator = searchValidator;
 }
コード例 #3
0
        /// <summary>
        /// List of stop per Run
        /// SttopApiController/Get
        /// </summary>
        /// <param name="iRunID"></param>
        /// <returns></returns>
        public async Task <List <Stop> > List(int iRunID)
        {
            var oStopRepository = new StopRepository();

            IDataReader oDataReader = null;

            try
            {
                oDataReader = await oStopRepository.List(iRunID);
            }
            catch (Exception)
            {
                throw;
            }

            var lstStops = new List <Stop>();

            while (oDataReader.Read())
            {
                var oStop = new Stop(oDataReader);
                oStop.Customer = new Customer(oDataReader);

                string sStatus = oDataReader.ReadColumn("Status_CD").Trim();
                oStop.CurrentStatus = await StopStatus.Instance(sStatus);

                lstStops.Add(oStop);
            }

            oDataReader.Close();

            return(lstStops);
        }
コード例 #4
0
 public void Should_Return_All_Stops()
 {
     using (var repos = new StopRepository(DataFilePath)) {
         var result = repos.GetAllStops();
         Assert.That(result.Count(t => t != null), Is.EqualTo(DataFileRowCountMinusHeader));
     }
 }
コード例 #5
0
 public IEnumerable<StopReturn> GetStops(string latitude,string longitude,int direction,int distanceMax)
 {
     using (var hibernateRepository = new StopRepository())
         {
             var application = hibernateRepository.FindStopByCoordinates(latitude, longitude, direction, distanceMax);
             return application;
         }
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork"/> class.
 /// </summary>
 /// <param name="context">The context<see cref="ApplicationContext"/>.</param>
 public UnitOfWork(ApplicationContext context)
 {
     _context  = context;
     Buses     = new BusRepository(_context);
     Stops     = new StopRepository(_context);
     Routes    = new RouteRepository(_context);
     BusRoutes = new BusRouteRepository(_context);
     Bookings  = new BookingRepository(_context);
     Users     = new UserRepository(_context);
 }
コード例 #7
0
ファイル: StopManager.cs プロジェクト: mchilicki/commline
 public StopManager(
     StopRepository stopRepository,
     MixedRepository mixedRepository,
     StopValidator stopValidator,
     StopFactory stopFactory)
 {
     _stopRepository  = stopRepository;
     _mixedRepository = mixedRepository;
     _stopValidator   = stopValidator;
     _stopFactory     = stopFactory;
 }
コード例 #8
0
 public SearchManager(
     IConnectionSearchEngine connectionSearchEngine,
     IGraphFactory <StopGraph> graphGenerator,
     FastestPathResolver fastestPathResolver,
     FastestPathDescriptionWriter fastestPathDescriptionWriter,
     SearchValidator searchValidator,
     SearchInputManualMapper searchInputManualMapper,
     LineRepository lineRepository,
     StopRepository stopRepository)
 {
     _connectionSearchEngine       = connectionSearchEngine;
     _graphGenerator               = graphGenerator;
     _fastestPathDescriptionWriter = fastestPathDescriptionWriter;
     _searchValidator              = searchValidator;
     _searchInputManualMapper      = searchInputManualMapper;
     _lineRepository               = lineRepository;
     _stopRepository               = stopRepository;
     _fastestPathResolver          = fastestPathResolver;
 }
コード例 #9
0
        /// <summary>
        /// When implemented in a derived class, executes the scheduled job asynchronously. Implementations that want to know whether
        ///             the scheduled job is being cancelled can get a <see cref="P:Microsoft.WindowsAzure.Mobile.Service.ScheduledJob.CancellationToken"/> from the <see cref="M:CancellationToken"/> property.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Threading.Tasks.Task"/> representing the asynchronous operation.
        /// </returns>
        public override async Task ExecuteAsync()
        {
            // Load Feed Message
            var dbConnStr = ConfigurationManager.ConnectionStrings["MTA_DB"].ConnectionString;

            var service = new StaticFileService(new StaticFileDownloader());


            StringBuilder sb = new StringBuilder();

            List<string> tableNames = new List<string>()
            {
                "agency",
                "calendar",
                "calendar_dates",
                "shapes",
                "stop_times",
                "transfers",
                "trips",
                "routes",
                "stops",
            };

            tableNames.ForEach(s => sb.AppendFormat("TRUNCATE TABLE {0};", s));

            using (var conn = new SqlConnection(dbConnStr))
            {
                using (var cmd = new SqlCommand(sb.ToString(), conn))
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }


                //Agency
                using (var repository = new AgencyRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetAgencies());
                }

//            using (var repository = new CalendarDateRepository(dbConnStr))
//            {
//                // Load Tables
//                repository.AddRange(service.GetCalendarDates());
//            }

                //Calendars
                using (var repository = new CalendarRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetCalendars());
                }
                //Route
                using (var repository = new RouteRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetRoutes());
                }
                //Shape
                using (var repository = new ShapeRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetShapes());
                }
                //Stop
                using (var repository = new StopRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetStops());
                }
                //Stop Time
                using (var repository = new StopTimeRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetStopTimes());
                }
                //Transfer
                using (var repository = new TransferRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetTransfers());
                }
                //Trip
                using (var repository = new TripRepository() {Connection = conn})
                {
                    // Load Tables
                    repository.AddRange(await service.GetTrips());
                }

                // Build Stations
                using (var cmd = new SqlCommand("sp_BuildStations", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
//                    conn.Open();
                    cmd.ExecuteNonQuery();
                }

                using (var cmd = new SqlCommand("sp_CreateStaticSchedule", conn))
                {
                    cmd.CommandTimeout = 120;
                    cmd.CommandType = CommandType.StoredProcedure;
                    //                    conn.Open();

                    TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
                    DateTime easternTimeNow = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.Utc,
                                                                    easternZone);
                    cmd.Parameters.AddWithValue("@today", easternTimeNow);

                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #10
0
ファイル: StopValidator.cs プロジェクト: mchilicki/commline
 public StopValidator(
     StopRepository stopRepository)
 {
     _stopRepository = stopRepository;
 }
コード例 #11
0
ファイル: SearchValidator.cs プロジェクト: mchilicki/commline
 public SearchValidator(StopRepository stopRepository)
 {
     _stopRepository = stopRepository;
 }
コード例 #12
0
 public FavoriteStopRepository(CloudTable table, StopRepository stopRepository)
 {
     _table          = table;
     _stopRepository = stopRepository;
 }