升级到.net core 3.1;整体组件升级到最新版本

This commit is contained in:
2019-12-06 16:26:46 +08:00
parent 9fc5162230
commit e740282650
16 changed files with 179 additions and 61 deletions
@@ -483,8 +483,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
}
}
}
//处理三个勾选属性的
string isnew = Request.Form["IsNew"];
model.IsNew = isnew == "1" ? 1 : 0;
@@ -493,6 +491,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
string IsHide = Request.Form["IsHide"];
model.IsHide = IsHide == "1" ? 1 : 0;
//处理三个勾选属性的
model.Hits = entity.Hits;
model.UpdateTime = DateTime.Now;
@@ -503,8 +503,43 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
content = ThumbnailHelper.SaveRemoteImgForContent(content);
model.Content = content;
}
entity.AddTime = model.AddTime;
entity.AdsId = model.AdsId;
entity.BannerImg = model.BannerImg;
entity.Content = model.Content;
entity.Description = model.Description;
entity.FilePath = model.FilePath;
entity.Hits = model.Hits;
entity.Icon = model.Icon;
entity.IsBest = model.IsBest;
entity.IsComment = model.IsComment;
entity.IsDel = model.IsDel;
entity.IsHide = model.IsHide;
entity.IsLock = model.IsLock;
entity.IsMember = model.IsMember;
entity.IsNew = model.IsNew;
entity.IsRecommend = model.IsRecommend;
entity.IsTop = model.IsTop;
entity.ItemImg = morIMG;
entity.Keyword = model.Keyword;
entity.KId = model.KId;
entity.LinkURL = model.LinkURL;
entity.Location = model.Location;
entity.Origin = model.Origin;
entity.OriginURL = model.OriginURL;
entity.Pic = model.Pic;
entity.Sequence = model.Sequence;
entity.SubTitle = model.SubTitle;
entity.Tags = model.Tags;
entity.TemplateFile = model.TemplateFile;
entity.Title = model.Title;
entity.TitleColor = model.TitleColor;
entity.UpdateTime = DateTime.Now;
//model.AuthorId = Core.Admin.GetMyInfo().Id;
model.Save();
entity.Update();
//Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title);
Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");");
tip.Status = JsonTip.SUCCESS;
@@ -10,6 +10,11 @@ using XCode;
using Newtonsoft.Json;
using COMCMS.Web.Common;
using Microsoft.AspNetCore.Http;
using System.IO;
using NewLife.Log;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;
using System.Text;
namespace COMCMS.Web.Areas.AdminCP.Controllers
{
@@ -17,6 +22,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
[DisplayName("后台权限")]
public class PermissionController : AdminBaseController
{
private IWebHostEnvironment _env;
public PermissionController(IWebHostEnvironment env)
{
_env = env;
}
#region 事件管理
/// <summary>
/// 目标事件
@@ -329,5 +340,77 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
return Json(tip);
}
#endregion
#region 系统运行日志
[HttpGet]
[MyAuthorize("viewlist", "runlogs")]
[DisplayName("系统运行日志")]
public IActionResult RunLogs()
{
string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}";
List<string> lognames = new List<string>();
try
{
if (Directory.Exists(logPath))
{
DirectoryInfo directory = new DirectoryInfo(logPath);
List<string> listFiles = new List<string>();
DirectoryInfo[] directorys = directory.GetDirectories();
FileInfo[] files;
files = directory.GetFiles();
foreach (FileInfo file in files)
{
lognames.Add(file.Name);
}
}
}
catch (Exception ex)
{
XTrace.WriteException(ex);
}
lognames.Reverse();//倒序排列一下
ViewBag.logPath = logPath;
return View(lognames);
}
#endregion
#region 获取日志详情
[HttpPost]
[MyAuthorize("viewlist", "runlogs")]
public async Task<IActionResult> GetRunLogDetail(string logname)
{
if (string.IsNullOrEmpty(logname))
{
return Content("错误日志名称!");
}
string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}";
string logFullPath = logPath + logname;
if (!System.IO.File.Exists(logFullPath))
{
return Content("系统找不到本日志文件!");
}
XTrace.WriteLine("查看日志:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
IFileProvider fileProvider = new PhysicalFileProvider(logPath);
StringBuilder detail = new StringBuilder();
using (Stream stream = fileProvider.GetFileInfo(logname).CreateReadStream())
{
byte[] buffer = new byte[stream.Length];
await stream.ReadAsync(buffer, 0, buffer.Length);
detail.Append(Encoding.Default.GetString(buffer));
}
//using (StreamReader fs = new StreamReader(logFullPath))
//{
// detail.Append(fs.ReadToEndAsync());
//}
//string detail = await System.IO.File.ReadAllTextAsync(logFullPath);
return Content(detail.ToString());
}
#endregion
}
}
@@ -25,7 +25,7 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">文章标题:</label>
<label class="col-sm-3 control-label text-danger">文章标题:</label>
<div class="col-sm-8">
<input id="Title" name="Title" maxlength="200" type="text" class="form-control" required aria-required="true" placeholder="填写文章标题">
</div>
@@ -221,7 +221,7 @@
return false;
}
list.map(function (item, index) {
if (item.Id) {
if (item.id) {
ids.push(item.id);
}
})
@@ -265,7 +265,7 @@
return false;
}
list.map(function (item, index) {
if (item.Id) {
if (item.id) {
ids.push(item.id);
}
})