Example #1
0
        private ServiceEndpoint GetServiceEndpointByConfig(string configName, string endpointConfigurationName)
        {
            ServiceEndpoint        serviceEndpoint = null;
            DsConfigurationManager dcm             = new DsConfigurationManager();

            System.Configuration.Configuration config = dcm.Get <System.Configuration.Configuration>(ConfigurationFileHelper.GetAddinConfigurationFilePath(configName));
            ClientSection cconfig = config.GetSection(GlobalParams.ClientHostSession) as ClientSection;

            if (cconfig != null)
            {
                if (cconfig.Endpoints.Count > 0)
                {
                    foreach (ChannelEndpointElement e in cconfig.Endpoints)
                    {
                        if (e.Name != endpointConfigurationName)
                        {
                            continue;
                        }
                        channelType     = TypeResolutionUtils.ResolveType(e.Contract);
                        serviceEndpoint = new ServiceEndpoint(ContractDescription.GetContract(channelType), WCFMateHelper.BindingFactory(config, e), new EndpointAddress(e.Address));
                    }
                }
            }
            if (serviceEndpoint == null)
            {
                throw new ArgumentNullException("The configuration file{0},The client access to WCF configuration information is not correct".FormatString(configName));
            }
            return(serviceEndpoint);
        }
Example #2
0
        private void InitConfiguration(string isMonitor)
        {
            DsConfigurationManager dscm = new DsConfigurationManager();
            var config = dscm.Get <DsConfigurationSection>(AppDomain.CurrentDomain.BaseDirectory + "DS.AFP.WindowsService.App.exe.config", "ds/base");

            GlobalParams.WindowsService = ConfigurationManager.GetSection("ds/windowsService") as WindowsServiceConfigurationSection;
            if (GlobalParams.WindowsService.Service.ServiceName.IsNullOrEmpty())
            {
                if (LoggerFacade.IsErrorEnabled)
                {
                    LoggerFacade.Error("DS服务名称配置节点“serviceName”为空,请配置该节点");
                }
                throw new Exception("DS服务名称配置节点“serviceName”为空");
                //    LogTraceClient.WriteLog(LogTraceType.Info, "{0} DS服务名称配置节点“serviceName”为空,\r\n将采用默认服务名:DSWindowService,默认服务显示名:DSWindows服务".FormatString(DateTime.Now.ToString("HH:mm:ss fff")));
            }
            else
            {
                GlobalParams.ServiceName = GlobalParams.WindowsService.Service.ServiceName;
                GlobalParams.DisplayName = GlobalParams.WindowsService.Service.DisplayName;
            }
        }
Example #3
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));
        }