Exemplo n.º 1
0
        /// <summary>
        /// 加载
        /// </summary>
        private void LoadPluginDispatchServices()
        {
            PluginDefinition pluginDefinition;

            try
            {
                pluginDefinition = ReadPluginDefinitions();
            }
            catch (Exception ex)
            {
                ExceptionLog("LoadPluginDefinition Failed", ex);
                DebugLog("LoadPluginDefinition Failed,Create Empty Config");
                //如果发生异常,创建空的内容
                pluginDefinition = new PluginDefinition();
                File.WriteAllText(PathUtils.PluginDefinitionPath, SerializationUtils.XmlSerialize(pluginDefinition));
            }
            var esClientConfig = EsClientConfigUtils.ReadEsClientConfig();

            if (!esClientConfig.CustomerAgreementState.Registered)
            {
                DebugLog("Not Registered,Start None Plugin");
                return;
            }
            var serverRoles = esClientConfig.ServerRoles;
            //string customerCode = LicenseUtils.GetCustomerCode(esClientConfig.LicenseOperatorServiceAddress);
            var hostName = Dns.GetHostName();

            foreach (var pluginConfig in pluginDefinition.PluginConfigs)
            {
                //插件启用的服务器角色中 有当前服务器角色(之一) 启用
                if (!CheckEnableByServerRole(serverRoles, pluginConfig.EnableServerRoles))
                {
                    DebugLog(string.Format("Server Role Not Match:[{0}][{1}][{2}]",
                                           pluginConfig.TypeKey, string.Join(",", serverRoles.ToArray()),
                                           string.Join(",", pluginConfig.EnableServerRoles.ToArray())));
                    continue;
                }
                if (!CheckEnableByAgreement(esClientConfig.CustomerAgreementState, pluginConfig.PluginType))
                {
                    DebugLog(string.Format("Agreement Not Match:[{0}][{1}][{2}][{3}][{4}]",
                                           pluginConfig.TypeKey, esClientConfig.CustomerAgreementState.Registered,
                                           esClientConfig.CustomerAgreementState.AgreeToUxImproving,
                                           esClientConfig.CustomerAgreementState.AgreeToE10Examination,
                                           pluginConfig.PluginType));
                    continue;
                }
                var context = new PluginExecuteContext(pluginConfig, serverRoles, null,
                                                       hostName, esClientConfig.LicenseOperatorServiceAddress);
                var pluginDispatchService = new PluginDispatchService(context);
                //注入服务环境
                Connection(pluginDispatchService, ResourceServiceProvider, ServiceCallContext);
                DebugLog("Add Plugin:" + pluginConfig.TypeKey);
                _pluginDispatchServices.Add(pluginDispatchService);
            }
        }
Exemplo n.º 2
0
 private void LazyInitialize()
 {
     _esClientConfig = EsClientConfigUtils.ReadEsClientConfig();
     _customerCode   = LicenseUtils.GetCustomerCode(_esClientConfig.LicenseOperatorServiceAddress);
 }