/// <summary>
            /// Initializes a new instance of the type
            /// </summary>
            /// <param name="summary">The summary to modify</param>
            public Tracker(ISummary summary)
            {
                _summary = summary;

                _watch = DateTime.UtcNow;
//                _watch = Stopwatch.StartNew();
            }
Example #2
0
    public IEnumerator Routine()
    {
        while (gameObject.activeInHierarchy)
        {
            if (Target == null)
            {
                if (entity && entity is ISummary)
                {
                    Target = entity as ISummary;
                }
                yield return(new WaitForSeconds(0.33f));

                continue;
            }
            int spare = Target.GetSparePeople(), now = Target.GetNowPeople(), total = Target.GetTotalPeople();
            PeopleIndicator.text = string.Concat(new object[] { spare == -1?"":spare as object, " / ", now == -1 ? "" : now as object, " / ", total == -1 ? "" : total as object });
            bool res = Target.IsProducing();
            ProdSprite.gameObject.SetActive(res);
            progressbar.gameObject.SetActive((entity as Building).UnderConstruct);
            if (res)
            {
                ProdSprite.sprite = Target.GetProductSprite();
            }
            if ((entity as Building).UnderConstruct)
            {
                progressbar.Value = Target.GetProdPercentage();
            }
            yield return(new WaitForSeconds(0.33f));
        }
    }
Example #3
0
        public static SummaryVisitor Collect(this ISummary summary)
        {
            var visitor = new SummaryVisitor();

            summary.Visit(visitor);
            return(visitor);
        }
Example #4
0
 /// <summary>
 /// A load new series command has been initiated. Reload the models from the files.
 /// </summary>
 /// <param name="message"></param>
 private void LoadNewSeries(LoadNewSeriesMessage message)
 {
     this.Seasons       = this.seasonIo.GetSeasons();
     this.Athletes      = this.athleteData.ReadAthleteData();
     this.Clubs         = this.clubData.LoadClubData();
     this.GlobalSummary = this.summaryData.LoadSummaryData();
 }
Example #5
0
        /// <summary>Called to start the job.</summary>
        /// <param name="jobManager">The job manager running this job.</param>
        /// <param name="workerThread">The thread this job is running on.</param>
        public void Run(JobManager jobManager, BackgroundWorker workerThread)
        {
            try
            {
                StartRun();
                DoRun(jobManager, workerThread);
                CleanupRun();
            }
            catch (ApsimXException err)
            {
                ErrorMessage = "ERROR in file: " + FileName + "\r\n" +
                               "Simulation name: " + Name + "\r\n" +
                               err.ToString();

                ISummary summary = Apsim.Find(this, typeof(Summary)) as ISummary;
                summary.WriteMessage(this, ErrorMessage);
                CleanupRun();

                throw new Exception(ErrorMessage);
            }
            catch (Exception err)
            {
                ErrorMessage = "ERROR in file: " + FileName + "\r\n" +
                               "Simulation name: " + Name + "\r\n" +
                               err.ToString();

                ISummary summary = Apsim.Find(this, typeof(Summary)) as ISummary;
                summary.WriteMessage(this, ErrorMessage);
                CleanupRun();

                throw new Exception(ErrorMessage);
            }
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="logger">The logger to write debugging and diagnostics information to</param>
        /// <param name="metricFactory">The factory to create metric recorders from</param>
        /// <param name="consumerGroupName">The name of the consumer group that the processor is associated with</param>
        /// <param name="storageAccount">The storage account used to access the Azure BLOB store</param>
        /// <param name="containerName">The name of the container that the BLOBs are contained in</param>
        /// <param name="subContainerPrefix">The prefix for the BLOB container</param>
        public AzureStorageEpochRecorder(ILogger logger, IMetricFactory metricFactory, string consumerGroupName, CloudStorageAccount storageAccount, string containerName, string subContainerPrefix)
        {
            Guard.NotNullOrWhitespace(nameof(consumerGroupName), consumerGroupName);
            Guard.NotNull(nameof(storageAccount), storageAccount);
            Guard.NotNull(nameof(logger), logger);
            AzureBlobCommon.ValidContainerName(nameof(containerName), containerName);

            _logger = logger;

            using (_logger.BeginScope("Azure Storage Lease Manager::ctor"))
            {
                _logger.LogInformation("Creating Azure lease manager for consumer group {consumerGroupName}, container {containerName}", containerName, consumerGroupName);

                subContainerPrefix = (subContainerPrefix != null) ? subContainerPrefix.Trim() : "";

                var storageClient = storageAccount.CreateCloudBlobClient();

                storageClient.DefaultRequestOptions = new BlobRequestOptions {
                    MaximumExecutionTime = TimeSpan.FromSeconds(60)
                };
                _epochStoreContainer    = storageClient.GetContainerReference(containerName);
                _consumerGroupDirectory = _epochStoreContainer.GetDirectoryReference($"{subContainerPrefix}{consumerGroupName}");

                _epochReadCounter          = metricFactory.CreateCounter("aer-checkpoint-read", "The number of times that the Azure Storage epoch recorder has read the epoch", false, new string[0]);
                _epochUpdateCounter        = metricFactory.CreateCounter("aer-checkpoint-update", "The number of times that the Azure Storage epoch recorder has updated the epoch", false, new string[0]);
                _epochErrorCounter         = metricFactory.CreateCounter("aer-checkpoint-error", "The number of times that the Azure Storage epoch recorder has errors raised", false, new string[0]);
                _storagePerformanceSummary = metricFactory.CreateSummary("aer-storage-timing", "The duration taken to access Azure Storage to perform checkpoint recorder operations", 10, false, new string[0]);
            }
        }
Example #7
0
        /// <summary>
        /// 往导出后的容器中写数据
        /// </summary>
        /// <param name="pContainer">导出后的容器,如果导出为Excel,则为WookSheet</param>
        /// <param name="pSummary">报表摘要</param>
        /// <param name="pSummaryValue">摘要值</param>
        /// <param name="pRowIndex">行</param>
        /// <param name="pColumnIndex">列</param>
        /// <param name="pIsIncludeSummaryTitle">是否在写数据的时候包含摘要标题(主要是当摘要列是第一列时,将标题和数据放在一起写)</param>
        /// <param name="pColumnType">摘要所属的表格列的列类型</param>
        public void WriteSummary(object pContainer, ISummary pSummary, object pSummaryValue, int pRowIndex, int pColumnIndex, bool pIsIncludeSummaryTitle, ColumnTypes pColumnType)
        {
            var sheet = pContainer as Worksheet;

            if (sheet != null)
            {
                //初始化
                Cell  contentCell = sheet.Cells[pRowIndex, pColumnIndex];
                Style style       = contentCell.GetStyle();
                style.HorizontalAlignment = TextAlignmentType.Right;
                //
                string cellVal = string.Empty;
                if (pSummaryValue != null)
                {
                    cellVal = pSummaryValue.ToString();
                }
                if (pIsIncludeSummaryTitle)
                {
                    cellVal = string.Format("{0}{1}", pSummary.Title, cellVal);
                }
                //
                contentCell.PutValue(cellVal);
            }
            else
            {
                throw new ArgumentNullException("pContainer", "pContainer为null或不是Aspose.Cells.Worksheet对象.");
            }
        }
Example #8
0
 /// <summary>
 /// Saves the summary details
 /// </summary>
 /// <param name="seasonName">season name</param>
 /// <param name="summaryDetails">details to save</param>
 /// <returns>success flag</returns>
 public bool SaveSummaryData(
     string seasonName,
     ISummary summaryDetails)
 {
     return(this.summaryDataReader.SaveSummaryData(
                RootPath.DataPath + Path.DirectorySeparatorChar + seasonName + Path.DirectorySeparatorChar + seasonName + IOPaths.xmlExtension,
                summaryDetails));
 }
Example #9
0
        /// <summary>
        /// Checks validity of soil parameters. Throws if soil is invalid.
        /// Standardises the soil before performing tests.
        /// </summary>
        /// <param name="soilToCheck">The soil to check.</param>
        /// <param name="summary">A summary instance to write warning messages to.</param>
        public static void CheckWithStandardisation(Soil soilToCheck, ISummary summary)
        {
            var soil = Apsim.Clone(soilToCheck) as Soil;

            SoilStandardiser.Standardise(soil);

            Check(soil, summary);
        }
Example #10
0
 /// <summary>
 /// Add new warning to the List if it hasn't been reported
 /// </summary>
 /// <param name="checkMessage">The warning message to check if it exists</param>
 /// <param name="summary">The summary model to write to</param>
 /// <param name="sender">The activity sending the warning</param>
 /// <param name="messageType">The type of message to write</param>
 /// <param name="fullMessage">A full message to report if check message does not exist, otherwise use check message</param>
 public void CheckAndWrite(string checkMessage, ISummary summary, IModel sender, MessageType messageType, string fullMessage = "")
 {
     if (!Exists(checkMessage) & summary != null)
     {
         summary.WriteMessage(sender, (fullMessage.Any())?fullMessage:checkMessage, messageType);
         Add(checkMessage);
     }
 }
Example #11
0
        public static SummaryViewModel AddSummaryRow(this Panel parent, ISummary summary, uint rowHeight = 0)
        {
            var contentPresenter = new ContentPresenter {
                HorizontalAlignment = HorizontalAlignment.Right
            };

            return(new SummaryViewModel(summary, AddLabeledRow(parent, summary.Name, contentPresenter, rowHeight), contentPresenter));
        }
        private double fitnessOf(ISummary summary)
        {
            var fitness = 0.0;

            // time-out x crashing x nothing
            switch (summary.Result)
            {
            case Result.TimeOut:
                return(0.0);

            case Result.Failed:
                // still better than timing out
                break;

            case Result.Suceeded:
                fitness += 100;     // on top of the "distance travelled" score
                break;
            }

            // points for every way point passed
            fitness += summary.DistanceTravelled * 100 / Math.Max(1.0, summary.SimulationTime.TotalSeconds);

            var actionsInTotal = 0;
            var actionsWithHightThrottleAndSmallSteeringAngle = 0;

            var          totalDistanceTravelled = 0.0;
            VehicleState?previous = null;

            foreach (var log in summary.Log)
            {
                // ideas:
                // - proportion of time when it was going at max speed
                // - minimize number of direction changes
                if (log is IActionSelectedEvent selected)
                {
                    actionsInTotal++;

                    if (selected.Action.Throttle > 0.75 && Math.Abs(selected.Action.Steering) < 0.2)
                    {
                        actionsWithHightThrottleAndSmallSteeringAngle++;
                    }
                }
                else if (log is VehicleStateUpdatedEvent updated)
                {
                    if (previous.HasValue)
                    {
                        totalDistanceTravelled += Distance.Between(updated.State.Position, previous.Value.Position);
                    }

                    previous = updated.State;
                }
            }

            fitness += 10 * ((double)actionsWithHightThrottleAndSmallSteeringAngle / actionsInTotal);
            fitness += 10 * summary.SimulationTime.TotalSeconds / totalDistanceTravelled;

            return(Math.Max(0.0, fitness));
        }
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="logger">The logger to write debugging and diagnostics information to</param>
        /// <param name="metricFactory">The factory to create metrics containers from.</param>
        /// <param name="partitionId">The identifier of the partition that the context represents.</param>
        /// <param name="readLastEnqueuedEventProperties">A function that can be used to read the last enqueued event properties for the partition.</param>
        /// <param name="checkpointManager">The checkpoint manager to used to create the checkpoint</param>
        internal ProcessorPartitionContext(ILogger logger, IMetricFactory metricFactory, string partitionId, LastPropertiesReader readLastEnqueuedEventProperties, ICheckpointManager checkpointManager) : base(partitionId)
        {
            _logger            = logger;
            _checkpointManager = checkpointManager;
            _readLastEnqueuedEventProperties = readLastEnqueuedEventProperties;

            _checkpointCounter = metricFactory.CreateCounter($"ppc-checkpoint-counter-{partitionId}", $"The number of times that the checkpoint has been called for partition {partitionId}", false, new string[0]);
            _checkpointTiming  = metricFactory.CreateSummary($"ppc-checkpoint-timing-{partitionId}", $"The time taken to perform checkpoints for partition {partitionId}", 10, false, new string[0]);
        }
 public NotificationSummary(ISummary sum, NotificationType notificationType)
 {
     Subject = sum.Subject;
     Received = sum.Received;
     Sender = sum.Sender;
     EnvelopeId = sum.EnvelopeId;
     UniqueId = sum.UniqueId;
     CcLine = sum.CcLine;
     NotificationType = notificationType.ToString();
 }
        public string GetSummaryAsText(ISummary summary)
        {
            if (summary == null)
                return string.Empty;

            if (summary.InvalidInput)
                return string.Empty;

            return _formatter.GetFormattedSummary(summary, ' ');
        }
Example #16
0
        /// <inheritdoc />
        public ISummary CreateSummary(string name, string help, long duration, bool delayPublish, string[] labels)
        {
            var summaries = new ISummary[_providers.Count];

            for (var index = 0; index < summaries.Length; index++)
            {
                summaries[index] = _providers.ElementAt(index).Value.CreateSummary(name, help, duration, delayPublish, labels);
            }

            return(summaries.Length == 1 ? summaries[0] : new Summary(summaries, name, help, labels));
        }
Example #17
0
 private static ScenarioSummary ConvertToScenarioSummary(ISummary summary, ScenarioMetaData scenarioMetaData)
 {
     return(new ScenarioSummary(GetScenarioType(summary),
                                scenarioMetaData.ContainerType,
                                summary.LevelMin,
                                summary.LevelMax,
                                summary.Name,
                                summary.Author,
                                summary.Description,
                                summary,
                                scenarioMetaData.LastWriteTime,
                                scenarioMetaData.FullName));
 }
Example #18
0
        /// <summary>
        /// Release the old model and reset with the new one.
        /// </summary>
        /// <param name="newModel">new model.</param>
        protected void UpdateModel(ISummary newModel)
        {
            this.model.SummaryDataChangedEvent -= this.PopulateSummaryFromModel;
            this.model.FastestDataChangedEvent -= this.FastestAthletesFromModel;

            this.model = newModel;

            this.model.SummaryDataChangedEvent += this.PopulateSummaryFromModel;
            this.model.FastestDataChangedEvent += this.FastestAthletesFromModel;

            this.PopulateSummaryFromModel(null, EventArgs.Empty);
            this.FastestAthletesFromModel(null, EventArgs.Empty);
        }
        public void Setup()
        {
            _summary      = OurMetricFactory.CreateSummary("testSummary1", HelpText);
            _theirSummary = TheirMetricFactory.CreateSummary("testSummary1", HelpText);
            _dataset      = new double[_opIterations];

            var rnd = new Random();

            for (int i = 0; i < _opIterations; i++)
            {
                _dataset[i] = rnd.NextDouble() * 100_000d;
            }
        }
Example #20
0
        public string GetSummaryAsText(ISummary summary)
        {
            if (summary == null)
            {
                return(string.Empty);
            }

            if (summary.InvalidInput)
            {
                return(string.Empty);
            }

            return(_formatter.GetFormattedSummary(summary, ' '));
        }
Example #21
0
        public static void StoreResult(ITrack track, IVehicleModel vehicle, ISummary summary, string imageFilePath, string fileName)
        {
            var serializableSummary = new SerialzableSimulationResult
            {
                SimulationTime     = summary.SimulationTime.TotalSeconds,
                Result             = summary.Result,
                Log                = summary.Log.Select(SerializableEventFactory.From),
                Track              = SerializableTrack.From(track.TileSize, track.Circuit, track.OccupancyGrid),
                VehicleModel       = vehicle,
                TrackImageFilePath = imageFilePath
            };

            var json = JsonConvert.SerializeObject(serializableSummary, CustomJsonSerializationSettings.Default);

            File.WriteAllText(fileName, json);
        }
Example #22
0
 public override bool IsVisible(IReadonlyContext context, ISummary summary)
 {
     if (summary == HintSummary)
     {
         return(CopySpelling.Get(context).Enabled);
     }
     if (summary == SsvepSchemesSummary)
     {
         return(ControlParadigm.Get(context) == SpellerControlParadigm.SsvepWithEyeTracking);
     }
     if (summary == EstimatedFlashingCountSummary || summary == SubTrialDurationSummary)
     {
         return(ControlParadigm.Get(context) == SpellerControlParadigm.P300WithEyeTracking);
     }
     return(true);
 }
Example #23
0
        /// <summary>
        /// 往容器中写摘要标题
        /// </summary>
        /// <param name="pContainer"></param>
        /// <param name="pSummary"></param>
        /// <param name="pRowIndex"></param>
        /// <param name="pColumnIndex"></param>
        public void WriteSummaryTitle(object pContainer, ISummary pSummary, int pRowIndex, int pColumnIndex)
        {
            var sheet = pContainer as Worksheet;

            if (sheet != null)
            {
                //初始化
                Cell  contentCell = sheet.Cells[pRowIndex, pColumnIndex];
                Style style       = contentCell.GetStyle();
                style.HorizontalAlignment = TextAlignmentType.Left;
                contentCell.PutValue(pSummary.Title);
            }
            else
            {
                throw new ArgumentNullException("pContainer", "pContainer为null或不是Aspose.Cells.Worksheet对象.");
            }
        }
Example #24
0
 public void CheckSoil(object sender, EventArgs e)
 {
     try
     {
         Soil currentSoil = this.explorerPresenter.ApsimXFile.FindByPath(this.explorerPresenter.CurrentNodePath)?.Value as Soil;
         if (currentSoil != null)
         {
             ISummary summary = currentSoil.FindInScope <ISummary>(this.explorerPresenter.CurrentNodePath);
             SoilChecker.CheckWithStandardisation(currentSoil, summary);
             explorerPresenter.MainPresenter.ShowMessage("Soil water parameters are valid.", Simulation.MessageType.Information);
         }
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Example #25
0
        public RequestMetricMiddleware(
            RequestDelegate next,
            IOptions <RequestMetricOptions> options,
            IMetricFactory <RequestMetricMiddleware> factory)
        {
            _next    = next;
            _options = options.Value;

            var labels = new List <string>();

            if (_options.IncludeStatusCode)
            {
                labels.Add("status_code");
            }

            if (_options.IncludeMethod)
            {
                labels.Add("method");
            }

            if (_options.IncludePath)
            {
                labels.Add("path");
            }

            if (_options.CustomLabels != null)
            {
                foreach (var customLabel in _options.CustomLabels)
                {
                    labels.Add(customLabel.Key);
                }
            }

            var helpTextEnd = string.Join(", ", labels);

            _labelsCount      = labels.Count;
            _requestDurations = factory.CreateSummary(_options.RequestDurationMetricName, opts =>
            {
                opts.Help       = DurationHelpText + helpTextEnd;
                opts.LabelNames = labels;
                if (_options.RequestDurationObjectives != null)
                {
                    opts.Objectives = _options.RequestDurationObjectives;
                }
            });
        }
Example #26
0
        /// <summary>
        /// Initialises a new instance of <see cref="ViewModels.SummaryViewModel"/> class.
        /// </summary>
        public SummaryViewModel(
            ISummary model)
        {
            this.model           = model;
            this.MaleRunners     = this.model.MaleRunners;
            this.FemaleRunners   = this.model.FemaleRunners;
            this.SBs             = this.model.SBs;
            this.PBs             = this.model.PBs;
            this.FirstTimers     = this.model.FirstTimers;
            this.FastestBoy      = this.model.FastestBoy;
            this.FastestBoyTime  = this.model.FastestBoyTime;
            this.FastestGirl     = this.model.FastestGirl;
            this.FastestGirlTime = this.model.FastestGirlTime;

            this.model.SummaryDataChangedEvent += this.PopulateSummaryFromModel;
            this.model.FastestDataChangedEvent += this.FastestAthletesFromModel;
        }
Example #27
0
        /// <summary>
        /// Configures the basic information associated with the instance, including metrics setup
        /// </summary>
        /// <param name="logger">The logger to write debugging and diagnostics information to</param>
        /// <param name="metricFactory">The metrics factory used to create metrics containers from</param>
        private void ConfigureInstance(ILogger logger, IMetricFactory metricFactory)
        {
            Guard.NotNull(nameof(logger), logger);
            Guard.NotNull(nameof(metricFactory), metricFactory);

            Logger        = logger;
            MetricFactory = metricFactory;

            using (logger.BeginScope("Configuring Instance"))
            {
                Logger.LogInformation("Beginning Configuring instance");
                _testCounter      = metricFactory.CreateCounter("bpm-test-count", "The number of times the poisoned message test has beene executed since the start of the instance.", false, new string[0]);
                _updateCounter    = metricFactory.CreateCounter("bpm-update-count", "The number of times the poisoned message store has been updated since the start of the instance.", false, new string[0]);
                _updateBlobTiming = metricFactory.CreateSummary("bspm-update-timing", "The timing of the calls to the Azure Storage for updating the poisoned message values", 10, false, new string[0]);
                _readBlobTiming   = metricFactory.CreateSummary("bspm-read-timing", "The timing of the calls to the Azure Storage for reading the poisoned message values", 10, false, new string[0]);
                Logger.LogInformation("Finished Configuring instance");
            }
        }
 public string GetFormattedSummary(ISummary summary, char seperator)
 {
     var outPutString = string.Empty;
     if (summary != null)
     {
         // get output
         outPutString = summary.TotalNumberOfPassengers.ToString() + seperator
                        + summary.NumberOfGeneralPassengers + seperator
                        + summary.NumberOfAirlinePassengers + seperator
                        + summary.NumberOfLoyaltyPassengers + seperator
                        + summary.NumberOfBags + seperator
                        + summary.LoyaltyPointsRedeemed + seperator
                        + summary.TotalCostOfFlight + seperator
                        + summary.UnadjustedTicketRevenue + seperator
                        + summary.AdjustedTicketRevenue + seperator
                        + (summary.CanFlightProceed?.ToString().ToUpperInvariant() ?? "FALSE");
     }
     return outPutString;
 }
Example #29
0
        /// <summary>
        /// Configures the basic information associated with the instance, including metrics setup
        /// </summary>
        /// <param name="logger">The logger to write debugging and diagnostics information to</param>
        /// <param name="metricFactory">The metrics factory used to create metrics containers from</param>
        private void ConfigureInstance(ILogger logger, IMetricFactory metricFactory)
        {
            Guard.NotNull(nameof(logger), logger);
            Guard.NotNull(nameof(metricFactory), metricFactory);

            Logger        = logger;
            MetricFactory = metricFactory;


            using (logger.BeginScope("Configuring Instance"))
            {
                Logger.LogInformation("Beginning Configuring instance");
                _listCheckpointsCounter  = metricFactory.CreateCounter("bscm-list-count", "The number of times the list of checkpoints has been invoked since the start of the instance.", false, new string[0]);
                _updateCheckpointCounter = metricFactory.CreateCounter("bscm-update-count", "The number of times the update checkpoint has been invoked since the start of the instance.", false, new string[0]);
                _listBlobTiming          = metricFactory.CreateSummary("bscm-list-timing", "The timing of the calls to the Azure Storage for list blob operations", 10, false, new string[0]);
                UpdateBlobTiming         = metricFactory.CreateSummary("bscm-update-timing", "The timing of the calls to the Azure Storage for update blob operations", 10, false, new string[0]);
                Logger.LogInformation("Finished Configuring instance");
            }
        }
        public string GetFormattedSummary(ISummary summary, char seperator)
        {
            var outPutString = string.Empty;

            if (summary != null)
            {
                // get output
                outPutString = summary.TotalNumberOfPassengers.ToString() + seperator
                               + summary.NumberOfGeneralPassengers + seperator
                               + summary.NumberOfAirlinePassengers + seperator
                               + summary.NumberOfLoyaltyPassengers + seperator
                               + summary.NumberOfBags + seperator
                               + summary.LoyaltyPointsRedeemed + seperator
                               + summary.TotalCostOfFlight + seperator
                               + summary.UnadjustedTicketRevenue + seperator
                               + summary.AdjustedTicketRevenue + seperator
                               + (summary.CanFlightProceed?.ToString().ToUpperInvariant() ?? "FALSE");
            }
            return(outPutString);
        }
Example #31
0
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="dependencyService">A service that can be used to retrieve dependencies that were injected</param>
        /// <param name="loggerFactory">A factory that can be used to create loggers</param>
        /// <param name="metricFactory">A factory that can be used to create metrics</param>
        /// <param name="webSocketConfiguration">The configuration of the web socket</param>
        /// <param name="bufferPool">The buffer pool used to retreive arrays</param>
        public WebSocketHandler(IDependencyService dependencyService, IWebSocketConfiguration webSocketConfiguration, IMetricFactory metricFactory, ILoggerFactory loggerFactory, IBufferPool bufferPool)
        {
            Guard.NotNull(nameof(metricFactory), metricFactory);
            Guard.NotNull(nameof(loggerFactory), loggerFactory);
            Guard.NotNull(nameof(bufferPool), bufferPool);
            Guard.NotNull(nameof(webSocketConfiguration), webSocketConfiguration);

            WebSocketConfiguration = webSocketConfiguration;
            BufferPool             = bufferPool;
            SessionId     = Guid.NewGuid();
            MetricFactory = metricFactory;
            Logger        = loggerFactory.CreateLogger($"Session Handler: {SessionId:N}");

            DependencyService = dependencyService;

            _errorCounter        = metricFactory.CreateCounter("WebSocket error counter", "Tracks the number of errors that have occurred since the start of the service", false, new string[0]);
            _serviceSessionGauge = metricFactory.CreateGauge("WebSocket sessions in progress", "Tracks the number of sessions underway", false, new string[0]);
            _sessionTimes        = metricFactory.CreateSummary("WebSocket session iteration times", "Tracks the time taken to execute an iteration in the session", 10, false, new string[0]);
            _receiveTimes        = metricFactory.CreateSummary("WebSocket message receive time", "Tracks the time taken to receive a message", 10, false, new string[0]);
        }
Example #32
0
 /// <summary>
 /// 获取摘要值
 /// </summary>
 /// <param name="pColumn">需要进行过滤的列</param>
 /// <param name="pSummary">摘要</param>
 /// <returns></returns>
 public string GetSummary(FilteringColumn pColumn, ISummary pSummary)
 {
     if (pColumn != null && pColumn.GridColumn != null && pSummary != null && this.ColumnSummaryValues != null)
     {
         if (this.ColumnSummaryValues.ContainsKey(pColumn.GridColumn))
         {
             var vals = this.ColumnSummaryValues[pColumn.GridColumn];
             if (vals != null && vals.Count > 0)
             {
                 foreach (var val in vals)
                 {
                     if (val.Key == pSummary)
                     {
                         return(val.Value);
                     }
                 }
             }
         }
     }
     return(null);
 }
Example #33
0
        public override IList <Object> GetSummary()
        {
            try
            {
                AccessLevel accessLevel = Authorize("summary");

                if (accessLevel < AccessLevel.Read)
                {
                    throw new UnauthorizedAccessException(String.Format(UNAUTHORIZED_ERROR, _settings["scope"]));
                }

                _kernel.Load(_summaryBindingPath);
                ISummary summary = _kernel.Get <ISummary>();
                return(summary.GetSummary());
            }
            catch (Exception e)
            {
                _logger.Error("Error getting summary: " + e);
                throw e;
            }
        }