public static IList <IPerformanceCountersByResource> GetResourceCountersTo(this IPerformanceCounterTo to) { var res = new List <IPerformanceCountersByResource>(); var ids = to.ResourceCounters; foreach (var resourcePerformanceCounter in ids) { var current = res.FirstOrDefault(a => a.ResourceId == resourcePerformanceCounter.ResourceId); if (current == null) { current = new PerformanceCountersByResource { ResourceId = resourcePerformanceCounter.ResourceId, CounterName = resourcePerformanceCounter.CategoryInstanceName }; res.Add(current); } switch (resourcePerformanceCounter.PerfCounterType) { case WarewolfPerfCounterType.AverageExecutionTime: current.AverageExecutionTime = true; break; case WarewolfPerfCounterType.ExecutionErrors: current.TotalErrors = true; break; case WarewolfPerfCounterType.ConcurrentRequests: current.ConcurrentRequests = true; break; case WarewolfPerfCounterType.RequestsPerSecond: current.RequestPerSecond = true; break; } } return(res); }
public void Save(IPerformanceCounterTo toSave) { var resourceCounters = toSave.ResourceCounters; var nativeCounters = toSave.NativeCounters; _perf.Save(nativeCounters); _perf.Save(resourceCounters); _counters = nativeCounters; _resourceCounters = resourceCounters.Cast <IPerformanceCounter>().ToList(); }
public PerfcounterViewModel(IPerformanceCounterTo counters, IServer environment, Func <IResourcePickerDialog> createfunc = null) { VerifyArgument.IsNotNull("counters", counters); VerifyArgument.IsNotNull("environment", environment); _resourcePicker = (createfunc ?? CreateResourcePickerDialog)(); _environment = environment; PickResourceCommand = new DelegateCommand(PickResource); ResetCountersCommand = new DelegateCommand(ResetCounters); ServerCounters = new ObservableCollection <IPerformanceCountersByMachine>(); ResourceCounters = new ObservableCollection <IPerformanceCountersByResource>(); InitializeTos(counters); }
public static IList <IPerformanceCountersByMachine> GetServerCountersTo(this IPerformanceCounterTo to) { var result = new PerformanceCountersByMachine { AverageExecutionTime = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.AverageExecutionTime && a.IsActive), ConcurrentRequests = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.ConcurrentRequests && a.IsActive), NotAuthorisedErrors = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.NotAuthorisedErrors && a.IsActive), RequestPerSecond = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.RequestsPerSecond && a.IsActive), TotalErrors = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.ExecutionErrors && a.IsActive), WorkFlowsNotFound = to.NativeCounters.Any(a => a.PerfCounterType == WarewolfPerfCounterType.ServicesNotFound && a.IsActive) }; return(new List <IPerformanceCountersByMachine> { result }); }
public void SetItem(IPerformanceCounterTo model) { ItemServerCounters = new List <IPerformanceCountersByMachine>(); ItemResourceCounters = new List <IPerformanceCountersByResource>(); var performanceCountersByMachines = model.GetServerCountersTo(); foreach (var performanceCountersByMachine in performanceCountersByMachines) { ItemServerCounters.Add(performanceCountersByMachine); } var performanceCountersByResources = model.GetResourceCountersTo(); foreach (var performanceCountersByResource in performanceCountersByResources) { ItemResourceCounters.Add(performanceCountersByResource); } ItemResourceCounters.Add(CreateNewCounter()); }
private void UpdateServerCounter(IPerformanceCounterTo perfCounterTo) { var serverCounter = ServerCounters[0]; if (serverCounter != null) { var serverAvgExecTimePerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.AverageExecutionTime); if (serverAvgExecTimePerfCounter != null) { serverAvgExecTimePerfCounter.IsActive = serverCounter.AverageExecutionTime; } var serverConcurrentRequestsPerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.ConcurrentRequests); if (serverConcurrentRequestsPerfCounter != null) { serverConcurrentRequestsPerfCounter.IsActive = serverCounter.ConcurrentRequests; } var serverExecutionErrorsPerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.ExecutionErrors); if (serverExecutionErrorsPerfCounter != null) { serverExecutionErrorsPerfCounter.IsActive = serverCounter.TotalErrors; } var serverNotAuthorisedErrorsPerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.NotAuthorisedErrors); if (serverNotAuthorisedErrorsPerfCounter != null) { serverNotAuthorisedErrorsPerfCounter.IsActive = serverCounter.NotAuthorisedErrors; } var serverRequestsPerSecondPerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.RequestsPerSecond); if (serverRequestsPerSecondPerfCounter != null) { serverRequestsPerSecondPerfCounter.IsActive = serverCounter.RequestPerSecond; } var serverServicesNotFoundPerfCounter = perfCounterTo.NativeCounters.FirstOrDefault(counter => counter.PerfCounterType == WarewolfPerfCounterType.ServicesNotFound); if (serverServicesNotFoundPerfCounter != null) { serverServicesNotFoundPerfCounter.IsActive = serverCounter.WorkFlowsNotFound; } } }
private void InitializeTos(IPerformanceCounterTo nativeCounters) { ServerCounters.Clear(); ResourceCounters.Clear(); var performanceCountersByMachines = nativeCounters.GetServerCountersTo(); foreach (var performanceCountersByMachine in performanceCountersByMachines) { RegisterPropertyChanged(performanceCountersByMachine); ServerCounters.Add(performanceCountersByMachine); } var performanceCountersByResources = nativeCounters.GetResourceCountersTo(); foreach (var performanceCountersByResource in performanceCountersByResources) { RegisterPropertyChanged(performanceCountersByResource); ResourceCounters.Add(performanceCountersByResource); } ResourceCounters.Add(CreateNewCounter()); SetItem(nativeCounters); }
internal PerfcounterViewModel(IPerformanceCounterTo counters, IServer environment) : this(counters, environment, null) { }
private void UpdateResourceCounter(IPerformanceCounterTo perfCounterTo) { perfCounterTo.ResourceCounters = ResourceCounters.ToList().GetResourceCounters(); }
public void Save(IPerformanceCounterTo perfCounterTo) { UpdateServerCounter(perfCounterTo); UpdateResourceCounter(perfCounterTo); InitializeTos(perfCounterTo); }
public TestPerfCounterViewModel(IPerformanceCounterTo counters, IServer environment, Func <IResourcePickerDialog> createfunc = null) : base(counters, environment, createfunc) { }