Example #1
0
 void IDisposable.Dispose()
 {
     if (!_isDisposed)
     {
         Dispose();
         GC.SuppressFinalize(this);
         State       = BundleRuntimeState.Disposed;
         _isDisposed = true;
     }
 }
 /// <summary>
 /// 释放
 /// </summary>
 void IDisposable.Dispose()
 {
     if (this._isDisposed)
     {
         return;
     }
     GC.SuppressFinalize(this);
     this.State       = BundleRuntimeState.Disposed;
     this._isDisposed = true;
 }
Example #3
0
 /// <summary>
 /// Restart the website if the bundle runtime state is still in specified state.
 /// </summary>
 /// <param name="expectedState">Specified state.</param>
 private void StateTimeoutToRestart(BundleRuntimeState expectedState)
 {
     _appStartingTimeout = new Timer(delegate(object state)
     {
         _appStartingTimeout.Dispose();
         if (BundleRuntime.State != (BundleRuntimeState)state)
         {
             FileLogUtility.Warn(string.Format("Fail to start/stop framework. BundleRuntime state is not in '{0}'.", state));
             RestartAppDomain();
             return;
         }
         FileLogUtility.Inform(string.Format("Dectect that the framework is in '{0}' state.", state));
     },
                                     expectedState,
                                     90000,
                                     -1);
 }
 /// <summary>
 /// 停止
 /// </summary>
 public void Stop()
 {
     if (!this._started)
     {
         return;
     }
     this.State = BundleRuntimeState.Stopping;
     try
     {
         this.Framework.Shutdown();
     }
     catch (Exception ex)
     {
         FileLogUtility.Error("StopTheFrameworkFailed" + ex.Message);
     }
     this.State    = BundleRuntimeState.Stopped;
     this._started = false;
 }
Example #5
0
 public void Stop()
 {
     if (_started)
     {
         State = BundleRuntimeState.Stopping;
         try
         {
             Framework.Stop();
         }
         catch (Exception exception)
         {
             FileLogUtility.Error(Messages.StopTheFrameworkFailed);
             FileLogUtility.Error(exception);
         }
         State    = BundleRuntimeState.Stopped;
         _started = false;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            BundleRuntime      br    = BundleRuntime.Instance;
            BundleRuntimeState state = br.State;

            switch (state)
            {
            case BundleRuntimeState.Started:
            case BundleRuntimeState.Starting:
                hintLabel.Text = "系统正在启动,请稍等片刻,然后点击“返回首页”按钮再次访问。";
                break;

            case BundleRuntimeState.Stopped:
            case BundleRuntimeState.Stopping:
            case BundleRuntimeState.Disposed:
                hintLabel.Text = "系统正在终止运行或已经停止运行,请稍等片刻,然后点击“返回首页”按钮再次访问。";
                break;
            }
        }
Example #7
0
 public void Start(string[] args)
 {
     if (!_started)
     {
         StartArgs = args;
         State     = BundleRuntimeState.Starting;
         try
         {
             Framework.Start();
             State    = BundleRuntimeState.Started;
             _started = true;
         }
         catch (Exception exception)
         {
             State    = BundleRuntimeState.Stopped;
             _started = false;
             FileLogUtility.Error(Messages.StartTheFrameworkFailed);
             FileLogUtility.Error(exception);
         }
     }
 }
Example #8
0
 /// <summary>
 /// Restart the website if the bundle runtime state is still in specified state.
 /// </summary>
 /// <param name="expectedState">Specified state.</param>
 private void StateTimeoutToRestart(BundleRuntimeState expectedState)
 {
     _appStartingTimeout = new Timer(
         state =>
     {
         _appStartingTimeout.Dispose();
         if (BundleRuntime.State != (BundleRuntimeState)state)
         {
             // If website is not started within 90 seconds, it will be restarted immediately.
             FileLogUtility.Warn(string.Format("Fail to start/stop framework. BundleRuntime state is not in '{0}'.", state));
             RestartAppDomain();
         }
         else
         {
             // If website is not started within 90 seconds, it will be restarted immediately.
             FileLogUtility.Inform(string.Format("Dectect that the framework is in '{0}' state.", state));
         }
     },
         expectedState,
         StateTimeOut * 1000,
         -1);
 }
        /// <summary>
        /// 启动服务
        /// </summary>
        /// <param name="args">参数</param>
        public void Start(string[] args)
        {
            if (this._started)
            {
                return;
            }
            this.StartArgs = args;
            this.State     = BundleRuntimeState.Starting;
            try
            {
                this.Framework.Launch();

                //加载配置文件和组件
                GetBundleDatas(_registeredBunldeCache);
                //根据组件信息 安装 组件
                InstallAllBundlesByBundleData(_registeredBunldeCache);
                //启动所有已经安装的组件
                StartAllBundles();

                switch (BundleRuntimeType)
                {
                case BundleRuntimeType.AspNet:
                    GetHostAssembly();
                    break;
                }

                this.State    = BundleRuntimeState.Started;
                this._started = true;
            }
            catch (Exception ex)
            {
                this.State    = BundleRuntimeState.Stopped;
                this._started = false;
                FileLogUtility.Error("start  is Error!" + ex.Message);
            }
        }