diff --git a/OS.Common/ComModels/Enums/AppClientEnum.cs b/OS.Common/ComModels/Enums/AppClient.cs
similarity index 99%
rename from OS.Common/ComModels/Enums/AppClientEnum.cs
rename to OS.Common/ComModels/Enums/AppClient.cs
index 8e80e64..8d815c7 100644
--- a/OS.Common/ComModels/Enums/AppClientEnum.cs
+++ b/OS.Common/ComModels/Enums/AppClient.cs
@@ -11,8 +11,6 @@
///
Web=0,
-
-
///
/// IOS
///
diff --git a/OS.Common/ComModels/Enums/MobileCountry.cs b/OS.Common/ComModels/Enums/MobileCountry.cs
new file mode 100644
index 0000000..54ce411
--- /dev/null
+++ b/OS.Common/ComModels/Enums/MobileCountry.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel;
+
+namespace OS.Common.ComModels.Enums
+{
+ public enum MobileCountry
+ {
+ ///
+ /// 中国
+ ///
+ [Description("中国")]
+ China=86,
+
+ ///
+ /// 日本
+ ///
+ [Description("日本")]
+ Japan=81
+ }
+}
diff --git a/OS.Common/ComModels/ResultModel.cs b/OS.Common/ComModels/ResultModel.cs
index d5356b8..ae43b52 100644
--- a/OS.Common/ComModels/ResultModel.cs
+++ b/OS.Common/ComModels/ResultModel.cs
@@ -11,7 +11,7 @@ namespace OS.Common.ComModels
///
public ResultModel()
{
- Ret = 200;
+ Ret = ResultTypes.Success;
}
///
@@ -21,7 +21,7 @@ namespace OS.Common.ComModels
///
public ResultModel(int ret, string message = "")
{
- Ret = ret;
+ Ret = (ResultTypes)ret;
Message = message;
}
@@ -33,7 +33,7 @@ namespace OS.Common.ComModels
///
public ResultModel(ResultTypes ret, string message = "")
{
- this.Ret = (int) ret;
+ this.Ret = ret;
this.Message = message;
}
@@ -46,7 +46,7 @@ namespace OS.Common.ComModels
/// 5xx 服务器内部相关错误信息
/// 6xx 系统级定制错误信息,如升级维护等
///
- public int Ret { get; set; }
+ public ResultTypes Ret { get; set; }
///
/// 错误或者状态
@@ -68,12 +68,12 @@ namespace OS.Common.ComModels
}
- ///
+ ///
/// 构造函数
///
///
///
- public ResultIdModel(int ret=200, string message = ""):base(ret,message)
+ public ResultIdModel(int ret, string message = ""):base(ret,message)
{
}
@@ -83,7 +83,7 @@ namespace OS.Common.ComModels
///
///
///
- public ResultIdModel(ResultTypes ret = ResultTypes.Success, string message = "")
+ public ResultIdModel(ResultTypes ret, string message = "")
: base(ret, message)
{
}
@@ -93,4 +93,62 @@ namespace OS.Common.ComModels
///
public long Id { get; set; }
}
+
+
+
+ public class ResultModel : ResultModel
+ {
+ ///
+ /// 构造函数
+ ///
+ ///
+ public ResultModel(TType data)
+ : base(200, null)
+ {
+ Data = data;
+ }
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ ///
+ public ResultModel(int ret, string message = "")
+ : base(ret, message)
+ {
+ }
+
+ ///
+ /// 构造函数
+ ///
+ ///
+ ///
+ public ResultModel(ResultTypes ret, string message = "")
+ : base(ret, message)
+ {
+ }
+
+ ///
+ /// 返回指定类型的数据
+ ///
+ public TType Data { get; set; }
+ }
+
+
+ public static class ResultModelMap
+ {
+ ///
+ /// 将结果实体基本属性(ret,message)赋值
+ ///
+ /// 输出对象
+ /// 输出对象
+ public static TResult ConvertBaseTo(this ResultModel source)
+ where TResult : ResultModel, new()
+ {
+ TResult ot = new TResult();
+ ot.Ret = source.Ret;
+ ot.Message = source.Message;
+ return ot;
+ }
+ }
}
diff --git a/OS.Common/Encrypt/MD5Encrypt.cs b/OS.Common/Encrypt/MD5Encrypt.cs
index 65cfa44..79e5e44 100644
--- a/OS.Common/Encrypt/MD5Encrypt.cs
+++ b/OS.Common/Encrypt/MD5Encrypt.cs
@@ -12,7 +12,7 @@
///
///
///
- public static string GetMD5_16(string input)
+ public static string GetMD5_16(this string input)
{
string result = GetMD5(input);
if (!string.IsNullOrEmpty(result))
@@ -28,7 +28,7 @@
///
///
///
- public static string GetMD5(string input)
+ public static string GetMD5(this string input)
{
if (string.IsNullOrEmpty(input))
{
diff --git a/OS.Common/Extention/EnumExtention.cs b/OS.Common/Extention/EnumExtention.cs
index bf94542..9e649c0 100644
--- a/OS.Common/Extention/EnumExtention.cs
+++ b/OS.Common/Extention/EnumExtention.cs
@@ -14,22 +14,22 @@ namespace OS.Common.Extention
///
///
///
- public static string GetDesp(this Enum en, bool isFlag=false, string operate=",")
+ public static string GetDesp(this Enum en, bool isFlag = false, string operate = ",")
{
var values = en.GetType().ToEnumDirs();
- int current = (int)Enum.Parse(en.GetType(), en.ToString());
+ int current = (int) Enum.Parse(en.GetType(), en.ToString());
if (isFlag)
{
- StringBuilder strResult=new StringBuilder();
+ StringBuilder strResult = new StringBuilder();
foreach (var value in values)
{
int tempKey = value.Key.ToInt32();
- if ((tempKey¤t)==tempKey)
+ if ((tempKey & current) == tempKey)
{
- if (strResult.Length!=0)
+ if (strResult.Length != 0)
{
strResult.Append(operate);
}
@@ -38,11 +38,9 @@ namespace OS.Common.Extention
}
return strResult.ToString();
}
- else
- {
- KeyValuePair keypair = values.FirstOrDefault(e => e.Key == current.ToString());
- return keypair.Key==null ? "不存在的枚举值" : keypair.Value;
- }
+
+ KeyValuePair keypair = values.FirstOrDefault(e => e.Key == current.ToString());
+ return keypair.Key == null ? "不存在的枚举值" : keypair.Value;
}
@@ -78,7 +76,7 @@ namespace OS.Common.Extention
var name = Enum.GetName(enType, value);
string resultValue = isIntValue ? ((int)value).ToString() : value.ToString();
var attrList = enType.GetField(name).GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[];
- if (attrList.Length > 0)
+ if (attrList != null && attrList.Length > 0)
{
dirs.Add(resultValue, attrList[0].Description);
continue;
diff --git a/OS.Common/Modules/LogModule/LogUtil.cs b/OS.Common/Modules/LogModule/LogUtil.cs
index 676760b..eb8e543 100644
--- a/OS.Common/Modules/LogModule/LogUtil.cs
+++ b/OS.Common/Modules/LogModule/LogUtil.cs
@@ -1,4 +1,5 @@
+using System;
using System.Collections.Generic;
using OS.Common.Modules;
using OS.Common.Modules.AsynModule;
@@ -26,8 +27,6 @@ namespace OS.Common.LogModule
/// 警告
///
Warning,
-
-
}
public class LogInfo
@@ -39,6 +38,8 @@ namespace OS.Common.LogModule
{
}
+
+
///
/// 日志构造函数
///
@@ -63,6 +64,7 @@ namespace OS.Common.LogModule
/// 日志类型
///
public string ModuleName { get; set; }
+
///
/// key值 可以是id等
///
@@ -72,6 +74,11 @@ namespace OS.Common.LogModule
/// 日志信息
///
public string Message { get; set; }
+
+ ///
+ /// 错误编号
+ ///
+ public string ErrorCode { get; internal set; }
}
///
@@ -122,9 +129,9 @@ namespace OS.Common.LogModule
/// 日志信息
/// 关键值
/// 模块名称
- public static void Info(string msg,object key=null,string moduleName=ModuleCacheKeys.Default)
+ public static string Info(string msg, object key=null, string moduleName=ModuleCacheKeys.Default)
{
- Log(new LogInfo(LogLevelEnum.Info, msg, key, moduleName));
+ return Log(new LogInfo(LogLevelEnum.Info, msg, key, moduleName));
}
///
@@ -133,9 +140,9 @@ namespace OS.Common.LogModule
/// 日志信息
/// 关键值
/// 模块名称
- public static void Warning( string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
+ public static string Warning(string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
{
- Log(new LogInfo(LogLevelEnum.Warning, msg, key, moduleName));
+ return Log(new LogInfo(LogLevelEnum.Warning, msg, key, moduleName));
}
///
@@ -144,31 +151,46 @@ namespace OS.Common.LogModule
/// 日志信息
/// 关键值
/// 模块名称
- public static void Error( string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
+ public static string Error(string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
{
- Log(new LogInfo(LogLevelEnum.Error, msg, key, moduleName));
+ return Log(new LogInfo(LogLevelEnum.Error, msg, key, moduleName));
}
///
/// 记录错误,用于捕获到的异常信息记录
///
- /// 分类
/// 日志信息
/// 关键值
/// 模块名称
- public static void Trace(string category, string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
+ public static string Trace(string msg, object key = null, string moduleName=ModuleCacheKeys.Default)
{
- Log(new LogInfo(LogLevelEnum.Trace, msg, key, moduleName));
+ return Log(new LogInfo(LogLevelEnum.Trace, msg, key, moduleName));
}
+
///
/// 记录日志
///
///
- public static void Log(LogInfo info)
+ public static string Log(LogInfo info)
{
+ info.ErrorCode = GetErrorCode();
var logWrite = GetLogWrite(info.ModuleName);
+
AsynUtil.Asyn(logWrite.WriteLog, info, LogAsynModuleName); // logActionList.Post(info);
+ return info.ErrorCode;
+ }
+
+
+
+
+ ///
+ /// 生成错误编号
+ ///
+ ///
+ private static string GetErrorCode()
+ {
+ return Guid.NewGuid().ToString().Replace("-", "");
}
}
}
diff --git a/OS.Common/Modules/ModuleKeys.cs b/OS.Common/Modules/ModuleKeys.cs
index f4bd6ee..5b4e89d 100644
--- a/OS.Common/Modules/ModuleKeys.cs
+++ b/OS.Common/Modules/ModuleKeys.cs
@@ -31,5 +31,11 @@
/// 默认本地文件日志
///
public const string Default = "default";
+
+
+ ///
+ /// 记录sql语句log模块
+ ///
+ public const string SqlLog = "SQLLog";
}
}
diff --git a/OS.Common/OS.Common.csproj b/OS.Common/OS.Common.csproj
index 8146b86..a47a866 100644
--- a/OS.Common/OS.Common.csproj
+++ b/OS.Common/OS.Common.csproj
@@ -41,6 +41,8 @@
+
+