Browse Source

1.修正防火墙bug和Session的bug
2.更新包,修正一些bug
3.资源管理器的bug修复
4.图床bug修复

懒得勤快 6 years ago
parent
commit
0488890548

+ 167 - 171
src/Masuit.MyBlogs.Core/Common/CommonHelper.cs

@@ -12,8 +12,6 @@ using Masuit.Tools.Html;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.Models;
 using Masuit.Tools.Models;
 #endif
 #endif
-using Masuit.Tools.Security;
-using Masuit.Tools.Systems;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using Microsoft.Net.Http.Headers;
 using Microsoft.Net.Http.Headers;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
@@ -84,6 +82,7 @@ namespace Common
         /// 系统设定
         /// 系统设定
         /// </summary>
         /// </summary>
         public static Dictionary<string, string> SystemSettings { get; set; }
         public static Dictionary<string, string> SystemSettings { get; set; }
+
         /// <summary>
         /// <summary>
         /// 访问量
         /// 访问量
         /// </summary>
         /// </summary>
@@ -100,6 +99,7 @@ namespace Common
                     return 1;
                     return 1;
                 }
                 }
             }
             }
+            set => RedisHelper.IncrBy("Interview:ViewCount");
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -112,7 +112,6 @@ namespace Common
                 try
                 try
                 {
                 {
                     return RedisHelper.Get<double>("Interview:ViewCount") / RedisHelper.Get<double>("Interview:RunningDays");
                     return RedisHelper.Get<double>("Interview:ViewCount") / RedisHelper.Get<double>("Interview:RunningDays");
-
                 }
                 }
                 catch
                 catch
                 {
                 {
@@ -181,32 +180,29 @@ namespace Common
         /// 上传图片到新浪图床
         /// 上传图片到新浪图床
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        public static (string, bool) UploadImage(Stream stream, string ext)
+        public static (string, bool) UploadImage(string file)
         {
         {
-            string[] apis =
-            {
-                "https://tu.xiangkanju.com/Zs_UP.php?type=multipart",
-                "https://api.yum6.cn/sinaimg.php?type=multipart",
-            };
-            int index = 0;
+            string api = "https://api.yum6.cn/sinaimg.php?type=multipart";
             string url = string.Empty;
             string url = string.Empty;
-            bool success = false;
-            for (int i = 0; i < apis.Length; i++)
+            using (HttpClient httpClient = new HttpClient())
             {
             {
-                using (HttpClient httpClient = new HttpClient())
+                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
+                httpClient.DefaultRequestHeaders.Referrer = new Uri(api);
+                using (var fs = File.OpenRead(file))
                 {
                 {
-                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                    httpClient.DefaultRequestHeaders.Referrer = new Uri(apis[i]);
-                    using (var bc = new StreamContent(stream))
+                    using (var bc = new StreamContent(fs))
                     {
                     {
                         bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                         bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                         {
                         {
-                            FileName = "".MDString() + ext,
+                            FileName = Path.GetFileName(file),
                             Name = "file"
                             Name = "file"
                         };
                         };
-                        using (var content = new MultipartFormDataContent { bc })
+                        using (var content = new MultipartFormDataContent
                         {
                         {
-                            var code = httpClient.PostAsync(apis[index], content).ContinueWith(t =>
+                            bc
+                        })
+                        {
+                            var code = httpClient.PostAsync(api, content).ContinueWith(t =>
                             {
                             {
                                 if (t.IsCanceled || t.IsFaulted)
                                 if (t.IsCanceled || t.IsFaulted)
                                 {
                                 {
@@ -220,30 +216,11 @@ namespace Common
                                     {
                                     {
                                         string s = res.Content.ReadAsStringAsync().Result;
                                         string s = res.Content.ReadAsStringAsync().Result;
                                         var token = JObject.Parse(s);
                                         var token = JObject.Parse(s);
-                                        switch (index)
-                                        {
-                                            case 0:
-                                                s = (string)token["code"];
-                                                if (s.Equals("200"))
-                                                {
-                                                    url = (string)token["pid"];
-                                                    return 1;
-                                                }
-
-                                                return 2;
-                                            case 1:
-                                                s = (string)token["code"];
-                                                if (s.Equals("200"))
-                                                {
-                                                    url = ((string)token["url"]).Replace("thumb150", "large");
-                                                    return 1;
-                                                }
-
-                                                return 2;
-                                        }
-                                        if (url.Length < 40)
+                                        s = (string)token["code"];
+                                        if (s.Equals("200"))
                                         {
                                         {
-                                            return 2;
+                                            url = ((string)token["url"]).Replace("thumb150", "large");
+                                            return url.Length > 40 ? 1 : 2;
                                         }
                                         }
                                     }
                                     }
                                     catch
                                     catch
@@ -256,69 +233,65 @@ namespace Common
                             }).Result;
                             }).Result;
                             if (code == 1)
                             if (code == 1)
                             {
                             {
-                                success = true;
-                                break;
-                            }
-
-                            index++;
-                            if (index == apis.Length)
-                            {
-                                Console.WriteLine("所有上传接口都挂掉了,重试人民网图床");
-                                return UploadPeople(stream, ext);
+                                var success = true;
+                                return (url.Replace("/thumb150/", "/large/"), success);
                             }
                             }
 
 
-                            Console.WriteLine("正在准备重试图片上传接口:" + apis[index]);
+                            Console.WriteLine("https://api.yum6.cn 图床接口都挂掉了,重试人民网图床");
+                            return UploadPeople(file);
                         }
                         }
                     }
                     }
-
                 }
                 }
             }
             }
-
-            return (url.Replace("/thumb150/", "/large/"), success);
         }
         }
+
         /// <summary>
         /// <summary>
         /// 上传图片到人民网图床
         /// 上传图片到人民网图床
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        public static (string url, bool success) UploadPeople(Stream stream, string ext)
+        public static (string url, bool success) UploadPeople(string file)
         {
         {
-            bool success = false;
+            var success = false;
             using (var httpClient = new HttpClient())
             using (var httpClient = new HttpClient())
             {
             {
                 httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Chrome/72.0.3626.96"));
                 httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Chrome/72.0.3626.96"));
-                using (var sc = new StreamContent(stream))
+                using (var fs = File.OpenRead(file))
                 {
                 {
-                    using (var mc = new MultipartFormDataContent
+                    using (var sc = new StreamContent(fs))
                     {
                     {
-                        { sc, "Filedata", SnowFlake.GetInstance().GetUniqueId()+ext },
-                        {new StringContent(ext),"filetype"}
-                    })
-                    {
-                        var str = httpClient.PostAsync("http://bbs1.people.com.cn/postImageUpload.do", mc).ContinueWith(t =>
+                        using (var mc = new MultipartFormDataContent
+                        {
+                            { sc, "Filedata", Path.GetFileName(file) },
+                            { new StringContent(Path.GetExtension(file)), "filetype" }
+                        })
                         {
                         {
-                            if (t.IsCompletedSuccessfully)
+                            var s = httpClient.PostAsync("http://bbs1.people.com.cn/postImageUpload.do", mc).ContinueWith(t =>
                             {
                             {
-                                var res = t.Result;
-                                if (res.IsSuccessStatusCode)
+                                if (t.IsCompletedSuccessfully)
                                 {
                                 {
-                                    string result = res.Content.ReadAsStringAsync().Result;
-                                    string url = "http://bbs1.people.com.cn" + (string)JObject.Parse(result)["imageUrl"];
-                                    if (url.EndsWith(ext))
+                                    var res = t.Result;
+                                    if (res.IsSuccessStatusCode)
                                     {
                                     {
-                                        success = true;
-                                        return url;
+                                        string result = res.Content.ReadAsStringAsync().Result;
+                                        string url = "http://bbs1.people.com.cn" + (string)JObject.Parse(result)["imageUrl"];
+                                        if (url.EndsWith(Path.GetExtension(file)))
+                                        {
+                                            success = true;
+                                            return url;
+                                        }
                                     }
                                     }
                                 }
                                 }
+
+                                return "";
+                            }).Result;
+                            if (!success)
+                            {
+                                Console.WriteLine("人民网图床上传接口都挂掉了,重试sm.ms图床");
+                                return UploadSmmsImage(file);
                             }
                             }
 
 
-                            return "";
-                        }).Result;
-                        if (!success)
-                        {
-                            Console.WriteLine("人民网图床上传接口都挂掉了,重试sm.ms图床");
-                            return UploadImageFallback(stream, ext);
+                            return (s, success);
                         }
                         }
-                        return (str, success);
                     }
                     }
                 }
                 }
             }
             }
@@ -328,43 +301,49 @@ namespace Common
         /// 上传图片到sm图床
         /// 上传图片到sm图床
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        private static (string, bool) UploadImageFallback(Stream stream, string ext)
+        private static (string, bool) UploadSmmsImage(string file)
         {
         {
             string url = string.Empty;
             string url = string.Empty;
             bool success = false;
             bool success = false;
-            using (HttpClient httpClient = new HttpClient())
+            using (var fs = File.OpenRead(file))
             {
             {
-                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                using (var bc = new StreamContent(stream))
+                using (HttpClient httpClient = new HttpClient())
                 {
                 {
-                    bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                    {
-                        FileName = "".CreateShortToken() + ext,
-                        Name = "smfile"
-                    };
-                    using (var content = new MultipartFormDataContent { bc })
+                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
+                    using (var bc = new StreamContent(fs))
                     {
                     {
-                        var code = httpClient.PostAsync("https://sm.ms/api/upload?inajax=1&ssl=1", content).ContinueWith(t =>
+                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
+                        {
+                            FileName = Path.GetFileName(file),
+                            Name = "smfile"
+                        };
+                        using (var content = new MultipartFormDataContent
                         {
                         {
-                            if (t.IsCanceled || t.IsFaulted)
+                            bc
+                        })
+                        {
+                            var code = httpClient.PostAsync("https://sm.ms/api/upload?inajax=1&ssl=1", content).ContinueWith(t =>
                             {
                             {
-                                return 0;
-                            }
+                                if (t.IsCanceled || t.IsFaulted)
+                                {
+                                    return 0;
+                                }
 
 
-                            var res = t.Result;
-                            if (res.IsSuccessStatusCode)
+                                var res = t.Result;
+                                if (res.IsSuccessStatusCode)
+                                {
+                                    string s = res.Content.ReadAsStringAsync().Result;
+                                    var token = JObject.Parse(s);
+                                    url = (string)token["data"]["url"];
+                                    return 1;
+                                }
+
+                                return 2;
+                            }).Result;
+                            if (code == 1)
                             {
                             {
-                                string s = res.Content.ReadAsStringAsync().Result;
-                                var token = JObject.Parse(s);
-                                url = (string)token["data"]["url"];
-                                return 1;
+                                success = true;
                             }
                             }
-
-                            return 2;
-                        }).Result;
-                        if (code == 1)
-                        {
-                            success = true;
                         }
                         }
                     }
                     }
                 }
                 }
@@ -375,53 +354,59 @@ namespace Common
                 return (url, success);
                 return (url, success);
             }
             }
 
 
-            return UploadImageFallback2(stream, ext);
+            return UploadImageFallback(file);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 上传图片到新浪图床
+        /// 上传图片到upload.cc图床
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        private static (string, bool) UploadImageFallback2(Stream stream, string ext)
+        private static (string, bool) UploadImageFallback(string file)
         {
         {
             string url = string.Empty;
             string url = string.Empty;
             bool success = false;
             bool success = false;
             using (HttpClient httpClient = new HttpClient())
             using (HttpClient httpClient = new HttpClient())
             {
             {
-                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                using (var bc = new StreamContent(stream))
+                using (var fs = File.OpenRead(file))
                 {
                 {
-                    bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                    {
-                        FileName = "".CreateShortToken() + ext,
-                        Name = "uploaded_file[]"
-                    };
-                    using (var content = new MultipartFormDataContent { bc })
+                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
+                    using (var bc = new StreamContent(fs))
                     {
                     {
-                        var code = httpClient.PostAsync("https://upload.cc/image_upload", content).ContinueWith(t =>
+                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
+                        {
+                            FileName = Path.GetFileName(file),
+                            Name = "uploaded_file[]"
+                        };
+                        using (var content = new MultipartFormDataContent
                         {
                         {
-                            if (t.IsCanceled || t.IsFaulted)
+                            bc
+                        })
+                        {
+                            var code = httpClient.PostAsync("https://upload.cc/image_upload", content).ContinueWith(t =>
                             {
                             {
-                                return 0;
-                            }
+                                if (t.IsCanceled || t.IsFaulted)
+                                {
+                                    return 0;
+                                }
 
 
-                            var res = t.Result;
-                            if (res.IsSuccessStatusCode)
-                            {
-                                string s = res.Content.ReadAsStringAsync().Result;
-                                var token = JObject.Parse(s);
-                                if ((int)token["code"] == 100)
+                                var res = t.Result;
+                                if (res.IsSuccessStatusCode)
                                 {
                                 {
-                                    url = "https://upload.cc/" + (string)token["success_image"][0]["url"];
-                                    return 1;
+                                    string s = res.Content.ReadAsStringAsync().Result;
+                                    var token = JObject.Parse(s);
+                                    if ((int)token["code"] == 100)
+                                    {
+                                        url = "https://upload.cc/" + (string)token["success_image"][0]["url"];
+                                        return 1;
+                                    }
                                 }
                                 }
-                            }
 
 
-                            return 2;
-                        }).Result;
-                        if (code == 1)
-                        {
-                            success = true;
+                                return 2;
+                            }).Result;
+                            if (code == 1)
+                            {
+                                success = true;
+                            }
                         }
                         }
                     }
                     }
                 }
                 }
@@ -432,55 +417,61 @@ namespace Common
                 return (url, success);
                 return (url, success);
             }
             }
 
 
-            return UploadImageFallback3(stream, ext);
+            return UploadImageFallback2(file);
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// 上传图片到新浪图床
+        /// 上传图片到upload.otar.im图床
         /// </summary>
         /// </summary>
         /// <returns></returns>
         /// <returns></returns>
-        private static (string, bool) UploadImageFallback3(Stream stream, string ext)
+        private static (string, bool) UploadImageFallback2(string file)
         {
         {
             string url = string.Empty;
             string url = string.Empty;
             bool success = false;
             bool success = false;
-            using (HttpClient httpClient = new HttpClient())
+            using (var fs = File.OpenRead(file))
             {
             {
-                httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
-                using (var bc = new StreamContent(stream))
+                using (HttpClient httpClient = new HttpClient())
                 {
                 {
-                    bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
-                    {
-                        FileName = "".CreateShortToken() + ext,
-                        Name = "img"
-                    };
-                    using (var content = new MultipartFormDataContent { bc })
+                    httpClient.DefaultRequestHeaders.UserAgent.Add(ProductInfoHeaderValue.Parse("Mozilla/5.0"));
+                    using (var bc = new StreamContent(fs))
                     {
                     {
-                        var code = httpClient.PostAsync("http://upload.otar.im/api/upload/imgur", content).ContinueWith(t =>
+                        bc.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
+                        {
+                            FileName = Path.GetFileName(file),
+                            Name = "img"
+                        };
+                        using (var content = new MultipartFormDataContent
                         {
                         {
-                            if (t.IsCanceled || t.IsFaulted)
+                            bc
+                        })
+                        {
+                            var code = httpClient.PostAsync("http://upload.otar.im/api/upload/imgur", content).ContinueWith(t =>
                             {
                             {
-                                return 0;
-                            }
+                                if (t.IsCanceled || t.IsFaulted)
+                                {
+                                    return 0;
+                                }
+
+                                var res = t.Result;
+                                if (res.IsSuccessStatusCode)
+                                {
+                                    string s = res.Content.ReadAsStringAsync().Result;
+                                    var token = JObject.Parse(s);
+                                    url = (string)token["url"];
+                                    return 1;
+                                }
 
 
-                            var res = t.Result;
-                            if (res.IsSuccessStatusCode)
+                                return 2;
+                            }).Result;
+                            if (code == 1)
                             {
                             {
-                                string s = res.Content.ReadAsStringAsync().Result;
-                                var token = JObject.Parse(s);
-                                url = (string)token["url"];
-                                return 1;
+                                success = true;
                             }
                             }
-
-                            return 2;
-                        }).Result;
-                        if (code == 1)
-                        {
-                            success = true;
                         }
                         }
                     }
                     }
                 }
                 }
-
             }
             }
+
             return (url, success);
             return (url, success);
         }
         }
 
 
@@ -499,18 +490,16 @@ namespace Common
                     var path = Path.Combine(AppContext.BaseDirectory + "wwwroot", src.Replace("/", @"\").Substring(1));
                     var path = Path.Combine(AppContext.BaseDirectory + "wwwroot", src.Replace("/", @"\").Substring(1));
                     if (File.Exists(path))
                     if (File.Exists(path))
                     {
                     {
-                        using (var fs = File.OpenRead(path))
+                        var (url, success) = UploadImage(path);
+                        if (success)
                         {
                         {
-                            var (url, success) = UploadImage(fs, Path.GetExtension(path));
-                            if (success)
-                            {
-                                content = content.Replace(src, url);
-                                BackgroundJob.Enqueue(() => File.Delete(path));
-                            }
+                            content = content.Replace(src, url);
+                            BackgroundJob.Enqueue(() => File.Delete(path));
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
+
             return content;
             return content;
         }
         }
 
 
@@ -521,7 +510,14 @@ namespace Common
         /// <returns></returns>
         /// <returns></returns>
         public static bool IsRobot(this HttpRequest req)
         public static bool IsRobot(this HttpRequest req)
         {
         {
-            return req.Headers[HeaderNames.UserAgent].ToString().Contains(new[] { "DNSPod", "Baidu", "spider", "Python", "bot" });
+            return req.Headers[HeaderNames.UserAgent].ToString().Contains(new[]
+            {
+                "DNSPod",
+                "Baidu",
+                "spider",
+                "Python",
+                "bot"
+            });
         }
         }
     }
     }
 }
 }

+ 43 - 80
src/Masuit.MyBlogs.Core/Configs/RegisterAutomapper.cs

@@ -19,99 +19,62 @@ namespace Masuit.MyBlogs.Core.Configs
         {
         {
             Mapper.Initialize(m =>
             Mapper.Initialize(m =>
             {
             {
-                m.CreateMap<Broadcast, BroadcastInputDto>();
-                m.CreateMap<BroadcastInputDto, Broadcast>();
-                m.CreateMap<Broadcast, BroadcastOutputDto>();
-                m.CreateMap<BroadcastOutputDto, Broadcast>();
-                m.CreateMap<BroadcastOutputDto, BroadcastInputDto>();
-                m.CreateMap<BroadcastInputDto, BroadcastOutputDto>();
+                m.CreateMap<Broadcast, BroadcastInputDto>().ReverseMap();
+                m.CreateMap<Broadcast, BroadcastOutputDto>().ReverseMap();
+                m.CreateMap<BroadcastOutputDto, BroadcastInputDto>().ReverseMap();
 
 
-                m.CreateMap<Category, CategoryInputDto>();
-                m.CreateMap<CategoryInputDto, Category>();
-                m.CreateMap<Category, CategoryOutputDto>().ForMember(c => c.TotalPostCount, e => e.MapFrom(c => c.Post.Count)).ForMember(c => c.PendedPostCount, e => e.MapFrom(c => c.Post.Count(p => p.Status == Status.Pended)));
-                m.CreateMap<CategoryOutputDto, Category>();
-                m.CreateMap<CategoryInputDto, CategoryOutputDto>();
-                m.CreateMap<CategoryOutputDto, CategoryInputDto>();
+                m.CreateMap<Category, CategoryInputDto>().ReverseMap();
+                m.CreateMap<Category, CategoryOutputDto>().ForMember(c => c.TotalPostCount, e => e.MapFrom(c => c.Post.Count)).ForMember(c => c.PendedPostCount, e => e.MapFrom(c => c.Post.Count(p => p.Status == Status.Pended))).ReverseMap();
+                m.CreateMap<CategoryInputDto, CategoryOutputDto>().ReverseMap();
 
 
-                m.CreateMap<Comment, CommentInputDto>();
-                m.CreateMap<CommentInputDto, Comment>();
-                m.CreateMap<Comment, CommentOutputDto>();
-                m.CreateMap<CommentOutputDto, Comment>();
-                m.CreateMap<CommentInputDto, CommentOutputDto>();
-                m.CreateMap<CommentOutputDto, CommentInputDto>();
-                m.CreateMap<Comment, CommentViewModel>().ForMember(c => c.CommentDate, e => e.MapFrom(c => c.CommentDate.ToString("yyyy-MM-dd HH:mm:ss")));
+                m.CreateMap<Comment, CommentInputDto>().ReverseMap();
+                m.CreateMap<Comment, CommentOutputDto>().ReverseMap();
+                m.CreateMap<CommentInputDto, CommentOutputDto>().ReverseMap();
+                m.CreateMap<Comment, CommentViewModel>().ForMember(c => c.CommentDate, e => e.MapFrom(c => c.CommentDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
 
 
-                m.CreateMap<LeaveMessage, LeaveMessageInputDto>();
-                m.CreateMap<LeaveMessageInputDto, LeaveMessage>();
-                m.CreateMap<LeaveMessage, LeaveMessageOutputDto>();
-                m.CreateMap<LeaveMessageOutputDto, LeaveMessage>();
-                m.CreateMap<LeaveMessageInputDto, LeaveMessageOutputDto>();
-                m.CreateMap<LeaveMessageOutputDto, LeaveMessageInputDto>();
-                m.CreateMap<LeaveMessage, LeaveMessageViewModel>().ForMember(l => l.PostDate, e => e.MapFrom(l => l.PostDate.ToString("yyyy-MM-dd HH:mm:ss")));
+                m.CreateMap<LeaveMessage, LeaveMessageInputDto>().ReverseMap();
+                m.CreateMap<LeaveMessage, LeaveMessageOutputDto>().ReverseMap();
+                m.CreateMap<LeaveMessageInputDto, LeaveMessageOutputDto>().ReverseMap();
+                m.CreateMap<LeaveMessage, LeaveMessageViewModel>().ForMember(l => l.PostDate, e => e.MapFrom(l => l.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
 
 
-                m.CreateMap<Links, LinksInputDto>();
-                m.CreateMap<LinksInputDto, Links>();
-                m.CreateMap<Links, LinksOutputDto>();
-                m.CreateMap<LinksOutputDto, Links>();
-                m.CreateMap<LinksInputDto, LinksOutputDto>();
-                m.CreateMap<LinksOutputDto, LinksInputDto>();
+                m.CreateMap<Links, LinksInputDto>().ReverseMap();
+                m.CreateMap<Links, LinksOutputDto>().ReverseMap();
+                m.CreateMap<LinksInputDto, LinksOutputDto>().ReverseMap();
 
 
-                m.CreateMap<Menu, MenuInputDto>();
-                m.CreateMap<MenuInputDto, Menu>();
-                m.CreateMap<Menu, MenuOutputDto>();
-                m.CreateMap<MenuOutputDto, Menu>();
-                m.CreateMap<MenuInputDto, MenuOutputDto>();
-                m.CreateMap<MenuOutputDto, MenuInputDto>();
+                m.CreateMap<Menu, MenuInputDto>().ReverseMap();
+                m.CreateMap<Menu, MenuOutputDto>().ReverseMap();
+                m.CreateMap<MenuInputDto, MenuOutputDto>().ReverseMap();
 
 
-                m.CreateMap<Misc, MiscInputDto>();
-                m.CreateMap<MiscInputDto, Misc>();
-                m.CreateMap<Misc, MiscOutputDto>();
-                m.CreateMap<MiscOutputDto, Misc>();
-                m.CreateMap<MiscInputDto, MiscOutputDto>();
-                m.CreateMap<MiscOutputDto, MiscInputDto>();
-                m.CreateMap<Misc, MiscViewModel>().ForMember(c => c.PostDate, e => e.MapFrom(c => c.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(c => c.ModifyDate, e => e.MapFrom(c => c.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")));
+                m.CreateMap<Misc, MiscInputDto>().ReverseMap();
+                m.CreateMap<Misc, MiscOutputDto>().ReverseMap();
+                m.CreateMap<MiscInputDto, MiscOutputDto>().ReverseMap();
+                m.CreateMap<Misc, MiscViewModel>().ForMember(c => c.PostDate, e => e.MapFrom(c => c.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(c => c.ModifyDate, e => e.MapFrom(c => c.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
 
 
-                m.CreateMap<Notice, NoticeInputDto>();
-                m.CreateMap<NoticeInputDto, Notice>();
-                m.CreateMap<Notice, NoticeOutputDto>();
-                m.CreateMap<NoticeOutputDto, Notice>();
-                m.CreateMap<NoticeInputDto, NoticeOutputDto>();
-                m.CreateMap<NoticeOutputDto, NoticeInputDto>();
-                m.CreateMap<Notice, NoticeViewModel>().ForMember(c => c.PostDate, e => e.MapFrom(c => c.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(c => c.ModifyDate, e => e.MapFrom(c => c.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")));
+                m.CreateMap<Notice, NoticeInputDto>().ReverseMap();
+                m.CreateMap<Notice, NoticeOutputDto>().ReverseMap();
+                m.CreateMap<NoticeInputDto, NoticeOutputDto>().ReverseMap();
+                m.CreateMap<Notice, NoticeViewModel>().ForMember(c => c.PostDate, e => e.MapFrom(c => c.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(c => c.ModifyDate, e => e.MapFrom(c => c.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
 
 
-                m.CreateMap<Post, PostInputDto>();
+                m.CreateMap<Post, PostInputDto>().ReverseMap();
                 m.CreateMap<Post, PostHistoryVersion>().ForMember(v => v.PostId, e => e.MapFrom(p => p.Id));
                 m.CreateMap<Post, PostHistoryVersion>().ForMember(v => v.PostId, e => e.MapFrom(p => p.Id));
-                m.CreateMap<PostInputDto, Post>();
-                m.CreateMap<Post, PostOutputDto>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ForMember(p => p.CommentCount, e => e.MapFrom(p => p.Comment.Count(c => c.Status == Status.Pended)));
-                m.CreateMap<PostOutputDto, Post>();
-                m.CreateMap<PostInputDto, PostOutputDto>();
-                m.CreateMap<PostHistoryVersion, PostOutputDto>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name));
-                m.CreateMap<PostOutputDto, PostInputDto>();
-                m.CreateMap<Post, PostViewModel>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ForMember(p => p.PostDate, e => e.MapFrom(p => p.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(p => p.ModifyDate, e => e.MapFrom(p => p.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")));
+                m.CreateMap<Post, PostOutputDto>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ForMember(p => p.CommentCount, e => e.MapFrom(p => p.Comment.Count(c => c.Status == Status.Pended))).ReverseMap();
+                m.CreateMap<PostInputDto, PostOutputDto>().ReverseMap();
+                m.CreateMap<PostHistoryVersion, PostOutputDto>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ReverseMap();
+                m.CreateMap<Post, PostViewModel>().ForMember(p => p.CategoryName, e => e.MapFrom(p => p.Category.Name)).ForMember(p => p.PostDate, e => e.MapFrom(p => p.PostDate.ToString("yyyy-MM-dd HH:mm:ss"))).ForMember(p => p.ModifyDate, e => e.MapFrom(p => p.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss"))).ReverseMap();
 
 
-                m.CreateMap<SearchDetails, SearchDetailsInputDto>();
-                m.CreateMap<SearchDetailsInputDto, SearchDetails>();
-                m.CreateMap<SearchDetails, SearchDetailsOutputDto>();
-                m.CreateMap<SearchDetailsOutputDto, SearchDetails>();
-                m.CreateMap<SearchDetailsInputDto, SearchDetailsOutputDto>();
-                m.CreateMap<SearchDetailsOutputDto, SearchDetailsInputDto>();
+                m.CreateMap<SearchDetails, SearchDetailsInputDto>().ReverseMap();
+                m.CreateMap<SearchDetails, SearchDetailsOutputDto>().ReverseMap();
+                m.CreateMap<SearchDetailsInputDto, SearchDetailsOutputDto>().ReverseMap();
 
 
-                m.CreateMap<UserInfo, UserInfoInputDto>();
-                m.CreateMap<UserInfoInputDto, UserInfo>();
-                m.CreateMap<UserInfo, UserInfoOutputDto>();
-                m.CreateMap<UserInfoOutputDto, UserInfo>();
-                m.CreateMap<UserInfoInputDto, UserInfoOutputDto>();
-                m.CreateMap<UserInfoOutputDto, UserInfoInputDto>();
+                m.CreateMap<UserInfo, UserInfoInputDto>().ReverseMap();
+                m.CreateMap<UserInfo, UserInfoOutputDto>().ReverseMap();
+                m.CreateMap<UserInfoInputDto, UserInfoOutputDto>().ReverseMap();
 
 
-                m.CreateMap<LoginRecord, LoginRecordOutputDto>();
-                m.CreateMap<LoginRecordOutputDto, LoginRecord>();
+                m.CreateMap<LoginRecord, LoginRecordOutputDto>().ReverseMap();
 
 
-                m.CreateMap<Seminar, SeminarInputDto>();
-                m.CreateMap<SeminarInputDto, Seminar>();
-                m.CreateMap<Seminar, SeminarOutputDto>();
-                m.CreateMap<SeminarOutputDto, Seminar>();
-                m.CreateMap<SeminarInputDto, SeminarOutputDto>();
-                m.CreateMap<SeminarOutputDto, SeminarInputDto>();
+                m.CreateMap<Seminar, SeminarInputDto>().ReverseMap();
+                m.CreateMap<Seminar, SeminarOutputDto>().ReverseMap();
+                m.CreateMap<SeminarInputDto, SeminarOutputDto>().ReverseMap();
 
 
                 m.CreateMap<SeminarPost, SeminarPostHistoryVersion>().ForMember(s => s.PostHistoryVersionId, e => e.MapFrom(s => s.PostId)).ReverseMap();
                 m.CreateMap<SeminarPost, SeminarPostHistoryVersion>().ForMember(s => s.PostHistoryVersionId, e => e.MapFrom(s => s.PostId)).ReverseMap();
             });
             });

+ 50 - 56
src/Masuit.MyBlogs.Core/Controllers/FileController.cs

@@ -82,6 +82,31 @@ namespace Masuit.MyBlogs.Core.Controllers
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        public ActionResult Upload(string destination)
+        {
+            List<object> list = new List<object>();
+            if (Request.Form.Files.Count > 0)
+            {
+                foreach (var t in Request.Form.Files)
+                {
+                    string path = Path.Combine(_hostingEnvironment.ContentRootPath, CommonHelper.SystemSettings["PathRoot"].TrimStart('\\', '/'), destination.TrimStart('\\', '/'), t.FileName);
+                    using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+                    {
+                        t.CopyTo(fs);
+                    }
+                }
+            }
+            return Json(new
+            {
+                result = list
+            });
+        }
+
         /// <summary>
         /// <summary>
         /// 操作文件
         /// 操作文件
         /// </summary>
         /// </summary>
@@ -91,11 +116,11 @@ namespace Masuit.MyBlogs.Core.Controllers
         public ActionResult Handle([FromBody]FileRequest req)
         public ActionResult Handle([FromBody]FileRequest req)
         {
         {
             List<object> list = new List<object>();
             List<object> list = new List<object>();
-            var prefix = CommonHelper.SystemSettings["PathRoot"].Trim('\\', '/');
+            var root = Path.Combine(_hostingEnvironment.ContentRootPath, CommonHelper.SystemSettings["PathRoot"].TrimStart('\\', '/'));
             switch (req.Action)
             switch (req.Action)
             {
             {
                 case "list":
                 case "list":
-                    string path = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + req.Path : prefix + req.Path; //_hostingEnvironment.WebRootPath + (req.Path);
+                    string path = Path.Combine(root, req.Path.TrimStart('\\', '/'));
                     string[] dirs = Directory.GetDirectories(path);
                     string[] dirs = Directory.GetDirectories(path);
                     string[] files = Directory.GetFiles(path);
                     string[] files = Directory.GetFiles(path);
                     dirs.ForEach(s =>
                     dirs.ForEach(s =>
@@ -105,7 +130,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         {
                         {
                             date = dirinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"),
                             date = dirinfo.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"),
                             name = dirinfo.Name,
                             name = dirinfo.Name,
-                            rights = "drwxrwxrwx",
+                            //rights = "drwxrwxrwx",
                             size = 0,
                             size = 0,
                             type = "dir"
                             type = "dir"
                         });
                         });
@@ -116,7 +141,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                         list.Add(new FileList()
                         list.Add(new FileList()
                         {
                         {
                             name = info.Name,
                             name = info.Name,
-                            rights = "-rw-rw-rw-",
+                            //rights = "-rw-rw-rw-",
                             size = info.Length,
                             size = info.Length,
                             date = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"),
                             date = info.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"),
                             type = "file"
                             type = "file"
@@ -126,7 +151,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 case "remove":
                 case "remove":
                     req.Items.ForEach(s =>
                     req.Items.ForEach(s =>
                     {
                     {
-                        s = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + s : prefix + s;
+                        s = Path.Combine(root, s.TrimStart('\\', '/'));
                         try
                         try
                         {
                         {
                             System.IO.File.Delete(s);
                             System.IO.File.Delete(s);
@@ -143,8 +168,8 @@ namespace Masuit.MyBlogs.Core.Controllers
                     break;
                     break;
                 case "rename":
                 case "rename":
                 case "move":
                 case "move":
-                    path = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + req.Item : prefix + req.Item;
-                    var newpath = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + req.NewItemPath : prefix + req.NewItemPath;
+                    path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
+                    var newpath = Path.Combine(root, req.NewItemPath);
                     if (!string.IsNullOrEmpty(req.Item))
                     if (!string.IsNullOrEmpty(req.Item))
                     {
                     {
                         try
                         try
@@ -158,16 +183,16 @@ namespace Masuit.MyBlogs.Core.Controllers
                     }
                     }
                     else
                     else
                     {
                     {
-                        newpath = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + req.NewPath : prefix + req.NewPath;
+                        newpath = Path.Combine(root, req.NewPath.TrimStart('\\', '/'));
                         req.Items.ForEach(s =>
                         req.Items.ForEach(s =>
                         {
                         {
                             try
                             try
                             {
                             {
-                                System.IO.File.Move(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s, Path.Combine(newpath, Path.GetFileName(s)));
+                                System.IO.File.Move(Path.Combine(root, s.TrimStart('\\', '/')), Path.Combine(newpath, Path.GetFileName(s)));
                             }
                             }
                             catch
                             catch
                             {
                             {
-                                Directory.Move(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s, Path.Combine(newpath, Path.GetFileName(s)));
+                                Directory.Move(Path.Combine(root, s.TrimStart('\\', '/')), Path.Combine(newpath, Path.GetFileName(s)));
                             }
                             }
                         });
                         });
                     }
                     }
@@ -177,18 +202,16 @@ namespace Masuit.MyBlogs.Core.Controllers
                     });
                     });
                     break;
                     break;
                 case "copy":
                 case "copy":
-                    path = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Item) : prefix + req.Item;
-                    newpath = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.NewItemPath) : prefix + req.NewItemPath;
-                    //newpath = _hostingEnvironment.WebRootPath + (req.NewItemPath);
+                    path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
+                    newpath = Path.Combine(root, req.NewItemPath.TrimStart('\\', '/'));
                     if (!string.IsNullOrEmpty(req.Item))
                     if (!string.IsNullOrEmpty(req.Item))
                     {
                     {
                         System.IO.File.Copy(path, newpath);
                         System.IO.File.Copy(path, newpath);
                     }
                     }
                     else
                     else
                     {
                     {
-                        newpath = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.NewPath) : prefix + req.NewPath;
-                        //_hostingEnvironment.WebRootPath + (req.NewPath);
-                        req.Items.ForEach(s => System.IO.File.Copy(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s, !string.IsNullOrEmpty(req.SingleFilename) ? Path.Combine(newpath, req.SingleFilename) : Path.Combine(newpath, Path.GetFileName(s))));
+                        newpath = Path.Combine(root, req.NewPath.TrimStart('\\', '/'));
+                        req.Items.ForEach(s => System.IO.File.Copy(Path.Combine(root, s.TrimStart('\\', '/')), !string.IsNullOrEmpty(req.SingleFilename) ? Path.Combine(newpath, req.SingleFilename) : Path.Combine(newpath, Path.GetFileName(s))));
                     }
                     }
                     list.Add(new
                     list.Add(new
                     {
                     {
@@ -196,8 +219,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     });
                     });
                     break;
                     break;
                 case "edit":
                 case "edit":
-                    path = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Item) : prefix + req.Item;
-                    //path = _hostingEnvironment.WebRootPath + (req.Item);
+                    path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
                     string content = req.Content;
                     string content = req.Content;
                     System.IO.File.WriteAllText(path, content, Encoding.UTF8);
                     System.IO.File.WriteAllText(path, content, Encoding.UTF8);
                     list.Add(new
                     list.Add(new
@@ -206,16 +228,14 @@ namespace Masuit.MyBlogs.Core.Controllers
                     });
                     });
                     break;
                     break;
                 case "getContent":
                 case "getContent":
-                    path = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Item) : prefix + req.Item;
-                    //path = _hostingEnvironment.WebRootPath + (req.Item);
+                    path = Path.Combine(root, req.Item.TrimStart('\\', '/'));
                     content = System.IO.File.ReadAllText(path, Encoding.UTF8);
                     content = System.IO.File.ReadAllText(path, Encoding.UTF8);
                     return Json(new
                     return Json(new
                     {
                     {
                         result = content
                         result = content
                     });
                     });
                 case "createFolder":
                 case "createFolder":
-                    string dir = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.NewPath) : prefix + req.NewPath;
-                    //string dir = _hostingEnvironment.WebRootPath + (req.NewPath);
+                    string dir = Path.Combine(root, req.NewPath.TrimStart('\\', '/'));
                     var directoryInfo = Directory.CreateDirectory(dir);
                     var directoryInfo = Directory.CreateDirectory(dir);
                     list.Add(new
                     list.Add(new
                     {
                     {
@@ -225,8 +245,8 @@ namespace Masuit.MyBlogs.Core.Controllers
                 case "changePermissions":
                 case "changePermissions":
                     break;
                     break;
                 case "compress":
                 case "compress":
-                    string filename = Path.Combine(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Destination) : prefix + req.Destination, Path.GetFileNameWithoutExtension(req.CompressedFilename) + ".zip");
-                    _sevenZipCompressor.Zip(req.Items.Select(s => string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s).ToList(), filename);
+                    string filename = Path.Combine(Path.Combine(root, req.Destination.TrimStart('\\', '/')), Path.GetFileNameWithoutExtension(req.CompressedFilename) + ".zip");
+                    _sevenZipCompressor.Zip(req.Items.Select(s => Path.Combine(root, s.TrimStart('\\', '/'))).ToList(), filename);
 
 
                     list.Add(new
                     list.Add(new
                     {
                     {
@@ -234,8 +254,8 @@ namespace Masuit.MyBlogs.Core.Controllers
                     });
                     });
                     break;
                     break;
                 case "extract":
                 case "extract":
-                    string folder = Path.Combine(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Destination) : prefix + req.Destination, req.FolderName.Trim('/', '\\'));
-                    string zip = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (req.Item) : prefix + req.Item;
+                    string folder = Path.Combine(Path.Combine(root, req.Destination.TrimStart('\\', '/')), req.FolderName.Trim('/', '\\'));
+                    string zip = Path.Combine(root, req.Item.TrimStart('\\', '/'));
                     _sevenZipCompressor.Extract(zip, folder);
                     _sevenZipCompressor.Extract(zip, folder);
                     list.Add(new
                     list.Add(new
                     {
                     {
@@ -249,32 +269,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             });
             });
         }
         }
 
 
-        /// <summary>
-        /// 上传文件
-        /// </summary>
-        /// <returns></returns>
-        [HttpPost]
-        public ActionResult Upload(string destination)
-        {
-            List<object> list = new List<object>();
-            var prefix = CommonHelper.SystemSettings["PathRoot"].Trim('\\', '/');
-            if (Request.Form.Files.Count > 0)
-            {
-                foreach (var t in Request.Form.Files)
-                {
-                    string path = Path.Combine(string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (destination) : prefix + destination, t.FileName);
-                    using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
-                    {
-                        t.CopyTo(fs);
-                    }
-                }
-            }
-            return Json(new
-            {
-                result = list
-            });
-        }
-
         /// <summary>
         /// <summary>
         /// 下载文件
         /// 下载文件
         /// </summary>
         /// </summary>
@@ -285,19 +279,19 @@ namespace Masuit.MyBlogs.Core.Controllers
         [HttpGet]
         [HttpGet]
         public ActionResult Handle(string path, string[] items, string toFilename)
         public ActionResult Handle(string path, string[] items, string toFilename)
         {
         {
-            var prefix = CommonHelper.SystemSettings["PathRoot"].Trim('\\', '/');
+            path = path?.TrimStart('\\', '/') ?? "";
+            var root = CommonHelper.SystemSettings["PathRoot"].TrimStart('\\', '/');
+            var file = Path.Combine(_hostingEnvironment.ContentRootPath, root, path);
             switch (Request.Query["action"])
             switch (Request.Query["action"])
             {
             {
                 case "download":
                 case "download":
-                    string file = string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (path) : prefix + path;
-                    //_hostingEnvironment.WebRootPath + (path);
                     if (System.IO.File.Exists(file))
                     if (System.IO.File.Exists(file))
                     {
                     {
                         return this.ResumePhysicalFile(file, Path.GetFileName(file));
                         return this.ResumePhysicalFile(file, Path.GetFileName(file));
                     }
                     }
                     break;
                     break;
                 case "downloadMultiple":
                 case "downloadMultiple":
-                    byte[] buffer = _sevenZipCompressor.ZipStream(items.Select(s => string.IsNullOrEmpty(prefix) && !Directory.Exists(prefix) ? _hostingEnvironment.WebRootPath + (s) : prefix + s).ToList()).ToArray();
+                    byte[] buffer = _sevenZipCompressor.ZipStream(items.Select(s => Path.Combine(_hostingEnvironment.ContentRootPath, root, s.TrimStart('\\', '/'))).ToList()).ToArray();
                     return this.ResumeFile(buffer, Path.GetFileName(toFilename));
                     return this.ResumeFile(buffer, Path.GetFileName(toFilename));
             }
             }
             return Content("null");
             return Content("null");

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

@@ -1105,7 +1105,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         {
         {
             if (!RedisHelper.Exists("ArticleViewToken"))
             if (!RedisHelper.Exists("ArticleViewToken"))
             {
             {
-                RedisHelper.Set("ArticleViewToken", string.Empty.CreateShortToken(6));
+                RedisHelper.Set("ArticleViewToken", SnowFlake.GetInstance().GetUniqueShortId(6));
             }
             }
 
 
             var token = RedisHelper.Get("ArticleViewToken");
             var token = RedisHelper.Get("ArticleViewToken");

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

@@ -57,7 +57,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 return RedirectToAction("Search");
                 return RedirectToAction("Search");
             }
             }
             var start = DateTime.Today.AddDays(-7);
             var start = DateTime.Today.AddDays(-7);
-            string key = HttpContext.Connection.Id;
+            string key = "Search:" + HttpContext.Session.Id;
             if (RedisHelper.Exists(key) && !RedisHelper.Get(key).Equals(wd))
             if (RedisHelper.Exists(key) && !RedisHelper.Get(key).Equals(wd))
             {
             {
                 var hotSearches = SearchDetailsService.LoadEntitiesFromL2CacheNoTracking(s => s.SearchTime > start, s => s.SearchTime, false).GroupBy(s => s.KeyWords.ToLower()).OrderByDescending(g => g.Count()).Take(7).Select(g => new KeywordsRankOutputDto()
                 var hotSearches = SearchDetailsService.LoadEntitiesFromL2CacheNoTracking(s => s.SearchTime > start, s => s.SearchTime, false).GroupBy(s => s.KeyWords.ToLower()).OrderByDescending(g => g.Count()).Take(7).Select(g => new KeywordsRankOutputDto()

+ 13 - 1
src/Masuit.MyBlogs.Core/Controllers/SystemController.cs

@@ -215,6 +215,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                     name = e.GetDisplay()
                     name = e.GetDisplay()
                 });
                 });
             }
             }
+
             return ResultData(list);
             return ResultData(list);
         }
         }
 
 
@@ -257,10 +258,16 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// <returns></returns>
         /// <returns></returns>
         public ActionResult PathTest(string path)
         public ActionResult PathTest(string path)
         {
         {
-            if (path.Equals("/") || path.Equals("\\") || string.IsNullOrWhiteSpace(path))
+            if (!(path.EndsWith("/") || path.EndsWith("\\")))
+            {
+                return ResultData(null, false, "路径不存在");
+            }
+
+            if (path.Equals("/") || path.Equals("\\"))
             {
             {
                 return ResultData(null, true, "根路径正确");
                 return ResultData(null, true, "根路径正确");
             }
             }
+
             try
             try
             {
             {
                 bool b = Directory.Exists(path);
                 bool b = Directory.Exists(path);
@@ -282,6 +289,7 @@ namespace Masuit.MyBlogs.Core.Controllers
             MyHub.PerformanceCounter.Clear();
             MyHub.PerformanceCounter.Clear();
             return Ok();
             return Ok();
         }
         }
+
         #region 网站防火墙
         #region 网站防火墙
 
 
         /// <summary>
         /// <summary>
@@ -331,6 +339,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 {
                 {
                 }
                 }
             }
             }
+
             return ResultData(null);
             return ResultData(null);
         }
         }
 
 
@@ -412,9 +421,11 @@ namespace Masuit.MyBlogs.Core.Controllers
                         CommonHelper.DenyAreaIP[kv.Key].Remove(item);
                         CommonHelper.DenyAreaIP[kv.Key].Remove(item);
                     }
                     }
                 }
                 }
+
                 System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString(), Encoding.UTF8);
                 System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString(), Encoding.UTF8);
                 return ResultData(null);
                 return ResultData(null);
             }
             }
+
             return ResultData(null, false);
             return ResultData(null, false);
         }
         }
 
 
@@ -433,6 +444,7 @@ namespace Masuit.MyBlogs.Core.Controllers
                 System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"), string.Join(",", CommonHelper.IPWhiteList.Distinct()), Encoding.UTF8);
                 System.IO.File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "whitelist.txt"), string.Join(",", CommonHelper.IPWhiteList.Distinct()), Encoding.UTF8);
                 return ResultData(null);
                 return ResultData(null);
             }
             }
+
             return ResultData(null, false);
             return ResultData(null, false);
         }
         }
 
 

+ 1 - 39
src/Masuit.MyBlogs.Core/Controllers/ToolsController.cs

@@ -1,16 +1,12 @@
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Configs;
+using Masuit.Tools.Core.Net;
 using Masuit.Tools.Models;
 using Masuit.Tools.Models;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Net.Http.Headers;
 using Microsoft.Net.Http.Headers;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
-using Quartz;
-using Quartz.Spi;
 using System;
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Net.Http;
 using System.Net.Http;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
-using Masuit.Tools.Core.Net;
 
 
 #if DEBUG
 #if DEBUG
 using Masuit.Tools.Win32;
 using Masuit.Tools.Win32;
@@ -123,39 +119,5 @@ namespace Masuit.MyBlogs.Core.Controllers
                 return Json(physicsAddress.result.location);
                 return Json(physicsAddress.result.location);
             }
             }
         }
         }
-
-        /// <summary>
-        /// corn表达式生成
-        /// </summary>
-        /// <returns></returns>
-        [HttpGet("cron"), ResponseCache(Duration = 600, VaryByHeader = HeaderNames.Cookie)]
-        public ActionResult Cron()
-        {
-            return View();
-        }
-
-        /// <summary>
-        /// corn表达式
-        /// </summary>
-        /// <param name="cron"></param>
-        /// <returns></returns>
-        [HttpPost("cron"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "cron" }, VaryByHeader = HeaderNames.Cookie)]
-        public ActionResult Cron(string cron)
-        {
-            //时间表达式
-            ITrigger trigger = TriggerBuilder.Create().WithCronSchedule(cron).Build();
-            var dates = TriggerUtils.ComputeFireTimes(trigger as IOperableTrigger, null, 5);
-            List<string> list = new List<string>();
-            foreach (DateTimeOffset dtf in dates)
-            {
-                list.Add(TimeZoneInfo.ConvertTimeFromUtc(dtf.DateTime, TimeZoneInfo.Local).ToString());
-            }
-            if (list.Any())
-            {
-                return ResultData(list);
-            }
-            list.Add($"{cron} 不是合法的cron表达式");
-            return ResultData(list);
-        }
     }
     }
 }
 }

+ 12 - 1
src/Masuit.MyBlogs.Core/Controllers/UploadController.cs

@@ -1,4 +1,5 @@
 using Common;
 using Common;
+using Hangfire;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Common;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions.UEditor;
 using Masuit.MyBlogs.Core.Extensions.UEditor;
@@ -253,9 +254,19 @@ namespace Masuit.MyBlogs.Core.Controllers
             {
             {
                 case var _ when file.ContentType.StartsWith("image"):
                 case var _ when file.ContentType.StartsWith("image"):
                     path = Path.Combine(_hostingEnvironment.WebRootPath, "upload", "images", filename);
                     path = Path.Combine(_hostingEnvironment.WebRootPath, "upload", "images", filename);
-                    var (url, success) = CommonHelper.UploadImage(file.OpenReadStream(), Path.GetExtension(file.FileName));
+                    var dir = Path.GetDirectoryName(path);
+                    if (!Directory.Exists(dir))
+                    {
+                        Directory.CreateDirectory(dir);
+                    }
+                    using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))
+                    {
+                        file.CopyTo(fs);
+                    }
+                    var (url, success) = CommonHelper.UploadImage(path);
                     if (success)
                     if (success)
                     {
                     {
+                        BackgroundJob.Enqueue(() => System.IO.File.Delete(path));
                         return ResultData(url);
                         return ResultData(url);
                     }
                     }
                     break;
                     break;

+ 38 - 5
src/Masuit.MyBlogs.Core/Extensions/FirewallMiddleware.cs

@@ -2,8 +2,11 @@
 using Hangfire;
 using Hangfire;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.Tools;
 using Masuit.Tools;
+using Masuit.Tools.Core.Net;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using System;
 using System;
+using System.IO;
+using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Web;
 using System.Web;
 
 
@@ -50,27 +53,57 @@ namespace Masuit.MyBlogs.Core.Extensions
                 return;
                 return;
             }
             }
 
 
-            if (context.Connection.RemoteIpAddress.MapToIPv4().ToString().IsDenyIpAddress())
+            string ip = context.Connection.RemoteIpAddress.MapToIPv4().ToString();
+            if (ip.IsDenyIpAddress())
             {
             {
                 context.Response.StatusCode = 403;
                 context.Response.StatusCode = 403;
-                await context.Response.WriteAsync($"检测到您的IP({context.Connection.RemoteIpAddress.MapToIPv4()})异常,已被本站禁止访问,如有疑问,请联系站长!");
+                await context.Response.WriteAsync($"检测到您的IP({ip})异常,已被本站禁止访问,如有疑问,请联系站长!");
                 BackgroundJob.Enqueue(() => HangfireBackJob.InterceptLog(new IpIntercepter()
                 BackgroundJob.Enqueue(() => HangfireBackJob.InterceptLog(new IpIntercepter()
                 {
                 {
-                    IP = context.Connection.RemoteIpAddress.MapToIPv4().ToString(),
+                    IP = ip,
                     RequestUrl = HttpUtility.UrlDecode(context.Request.Scheme + "://" + context.Request.Host + context.Request.Path),
                     RequestUrl = HttpUtility.UrlDecode(context.Request.Scheme + "://" + context.Request.Host + context.Request.Path),
                     Time = DateTime.Now
                     Time = DateTime.Now
                 }));
                 }));
                 return;
                 return;
             }
             }
 
 
-            var times = RedisHelper.IncrBy("Frequency:" + context.Connection.Id);
-            RedisHelper.Expire("Frequency:" + context.Connection.Id, TimeSpan.FromMinutes(1));
+            var times = RedisHelper.IncrBy("Frequency:" + context.Session.Id);
+            RedisHelper.Expire("Frequency:" + context.Session.Id, TimeSpan.FromMinutes(1));
             if (times > 300)
             if (times > 300)
             {
             {
                 await context.Response.WriteAsync($"检测到您的IP({context.Connection.RemoteIpAddress})访问过于频繁,已被本站暂时禁止访问,如有疑问,请联系站长!");
                 await context.Response.WriteAsync($"检测到您的IP({context.Connection.RemoteIpAddress})访问过于频繁,已被本站暂时禁止访问,如有疑问,请联系站长!");
                 return;
                 return;
             }
             }
+
+            if (bool.Parse(CommonHelper.SystemSettings["EnableDenyArea"]) && !context.Session.TryGetValue("firewall", out _))
+            {
+                context.Session.Set("firewall", 0);
+                BackgroundJob.Enqueue(() => CheckFirewallIP(ip));
+            }
+
             await _next.Invoke(context);
             await _next.Invoke(context);
         }
         }
+
+        public static async Task CheckFirewallIP(string ip)
+        {
+            await ip.GetPhysicsAddressInfo().ContinueWith(async t =>
+            {
+                if (t.IsCompletedSuccessfully)
+                {
+                    var result = await t;
+                    if (result.Status == 0)
+                    {
+                        foreach (var key in CommonHelper.DenyAreaIP.Keys)
+                        {
+                            if (result.AddressResult.FormattedAddress.Contains(key))
+                            {
+                                CommonHelper.DenyAreaIP[key].Add(ip);
+                                File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString(), Encoding.UTF8);
+                            }
+                        }
+                    }
+                }
+            });
+        }
     }
     }
 }
 }

+ 1 - 1
src/Masuit.MyBlogs.Core/Extensions/RequestInterceptMiddleware.cs

@@ -26,7 +26,7 @@ namespace Masuit.MyBlogs.Core.Extensions
             if (!context.Session.TryGetValue("session", out _) && !context.Request.IsRobot())
             if (!context.Session.TryGetValue("session", out _) && !context.Request.IsRobot())
             {
             {
                 context.Session.Set("session", 0);
                 context.Session.Set("session", 0);
-                RedisHelper.IncrBy("Interview:ViewCount");
+                CommonHelper.InterviewCount++;
             }
             }
             await _next.Invoke(context);
             await _next.Invoke(context);
         }
         }

+ 8 - 8
src/Masuit.MyBlogs.Core/Extensions/SessionExt.cs

@@ -34,8 +34,8 @@ namespace Masuit.MyBlogs.Core.Extensions
 
 
             try
             try
             {
             {
-                RedisHelper.HSet("Session:" + HttpContext2.Current.Connection.Id, key, obj); //存储数据到缓存服务器,这里将字符串"my value"缓存,key 是"test"
-                RedisHelper.Expire("Session:" + HttpContext2.Current.Connection.Id, TimeSpan.FromMinutes(expire));
+                RedisHelper.HSet("Session:" + session.Id, key, obj); //存储数据到缓存服务器,这里将字符串"my value"缓存,key 是"test"
+                RedisHelper.Expire("Session:" + session.Id, TimeSpan.FromMinutes(expire));
             }
             }
             catch
             catch
             {
             {
@@ -47,27 +47,27 @@ namespace Masuit.MyBlogs.Core.Extensions
         /// 从Redis取Session
         /// 从Redis取Session
         /// </summary>
         /// </summary>
         /// <typeparam name="T"></typeparam>
         /// <typeparam name="T"></typeparam>
-        /// <param name="_"></param>
+        /// <param name="session"></param>
         /// <param name="key">键</param>
         /// <param name="key">键</param>
         /// <param name="expire">过期时间,默认20分钟</param>
         /// <param name="expire">过期时间,默认20分钟</param>
         /// <returns></returns> 
         /// <returns></returns> 
-        public static T GetByRedis<T>(this ISession _, string key, int expire = 20) where T : class
+        public static T GetByRedis<T>(this ISession session, string key, int expire = 20) where T : class
         {
         {
             if (HttpContext2.Current is null)
             if (HttpContext2.Current is null)
             {
             {
                 throw new Exception("请确保此方法调用是在同步线程中执行!");
                 throw new Exception("请确保此方法调用是在同步线程中执行!");
             }
             }
             T obj = default(T);
             T obj = default(T);
-            if (_ != null)
+            if (session != null)
             {
             {
-                obj = _.Get<T>(key);
+                obj = session.Get<T>(key);
             }
             }
 
 
             if (obj == default(T))
             if (obj == default(T))
             {
             {
                 try
                 try
                 {
                 {
-                    var sessionKey = "Session:" + HttpContext2.Current.Connection.Id;
+                    var sessionKey = "Session:" + session.Id;
                     if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
                     if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
                     {
                     {
                         RedisHelper.Expire(sessionKey, TimeSpan.FromMinutes(expire));
                         RedisHelper.Expire(sessionKey, TimeSpan.FromMinutes(expire));
@@ -102,7 +102,7 @@ namespace Masuit.MyBlogs.Core.Extensions
 
 
             try
             try
             {
             {
-                var sessionKey = "Session:" + HttpContext2.Current.Connection.Id;
+                var sessionKey = "Session:" + session.Id;
                 if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
                 if (RedisHelper.Exists(sessionKey) && RedisHelper.HExists(sessionKey, key))
                 {
                 {
                     RedisHelper.HDel(sessionKey, key);
                     RedisHelper.HDel(sessionKey, key);

+ 13 - 14
src/Masuit.MyBlogs.Core/Extensions/UEditor/CrawlerHandler.cs

@@ -1,4 +1,5 @@
 using Common;
 using Common;
+using Hangfire;
 using Masuit.Tools;
 using Masuit.Tools;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using System;
 using System;
@@ -81,23 +82,21 @@ namespace Masuit.MyBlogs.Core.Extensions.UEditor
                 {
                 {
                     using (var stream = response.GetResponseStream())
                     using (var stream = response.GetResponseStream())
                     {
                     {
-                        var (url, success) = CommonHelper.UploadImage(stream, Path.GetExtension(ServerUrl));
-                        if (success)
+                        var savePath = AppContext.BaseDirectory + "wwwroot" + ServerUrl;
+                        if (!Directory.Exists(Path.GetDirectoryName(savePath)))
                         {
                         {
-                            ServerUrl = url;
+                            Directory.CreateDirectory(Path.GetDirectoryName(savePath));
+                        }
+                        using (var ms = new MemoryStream())
+                        {
+                            stream.CopyTo(ms);
+                            File.WriteAllBytes(savePath, ms.GetBuffer());
                         }
                         }
-                        else
+                        var (url, success) = CommonHelper.UploadImage(savePath);
+                        if (success)
                         {
                         {
-                            var savePath = AppContext.BaseDirectory + "wwwroot" + ServerUrl;
-                            if (!Directory.Exists(Path.GetDirectoryName(savePath)))
-                            {
-                                Directory.CreateDirectory(Path.GetDirectoryName(savePath));
-                            }
-                            using (var ms = new MemoryStream())
-                            {
-                                stream.CopyTo(ms);
-                                File.WriteAllBytes(savePath, ms.GetBuffer());
-                            }
+                            BackgroundJob.Enqueue(() => File.Delete(savePath));
+                            ServerUrl = url;
                         }
                         }
                         State = "SUCCESS";
                         State = "SUCCESS";
                     }
                     }

+ 32 - 46
src/Masuit.MyBlogs.Core/Extensions/UEditor/UploadHandler.cs

@@ -1,4 +1,5 @@
 using Common;
 using Common;
+using Hangfire;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Http;
 using System;
 using System;
 using System.IO;
 using System.IO;
@@ -25,66 +26,51 @@ namespace Masuit.MyBlogs.Core.Extensions.UEditor
 
 
         public override string Process()
         public override string Process()
         {
         {
-            byte[] uploadFileBytes;
-            string uploadFileName;
+            var file = Request.Form.Files[UploadConfig.UploadFieldName];
+            var uploadFileName = file.FileName;
 
 
-            if (UploadConfig.Base64)
+            if (!CheckFileType(uploadFileName))
             {
             {
-                uploadFileName = UploadConfig.Base64Filename;
-                uploadFileBytes = Convert.FromBase64String(Request.Query[UploadConfig.UploadFieldName]);
+                Result.State = UploadState.TypeNotAllow;
+                return WriteResult();
             }
             }
-            else
+            if (!CheckFileSize(file.Length))
             {
             {
-                var file = Request.Form.Files[UploadConfig.UploadFieldName];
-                uploadFileName = file.FileName;
-
-                if (!CheckFileType(uploadFileName))
-                {
-                    Result.State = UploadState.TypeNotAllow;
-                    return WriteResult();
-                }
-                if (!CheckFileSize(file.Length))
-                {
-                    Result.State = UploadState.SizeLimitExceed;
-                    return WriteResult();
-                }
-
-                uploadFileBytes = new byte[file.Length];
-                try
-                {
-                    file.OpenReadStream().Read(uploadFileBytes, 0, (int)file.Length);
-                }
-                catch (Exception)
-                {
-                    Result.State = UploadState.NetworkError;
-                    return WriteResult();
-                }
+                Result.State = UploadState.SizeLimitExceed;
+                return WriteResult();
             }
             }
 
 
+            var uploadFileBytes = new byte[file.Length];
+            try
+            {
+                file.OpenReadStream().Read(uploadFileBytes, 0, (int)file.Length);
+            }
+            catch (Exception)
+            {
+                Result.State = UploadState.NetworkError;
+                return WriteResult();
+            }
             Result.OriginFileName = uploadFileName;
             Result.OriginFileName = uploadFileName;
-
             var savePath = PathFormatter.Format(uploadFileName, UploadConfig.PathFormat);
             var savePath = PathFormatter.Format(uploadFileName, UploadConfig.PathFormat);
             var localPath = AppContext.BaseDirectory + "wwwroot" + savePath;
             var localPath = AppContext.BaseDirectory + "wwwroot" + savePath;
             try
             try
             {
             {
                 if (UploadConfig.AllowExtensions.Contains(Path.GetExtension(uploadFileName)))
                 if (UploadConfig.AllowExtensions.Contains(Path.GetExtension(uploadFileName)))
                 {
                 {
-                    using (MemoryStream ms = new MemoryStream(uploadFileBytes))
+                    if (!Directory.Exists(Path.GetDirectoryName(localPath)))
+                    {
+                        Directory.CreateDirectory(Path.GetDirectoryName(localPath));
+                    }
+                    File.WriteAllBytes(localPath, file.OpenReadStream().ToByteArray());
+                    var (url, success) = CommonHelper.UploadImage(localPath);
+                    if (success)
+                    {
+                        BackgroundJob.Enqueue(() => File.Delete(localPath));
+                        Result.Url = url;
+                    }
+                    else
                     {
                     {
-                        var (url, success) = CommonHelper.UploadImage(ms, Path.GetExtension(uploadFileName));
-                        if (success)
-                        {
-                            Result.Url = url;
-                        }
-                        else
-                        {
-                            if (!Directory.Exists(Path.GetDirectoryName(localPath)))
-                            {
-                                Directory.CreateDirectory(Path.GetDirectoryName(localPath));
-                            }
-                            File.WriteAllBytes(localPath, uploadFileBytes);
-                            Result.Url = savePath;
-                        }
+                        Result.Url = savePath;
                     }
                     }
                 }
                 }
                 else
                 else

+ 6 - 8
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.csproj

@@ -67,23 +67,21 @@
     <PackageReference Include="AutoMapper" Version="8.0.0" />
     <PackageReference Include="AutoMapper" Version="8.0.0" />
     <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="1.2.0" />
     <PackageReference Include="CacheManager.Microsoft.Extensions.Caching.Memory" Version="1.2.0" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="1.2.0" />
     <PackageReference Include="CacheManager.Serialization.Json" Version="1.2.0" />
-    <PackageReference Include="Caching.CSRedis" Version="3.0.41" />
-    <PackageReference Include="CSRedisCore" Version="3.0.42" />
+    <PackageReference Include="CSRedisCore" Version="3.0.45" />
     <PackageReference Include="Dapper" Version="1.60.1" />
     <PackageReference Include="Dapper" Version="1.60.1" />
     <PackageReference Include="EFSecondLevelCache.Core" Version="1.7.1" />
     <PackageReference Include="EFSecondLevelCache.Core" Version="1.7.1" />
-    <PackageReference Include="Hangfire" Version="1.6.22" />
+    <PackageReference Include="Hangfire" Version="1.6.23" />
     <PackageReference Include="Hangfire.Autofac" Version="2.3.1" />
     <PackageReference Include="Hangfire.Autofac" Version="2.3.1" />
     <PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.0" />
     <PackageReference Include="Hangfire.Redis.StackExchange" Version="1.8.0" />
     <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
     <PackageReference Include="htmldiff.net-core" Version="1.3.6" />
     <PackageReference Include="Microsoft.AspNetCore.App" />
     <PackageReference Include="Microsoft.AspNetCore.App" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.2" />
-    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.2" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.3" />
+    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
     <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
     <PackageReference Include="PanGu.HighLight" Version="1.0.0" />
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
     <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
-    <PackageReference Include="Quartz" Version="3.0.7" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
-    <PackageReference Include="WilderMinds.RssSyndication" Version="1.4.0" />
-    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.1.54" />
+    <PackageReference Include="WilderMinds.RssSyndication" Version="1.5.0" />
+    <PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="2.1.56" />
     <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.18" />
     <PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.18" />
     <PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />
     <PackageReference Include="Z.ExtensionMethods" Version="2.1.1" />
   </ItemGroup>
   </ItemGroup>

+ 13 - 26
src/Masuit.MyBlogs.Core/Masuit.MyBlogs.Core.xml

@@ -87,33 +87,33 @@
             <param name="content">内容</param>
             <param name="content">内容</param>
             <param name="tos">收件人</param>
             <param name="tos">收件人</param>
         </member>
         </member>
-        <member name="M:Common.CommonHelper.UploadImage(System.IO.Stream,System.String)">
+        <member name="M:Common.CommonHelper.UploadImage(System.String)">
             <summary>
             <summary>
             上传图片到新浪图床
             上传图片到新浪图床
             </summary>
             </summary>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Common.CommonHelper.UploadPeople(System.IO.Stream,System.String)">
+        <member name="M:Common.CommonHelper.UploadPeople(System.String)">
             <summary>
             <summary>
             上传图片到人民网图床
             上传图片到人民网图床
             </summary>
             </summary>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Common.CommonHelper.UploadImageFallback(System.IO.Stream,System.String)">
+        <member name="M:Common.CommonHelper.UploadSmmsImage(System.String)">
             <summary>
             <summary>
             上传图片到sm图床
             上传图片到sm图床
             </summary>
             </summary>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Common.CommonHelper.UploadImageFallback2(System.IO.Stream,System.String)">
+        <member name="M:Common.CommonHelper.UploadImageFallback(System.String)">
             <summary>
             <summary>
-            上传图片到新浪图床
+            上传图片到upload.cc图床
             </summary>
             </summary>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Common.CommonHelper.UploadImageFallback3(System.IO.Stream,System.String)">
+        <member name="M:Common.CommonHelper.UploadImageFallback2(System.String)">
             <summary>
             <summary>
-            上传图片到新浪图床
+            上传图片到upload.otar.im图床
             </summary>
             </summary>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
@@ -628,17 +628,17 @@
             <param name="content"></param>
             <param name="content"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Handle(Masuit.MyBlogs.Core.Models.ViewModel.FileRequest)">
+        <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Upload(System.String)">
             <summary>
             <summary>
-            操作文件
+            上传文件
             </summary>
             </summary>
-            <param name="req"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Upload(System.String)">
+        <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Handle(Masuit.MyBlogs.Core.Models.ViewModel.FileRequest)">
             <summary>
             <summary>
-            上传文件
+            操作文件
             </summary>
             </summary>
+            <param name="req"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
         <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Handle(System.String,System.String[],System.String)">
         <member name="M:Masuit.MyBlogs.Core.Controllers.FileController.Handle(System.String,System.String[],System.String)">
@@ -1979,19 +1979,6 @@
             <param name="addr"></param>
             <param name="addr"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.ToolsController.Cron">
-            <summary>
-            corn表达式生成
-            </summary>
-            <returns></returns>
-        </member>
-        <member name="M:Masuit.MyBlogs.Core.Controllers.ToolsController.Cron(System.String)">
-            <summary>
-            corn表达式
-            </summary>
-            <param name="cron"></param>
-            <returns></returns>
-        </member>
         <member name="T:Masuit.MyBlogs.Core.Controllers.UploadController">
         <member name="T:Masuit.MyBlogs.Core.Controllers.UploadController">
             <summary>
             <summary>
             文件上传
             文件上传
@@ -2274,7 +2261,7 @@
             从Redis取Session
             从Redis取Session
             </summary>
             </summary>
             <typeparam name="T"></typeparam>
             <typeparam name="T"></typeparam>
-            <param name="_"></param>
+            <param name="session"></param>
             <param name="key">键</param>
             <param name="key">键</param>
             <param name="expire">过期时间,默认20分钟</param>
             <param name="expire">过期时间,默认20分钟</param>
             <returns></returns> 
             <returns></returns> 

+ 2 - 9
src/Masuit.MyBlogs.Core/Startup.cs

@@ -10,13 +10,10 @@ using JiebaNet.Segmenter;
 using Masuit.LuceneEFCore.SearchEngine;
 using Masuit.LuceneEFCore.SearchEngine;
 using Masuit.LuceneEFCore.SearchEngine.Extensions;
 using Masuit.LuceneEFCore.SearchEngine.Extensions;
 using Masuit.MyBlogs.Core.Configs;
 using Masuit.MyBlogs.Core.Configs;
-using Masuit.MyBlogs.Core.Controllers;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Extensions.Hangfire;
 using Masuit.MyBlogs.Core.Hubs;
 using Masuit.MyBlogs.Core.Hubs;
 using Masuit.MyBlogs.Core.Infrastructure;
 using Masuit.MyBlogs.Core.Infrastructure;
-using Masuit.MyBlogs.Core.Infrastructure.Repository;
-using Masuit.MyBlogs.Core.Infrastructure.Services;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.DTO;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.MyBlogs.Core.Models.ViewModel;
 using Masuit.Tools.AspNetCore.Mime;
 using Masuit.Tools.AspNetCore.Mime;
@@ -31,8 +28,6 @@ using Microsoft.AspNetCore.Rewrite;
 using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.AspNetCore.WebSockets;
 using Microsoft.AspNetCore.WebSockets;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Caching.Distributed;
-using Microsoft.Extensions.Caching.Redis;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.WebEncoders;
 using Microsoft.Extensions.WebEncoders;
@@ -45,6 +40,7 @@ using System.Data;
 using System.Data.SqlClient;
 using System.Data.SqlClient;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using System.Reflection;
 using System.Text.Encodings.Web;
 using System.Text.Encodings.Web;
 using System.Text.Unicode;
 using System.Text.Unicode;
 using SameSiteMode = Microsoft.AspNetCore.Http.SameSiteMode;
 using SameSiteMode = Microsoft.AspNetCore.Http.SameSiteMode;
@@ -124,7 +120,6 @@ namespace Masuit.MyBlogs.Core
 
 
             services.AddSevenZipCompressor().AddResumeFileResult().AddSearchEngine<DataContext>(new LuceneIndexerOptions() { Path = "lucene" });// 配置7z和断点续传和Redis和Lucene搜索引擎
             services.AddSevenZipCompressor().AddResumeFileResult().AddSearchEngine<DataContext>(new LuceneIndexerOptions() { Path = "lucene" });// 配置7z和断点续传和Redis和Lucene搜索引擎
             RedisHelper.Initialization(new CSRedisClient(AppConfig.Redis));
             RedisHelper.Initialization(new CSRedisClient(AppConfig.Redis));
-            services.AddSingleton<IDistributedCache>(new CSRedisCache(RedisHelper.Instance));
 
 
             //配置EF二级缓存
             //配置EF二级缓存
             services.AddEFSecondLevelCache();
             services.AddEFSecondLevelCache();
@@ -153,9 +148,7 @@ namespace Masuit.MyBlogs.Core
 
 
             ContainerBuilder builder = new ContainerBuilder();
             ContainerBuilder builder = new ContainerBuilder();
             builder.Populate(services);
             builder.Populate(services);
-            builder.RegisterAssemblyTypes(typeof(BaseRepository<>).Assembly).AsImplementedInterfaces().Where(t => t.Name.EndsWith("Repository")).PropertiesAutowired().AsSelf().InstancePerDependency();
-            builder.RegisterAssemblyTypes(typeof(BaseService<>).Assembly).AsImplementedInterfaces().Where(t => t.Name.EndsWith("Service")).PropertiesAutowired().AsSelf().InstancePerDependency();
-            builder.RegisterAssemblyTypes(typeof(BaseController).Assembly).AsImplementedInterfaces().Where(t => t.Name.EndsWith("Controller")).PropertiesAutowired().AsSelf().InstancePerDependency(); //注册控制器为属性注入
+            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces().Where(t => t.Name.EndsWith("Repository") || t.Name.EndsWith("Service") || t.Name.EndsWith("Controller")).PropertiesAutowired().AsSelf().InstancePerDependency(); //注册控制器为属性注入
             builder.RegisterType<BackgroundJobClient>().SingleInstance(); //指定生命周期为单例
             builder.RegisterType<BackgroundJobClient>().SingleInstance(); //指定生命周期为单例
             builder.RegisterType<HangfireBackJob>().As<IHangfireBackJob>().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerDependency();
             builder.RegisterType<HangfireBackJob>().As<IHangfireBackJob>().PropertiesAutowired(PropertyWiringOptions.PreserveSetValues).InstancePerDependency();
             AutofacContainer = new AutofacServiceProvider(builder.Build());
             AutofacContainer = new AutofacServiceProvider(builder.Build());

+ 0 - 773
src/Masuit.MyBlogs.Core/Views/Tools/Cron.cshtml

@@ -1,773 +0,0 @@
-@{
-    ViewBag.Title = "Cron表达式生成器";
-    Layout = "~/Views/Shared/_Layout.cshtml";
-}
-<style type="text/css">
-    .imp {
-        padding-left: 25px;
-    }
-
-    .col {
-        text-align: center;
-        background-color: transparent !important;
-    }
-
-    .textbox-text {
-        width: 60px !important;
-        height: 34px;
-        padding: 6px 12px;
-        font-size: 14px;
-        line-height: 1.42857143;
-        color: #555;
-        background-image: none;
-        background-color: transparent;
-        border: 1px solid #ccc;
-        border-radius: 4px;
-        -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-        box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-        -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-        -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
-        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
-    }
-
-        .textbox-text:focus {
-            border-color: #66afe9;
-            outline: 0;
-            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
-            box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102,175,233,.6);
-        }
-</style>
-<script src="~/Scripts/cron.js"></script>
-<div class="container">
-    <ol class="cd-breadcrumb triangle">
-        <li>@Html.ActionLink("首页", "Index", "Home")</li>
-        <li class="current">
-            <em>@ViewBag.Title</em>
-        </li>
-    </ol>
-    <ul class="list-group">
-        <li class="list-group-item">
-            <p class="size24">
-                如果你觉得这个工具有用,请 @Html.ActionLink("点击这里", "Donate", "Misc") 支持一下博主!
-            </p>
-        </li>
-    </ul>
-    <div role="tabpanel">
-        <!-- Nav tabs -->
-        <ul class="nav nav-tabs" role="tablist">
-            <li role="presentation" class="active">
-                <a href="#sec" aria-controls="home" role="tab" data-toggle="tab">秒</a>
-            </li>
-            <li role="presentation">
-                <a href="#min" aria-controls="tab" role="tab" data-toggle="tab">分钟</a>
-            </li>
-            <li role="presentation">
-                <a href="#hour" aria-controls="tab" role="tab" data-toggle="tab">小时</a>
-            </li>
-            <li role="presentation">
-                <a href="#day" aria-controls="tab" role="tab" data-toggle="tab">日</a>
-            </li>
-            <li role="presentation">
-                <a href="#month" aria-controls="tab" role="tab" data-toggle="tab">月</a>
-            </li>
-            <li role="presentation">
-                <a href="#week" aria-controls="tab" role="tab" data-toggle="tab">周</a>
-            </li>
-            <li role="presentation">
-                <a href="#year" aria-controls="tab" role="tab" data-toggle="tab">年</a>
-            </li>
-        </ul>
-        <!-- Tab panes -->
-        <div class="tab-content">
-            <div role="tabpanel" class="tab-pane active" id="sec">
-                <div class="line">
-                    <input type="radio" name="second" onclick="everyTime(this)">
-                    每秒 允许的通配符[, - * /]
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="second" onclick="cycle(this)">
-                    周期从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:58" value="1"
-                           id="secondStart_0">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:59" value="2"
-                           id="secondEnd_0">
-                    秒
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="second" onclick="startOn(this)">
-                    从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:0,max:59" value="0"
-                           id="secondStart_1">
-                    秒开始,每
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:59" value="1"
-                           id="secondEnd_1">
-                    秒执行一次
-                </div>
-                <div class="line">
-                    <input type="radio" name="second" checked="checked" id="sencond_appoint">
-                    指定
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" checked="checked" value="0">00
-                    <input type="checkbox" value="1">01
-                    <input type="checkbox" value="2">02
-                    <input type="checkbox" value="3">03
-                    <input type="checkbox" value="4">04
-                    <input type="checkbox" value="5">05
-                    <input type="checkbox" value="6">06
-                    <input type="checkbox" value="7">07
-                    <input type="checkbox" value="8">08
-                    <input type="checkbox" value="9">09
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" value="10">10
-                    <input type="checkbox" value="11">11
-                    <input type="checkbox" value="12">12
-                    <input type="checkbox" value="13">13
-                    <input type="checkbox" value="14">14
-                    <input type="checkbox" value="15">15
-                    <input type="checkbox" value="16">16
-                    <input type="checkbox" value="17">17
-                    <input type="checkbox" value="18">18
-                    <input type="checkbox" value="19">19
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" value="20">20
-                    <input type="checkbox" value="21">21
-                    <input type="checkbox" value="22">22
-                    <input type="checkbox" value="23">23
-                    <input type="checkbox" value="24">24
-                    <input type="checkbox" value="25">25
-                    <input type="checkbox" value="26">26
-                    <input type="checkbox" value="27">27
-                    <input type="checkbox" value="28">28
-                    <input type="checkbox" value="29">29
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" value="30">30
-                    <input type="checkbox" value="31">31
-                    <input type="checkbox" value="32">32
-                    <input type="checkbox" value="33">33
-                    <input type="checkbox" value="34">34
-                    <input type="checkbox" value="35">35
-                    <input type="checkbox" value="36">36
-                    <input type="checkbox" value="37">37
-                    <input type="checkbox" value="38">38
-                    <input type="checkbox" value="39">39
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" value="40">40
-                    <input type="checkbox" value="41">41
-                    <input type="checkbox" value="42">42
-                    <input type="checkbox" value="43">43
-                    <input type="checkbox" value="44">44
-                    <input type="checkbox" value="45">45
-                    <input type="checkbox" value="46">46
-                    <input type="checkbox" value="47">47
-                    <input type="checkbox" value="48">48
-                    <input type="checkbox" value="49">49
-                </div>
-                <div class="imp secondList">
-                    <input type="checkbox" value="50">50
-                    <input type="checkbox" value="51">51
-                    <input type="checkbox" value="52">52
-                    <input type="checkbox" value="53">53
-                    <input type="checkbox" value="54">54
-                    <input type="checkbox" value="55">55
-                    <input type="checkbox" value="56">56
-                    <input type="checkbox" value="57">57
-                    <input type="checkbox" value="58">58
-                    <input type="checkbox" value="59">59
-                </div>
-            </div>
-            <div role="tabpanel" class="tab-pane" id="min">
-                <div class="line">
-                    <input type="radio" checked="checked" name="min" onclick="everyTime(this)">
-                    分钟 允许的通配符[, - * /]
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="min" onclick="cycle(this)">
-                    周期从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:58" value="1"
-                           id="minStart_0">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:59" value="2"
-                           id="minEnd_0">
-                    分钟
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="min" onclick="startOn(this)">
-                    从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:0,max:59" value="0"
-                           id="minStart_1">
-                    分钟开始,每
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:59" value="1"
-                           id="minEnd_1">
-                    分钟执行一次
-                </div>
-                <div class="line">
-                    <input type="radio" name="min" id="min_appoint">
-                    指定
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="0">00
-                    <input type="checkbox" value="1">01
-                    <input type="checkbox" value="2">02
-                    <input type="checkbox" value="3">03
-                    <input type="checkbox" value="4">04
-                    <input type="checkbox" value="5">05
-                    <input type="checkbox" value="6">06
-                    <input type="checkbox" value="7">07
-                    <input type="checkbox" value="8">08
-                    <input type="checkbox" value="9">09
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="10">10
-                    <input type="checkbox" value="11">11
-                    <input type="checkbox" value="12">12
-                    <input type="checkbox" value="13">13
-                    <input type="checkbox" value="14">14
-                    <input type="checkbox" value="15">15
-                    <input type="checkbox" value="16">16
-                    <input type="checkbox" value="17">17
-                    <input type="checkbox" value="18">18
-                    <input type="checkbox" value="19">19
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="20">20
-                    <input type="checkbox" value="21">21
-                    <input type="checkbox" value="22">22
-                    <input type="checkbox" value="23">23
-                    <input type="checkbox" value="24">24
-                    <input type="checkbox" value="25">25
-                    <input type="checkbox" value="26">26
-                    <input type="checkbox" value="27">27
-                    <input type="checkbox" value="28">28
-                    <input type="checkbox" value="29">29
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="30">30
-                    <input type="checkbox" value="31">31
-                    <input type="checkbox" value="32">32
-                    <input type="checkbox" value="33">33
-                    <input type="checkbox" value="34">34
-                    <input type="checkbox" value="35">35
-                    <input type="checkbox" value="36">36
-                    <input type="checkbox" value="37">37
-                    <input type="checkbox" value="38">38
-                    <input type="checkbox" value="39">39
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="40">40
-                    <input type="checkbox" value="41">41
-                    <input type="checkbox" value="42">42
-                    <input type="checkbox" value="43">43
-                    <input type="checkbox" value="44">44
-                    <input type="checkbox" value="45">45
-                    <input type="checkbox" value="46">46
-                    <input type="checkbox" value="47">47
-                    <input type="checkbox" value="48">48
-                    <input type="checkbox" value="49">49
-                </div>
-                <div class="imp minList">
-                    <input type="checkbox" value="50">50
-                    <input type="checkbox" value="51">51
-                    <input type="checkbox" value="52">52
-                    <input type="checkbox" value="53">53
-                    <input type="checkbox" value="54">54
-                    <input type="checkbox" value="55">55
-                    <input type="checkbox" value="56">56
-                    <input type="checkbox" value="57">57
-                    <input type="checkbox" value="58">58
-                    <input type="checkbox" value="59">59
-                </div>
-            </div>
-            <div id="hour" class="tab-pane">
-                <div class="line">
-                    <input type="radio" checked="checked" name="hour" onclick="everyTime(this)">
-                    小时 允许的通配符[, - * /]
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="hour" onclick="cycle(this)">
-                    周期从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:0,max:23" value="0"
-                           id="hourStart_0">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:23" value="2"
-                           id="hourEnd_1">
-                    小时
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="hour" onclick="startOn(this)">
-                    从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:0,max:23" value="0"
-                           id="hourStart_1">
-                    小时开始,每
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:23" value="1"
-                           id="hourEnd_1">
-                    小时执行一次
-                </div>
-                <div class="line">
-                    <input type="radio" name="hour" id="hour_appoint">
-                    指定
-                </div>
-                <div class="imp hourList">
-                    AM:
-                    <input type="checkbox" value="0">00
-                    <input type="checkbox" value="1">01
-                    <input type="checkbox" value="2">02
-                    <input type="checkbox" value="3">03
-                    <input type="checkbox" value="4">04
-                    <input type="checkbox" value="5">05
-                    <input type="checkbox" value="6">06
-                    <input type="checkbox" value="7">07
-                    <input type="checkbox" value="8">08
-                    <input type="checkbox" value="9">09
-                    <input type="checkbox" value="10">10
-                    <input type="checkbox" value="11">11
-                </div>
-                <div class="imp hourList">
-                    PM:
-                    <input type="checkbox" value="12">12
-                    <input type="checkbox" value="13">13
-                    <input type="checkbox" value="14">14
-                    <input type="checkbox" value="15">15
-                    <input type="checkbox" value="16">16
-                    <input type="checkbox" value="17">17
-                    <input type="checkbox" value="18">18
-                    <input type="checkbox" value="19">19
-                    <input type="checkbox" value="20">20
-                    <input type="checkbox" value="21">21
-                    <input type="checkbox" value="22">22
-                    <input type="checkbox" value="23">23
-                </div>
-            </div>
-            <div id="day" class="tab-pane">
-                <div class="line">
-                    <input type="radio" checked="checked" name="day" onclick="everyTime(this)">
-                    日 允许的通配符[, - * / L W]
-                </div>
-                <div class="line">
-                    <input type="radio" name="day" onclick="unAppoint(this)">
-                    不指定
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="day" onclick="cycle(this)">
-                    周期从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:31" value="1"
-                           id="dayStart_0">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:31" value="2"
-                           id="dayEnd_0">
-                    日
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="day" onclick="startOn(this)">
-                    从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:31" value="1"
-                           id="dayStart_1">
-                    日开始,每
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:31" value="1"
-                           id="dayEnd_1">
-                    天执行一次
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="day" onclick="workDay(this)">
-                    每月
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:31" value="1"
-                           id="dayStart_2">
-                    号最近的那个工作日
-                </div>
-                <div class="line">
-                    <input type="radio" name="day" onclick="lastDay(this)">
-                    本月最后一天
-                </div>
-                <div class="line">
-                    <input type="radio" name="day" id="day_appoint">
-                    指定
-                </div>
-                <div class="imp dayList">
-                    <input type="checkbox" value="1">1
-                    <input type="checkbox" value="2">2
-                    <input type="checkbox" value="3">3
-                    <input type="checkbox" value="4">4
-                    <input type="checkbox" value="5">5
-                    <input type="checkbox" value="6">6
-                    <input type="checkbox" value="7">7
-                    <input type="checkbox" value="8">8
-                    <input type="checkbox" value="9">9
-                    <input type="checkbox" value="10">10
-                    <input type="checkbox" value="11">11
-                    <input type="checkbox" value="12">12
-                    <input type="checkbox" value="13">13
-                    <input type="checkbox" value="14">14
-                    <input type="checkbox" value="15">15
-                    <input type="checkbox" value="16">16
-                </div>
-                <div class="imp dayList">
-                    <input type="checkbox" value="17">17
-                    <input type="checkbox" value="18">18
-                    <input type="checkbox" value="19">19
-                    <input type="checkbox" value="20">20
-                    <input type="checkbox" value="21">21
-                    <input type="checkbox" value="22">22
-                    <input type="checkbox" value="23">23
-                    <input type="checkbox" value="24">24
-                    <input type="checkbox" value="25">25
-                    <input type="checkbox" value="26">26
-                    <input type="checkbox" value="27">27
-                    <input type="checkbox" value="28">28
-                    <input type="checkbox" value="29">29
-                    <input type="checkbox" value="30">30
-                    <input type="checkbox" value="31">31
-                </div>
-            </div>
-            <div id="month" class="tab-pane">
-                <div class="line">
-                    <input type="radio" checked="checked" name="mouth" onclick="everyTime(this)">
-                    月 允许的通配符[, - * /]
-                </div>
-                <div class="line">
-                    <input type="radio" name="mouth" onclick="unAppoint(this)">
-                    不指定
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="mouth" onclick="cycle(this)">
-                    周期从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:12" value="1"
-                           id="mouthStart_0">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:12" value="2"
-                           id="mouthEnd_0">
-                    月
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="mouth" onclick="startOn(this)">
-                    从
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:12" value="1"
-                           id="mouthStart_1">
-                    日开始,每
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:12" value="1"
-                           id="mouthEnd_1">
-                    月执行一次
-                </div>
-                <div class="line">
-                    <input type="radio" name="mouth" id="mouth_appoint">
-                    指定
-                </div>
-                <div class="imp mouthList">
-                    <input type="checkbox" value="1">1
-                    <input type="checkbox" value="2">2
-                    <input type="checkbox" value="3">3
-                    <input type="checkbox" value="4">4
-                    <input type="checkbox" value="5">5
-                    <input type="checkbox" value="6">6
-                    <input type="checkbox" value="7">7
-                    <input type="checkbox" value="8">8
-                    <input type="checkbox" value="9">9
-                    <input type="checkbox" value="10">10
-                    <input type="checkbox" value="11">11
-                    <input type="checkbox" value="12">12
-                </div>
-            </div>
-            <div id="week" class="tab-pane">
-                <div class="line">
-                    <input type="radio" checked="checked" name="week" onclick="everyTime(this)">
-                    周 允许的通配符[, - * / L #]
-                </div>
-                <div class="line">
-                    <input type="radio" name="week" onclick="unAppoint(this)">
-                    不指定
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="week" onclick="startOn(this)">
-                    周期 从星期<input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:7"
-                                 id="weekStart_0" value="1">
-                    -
-                    <input class="numberspinner form-control" style="width: 60px;" data-options="min:2,max:7" value="2"
-                           id="weekEnd_0">
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="week" onclick="weekOfDay(this)">
-                    第<input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:4" value="1"
-                            id="weekStart_1">
-                    周 的星期<input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:7"
-                                id="weekEnd_1" value="1">
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="week" onclick="lastWeek(this)">
-                    本月最后一个星期<input class="numberspinner form-control" style="width: 60px;" data-options="min:1,max:7"
-                                   id="weekStart_2" value="1">
-                </div>
-                <div class="line">
-                    <input type="radio" name="week" id="week_appoint">
-                    指定
-                </div>
-                <div class="imp weekList">
-                    <input type="checkbox" value="1">1
-                    <input type="checkbox" value="2">2
-                    <input type="checkbox" value="3">3
-                    <input type="checkbox" value="4">4
-                    <input type="checkbox" value="5">5
-                    <input type="checkbox" value="6">6
-                    <input type="checkbox" value="7">7
-                </div>
-            </div>
-            <div id="year" class="tab-pane">
-                <div class="line">
-                    <input type="radio" checked="checked" name="year" onclick="unAppoint(this)">
-                    不指定 允许的通配符[, - * /] 非必填
-                </div>
-                <div class="line">
-                    <input type="radio" name="year" onclick="everyTime(this)">
-                    每年
-                </div>
-                <div class="line form-inline">
-                    <input type="radio" name="year" onclick="cycle(this)">周期 从
-                    <input class="numberspinner form-control" style="width: 90px;" data-options="min:2013,max:3000"
-                           id="yearStart_0" value="2013">
-                    -
-                    <input class="numberspinner form-control" style="width: 90px;" data-options="min:2014,max:3000"
-                           id="yearEnd_0" value="2014">
-                </div>
-            </div>
-        </div>
-    </div>
-
-    <div class="panel panel-info">
-        <div class="panel-heading">
-            <h3 class="panel-title size20">表达式</h3>
-        </div>
-        <div class="panel-body">
-            <table class="table table-responsive table-condensed margin-clear">
-                <tbody style="text-align: center">
-                    <tr>
-                        <td></td>
-                        <td>
-                            秒
-                        </td>
-                        <td>
-                            分钟
-                        </td>
-                        <td>
-                            小时
-                        </td>
-                        <td>
-                            日
-                        </td>
-                        <td>
-                            月
-                        </td>
-                        <td>
-                            星期
-                        </td>
-                        <td>
-                            年
-                        </td>
-                    </tr>
-                    <tr>
-                        <td style="width: 100px;">
-                            表达式字段:
-                        </td>
-                        <td>
-                            <input type="text" name="v_second" class="col form-control" value="*" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_min" class="col form-control" value="*" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_hour" class="col form-control" value="*" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_day" class="col form-control" value="*" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_mouth" class="col form-control" value="*" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_week" class="col form-control" value="?" readonly="readonly" />
-                        </td>
-                        <td>
-                            <input type="text" name="v_year" class="col form-control" readonly="readonly" />
-                        </td>
-                    </tr>
-                </tbody>
-            </table>
-            <div class="input-group">
-                <span class="input-group-addon">
-                    Cron 表达式:
-                </span>
-                <input type="text" name="cron" class="form-control" value="* * * * * ?" id="cron" />
-                <span class="input-group-btn">
-                    <input class="btn btn-success" type="button" value="反解析到UI " id="btnFan" onclick="btnFan()" />
-                </span>
-            </div>
-            <div class="page-header margin-clear">
-                <h2 class="size24 inline">
-                    最近5次运行时间:
-                </h2>
-            </div>
-            <div id="runTime">
-
-            </div>
-        </div>
-    </div>
-</div>
-<script src="~/Scripts/jquery.easyui.min.js"></script>
-<script type="text/javascript">
-    function btnFan() {
-        //获取参数中表达式的值
-        var txt = $("#cron").val();
-        if (txt) {
-            var regs = txt.split(' ');
-            $("input[name=v_second]").val(regs[0]);
-            $("input[name=v_min]").val(regs[1]);
-            $("input[name=v_hour]").val(regs[2]);
-            $("input[name=v_day]").val(regs[3]);
-            $("input[name=v_mouth]").val(regs[4]);
-            $("input[name=v_week]").val(regs[5]);
-
-            initObj(regs[0], "second");
-            initObj(regs[1], "min");
-            initObj(regs[2], "hour");
-            initDay(regs[3]);
-            initMonth(regs[4]);
-            initWeek(regs[5]);
-
-            if (regs.length > 6) {
-                $("input[name=v_year]").val(regs[6]);
-                initYear(regs[6]);
-            }
-        }
-    }
-
-    function initObj(strVal, strid) {
-        var ary = null;
-        var objRadio = $("input[name='" + strid + "'");
-        if (strVal == "*") {
-            objRadio.eq(0).attr("checked", "checked");
-        } else if (strVal.split('-').length > 1) {
-            ary = strVal.split('-');
-            objRadio.eq(1).attr("checked", "checked");
-            $("#" + strid + "Start_0").numberspinner('setValue', ary[0]);
-            $("#" + strid + "End_0").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('/').length > 1) {
-            ary = strVal.split('/');
-            objRadio.eq(2).attr("checked", "checked");
-            $("#" + strid + "Start_1").numberspinner('setValue', ary[0]);
-            $("#" + strid + "End_1").numberspinner('setValue', ary[1]);
-        } else {
-            objRadio.eq(3).attr("checked", "checked");
-            if (strVal != "?") {
-                ary = strVal.split(",");
-                for (var i = 0; i < ary.length; i++) {
-                    $("." + strid + "List input[value='" + ary[i] + "']").attr("checked", "checked");
-                }
-            }
-        }
-    }
-
-    function initDay(strVal) {
-        var ary = null;
-        var objRadio = $("input[name='day'");
-        if (strVal == "*") {
-            objRadio.eq(0).attr("checked", "checked");
-        } else if (strVal == "?") {
-            objRadio.eq(1).attr("checked", "checked");
-        } else if (strVal.split('-').length > 1) {
-            ary = strVal.split('-');
-            objRadio.eq(2).attr("checked", "checked");
-            $("#dayStart_0").numberspinner('setValue', ary[0]);
-            $("#dayEnd_0").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('/').length > 1) {
-            ary = strVal.split('/');
-            objRadio.eq(3).attr("checked", "checked");
-            $("#dayStart_1").numberspinner('setValue', ary[0]);
-            $("#dayEnd_1").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('W').length > 1) {
-            ary = strVal.split('W');
-            objRadio.eq(4).attr("checked", "checked");
-            $("#dayStart_2").numberspinner('setValue', ary[0]);
-        } else if (strVal == "L") {
-            objRadio.eq(5).attr("checked", "checked");
-        } else {
-            objRadio.eq(6).attr("checked", "checked");
-            ary = strVal.split(",");
-            for (var i = 0; i < ary.length; i++) {
-                $(".dayList input[value='" + ary[i] + "']").attr("checked", "checked");
-            }
-        }
-    }
-
-    function initMonth(strVal) {
-        var ary = null;
-        var objRadio = $("input[name='mouth'");
-        if (strVal == "*") {
-            objRadio.eq(0).attr("checked", "checked");
-        } else if (strVal == "?") {
-            objRadio.eq(1).attr("checked", "checked");
-        } else if (strVal.split('-').length > 1) {
-            ary = strVal.split('-');
-            objRadio.eq(2).attr("checked", "checked");
-            $("#mouthStart_0").numberspinner('setValue', ary[0]);
-            $("#mouthEnd_0").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('/').length > 1) {
-            ary = strVal.split('/');
-            objRadio.eq(3).attr("checked", "checked");
-            $("#mouthStart_1").numberspinner('setValue', ary[0]);
-            $("#mouthEnd_1").numberspinner('setValue', ary[1]);
-
-        } else {
-            objRadio.eq(4).attr("checked", "checked");
-
-            ary = strVal.split(",");
-            for (var i = 0; i < ary.length; i++) {
-                $(".mouthList input[value='" + ary[i] + "']").attr("checked", "checked");
-            }
-        }
-    }
-
-    function initWeek(strVal) {
-        var ary = null;
-        var objRadio = $("input[name='week'");
-        if (strVal == "*") {
-            objRadio.eq(0).attr("checked", "checked");
-        } else if (strVal == "?") {
-            objRadio.eq(1).attr("checked", "checked");
-        } else if (strVal.split('/').length > 1) {
-            ary = strVal.split('/');
-            objRadio.eq(2).attr("checked", "checked");
-            $("#weekStart_0").numberspinner('setValue', ary[0]);
-            $("#weekEnd_0").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('-').length > 1) {
-            ary = strVal.split('-');
-            objRadio.eq(3).attr("checked", "checked");
-            $("#weekStart_1").numberspinner('setValue', ary[0]);
-            $("#weekEnd_1").numberspinner('setValue', ary[1]);
-        } else if (strVal.split('L').length > 1) {
-            ary = strVal.split('L');
-            objRadio.eq(4).attr("checked", "checked");
-            $("#weekStart_2").numberspinner('setValue', ary[0]);
-        } else {
-            objRadio.eq(5).attr("checked", "checked");
-            ary = strVal.split(",");
-            for (var i = 0; i < ary.length; i++) {
-                $(".weekList input[value='" + ary[i] + "']").attr("checked", "checked");
-            }
-        }
-    }
-
-    function initYear(strVal) {
-        var ary = null;
-        var objRadio = $("input[name='year'");
-        if (strVal == "*") {
-            objRadio.eq(1).attr("checked", "checked");
-        } else if (strVal.split('-').length > 1) {
-            ary = strVal.split('-');
-            objRadio.eq(2).attr("checked", "checked");
-            $("#yearStart_0").numberspinner('setValue', ary[0]);
-            $("#yearEnd_0").numberspinner('setValue', ary[1]);
-        }
-    }
-</script>

+ 12 - 16
src/Masuit.MyBlogs.Core/wwwroot/ng-views/filemanager/js/controllers/main.js

@@ -347,22 +347,18 @@
         $scope.getUrl = function(_item) {
         $scope.getUrl = function(_item) {
             return $scope.apiMiddleware.getUrl(_item);
             return $scope.apiMiddleware.getUrl(_item);
         };
         };
-			$scope.changeroot= function(path) {
-				$http.post('/system/save', {
-					sets: JSON.stringify([{
-						Name: "PathRoot",
-						Value:path
-					}])
-				}, {
-					'Content-Type': 'application/x-www-form-urlencoded'
-				}).then(function(res) {
-					if (res.data.Success) {
-						$scope.fileNavigator.goTo(-1);
-					}
-				}, function() {
-
-				});
-			}
+		$scope.changeroot= function(path) {
+			$http.post('/system/save?sets='+JSON.stringify([{
+				Name: "PathRoot",
+				Value:path
+			}])).then(function(res) {
+				if (res.data.Success) {
+					$scope.fileNavigator.goTo(-1);
+				}
+			}, function() {
+
+			});
+		}
         var validateSamePath = function(item) {
         var validateSamePath = function(item) {
             var selectedPath = $rootScope.selectedModalPath.join('');
             var selectedPath = $rootScope.selectedModalPath.join('');
             var selectedItemsPath = item && item.model.path.join('');
             var selectedItemsPath = item && item.model.path.join('');

+ 4 - 4
src/Masuit.MyBlogs.Core/wwwroot/ng-views/filemanager/templates/main-table.html

@@ -19,12 +19,12 @@
                     <span class="sortorder" ng-show="predicate[1] === 'model.date'" ng-class="{reverse:reverse}"></span>
                     <span class="sortorder" ng-show="predicate[1] === 'model.date'" ng-class="{reverse:reverse}"></span>
                 </a>
                 </a>
             </th>
             </th>
-            <th class="hidden-sm hidden-xs" ng-hide="config.hidePermissions">
+            <!--<th class="hidden-sm hidden-xs" ng-hide="config.hidePermissions">
                 <a href="" ng-click="order('model.permissions')">
                 <a href="" ng-click="order('model.permissions')">
                     {{"permissions" | translate}}
                     {{"permissions" | translate}}
                     <span class="sortorder" ng-show="predicate[1] === 'model.permissions'" ng-class="{reverse:reverse}"></span>
                     <span class="sortorder" ng-show="predicate[1] === 'model.permissions'" ng-class="{reverse:reverse}"></span>
                 </a>
                 </a>
-            </th>
+            </th>-->
         </tr>
         </tr>
     </thead>
     </thead>
     <tbody class="file-item">
     <tbody class="file-item">
@@ -59,9 +59,9 @@
             <td class="hidden-sm hidden-xs" ng-hide="config.hideDate">
             <td class="hidden-sm hidden-xs" ng-hide="config.hideDate">
                 {{item.model.date | formatDate }}
                 {{item.model.date | formatDate }}
             </td>
             </td>
-            <td class="hidden-sm hidden-xs" ng-hide="config.hidePermissions">
+            <!--<td class="hidden-sm hidden-xs" ng-hide="config.hidePermissions">
                 {{item.model.perms.toCode(item.model.type === 'dir'?'d':'-')}}
                 {{item.model.perms.toCode(item.model.type === 'dir'?'d':'-')}}
-            </td>
+            </td>-->
         </tr>
         </tr>
     </tbody>
     </tbody>
 </table>
 </table>