private static IConfService OpenCfg() { var ConfServerURI = WebConfigurationManager.AppSettings["CfgServer.URI"]; var ClientName = WebConfigurationManager.AppSettings["CfgServer.ClientName"]; var UserName = WebConfigurationManager.AppSettings["CfgServer.UserName"]; var UserPassword = WebConfigurationManager.AppSettings["CfgServer.UserPassword"]; Endpoint confServerUri = new Endpoint(new Uri(ConfServerURI)); ConfServerProtocol cfgServiceProtocol; EventBrokerService _eventBrokerService; cfgServiceProtocol = new ConfServerProtocol(confServerUri); cfgServiceProtocol.ClientName = ClientName; cfgServiceProtocol.UserName = UserName; cfgServiceProtocol.UserPassword = UserPassword; cfgServiceProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE; try { cfgServiceProtocol.Open(); } catch (ProtocolException e) { log.Error(e.Message); } catch (Exception e) { log.Error(e.Message); } _eventBrokerService = BrokerServiceFactory.CreateEventBroker(cfgServiceProtocol); IConfService cfgService = ConfServiceFactory.CreateConfService(cfgServiceProtocol, _eventBrokerService); return(cfgService); }
public static IConfService InitializeConfigService(string cfgsrvHost, int cfgsrvPort, string username, string password) { Endpoint confServerUri = new Endpoint(new Uri("tcp://" + cfgsrvHost + ":" + cfgsrvPort)); String _clientName = "default"; ConfServerProtocol cfgServiceProtocol; EventBrokerService _eventBrokerService; cfgServiceProtocol = new ConfServerProtocol(confServerUri); cfgServiceProtocol.ClientName = _clientName; cfgServiceProtocol.UserName = username; cfgServiceProtocol.UserPassword = password; cfgServiceProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE; try { cfgServiceProtocol.Open(); } catch (ProtocolException e) { log.Info(e.Message); } catch (Exception e) { log.Info(e.Message); } _eventBrokerService = BrokerServiceFactory .CreateEventBroker(cfgServiceProtocol); IConfService cfgService = ConfServiceFactory.CreateConfService( cfgServiceProtocol, _eventBrokerService); return(cfgService); }