Files
HTCloud/HT.Cloud.Web/Areas/SystemSecurity/Controllers/DeviceIOStatusController.cs
2023-04-25 10:27:55 +08:00

46 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*******************************************************************************
* Copyright © 2020 HT.Cloud.Framework 版权所有
* Author: HT.Cloud
* Description: WaterCloud快速开发平台
* Website
*********************************************************************************/
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Threading.Tasks;
using HT.Cloud.Code;
using HT.Cloud.Service.SystemSecurity;
namespace HT.Cloud.Web.Areas.SystemSecurity.Controllers
{
[Area("SystemSecurity")]
public class DeviceIOStatusController : BaseController
{
public ServerStateService _serverStateService { get; set; }
[HttpGet]
public async Task<ActionResult> GetServerDataJson()
{
return await Task.Run(() =>
{
//windows环境
var computer = ComputerHelper.GetComputerInfo();
var arm = computer.RAMRate;
var cpu = computer.CPURate;
var iis = computer.RunTime;
var TotalRAM = computer.TotalRAM;
string ip = WebHelper.GetWanIp();
string ipLocation = WebHelper.GetIpLocation(ip);
var IP = string.Format("{0} ({1})", ip, ipLocation);
return Content(new { ARM = arm, CPU = cpu, IIS = iis, TotalRAM = TotalRAM, IP = IP }.ToJson());
});
}
[HttpGet]
public async Task<ActionResult> GetServerData()
{
var data = (await _serverStateService.GetList(2)).OrderBy(a => a.F_Date).ToList();
return Content(data.ToJson());
}
}
}