You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			145 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			145 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			C#
		
	
using BaseModule;
 | 
						|
using Prism.Ioc;
 | 
						|
using Prism.Modularity;
 | 
						|
using Prism.Services.Dialogs;
 | 
						|
using Prism.Unity;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Configuration;
 | 
						|
using System.Data;
 | 
						|
using System.Linq;
 | 
						|
using System.Threading.Tasks;
 | 
						|
using System.Windows;
 | 
						|
using System.Windows.Threading;
 | 
						|
using Txgy.EWS.Client.BLL;
 | 
						|
using Txgy.EWS.Client.Common;
 | 
						|
using Txgy.EWS.Client.Common.Helpers;
 | 
						|
using Txgy.EWS.Client.DAL;
 | 
						|
using Txgy.EWS.Client.IBLL;
 | 
						|
using Txgy.EWS.Client.IDAL;
 | 
						|
using Txgy.EWS.Client.ILog;
 | 
						|
using Txgy.EWS.Client.Log;
 | 
						|
using Txgy.EWS.Client.MainModule;
 | 
						|
using Txgy.EWS.Client.PageModule;
 | 
						|
using Txgy.EWS.Client.Start.ViewModels;
 | 
						|
using Txgy.EWS.Client.Start.Views;
 | 
						|
using Txgy.EWS.Client.SysModule;
 | 
						|
 | 
						|
namespace Txgy.EWS.Client.Start
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    /// App.xaml 的交互逻辑
 | 
						|
    /// </summary>
 | 
						|
    public partial class App : PrismApplication
 | 
						|
    {
 | 
						|
        public App()
 | 
						|
        {
 | 
						|
            // 日志Log4Net初始化
 | 
						|
            LogConfiguration log = new LogConfiguration();
 | 
						|
            log.Initialize();
 | 
						|
 | 
						|
            this.Exit += App_Exit;
 | 
						|
            //this.DispatcherUnhandledException += App_DispatcherUnhandledException;
 | 
						|
        }
 | 
						|
 | 
						|
        private void App_Exit(object sender, ExitEventArgs e)
 | 
						|
        {
 | 
						|
            try
 | 
						|
            {
 | 
						|
                GlobalData.IsRunning = false;
 | 
						|
                Task.WaitAll(GlobalData.TaskList.ToArray());
 | 
						|
                //RealtimeViewModel.GetInstance().Dispose();
 | 
						|
            }
 | 
						|
            catch { }
 | 
						|
        }
 | 
						|
        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 | 
						|
        {
 | 
						|
            //CommonLogHelper.Fatal(e.Exception);//添加系统全局抓取日志记录
 | 
						|
            //e.Handled = true;
 | 
						|
        }
 | 
						|
 | 
						|
        protected override Window CreateShell()
 | 
						|
        {
 | 
						|
            //bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString(), out GlobalConfig.IsDesign);
 | 
						|
            //Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString());
 | 
						|
            GlobalConfig.IsDesign = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString());
 | 
						|
            return Container.Resolve<MainWindow>();
 | 
						|
        }
 | 
						|
        protected override void InitializeShell(Window shell)
 | 
						|
        {
 | 
						|
            GlobalConfig.ReadConfig();
 | 
						|
            //if (GlobalData.IsDesign)
 | 
						|
            //{                
 | 
						|
            //    base.InitializeShell(shell);
 | 
						|
            //}
 | 
						|
            //else
 | 
						|
            {
 | 
						|
                //GlobalConfig.ReadConfig();
 | 
						|
                // 通信容器来获取对象  可以进行相关对象的注入
 | 
						|
                if (Container.Resolve<LoginView>().ShowDialog() == false)
 | 
						|
                {
 | 
						|
                    //GlobalConfig.ReadConfig();
 | 
						|
                    Application.Current?.Shutdown();
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    //CommonLogHelper.Debug("====Start=====>");
 | 
						|
                    //Console.WriteLine(System.Configuration.ConfigurationManager.AppSettings["IsDesign"].ToString());
 | 
						|
                    base.InitializeShell(shell);
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
 | 
						|
        {
 | 
						|
            /// 全局对象注册
 | 
						|
            containerRegistry.Register<Dispatcher>(() => Application.Current.Dispatcher);
 | 
						|
            //注册View
 | 
						|
            containerRegistry.RegisterDialog<LoginView>();
 | 
						|
 | 
						|
            //注册DAL
 | 
						|
            containerRegistry.Register<IWebDataAccess, WebDataAccess>();
 | 
						|
            containerRegistry.Register<ILocalDataAccess, LocalDataAccess>();
 | 
						|
            containerRegistry.Register<IRemoteMySQLDataAccess, RemoteMySQLDataAccess>();
 | 
						|
            containerRegistry.Register<IRemoteMySqlDownload, RemoteMySqlDownload>();
 | 
						|
            containerRegistry.Register<IUpgradeDal, UpgradeDal>();
 | 
						|
            containerRegistry.Register<IMenuDal, MenuDal>();
 | 
						|
            containerRegistry.Register<IUserDal, UserDal>();
 | 
						|
            containerRegistry.Register<IRoleDal, RoleDal>();
 | 
						|
 | 
						|
            containerRegistry.RegisterSingleton<FreeSqlTencent>();
 | 
						|
            //containerRegistry.RegisterSingleton<IFreeSql, FreeDB>();
 | 
						|
            //注册BLL
 | 
						|
            containerRegistry.Register<IUpgradeFileBLL, UpgradeFileBLL>();
 | 
						|
            containerRegistry.Register<ILoginBLL, LoginBLL>();
 | 
						|
            containerRegistry.Register<IMenuBLL, MenuBLL>();
 | 
						|
            containerRegistry.Register<IUserBLL, UserBLL>();
 | 
						|
            containerRegistry.Register<IRoleBLL, RoleBLL>();
 | 
						|
            containerRegistry.Register<ISearchMsEventBLL, SearchMsEventBLL>();
 | 
						|
            //containerRegistry.Register<IRemoteDownloadDataBLL, RemoteDownloadDataBLL>();
 | 
						|
            //注册对话框
 | 
						|
            containerRegistry.Register<IDialogHostService, DialogHostService>();
 | 
						|
 | 
						|
            //注册日志
 | 
						|
            containerRegistry.RegisterSingleton<ILogHelper, LogHelper>();
 | 
						|
            //containerRegistry.RegisterDialog<LoginView, LoginViewModel>();
 | 
						|
            //throw new NotImplementedException();
 | 
						|
        }
 | 
						|
        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
 | 
						|
        {
 | 
						|
            base.ConfigureModuleCatalog(moduleCatalog);
 | 
						|
            // 自动扫描目录
 | 
						|
 | 
						|
            // 手动添加
 | 
						|
            moduleCatalog.AddModule<MainModuleProfile>();
 | 
						|
            moduleCatalog.AddModule<PageModuleProfile>();
 | 
						|
            moduleCatalog.AddModule<SysModuleProfile>();
 | 
						|
            moduleCatalog.AddModule<BaseModuleProfiel>();
 | 
						|
            //moduleCatalog.AddModule<SystemModule>();
 | 
						|
            //moduleCatalog.AddModule<BaseInfoModule>();
 | 
						|
            //moduleCatalog.AddModule<AutoInfoModule>();
 | 
						|
            //moduleCatalog.AddModule<ReportInfoModule>();
 | 
						|
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |