Esempio n. 1
0
        public void Init()
        {
            try
            {
                log.Info("SOA 2.0 Service Initialization", "SOA 2.0 Service is initializing...",
                         new Dictionary <string, string>
                {
                    { "StartUp", "SOA2.0" },
                    { "ErrorCode", "FXD300049" }
                });

                if (Instance != null)
                {
                    throw new InvalidDataException("AppHostBase.Instance has already been set");
                }

                Instance = this;

                var serviceManager = EndpointHost.Config.ServiceManager;
                if (serviceManager != null)
                {
                    serviceManager.Init();//服务初始化 route controller action
                    Configure(EndpointHost.Config.ServiceManager.Container);
                }
                else
                {
                    Configure(null);
                }

                EndpointHost.AfterInit();

                // periodically send metrics
                var mTimer = new Timer();
                mTimer.Interval  = DEFAULT_METRIC_SENDING_INTERVAL;
                mTimer.Enabled   = true;
                mTimer.AutoReset = true;
                mTimer.Elapsed  += new ElapsedEventHandler(sendMetrics);

                StartUpTime = DateTime.Now;

                //序列化日期
                JsConfig.UseStandardLongDateTime();

                log.Info("SOA 2.0 Service Initialization", "SOA 2.0 Service has been initialized.",
                         new Dictionary <string, string>
                {
                    { "StartUp", "SOA2.0" },
                    { "ErrorCode", "FXD300050" }
                });
            }
            catch (Exception ex)
            {
                log.Error("Error occurred while initializing SOA 2.0 Service", ex,
                          new Dictionary <string, string>
                {
                    { "StartUp", "SOA2.0" },
                    { "ErrorCode", "FXD300086" }
                });
                throw;
            }
        }