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


C# Session.GetService方法代码示例

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


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

示例1: 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

示例2: SendIntradayBarRequest

        private void SendIntradayBarRequest(Session session, RealTimeDataRequest req)
        {
            session.OpenService("//blp/refdata");
            Service refDataService = session.GetService("//blp/refdata");
            Request request = refDataService.CreateRequest("IntradayBarRequest");

            // only one security/eventType per request
            request.Set("security", req.Instrument.DatasourceSymbol);
            request.Set("eventType", "TRADE");
            request.Set("interval", req.Frequency.ToTimeSpan().TotalSeconds);

            DateTime prevTradedDate = DateTime.Now.AddDays(-1); //todo fix
            var startDateTime = string.Format("{0}-{1}-{2}T13:30:00", prevTradedDate.Year, prevTradedDate.Month, prevTradedDate.Day);
            prevTradedDate = prevTradedDate.AddDays(1); // next day for end date
            var endDateTime = string.Format("{0}-{1}-{2}T13:30:00", prevTradedDate.Year, prevTradedDate.Month, prevTradedDate.Day);

            request.Set("startDateTime", startDateTime);
            request.Set("endDateTime", endDateTime);


            request.Set("gapFillInitialBar", true);

            session.SendRequest(request, null);
        }
开发者ID:leo90skk,项目名称:qdms,代码行数:24,代码来源:Bloomberg.cs

示例3: CreateRequest

        private Request CreateRequest(Session session)
        {
            var request = session.GetService("//blp/refdata").CreateRequest("HistoricalDataRequest");

            AddSecurities(request);
            AddFields(request);

            request.Set("startDate", _dateId.ToString());
            request.Set("endDate", _dateId.ToString());
            request.Set("periodicityAdjustment", "ACTUAL");
            request.Set("periodicitySelection", "DAILY"); // 1 data point per day
            request.Set("currency", "EUR"); // request px_last converted to euro

            return request;
        }
开发者ID:jbontik,项目名称:bloomberg_downloader,代码行数:15,代码来源:Program.cs

示例4: SendIntradayTickRequest

        private void SendIntradayTickRequest(Session session)
        {
            Service refDataService = session.GetService("//blp/refdata");
            Request request = refDataService.CreateRequest("IntradayTickRequest");

            request.Set("security", _dSecurity);

            // Add fields to request
            var eventTypes = request.GetElement("eventTypes");
            foreach (object t in _dEvents)
            {
                eventTypes.AppendValue((string)t);
            }

            // All times are in GMT
            request.Set("startDateTime", _dStartDateTime);
            request.Set("endDateTime", _dEndDateTime);

            if (_dConditionCodes)
            {
                request.Set("includeConditionCodes", true);
            }

            Console.WriteLine(@"Sending Request: " + request);
            session.SendRequest(request, null);
        }
开发者ID:rlyalko,项目名称:REVERSALS_v14,代码行数:26,代码来源:IntradayTick.cs

示例5: 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

示例6: RequestProcessor

        protected RequestProcessor(Session session,IRequestContract requestContract)
        {
            // get the configuration to process bloomberg request
            BloombergApiSessionConfig config = new BloombergApiSessionConfig();

            // TODO MOVE THIS CODE TO THE CONSTRUCTOR FOR PREPOSTING ITEMS OT THE REQUEST FIELDS
            // create the service
            Service refDataSvc = session.GetService(config.BbService);
            // get Request type
            var requestName = Enum.GetName(typeof(BloombergRequestServiceTypes), requestContract.RequestType);
            // create the request
            request = refDataSvc.CreateRequest(requestName);
        }
开发者ID:Rab815,项目名称:BBWebApi,代码行数:13,代码来源:RequestProcessor.cs

示例7: 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

示例8: 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

示例9: HandleServiceStatusEvent

 private void HandleServiceStatusEvent(Event eventobject, Session session)
 {
     if (!IsServiceOpenedEvent(eventobject)) return;
     var service = session.GetService(ServiceUri);
     OnServiceOpened(new ServiceOpenedEventArgs(service));
 }
开发者ID:tweakch,项目名称:TweakToolkit,代码行数:6,代码来源:SubscriptionBehaviourBase.cs


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