/// <summary> /// Initialises the specified URI session and opens the service. /// </summary> /// <param name="uri">The URI.</param> /// <returns></returns> private bool Initialise(string uri, int requestCount) { sessionOptions = new BB.SessionOptions(); sessionOptions.ServerHost = "localhost"; sessionOptions.ServerPort = 8194; if (requestCount > sessionOptions.MaxPendingRequests) { sessionOptions.MaxPendingRequests = requestCount; } UpdateStatus("Starting the Bloomberg session."); session = new BB.Session(sessionOptions, new BB.EventHandler(processEvent)); if (session.Start()) { if (!session.OpenService(uri)) { throw new Exception("Bloomberg failed to open session " + uri); } return(true); } else { throw new Exception("An error occurred starting the Bloomberg session. Ensure Bloomberg is installed."); } }
/// <summary> /// Initializes the SecurityLookup instance by creating a session and authorizing it so that its /// ready to conduct searches. Once initialized multiple searches may be conducted with the same instance. /// </summary> public void Init() { try { SessionOptions sessionOptions = new SessionOptions(); sessionOptions.ServerHost = d_host; sessionOptions.ServerPort = d_port; sessionOptions.AuthenticationOptions = d_authOptions; Console.WriteLine("Connecting to {0}:{1}", d_host, d_port); session = new Session(sessionOptions); if (!session.Start()) { throw new Exception("Failed to start session"); } identity = null; if (d_authOptions != null) { Authorize(out identity, session); } if (!session.OpenService(INSTRUMENT_SERVICE)) { throw new Exception( string.Format("Failed to open: {0}", INSTRUMENT_SERVICE)); } } catch (Exception e) { Console.WriteLine(string.Format("Exception: {0}", e.Message)); Console.WriteLine(); } }
public MktBarSubscriptionWithEvents() { d_sessionOptions = new SessionOptions(); d_host = "localhost"; d_port = 8194; d_sessionOptions = new SessionOptions(); d_securities = new List <string>(); d_fields = new List <string>(); d_options = new List <string>(); d_subscriptions = new List <Subscription>(); }
public MktBarSubscriptionWithEvents() { d_sessionOptions = new SessionOptions(); d_hosts = new List <string>(); d_port = 8194; d_sessionOptions = new SessionOptions(); d_securities = new List <string>(); d_fields = new List <string>(); d_options = new List <string>(); d_subscriptions = new List <Subscription>(); d_authOption = string.Empty; d_name = string.Empty; d_dsName = string.Empty; }
/***************************************************************************** * Function : createSession * Description : This function creates a session object and opens the market * bar service. Returns false on failure. * Arguments : none * Returns : bool *****************************************************************************/ private bool createSession() { if (d_session != null) { d_session.Stop(); } string authOptions = string.Empty; d_sessionOptions = new SessionOptions(); if (d_authOption == "APPLICATION") { // Set Application Authentication Option authOptions = "AuthenticationMode=APPLICATION_ONLY;"; authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;"; // ApplicationName is the entry in EMRS. authOptions += "ApplicationName=" + d_name; } else if (d_authOption == "USER_APP") { // Set User and Application Authentication Option authOptions = "AuthenticationMode=USER_AND_APPLICATION;"; authOptions += "AuthenticationType=OS_LOGON;"; authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;"; // ApplicationName is the entry in EMRS. authOptions += "ApplicationName=" + d_name; } else if (d_authOption == "USER_DS_APP") { // Set User and Application Authentication Option authOptions = "AuthenticationMode=USER_AND_APPLICATION;"; authOptions += "AuthenticationType=DIRECTORY_SERVICE;"; authOptions += "DirSvcPropertyName=" + d_dsName + ";"; authOptions += "ApplicationAuthenticationType=APPNAME_AND_KEY;"; // ApplicationName is the entry in EMRS. authOptions += "ApplicationName=" + d_name; } else if (d_authOption == "DIRSVC") { // Authenticate user using active directory service property authOptions = "AuthenticationType=DIRECTORY_SERVICE;"; authOptions += "DirSvcPropertyName=" + d_dsName; } else { // Authenticate user using windows/unix login name (default) authOptions = "AuthenticationType=OS_LOGON"; } System.Console.WriteLine("Authentication Options = " + authOptions); d_sessionOptions.AuthenticationOptions = authOptions; SessionOptions.ServerAddress[] servers = new SessionOptions.ServerAddress[d_hosts.Count]; int index = 0; System.Console.WriteLine("Connecting to port " + d_port.ToString() + " on host(s):"); foreach (string host in d_hosts) { servers[index] = new SessionOptions.ServerAddress(host, d_port); System.Console.WriteLine(host); index++; } // auto restart on disconnect d_sessionOptions.ServerAddresses = servers; d_sessionOptions.AutoRestartOnDisconnection = true; d_sessionOptions.NumStartAttempts = d_hosts.Count; // change default subscription service d_sessionOptions.DefaultSubscriptionService = MKTBAR_SVC; // create session and start d_session = new Session(d_sessionOptions, processEvent); return(d_session.Start()); }