public WMSBaseApiAccessor(Wms_warehouse warehouse, ISqlSugarClient client, SysUserDto userDto) { this.Warehouse = warehouse; HttpApiConfig config = new HttpApiConfig(); config.HttpHost = new Uri(warehouse.IFAddress); if (!string.IsNullOrWhiteSpace(WMSProxy)) { config.HttpHandler.UseProxy = true; config.HttpHandler.Proxy = new HttpProxy(WMSProxy); WebRequest.DefaultWebProxy = new WebProxy(WMSProxy) { BypassProxyOnLocal = false }; } _apiProxy = HttpApi.Create <IWMSApiProxy>(config); _selfAccessor = new SelfWMSBaseApiAccessor(warehouse, client, userDto); }
/// <summary> /// 获取基本Api /// </summary> /// <param name="key"></param> /// <param name="sqlSugar"></param> /// <param name="user"></param> /// <returns></returns> public static IWMSBaseApiAccessor GetBaseApiAccessor(string key, ISqlSugarClient sqlSugar, SysUserDto user = null) { if (_baseApiInstanceMap.ContainsKey(key)) { return(_baseApiInstanceMap[key]); } if (!_warehouseMap.ContainsKey(key)) { return(null); } Wms_warehouse warehouse = _warehouseMap[key]; IWMSBaseApiAccessor accessor = null; if (string.IsNullOrWhiteSpace(warehouse.IFAddress)) { accessor = new SelfWMSBaseApiAccessor(warehouse, sqlSugar, user); } else { accessor = new WMSBaseApiAccessor(warehouse, sqlSugar, user); _baseApiInstanceMap.Add(key, accessor); } return(accessor); }