usingHh.Mes.Common;usingHh.Mes.Common.Http;usingHh.Mes.Common.log;usingHh.Mes.Pojo.System;usingMicrosoft.AspNetCore.Mvc;usingSystem;usingSystem.IO;usingSystem.Linq;namespaceWebMvc.Areas.Planned.Controllers{[Area("Planned")]publicclassToolController:Controller{#regionpostmanpublicIActionResultIndex(){returnView();}[HttpPost]publicstringPostMan(HttpItemhttpItem){varresponse=HttpSend(httpItem);returnresponse;}privatestringHttpSend(HttpItemhttpItem){if(string.IsNullOrEmpty(httpItem.URL))return"{\"error\":\"URL is null\"}";varmethod=httpItem.Method;varitem=newHttpItem(){URL=httpItem.URL,Method=method,Referer=httpItem.Referer};if(method.ToUpper()=="POST"){if(string.IsNullOrEmpty(httpItem.Postdata))return"{\"error\":\"The option is post, and the parameter【Postdata】cannot be empty\"}";item.Postdata=httpItem.Postdata;item.ContentType=httpItem.ContentType;}if(!string.IsNullOrEmpty(httpItem.Referer))item.Referer=httpItem.Referer;//设置head信息if(!string.IsNullOrEmpty(httpItem.HeaderStr)){vararr=httpItem.HeaderStr.ToString().Split("&$");foreach(varvalueinarr){vartemp=value.Split(":");item.Header.Add(temp[0],temp[1]);}}varhttp=newHttpHelper();varresult=http.GetHtml(item);returnresult.Html;}#endregion#regionjosn美化publicIActionResultJosnIndex(){returnView();}#endregion#region系统监控publicIActionResultMonitor(){returnView();}[HttpGet]publicIActionResultGetSystemInfo(){try{varallDirves=ComputerHelp.GetDriveInfos();vardriveInfos=allDirves.Select(x=>new{dirName=x.Name,sysTypeName=x.DriveFormat,free=(x.TotalFreeSpace/1024/1024/1024).ToString("N1")+"G",total=(x.TotalSize/1024/1024/1024).ToString("N1")+"G",used=((x.TotalSize-x.TotalFreeSpace)/1024/1024/1024).ToString("N1")+"G",usage=((x.TotalSize-x.TotalFreeSpace)*100/x.TotalSize).ToString("N1")+"%"}).ToList();varmemery=ComputerHelp.GetMemery();varos=ComputerHelp.GetOSInfo();varcpuInfo=ComputerHelp.GetCPUInfo();vartimeSpan=DateTime.Now-SystemVariable.StartTime;varresult=new{cpu=new{name=string.Join("|",cpuInfo.Where(x=>x.Key.StartsWith("Name")).Select(x=>x.Value).ToArray()),supper=string.Join("|",cpuInfo.Where(x=>x.Key.StartsWith("Manufacturer")).Select(x=>x.Value).ToArray()),num=string.Join("|",cpuInfo.Where(x=>x.Key.StartsWith("ThreadCount")).Select(x=>x.Value).ToArray()),used=ComputerHelp.GetCpuUsage(),},mem=new{total=memery.Item1,free=memery.Item2,sys=memery.Item3,used=memery.Item4,},sys=new{name=ComputerHelp.GetComputerName(),startTime=SystemVariable.StartTime.ToString(),runTime=$"{timeSpan.Days}天{timeSpan.Hours}时{timeSpan.Minutes}分{timeSpan.Seconds}秒",path=Directory.GetCurrentDirectory(),caption=os["Caption"],osArchitecture=os["OSArchitecture"],ip=ComputerHelp.GetAddressIP(),},sysFiles=driveInfos};returnOk(result);}catch(Exceptionex){Log4NetHelper.Instance.Error($"获取系统信息失败,{ex}");returnBadRequest(ex);}}#endregion}}