protected override void OnServerStarted() { base.OnServerStarted(); _defaultSmtpServer = OtherSettings.GetValue(AlertRule.MailHost, "mailhost"); _defaultMailFrom = OtherSettings.GetValue(AlertRule.MailFrom, AlertRule.UserDefaultReplyTo); _defaultMailTo = OtherSettings.GetArray(AlertRule.MailTo, new[] { AlertRule.GroupDefaultMailTo }); }
protected override void OnServerStarted() { // default configuration _activeProviders = new[] { MDSProviderId.Bloomberg }; // custom configuration string[] enabledProviders = OtherSettings.GetArray <string>(MdsPropName.EnabledProviders); if (enabledProviders != null && enabledProviders.Length > 0) { _activeProviders = enabledProviders.Select(providerName => EnumHelper.Parse <MDSProviderId>(providerName, true)).ToArray(); } // derived configuration EnvId envId = IntClient.Target.ClientInfo.ConfigEnv; string envName = EnvHelper.EnvName(envId); var port = OtherSettings.GetValue(MdsPropName.Port, EnvHelper.SvcPort(envId, SvcId.MarketData)); // service endpoints string transEndpoints = ServiceHelper.FormatEndpoint(WcfConst.NetTcp, port); string discoEndpoints = ServiceHelper.FormatEndpoint(WcfConst.NetTcp, port); transEndpoints = OtherSettings.GetValue(MdsPropName.Endpoints, transEndpoints); // add default port to endpoints if required var tempEndpoints = new List <string>(); foreach (string ep in transEndpoints.Split(';')) { var epParts = ep.Split(':'); var scheme = epParts[0]; var tport = port; if (epParts.Length > 1) { tport = Int32.Parse(epParts[1]); } tempEndpoints.Add($"{scheme}:{tport}"); } transEndpoints = String.Join(";", tempEndpoints.ToArray()); // get user identity and full name WindowsIdentity winIdent = WindowsIdentity.GetCurrent(); UserPrincipal principal = null; try { var principalContext = new PrincipalContext(ContextType.Domain); principal = UserPrincipal.FindByIdentity(principalContext, IdentityType.SamAccountName, winIdent.Name); } catch (PrincipalException principalException) { // swallow - can occur on machines not connected to domain controller Logger.LogWarning("UserPrincipal.FindByIdentity failed: {0}: {1}", principalException.GetType().Name, principalException.Message); } string userFullName = null; if (principal != null) { userFullName = principal.GivenName + " " + principal.Surname; } _serverCfg = new ServerCfg( new ModuleInfo(envName, Guid.NewGuid(), winIdent.Name, userFullName, null, null), transEndpoints, discoEndpoints); foreach (MDSProviderId providerId in _activeProviders) { _providers[(int)providerId] = new MarketDataRealtimeClient(LoggerRef, MainThreadQueue, IntClient.Target, providerId); } string svcName = EnvHelper.SvcPrefix(SvcId.MarketData); // V2.2 _mrktDataV221ServerHost = new CustomServiceHost <IMrktDataV221, MrktDataRecverV221>( Logger, new MrktDataRecverV221(this), _serverCfg.TransEndpoints, svcName, typeof(IMrktDataV221).Name, true); _sessCtrlV131ServerHost = new CustomServiceHost <ISessCtrlV131, SessCtrlRecverV131>( Logger, new SessCtrlRecverV131(this), _serverCfg.DiscoEndpoints, svcName, typeof(ISessCtrlV131).Name, true); _discoServerHostV111 = new CustomServiceHost <IDiscoverV111, DiscoverRecverV111>( Logger, new DiscoverRecverV111(this), _serverCfg.DiscoEndpoints, svcName, typeof(IDiscoverV111).Name, true); }