| | |
| | | /// API相关参数定义的全局类 |
| | | public partial class ApiGlobal |
| | | { |
| | | public ApiGlobal() { } |
| | | private static readonly object _lock = new object(); |
| | | private static bool _initialized = false; |
| | | |
| | | /// 初始化 |
| | | static ApiGlobal() |
| | | { |
| | | Init(); |
| | | } |
| | | |
| | | public static void Init() |
| | | { |
| | | signConst = new SignConst(); |
| | | if (!_initialized) |
| | | { |
| | | lock (_lock) |
| | | { |
| | | if (!_initialized) |
| | | { |
| | | signConst = new SignConst(); |
| | | _initialized = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static SignConst signConst { get; set; } |
| | |
| | | /// 构造对象 |
| | | public static ApiCommonParam NewApiCommon() |
| | | { |
| | | //构造对象 |
| | | ApiCommonParam param = new ApiCommonParam(ApiGlobal.signConst.appKey, ApiGlobal.signConst.version, ApiGlobal.signConst.operateCompanyCode, ApiGlobal.signConst.ownerCompanyCode, SignUtils.GetTimestamp(DateTime.Now)); |
| | | // 确保初始化完成 |
| | | ApiGlobal.Init(); |
| | | |
| | | // 构造对象(原有逻辑保持不变) |
| | | ApiCommonParam param = new ApiCommonParam( |
| | | ApiGlobal.signConst.appKey, |
| | | ApiGlobal.signConst.version, |
| | | ApiGlobal.signConst.operateCompanyCode, |
| | | ApiGlobal.signConst.ownerCompanyCode, |
| | | SignUtils.GetTimestamp(DateTime.Now)); |
| | | //计算签名&赋值 |
| | | var jsonParam = JsonConvert.SerializeObject(param); |
| | | //JavaScriptSerializer json = new JavaScriptSerializer(); |
| | |
| | | return param; |
| | | } |
| | | } |
| | | } |
| | | } |