Example #1
0
        /// <summary>
        ///     Retrieves the events that have occurred in an enterprise.  Events will occasionally arrive out of order.  You may need to buffer events and apply them in a logical order.
        /// </summary>
        /// <param name="createdAfter">A lower bound on the timestamp of the events returned</param>
        /// <param name="createdBefore">An upper bound on the timestamp of the events returned</param>
        /// <param name="eventTypes">A list of event types to filter by.  Only events of these types will be returned.</param>
        /// <returns>A collection of EnterpriseEvents.</returns>
        public EnterpriseEventCollection GetEnterpriseEvents(DateTime? createdAfter = null, DateTime? createdBefore = null, EnterpriseEventType[] eventTypes = null)
        {
            const int pageSize = 500;
            int offset = 0;
            var collection = new EnterpriseEventCollection();

            EnterpriseEventCollection page;
            do
            {
                page = GetEnterpriseEvents(offset, pageSize, createdAfter, createdBefore, eventTypes);
                collection.Entries.AddRange(page.Entries);
                collection.ChunkSize += page.ChunkSize;
                offset += pageSize;
            } while (page.ChunkSize == pageSize);

            return collection;
        }
 private int GetCountOfUsersDoing(EnterpriseEventType enterpriseEventType)
 {
     var collection = Client.GetEnterpriseEvents(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow, new[] {enterpriseEventType,});
     return collection.Entries.Select(e => e.CreatedBy.Login).Distinct().OrderBy(l => l).Count();
 }
 /// <summary>
 ///     Retrieves the events that have occurred in an enterprise.  Events will occasionally arrive out of order.  You may need to buffer events and apply them in a logical order.
 /// </summary>
 /// <param name="onSuccess">Action to perform with the retrieved events</param>
 /// <param name="onFailure">Action to perform following a failed Event operation</param>
 /// <param name="offset">The item at which to start.  Deault is 0 (the earliest known event.)</param>
 /// <param name="limit">The maximum number of events to return with this request. Default is 100.</param>
 /// <param name="createdAfter">A lower bound on the timestamp of the events returned</param>
 /// <param name="createdBefore">An upper bound on the timestamp of the events returned</param>
 /// <param name="eventTypes">A list of event types to filter by.  Only events of these types will be returned.</param>
 public void GetEnterpriseEvents(Action<EnterpriseEventCollection> onSuccess, Action<Error> onFailure, int offset = 0, int limit = 100, DateTime? createdAfter = null,
     DateTime? createdBefore = null, EnterpriseEventType[] eventTypes = null)
 {
     var request = _requestHelper.GetEnterpriseEvents(offset, limit, createdAfter, createdBefore, eventTypes);
     _restClient.ExecuteAsync(request, onSuccess, onFailure);
 }
 /// <summary>
 ///     Retrieves the events that have occurred in an enterprise.  Events will occasionally arrive out of order.  You may need to buffer events and apply them in a logical order.
 /// </summary>
 /// <param name="offset">The item at which to start.  Deault is 0 (the earliest known event.)</param>
 /// <param name="limit">The maximum number of events to return with this request. Default is 100.</param>
 /// <param name="createdAfter">A lower bound on the timestamp of the events returned</param>
 /// <param name="createdBefore">An upper bound on the timestamp of the events returned</param>
 /// <param name="eventTypes">A list of event types to filter by.  Only events of these types will be returned.</param>
 /// <returns>A collection of EnterpriseEvents.</returns>
 public EnterpriseEventCollection GetEnterpriseEvents(int offset = 0, int limit = 100, DateTime? createdAfter = null, DateTime? createdBefore = null, EnterpriseEventType[] eventTypes = null)
 {
     var request = _requestHelper.GetEnterpriseEvents(offset, limit, createdAfter, createdBefore, eventTypes);
     return _restClient.ExecuteAndDeserialize<EnterpriseEventCollection>(request);
 }
        private int GetCountOfUsersDoing(EnterpriseEventType enterpriseEventType)
        {
            var collection = Client.GetEnterpriseEvents(DateTime.UtcNow.AddDays(-7), DateTime.UtcNow, new[] { enterpriseEventType, });

            return(collection.Entries.Select(e => e.CreatedBy.Login).Distinct().OrderBy(l => l).Count());
        }