コード例 #1
0
        private void LogFailedRequestEnd( AsyncChainedState<TrackerState> asyncChainedState, TrackerState result )
        {
            if ( result.Error.Type == Data.ErrorType.ResponseHasNoData ||
               result.Error.Type == Data.ErrorType.BadTrackerId )
              {
            ErrorHandlingLog.DebugFormat(
              "Request for {0}, page {1}, lrid {2} failed: {3}",
              this.Id,
              this.currentRequest.Page,
              asyncChainedState.Id,
              result.Error );
              }
              else
              {
            bool shouldReportProblem = true;
            int consequentErrorsCount = 1;

            if ( this.consequentErrorsCounter != null )
            {
              consequentErrorsCount =
            this.consequentErrorsCounter.RequestsErrorsCounter.Increment( out shouldReportProblem );
            }

            string message =
              string.Format
              (
            "Request for {0}, page {1}, lrid {2} failed: {3}. That's a consequent request error #{4}",
            this.Id,
            this.currentRequest.Page,
            asyncChainedState.Id,
            result.Error,
            consequentErrorsCount
              );

            if ( shouldReportProblem )
              ErrorHandlingLog.Error( message );
            else
              ErrorHandlingLog.Info( message );
              }
        }
コード例 #2
0
        private void LogSuccRequestEnd( AsyncChainedState<TrackerState> asyncChainedState )
        {
            if ( Log.IsDebugEnabled )
            Log.DebugFormat( "Call succeeded for {0}, lrid {1}", this.Id, asyncChainedState.Id );

              if ( this.appAuxLogFolder != null )
              {
            try
            { // we need an idea of how diff.feeds work without keeping log on.
              // Creation of a timestamp file is not synced, because it's no problem when it fails - the next one will eventually succeed.
              string path = Path.Combine( this.appAuxLogFolder, "succ.timestamp" );
              File.WriteAllText( path, "" );
            }
            catch ( Exception exc )
            {
              Log.ErrorFormat( "SpotFeedRequestCallback for {0}, lrid {1}: {2}", this.Id, asyncChainedState.Id, exc );
            }
              }

              if ( this.consequentErrorsCounter != null )
            this.consequentErrorsCounter.RequestsErrorsCounter.Reset( );
        }
コード例 #3
0
        public override IAsyncResult BeginReadLocation( AsyncCallback callback, object state )
        {
            lock ( this.sync )
              {
            if ( this.inCall )
              throw new InvalidOperationException( "BeginReadLocation has already been called for this instance" );

            this.inCall = true;
              }

              var asyncChainedState = new AsyncChainedState<TrackerState>( callback, state );

              Lrid = asyncChainedState.Id;

              this.currentRequest =
            new SpotFeedRequest(
              this.Id,
              0,
              asyncChainedState.Id,
              this.consequentErrorsCounter == null
            ? null
            : this.consequentErrorsCounter.UnexpectedForeignErrorsCounter
            );

              Log.InfoFormat( "Created request for {0}, lrid {1}", this.Id, asyncChainedState.Id );

              this.currentRequest.BeginRequest( SpotFeedRequestCallback, asyncChainedState );

              return asyncChainedState.FinalAsyncResult;
        }