/// <summary> /// The finalize request. /// </summary> /// <param name="request"> /// The request. /// </param> public void FinalizeRequest(FareMonitorRequest request) { this._processQueue.Remove(request); if (this._pendingQueue.Count == 0 && this._processQueue.Count == 0) { this.Stop(); } }
/// <summary> /// The stop. /// </summary> /// <param name="request"> /// The request. /// </param> public void Stop(FareMonitorRequest request) { this._logger.Info("Stopping " + this.GetType().Name); if (this.RequestStopping != null) { FareBrowserRequestArg args = new FareBrowserRequestArg(request); this.OnRequestStopping(args); if (args.Cancel) { return; } } request.Stop(); }
/// <summary> /// The enqueue. /// </summary> /// <param name="request"> /// The request. /// </param> public void Enqueue(FareMonitorRequest request) { request.OwnerMonitor = this; this._pendingQueue.Enqueue(request); }
/// <summary> /// The enqueue. /// </summary> /// <param name="origin"> /// The origin. /// </param> /// <param name="destination"> /// The destination. /// </param> /// <param name="departureDate"> /// The departure date. /// </param> /// <param name="returnDate"> /// The return date. /// </param> public void Enqueue(Airport origin, Airport destination, DateTime departureDate, DateTime returnDate) { var newRequest = new FareMonitorRequest(origin, destination, departureDate, returnDate); this.Enqueue(newRequest); }
/// <summary> /// Initializes a new instance of the <see cref="FareBrowserRequestArg"/> class. /// </summary> /// <param name="request"> /// The request. /// </param> public FareBrowserRequestArg(FareMonitorRequest request) { this.Request = request; if (request != null && request.BrowserControl != null) { this.RequestInitiatedDate = request.BrowserControl.LastRequestInitiatedDate; } }
/// <summary> /// Initializes a new instance of the <see cref="FareMonitorRequest"/> class. /// </summary> /// <param name="request"> /// The request. /// </param> public FareMonitorRequest(FareMonitorRequest request) : this(request.Departure, request.Destination, request.DepartureDate, request.ReturnDate) { }
/// <summary> /// The set status. /// </summary> /// <param name="request"> /// The request. /// </param> internal void SetStatus(FareMonitorRequest request) { string action = request.BrowserControl.RequestState == DataRequestState.Pending ? "Getting" : "Waiting"; bool oneWayTrip = request.ReturnDate.IsUndefined(); string trip = string.Format( "{0} trip {1}{2}", oneWayTrip ? "one-way" : "round", request.DepartureDate.ToShortDayAndDateString(), oneWayTrip ? string.Empty : " - " + request.ReturnDate.ToShortDayAndDateString()); var img = request.BrowserControl.RequestState == DataRequestState.Pending ? Resources.Loading : null; string message = string.Format( "{0} fare data for {1} ({2}/{3})...", action, trip, this.loadProgress.ControlItem.Value, this.loadProgress.ControlItem.Maximum); AppContext.Logger.Debug(message); this.SetStatus(message, img); }