Esempio n. 1
0
        private EventFeed QueryGCal(FeedQuery query, string userName, DateTime modifiedSince)
        {
            if (log.IsInfoEnabled)
            {
                log.Info(String.Format("Querying GCal for User '{0}': {1}", userName, query.Uri));
            }

            EventFeed feed = null;

            // Wait as necessary before making new request.

            connectionThrottler.WaitBeforeNewConnection();

            try
            {
                using (BlockTimer bt = new BlockTimer("QueryGCal"))
                {
                    feed = service.Query(query, modifiedSince) as EventFeed;
                }
            }
            catch (GDataNotModifiedException e)
            {
                // Content was not modified
                log.InfoFormat("NotModified: {0}", e.Message);
            }
            catch (Exception)
            {
                // Report a failure, regardless of the exception, as long as it is not GDataNotModifiedException.
                // This could be a bit overly aggressive, but it is hard to make bets
                // what exception was caught and rethrown in GData and what was let to fly.
                connectionThrottler.ReportFailure();

                throw;
            }

            // Everything went well, report it.
            // Note this is valid even when we caught GDataNotModifiedException.
            connectionThrottler.ReportSuccess();

            LogResponse(feed, userName);

            return(feed);
        }