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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
 public ushort GetDiagnosticPort(AbstractRequestApiModel request)
 {
     return(GetPort(request, "DiagnosticPort", DefaultDiagnosticPort));
 }
예제 #7
0
 public ushort GetExecutorPort(AbstractRequestApiModel request)
 {
     return(GetPort(request, "ExecutorPort", DefaultExecutorPort));
 }