Ejemplo n.º 1
0
        /// <summary>
        /// The get environment.
        /// </summary>
        /// <param name="executionParam">
        /// The execution param.
        /// </param>
        /// <param name="globalContext">
        /// The global context.
        /// </param>
        /// <returns>
        /// The <see cref="MonitorEnvironment"/>.
        /// </returns>
        private MonitorEnvironment GetEnvironment(ExecutionParam executionParam, WinFormGlobalContext globalContext)
        {
            var pluginResolver = new AssemblyPluginResolver(this.Logger);
            pluginResolver.LoadPlugins();
            var configStore = new FileConfigStore(AppUtil.GetLocalDataPath(this.ENV_CONFIG_FILENAME), pluginResolver, this.Logger);

            MonitorEnvironment env = configStore.LoadEnv();

            if (env == null || env.ArchiveManager == null || env.FareDatabase == null || env.FareDataProvider == null)
            {
                env = new MonitorEnvironment(configStore, pluginResolver, new BackgroundServiceManager(this.Logger), this.Logger);
                globalContext.AddServices(env);
                using (var configDialog = new EnvConfiguratorDialog(env, executionParam))
                {
                    if (configDialog.ShowDialog() == DialogResult.OK)
                    {
                        env = configDialog.ResultEnvironment;
                    }
                    else
                    {
                        env.Close();
                        env = null;
                    }
                }
            }

            return env;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// The btn config_ click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void btnConfig_Click(object sender, EventArgs e)
 {
     using (var configDialog = new EnvConfiguratorDialog(AppContext.MonitorEnvironment, this._executionParam))
     {
         var result = configDialog.ShowDialog(this);
         if (result == DialogResult.OK)
         {
             var resultEnv = configDialog.ResultEnvironment;
             this._executionParam = configDialog.ResultParam;
             WinFormGlobalContext.GetInstance().SetEnvironment(resultEnv);
             this.InitializeView();
             this.ReloadRoutes();
         }
     }
 }