9using System.Collections;
10using System.Collections.Concurrent;
11using System.Collections.Generic;
13using System.Threading;
22 private readonly
object _syncLock =
new object();
23 private ConcurrentQueue<InterceptArgs> _initializeQueue =
new ConcurrentQueue<InterceptArgs>();
24 private ConcurrentQueue<InterceptArgs> _completeQueue =
new ConcurrentQueue<InterceptArgs>();
25 private readonly Timer _timerInitialize;
26 private readonly Timer _timerComplete;
27 private ConcurrentQueue<Activity> _recentActivity =
new ConcurrentQueue<Activity>();
28 private const int _timerDueTime = 50;
29 private const int _timerPeriod = 500;
36 _timerInitialize =
new Timer(ProcessInitializeQueue,
null, _timerDueTime, _timerPeriod);
37 _timerComplete =
new Timer(ProcessCompleteQueue,
null, _timerDueTime, _timerPeriod);
47 private void ProcessCompleteQueue(
object state)
49 if (_completeQueue.IsEmpty)
52 _timerComplete.Change(Timeout.Infinite, Timeout.Infinite);
57 if (result.Exception !=
null)
58 Interlocked.Add(ref _failedCalls, 1);
60 Interlocked.Add(ref _completedCalls, 1);
61 _recentActivity.Enqueue(
new Activity(result));
65 _recentActivity.TryDequeue(out Activity discard);
69 _timerComplete.Change(_timerDueTime, _timerPeriod);
73 private void ProcessInitializeQueue(
object state)
75 if (_initializeQueue.IsEmpty)
78 _timerInitialize.Change(Timeout.Infinite, Timeout.Infinite);
81 while (_initializeQueue.TryDequeue(out InterceptArgs result))
83 Interlocked.Add(ref _totalCalls, 1);
88 _timerInitialize.Change(_timerDueTime, _timerPeriod);
95 public DateTimeOffset
FirstCall {
get;
private set; }
100 public DateTimeOffset
LastCall {
get;
private set; }
101 private long _totalCalls;
108 get {
return Interlocked.Read(ref _totalCalls); }
111 private long _completedCalls;
118 get {
return Interlocked.Read(ref _completedCalls); }
121 private long _failedCalls;
128 get {
return Interlocked.Read(ref _failedCalls); }
136 return _recentActivity.ToList();
142 _initializeQueue.Enqueue(e);
147 _completeQueue.Enqueue(e);
155 _timerComplete.Dispose();
156 _timerInitialize.Dispose();
Information about a server-side data portal invocation.
Data portal server dashboard.
List< Activity > GetRecentActivity()
Gets the items in the recent activity queue.
long FailedCalls
Gets the number of times data portal calls have failed
Dashboard()
Creates an instance of the type.
void Dispose()
Dispose resources used by this object.
DateTimeOffset LastCall
Gets the most recent time the data portal was invoked
DateTimeOffset FirstCall
Gets the time the data portal was first invoked
long CompletedCalls
Gets the number of times data portal calls have successfully completed
int RecentActivityCount
Gets or sets a value indicating the number of items to maintain in the recent activity list.
long TotalCalls
Gets the total number of times the data portal has been invoked
Arguments parameter passed to the interceptor methods.
Data portal server dashboard.
void InitializeCall(InterceptArgs e)
Called by the data portal to indicate a call has been inititalized.