public void RegisterDependencies(IAppRegistration appRegistration) { }
public void Initialization() { IsInit = true; SignTime("启动"); string appGuid = Guid.NewGuid().ToString(); StringBuilder exSb = new StringBuilder(); LoadApplicationXml(); SignTime("全局配置完毕..."); // Logger = LogManager.GetLogger(typeof(AtawAppContext), ApplicationXml.HasLogger); FastJson = JSON.Current; AtawCache = DefaultAtawCache.Current; //if (ApplicationXml.HasLogger) //{ string fpath = Path.Combine(BinPath, AtawApplicationConfig.REAL_PATH, "AtawLogs\\log\\log.txt"); LogManager.Configure(fpath, 1000, false); // } // Logger.Debug("程序初始化开始: " + appGuid); var dconn = DBConfigXml.Databases.First(a => a.IsDefault); AtawDebug.AssertNotNull(dconn, "至少有一个默认的数据库连接字符串", this); DefaultConnString = dconn.ConnectionString; // MemCachedCache mcc = MemCachedCache.Current; SignTime("日志初始化完毕...."); if ("EBS".AppKv <bool>(false)) { //初始化 消息总线 //AtawBus = ServiceBus.Create().Start(); } SignTime("消息总线初始化完毕...."); //载入代码插件 //AssamblyTable at = new AssamblyTable(); //at.Exe(); //------------web的程序装载器 IAppRegistration webApp = AtawIocContext.Current.FetchInstance <IAppRegistration>(ATAW_WEB_REGNAME); AtawDebug.AssertNotNull(webApp, "web的程序装载器 加载失败", this); //webApp.Initialization(); //this. AppDomainTypeFinder finder = new AppDomainTypeFinder(); finder.LoadMatchingAssemblies(Path.Combine(BinPath, "bin")); var assList = finder.GetAssemblies(); assList.ForEach( a => { try { LogBuilder(System.Environment.NewLine + "开始检查程序集:" + a.FullName); var types = a.GetTypes(); var dll = this.dllLog(a.FullName); foreach (var t in types) { try { LogBuilder(System.Environment.NewLine + "开始检查类型:" + t.FullName); SetAssamblyClassType(t, dll); webApp.SetAssamblyClassType(t); } catch (ReflectionTypeLoadException rtlex) { // LogBuilder(); string _mesg = string.Join(System.Environment.NewLine, rtlex.LoaderExceptions.Select(b => b.Message)); LogBuilder(t.FullName + "插件异常单个记录", _mesg); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); //exSb.Append(rtlex.Message); //SysTxtBuilder.Current.Append(rtlex.Message); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); } catch (Exception ex) { // if(ex.InnerException != null) LogBuilder(t.FullName + "插件异常单个记录", ex.Message, ex.InnerException == null ? "" : ex.InnerException.Message); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); dll.ClassInfoList.Add( new ClassInfo() { Error = t.FullName + "插件异常单个记录" + ex.Message + (ex.InnerException == null ? "" : ex.InnerException.Message) } ); //exSb.Append(ex.Message); //SysTxtBuilder.Current.Append(ex.Message); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); } } } catch (ReflectionTypeLoadException rtlex) { StringBuilder sb = new StringBuilder(); foreach (Exception exc in rtlex.LoaderExceptions) { sb.AppendLine("dll载入异常记录 " + exc.Message + (exc.InnerException == null ? "" : exc.InnerException.Message)); // LogBuilder("dll载入异常记录", exc.Message, exc.InnerException == null ? "" : exc.InnerException.Message); } this.dllErrorLog(sb.ToString()); } catch (Exception ex2) { LogBuilder(a.FullName + "插件程序集异常单个记录", ex2.Message, ex2.InnerException == null ? "" : ex2.InnerException.Message); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); this.dllErrorLog(a.FullName + "插件程序集异常单个记录 " + ex2.Message + (ex2.InnerException == null ? "" : ex2.InnerException.Message)); //exSb.Append(ex2.Message); //SysTxtBuilder.Current.Append(ex2.Message); //exSb.Append(System.Environment.NewLine); //SysTxtBuilder.Current.NewLine(); } } ); SignTime("程序集插件注册完毕...."); //注册享元插件 PageFlyweight = AtawIocContext.Current.FetchInstance <IFlyweight>("PageFlyweight"); ////把工作单元做为享元 //PageFlyweight.Set<IUnitOfData>("PFW_UFD", CreateDbContext()); //载入xml 插件 //执行全局配置的宏插件 // this.ApplicationXml.ExeMacro(); SignTime("执行全局配置的宏插件完毕...."); string rightRegName = ApplicationXml.RightBuilder.RegName; AtawRightBuilder = new Lazy <IAtawRightBuilder>( () => AtawIocContext.Current.FetchInstance <IAtawRightBuilder>(rightRegName) ); string groupRegName = ApplicationXml.GroupBuilder.RegName; GroupBuilder = new Lazy <IGroupBuilder>( () => AtawIocContext.Current.FetchInstance <IGroupBuilder>(groupRegName) ); //注册gps string gpsRegName = ApplicationXml.GPSBuilder.RegName; GPSBuilder = new Lazy <IGPSBuilder>( () => AtawIocContext.Current.FetchInstance <IGPSBuilder>(gpsRegName) ); //注册gpsSet string gpsSetRegName = ApplicationXml.GPSSetBuilder.RegName; GPSSetBuilder = new Lazy <IGPSSet>( () => AtawIocContext.Current.FetchInstance <IGPSSet>(gpsSetRegName) ); //注册内部服务 string ServiceRegName = ApplicationXml.ServiceBuilder.RegName; AtawServiceBuilder = new Lazy <IAtawServiceBuilder>( () => AtawIocContext.Current.FetchInstance <IAtawServiceBuilder>(ServiceRegName) ); //注册内部信息接口 string MessagesRegName = ApplicationXml.MessagesBuilder.RegName; AtawMessagesBuilder = new Lazy <IMessagesBuilder>( () => AtawIocContext.Current.FetchInstance <IMessagesBuilder>(MessagesRegName) ); ////注册工作流模式接口 //string WorkflowDefRegName = ApplicationXml.WorkflowDefBuilder.RegName; //AtawWorkflowDefBuilder = new Lazy<IWorkflowDefBuilder>( // () => AtawIocContext.Current.FetchInstance<IWorkflowDefBuilder>(WorkflowDefRegName) // ); //载入 codeTable xml SignTime("app配置注册完毕...."); InitAppXml(); SignTime("固定接口注册完毕...."); InitCodeTableXml(); SignTime("XMl代码表注册完毕...."); InitDataDictXml(); SignTime("XMl数据字典注册完毕...."); InitCustomScriptXml(); SignTime("自定义js注册完毕...."); //载入控制器 //AtawIocContext.Current.FetchInstance<IAppRegistration>(AtawAppContext.ATAW_WEB_REGNAME).Initialization(); webApp.Initialization(); ExeAppRegistration(); SignTime("全局插件执行完毕...."); // Logger.Debug("程序初始化结束: " + appGuid); // Logger.Debug("插件异常总结: " + exSb.ToString()); // SysTxtBuilder.Current.Flush(LogType.Plugin); AtawTrace.WriteFile(LogType.Plugin, this.fLogInfo.ToJson()); if ("CombineJs".AppKv <bool>(false)) { //ICombineJs combine = "CombineJs".CodePlugIn<ICombineJs>(); //bool CombinJsResult = combine.init(AtawAppContext.Current.BinPath); //if (!CombinJsResult) //{ // throw new AtawException("压缩JS出错!", this); //} //SignTime("js压缩执行完毕...."); } }