Ejemplo n.º 1
0
        public ActionResult SetActualValue(Guid id)
        {
            var metric = GetMetricById(id);
            var model  = new SetActualValueModel()
            {
                Id             = metric.Id,
                MetricTypeName = metric.MetricType.DisplayName
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public JsonResult SetActualValue(SetActualValueModel model)
        {
            try
            {
                var metric = GetMetricById(model.Id);
                var client = GetDispatcherClient();

                // парсим число
                double?value = null;
                if (model.Value != null)
                {
                    try
                    {
                        value = ParseHelper.ParseDouble(model.Value);
                    }
                    catch (Exception)
                    {
                        throw new UserFriendlyException("Не удалось получить число из строки: " + model.Value);
                    }
                }

                var data = new SendMetricRequestData()
                {
                    ComponentId = metric.ComponentId,
                    Name        = metric.MetricType.SystemName,
                    Value       = value
                };
                if (model.ActualTime.HasValue)
                {
                    data.ActualIntervalSecs = model.ActualTime.Value.TotalSeconds;
                }
                client.SendMetric(CurrentUser.AccountId, data).Check();
                return(GetSuccessJsonResponse());
            }
            catch (Exception exception)
            {
                MvcApplication.HandleException(exception);
                return(GetErrorJsonResponse(exception));
            }
        }