public void InitAuthKey(AbstractRequestApiModel model) { var request = HttpContext.Request; StringValues authKey; request.Headers.TryGetValue("AuthKey", out authKey); if (authKey.Count > 0) { var key = authKey.FirstOrDefault(); model.AuthKey = key; } }
public int GetRequestTimeout(AbstractRequestApiModel request) { string result = ""; if (!string.IsNullOrWhiteSpace(request.NetworkAlias)) { string config_path = $"ApiNode:servers:{request.NetworkAlias}:s{ServerNum}:"; result = Configuration[config_path + "TimeOut"]; } int tout; if (!int.TryParse(result, out tout)) { tout = DefaultTimeout; } return(tout); }
public string GetNetworkIp(AbstractRequestApiModel request, string defaultValue = "127.0.0.1") { string result = ""; if (!string.IsNullOrWhiteSpace(request.NetworkAlias)) { string config_path = $"ApiNode:servers:{request.NetworkAlias}:s{ServerNum}:"; result = Configuration[config_path + "Ip"]; } else { result = request.NetworkIp; } if (string.IsNullOrWhiteSpace(result)) { return(defaultValue); } return(result); }
public API.Client GetClientByModel(AbstractRequestApiModel model) { if (!String.IsNullOrEmpty(model.NetworkIp) && !String.IsNullOrEmpty(model.NetworkPort)) { return(BCTransactionTools.CreateContextBC(model.NetworkIp, Int32.Parse(model.NetworkPort), 30000 )); } var authUser = AuthDataService.ListAuthKey.FirstOrDefault(p => p.AuthKey == model.AuthKey); if (authUser == null) { return(null); } return(InitContextBC(model.NetworkAlias)); }
ushort GetPort(AbstractRequestApiModel request, string paramName, ushort defaultValue) { string result = ""; if (!string.IsNullOrWhiteSpace(request.NetworkAlias)) { string config_path = $"ApiNode:servers:{request.NetworkAlias}:s{ServerNum}:"; result = Configuration[config_path + paramName]; } else { result = request.NetworkPort; } ushort port; if (!ushort.TryParse(result, out port)) { port = defaultValue; } return(port); }
public ushort GetDiagnosticPort(AbstractRequestApiModel request) { return(GetPort(request, "DiagnosticPort", DefaultDiagnosticPort)); }
public ushort GetExecutorPort(AbstractRequestApiModel request) { return(GetPort(request, "ExecutorPort", DefaultExecutorPort)); }