예제 #1
0
        public Boolean ConnectToLca()
        {
            Boolean result = false;

            try
            {
                if (!IsConnectedToLca())
                {
                    TpsLogManager <MessageServer> .Info("Connecting to Local Control Agent...");

                    _localControlAgentProtocol = new LocalControlAgentProtocol(lCAPort)
                    {
                        ClientName    = applicationName,
                        ExecutionMode = ApplicationExecutionMode.Backup,
                        ControlStatus = (int)ApplicationStatus.Initializing,
                        Timeout       = new TimeSpan(0, 0, _lcaTimeout)
                    };
                    //TpsLogManager<MessageServer>.Info("Initialising Local Control Agent parameters");
                    _mEventBroker = BrokerServiceFactory.CreateEventBroker(_localControlAgentProtocol);
                    _mEventBroker.Register(OnEventChangeExecutionMode, new MessageIdFilter(EventChangeExecutionMode.MessageId));
                    _localControlAgentProtocol.Open();
                    TpsLogManager <MessageServer> .Info("Connected to Local Control Agent.");
                }

                result = true;
            }
            catch (Exception e) {
                TpsLogManager <MessageServer> .Error(e.Message);
            }

            return(result);
        }
예제 #2
0
        private void Connect(string appName, int addpClientTimeout, int addpServerTimeout, string addpTrace)
        {
            configServerId          = CConfServerIdentifier + Guid.NewGuid();
            confServerConfiguration = new ConfServerConfiguration(configServerId)
            {
                Uri                 = new Uri(configServerPrimaryUri),
                ClientName          = appName,
                UserName            = "",
                UserPassword        = "",
                WarmStandbyUri      = new Uri(configServerBackupUri),
                WarmStandbyAttempts = 5,
                UseAddp             = true,
                AddpClientTimeout   = addpClientTimeout,
                AddpServerTimeout   = addpServerTimeout,
                AddpTrace           = addpTrace
            };


            protocolManagementService = new ProtocolManagementService();
            protocolManagementService.ProtocolOpened += OnProtocolOpened;
            protocolManagementService.ProtocolClosed += OnProtocolClosed;
            protocolManagementService.Register(confServerConfiguration);

            eventBrokerService  = BrokerServiceFactory.CreateEventBroker(protocolManagementService.Receiver);
            confServiceContract = ConfServiceFactory.CreateConfService(protocolManagementService[configServerId], eventBrokerService);
            confServiceContract.Register(OnConfEvent);

            protocolManagementService.BeginOpen();
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }