ServiceMonExtensionExample-noexe.zip
ServiceMonExtensionExample
ServiceMonExtensions
Properties
Service References
TempConvertWebService
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
tempconvert.wsdl
Tests
Properties
ServiceMonExtensionExample.zip
bin
Kaleida.ServiceMonitor.Framework.dll
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
tempconvert.wsdl
ServiceMon_v1.0.0_Source-noexe.zip
ServiceMon v1.0.0 Source
BuildTools
antlr-3.2.jar
nUnit
Failure.jpg
Ignored.jpg
NUnitTests.nunit
Success.jpg
tempfile.tmp
Everything.build
Kaleida.ServiceMonitor.CodePlexUploader
Kaleida.ServiceMonitor.Framework
Properties
Responses
Kaleida.ServiceMonitor.Model
Email
Layout
Parsing
ScriptGrammar.g
Properties
Runtime
ScriptDirectives
Statistics
StructuredSource
Kaleida.ServiceMonitor.Operations
PreparedRequests
Properties
ResponseHandlers
Kaleida.ServiceMonitor.UI
Application.ico
Icons
Application.ico
Error.ico
Running.ico
Stopped.ico
Kaleida.ProductBuilder.ServiceMonitor.csproj.DotSettings
Kaleida.ProductBuilder.ServiceMonitor.csproj.DotSettings.user
Kaleida.ProductBuilder.ServiceMonitor.csproj.ReSharper
NotificationPanels
Properties
Settings.settings
Scripts
Introductory Examples.mscr
More Examples.mscr
Kaleida.ServiceMonitor.UnitTests
Framework
Model
Email
Layout
Parsing
Runtime
Statistics
Operations
Scripts
Setup
DialogBackround.bmp
DialogBackround.pdn
DialogTopBanner.bmp
GPLv3License.rtf
Product.wxs
Setup.wixproj
ServiceMon_v1.0.0_Source.zip
bin
Antlr3.Runtime.dll
CodePlex.WebServices.Client.dll
JetBrains.Annotations.dll
log4net.dll
antlr-3.2.jar
Failure.jpg
fit.dll
Ignored.jpg
loadtest-assembly.dll
mock-assembly.dll
nonamespace-assembly.dll
notestfixtures-assembly.dll
nunit.core.dll
nunit.core.extensions.dll
nunit.core.interfaces.dll
nunit.core.tests.dll
nunit.exe
nunit.extensions.tests.dll
nunit.fixtures.dll
nunit.fixtures.tests.dll
nunit.framework.dll
nunit.framework.extensions.dll
nunit.framework.tests.dll
nunit.mocks.dll
nunit.mocks.tests.dll
nunit.testutilities.dll
nunit.uikit.dll
nunit.uikit.tests.dll
nunit.util.dll
nunit.util.tests.dll
nunit-console.exe
nunit-console.tests.dll
nunit-console-runner.dll
nunit-console-x86.exe
nunit-gui.exe
nunit-gui.tests.dll
nunit-gui-runner.dll
NUnitTests.nunit
nunit-test-server.dll
nunit-x86.exe
runFile.exe
Success.jpg
tempfile.tmp
test-assembly.dll
test-utilities.dll
timing-tests.dll
WixFileVersionExtension.dll
COPYING
Everything.build
Properties
ScriptGrammar.g
Application.ico
Application.ico
Error.ico
Running.ico
Stopped.ico
Kaleida.ProductBuilder.ServiceMonitor.csproj.DotSettings
Kaleida.ProductBuilder.ServiceMonitor.csproj.DotSettings.user
Kaleida.ProductBuilder.ServiceMonitor.csproj.ReSharper
Settings.settings
Introductory Examples.mscr
More Examples.mscr
DialogBackround.bmp
DialogBackround.pdn
DialogTopBanner.bmp
GPLv3License.rtf
Product.wxs
Setup.wixproj
|
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using Kaleida.ServiceMonitor.Model.Runtime;
using Kaleida.ServiceMonitor.Model.Statistics;
using System.Linq;
namespace Kaleida.ServiceMonitor.Model
{
public class OperationStatisticsMap
{
private readonly ProcessingStatistics combined = new ProcessingStatistics("Combined", "Combined operations");
private readonly Dictionary<IOperation,ProcessingStatistics> map = new Dictionary<IOperation, ProcessingStatistics>();
public ProcessingStatistics Combined
{
get { return combined; }
}
public IList<ProcessingStatistics> Operations
{
get { return map.Values.ToList().AsReadOnly(); }
}
public IList<ProcessingStatistics> AllValues
{
get
{
lock (this)
{
var all = new List<ProcessingStatistics> {combined};
all.AddRange(map.Values);
return all.AsReadOnly();
}
}
}
public void Initialise(IList<IOperation> operations)
{
lock (this)
{
combined.Reset();
map.Clear();
foreach (var operation in operations)
{
var position = operations.IndexOf(operation) + 1;
var name = "Operation " + position.ToString("0");
map.Add(operation, new ProcessingStatistics(name, operation.Description));
}
}
}
private void TryUpdateStatistics([NotNull] IOperation operation, Action<ProcessingStatistics> updateAction)
{
if (operation == null) throw new ArgumentNullException("operation");
lock (this)
{
ProcessingStatistics stats;
if (map.TryGetValue(operation, out stats))
{
updateAction(stats);
}
}
}
public void ResetAll()
{
combined.Reset();
lock (this)
{
foreach (var entry in map)
{
entry.Value.Reset();
}
}
}
internal void Start()
{
lock (this)
{
foreach(var stats in AllValues)
stats.Start();
}
}
internal void IncrementSuccessCount(IOperation operation, TimeSpan elapsed)
{
lock (this)
{
combined.IncrementSuccessCount(elapsed);
TryUpdateStatistics(operation, i => i.IncrementSuccessCount(elapsed));
}
}
internal void IncrementFailureCount(IOperation operation)
{
lock (this)
{
combined.IncrementFailureCount();
TryUpdateStatistics(operation, i => i.IncrementFailureCount());
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.