コード例 #1
0
        public void AppStarting(object application, BaseAppSetting appsetting,
                                BaseGlobalVariable globalVariable)
        {
            TkAdoData.Culture = appsetting.Culture ?? CultureInfo.CurrentCulture;

            BaseXmlPlugInFactory factory = globalVariable.FactoryManager.GetCodeFactory(
                CodeTablePlugInFactory.REG_NAME).Convert <BaseXmlPlugInFactory>();

            if (factory != null)
            {
                factory.FailGetRegItem += AddStandardCodeTable;

                XmlPlugInAttribute codeTableAttr = new XmlPlugInAttribute(CodeTablePlugInFactory.PATH,
                                                                          typeof(CodeTableXml))
                {
                    SearchPattern = "*CodeTable.xml"
                };
                factory.AddXmlPlugInAttribute(codeTableAttr);

                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  StandardCodeTableConfig.BASE_CLASS, typeof(InternalStandardDbCodeTable)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5CodeTableConfig.BASE_CLASS, typeof(InternalTk5DbCodeTable)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  SqlCodeTableConfig.BASE_CLASS, typeof(InternalSqlCodeTable)));
            }

            factory = globalVariable.FactoryManager.GetCodeFactory(
                EasySearchPlugInFactory.REG_NAME).Convert <BaseXmlPlugInFactory>();

            if (factory != null)
            {
                XmlPlugInAttribute easySearchAttr = new XmlPlugInAttribute(CodeTablePlugInFactory.PATH,
                                                                           typeof(EasySearchXml))
                {
                    SearchPattern = "*EasySearch.xml"
                };
                factory.AddXmlPlugInAttribute(easySearchAttr);

                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5EasySearchConfig.BASE_CLASS, typeof(InternalTk5DbEasySearch)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5CodeTableEasySearchConfig.BASE_CLASS, typeof(InternalTk5DbCodeTableEasySearch)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5Level0CodeTableEasySearchConfig.BASE_CLASS,
                                                  typeof(InternalTk5DbLevel0CodeTableEasySearch)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5LevelCodeTableEasySearchConfig.BASE_CLASS,
                                                  typeof(InternalTk5DbLevelCodeTableEasySearch)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  Tk5TreeEasySearchConfig.BASE_CLASS,
                                                  typeof(InternalTk5DbTreeEasySearch)));
                factory.AddBaseClassAttribute(new XmlBaseClassAttribute(
                                                  SqlEasySearchConfig.BASE_CLASS,
                                                  typeof(InternalTk5DbSqlEasySearch)));
            }
        }
コード例 #2
0
        protected override void ReadConfig(BaseAppSetting appSetting)
        {
            WebAppSetting webSetting = appSetting.Convert <WebAppSetting>();
            string        fileName   = Path.Combine(appSetting.XmlPath, webSetting.ConfigFile);

            if (File.Exists(fileName))
            {
                Config.ReadXmlFromFile(fileName);
            }
        }
コード例 #3
0
        private void ProcessConfigDefaultValue(BaseAppSetting appSetting)
        {
            ConfigTypeFactory typeFactory = FactoryManager.GetCodeFactory(
                ConfigTypeFactory.REG_NAME).Convert <ConfigTypeFactory>();

            Config.RegisterConfig(typeFactory);
            DefaultValueTypeFactory defaultFactory = FactoryManager.GetCodeFactory(
                DefaultValueTypeFactory.REG_NAME).Convert <DefaultValueTypeFactory>();

            DefaultValue.RegisterConfig(defaultFactory);

            ReadDefaultConfig(appSetting);
            ReadConfig(appSetting);
        }
コード例 #4
0
        //internal void InitialIndexer()
        //{
        //    fExceptionIndexer = new ExceptionIndexer();
        //}

        //internal string GetExceptionLogName(Exception ex)
        //{
        //    string fileName = string.Format(ObjectUtil.SysCulture, "{0}_{1}.xml",
        //        ex.GetType().Name, fExceptionIndexer.NextIndex());
        //    return Path.Combine(BaseAppSetting.Current.ErrorPath, fileName);
        //}

        protected override void ReadDefaultConfig(BaseAppSetting appSetting)
        {
            WebAppSetting webSetting = appSetting.Convert <WebAppSetting>();
            string        fileName   = Path.Combine(appSetting.XmlPath, webSetting.DefaultValueFile);

            if (File.Exists(fileName))
            {
                WebDefaultValue.ReadXmlFromFile(fileName);
            }
            else
            {
                WebDefaultValue.OnReadObject();
            }
        }
コード例 #5
0
 protected virtual void ReadConfig(BaseAppSetting appSetting)
 {
 }
コード例 #6
0
        public void Initialize(BaseAppSetting appSetting, object application)
        {
            TkDebug.AssertArgumentNull(appSetting, "appSetting", this);

            fManager = new AssemblyManager();
            if (NeitherContext)
            {
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            }

            // 初始化AppPath下所有的Assembly
            AppPathAssembly = CreateAppPathAssembly(appSetting.AppPath, fManager);
            TkDebug.AssertNotNull(AppPathAssembly, "CreateAppPathAssembly返回为空", this);

            //fLoadedAssembly = AppPathAssembly.LoadedAssembly;
            // AppPath下的Assembly中查找添加PlugInFactory
            AppPathAssembly.AddPlugInFactory(FactoryManager);
            // 执行AppPath下的IInitialization
            var inits = AppPathAssembly.CreateInitializations();

            foreach (var item in inits)
            {
                try
                {
                    TkTrace.LogInfo($"执行{item.GetType()}的AppStarting");
                    item.AppStarting(application, appSetting, this);
                }
                catch (Exception ex)
                {
                    HandleStartedExeception("SAppStarting", item.GetType(), ex);
                }
            }

            // 搜索Code插件
            foreach (var assembly in AppPathAssembly)
            {
                if (assembly == ToolkitConst.TOOLKIT_CORE_ASSEMBLY)
                {
                    continue;
                }
                LoadAssembly(assembly);
            }

            fPlugIn = new PlugInAssembly(appSetting, fManager);
            //IEnumerable<AssemblyName> moduleAssembyNames = GetModuleAssemblies(appSetting);
            foreach (var assemblyName in fPlugIn)
            {
                if (!fManager.Contains(assemblyName.Name))
                {
                    var assembly = fPlugIn.LoadAssembly(fManager, NeitherContext, assemblyName);
                    //Assembly assembly = CreateAssembly(assemblyName);
                    //fLoadedAssemblyDict.Add(assembly.FullName, assembly);
                    if (assembly != null)
                    {
                        LoadAssembly(assembly);
                        //fLoadedAssembly.Add(assemblyName.FullName);
                    }
                }
            }

            if (NeitherContext)
            {
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }

            // 搜索Xml插件
            var factories = FactoryManager.CodeFactories;

            foreach (var factory in factories)
            {
                factory.SearchXmlPlugIn(appSetting.XmlPath);
            }

            ProcessConfigDefaultValue(appSetting);
            foreach (var item in inits)
            {
                try
                {
                    TkTrace.LogInfo($"执行{item.GetType()}的AppStarted");
                    item.AppStarted(application, appSetting, this);
                }
                catch (Exception ex)
                {
                    HandleStartedExeception("SAppStarted", item.GetType(), ex);
                }
            }

            LogPlugError(fPlugInErrorLog);
        }
コード例 #7
0
 public void AppStarted(object application, BaseAppSetting appsetting,
                        BaseGlobalVariable globalVariable)
 {
 }
コード例 #8
0
 public void AppStarting(object application, BaseAppSetting appsetting, BaseGlobalVariable globalVariable)
 {
     TkWebApp.Culture = appsetting.Culture ?? CultureInfo.CurrentCulture;
 }