private JsonRequest GetJsonRequest(IntervalEventArgs e)
        {
            var details = new Dictionary<string, object>();
            //double workingIntervalActiveSeconds = 0;

            //Worker State details
            foreach (var s in e.WorkerStateDetails)
            {
                //In addition to storing the WorkingIntervalActive as an interval string, we are going to store the total seconds for easier math later. (Grab it here as we are already iterating the WorkerStateDetails)
                //if (string.Compare(s.Name, "Working", true) == 0) workingIntervalActiveSeconds = s.StopwatchInterval.Elapsed.TotalSeconds;

                var detail = new Dictionary<string, object>();
                detail.Add("TotalActive", s.StopwatchActive.Elapsed.TotalSeconds);
                detail.Add("IntervalActive", s.StopwatchInterval.Elapsed.TotalSeconds);
                details.Add(s.Name, detail);
            }

            //Statistics details
            var statsDetail = new Dictionary<string, object>();
            statsDetail.Add("IntervalProcessedMessageCount", e.IntervalProcessedMessageCount);
            //statsDetail.Add("WorkingIntervalActiveSeconds", workingIntervalActiveSeconds); // Yes, this is a duplicate value of the WorkerStateDetails.  However, It's far less expensive to SUM this value then try to convert oracle intervals to total seconds.
            details.Add("Statistics", statsDetail);

            //Method Specific Stats
            var methodStatsDetail = new Dictionary<string, object>();
            foreach (var s in e.IntervalProcessedMessageCountByMethod)
            {
                methodStatsDetail.Add(s.Key.ToUpper(), s.Value);
            }
            if(methodStatsDetail.Count > 0) details.Add("IntervalMethodProcessedCount:", methodStatsDetail);    

            
            var instrumentationEntry = new InstrumentationEntry
            {
                MachineName = Environment.MachineName,
                AppName = AppDomain.CurrentDomain.FriendlyName,
                ProcessId = Process.GetCurrentProcess().Id,
                Data = new InstrumentationData()
                {
                    TotalTime = e.TotalTime,
                    IntervalTime = e.IntervalTime,
                    Details = details
                },
                Date = DateTime.Now
            };

            if (this._genericWorkerQueueSettings != null && !string.IsNullOrEmpty(this._genericWorkerQueueSettings.RequestQueue))
            {
                instrumentationEntry.Data.Queue = this._genericWorkerQueueSettings.RequestQueue;
            }


            return new JsonRequest
            {
                JsonRpc = "2.0",
                Id = Guid.NewGuid(),
                Method = InstrumentationServiceMethod,
                Params = new Dictionary<string, object> { { "InstrumentationEntry", instrumentationEntry } }
            };
        }
예제 #2
0
        public void GenericWorkerInstrumentationWriter_InstrumentationIntervalTest()
        {
            var intervalEventArgs = new IntervalEventArgs()
            {
                IntervalTime       = new TimeSpan(0, 0, 60),
                TotalTime          = new TimeSpan(0, 60, 0),
                WorkerStateDetails = new List <WorkerStateDetail>()
                {
                    new WorkerStateDetail()
                    {
                        Name = "Test", StopwatchActive = new Stopwatch(), StopwatchInterval = new Stopwatch()
                    }
                },
                IntervalProcessedMessageCountByMethod = new Dictionary <string, int>()
            };

            var jsonHelperMock = new Mock <IJSonRPCHelper>();

            IUnityContainer container = new UnityContainer();

            container.RegisterInstance(typeof(IJSonRPCHelper), jsonHelperMock.Object);

            //Act
            var genericWorkerInstrumentationWriter = new GenericWorkerInstrumentationWriter(container);

            genericWorkerInstrumentationWriter.InstrumentationInterval(this, intervalEventArgs);

            System.Threading.Thread.Sleep(500);

            jsonHelperMock.Verify(j => j.SerializeJSonRPCRequest(It.IsAny <JsonRequest>()), Times.Once());
        }
        public void InstrumentationInterval(object sender, IntervalEventArgs e)
        {
            var jsonRequest = GetJsonRequest(e);
            var instrumentationMessage = this._jsonRpcHelper.SerializeJSonRPCRequest(jsonRequest);

            Task.Factory.StartNew(() =>
            {   
                bool putSuccess = this._mqQueueController.Put(_intrumentationQueueSettings,
                                                              instrumentationMessage);
            });

        }
예제 #4
0
 public void intervalPlayed(IntervalEventArgs i)
 {
     if (IntervalPlayed == null) return;
     IntervalPlayed(this, i);
 }
예제 #5
0
 public void intervalEffect(IntervalEventArgs i)
 {
 }
예제 #6
0
 private void formSetSlideshowInterval_OnIntervalChanged(object sender, IntervalEventArgs e)
 {
     timerSlideShow.Interval = e.Interval * 1000;
     _applicationSettingsService.Settings.SlideshowInterval = timerSlideShow.Interval;
 }
예제 #7
0
 public void intervalPlayed(object source, IntervalEventArgs i)
 {
     keyEffector.intervalEffect(i);
     intervalEffector.intervalEffect(i);
     lastInterval = i.intervalFrequency;
 }