当前位置: 首页>>代码示例>>C#>>正文


C# Session.Start方法代码示例

本文整理汇总了C#中Session.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Session.Start方法的具体用法?C# Session.Start怎么用?C# Session.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session.Start方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitialiseSessionAndService

        /// <summary>
        /// Initialise the Session and the Service
        /// </summary>
        internal void InitialiseSessionAndService()
        {
            if (_session == null)
            {
                var sessionOptions = new SessionOptions
                {
                    ServerHost = _serverHost,
                    ServerPort = _serverPort
                };

                //Console.WriteLine("Connecting to {0}:{1}", sessionOptions.ServerHost, sessionOptions.ServerPort);

                _session = new Session(sessionOptions);

                if (!_session.Start())
                    throw new Exception("Failed to connect!");

                if (!_session.OpenService("//blp/refdata"))
                {
                    _session.Stop();
                    _session = null;

                    throw new Exception("Failed to open //blp/refdata");
                }

                _refDataService = _session.GetService("//blp/refdata");
            }
        }
开发者ID:azmikamis,项目名称:bloombergdotnet,代码行数:31,代码来源:BloombergApi.cs

示例2: Bloomberg

        public Bloomberg(string host, int port)
        {
            Name = "Bloomberg";

            SessionOptions sessionOptions = new SessionOptions();
            sessionOptions.ServerHost = host;
            sessionOptions.ServerPort = port;

            Session session = new Session(sessionOptions);
            Connected = session.Start();
        }
开发者ID:KeithNel,项目名称:qdms,代码行数:11,代码来源:Bloomberg.cs

示例3: setup

    private void setup()
    {
      Logger.Info("About to startup bbg engines...", typeof(Core));
      m_processEventHandler = processEvent;

      try
      {
        // start a synchronous session
        SessionOptions opts = new SessionOptions();
        opts.ServerHost = ConfigHelper.BbgHost;
        opts.ServerPort = ConfigHelper.BbgPort;

        Logger.Info(string.Format("Bbg Session options: Host={0}; Port={1}", opts.ServerHost, opts.ServerPort.ToString()), typeof(Core));

        SyncSession = new Session(opts);
        if (!SyncSession.Start())
        {
          Logger.Fatal("Failed to start SyncSession instance of bloomberg session", typeof(Core));
          IsStarted = false;
          return;
        }
        else
        {
          Logger.Info("Bloomberg 'SyncSession' started successfully", typeof(Core));
        }

        if (!SyncSession.OpenService("//blp/refdata"))
        {
          Logger.Fatal("Failed to open service //blp/refdata on 'SyncSession' bbg session", typeof(Core));
          System.Console.Error.WriteLine("Failed to start RefData service");
          return;
        }
        else
        {
          Logger.Info("Successfully opened service //blp/refdata on 'SyncSession' bbg session", typeof(Core));
        }
        SyncRefService = SyncSession.GetService("//blp/refdata");

        ASyncSession = new Session(opts, m_processEventHandler);
        ASyncSession.Start();
        ASyncSession.OpenService("//blp/refdata");
        ASyncSession.OpenService("//blp/pagedata");
        ASyncRefService = ASyncSession.GetService("//blp/refdata");

        IsStarted = true;
      }
      catch (Exception ex_)
      {
        Logger.Error(string.Format("Error starting up Bloomberg Sessions: {0} {1}", ex_.Message, ex_.StackTrace), typeof(Core));
        IsStarted = false;
      }
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:52,代码来源:Core.cs

示例4: Test

        public void Test()
        {
            string serverHost = "localhost";
            int serverPort = 8194;

            SessionOptions sessionOptions = new SessionOptions();
            sessionOptions.ServerHost = serverHost;
            sessionOptions.ServerPort = serverPort;

            Debug.WriteLine("Connecting to " + serverHost + ":" + serverPort);
            Session session = new Session(sessionOptions);
            bool sessionStarted = session.Start();
            if (!sessionStarted)
            {
                System.Console.Error.WriteLine("Failed to start session.");
                return;
            }
            if (!session.OpenService("//blp/refdata"))
            {
                System.Console.Error.WriteLine("Failed to open //blp/refdata");
                return;
            }
            Service refDataService = session.GetService("//blp/refdata");
            Request request = refDataService.CreateRequest("IntradayBarRequest");
            request.Set("security", "IBM US Equity");
            request.Set("eventType", "TRADE");
            request.Set("interval", 60);	// bar interval in minutes
            DateTime tradedOn = getPreviousTradingDate();
            request.Set("startDateTime", new Datetime(tradedOn.Year,
                                                      tradedOn.Month,
                                                      tradedOn.Day,
                                                      13, 30, 0, 0));
            request.Set("endDateTime", new Datetime(tradedOn.Year,
                                                    tradedOn.Month,
                                                    tradedOn.Day,
                                                    21, 30, 0, 0));
            Debug.WriteLine("Sending Request: " + request);
            session.SendRequest(request, null);

            while (true)
            {
                Event eventObj = session.NextEvent();
                foreach (Message msg in eventObj.GetMessages())
                {
                    Debug.WriteLine(msg.ToString());
                }
                if (eventObj.Type == Event.EventType.RESPONSE)
                {
                    break;
                }
            }
        }
开发者ID:azmikamis,项目名称:bloombergdotnet,代码行数:52,代码来源:MainWindowViewModel.cs

示例5: Run

        private void Run(string[] args)
        {
            var commandLineOptions = new CommandLineOptions();
            if (!CommandLine.Parser.Default.ParseArguments(args, commandLineOptions))
            {
                return;
            }

            Initialize(commandLineOptions);

            var sessionOptions = GetSessionOptions();

            Logger.InfoFormat("Connecting to [{0}]:[{1}]", _host, _port);
            var session = new Session(sessionOptions);
            bool sessionStarted = session.Start();
            if (!sessionStarted)
            {
                Logger.Error("Failed to start session.");
                return;
            }
            if (!session.OpenService("//blp/refdata"))
            {
                Logger.Error("Failed to open //blp/refdata");
                return;
            }

            try
            {
                SendRefDataRequest(session);
            }
            catch (InvalidRequestException e)
            {
                Logger.WarnFormat("Exception occurred: [{0}]", e);
            }

            // wait for events from session.
            EventLoop(session);

            session.Stop();
        }
开发者ID:jbontik,项目名称:bloomberg_downloader,代码行数:40,代码来源:Program.cs

示例6: RunSession

        public void RunSession()
        {
            Timer.Stop();
            Timer.Interval = 1000;

            if (_hmaService.IsHmaEnabled() && (!_hmaService.IsHmaOn || _hmaService.IsHmaPendingRestart))
            {
                Timer.Start();
                return;
            }

            IsRunning = true;

            try
            {
                var settings = GlobalSettingsService.GetSettings(_provider);

                if (settings.ProviderEnabled)
                {
                    CurrentSession = CreateSession(settings);

                    if (CurrentSession == null)
                    {
                        Timer.Interval = TimeSpan.FromMinutes(5)
                                                 .TotalMilliseconds;
                    }
                    else
                    {
                        CurrentSession.Context.EngagementSession.IpAddress = _hmaService.CurrentIp;
                        CurrentSession.Start();
                    }
                }
                else
                {
                    Logger.Info(ProviderDisabledMessage, _provider);
                    Stop();
                    return;
                }
            }
            catch (UnrecoverableDomStateException e)
            {
                Logger.Error(string.Format("SESSION ERROR: The page reached a state which could not be recovered and must move on to another account: {0}", e.Message));
                // TODO: add full exception with inner to dev only log
                if ((CurrentSession != null) && (CurrentSession.Context != null))
                {
                    if (CurrentSession.Context.Driver != null)
                    {
                        CurrentSession.Context.Driver.SafeClose(ex => Logger.ErrorException(string.Format("Error Closing WebDriver Instance: {0}", ex.Message), ex));
                    }

                    if (CurrentSession.Context.EngagementSession != null)
                    {
                        CurrentSession.Context.EngagementSession.ErrorMessage = e.Message;
                    }
                }

                Timer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
            }
            catch (NewHotmailDesignException)
            {
                Logger.Info("Restart Hotmail provider. User has been migrated to new Outlook interface which is not supported.");
                Stop();
            }
            catch (Exception e)
            {
                Logger.ErrorException(string.Format("SESSION ERROR: {0}", e.Message), e);

                if ((CurrentSession != null) && (CurrentSession.Context != null))
                {
                    if (CurrentSession.Context.Driver != null)
                    {
                        CurrentSession.Context.Driver.SafeClose(ex => Logger.ErrorException(string.Format("Error Closing WebDriver Instance: {0}", ex.Message), ex));
                    }

                    if (CurrentSession.Context.EngagementSession != null)
                    {
                        CurrentSession.Context.EngagementSession.ErrorMessage = e.Message;
                    }
                }

                Timer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
            }
            finally
            {
                UpdateEngagementSession();
            }

            IsRunning = false;

            if (!stopTimer)
            {
                Timer.Start();
            }
            else
            {
                _serverStatusService.EngagerPhoneHomeAsync(_provider, Status.Stopped).Start();
            }
        }
开发者ID:c0d3m0nky,项目名称:mty,代码行数:98,代码来源:SessionManager.cs

示例7: Run

        private void Run()
        {
            var sessionOptions = new SessionOptions {ServerHost = _dHost, ServerPort = _dPort};

            Console.WriteLine(@"Connecting to " + _dHost + @":" + _dPort);
            var session = new Session(sessionOptions);
            bool sessionStarted = session.Start();
            if (!sessionStarted)
            {
                Console.Error.WriteLine("Failed to start session.");
                _waitEndOfCollection.Release();
                return;
            }
            if (!session.OpenService("//blp/refdata"))
            {
                Console.Error.WriteLine("Failed to open //blp/refdata");
                _waitEndOfCollection.Release();
                return;
            }

            DataManager.CreateTableForContract(_dSecurity);

            DataManager.DeleteTicks(_dSecurity, _startDate, _endDate);

            SendIntradayTickRequest(session);

            EventLoop(session);

            session.Stop();
        }
开发者ID:rlyalko,项目名称:REVERSALS_v14,代码行数:30,代码来源:IntradayTick.cs

示例8: OpenLogFile

 private void OpenLogFile(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Filter = "Log files (*.log;*.txt;*.csv)|*.log;*.txt;*.csv|All files (*.*)|*.*";
         if (DialogResult.OK == ofd.ShowDialog())
         {
             Session instance = new Session();
             instance.ReceiverType = "FILE";
             instance.Name = GetUniqueSessionName();
             instance.Resolve();
             instance.Dirty = true;
             FileReceiver fr = new FileReceiver();
             fr.FileName = ofd.FileName;
             instance.Receiver = fr;
             instance.Parser = new Log4JXmlLogEventParser();
             instance.CreateTab(this);
             _sessions.Add(instance);
             ReloadTabPages();
             instance.Start();
             tabControl1.SelectedTab = instance.TabPage;
         }
     }
 }
开发者ID:jkowalski,项目名称:NLogViewer,代码行数:24,代码来源:MainForm.cs

示例9: NewLiveLogReceiver_Clicked

 private void NewLiveLogReceiver_Clicked(object sender, EventArgs e)
 {
     using (NewReceiverDialog dlg = new NewReceiverDialog())
     {
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             Session instance = new Session();
             instance.ReceiverType = LogReceiverFactory.FindReceiverByType(dlg.Receiver.GetType()).Name;
             if (dlg.Parser != null)
                 instance.ParserType = LogEventParserFactory.FindParserByType(dlg.Parser.GetType()).Name;
             instance.Name = GetUniqueSessionName();
             instance.Dirty = true;
             instance.Receiver = dlg.Receiver;
             instance.Parser = dlg.Parser;
             instance.Resolve();
             instance.CreateTab(this);
             _sessions.Add(instance);
             ReloadTabPages();
             instance.Start();
             tabControl1.SelectedTab = instance.TabPage;
         }
     }
 }
开发者ID:jkowalski,项目名称:NLogViewer,代码行数:23,代码来源:MainForm.cs

示例10: OpenSession

 /// <summary>
 /// Etablie la connection avec Bloomberg
 /// </summary>
 private void OpenSession()
 {
     sessionOptions = new SessionOptions();
     sessionOptions.ServerHost = "localhost";
     sessionOptions.ServerPort = 8194;
     session = new Session(sessionOptions);
     l_title = new List<Title>();
     if (!session.Start())
     {
         System.Console.WriteLine("Could not start session.");
         Console.WriteLine(session.ToString());
         Remplissage_Non_connection();
         return;
     }
     if (!session.OpenService("//blp/refdata"))
     {
         System.Console.WriteLine("Could not open service " +
         "//blp/refdata");
         return;
     }
     refDataSvc = session.GetService("//blp/refdata");
     if (refDataSvc == null)
     {
         Console.WriteLine("Cannot get service");
         return;
     }
     else
     {
         request = refDataSvc.CreateRequest("ReferenceDataRequest");
     }
 }
开发者ID:TigerSCR,项目名称:TigerAppWPF,代码行数:34,代码来源:Connector.cs

示例11: GetEncompassSession

 public static Session GetEncompassSession(string encompassUrl, string login, string pw)
 {
     Session session = new Session();
     session.Start(encompassUrl, login, pw);
     return session;
 }
开发者ID:Guaranteed-Rate,项目名称:GuaranteedRate.Sextant,代码行数:6,代码来源:SessionUtils.cs

示例12: Submit

        public result Submit(string ISIN)
        {
            result FOSresult = new result();
            //open excel to get two parameter

            SessionOptions sessionOptions = new SessionOptions();
            sessionOptions.ServerHost = "WSG053";
            sessionOptions.ServerPort = 0x2002;
            Session session = new Session(sessionOptions);
            if (!session.Start())
            {
                Console.WriteLine("Could not start session.");
                Environment.Exit(1);
            }
            if (!session.OpenService("//blp/refdata"))
            {
                Console.WriteLine("Could not open service //blp/refdata");
                Environment.Exit(1);
            }
            CorrelationID requestID = new CorrelationID(1L);
            Request request = session.GetService("//blp/refdata").CreateRequest("ReferenceDataRequest");
            request.GetElement("securities").AppendValue(ISIN + " corp");
            Element fields = request.GetElement("fields");
            fields.AppendValue("SECURITY_DES");
            fields.AppendValue("CRNCY");
            fields.AppendValue("ISSUER");
            fields.AppendValue("COUNTRY_FULL_NAME");
            fields.AppendValue("MARKET_SECTOR_DES");
            fields.AppendValue("INDUSTRY_SECTOR");
            fields.AppendValue("PX_BID");
            fields.AppendValue("COUPON");
            fields.AppendValue("YLD_YTM_BID");
            fields.AppendValue("DUR_BID");
            fields.AppendValue("RTG_SP");
            fields.AppendValue("RTG_SP_LT_LC_ISSUER_CREDIT");
            fields.AppendValue("RTG_MOODY");
            fields.AppendValue("RTG_MOODY_LONG_TERM");
            fields.AppendValue("RTG_MDY_LC_CURR_ISSUER_RATING");
            fields.AppendValue("RTG_FITCH");
            fields.AppendValue("RTG_FITCH_LT_ISSUER_DEFAULT");
            fields.AppendValue("COLLAT_TYP");
            fields.AppendValue("MTY_YEARS_TDY");
            fields.AppendValue("NXT_CALL_DT");
            fields.AppendValue("MATURITY");
            fields.AppendValue("GUARANTOR");
            Console.WriteLine("Sending Request:" + request);
            session.SendRequest(request, null);
            while (true)
            {
                Event eventObj = session.NextEvent();
                this.processEvent(eventObj, session);
                if (eventObj.Type == Event.EventType.RESPONSE)
                {
                    IssueRating = RTG_SP + "/" + this.GetMoody(RTG_MOODY, RTG_MOODY_LONG_TERM) + "/" + RTG_FITCH;
                    IssuerRating = RTG_SP_LT_LC_ISSUER_CREDIT + "/" + RTG_MDY_LC_CURR_ISSUER_RATING + "/" + RTG_FITCH_LT_ISSUER_DEFAULT;
                    if (CallDate != "NA")
                    {
                        DateTime newdate = DateTime.Parse(CallDate);
                        DateTime nowdate = DateTime.Now;
                        decimal dCallDate = (decimal)(((TimeSpan)(newdate - nowdate)).Days) / 365;
                        CallDate = StandardFormat(Math.Round(dCallDate, 2).ToString(), 2);
                    }

                    FOSresult.CallDate = CallDate;
                    FOSresult.COLLATERAL_TYPE = COLLATERAL_TYPE;
                    FOSresult.COUNTRY_FULL_NAME = COUNTRY_FULL_NAME;
                    FOSresult.COUPON = COUPON;
                    FOSresult.CRNCY = CRNCY;
                    FOSresult.DUR_BID = DUR_BID;
                    FOSresult.INDUSTRY_SECTOR = INDUSTRY_SECTOR.ToUpper();
                    FOSresult.PX_BID = PX_BID;
                    FOSresult.YLD_YTM_BID = YLD_YTM_BID;
                    FOSresult.SECURITY_DES = SECURITY_DES;
                    FOSresult.IssueRating = IssueRating;
                    FOSresult.IssuerRating = IssuerRating;
                    FOSresult.MARKET_SECTOR_DES = MARKET_SECTOR_DES;
                    FOSresult.YearToMaturity = Maturity;
                    FOSresult.ISSUER = ISSUER;

                    GetInfoFromExcel(FOSresult);
                    //undoImpersonation();
                    return FOSresult;
                    //return base.Json(new { SECURITY_DES = SECURITY_DES, CRNCY = CRNCY, ISSUER = ISSUER, COUNTRY_FULL_NAME = COUNTRY_FULL_NAME, MARKET_SECTOR_DES = MARKET_SECTOR_DES, INDUSTRY_SECTOR = INDUSTRY_SECTOR.ToUpper(), PX_BID = PX_BID, COUPON = COUPON, YLD_YTM_BID = YLD_YTM_BID, DUR_BID = DUR_BID, IssueRating = IssueRating, IssuerRating = IssuerRating, COLLATERAL_TYPE = COLLATERAL_TYPE, YearToMaturity = Maturity, CallDate = CallDate });
                }
            }
        }
开发者ID:kyoliumiao,项目名称:PTCWebService,代码行数:86,代码来源:Submit.asmx.cs

示例13: Run

        /// <summary>
        /// Run the server. The method will not return until Stop() is called.
        /// </summary>
        public void Run()
        {
            if (authHandler == null)
                authHandler = new DefaultAuthHandler();

            if (fsHandler == null)
                fsHandler = new DefaultFileSystemHandler();

            if (socket == null)
                socket = new TcpListener(endpoint);

            socket.Start();

            // listen for new connections
            try {
                while (true)
                {
                    Socket peer = socket.AcceptSocket();

                    IPEndPoint peerPort = (IPEndPoint) peer.RemoteEndPoint;
                    Session session = new Session(peer, bufferSize,
                                                  authHandler.Clone(peerPort),
                                                  fsHandler.Clone(peerPort),
                                                  logHandler.Clone(peerPort));

                    session.Start();
                    sessions.Add(session);

                    // purge old sessions
                    for (int i = sessions.Count - 1; i >= 0; --i)
                    {
                        if (!sessions[i].IsOpen) {
                            sessions.RemoveAt(i);
                            --i;
                        }
                    }
                }
            } catch (SocketException) {
                // ignore, Stop() will probably cause this exception
            } finally {
                // close all running connections
                foreach (Session s in sessions) {
                    s.Stop();
                }
            }
        }
开发者ID:CubeCoders,项目名称:mooftpserv,代码行数:49,代码来源:Server.cs


注:本文中的Session.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。