Exemplo n.º 1
0
        /// <summary>
        /// Shows the mode where the user can edit an existing queue
        /// </summary>
        private void ShowEditMode()
        {
            if (!IsEditMode)
            {
                return;
            }

            pnlEditDetails.Visible = true;
            pnlViewDetails.Visible = false;
            HideSecondaryBlocks(true);

            cbIsActive.Checked               = RockWebFarm.IsEnabled();
            tbWebFarmKey.Text                = SystemSettings.GetValue(SystemSetting.WEBFARM_KEY);
            nbPollingMin.IntegerValue        = RockWebFarm.GetLowerPollingLimitSeconds();
            nbPollingMax.IntegerValue        = RockWebFarm.GetUpperPollingLimitSeconds();
            nbPollingWait.IntegerValue       = RockWebFarm.GetMaxPollingWaitSeconds();
            nbPollingDifference.IntegerValue = RockWebFarm.GetMinimumPollingDifferenceSeconds();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the mode where the user is only viewing an existing streak type
        /// </summary>
        private void ShowViewMode()
        {
            if (!IsViewMode())
            {
                return;
            }

            var canEdit = CanEdit();

            btnEdit.Visible = canEdit;

            pnlEditDetails.Visible = false;
            pnlViewDetails.Visible = true;
            HideSecondaryBlocks(false);

            // Load values from system settings
            var minPolling    = RockWebFarm.GetLowerPollingLimitSeconds();
            var maxPolling    = RockWebFarm.GetUpperPollingLimitSeconds();
            var minDifference = RockWebFarm.GetMinimumPollingDifferenceSeconds();
            var pollingWait   = RockWebFarm.GetMaxPollingWaitSeconds();

            var maskedKey = SystemSettings.GetValue(SystemSetting.WEBFARM_KEY).Masked();

            if (maskedKey.IsNullOrWhiteSpace())
            {
                maskedKey = "None";
            }

            // Build the description list with the values
            var descriptionList = new DescriptionList();

            descriptionList.Add("Key", string.Format("{0}", maskedKey));
            descriptionList.Add("Min Polling Limit", string.Format("{0} seconds", minPolling));
            descriptionList.Add("Max Polling Limit", string.Format("{0} seconds", maxPolling));
            descriptionList.Add("Min Polling Difference", string.Format("{0} seconds", minDifference));
            descriptionList.Add("Max Polling Wait", string.Format("{0} seconds", pollingWait));

            var unresponsiveMinutes  = 10;
            var unresponsiveDateTime = RockDateTime.Now.AddMinutes(0 - unresponsiveMinutes);

            // Bind the grid data view models
            using (var rockContext = new RockContext())
            {
                var webFarmNodeService       = new WebFarmNodeService(rockContext);
                var webFarmNodeMetricService = new WebFarmNodeMetricService(rockContext);

                var viewModels = webFarmNodeService.Queryable()
                                 .AsNoTracking()
                                 .Select(wfn => new WebFarmNodeService.NodeViewModel
                {
                    PollingIntervalSeconds = wfn.CurrentLeadershipPollingIntervalSeconds,
                    IsJobRunner            = wfn.IsCurrentJobRunner,
                    IsActive       = wfn.IsActive,
                    IsUnresponsive = wfn.IsActive && !wfn.StoppedDateTime.HasValue && wfn.LastSeenDateTime < unresponsiveDateTime,
                    IsLeader       = wfn.IsLeader,
                    NodeName       = wfn.NodeName,
                    LastSeen       = wfn.LastSeenDateTime,
                    Id             = wfn.Id,
                    Metrics        = wfn.WebFarmNodeMetrics
                                     .Where(wfnm =>
                                            wfnm.MetricType == WebFarmNodeMetric.TypeOfMetric.CpuUsagePercent &&
                                            wfnm.MetricValueDateTime >= ChartMinDate &&
                                            wfnm.MetricValueDateTime <= _chartMaxDate)
                                     .Select(wfnm => new WebFarmNodeMetricService.MetricViewModel
                    {
                        MetricValueDateTime = wfnm.MetricValueDateTime,
                        MetricValue         = wfnm.MetricValue
                    })
                                     .ToList()
                })
                                 .ToList();

                rNodes.DataSource = viewModels.OrderBy(n => n.NodeName);
                rNodes.DataBind();
            }

            lDescription.Text = descriptionList.Html;
        }