Skip to content

Commit

Permalink
CodeWatch
Browse files Browse the repository at this point in the history
T4
  • Loading branch information
magicodes committed Dec 23, 2014
1 parent 6172c91 commit ec43d37
Show file tree
Hide file tree
Showing 31 changed files with 903 additions and 24 deletions.
10 changes: 9 additions & 1 deletion Magicodes.Core.Web/Utility/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ public static string UrlEncode(string s)
{
return HttpUtility.UrlEncode(s);
}

/// <summary>
///
/// </summary>
/// <param name="stylePlusSrc"></param>
/// <returns></returns>
//public static string RenderPlusStyles(string stylePlusSrc)
//{

//}
#endregion

#region Cookie
Expand Down
7 changes: 6 additions & 1 deletion Magicodes.Core/Magicodes.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Spatial.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="MiniProfiler">
<HintPath>..\packages\MiniProfiler.3.1.1.140\lib\net40\MiniProfiler.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -144,7 +147,9 @@
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
10 changes: 9 additions & 1 deletion Magicodes.Core/Performance/Watch/CodeWatch.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Magicodes.Web.Interfaces;
using Magicodes.Web.Interfaces.Strategy.Logger;
using StackExchange.Profiling;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -27,7 +28,11 @@ public LoggerStrategyBase Log
string _currrentTag;
int? _currentWarnThreshold;
readonly Action<string, LoggerStrategyBase, int?, long> _currentThresholdAction;

/// <summary>
/// 集成MiniProfiler,以监控站点性能
/// </summary>
private static MiniProfiler profiler = MiniProfiler.Current;
IDisposable profilerStep;
public CodeWatch(string tag)
{
Init(tag);
Expand All @@ -36,6 +41,7 @@ public CodeWatch(string tag)
private void Init(string tag)
{
_currrentTag = tag;
profilerStep = profiler.Step(_currrentTag);
_watch.Start();
}
/// <summary>
Expand Down Expand Up @@ -78,6 +84,8 @@ protected virtual void Dispose(bool disposing)
{
if (!disposing) return;
_watch.Stop();
//释放计数器
if (profilerStep != null) profilerStep.Dispose();
if (_currentWarnThreshold == null || _watch.ElapsedMilliseconds < _currentWarnThreshold.Value) return;

Log.LogFormat(LoggerLevels.PerformanceWarn, "\t{0}:Execution time({1})ms.已超过阀值({2})ms.", _currrentTag, _watch.ElapsedMilliseconds, _currentWarnThreshold);
Expand Down
1 change: 1 addition & 0 deletions Magicodes.Core/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<package id="Microsoft.OData.Core" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.9.0" targetFramework="net45" />
<package id="MiniProfiler" version="3.1.1.140" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
<package id="NLog" version="3.1.0.0" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// filename :AdminSiteConfigInfoController
// description :后台站点配置 WebAPI
//
// created by 雪雁 at 2014/12/23 18:03:14
// created by 雪雁 at 2014/12/23 21:42:27
// http://www.magicodes.net
//
//======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// filename :MailConfigInfoController
// description :邮箱信息配置 WebAPI
//
// created by 雪雁 at 2014/10/29 00:21:37
// created by 雪雁 at 2014/12/23 21:42:27
// http://www.magicodes.net
//
//======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// filename :SiteConfigInfoController
// description :站点信息配置 WebAPI
//
// created by 雪雁 at 2014/10/29 00:21:37
// created by 雪雁 at 2014/12/23 21:42:27
// http://www.magicodes.net
//
//======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// filename :SystemConfigInfoController
// description : WebAPI
//
// created by 雪雁 at 2014/10/29 00:21:37
// created by 雪雁 at 2014/12/23 21:42:27
// http://www.magicodes.net
//
//======================================================================
Expand Down
3 changes: 3 additions & 0 deletions Magicodes.Web.Interfaces/Magicodes.Web.Interfaces.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
<ItemGroup>
<None Include="ClassDiagram1.cd" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<span><i class="fa fa-star-o fa-fw"></i>收藏</span>
<span><i class="fa fa-share-square-o fa-fw"></i>分享</span>
</div>

<h3>@this.ViewContext.Controller.GetType().Assembly.FullName</h3>
<h3>@this.ViewContext.Controller.GetType().BaseType.Assembly.FullName</h3>
<h3>h3.文章一级标题</h3>
<h4>h4.文章二级标题</h4>
<h5>h5.文章三级标题</h5>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
<span><i class="fa fa-star-o fa-fw"></i>收藏</span>
<span><i class="fa fa-share-square-o fa-fw"></i>分享</span>
</div>

<h3>@this.ViewContext.Controller.GetType().Assembly.FullName</h3>
<h3>@this.ViewContext.Controller.GetType().BaseType.Assembly.FullName</h3>
<h3>h3.文章一级标题</h3>
<h4>h4.文章二级标题</h4>
<h5>h5.文章三级标题</h5>
Expand Down
Loading

0 comments on commit ec43d37

Please sign in to comment.