예제 #1
0
        private void insatllPendingModules(IPersistenceManager pManager)
        {
            if (!AppConfiguration.CreateDatabase && ModuleManager.HasPendingInstallation())
            {
                try
                {
                    pManager.UpdateSchema();
                }
                catch (Exception ex)
                { }
                // When the pending modules' schemas are ported, their potential seed data should be generated.
                // This is done through calling Install method.
                foreach (var moduleId in ModuleManager.PendingModules())
                {
                    // The install method of the plugin is called once and only once.
                    // It generates the seed data and other module specific initializations
                    try
                    {
                        ModuleManager.GetModuleInfo(moduleId).Plugin.Install();
                    }
                    catch (Exception ex)
                    {
                        string message = string.Format("Unable to install module '{0}' while in pending state. Details: {1}.", moduleId, ex.Message);
                        LoggerFactory.GetFileLogger().LogCustom(message);
                        //throw new Exception(message);
                    }

                    // For security reasons, pending modules go to the "inactive" status after schema export.
                    // An administrator can endable them via the management console
                    try
                    {
                        ModuleManager.Disable(moduleId);
                    }
                    catch (Exception ex)
                    {
                        string message = string.Format("Unable to disable module '{0}' after recovering from pending state. Details: {1}.", moduleId, ex.Message);
                        LoggerFactory.GetFileLogger().LogCustom(message);
                        //throw new Exception(message);
                    }
                }
            }
        }