From 78092c1aa5874ec8433354844b9c93fcbd0cf5e9 Mon Sep 17 00:00:00 2001 From: kuaigoumanzhu <307788836@qq.com> Date: Sat, 27 Aug 2016 00:29:44 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8B=E8=BE=B9=E6=A1=86=E9=81=AE?= =?UTF-8?q?=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Infrastructure/Infrastructure.csproj | 8 ++++++++ Infrastructure/packages.config | 3 +-- OpenAuth.Mvc/Web.config | 2 +- OpenAuth.WebApi/Web.config | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/Infrastructure.csproj index 278fe132..7f2b60d8 100644 --- a/Infrastructure/Infrastructure.csproj +++ b/Infrastructure/Infrastructure.csproj @@ -59,6 +59,14 @@ True + + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll + True + + + ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll + True + diff --git a/Infrastructure/packages.config b/Infrastructure/packages.config index 51f427f2..6be7a119 100644 --- a/Infrastructure/packages.config +++ b/Infrastructure/packages.config @@ -3,7 +3,6 @@ - - + \ No newline at end of file diff --git a/OpenAuth.Mvc/Web.config b/OpenAuth.Mvc/Web.config index 8ae33c70..155883da 100644 --- a/OpenAuth.Mvc/Web.config +++ b/OpenAuth.Mvc/Web.config @@ -14,7 +14,7 @@ - + diff --git a/OpenAuth.WebApi/Web.config b/OpenAuth.WebApi/Web.config index b1a45900..1703f74c 100644 --- a/OpenAuth.WebApi/Web.config +++ b/OpenAuth.WebApi/Web.config @@ -10,7 +10,7 @@
- + From 35d76eb2b1f981047c3fe0d8f0476ffbe9b8804a Mon Sep 17 00:00:00 2001 From: kuaigoumanzhu <307788836@qq.com> Date: Sat, 27 Aug 2016 00:34:58 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BE=B9?= =?UTF-8?q?=E6=A1=86=E9=81=AE=E7=9B=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.Mvc/Content/BJUI/js/bjui-all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenAuth.Mvc/Content/BJUI/js/bjui-all.js b/OpenAuth.Mvc/Content/BJUI/js/bjui-all.js index 66c77eed..64eb4692 100644 --- a/OpenAuth.Mvc/Content/BJUI/js/bjui-all.js +++ b/OpenAuth.Mvc/Content/BJUI/js/bjui-all.js @@ -132,7 +132,7 @@ $('#bjui-container').height(iContentH) $('#bjui-navtab').width(iContentW) $('#bjui-leftside, #bjui-sidebar, #bjui-sidebar-s, #bjui-splitBar, #bjui-splitBarProxy').css({height:'100%'}) - $('#bjui-navtab .tabsPageContent').height(iContentH - navtabH) + $('#bjui-navtab .tabsPageContent').height(iContentH - navtabH - 1)//下边框遮盖问题 /* fixed pageFooter */ setTimeout(function() { From ece6a57d6ed64c36804e4e9b364b15ceb4072090 Mon Sep 17 00:00:00 2001 From: kuaigoumanzhu <307788836@qq.com> Date: Sat, 27 Aug 2016 00:36:59 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E5=A4=B1=E8=AF=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=95=B0=E6=8D=AE=E5=BA=93=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.Mvc/Web.config | 2 +- OpenAuth.WebApi/Web.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenAuth.Mvc/Web.config b/OpenAuth.Mvc/Web.config index 155883da..8ae33c70 100644 --- a/OpenAuth.Mvc/Web.config +++ b/OpenAuth.Mvc/Web.config @@ -14,7 +14,7 @@ - + diff --git a/OpenAuth.WebApi/Web.config b/OpenAuth.WebApi/Web.config index 1703f74c..b1a45900 100644 --- a/OpenAuth.WebApi/Web.config +++ b/OpenAuth.WebApi/Web.config @@ -10,7 +10,7 @@
- + From 981b595bccef54ea4264b69158d3717f22e0a5af Mon Sep 17 00:00:00 2001 From: kuaigoumanzhu <307788836@qq.com> Date: Sat, 27 Aug 2016 00:51:26 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=8A=A0=E5=85=A5MemoryCache=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Infrastructure/Cache/ICache.cs | 48 +++++++++++ Infrastructure/Cache/RuntimeMemoryCache.cs | 93 ++++++++++++++++++++++ Infrastructure/Infrastructure.csproj | 7 +- 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Infrastructure/Cache/ICache.cs create mode 100644 Infrastructure/Cache/RuntimeMemoryCache.cs diff --git a/Infrastructure/Cache/ICache.cs b/Infrastructure/Cache/ICache.cs new file mode 100644 index 00000000..7ade6edb --- /dev/null +++ b/Infrastructure/Cache/ICache.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Infrastructure.Cache +{ + public interface ICache + { + /// + /// 加入缓存项 + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + void Add(string key, object value, TimeSpan timeSpan); + /// + /// 加入依赖物理文件的缓存项 + /// + /// 缓存项标识 + /// 缓存项 + /// 依赖的文件全路径 + void AddWithFileDependency(string key, object value, string fullFileNameOfFileDependency); + /// + /// 获取缓存项 + /// + /// + /// + object Get(string cacheKey); + T Get(string cacheKey) where T : class; + void Remove(string cacheKey); + /// + /// 如果不存在缓存项则添加,否则更新(相对过期) + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + void Set(string key, object value, TimeSpan timeSpan); + /// + /// 设置绝对过期时间 + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + void SetAbsoluteExpiration(string key, object value, TimeSpan timeSpan); + } +} diff --git a/Infrastructure/Cache/RuntimeMemoryCache.cs b/Infrastructure/Cache/RuntimeMemoryCache.cs new file mode 100644 index 00000000..e067c237 --- /dev/null +++ b/Infrastructure/Cache/RuntimeMemoryCache.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Runtime.Caching; +namespace Infrastructure.Cache +{ + public class RuntimeMemoryCache : ICache + { + private readonly MemoryCache memoryCache = MemoryCache.Default; + /// + /// 加入缓存项(绝对过期时间) + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + public void Add(string key, object value, TimeSpan timeSpan) + { + if (!string.IsNullOrEmpty(key) && (value != null)) + { + CacheItemPolicy cip = new CacheItemPolicy() + { + AbsoluteExpiration = DateTime.Now.Add(timeSpan) + }; + this.memoryCache.Add(key, value, cip, null); + } + } + /// + /// 加入依赖物理文件的缓存项 + /// + /// 缓存项标识 + /// 缓存项 + /// 依赖的文件全路径 + public void AddWithFileDependency(string key, object value, string fullFileNameOfFileDependency) + { + if (!string.IsNullOrEmpty(key) && (value != null)) + { + CacheItemPolicy policy = new CacheItemPolicy + { + AbsoluteExpiration = DateTimeOffset.Now.AddMonths(1) + }; + policy.ChangeMonitors.Add(new HostFileChangeMonitor(new List { fullFileNameOfFileDependency })); + this.memoryCache.Add(key, value, policy, null); + } + } + + public object Get(string cacheKey) + { + return this.memoryCache[cacheKey]; + } + + public T Get(string cacheKey) where T : class + { + object obj = this.Get(cacheKey); + if (obj != null) + { + return (obj as T); + } + return default(T); + } + + public void Remove(string cacheKey) + { + this.memoryCache.Remove(cacheKey, null); + } + /// + /// 如果不存在缓存项则添加,否则更新(相对过期) + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + public void Set(string key, object value, TimeSpan timeSpan) + { + CacheItemPolicy cip = new CacheItemPolicy() + { + SlidingExpiration = timeSpan, + }; + this.memoryCache.Set(key, value, cip, null); + } + /// + /// 设置绝对过期时间 + /// + /// 缓存项标识 + /// 缓存项 + /// 缓存失效时间 + public void SetAbsoluteExpiration(string key, object value, TimeSpan timeSpan) + { + CacheItemPolicy cip = new CacheItemPolicy() + { + AbsoluteExpiration = DateTime.Now.Add(timeSpan), + }; + this.memoryCache.Set(key, value, cip, null); + } + } +} diff --git a/Infrastructure/Infrastructure.csproj b/Infrastructure/Infrastructure.csproj index 7f2b60d8..b7226120 100644 --- a/Infrastructure/Infrastructure.csproj +++ b/Infrastructure/Infrastructure.csproj @@ -58,6 +58,7 @@ ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll True + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll @@ -77,6 +78,8 @@ + + @@ -98,7 +101,9 @@ - + + +