public SchemaManager(ISchemaProvider provider, IZetboxContext schema, IZetboxContext savedSchema, ZetboxConfig config) { this.config = config; this.schema = schema; this.db = provider; this.Case = new Cases(schema, provider, savedSchema); }
public FileViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IZetboxContext dataCtx, ViewModel parent, File obj) : base(appCtx, dataCtx, parent, obj) { this.File = obj; }
public BootstrapperService(ZetboxConfig config) { if (config == null) throw new ArgumentNullException("config"); Log.DebugFormat("Starting BootstrapperService from {0}", config.ConfigFilePath); this.config = config; }
public static ContainerBuilder CreateContainerBuilder(ZetboxConfig config, IEnumerable<ZetboxConfig.Module> modules) { if (config == null) throw new ArgumentNullException("config"); var builder = new ContainerBuilder(); // register the configuration builder .RegisterInstance(config) .ExternallyOwned() .SingleInstance(); foreach (var m in (modules ?? new ZetboxConfig.Module[] { })) { try { var moduleDescriptor = FindModule(config, m.TypeName); if (moduleDescriptor == null) { if (config.IsFallback) { // Don't report an error - fallback case. Dev Environments require this! Directory may not exits yet. Logging.Log.WarnFormat(string.Format("Fallback, ignoring error: Module loading aborted: cannot find '{0}'", m.TypeName)); continue; } else { throw new ConfigurationException(string.Format("Module loading aborted: cannot find '{0}'", m.TypeName)); } } if (config.IsFallback && moduleDescriptor.NotOnFallback) { Logging.Log.InfoFormat("Skipped module [{0}] in fallback mode", m.TypeName); } else { Logging.Log.InfoFormat("Adding module [{0}]", m.TypeName); builder.RegisterModule((IModule)Activator.CreateInstance(Type.GetType(moduleDescriptor.TypeName, true))); } } catch (Exception ex) { Logging.Log.Error(String.Format("Unable to register Module [{0}] from Config", m.TypeName), ex); throw; } } foreach (var file in GetAssemblyFiles(config)) { foreach (var m in FindModules(ModuleDefinition.ReadModule(file)).Where(m => m.IsAutoloaded)) { Logging.Log.InfoFormat("Adding autoloaded module [{0}]", m.TypeName); builder.RegisterModule((IModule)Activator.CreateInstance(Type.GetType(m.TypeName, true))); } } return builder; }
public Launcher(Func<ContextIsolationLevel, IZetboxContext> ctxFactory, IViewModelFactory mdlFactory, IFrozenContext frozenCtx, ZetboxConfig cfg, IPerfCounter perfCounter) { this.frozenCtx = frozenCtx; this.ctxFactory = ctxFactory; this.mdlFactory = mdlFactory; this.cfg = cfg; this.perfCounter = perfCounter; }
public SchemaManager(ISchemaProvider provider, IZetboxContext schema, IZetboxContext savedSchema, ZetboxConfig config, IEnumerable<IGlobalMigrationFragment> globalMigrationFragments, IEnumerable<IMigrationFragment> migrationFragments) { this.config = config; this.schema = schema; this.db = provider; this._globalMigrationFragments = globalMigrationFragments; this.Case = new Cases(schema, provider, savedSchema, migrationFragments); }
public FileViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IZetboxContext dataCtx, ViewModel parent, File obj) : base(appCtx, dataCtx, parent, obj) { this.File = obj; // When the context was saved, no more changes are allowed. this.DataContext.IsModifiedChanged += new EventHandler(DataContext_IsModifiedChanged); }
/// <summary> /// Creates the Connectionstring. /// </summary> /// <returns></returns> private static string BuildConnectionString(ZetboxConfig config) { // Build connectionString var connectionString = config.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey); StringBuilder sb = new StringBuilder(); sb.AppendFormat("metadata=res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.csdl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.msl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.{0}.ssdl;", connectionString.SchemaProvider); sb.AppendFormat("provider={0};", connectionString.DatabaseProvider); sb.AppendFormat("provider connection string='{0}'", connectionString.ConnectionString); return sb.ToString(); }
/// <summary> /// Creates the Connectionstring. /// <remarks>Format is: metadata=res://*;provider={provider};provider connection string='{Provider Connectionstring}'</remarks> /// </summary> /// <returns></returns> private static string BuildConnectionString(ZetboxConfig config) { // Build connectionString // metadata=res://*;provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS;Initial Catalog=Zetbox;Integrated Security=True;MultipleActiveResultSets=true;' var connectionString = config.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey); StringBuilder sb = new StringBuilder(); sb.AppendFormat("metadata=res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.csdl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.msl|res://Zetbox.Objects.EfImpl/Zetbox.Objects.EfImpl.Model.{0}.ssdl;", connectionString.SchemaProvider); sb.AppendFormat("provider={0};", connectionString.DatabaseProvider); sb.AppendFormat("provider connection string='{0}'", connectionString.ConnectionString); return sb.ToString(); }
public void Start(ZetboxConfig config) { if (container != null) { throw new InvalidOperationException("already started"); } Logging.Configure(); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); container = Program.CreateMasterContainer(config); wcfServer = container.Resolve<IZetboxAppDomain>(); wcfServer.Start(config); }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, IZetboxContext dataCtx, ViewModel parent, Func<IZetboxContext> workingCtxFactory, ObjectClass type, Func<IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, dataCtx, parent, workingCtxFactory, type, qry) { }
public TreeItemInstanceListViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IFileOpener fileOpener, ITempFileService tmpService, Lazy<IUIExceptionReporter> errorReporter, IZetboxContext dataCtx, ViewModel parent, ObjectClass type, Func<IQueryable> qry) : base(appCtx, config, fileOpener, tmpService, errorReporter, dataCtx, parent, type, qry) { }
public WcfServer(AutofacServiceHostFactory factory, AutofacWebServiceHostFactory webFactory, ZetboxConfig config) { if (factory == null) { throw new ArgumentNullException("factory"); } if (webFactory == null) { throw new ArgumentNullException("webFactory"); } if (config == null) throw new ArgumentNullException("config"); _defaultConfig = config; _mainHost = factory.CreateServiceHost(typeof(ZetboxService).AssemblyQualifiedName, new Uri[] { }); _mainHost.UnknownMessageReceived += new EventHandler<UnknownMessageReceivedEventArgs>(host_UnknownMessageReceived); _mainHost.Faulted += host_Faulted; _mainHost.Closed += host_Closed; _mainHost.Opened += host_Opened; }
/// <summary> /// Initialises a new instance of the BaseCustomActionsManager class /// using the specified extra suffix and the assembly of the actual type of this class. /// </summary> protected BaseCustomActionsManager(ILifetimeScope container, string extraSuffix, IEnumerable<ImplementorAssembly> assemblies) { if (container == null) { throw new ArgumentNullException("container"); } if (assemblies == null) { throw new ArgumentNullException("assemblies"); } _container = container; // Each assembly only once. Thus assemblies will be registered by modules throug Autofac it cannot be guaranteed that this will happen only once per assembly. _assemblies = assemblies.Distinct().ToList(); ExtraSuffix = extraSuffix; ImplementationAssemblyName = this.GetType().Assembly.FullName; container.TryResolve<IAssetsManager>(out _assetsMgr); cfg = container.Resolve<ZetboxConfig>(); }
/// <summary> /// Deserialize from a TextReader /// </summary> /// <param name="filename">configuration file w/ or w/o path</param> /// <param name="fallbackBaseName">A configuration name to search in the %zenv% environmentvariable, if none is specified in the first parameter</param> /// <returns>Current Configuration</returns> public static ZetboxConfig FromFile(string filename, string fallbackBaseName) { filename = String.IsNullOrEmpty(filename) ? GetDefaultConfigName(fallbackBaseName) : filename; if (!File.Exists(filename)) { throw new FileNotFoundException(String.Format("Configuration file [{0}] not found", filename), filename); } using (var r = new XmlTextReader(filename)) { ZetboxConfig result = (ZetboxConfig)xml.Deserialize(r); result.ConfigFilePath = filename; return(result); } }
public void Start(ZetboxConfig config) { if (config == null) { throw new ArgumentNullException("config"); } if (container != null) { throw new InvalidOperationException("already started"); } Logging.Configure(); AssemblyLoader.Bootstrap(AppDomain.CurrentDomain, config); container = Program.CreateMasterContainer(config); IServiceControlManager scm = null; if (container.TryResolve<IServiceControlManager>(out scm)) { Logging.Log.Info("Starting Zetbox Services"); scm.Start(); } else { Logging.Log.Info("Service control manager not registered"); } }
public static ContainerBuilder CreateContainerBuilder(ZetboxConfig config, string[] modules) { if (config == null) throw new ArgumentNullException("config"); var builder = new ContainerBuilder(); // register the configuration builder .RegisterInstance(config) .ExternallyOwned() .SingleInstance(); foreach (var m in modules ?? new string[] { }) { try { Logging.Log.InfoFormat("Adding module [{0}]", m); #if MONO // workaround for https://bugzilla.novell.com/show_bug.cgi?id=661461 var parts = m.Split(",".ToCharArray(), 2); if (parts.Length == 2) { var assemblyName = parts[1]; System.Reflection.Assembly.Load(assemblyName); } #endif builder.RegisterModule((IModule)Activator.CreateInstance(Type.GetType(m, true))); } catch (Exception ex) { Logging.Log.Error(String.Format("Unable to register Module [{0}] from Config", m), ex); throw; } } return builder; }
public void Start(ZetboxConfig config) { using (Logging.Log.DebugTraceMethodCall("Start", "Starting AppDomain for Server")) { serverDomain = AppDomain.CreateDomain("ServerAppDomain", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); AssemblyLoader.Bootstrap(serverDomain, config); serverManager = (IZetboxAppDomain)serverDomain.CreateInstanceAndUnwrap( "Zetbox.Server.Service", "Zetbox.Server.Service.ServerManager"); serverManager.Start(config); if (clientSponsor == null) { clientSponsor = new ClientSponsor(); clientSponsor.RenewalTime = TimeSpan.FromMinutes(2); } clientSponsor.Register(serverManager as MarshalByRefObject); } }
public void Start(ZetboxConfig config) { if (config == null) { throw new ArgumentNullException("config"); } using (Logging.Log.DebugTraceMethodCall("Start", "Starting AppDomain for Server")) { var serverConfig = new ZetboxConfig() { ConfigFilePath = config.ConfigFilePath, ConfigName = config.ConfigName, EnableShadowCopy = config.EnableShadowCopy, HostType = HostType.Server, IsFallback = false, Server = config.Server, }; serverDomain = AppDomain.CreateDomain("ServerAppDomain", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); AssemblyLoader.Bootstrap(serverDomain, serverConfig); serverManager = (IZetboxAppDomain)serverDomain.CreateInstanceAndUnwrap( "Zetbox.Server.Service", "Zetbox.Server.Service.ServerManager"); serverManager.Start(serverConfig); if (clientSponsor == null) { clientSponsor = new ClientSponsor(); clientSponsor.RenewalTime = TimeSpan.FromMinutes(2); } clientSponsor.Register(serverManager as MarshalByRefObject); } }
/// <summary> /// Starts the WCF Server in the background. If the server hasn't /// started successfully within 40 seconds, it is aborted and an /// <see cref="InvalidOperationException"/> is thrown. /// </summary> /// <param name="config">the loaded configuration for the Server</param> public void Start(ZetboxConfig config) { if (config == null) throw new ArgumentNullException("config"); if (config.AdditionalCommandlineOptions.ContainsKey(ServerModule.NoWcfKey)) { Log.Info("Not starting embedded WCF Server. As requested by -nowcf."); } else { using (Log.InfoTraceMethodCall("Starting Server")) { serviceThread = new Thread(new ThreadStart(this.RunWCFServer)); serviceThread.Start(); if (!serverStarted.WaitOne(40 * 1000, false)) { throw new InvalidOperationException("Server did not start within 40 sec."); } } } }
public CmdLineData(ZetboxConfig config, string prototype, string description, object dataKey, int maxValueCount) : base(prototype, description, maxValueCount) { _config = config; _dataKey = dataKey; }
public CmdLineAction(ZetboxConfig config, string prototype, string description, int maxValueCount) : base(prototype, description, maxValueCount) { _config = config; }
public WaitAction(ZetboxConfig config) : base(config, "wait", "let the process wait for user input before exiting", 0) { }
public SimpleCmdLineFlag(ZetboxConfig config, string prototype, string description, object dataKey) : base(config, prototype, description, dataKey, 0) { }
public SimpleCmdLineAction(ZetboxConfig config, string prototype, string description, Action<ILifetimeScope, string[]> listAction) : base(config, prototype, description, 1) { _listAction = listAction; }
public SimpleCmdLineAction(ZetboxConfig config, string prototype, string description, Action<ILifetimeScope, string> action) : base(config, prototype, description, 1) { _listAction = (scope, args) => { if (args.Length == 0) { action(scope, null); } else { args.ForEach(arg => action(scope, arg)); } }; }
public ServerConfigViewModel(ZetboxConfig.ServerConfig cfg) { _cfg = cfg; }
public ImageViewModel( IViewModelDependencies appCtx, ZetboxConfig config, IZetboxContext dataCtx, ViewModel parent, File obj) : base(appCtx, config, dataCtx, parent, obj) { }
public HelpAction(ZetboxConfig config) : base(config, "help", "prints this help", 0) { }
internal static IContainer CreateMasterContainer(ZetboxConfig config) { var builder = Zetbox.API.Utils.AutoFacBuilder.CreateContainerBuilder(config, config.Server.Modules); builder.RegisterType<WindowsService>().SingleInstance(); // register deployment-specific components if (ConfigurationManager.GetSection("servercomponents") != null) { builder.RegisterModule(new ConfigurationSettingsReader("servercomponents")); } var container = builder.Build(); container.ApplyPerfCounterTracker(); API.AppDomainInitializer.InitializeFrom(container); return container; }
public SimpleCmdLineAction(ZetboxConfig config, string prototype, string description, Action<ILifetimeScope> action) : base(config, prototype, description, 0) { _listAction = (scope, args) => { action(scope); }; }