예제 #1
0
        public ActionResult <ServerInfo> GetServerInfo(string key)
        {
            if (string.Compare(key, statsKey) != 0)
            {
                return(BadRequest());
            }
            var ret  = new ServerInfo();
            var file = new FileInfo(typeof(StateController).Assembly.Location);

            ret.BuiltTime         = file.LastWriteTime;
            file                  = new FileInfo(typeof(Aspose.ThreeD.Scene).Assembly.Location);
            ret.Aspose3DBuiltTime = file.LastWriteTime;

            var process = Process.GetCurrentProcess();

            ret.ServerTime  = DateTime.Now;
            ret.StartupTime = process.StartTime;
            ret.Uptime      = (ret.ServerTime - ret.StartupTime).ToString();
            ret.WorkingSet  = process.WorkingSet64 / 1024.0 / 1024.0;
            List <OperationInfo> activeTasks = new List <OperationInfo>();
            var measurements = measurementService.GetMeasurements();

            foreach (var measurement in measurements)
            {
                var ops = measurement.GetActiveOperations();
                for (int i = 0; i < ops.Length; i++)
                {
                    activeTasks.Add(OperationInfo.From(ops[i]));
                }
            }
            ret.ActiveTasks = activeTasks.ToArray();
            return(new ActionResult <ServerInfo>(ret));
        }
예제 #2
0
        ///Gets at most last 200 measurements or measurements defined by queryParams from and to (ISO 8601)
        public async Task <IActionResult> Get(
            [FromRoute(Name = "deviceId")] string deviceId,
            [FromQuery] MeasurementQueryModel queryModel)
        {
            var watch = Stopwatch.StartNew();

            _logger.LogDebug(String.Format("Getting Measurements for serial number: {0}", deviceId));

            var measurements = await _measurementService.GetMeasurements(deviceId, queryModel.FromDate, queryModel.ToDate);

            watch.Stop();
            _logger.LogInformation(string.Format("Found {0} Measurements for serial number {1} in {2}ms", measurements.Count, deviceId, watch.ElapsedMilliseconds));

            return(Ok(measurements));
        }
        public async Task <IEnumerable <MeasurementDto> > GetMeasurements(string deviceUuid, int hours)
        {
            var measurements = await _measurementService.GetMeasurements(deviceUuid, hours);

            return(measurements.Select(MeasurementDto.FromModel));
        }