Exemple #1
0
        private void EnsureModulesDiscovered()
        {
            IDsConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();

            if (section != null)
            {
                foreach (ModuleConfigurationElement element in section.Modules)
                {
                    IList <string> dependencies = new List <string>();

                    if (element.Dependencies.Count > 0)
                    {
                        foreach (ModuleDependencyConfigurationElement dependency in element.Dependencies)
                        {
                            dependencies.Add(dependency.ModuleName);
                        }
                    }
                    ModuleInfo moduleInfo = new ModuleInfo(element.ModuleName, element.ModuleType, element.Index)
                    {
                        Ref = PathHelper.GetFileAbsoluteUri(element.AssemblyFile),
                        InitializationMode = element.StartupLoaded ? InitializationMode.WhenAvailable : InitializationMode.OnDemand
                    };
                    moduleInfo.DependsOn.AddRange(dependencies.ToArray());
                    AddModule(moduleInfo);
                }
            }
        }
        public WebBrowserModule(IApplicationContext container, IPortal portal, IDsConfigurationSection dsconfig, IShell shell, ILoadingManage loadingManage, IDsEnvironment dsEnvironment, IRegionManager regionManager
                                , IEventAggregator eventAggregator, ILoggerFacade logger)
            : base(container, dsconfig)
        {
            AddinPath       = base.AddinInfo.AddinPath.Substring(0, base.AddinInfo.AddinPath.LastIndexOf('\\'));
            EventAggregator = eventAggregator;
            Container       = base.Container;
            UIRegionManager = regionManager;
            MainWindow      = shell;
            portaldata      = portal;
            DsConfiguration = dsconfig;
            Logger          = logger;
            DsEnvironment   = dsEnvironment;
            DsAddinConfig   = base.CurrentAddinConfiguration.GetSection("ds/base") as IDsAddinConfigurationSection;

            string Language    = string.Empty;
            var    LanguagePar = DsConfiguration.Params["Language"];

            if (LanguagePar != null)
            {
                Language = LanguagePar.Value;
            }

            // CefManager.Strat();


            string dxcx = (new DS.AFP.Common.Core.ResManager()).GetResource("DS.AFP.WebBrowser", "Close").ToString();
        }
Exemple #3
0
        /// <summary>
        /// 初始化环境参数
        /// </summary>
        /// <param name="dsConfig"></param>
        /// <param name="assemblyFullName"></param>
        private void InitializationDsEnvironment(IDsConfigurationSection dsConfig, string assemblyFullName)
        {
            //#if DEBUG

            //            Debugger.Launch();

            //#endif
            Console.WriteLine("InitializationDsEnvironment:{0},{1}".FormatString(dsConfig.ToString(), assemblyFullName));
            try
            {
                //var server;
                IDsEnvironment de = ParentContaioner.GetObject <IDsEnvironment>();
                IList <ModuleConfigurationElement> server = (from ModuleConfigurationElement me in dsConfig.Modules
                                                             where me.ModuleType.EndsWith(assemblyFullName)
                                                             select me).ToList <ModuleConfigurationElement>();
                Console.WriteLine("Modules:{0},server count:{0}".FormatString(dsConfig.Modules.Count, server.Count));
                ModuleConfigurationElement mce = server.FirstOrDefault();
                this.AddinInfo = new AddinInfo()
                {
                    AddinAssemblyName     = assemblyFullName,
                    AddinNameSpace        = mce.AssemblyFile.Substring(mce.AssemblyFile.LastIndexOf('/') + 1).Replace(".dll", ""),
                    AddinName             = mce.ModuleName,
                    ConfigurationFilePath = ConfigurationFileHelper.GetAddinConfigurationFilePath(mce.AssemblyFile),
                    AddinConfigurationEle = mce,
                    AddinPath             = PathHelper.GetFullPath(mce.AssemblyFile)
                };
                if (de.AddinInfos.ContainsKey(AddinInfo.AddinName))
                {
                    AddinInfo addin = de.AddinInfos[AddinInfo.AddinName];
                    addin.ConfigurationFilePath = this.AddinInfo.ConfigurationFilePath;
                    addin.AddinConfigurationEle = this.AddinInfo.AddinConfigurationEle;
                    addin.AddinPath             = this.AddinInfo.AddinPath;
                    //throw new Exception("DsEnvironment中注册AddinName失败,原因是AddinName作为键值重复!");
                }
                else
                {
                    de.AddinInfos.Add(mce.ModuleName, AddinInfo);
                }
            }catch (Exception ex)
            {
                Console.WriteLine("InitializationDsEnvironment异常:{0}".FormatString(ex.StackTrace.ToString()));

                throw new Exception("InitializationDsEnvironment异常。", ex);
            }
        }
Exemple #4
0
        public MainWindow(IDsEnvironment dsEnvironment, IDsConfigurationSection dsconfig)
        {
            InitializeComponent();

            dsNotifications.Top  = SystemParameters.WorkArea.Height - topOffset;
            dsNotifications.Left = SystemParameters.WorkArea.Left + SystemParameters.WorkArea.Width - leftOffset;
            DsEnvironment        = dsEnvironment;

            /////这里是在初始化加载控件之前就已经做了,故使用配置的方式进行加载
            ////1、创建默认主题(默认情况下是DeepBlue)
            if (dsconfig.Themes.Count > 0)
            {
                foreach (ThemeElement item in dsconfig.Themes)
                {
                    ThemeManage.CurrentTheme = item.Name;
                    break;
                }
            }
            System.Windows.Application.Current.Resources.MergedDictionaries.Clear();
            ////2、加载控件的样式
            foreach (ModuleConfigurationElement module in dsconfig.Modules)
            {
                string assemblyfile = module.AssemblyFile.Substring(module.AssemblyFile.LastIndexOf('/') + 1);
                string path         = assemblyfile.Substring(0, assemblyfile.LastIndexOf('.'));
                ThemeManage.EnsureApplicationResources(ThemeManage.CurrentTheme, path);
            }
            //////这部分代码怎么实现的问题---gefx
            //if (dsEnvironment.AddinInfos == null || dsEnvironment.AddinInfos.Count <= 0)
            //    DsEnvironment = ParentContaioner.GetObject<IDsEnvironment>();

            //foreach (AddinInfo addininfo in DsEnvironment.AddinInfos.Values)
            //{
            //    ////这里又有一个问题就是命名空间要更程序集的名称对应,不然的话就需要截取字符串的形式啦!!
            //    string assemblyname = addininfo.AddinNameSpace;
            //    ThemeManage.EnsureApplicationResources(ThemeManage.CurrentTheme, assemblyname);
            //}
            #region Debug
            //base.SetWindowTheme("DeepBlue", "DS.AFP.UIFramework");
            #endregion

            App.iconMouseEvent += App_iconMouseEvent;

            FullScreenManager.RepairWpfWindowFullScreenBehavior(this);
        }
Exemple #5
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="container"></param>
        /// <param name="dsconfig"></param>
        protected ModuleBase(IApplicationContext container, IDsConfigurationSection dsconfig)
        {
//#if DEBUG

//            Debugger.Launch();

//#endif
            logger = new LoggerFacade(this.GetType());
            DsConfigurationManager dcm = new DsConfigurationManager();
            Assembly a           = this.GetType().Assembly;
            string   contextName = a.GetName().Name.ToLower();

            ParentContaioner = container;
            //初始化环境信息
            this.InitializationDsEnvironment(dsconfig, a.FullName);
            logger.Debug("{0} Plug-ins start loading".FormatString(AddinInfo.AddinName));
            //SyncInfo(dcm);
            if (File.Exists(AddinInfo.ConfigurationFilePath))
            {
                System.Configuration.Configuration ecs = dcm.Get <System.Configuration.Configuration>(AddinInfo.ConfigurationFilePath);
                if (ecs == null)
                {
                    logger.Error("{0} Configuration file loading exception, configuration file does not exist!".FormatString(AddinInfo.AddinName));
                }
                CurrentAddinConfiguration   = ecs;
                this.DsConfigurationSection = dsconfig;
                AddinConfigurationList.TryAdd(AddinInfo.AddinName, ecs);

                ParentContaioner.RegisterInstance(this);
                Container = ChildContainer.Create(container, contextName, ecs);

                GlobalObject.SetAddinContanier(AddinInfo.AddinName, Container);
                //初始化WCF服务
                WCFServiceContainer.Create(contextName, CurrentAddinConfiguration);
                //初始化Socket服务
                SocketServiceContainer.Create(CurrentAddinConfiguration);
            }
            logger.Debug("{0} Plug-in loaded".FormatString(AddinInfo.AddinName));
        }
        private void LoadAssemblybyConfigAndDir()
        {
            IDsConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();

            if (section != null)
            {
                foreach (ModuleConfigurationElement element in section.Modules)
                {
                    IList <string> dependencies = new List <string>();

                    if (element.Dependencies.Count > 0)
                    {
                        foreach (ModuleDependencyConfigurationElement dependency in element.Dependencies)
                        {
                            dependencies.Add(dependency.ModuleName);
                        }
                    }
                    //防止重复模块加载,判断依据ModuleName是否一致
                    if (this.Modules.SingleOrDefault(m => m.ModuleName == element.ModuleName) != null)
                    {
                        continue;
                    }
                    string assemblyRef = PathHelper.GetFileAbsoluteUri(element.AssemblyFile);
                    //string SplashNameSpace = assemblyRef.Substring(assemblyRef.LastIndexOf('/') + 1).Replace(".dll", "");
                    //string SplashType = "{0}.{1}".FormatString(SplashNameSpace, "SplashPage");
                    //string assemblyPath = assemblyRef.Substring(0, assemblyRef.LastIndexOf('/') + 1);
                    ModuleInfo moduleInfo = new ModuleInfo(element.ModuleName, element.ModuleType, element.Index)
                    {
                        Ref = assemblyRef,
                        IsModuleEntrance   = true,
                        InitializationMode = element.StartupLoaded ? InitializationMode.WhenAvailable : InitializationMode.OnDemand
                                             //SplashPageUri = assemblyPath + "SplashPage.xaml"
                    };
                    string path = moduleInfo.Ref.Substring(PathHelper.RefFilePrefix.Length + 1);

                    if (!File.Exists(path))
                    {
                        string message           = "{0}插件,文件不存在。路径:{1}".FormatString(moduleInfo.ModuleName, moduleInfo.Ref);
                        FileNotFoundException fe = new FileNotFoundException(message);
                        this.logger.Error(message, fe);
                        throw fe;
                    }
                    //try
                    //{
                    //    Assembly ea = Assembly.LoadFrom(moduleInfo.Ref);
                    //    //ResourceManager rm = new ResourceManager(ea.GetModules()[0].Name.Replace("dll", "") + "Resources.ModuleResource", ea);
                    //    //rm.IgnoreCase = true;
                    //    //if (rm.GetObject("ModuleName") != null)
                    //    //    moduleInfo.ModuleName = rm.GetString("ModuleName");
                    //    //if (rm.GetObject("ModuleTitle") != null)
                    //    //    moduleInfo.ModuleTitle = rm.GetString("ModuleTitle");
                    //    //if (rm.GetObject("ModuleDescription") != null)
                    //    //    moduleInfo.ModuleDescription = rm.GetString("ModuleDescription");
                    //}
                    //catch(Exception e)
                    //{
                    //    this.logger.Error("程序集加载异常。程序集路径:{0}".FormatString(moduleInfo.Ref),e);
                    //    throw e;
                    //}
                    moduleInfo.DependsOn.AddRange(dependencies.ToArray());
                    AddModule(moduleInfo);
                    //string assfile = Path.GetFullPath(element.AssemblyFile);
                    string        assfile = PathHelper.GetFullPath(element.AssemblyFile);
                    DirectoryInfo dir     = new DirectoryInfo(assfile.Replace(Path.GetFileName(assfile), string.Empty));
                    if (dir.Exists)
                    {
                        foreach (var f in dir.GetFiles("*.dll", SearchOption.TopDirectoryOnly))
                        {
                            ModuleInfo moduleInfo2 = new ModuleInfo(f.Name, "", element.Index)
                            {
                                Ref = PathHelper.GetFileAbsoluteUri(f.FullName, true),
                                IsModuleEntrance   = false,
                                InitializationMode = InitializationMode.WhenAvailable
                            };
                            if (this.Modules.SingleOrDefault(m => m.ModuleName == moduleInfo2.ModuleName) == null)
                            {
                                AddModule(moduleInfo2);
                            }
                        }
                    }
                }
            }
        }
Exemple #7
0
 public void Attach(IApplicationContext container, IDsConfigurationSection config)
 {
     XmlApplicationContext chaild = new XmlApplicationContext(container, "assembly://DS.WorkflowManager.Services/DS.WorkflowManager.Services.Objects/Objects.xml");
 }