完成注册加一个确认密码,程序异常的显示

This commit is contained in:
summer853300975 2016-11-11 21:44:41 +08:00
parent 15c0bf6154
commit 0bfee14844
15 changed files with 296 additions and 12 deletions

View File

@ -183,6 +183,7 @@
<Content Include="Content\js\messages_zh.min.js" />
<Content Include="Scripts\Content.js" />
<Content Include="Scripts\Dicts.js" />
<Content Include="Scripts\Exceptions.js" />
<Content Include="Scripts\Groups.js" />
<Content Include="Scripts\icon.js" />
<Content Include="Scripts\lock.js" />
@ -224,6 +225,7 @@
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\DictsController.cs" />
<Compile Include="Controllers\ExceptionsController.cs" />
<Compile Include="Controllers\GroupsController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\LogsController.cs" />
@ -237,6 +239,7 @@
<Compile Include="Models\ContentModel.cs" />
<Compile Include="Models\LockModel.cs" />
<Compile Include="Models\QueryDictOption.cs" />
<Compile Include="Models\QueryExceptionOption.cs" />
<Compile Include="Models\QueryGroupOption.cs" />
<Compile Include="Models\QueryLogOption.cs" />
<Compile Include="Models\QueryMenuOption.cs" />
@ -289,6 +292,7 @@
<Content Include="Views\Admin\Notifications.cshtml" />
<Content Include="Views\Admin\Infos.cshtml" />
<Content Include="Views\Admin\Excep.cshtml" />
<Content Include="Views\Admin\Exceptions.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>

View File

@ -121,5 +121,14 @@ namespace Bootstrap.Admin.Controllers
}
return View();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Exceptions()
{
var v = new NavigatorBarModel("~/Admin/Exceptions");
return View(v);
}
}
}

View File

@ -0,0 +1,20 @@
using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
public class ExceptionsController : ApiController
{
/// <summary>
/// 显示所有异常
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public QueryData<Exceptions> Get([FromUri]QueryExceptionOption value)
{
return value.RetrieveData();
}
}
}

View File

@ -0,0 +1,67 @@
using Bootstrap.DataAccess;
using Longbow.Web.Mvc;
using System;
using System.Globalization;
using System.Linq;
namespace Bootstrap.Admin.Models
{
public class QueryExceptionOption : PaginationOption
{
/// <summary>
///
/// </summary>
public string OperateTimeStart { get; set; }
/// <summary>
///
/// </summary>
public string OperateTimeEnd { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public QueryData<Exceptions> RetrieveData()
{
var data = ExceptionHelper.RetrieveExceptions();
if (!string.IsNullOrEmpty(OperateTimeStart))
{
DateTime opTimeStart = StringToDateTime(OperateTimeStart);
if (opTimeStart != null)
data = data.Where(t => IsSmallThen(opTimeStart, t.LogTime));
}
if (!string.IsNullOrEmpty(OperateTimeEnd))
{
DateTime opTimeEnd = StringToDateTime(OperateTimeEnd);
if (opTimeEnd != null)
data = data.Where(t => IsSmallThen(t.LogTime, opTimeEnd));
}
var ret = new QueryData<Exceptions>();
ret.total = data.Count();
data = Order == "asc" ? data.OrderBy(t => t.AppDomainName) : data.OrderByDescending(t => t.AppDomainName);
ret.rows = data.Skip(Offset).Take(Limit);
return ret;
}
private static DateTime StringToDateTime(string dt_str)
{
DateTime dt;
DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
dtFormat.ShortDatePattern = "yyyy-MM-dd HH:mm:ss";
dt = Convert.ToDateTime(dt_str, dtFormat);
return dt;
}
/// <summary>
/// 比较两个DateTime
/// (去掉了毫秒)
/// </summary>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <returns></returns>
private static bool IsSmallThen(DateTime d1, DateTime d2)
{
return new DateTime(d1.Year, d1.Month, d1.Day, d1.Hour, d1.Minute, d1.Second) <=
new DateTime(d2.Year, d2.Month, d2.Day, d2.Hour, d2.Minute, d2.Second);
}
}
}

View File

@ -0,0 +1,42 @@
$(function () {
var bsa = new BootstrapAdmin({
url: '../api/Exceptions',
dataEntity: new DataEntity({
map: {
ID: "ID",
AppDomainName: "appDomainName",
ErrorPage: "errorPage",
UserID: "userId",
UserIp: "userIp",
Message: "message",
StackTrace: "stackTrace",
LogTime:"logTime"
}
}),
})
$('table').smartTable({
url: '../api/Exceptions', //请求后台的URL*
sortName: 'AppDomainName',
queryParams: function (params) { return $.extend(params, { OperateTimeStart: $("#txt_operate_start").val(), OperateTimeEnd: $("#txt_operate_end").val() }); }, //传递参数(*
columns: [{ checkbox: true },
{ title: "APP域名", field: "AppDomainName", sortable: true },
{ title: "错误页", field: "ErrorPage", sortable: false },
{
title: "用户名", field: "UserID", sortable: false,
},
{ title: "用户IP", field: "UserIp", sortable: false },
{ title: "备注", field: "Message", sortable: false },
{ title: "栈记录", field: "StackTrace", sortable: false },
{ title: "异常捕获时间", field: "LogTime", sortable: false,
formatter: function (value, row, index) {
return value.substring(0, 19).replace("T", " ");
}
}
]
});
$('input[type="datetime"]').parent().datetimepicker({
locale: "zh-cn",
format: "YYYY-MM-DD"
});
});

View File

@ -12,6 +12,11 @@
required: true,
maxlength: 50
},
assurePassword: {
required: true,
maxlength: 50,
equalTo:"#password"
},
description: {
required: true,
maxlength: 500
@ -21,12 +26,12 @@
$('#btnAccount').click(function () {
var valid = $('form').valid();
if (valid) {
$('.setup-main').hide();
$('.steps li').toggleClass('current');
$('#loginID').text($('#userName').val());
$('#loginName').text($('#displayName').val());
$('#loginDesc').text($('#description').val());
$('.setup-confirm').show();
$('.setup-main').hide();
$('.steps li').toggleClass('current');
$('#loginID').text($('#userName').val());
$('#loginName').text($('#displayName').val());
$('#loginDesc').text($('#description').val());
$('.setup-confirm').show();
}
});
});

View File

@ -0,0 +1,62 @@
@model NavigatorBarModel
@{
ViewBag.Title = "程序异常";
Layout = "~/Views/Shared/_Admin.cshtml";
}
@section css {
<link href="~/Content/css/bootstrap-table.css" rel="stylesheet" />
<link href="~/Content/css/bootstrap-datetimepicker.css" rel="stylesheet" />
}
@section Javascript {
<script src="~/content/js/bootstrap-table.js"></script>
<script src="~/content/js/bootstrap-table-zh-CN.js"></script>
<script src="~/Content/js/moment-with-locales.js"></script>
<script src="~/Content/js/bootstrap-datetimepicker.js"></script>
<script src="~/content/js/longbow.dataentity.js"></script>
<script src="~/scripts/Exceptions.js"></script>
}
@section header {
@Html.Partial("Header", Model)
}
@section navigator {
@Html.Partial("Navigator", Model)
}
<div class="panel panel-default">
<div class="panel-heading">查询条件</div>
<div class="panel-body">
<form class="form-inline" role="form">
<div class="row">
<div class="form-group col-xs-12 col-sm-6 col-md-5 col-lg-5">
<label class="control-label" for="txt_operate_start">起始时间</label>
<div class="input-group date">
<input type="datetime" class="form-control" id="txt_operate_start" />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar" aria-hidden="true"></i></button>
</span>
</div>
</div>
<div class="form-group col-xs-12 col-sm-6 col-md-5 col-lg-5">
<label class="control-label" for="txt_operate_end">终止时间</label>
<div class="input-group input-append date form_datetime">
<input type="datetime" class="form-control" id="txt_operate_start" />
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-calendar" aria-hidden="true"></i></button>
</span>
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-2 col-lg-2">
<label class="sr-only"></label>
<button type="button" id="btn_query" class="btn btn-primary form-control"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button>
</div>
</div>
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
查询结果
</div>
<div class="panel-body">
<table></table>
</div>
</div>

View File

@ -8,6 +8,7 @@
@section javascript {
<script src="~/content/js/jquery.validate.js"></script>
<script src="~/content/js/messages_zh.js"></script>
<script src="~/content/js/sweetalert.js"></script>
<script src="~/Scripts/register.js"></script>
}
<div class="container">
@ -43,10 +44,15 @@
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="password" id="password" name="password" class="form-control" value="" placeholder="密码" />
</div>
<label for="description">申请理由</label>
<label for="assurePassword">确认密码</label>
<div class="input-group">
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="text" id="description" name="description" class="form-control" value="" placeholder="申请理由" />
<input type="password" id="assurePassword" name="assurePassword" class="form-control" value="" placeholder="确认密码" />
</div>
<label for="description">申请理由:</label>
<div class="input-group">
<span class="glyphicon glyphicon-certificate input-group-addon"></span>
<textarea id="description" name="description" class="form-control" placeholder="申请理由" ></textarea>
</div>
<button id="btnAccount" class="btn btn-primary" type="button">继续</button>
</div> <!-- /.setup-form-container -->

View File

@ -44,8 +44,10 @@
<add key="DictHelper-RetrieveDictsWebSettings" interval="600" desc="网站配置数据缓存"/>
<add key="NotificationHelper-RetrieveNotifications" interval="600" desc="通知管理数据缓存"/>
<add key="UserHelper-RetrieveNewUsers" interval="300" desc="新用户数据缓存" />
<add key="ExceptionHelper-RetrieveExceptions" interval="600" desc="程序异常数据缓存"/>
</cacheManager>
<cacheManagerList>
<add key="bd" url="http://localhost:53233/CacheList.axd?cacheKey={0}" desc="系统缓存模块"/>
</cacheManagerList>

View File

@ -61,6 +61,7 @@
<Compile Include="Dict.cs" />
<Compile Include="DictHelper.cs" />
<Compile Include="ExceptionHelper.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="Group.cs" />
<Compile Include="GroupHelper.cs" />
<Compile Include="Log.cs" />

View File

@ -17,7 +17,7 @@ namespace Bootstrap.DataAccess
/// <param name="dictIds"></param>
/// <param name="logIds"></param>
/// <param name="notifyIds"></param>
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null, string notifyIds = null)
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null, string notifyIds = null, string exceptionIds = null)
{
var cacheKeys = new List<string>();
if (roleIds != null)
@ -84,6 +84,12 @@ namespace Bootstrap.DataAccess
CacheManager.Clear(key => key.Contains(NotificationHelper.RetrieveNotificationsDataKey));
cacheKeys.Clear();
}
if (exceptionIds != null)
{
// final cleanup
CacheManager.Clear(key => key.Contains(ExceptionHelper.RetrieveExceptionsDataKey));
cacheKeys.Clear();
}
}
}
}

View File

@ -1,5 +1,9 @@
using Longbow.Data;
using Longbow.Caching;
using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Data.Common;
@ -8,8 +12,10 @@ namespace Bootstrap.DataAccess
{
public static class ExceptionHelper
{
public static void Log(Exception ex, NameValueCollection additionalInfo)
internal const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions";
public static bool Log(Exception ex, NameValueCollection additionalInfo)
{
bool ret = false;
try
{
var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @Message, @StackTrace, GetDate())";
@ -23,11 +29,49 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
ret = true;
}
catch
{
throw new Exception("Excetion Log Error");
}
return ret;
}
/// <summary>
/// 查询所有异常
/// </summary>
/// <param name="tId"></param>
/// <returns></returns>
public static IEnumerable<Exceptions> RetrieveExceptions()
{
return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveExceptionsDataKey), key =>
{
string sql = "select * from Exceptions";
List<Exceptions> Exceptions = new List<Exceptions>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
{
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{
while (reader.Read())
{
Exceptions.Add(new Exceptions()
{
ID = (int)reader[0],
AppDomainName = (string)reader[1],
ErrorPage = (string)reader[2],
UserID = (string)reader[3],
UserIp = (string)reader[4],
Message = (string)reader[5],
StackTrace = (string)reader[6],
LogTime = (DateTime)reader[7],
});
}
}
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return Exceptions;
}, CacheSection.RetrieveDescByKey(RetrieveExceptionsDataKey));
}
}
}

View File

@ -0,0 +1,15 @@
using System;
namespace Bootstrap.DataAccess
{
public class Exceptions
{
public int ID { get; set; }
public string AppDomainName { get; set; }
public string ErrorPage { get; set; }
public string UserID { get; set; }
public string UserIp { get; set; }
public string Message { get; set; }
public string StackTrace { get; set; }
public DateTime LogTime { get; set; }
}
}

View File

@ -3,7 +3,7 @@ GO
DELETE From Users where ID = 1
SET IDENTITY_INSERT [dbo].[Users] ON
insert into Users (ID, UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime, [Description]) values (1, 'Admin', 'Es7WVgNsJuELwWK8daCqufUBknCsSC0IYDphQZAiGOo=', 'W5vpBEOYRGHkQXatN0t+ECM/U8cHDuEgrq56+zZBk4J481xH', 'Administrator', GetDate(), GetDate(), N'系统默认创建')
insert into Users (ID, UserName, Password, PassSalt, DisplayName, RegisterTime, ApprovedTime,ApprovedBy, [Description]) values (1, 'Admin', 'Es7WVgNsJuELwWK8daCqufUBknCsSC0IYDphQZAiGOo=', 'W5vpBEOYRGHkQXatN0t+ECM/U8cHDuEgrq56+zZBk4J481xH', 'Administrator', GetDate(), GetDate(),'argo', N'系统默认创建')
SET IDENTITY_INSERT [dbo].[Users] OFF
DELETE From Dicts where ID < 12
@ -37,6 +37,7 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (12, 0, N'锁定屏幕', 110, N'fa fa-lock', N'~/Home/Lock', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (13, 0, N'锁定屏幕', 10, N'fa fa-lock', N'~/Home/Lock', N'1')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 13, N'锁定屏幕', 10, N'fa fa-lock', N'~/Home/Lock', N'1')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (15, 0, N'程序异常', 10, N'fa fa-bell-o', N'~/Admin/Exceptions', N'0')
SET IDENTITY_INSERT [dbo].[Navigations] OFF
DELETE FROM GROUPS WHERE ID = 1