11using System ;
22using System . Collections . Generic ;
33using System . ComponentModel ;
4- using System . Linq ;
54using System . Runtime . Serialization ;
65using System . Web . Script . Serialization ;
76using System . Xml . Serialization ;
87using NewLife ;
98using NewLife . Data ;
10- using NewLife . Log ;
119using XCode ;
1210using XCode . Cache ;
1311using XCode . Configuration ;
1412using XCode . DataAccessLayer ;
1513
1614namespace XCode . Membership666 ;
1715
18- /// <summary>日志</summary>
16+ /// <summary>日志。应用系统审计日志,记录用户的各种操作,禁止修改和删除 </summary>
1917[ Serializable ]
2018[ DataObject ]
21- [ Description ( "日志" ) ]
19+ [ Description ( "日志。应用系统审计日志,记录用户的各种操作,禁止修改和删除 " ) ]
2220[ BindIndex ( "IX_Log_Action_Category_ID" , false , "Action,Category,ID" ) ]
2321[ BindIndex ( "IX_Log_Category_LinkID_ID" , false , "Category,LinkID,ID" ) ]
2422[ BindIndex ( "IX_Log_CreateUserID_ID" , false , "CreateUserID,ID" ) ]
25- [ BindTable ( "Log" , Description = "日志" , ConnName = "Log" , DbType = DatabaseType . None ) ]
23+ [ BindTable ( "Log" , Description = "日志。应用系统审计日志,记录用户的各种操作,禁止修改和删除 " , ConnName = "Log" , DbType = DatabaseType . None ) ]
2624public partial class Log : ILog , IEntity < ILog >
2725{
2826 #region 属性
2927 private Int64 _ID ;
30- /// <summary>编号。按小时分表,按月分库 </summary>
28+ /// <summary>编号</summary>
3129 [ DisplayName ( "编号" ) ]
32- [ Description ( "编号。按小时分表,按月分库 " ) ]
30+ [ Description ( "编号" ) ]
3331 [ DataObjectField ( true , false , false , 0 ) ]
34- [ BindColumn ( "ID" , "编号。按小时分表,按月分库 " , "" , DataScale = "timeShard:yyMMddHH:yyyyMM " ) ]
32+ [ BindColumn ( "ID" , "编号" , "" , DataScale = "time " ) ]
3533 public Int64 ID { get => _ID ; set { if ( OnPropertyChanging ( "ID" , value ) ) { _ID = value ; OnPropertyChanged ( "ID" ) ; } } }
3634
3735 private String ? _Category ;
@@ -42,21 +40,21 @@ public partial class Log : ILog, IEntity<ILog>
4240 [ BindColumn ( "Category" , "类别" , "" ) ]
4341 public String ? Category { get => _Category ; set { if ( OnPropertyChanging ( "Category" , value ) ) { _Category = value ; OnPropertyChanged ( "Category" ) ; } } }
4442
45- private String ? _Action ;
43+ private String _Action = null ! ;
4644 /// <summary>操作</summary>
4745 [ DisplayName ( "操作" ) ]
4846 [ Description ( "操作" ) ]
49- [ DataObjectField ( false , false , true , 50 ) ]
47+ [ DataObjectField ( false , false , false , 50 ) ]
5048 [ BindColumn ( "Action" , "操作" , "" ) ]
51- public String ? Action { get => _Action ; set { if ( OnPropertyChanging ( "Action" , value ) ) { _Action = value ; OnPropertyChanged ( "Action" ) ; } } }
49+ public String Action { get => _Action ; set { if ( OnPropertyChanging ( "Action" , value ) ) { _Action = value ; OnPropertyChanged ( "Action" ) ; } } }
5250
53- private Int32 _LinkID ;
51+ private Int64 _LinkID ;
5452 /// <summary>链接</summary>
5553 [ DisplayName ( "链接" ) ]
5654 [ Description ( "链接" ) ]
5755 [ DataObjectField ( false , false , false , 0 ) ]
5856 [ BindColumn ( "LinkID" , "链接" , "" ) ]
59- public Int32 LinkID { get => _LinkID ; set { if ( OnPropertyChanging ( "LinkID" , value ) ) { _LinkID = value ; OnPropertyChanged ( "LinkID" ) ; } } }
57+ public Int64 LinkID { get => _LinkID ; set { if ( OnPropertyChanging ( "LinkID" , value ) ) { _LinkID = value ; OnPropertyChanged ( "LinkID" ) ; } } }
6058
6159 private Boolean _Success ;
6260 /// <summary>成功</summary>
@@ -151,7 +149,7 @@ public partial class Log : ILog, IEntity<ILog>
151149 [ DisplayName ( "创建用户" ) ]
152150 [ Description ( "创建用户" ) ]
153151 [ DataObjectField ( false , false , false , 0 ) ]
154- [ BindColumn ( "CreateUserID" , "创建用户" , "" ) ]
152+ [ BindColumn ( "CreateUserID" , "创建用户" , "" , ShowIn = "Auto,-Search" ) ]
155153 public Int32 CreateUserID { get => _CreateUserID ; set { if ( OnPropertyChanging ( "CreateUserID" , value ) ) { _CreateUserID = value ; OnPropertyChanged ( "CreateUserID" ) ; } } }
156154
157155 private String ? _CreateIP ;
@@ -241,7 +239,7 @@ public override Object? this[String name]
241239 case "ID" : _ID = value . ToLong ( ) ; break ;
242240 case "Category" : _Category = Convert . ToString ( value ) ; break ;
243241 case "Action" : _Action = Convert . ToString ( value ) ; break ;
244- case "LinkID" : _LinkID = value . ToInt ( ) ; break ;
242+ case "LinkID" : _LinkID = value . ToLong ( ) ; break ;
245243 case "Success" : _Success = value . ToBoolean ( ) ; break ;
246244 case "UserName" : _UserName = Convert . ToString ( value ) ; break ;
247245 case "Ex1" : _Ex1 = value . ToInt ( ) ; break ;
@@ -289,9 +287,9 @@ public override Object? this[String name]
289287 /// <param name="action">操作</param>
290288 /// <param name="category">类别</param>
291289 /// <returns>实体列表</returns>
292- public static IList < Log > FindAllByActionAndCategory ( String ? action , String ? category )
290+ public static IList < Log > FindAllByActionAndCategory ( String action , String ? category )
293291 {
294- if ( action == null ) return [ ] ;
292+ if ( action . IsNullOrEmpty ( ) ) return [ ] ;
295293 if ( category == null ) return [ ] ;
296294
297295 return FindAll ( _ . Action == action & _ . Category == category ) ;
@@ -301,7 +299,7 @@ public static IList<Log> FindAllByActionAndCategory(String? action, String? cate
301299 /// <param name="category">类别</param>
302300 /// <param name="linkId">链接</param>
303301 /// <returns>实体列表</returns>
304- public static IList < Log > FindAllByCategoryAndLinkID ( String ? category , Int32 linkId )
302+ public static IList < Log > FindAllByCategoryAndLinkID ( String ? category , Int64 linkId )
305303 {
306304 if ( category == null ) return [ ] ;
307305 if ( linkId < 0 ) return [ ] ;
@@ -325,21 +323,19 @@ public static IList<Log> FindAllByCreateUserID(Int32 createUserId)
325323 /// <param name="category">类别</param>
326324 /// <param name="action">操作</param>
327325 /// <param name="linkId">链接</param>
328- /// <param name="createUserId">创建用户</param>
329326 /// <param name="success">成功</param>
330327 /// <param name="start">编号开始</param>
331328 /// <param name="end">编号结束</param>
332329 /// <param name="key">关键字</param>
333330 /// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
334331 /// <returns>实体列表</returns>
335- public static IList < Log > Search ( String ? category , String ? action , Int32 linkId , Int32 createUserId , Boolean ? success , DateTime start , DateTime end , String key , PageParameter page )
332+ public static IList < Log > Search ( String ? category , String action , Int64 linkId , Boolean ? success , DateTime start , DateTime end , String key , PageParameter page )
336333 {
337334 var exp = new WhereExpression ( ) ;
338335
339336 if ( ! category . IsNullOrEmpty ( ) ) exp &= _ . Category == category ;
340337 if ( ! action . IsNullOrEmpty ( ) ) exp &= _ . Action == action ;
341338 if ( linkId >= 0 ) exp &= _ . LinkID == linkId ;
342- if ( createUserId >= 0 ) exp &= _ . CreateUserID == createUserId ;
343339 if ( success != null ) exp &= _ . Success == success ;
344340 exp &= _ . ID . Between ( start , end , Meta . Factory . Snow ) ;
345341 if ( ! key . IsNullOrEmpty ( ) ) exp &= SearchWhereByKeys ( key ) ;
@@ -358,34 +354,13 @@ public static Int32 DeleteWith(DateTime start, DateTime end, Int32 maximumRows =
358354 {
359355 return Delete ( _ . ID . Between ( start , end , Meta . Factory . Snow ) , maximumRows ) ;
360356 }
361-
362- /// <summary>删除指定时间段内的数据表</summary>
363- /// <param name="start">开始时间</param>
364- /// <param name="end">结束时间</param>
365- /// <returns>清理行数</returns>
366- public static Int32 DropWith ( DateTime start , DateTime end )
367- {
368- return Meta . AutoShard ( start , end , session =>
369- {
370- try
371- {
372- return session . Execute ( $ "Drop Table { session . FormatedTableName } ") ;
373- }
374- catch ( Exception ex )
375- {
376- XTrace . WriteException ( ex ) ;
377- return 0 ;
378- }
379- }
380- ) . Sum ( ) ;
381- }
382357 #endregion
383358
384359 #region 字段名
385360 /// <summary>取得日志字段信息的快捷方式</summary>
386361 public partial class _
387362 {
388- /// <summary>编号。按小时分表,按月分库 </summary>
363+ /// <summary>编号</summary>
389364 public static readonly Field ID = FindByName ( "ID" ) ;
390365
391366 /// <summary>类别</summary>
@@ -445,7 +420,7 @@ public partial class _
445420 /// <summary>取得日志字段名称的快捷方式</summary>
446421 public partial class __
447422 {
448- /// <summary>编号。按小时分表,按月分库 </summary>
423+ /// <summary>编号</summary>
449424 public const String ID = "ID" ;
450425
451426 /// <summary>类别</summary>
0 commit comments