void StartBundleRuntime() // Start OSGi Core. { FileLogUtility.SetLogLevel(LogLevel.Debug); FileLogUtility.SetMaxFileSizeByMB(10); FileLogUtility.SetCreateNewFileOnMaxSize(true); var st = new Stopwatch(); st.Start(); var setting = new AddinEngineStartUpSetting(); AddinEngineHost.InitializeBundleRuntime(setting); SplashWindow.Instance.Show(); var bundleRuntime = AddinEngineHost.Runtime; bundleRuntime.AddService <Application>(this); AddinEngineHost.StartRuntime(); Exit += AppExit; _bundleRuntime = bundleRuntime; st.Stop(); MessageService.Instance.SendMessage("StartRuntime takes " + st.ElapsedMilliseconds + "ms"); StartupWorkbench(); }
private static void RunApplication() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //const string PAGE_NAME_LOGIN = "******"; FileLogUtility.SetFileLogEnabled(true); FileLogUtility.SetLogFileName("log.txt"); FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); Application.Run(new MainForm()); }
void StartBundleRuntime() // Start OSGi Core. { FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); var bundleRuntime = new BundleRuntime(); bundleRuntime.AddService <Application>(this); bundleRuntime.Start(); Startup += App_Startup; Exit += App_Exit; _bundleRuntime = bundleRuntime; }
public void StartBundleRuntime() { FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); FileLogUtility.Debug("WebSite is starting."); PropertyInfo buildManagerProp = typeof(BuildManager).GetProperty("TheBuildManager", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetProperty); if (buildManagerProp != null) { BuildManager buildManager = buildManagerProp.GetValue(null, null) as BuildManager; if (buildManager != null) { PropertyInfo toplevelAssembliesProp = typeof(BuildManager).GetProperty("TopLevelReferencedAssemblies", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty); if (toplevelAssembliesProp != null) { _topLevelReferencedAssemblies = toplevelAssembliesProp.GetValue(buildManager, null) as IList <Assembly>; } } } if (_topLevelReferencedAssemblies == null) { throw new Exception("Retrieve top level referenced assembiles of BuildManager failed."); } AddPreDefinedRefAssemblies(); // Set SQLCE compact before BundleRuntime starting. AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); InitPhysicalPaths(); BundleRuntime = CreateBundleRuntime(); BundleRuntime.Instance.Framework.EventManager.AddBundleEventListener(BundleEventListener, true); FileLogUtility.Debug("Framework is starting."); StateTimeoutToRestart(BundleRuntimeState.Started); BundleRuntime.Start(); FileLogUtility.Debug("Framework is started."); FileLogUtility.Debug("WebSite is started."); ControllerBuilder.Current.SetControllerFactory(new BundleRuntimeControllerFactory()); RegisterGlobalFilters(GlobalFilters.Filters); }
/// <summary> /// 应用启动时处理函数。该函数用于初始化TopLevelReferncedAssemblies,并将UIShell.OSGi和UIShell.OSGi.WebExtension这两个程序集添加到该属性。 /// 同时,启动Bundle运行时。 /// </summary> /// <param name="sender">Sender。</param> /// <param name="e">事件参数。</param> protected virtual void Application_Start(object sender, EventArgs e) { FileLogUtility.Init(LogName, LogLocation); FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); FileLogUtility.Debug("WebSite is starting."); AddPreDefinedRefAssemblies(); AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); BundleRuntime = CreateBundleRuntime(); BundleRuntime.Instance.Framework.EventManager.AddBundleEventListener( new EventHandler <BundleStateChangedEventArgs>(BundleRuntimeHttpHostHelper.RefreshBundleTopLevelReferencedAssembliesByEvent), true); FileLogUtility.Debug("Framework is starting."); StateTimeoutToRestart(BundleRuntimeState.Started); BundleRuntime.Start(); FileLogUtility.Debug("Framework is started."); FileLogUtility.Debug("WebSite is started."); }
private void StartBundleRuntime() // Start OSGi Core. { FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); var bundleRuntime = new BundleRuntime(); bundleRuntime.EnableAssemblyMultipleVersions = false; bundleRuntime.Framework.EventManager.AddBundleEventListener(BundleStateChangedHandler, true); bundleRuntime.Framework.EventManager.AddFrameworkEventListener(FrameworkStateChangedHandler); bundleRuntime.AddService <Application>(this); bundleRuntime.Start(); bundleRuntime.Framework.EventManager.RemoveBundleEventListener(BundleStateChangedHandler, true); bundleRuntime.Framework.EventManager.RemoveFrameworkEventListener(FrameworkStateChangedHandler); Startup += App_Startup; Exit += App_Exit; _bundleRuntime = bundleRuntime; }
private static void RunApplication() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); const string PAGE_NAME_LOGIN = "******"; FileLogUtility.SetFileLogEnabled(true); FileLogUtility.SetLogFileName("log.txt"); FileLogUtility.SetLogLevel(LogLevel); FileLogUtility.SetMaxFileSizeByMB(MaxLogFileSize); FileLogUtility.SetCreateNewFileOnMaxSize(CreateNewLogFileOnMaxSize); using (BundleRuntime bundleRuntime = new BundleRuntime()) { bundleRuntime.Start(); // Get the page flow service. IPageFlowService pageFlowService = bundleRuntime.GetFirstOrDefaultService <IPageFlowService>(); if (pageFlowService == null) { throw new Exception(Resources.IPageFlowServiceServiceNotFound); } // Assert the first page node. if (string.IsNullOrEmpty(pageFlowService.FirstPageNodeValue) || string.IsNullOrEmpty(pageFlowService.FirstPageNodeName) || pageFlowService.FirstPageNodeOwner == null) { throw new Exception(Resources.CanNotFindAnAvailablePageNode); } // Load the form type of first page node. Type formType = pageFlowService.FirstPageNodeOwner.LoadClass(pageFlowService.FirstPageNodeValue); if (formType == null) { throw new Exception(string.Format(Resources.CanNotLoadTypeFromBundle, pageFlowService.FirstPageNodeValue, pageFlowService.FirstPageNodeOwner.SymbolicName)); } // Create the form instance of first page node and show it. Form formInstance = System.Activator.CreateInstance(formType) as Form; if (formInstance == null) { throw new Exception(string.Format(Resources.TypeIsNotWindowsFormType, pageFlowService.FirstPageNodeValue, pageFlowService.FirstPageNodeOwner.SymbolicName)); } // If first page node name is 'Login' then, show the dialog and then run application. if (pageFlowService.FirstPageNodeName.Equals(PAGE_NAME_LOGIN)) { DialogResult result = formInstance.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { PageNode nextNode = pageFlowService.GetNextPageNode(pageFlowService.FirstPageNodeName); if (nextNode != null) { Type mainPageFormType = nextNode.Bundle.LoadClass(nextNode.Value); if (mainPageFormType == null) { throw new Exception(string.Format(Resources.CanNotLoadTypeFromBundle, nextNode.Value, nextNode.Bundle.SymbolicName)); } Form mainPageForm = System.Activator.CreateInstance(mainPageFormType) as Form; Application.Run(mainPageForm); } } } else // Run the application directly. { Application.Run(formInstance); } } }