Beispiel #1
0
        private static void Initialize()
        {
            Log4NetLoggerAdapter adapter = new Log4NetLoggerAdapter();

            LogManager.AddLoggerAdapter(adapter);

            ICacheProvider provider = new RuntimeMemoryCacheProvider();

            CacheManager.SetProvider(provider, CacheLevel.First);

            IServicesBuilder builder = new ServicesBuilder();

            try
            {
                IServiceCollection services = builder.Build();

                services.AddLog4NetServices();
                services.AddDataServices();
                services.AddImplementServices();
                services.AddMdSmsServices();
                //services.AddJPushServices();


                IFrameworkInitializer initializer = new FrameworkInitializer();
                initializer.Initialize(new MvcAutofacIocBuilder(services));
                initializer.Initialize(new WebApiAutofacIocBuilder(services));
                //initializer.Initialize(new SignalRAutofacIocBuilder(services));
            }

            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
     _logger = LogManager.GetLogger(this);
     _logger.Info("App Startup");
     ServiceLocator.ClientEngine.Start();
 }
 /// <summary>
 /// 开始初始化基础日志
 /// </summary>
 /// <param name="config">日志配置信息</param>
 public void Initialize(LoggingConfig config)
 {
     LogManager.SetEntryInfo(config.EntryConfig.Enabled, config.EntryConfig.EntryLogLevel);
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
     //foreach (LoggingAdapterConfig adapterConfig in config.BasicLoggingConfig.AdapterConfigs)
     //{
     //    SetLoggingFromAdapterConfig(adapterConfig);
     //}
 }
Beispiel #4
0
        ///// <summary>
        ///// 加载应用程序集
        ///// </summary>
        ///// <param name="folder"></param>
        //public override void LoadAssemblies()
        //{
        //    if (PlusAssemblysList == null)
        //        PlusAssemblysList = new List<PluginDescriptor>();
        //    else
        //        PlusAssemblysList.Clear();

        //    #region 插件文件目录
        //    var plusFilesDirectoryInfo = new DirectoryInfo(SitePaths.PlusFilesDirPath);
        //    #endregion
        //    //插件前缀必须为Innocellence
        //    var plusDlls = plusFilesDirectoryInfo.GetFiles("*.dll", SearchOption.AllDirectories).ToList();
        //    if (plusDlls.Count == 0) return;
        //    //插件程序集
        //    //必须是Innocellence插件才会执行插件部署
        //    //dll名称必须与插件目录名称一致才能部署
        //    //{PlusDir}/{dllName}
        //    //{PlusDir}/bin/{dllName}
        //    var magicodesPlusDlls = plusDlls.Where(p => p.Name.StartsWith("Innocellence.") && (p.Directory.Name + ".dll" == p.Name || p.Directory.Parent.Name + ".dll" == p.Name));
        //    //依赖的程序集
        //    var orthersDlls = plusDlls.Where(p => !p.Name.StartsWith("Innocellence.")).Distinct();
        //    #region 设置程序域
        //    //var setup = new AppDomainSetup
        //    //{
        //    //    ApplicationName = "Infrastructure.Core",
        //    //    //DynamicBase = SitePaths.PlusShadowCopyDirPath,
        //    //    PrivateBinPath = SitePaths.PlusShadowCopyDirPath,
        //    //    DisallowCodeDownload = true,
        //    //    ShadowCopyFiles = "true",
        //    //    CachePath = SitePaths.PlusCacheDirPath,
        //    //    ShadowCopyDirectories = SitePaths.PlusShadowCopyDirPath,
        //    //    //PrivateBinPath = SitePaths.PlusShadowCopyDirPath
        //    //};
        //    //var appDomain = AppDomain.CreateDomain("Infrastructure.Core.Domain", null, setup);
        //    CurrentAppDomain = AppDomain.CurrentDomain;
        //    if (!CurrentAppDomain.IsFullyTrusted)
        //        throw new InnocellenceException("请将当前应用程序信任级别设置为完全信任");

        //    #endregion
        //    var binDir = new DirectoryInfo(SitePaths.SiteRootBinDirPath);

        //    #region 部署依赖程序集
        //    foreach (var plus in orthersDlls)
        //    {
        //        //如果网站bin目录不存在此dll,则将该dll复制到动态程序集目录
        //        if (binDir.GetFiles(plus.Name).Length == 0 && PluginManager.DynamicDirectory.GetFiles(plus.Name).Length == 0)
        //        {
        //            _PluginManager.CopyToDynamicDirectory(plus);
        //            Assembly assembly = Assembly.LoadFrom(plus.FullName);
        //            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
        //            if (!assemblies.Any(p => p.FullName == assembly.FullName))
        //                //将程序集添加到当前应用程序域
        //                BuildManager.AddReferencedAssembly(assembly);
        //        }

        //    }
        //    #endregion
        //    #region 部署插件程序集
        //    foreach (var plus in magicodesPlusDlls)
        //    {
        //        PluginManager.Deploy(plus);
        //    }
        //    #endregion
        //    #region 添加插件菜单
        //    var siteAdminNavigationRepository = APIContext<string>.Current.SiteAdminNavigationRepository;
        //    if (siteAdminNavigationRepository == null) return;
        //    #region 移除所有的插件菜单
        //    if (siteAdminNavigationRepository.GetQueryable().Any())
        //    {
        //        siteAdminNavigationRepository.RemoveRange(siteAdminNavigationRepository.GetQueryable());
        //        siteAdminNavigationRepository.SaveChanges();
        //    }
        //    #endregion
        //    //foreach (var plusInfo in PluginManager.ReferencedPlugins)
        //    //{
        //    //    if (plusInfo.PlusConfigInfo != null && plusInfo.PlusConfigInfo.PlusMenus != null && plusInfo.PlusConfigInfo.PlusMenus.Length > 0)
        //    //    {
        //    //        foreach (var plusMenu in plusInfo.PlusConfigInfo.PlusMenus)
        //    //        {
        //    //            AddPlusMenu(plusInfo, siteAdminNavigationRepository, plusMenu, null);
        //    //        }
        //    //    }
        //    //}
        //    siteAdminNavigationRepository.SaveChanges();
        //    #endregion
        //}
        ///// <summary>
        ///// 添加菜单
        ///// </summary>
        ///// <param name="plusInfo"></param>
        ///// <param name="r"></param>
        ///// <param name="plusMenu"></param>
        ///// <param name="parentId"></param>
        //private static void AddPlusMenu(PluginDescriptor plusInfo, SiteAdminNavigationRepositoryBase<string> r, PlusMenu plusMenu, Guid? parentId)
        //{
        //    var nav = new SiteAdminNavigationBase<string>()
        //    {
        //        BadgeRequestUrl = plusMenu.BadgeRequestUrl,
        //        Href = plusMenu.Href,
        //        IconCls = plusMenu.IconCls,
        //        Id = plusMenu.Id ?? Guid.NewGuid(),
        //        IsShowBadge = plusMenu.IsShowBadge,
        //        MenuBadgeType = plusMenu.MenuBadgeType,
        //        ParentId = plusMenu.ParentId ?? parentId,
        //        Text = plusMenu.Text,
        //        TextCls = plusMenu.TextCls,
        //        Deleted = false,
        //        //TODO:设置管理员账号
        //        CreateBy = "{B0FBB2AC-3174-4E5A-B772-98CF776BD4B9}",
        //        CreateTime = DateTime.Now,
        //        PlusId = plusInfo.Id
        //    };
        //    r.Add(nav);
        //    if (plusMenu.SubMenus != null && plusMenu.SubMenus.Length > 0)
        //    {
        //        foreach (var item in plusMenu.SubMenus)
        //        {
        //            AddPlusMenu(plusInfo, r, item, nav.Id);
        //        }
        //    }
        //}


        /// <summary>
        /// 应用程序日志类
        /// </summary>
        //public override LoggerStrategyBase ApplicationLog
        //{
        //    get
        //    {
        //        return this.StrategyManager.GetDefaultStrategy<LoggerStrategyBase>();
        //    }
        //}

        public override void PreApplicationStartInitialize()
        {
            //初始化策略管理器
            // StrategyManager = new StrategyManager();
            //初始化插件管理器
            //_PluginManager = new PluginManager();
            //【优先加载框架策略】加载框架策略作为默认策略,如果插件实现了该策略,则会被覆盖
            //默认集成了日志策略
            // _PluginManager.LoadPlusStrategys(this.GetType().Assembly);
            //初始化嵌入资源管理器
            //ManifestResourceManager = new ManifestResourceManager();
            //初始化文档协议管理器
            //   DocumentsOpenProtocolManager = new DocumentsOpenProtocolManager();


            log4net.Config.XmlConfigurator.Configure(new FileInfo(HostingEnvironment.MapPath("~/config/log4net.config")));

            Log4NetLoggerAdapter adapter = new Log4NetLoggerAdapter();

            LogManager.AddLoggerAdapter(adapter);

            //初始化配置管理器
            ConfigManager = new ConfigManager();
            //加载程序集
            // LoadAssemblies();

            //初始化Plugin
            PluginManager.Initialize();

            //初始化系统
            EngineContext.Initialize(false);

            //初始化数据库
            DatabaseInitialize();



            GlobalConfigurationManager.MapHttpAttributeRoutes();
            //初始化OData
            GlobalConfigurationManager.InitializeODATA();
            //初始化WebApi
            GlobalConfigurationManager.InitializeWebAPI();
            //初始化MVC插件引擎
            GlobalConfigurationManager.InitializeMVCEngines();


            //执行plugin的install方法
            //PluginManager.ExcuteAllInstallEvent();
        }
Beispiel #5
0
        /// <summary>
        /// 从日志适配器配置节点初始化日志适配器
        /// </summary>
        /// <param name="config">日志适配器配置节点</param>
        protected virtual void SetLoggingFromAdapterConfig(LoggingAdapterConfig config)
        {
            config.CheckNotNull("config");
            if (!config.Enabled)
            {
                return;
            }
            ILoggerAdapter adapter = ServiceProvider.GetService(config.AdapterType) as ILoggerAdapter;

            if (adapter == null)
            {
                return;
            }
            LogManager.AddLoggerAdapter(adapter);
        }
Beispiel #6
0
        /// <summary>
        /// 从日志适配器配置节点初始化日志适配器
        /// </summary>
        /// <param name="config">日志适配器配置节点</param>
        protected virtual void SetLoggingFromAdapterConfig(LoggingAdapterConfig config)
        {
            config.CheckNotNull("config");
            if (!config.Enabled)
            {
                return;
            }
            ILoggerAdapter adapter = Activator.CreateInstance(config.AdapterType) as ILoggerAdapter;

            if (adapter == null)
            {
                return;
            }
            LogManager.AddLoggerAdapter(adapter);
        }
Beispiel #7
0
 /// <summary>
 ///     简单的服务定位器
 /// </summary>
 static ServiceLocator()
 {
     // 添加全局日志
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
     GlobalLogger = LogManager.GetLogger(typeof(ServiceLocator));
     try {
         // 添加服务 需要注意服务的依赖顺序
         DebuggerContainer = new DebuggerContainer();
         ScheduleService   = new ScheduleService();
         ProfileService    = new ProfileService(Global.ProfilePath);
         ConfigManager     = new ConfigManager(Global.ConfigPath);
         MapManager        = new MapManager(Global.MapPath);
         WasManager        = new WasManager(Global.WdfPath);
         DrawingService    = new DrawingService();
         ClientEngine      = new ClientEngine();
         Window            = new GlWindow();
     } catch (Exception e) {
         GlobalLogger.Error(e);
         MessageBox.Show(Resources.ServiceLocator_Load_Error);
         Environment.Exit(0);
     }
 }
Beispiel #8
0
 private static void LoggingInit()
 {
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
 }
Beispiel #9
0
        private static void LoggingInitialize()
        {
            Log4NetLoggerAdapter adapter = new Log4NetLoggerAdapter();

            LogManager.AddLoggerAdapter(adapter);
        }
Beispiel #10
0
 //<summary>
 //开始初始化基础日志
 //</summary>
 //<param name="config">日志配置信息</param>
 public static void Initialize(LoggingConfig config)
 {
     LogManager.SetEntryInfo(config.Enabled, config.EntryLogLevel);
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
 }
Beispiel #11
0
 public void LoggingInit()
 {
     LogManager.AddLoggerAdapter(new Log4NetLoggerAdapter());
     LogManager.AddLoggerAdapter(new NLogLoggerAdapter());
 }