public NamingGrpcClientProxy( ILogger logger, string namespaceId, SecurityProxy securityProxy, IServerListFactory serverListFactory, NacosSdkOptions options, ServiceInfoHolder serviceInfoHolder) { this._logger = logger; this.namespaceId = namespaceId; this.uuid = Guid.NewGuid().ToString(); this._options = options; this._securityProxy = securityProxy; this.requestTimeout = options.DefaultTimeOut > 0 ? options.DefaultTimeOut : 3000L; Dictionary <string, string> labels = new Dictionary <string, string>() { { RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK }, { RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_NAMING }, }; this.rpcClient = RpcClientFactory.CreateClient(uuid, RemoteConnectionType.GRPC, labels); this.namingGrpcConnectionEventListener = new NamingGrpcConnectionEventListener(_logger, this); Start(serverListFactory, serviceInfoHolder); }
private static SecurityProxy CreateProxy(Security item) { CurrencyProxy currencyProxy = new CurrencyProxy() { Id = item.Currency_ID, Description = item.Currency.Description }; ExchangeProxy exchangeProxy = new ExchangeProxy() { Id = item.Exchange_ID, Description = item.Exchange.Description }; Security_Primary_TypeProxy securityPrimaryTypeProxy = new Security_Primary_TypeProxy() { Id = item.Security_Primary_Type_ID, Description = item.Security_Primary_Type.Description }; SecurityProxy securityProxy = new SecurityProxy() { Sid = item.SID, Ticker = item.Ticker, Description = item.Description, Start_Date = item.Start_Date, End_Date = item.End_Date, Currency = currencyProxy, Underlyning_Sid = item.Underlyning_SID, Exchange = exchangeProxy, Security_Primary_Type = securityPrimaryTypeProxy }; return(securityProxy); }
public async Task <Result> Register(string name, string email, string password, RoleType roleType) { var result = new Result(); try { var exists = UnitOfWork.UserRepository.Any(u => u.Email.Equals(email.ToLower())); if (exists) { throw new Exception("Email already registered"); } var securityProxy = new SecurityProxy(); var registerResult = await securityProxy.Register(email, password, roleType); if (!registerResult.Succeeded) { return(registerResult); } var userId = registerResult.Response.Value <string>("userId"); result.Succeeded = CreateUser(userId, name, email, roleType); } catch (Exception ex) { FillErrors(ex, result); } return(result); }
public IActionResult Search([FromBody] SecurityQuery searchQuery) { List <SecurityProxy> ProxyList = new List <SecurityProxy>(); try { IEnumerable <Security> resultSet = _context.Securities.Include(x => x.Currency) .Include(x => x.Exchange) .Include(x => x.Security_Primary_Type) .Where(searchQuery.Compile()); if (resultSet.Count() == 0) { return(NotFound("No records found")); } else { foreach (var item in resultSet) { SecurityProxy securityProxy = CreateProxy(item); ProxyList.Add(securityProxy); } return(Ok(ProxyList)); } } catch (Exception e) { return(BadRequest(e.Message)); } }
public NamingHttpClientProxy( ILogger logger, string namespaceId, SecurityProxy securityProxy, ServerListManager serverListManager, NacosSdkOptions options, ServiceInfoHolder serviceInfoHolder, IHttpClientFactory clientFactory = null) { this._logger = logger; this._clientFactory = clientFactory; this.serverListManager = serverListManager; this._securityProxy = securityProxy; this._options = options; this.SetServerPort(DEFAULT_SERVER_PORT); this.namespaceId = namespaceId; this.beatReactor = new BeatReactor(_logger, this, _options); // Don't create PushReceiver when using rpc, it will create a udp server if (!options.NamingUseRpc) { this.pushReceiver = new PushReceiver(_logger, serviceInfoHolder, _options); } this.serviceInfoHolder = serviceInfoHolder; }
private void InitializeClients() { Cdn = new CdnProxy(_internalData); Dns = new DnsProxy(_internalData); IaaS = new IaaSProxy(_internalData); Live = new LiveProxy(_internalData); Security = new SecurityProxy(_internalData); Storage = new StorageProxy(_internalData); Vod = new VodProxy(_internalData); }
public NamingClientProxyDelegate(ILogger logger, string @namespace, ServiceInfoHolder serviceInfoHolder, NacosSdkOptions options, InstancesChangeNotifier changeNotifier) { this._options = options; this.serverListManager = new ServerListManager(logger, options); this.serviceInfoHolder = serviceInfoHolder; this.securityProxy = new SecurityProxy(options, logger); InitSecurityProxy(); this._serviceInfoUpdateService = new ServiceInfoUpdateService(options, serviceInfoHolder, this, changeNotifier); this.grpcClientProxy = new NamingGrpcClientProxy(logger, @namespace, securityProxy, serverListManager, options, serviceInfoHolder); this.httpClientProxy = new NamingHttpClientProxy(logger, @namespace, securityProxy, serverListManager, options, serviceInfoHolder); }
public MsConfigServerHttpAgent(NacosOptions options) { _options = options; _serverListMgr = new ServerListManager(_options); _namespaceId = _options.Namespace; _serverListMgr = new ServerListManager(_options); _securityProxy = new SecurityProxy(_options, null); _securityProxy.LoginAsync(_serverListMgr.GetServerUrls()).ConfigureAwait(false).GetAwaiter().GetResult(); _timer = new Timer( async x => { await _securityProxy.LoginAsync(_serverListMgr.GetServerUrls()).ConfigureAwait(false); }, null, 0, _securityInfoRefreshIntervalMills); }
public IActionResult Create([FromBody] SecurityProxy s) { Security security = new Security() { SID = s.Sid, Ticker = s.Ticker, Description = s.Description, Start_Date = s.Start_Date, End_Date = s.End_Date, Currency_ID = s.Currency.Id, Underlyning_SID = s.Underlyning_Sid, Exchange_ID = s.Exchange.Id, Security_Primary_Type_ID = s.Security_Primary_Type.Id }; _context.Securities.Add(security); _context.SaveChanges(); return(Ok()); }
public IActionResult Edit([FromBody] SecurityProxy s) { Security security = _context.Securities.FirstOrDefault(x => x.SID == s.Sid); if (security == null) { return(BadRequest()); } security.Ticker = s.Ticker; security.Description = s.Description; security.Start_Date = s.Start_Date; security.End_Date = s.End_Date; security.Currency_ID = s.Currency.Id; security.Underlyning_SID = s.Underlyning_Sid; security.Exchange_ID = s.Exchange.Id; security.Security_Primary_Type_ID = s.Security_Primary_Type.Id; _context.Securities.Update(security); _context.SaveChanges(); return(Ok()); }