Sfoglia il codice sorgente

1.异常记录优化
2.一些逻辑的bug修复

懒得勤快 6 anni fa
parent
commit
4e202467ef

+ 1 - 0
src/Masuit.MyBlogs.Core/App_Data/CustomKeywords.txt

@@ -226162,3 +226162,4 @@ ubuntu环境设置
 读写控制电路
 超流水线结构
 页面替换策略
+ShadowsocksR

+ 1 - 1
src/Masuit.MyBlogs.Core/Configs/HangfireJobInit.cs

@@ -50,7 +50,7 @@ namespace Masuit.MyBlogs.Core.Configs
         /// </summary>
         public static void EveryweekJob()
         {
-            HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.CreateLiceneIndex), "default");
+            HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.CreateLuceneIndex), "default");
         }
     }
 }

+ 16 - 10
src/Masuit.MyBlogs.Core/Controllers/BugController.cs

@@ -1,6 +1,8 @@
 using Common;
 using Hangfire;
+using Masuit.LuceneEFCore.SearchEngine.Interfaces;
 using Masuit.MyBlogs.Core.Extensions;
+using Masuit.MyBlogs.Core.Infrastructure.Application;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.Entity;
@@ -27,14 +29,15 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <summary>
         /// IssueService
         /// </summary>
-        public IIssueService IssueService { get; set; }
+        private IIssueService IssueService { get; set; }
 
         /// <summary>
         /// MessageService
         /// </summary>
-        public IInternalMessageService MessageService { get; set; }
+        private IInternalMessageService MessageService { get; set; }
 
         private readonly IHostingEnvironment _hostingEnvironment;
+        private readonly ISearchEngine<DataContext> _searchEngine;
 
         /// <summary>
         /// bug反馈
@@ -42,11 +45,12 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="issueService"></param>
         /// <param name="messageService"></param>
         /// <param name="hostingEnvironment"></param>
-        public BugController(IIssueService issueService, IInternalMessageService messageService, IHostingEnvironment hostingEnvironment)
+        public BugController(IIssueService issueService, IInternalMessageService messageService, IHostingEnvironment hostingEnvironment, ISearchEngine<DataContext> searchEngine)
         {
             IssueService = issueService;
             MessageService = messageService;
             _hostingEnvironment = hostingEnvironment;
+            _searchEngine = searchEngine;
         }
 
         /// <summary>
@@ -72,13 +76,13 @@ namespace Masuit.MyBlogs.Core.Controllers
             int total;
             if (string.IsNullOrEmpty(filter.Kw))
             {
-                list = IssueService.LoadPageEntitiesFromL2CacheNoTracking(filter.Page, filter.Size, out total, i => i.Status != Status.Handled || i.Level != BugLevel.Fatal || user.IsAdmin, i => i.SubmitTime, false).ToList();
+                list = IssueService.LoadPageEntitiesFromL2CacheNoTracking(filter.Page, filter.Size, out total, i => i.Status != Status.Handled && i.Level != BugLevel.Fatal || user.IsAdmin, i => i.SubmitTime, false).ToList();
             }
             else
             {
                 var searchResult = IssueService.SearchPage(filter.Page, filter.Size, filter.Kw);
                 total = searchResult.Total;
-                list = searchResult.Results.Where(i => i.Status != Status.Handled || i.Level != BugLevel.Fatal || user.IsAdmin).ToList();
+                list = searchResult.Results;
             }
 
             var pageCount = Math.Ceiling(total * 1.0 / filter.Size).ToInt32();
@@ -124,7 +128,8 @@ namespace Masuit.MyBlogs.Core.Controllers
             issue.Status = Status.Handled;
             issue.HandleTime = DateTime.Now;
             issue.Msg = req.Text;
-            bool b = IssueService.UpdateEntitySaved(issue);
+            IssueService.UpdateEntity(issue);
+            bool b = _searchEngine.SaveChanges() > 0;
             string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/bugfeed.html").Replace("{{title}}", issue.Title).Replace("{{link}}", issue.Link).Replace("{{text}}", req.Text).Replace("{{date}}", issue.HandleTime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
             BackgroundJob.Enqueue(() => CommonHelper.SendMail("bug提交反馈通知", content, issue.Email));
             return ResultData(null, b, b ? "问题处理成功!" : "处理失败!");
@@ -140,16 +145,17 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
             issue.Description = CommonHelper.ReplaceImgSrc(Regex.Replace(issue.Description, @"<img\s+[^>]*\s*src\s*=\s*['""]?(\S+\.\w{3,4})['""]?[^/>]*/>", "<img src=\"$1\"/>")).Replace("/thumb150/", "/large/");
             issue.IPAddress = HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
-            Issue bug = IssueService.AddEntitySaved(issue);
-            if (bug != null)
+            IssueService.AddEntity(issue);
+            bool b = _searchEngine.SaveChanges(issue.Level < BugLevel.Fatal) > 0;
+            if (b)
             {
                 MessageService.AddEntitySaved(new InternalMessage()
                 {
                     Title = $"来自【{issue.Name}({issue.Email})】的bug问题反馈",
-                    Content = bug.Description,
+                    Content = issue.Description,
                     Link = Url.Action("Index")
                 });
-                string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/bugreport.html").Replace("{{name}}", bug.Name).Replace("{{email}}", bug.Email).Replace("{{title}}", bug.Title).Replace("{{desc}}", bug.Description).Replace("{{link}}", bug.Link).Replace("{{date}}", bug.SubmitTime.ToString("yyyy-MM-dd HH:mm:ss"));
+                string content = System.IO.File.ReadAllText(_hostingEnvironment.WebRootPath + "/template/bugreport.html").Replace("{{name}}", issue.Name).Replace("{{email}}", issue.Email).Replace("{{title}}", issue.Title).Replace("{{desc}}", issue.Description).Replace("{{link}}", issue.Link).Replace("{{date}}", issue.SubmitTime.ToString("yyyy-MM-dd HH:mm:ss"));
                 BackgroundJob.Enqueue(() => CommonHelper.SendMail("bug提交通知", content, "[email protected]"));
                 return ResultData(issue, true, "问题提交成功,感谢您的反馈!");
             }

+ 3 - 3
src/Masuit.MyBlogs.Core/Controllers/CommentController.cs

@@ -114,7 +114,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         //新评论,只通知博主和楼主
                         foreach (var s in emails.Distinct())
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer]) + "|博客文章新评论:", content.Replace("{{link}}", Url.Action("Details", "Post", new
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客文章新评论:", content.Replace("{{link}}", Url.Action("Details", "Post", new
                             {
                                 id = com.PostId,
                                 cid = com.Id
@@ -136,7 +136,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         }, Request.Scheme) + "#comment";
                         foreach (var s in emails)
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]}文章评论回复:", content.Replace("{{link}}", link), s));
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]}文章评论回复:", content.Replace("{{link}}", link), s));
                         }
                     }
 #endif
@@ -144,7 +144,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 }
                 foreach (var s in emails.Distinct())
                 {
-                    BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer]) + "|博客文章新评论(待审核):", content.Replace("{{link}}", Url.Action("Details", "Post", new
+                    BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客文章新评论(待审核):", content.Replace("{{link}}", Url.Action("Details", "Post", new
                     {
                         id = com.PostId,
                         cid = com.Id

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/ErrorController.cs

@@ -12,7 +12,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// 404
         /// </summary>
         /// <returns></returns>
-        [Route("{*url}", Order = 99999), ResponseCache(Duration = 600)]
+        [Route("{*url}", Order = 99999), ResponseCache(Duration = 36000)]
         public ActionResult Index()
         {
             Response.StatusCode = 404;
@@ -32,7 +32,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// 503
         /// </summary>
         /// <returns></returns>
-        [Route("ServiceUnavailable"), ResponseCache(Duration = 600)]
+        [Route("ServiceUnavailable"), ResponseCache(Duration = 36000)]
         public ActionResult ServiceUnavailable()
         {
             Response.StatusCode = 503;

+ 3 - 3
src/Masuit.MyBlogs.Core/Controllers/MsgController.cs

@@ -174,7 +174,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     if (msg.ParentId == 0)
                     {
                         //新评论,只通知博主
-                        BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer]) + "|博客新留言:", content.Replace("{{link}}", Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme)), email));
+                        BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客新留言:", content.Replace("{{link}}", Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme)), email));
                     }
                     else
                     {
@@ -185,13 +185,13 @@ namespace Masuit.MyBlogs.Core.Controllers
                         string link = Url.Action("Index", "Msg", new { cid = msg2.Id }, Request.Scheme);
                         foreach (var s in emails.Distinct().Except(new[] { msg2.Email }))
                         {
-                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Replace("{{link}}", link), s));
+                            BackgroundJob.Enqueue(() => CommonHelper.SendMail($"{HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer])}{CommonHelper.SystemSettings["Title"]} 留言回复:", content.Replace("{{link}}", link), s));
                         }
                     }
 #endif
                     return ResultData(null, true, "留言发表成功,服务器正在后台处理中,这会有一定的延迟,稍后将会显示到列表中!");
                 }
-                BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Host + Request.Headers[HeaderNames.Referer]) + "|博客新留言(待审核):", content.Replace("{{link}}", Url.Action("Index", "Msg", new
+                BackgroundJob.Enqueue(() => CommonHelper.SendMail(HttpUtility.UrlDecode(Request.Headers[HeaderNames.Referer]) + "|博客新留言(待审核):", content.Replace("{{link}}", Url.Action("Index", "Msg", new
                 {
                     cid = msg2.Id
                 }, Request.Scheme)) + "<p style='color:red;'>(待审核)</p>", email));

+ 2 - 2
src/Masuit.MyBlogs.Core/Controllers/PostController.cs

@@ -477,12 +477,12 @@ namespace Masuit.MyBlogs.Core.Controllers
             post.Status = Status.Pended;
             post.ModifyDate = DateTime.Now;
             post.PostDate = DateTime.Now;
-            bool b = PostService.UpdateEntitySaved(post);
+            PostService.UpdateEntity(post);
+            bool b = _searchEngine.SaveChanges() > 0;
             if (!b)
             {
                 return ResultData(null, false, "审核失败!");
             }
-            _luceneIndexer.Add(post);
             if ("false" == CommonHelper.SystemSettings["DisabledEmailBroadcast"])
             {
                 var cast = BroadcastService.LoadEntities(c => c.Status == Status.Subscribed).ToList();

+ 1 - 1
src/Masuit.MyBlogs.Core/Controllers/SearchController.cs

@@ -50,7 +50,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <param name="page"></param>
         /// <param name="size"></param>
         /// <returns></returns>
-        [Route("s/{wd?}/{page:int?}/{size:int?}"), ResponseCache(VaryByQueryKeys = new[] { "wd", "page", "size" }, VaryByHeader = HeaderNames.Cookie, Duration = 60)]
+        [Route("s/{wd?}/{page:int?}/{size:int?}"), ResponseCache(VaryByQueryKeys = new[] { "wd", "page", "size" }, VaryByHeader = HeaderNames.Cookie, Duration = 600)]
         public ActionResult Search(string wd = "", int page = 1, int size = 10)
         {
             var nul = new List<PostOutputDto>();

+ 5 - 4
src/Masuit.MyBlogs.Core/Extensions/ExceptionMiddleware.cs

@@ -38,13 +38,13 @@ namespace Masuit.MyBlogs.Core.Extensions
             }
             catch (DbUpdateConcurrencyException ex)
             {
-                var err = $"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{context.Request.Path},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t{ex.InnerException?.Message}\t";
+                var err = $"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{HttpUtility.UrlDecode(context.Request.Path)},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t{ex.InnerException?.Message}\t";
                 LogManager.Error(err, ex);
                 await RedirectError(context);
             }
             catch (DbUpdateException ex)
             {
-                var err = $"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{context.Request.Path},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t{ex?.InnerException?.Message}\t";
+                var err = $"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{HttpUtility.UrlDecode(context.Request.Path)},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t{ex?.InnerException?.Message}\t";
                 LogManager.Error(err, ex);
                 await RedirectError(context);
             }
@@ -53,7 +53,7 @@ namespace Masuit.MyBlogs.Core.Extensions
                 LogManager.Debug("↓↓↓" + ex.Message + "↓↓↓");
                 ex.Handle(e =>
                 {
-                    LogManager.Error($"异常源:{e.Source},异常类型:{e.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{context.Request.Path},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t", e);
+                    LogManager.Error($"异常源:{e.Source},异常类型:{e.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{HttpUtility.UrlDecode(context.Request.Path)},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t", e);
                     return true;
                 });
                 await RedirectError(context);
@@ -61,7 +61,7 @@ namespace Masuit.MyBlogs.Core.Extensions
             catch (Exception ex)
             {
                 //LogManager.Error(ex);
-                LogManager.Error($"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{context.Request.Path},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t", ex);
+                LogManager.Error($"异常源:{ex.Source},异常类型:{ex.GetType().Name},\n请求路径:{context.Request.Scheme}://{context.Request.Host}{HttpUtility.UrlDecode(context.Request.Path)},请求参数:{HttpUtility.UrlDecode(context.Request.Body.ToByteArray(), Encoding.UTF8)},客户端用户代理:{context.Request.Headers["User-Agent"]},客户端IP:{context.Connection.RemoteIpAddress}\t", ex);
                 await RedirectError(context);
             }
         }
@@ -75,6 +75,7 @@ namespace Masuit.MyBlogs.Core.Extensions
                     break;
                 default:
                     context.Response.ContentType = "application/json";
+                    context.Response.StatusCode = 503;
                     await context.Response.WriteAsync(JsonConvert.SerializeObject(new
                     {
                         StatusCode = 503,

+ 6 - 0
src/Masuit.MyBlogs.Core/Extensions/FirewallMiddleware.cs

@@ -43,8 +43,14 @@ namespace Masuit.MyBlogs.Core.Extensions
                 return;
             }
 
+            if (context.Request.Path.ToString().Contains(new[] { "error", "serviceunavailable" }))
+            {
+                return;
+            }
+
             if (context.Connection.RemoteIpAddress.MapToIPv4().ToString().IsDenyIpAddress())
             {
+                context.Response.StatusCode = 403;
                 await context.Response.WriteAsync($"检测到您的IP({context.Connection.RemoteIpAddress.MapToIPv4()})异常,已被本站禁止访问,如有疑问,请联系站长!");
                 BackgroundJob.Enqueue(() => HangfireBackJob.InterceptLog(new IpIntercepter()
                 {

+ 8 - 1
src/Masuit.MyBlogs.Core/Extensions/Hangfire/HangfireBackJob.cs

@@ -1,4 +1,5 @@
 using Common;
+using Masuit.LuceneEFCore.SearchEngine;
 using Masuit.LuceneEFCore.SearchEngine.Interfaces;
 using Masuit.MyBlogs.Core.Infrastructure.Application;
 using Masuit.MyBlogs.Core.Infrastructure.Services.Interface;
@@ -210,12 +211,18 @@ namespace Masuit.MyBlogs.Core.Extensions.Hangfire
         /// <summary>
         /// 重建Lucene索引库
         /// </summary>
-        public void CreateLiceneIndex()
+        public void CreateLuceneIndex()
         {
             _searchEngine.CreateIndex(new List<string>()
             {
                 nameof(DataContext.Post),nameof(DataContext.Issues),
             });
+            var list1 = _searchEngine.Context.Issues.Where(i => i.Status != Status.Handled && i.Level != BugLevel.Fatal).ToList();
+            var list2 = _searchEngine.Context.Post.Where(i => i.Status != Status.Pended).ToList();
+            var list = new List<LuceneIndexableBaseEntity>();
+            list.AddRange(list1);
+            list.AddRange(list2);
+            _searchEngine.LuceneIndexer.Delete(list);
         }
     }
 }

+ 1 - 1
src/Masuit.MyBlogs.Core/Extensions/Hangfire/IHangfireBackJob.cs

@@ -42,6 +42,6 @@ namespace Masuit.MyBlogs.Core.Extensions.Hangfire
         /// <summary>
         /// 重建Lucene索引库
         /// </summary>
-        void CreateLiceneIndex();
+        void CreateLuceneIndex();
     }
 }

+ 1 - 1
src/Masuit.MyBlogs.Core/Hubs/MyHub.cs

@@ -89,7 +89,7 @@ namespace Masuit.MyBlogs.Core.Hubs
                         Console.ForegroundColor = ConsoleColor.White;
                         errorCount++;
                     }
-                    Thread.Sleep(3000);
+                    Thread.Sleep(10000);
                 }
             });
         }

+ 31 - 0
src/Masuit.MyBlogs.Core/Infrastructure/Services/PostService.cs

@@ -10,6 +10,7 @@ using Masuit.MyBlogs.Core.Models.Enum;
 using PanGu;
 using PanGu.HighLight;
 using System.Linq;
+using System.Threading.Tasks;
 
 namespace Masuit.MyBlogs.Core.Infrastructure.Services
 {
@@ -59,5 +60,35 @@ namespace Masuit.MyBlogs.Core.Infrastructure.Services
                 Total = searchResult.TotalHits
             };
         }
+
+        /// <summary>
+        /// 统一保存的方法
+        /// </summary>
+        /// <returns>受影响的行数</returns>
+        public override int SaveChanges()
+        {
+            return _searchEngine.SaveChanges();
+        }
+
+        /// <summary>
+        /// 统一保存数据
+        /// </summary>
+        /// <returns>受影响的行数</returns>
+        public override Task<int> SaveChangesAsync()
+        {
+            return _searchEngine.SaveChangesAsync();
+        }
+
+        /// <summary>
+        /// 添加实体并保存
+        /// </summary>
+        /// <param name="t">需要添加的实体</param>
+        /// <returns>添加成功</returns>
+        public override Post AddEntitySaved(Post t)
+        {
+            var p = base.AddEntity(t);
+            bool b = _searchEngine.SaveChanges() > 0;
+            return b ? p : default(Post);
+        }
     }
 }

+ 3 - 8
src/Masuit.MyBlogs.Core/Startup.cs

@@ -8,7 +8,6 @@ using Hangfire.Dashboard;
 using JiebaNet.Segmenter;
 using Masuit.LuceneEFCore.SearchEngine;
 using Masuit.LuceneEFCore.SearchEngine.Extensions;
-using Masuit.LuceneEFCore.SearchEngine.Interfaces;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Controllers;
 using Masuit.MyBlogs.Core.Extensions;
@@ -40,7 +39,6 @@ using Newtonsoft.Json;
 using Newtonsoft.Json.Serialization;
 using Swashbuckle.AspNetCore.Swagger;
 using System;
-using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
 using System.IO;
@@ -166,9 +164,9 @@ namespace Masuit.MyBlogs.Core
         /// <param name="app"></param>
         /// <param name="env"></param>
         /// <param name="db"></param>
-        /// <param name="searchEngine"></param>
+        /// <param name="hangfire"></param>
         /// <param name="luceneIndexerOptions"></param>
-        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataContext db, ISearchEngine<DataContext> searchEngine, LuceneIndexerOptions luceneIndexerOptions)
+        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataContext db, IHangfireBackJob hangfire, LuceneIndexerOptions luceneIndexerOptions)
         {
             if (env.IsDevelopment())
             {
@@ -201,10 +199,7 @@ namespace Masuit.MyBlogs.Core
             if (!Directory.Exists(lucenePath) || Directory.GetFiles(lucenePath).Length < 1)
             {
                 Console.WriteLine(",索引库不存在,开始自动创建Lucene索引库...");
-                searchEngine.CreateIndex(new List<string>()
-                {
-                    nameof(DataContext.Post),nameof(DataContext.Issues)
-                });
+                hangfire.CreateLuceneIndex();
                 Console.WriteLine("索引库创建完成!");
             }