public static bool LoadSAPServerConfig() { try { //RfcDestinationCollection clientsSetting = ConfigFileTool.SAPClientServerSetting.getClientSettings(); //if (clientsSetting != null) //{ // RfcDestinationManager.RegisterDestinationConfiguration(new DefaultDestinationConfiguration(clientsSetting)); //} if (_serverStarted == false) { RfcServerCollection severSetting = ConfigFileTool.SAPClientServerSetting.getServerSettings(); if (severSetting != null) { RfcServerManager.RegisterServerConfiguration(new DefaultServerConfiguration(severSetting)); } _serverStarted = true; } // RfcServerManager.loadedFromParameterFile = true; return(true); } catch (Exception) { throw new SAPException("无法从配置文件加载"); } }
// private RfcServerCollection severSetting; // Methods internal DefaultServerConfiguration(RfcServerCollection serverCollection) { IEnumerator enumerator = serverCollection.GetEnumerator(); this.servers = new Dictionary <string, RfcConfigParameters>(); while (enumerator.MoveNext()) { RfcServerParameters current = (RfcServerParameters)enumerator.Current; RfcConfigParameters parameters2 = new RfcConfigParameters(0x20); // PropertyInfo[] properties = Type.GetType("SAP.Middleware.Connector.RfcServerParameters").GetProperties(); // PropertyInfo[] properties = Assembly.LoadFrom("ConfigFileTool.dll").GetType("ConfigFileTool.SapConfig.RfcServerParameters").GetProperties(); PropertyInfo[] properties = current.GetType().GetProperties(); // Type type = Type.GetType("SAP.Middleware.Connector.RfcConfigParameters"); // Type type = Assembly.LoadFrom("sapnco.dll").GetType("SAP.Middleware.Connector.RfcConfigParameters"); Type type = parameters2.GetType(); for (int i = 0; i < properties.Length; i++) { string str = properties[i].GetValue(current, null) as string; if ((str != null) && (str.Length > 0)) { parameters2[(string)type.GetField(properties[i].Name).GetValue(null)] = str; } } this.servers[current.Name] = parameters2; } }