添加项目文件。
This commit is contained in:
@ -0,0 +1,103 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2020 HT.Cloud.Framework 版权所有
|
||||
* Author: HT.Cloud
|
||||
* Description: WaterCloud快速开发平台
|
||||
* Website:
|
||||
*********************************************************************************/
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using HT.Cloud.Code;
|
||||
using HT.Cloud.Code.Model;
|
||||
|
||||
namespace HT.Cloud.Web.Areas.SystemSecurity.Controllers
|
||||
{
|
||||
[Area("SystemSecurity")]
|
||||
public class AppLogController : BaseController
|
||||
{
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetGridJson(Pagination pagination, int timetype = 2)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
//导出全部页使用
|
||||
if (pagination.rows == 0 && pagination.page == 0)
|
||||
{
|
||||
pagination.rows = 99999999;
|
||||
pagination.page = 1;
|
||||
}
|
||||
List<AppLogEntity> list = new List<AppLogEntity>();
|
||||
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
|
||||
getDirectory(list, logPath);
|
||||
DateTime startTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate();
|
||||
DateTime endTime = DateTime.Now.ToString("yyyy-MM-dd").ToDate().AddDays(1);
|
||||
switch (timetype)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
|
||||
case 2:
|
||||
startTime = startTime.AddDays(-7);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
startTime = startTime.AddMonths(-1);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
startTime = startTime.AddMonths(-3);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
list = list.Where(a => (a.FileName.Split('.')[0]).CompareTo(startTime.ToString("yyyy-MM-dd")) >= 0 && (a.FileName.Split('.')[0]).CompareTo(endTime.ToString("yyyy-MM-dd")) <= 0).ToList();
|
||||
pagination.records = list.Count();
|
||||
list = list.OrderBy(a => a.FileName).Skip((pagination.page - 1) * pagination.rows).Take(pagination.rows).ToList();
|
||||
return Success(pagination.records, list);
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetFormJson(string keyValue)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
string content;
|
||||
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", keyValue.Split('.')[0].Substring(0, 7), keyValue);
|
||||
using (StreamReader sr = new StreamReader(logPath))
|
||||
{
|
||||
content = sr.ReadToEnd();
|
||||
}
|
||||
return Success("操作成功", HttpUtility.HtmlEncode(content));
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得指定路径下所有文件名
|
||||
/// </summary>
|
||||
/// <param name="sw">列表</param>
|
||||
/// <param name="path">文件夹路径</param>
|
||||
public static void getDirectory(List<AppLogEntity> sw, string path)
|
||||
{
|
||||
DirectoryInfo root = new DirectoryInfo(path);
|
||||
foreach (FileInfo f in root.GetFiles())
|
||||
{
|
||||
AppLogEntity app = new AppLogEntity();
|
||||
app.FileName = f.Name;
|
||||
sw.Add(app);
|
||||
}
|
||||
foreach (DirectoryInfo d in root.GetDirectories())
|
||||
{
|
||||
getDirectory(sw, d.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2020 HT.Cloud.Framework 版权所有
|
||||
* Author: HT.Cloud
|
||||
* Description: WaterCloud快速开发平台
|
||||
* Website:
|
||||
*********************************************************************************/
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using HT.Cloud.Code;
|
||||
using HT.Cloud.Domain.SystemSecurity;
|
||||
using HT.Cloud.Service.SystemSecurity;
|
||||
|
||||
namespace HT.Cloud.Web.Areas.SystemSecurity.Controllers
|
||||
{
|
||||
[Area("SystemSecurity")]
|
||||
public class FilterIPController : BaseController
|
||||
{
|
||||
public FilterIPService _service { get; set; }
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetGridJson(string keyword)
|
||||
{
|
||||
var data = await _service.GetLookList(keyword);
|
||||
return Success(data.Count, data);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetFormJson(string keyValue)
|
||||
{
|
||||
var data = await _service.GetLookForm(keyValue);
|
||||
return Content(data.ToJson());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> SubmitForm(FilterIPEntity filterIPEntity, string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyValue))
|
||||
{
|
||||
filterIPEntity.F_DeleteMark = false;
|
||||
}
|
||||
await _service.SubmitForm(filterIPEntity, keyValue);
|
||||
return await Success("操作成功。", "", keyValue);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
[HandlerAuthorize]
|
||||
public async Task<ActionResult> DeleteForm(string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.DeleteForm(keyValue);
|
||||
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2020 HT.Cloud.Framework 版权所有
|
||||
* Author: HT.Cloud
|
||||
* Description: WaterCloud快速开发平台
|
||||
* Website:
|
||||
*********************************************************************************/
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using HT.Cloud.Code;
|
||||
|
||||
namespace HT.Cloud.Web.Areas.SystemSecurity.Controllers
|
||||
{
|
||||
[Area("SystemSecurity")]
|
||||
public class LogController : BaseController
|
||||
{
|
||||
[HttpGet]
|
||||
[HandlerAuthorize]
|
||||
public ActionResult RemoveLog()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetGridJson(Pagination pagination, string keyword, int timetype = 2)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pagination.field))
|
||||
{
|
||||
pagination.order = "desc";
|
||||
pagination.field = "F_CreatorTime";
|
||||
}
|
||||
//导出全部页使用
|
||||
if (pagination.rows == 0 && pagination.page == 0)
|
||||
{
|
||||
pagination.rows = 99999999;
|
||||
pagination.page = 1;
|
||||
}
|
||||
var data = await _logService.GetList(pagination, timetype, keyword);
|
||||
return Success(pagination.records, data);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> SubmitRemoveLog(string keepTime)
|
||||
{
|
||||
await _logService.RemoveLog(keepTime);
|
||||
return Success("清空成功。");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using HT.Cloud.Code;
|
||||
using HT.Cloud.Domain.SystemSecurity;
|
||||
using HT.Cloud.Service;
|
||||
using HT.Cloud.Service.SystemSecurity;
|
||||
|
||||
namespace HT.Cloud.Web.Areas.SystemSecurity.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务
|
||||
/// </summary>
|
||||
[Area("SystemSecurity")]
|
||||
public class OpenJobsController : BaseController
|
||||
{
|
||||
public OpenJobsService _service { get; set; }
|
||||
|
||||
//获取详情
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> GetFormJson(string keyValue)
|
||||
{
|
||||
var data = await _service.GetForm(keyValue);
|
||||
return Content(data.ToJson());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> SubmitForm(OpenJobEntity entity, string keyValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyValue))
|
||||
{
|
||||
entity.F_EnabledMark = false;
|
||||
entity.F_DeleteMark = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.F_EnabledMark = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
await _service.SubmitForm(entity, keyValue);
|
||||
return await Success("操作成功。", "", keyValue);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
[HandlerAuthorize]
|
||||
public async Task<ActionResult> DeleteForm(string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.DeleteForm(keyValue);
|
||||
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本地可执行的任务列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> QueryLocalHandlers()
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
var data = _service.QueryLocalHandlers();
|
||||
return Content(data.ToJson());
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetGridJson(Pagination pagination, string keyword)
|
||||
{
|
||||
pagination.order = "desc";
|
||||
pagination.field = "F_EnabledMark";
|
||||
//导出全部页使用
|
||||
if (pagination.rows == 0 && pagination.page == 0)
|
||||
{
|
||||
pagination.rows = 99999999;
|
||||
pagination.page = 1;
|
||||
}
|
||||
var data = await _service.GetLookList(pagination, keyword);
|
||||
foreach (var item in data)
|
||||
{
|
||||
if (item.F_EnabledMark == true)
|
||||
{
|
||||
CronExpression cronExpression = new CronExpression(item.F_CronExpress);
|
||||
item.NextValidTimeAfter = cronExpression.GetNextValidTimeAfter(DateTime.Now).Value.ToLocalTime().DateTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.NextValidTimeAfter = null;
|
||||
}
|
||||
}
|
||||
return Success(pagination.records, data);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> GetLogJson(string keyValue, string keyword)
|
||||
{
|
||||
var data = await _service.GetLogList(keyValue);
|
||||
if (!string.IsNullOrEmpty(keyword))
|
||||
{
|
||||
data = data.Where(a => a.F_Description.Contains(keyword)).ToList();
|
||||
}
|
||||
return Success(data.Count, data);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HandlerAjaxOnly]
|
||||
public ActionResult GetDBListJson()
|
||||
{
|
||||
var data = DBInitialize.GetConnectionConfigs(true);
|
||||
return Content(data.Select(a => a.ConfigId).ToJson());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改变任务状态,启动/停止
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> ChangeStatus(string keyValue, int status)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.ChangeJobStatus(keyValue, status);
|
||||
return await Success("操作成功。", "", keyValue);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 立即执行任务
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> DoNow(string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.DoNow(keyValue);
|
||||
return await Success("操作成功。", "", keyValue);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除任务计划
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> ClearScheduleJob()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.ClearScheduleJob();
|
||||
return await Success("操作成功。", "", "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[HandlerAjaxOnly]
|
||||
public async Task<ActionResult> DeleteLogForm(string keyValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _service.DeleteLogForm(keyValue);
|
||||
return await Success("操作成功。", "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return await Error(ex.Message, "", keyValue, DbLogType.Delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* 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 ServerMonitoringController : 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());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user