diff --git a/Src/Asp.NetCore2/DorisTest/LogEntity.cs b/Src/Asp.NetCore2/DorisTest/LogEntity.cs new file mode 100644 index 000000000..4ae3c03c0 --- /dev/null +++ b/Src/Asp.NetCore2/DorisTest/LogEntity.cs @@ -0,0 +1,94 @@ + using SqlSugar; +namespace DorisTest +{ + + /// + /// 日志记录表 + /// + [SugarTable("LogEntity111")] + public class LogEntity + { + /// + /// 主键 + /// + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } + + /// + /// 地址 + /// + [SugarColumn(IsNullable = true)] + public string? Url { get; set; } + + /// + /// 方法 + /// + [SugarColumn(IsNullable = true)] + public string? Method { get; set; } + + /// + /// 数据-请求体 + /// + [SugarColumn(IsNullable = true)] + public string? Data { get; set; } + + /// + /// 数据-返回(包括异常信息) + /// + [SugarColumn(IsNullable = true)] + public string? RsData { get; set; } + + /// + /// 是否成功 + /// + [SugarColumn(IsNullable = true)] + public bool? IsSuccess { get; set; } + + /// + /// Header + /// + [SugarColumn(IsNullable = true, IsJson = true )] + public Dictionary Header { get; set; } + + /// + /// Token + /// + [SugarColumn(IsNullable = true)] + public string? Token { get; set; } + + /// + /// 客户端ip + /// + [SugarColumn(IsNullable = true)] + public string ClientHost { get; set; } + + /// + /// 应用标识 + /// + [SugarColumn(IsNullable = true)] + public string? AppId { get; set; } + + /// + /// 应用的Ip + /// + [SugarColumn(IsNullable = true)] + public string? AppHost { get; set; } + + /// + /// 持续时长 + /// + [SugarColumn(IsNullable = true)] + public int? RunTime { get; set; } + + /// + /// 创建时间 + /// + public DateTime /*long*/ CreateTime { get; set; } + + public LogEntity() + { + CreateTime = DateTime.Now; + //CreateTime = DateTime.Now.ToFileTimeUtc(); + } + } +} \ No newline at end of file diff --git a/Src/Asp.NetCore2/DorisTest/Program.cs b/Src/Asp.NetCore2/DorisTest/Program.cs index 6ee6de9ab..e41e31ea0 100644 --- a/Src/Asp.NetCore2/DorisTest/Program.cs +++ b/Src/Asp.NetCore2/DorisTest/Program.cs @@ -1,4 +1,5 @@ -using SqlSugar; +using DorisTest; +using SqlSugar; using System; namespace OrmTest @@ -8,8 +9,26 @@ namespace OrmTest { static void Main(string[] args) { - var db = DbHelper.GetNewDb(); - + var db = DbHelper.GetNewDb(); + var xx= db.Ado.GetDataTable(@"SELECT + 0 as TableId, + TABLE_NAME as TableName, + column_name AS DbColumnName, + CASE WHEN COLUMN_TYPE NOT LIKE '(' THEN COLUMN_TYPE ELSE left(COLUMN_TYPE,LOCATE('(',COLUMN_TYPE)-1) END AS DataType, + CAST(SUBSTRING(COLUMN_TYPE,LOCATE('(',COLUMN_TYPE)+1,LOCATE(')',COLUMN_TYPE)-LOCATE('(',COLUMN_TYPE)-1) AS decimal(18,0) ) AS Length, + column_default AS `DefaultValue`, + column_comment AS `ColumnDescription`, + CASE WHEN COLUMN_KEY = 'PRI' + THEN true ELSE false END AS `IsPrimaryKey`, + CASE WHEN EXTRA='auto_increment' THEN true ELSE false END as IsIdentity, + CASE WHEN is_nullable = 'YES' + THEN true ELSE false END AS `IsNullable`, + numeric_scale as Scale, + numeric_scale as DecimalDigits, + LOCATE( 'unsigned',COLUMN_type ) >0 as IsUnsigned + FROM + Information_schema.columns where TABLE_NAME='LogEntity1' and TABLE_SCHEMA=(select database()) ORDER BY ordinal_position"); + db.CodeFirst.InitTables(); db.CodeFirst.InitTables(); db.Insertable(new Student11() { Id = 1, Age = 1, Name = "a" }) @@ -37,7 +56,7 @@ namespace OrmTest /// Database connection string /// 数据库连接字符串 /// - public readonly static string Connection = "data source=139.170.74.9;port=9030;database=test;user id=root;password=1q!1q!;pooling=true;charset=utf8;Pooling=false"; + public readonly static string Connection = "server=39.170.74.9;port=9030;Database=test;Uid=root;Pwd=1q!1q!;Pooling=false;"; /// /// Get a new SqlSugarClient instance with specific configurations @@ -61,6 +80,9 @@ namespace OrmTest { Console.WriteLine(UtilMethods.GetNativeSql(sql, para)); }; + it.Aop.OnError = ex => + { + }; }); return db; }