public void InitializePSDKApplicationBlocks() { protocolManagementService = new ProtocolManagementService(); isConfiguration = new InteractionServerConfiguration(ISERVER_IDENTIFIER); try { isConfiguration.Uri = new Uri(ISERVER_URI); } catch (Exception ex) { LogException(ex); } isConfiguration.ClientName = CLIENT_NAME; isConfiguration.ClientType = InteractionClient.AgentApplication; protocolManagementService.Register(isConfiguration); protocolManagementService.ProtocolOpened += new EventHandler <ProtocolEventArgs>(this.OnProtocolOpened); protocolManagementService.ProtocolClosed += new EventHandler <ProtocolEventArgs>(this.OnProtocolClosed); eventBrokerService = new EventBrokerService(protocolManagementService.Receiver); eventBrokerService.Register( IServerEventsHandler, new MessageFilter(protocolManagementService[ISERVER_IDENTIFIER].ProtocolId)); // Activate event broker service eventBrokerService.Activate(); protocolManagementService[ISERVER_IDENTIFIER].Opened += MediaCall_Opened; protocolManagementService[ISERVER_IDENTIFIER].Closed += MediaCall_Closed; }
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); }
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(); }
public List <IWidgetHost> LoadWidgets(EventBrokerService eventBroker) { this.WidgetHolderPanel.Attributes.Add(ZONE_ID_ATTR, this.WidgetZoneId.ToString()); //this.WidgetHolderPanelTrigger.CssClass = "WidgetZoneUpdatePanel_" + this.WidgetZoneId.ToString(); var facade = Services.Get <Facade>(); { this.WidgetInstances = facade.GetWidgetInstancesInZoneWithWidget(WidgetZoneId); } var controlsToDelete = new List <Control>(); foreach (Control control in this.WidgetHolderPanel.Controls) { if (control is IWidgetHost) { controlsToDelete.Add(control); } } controlsToDelete.ForEach((c) => this.WidgetHolderPanel.Controls.Remove(c)); List <IWidgetHost> widgetHosts = new List <IWidgetHost>(); this.WidgetInstances.Each(instance => { var widgetHost = CreateWidgetContainerFromWidgetInstance(eventBroker, instance); widgetHosts.Add(widgetHost); this.WidgetHolderPanel.Controls.Add(widgetHost as Control); }); return(widgetHosts); }
public void AddNewWidget(EventBrokerService eventBroker, WidgetInstance instance) { var widgetHost = CreateWidgetContainerFromWidgetInstance(eventBroker, instance); var widgetContainer = widgetHost as Control; var existingControls = this.WidgetHolderPanel.Controls; if (existingControls == null || existingControls.Count == 0) { this.WidgetHolderPanel.Controls.Add(widgetContainer); } else { var position = 0; foreach (Control existingControl in existingControls) { if (existingControl is IWidgetHost) { var existingHost = existingControl as IWidgetHost; if (existingHost.WidgetInstance.OrderNo >= instance.OrderNo) { break; } } } existingControls.AddAt(position, widgetContainer); } this.Refresh(); }
private static void InitializePSDKApplicationBlocks() { // Setup Application Blocks: // Create Protocol Manager Service object protocolManagementService = new ProtocolManagementService(); // Create and initialize connection configuration object for TServer. confServerConfiguration = new ConfServerConfiguration(CONFIGSERVER_IDENTIFIER); var ConfServerURI = WebConfigurationManager.AppSettings["CfgServer.URI"]; var ClientName = WebConfigurationManager.AppSettings["CfgServer.ClientName"]; var UserName = WebConfigurationManager.AppSettings["CfgServer.UserName"]; var UserPassword = WebConfigurationManager.AppSettings["CfgServer.UserPassword"]; // Set required values try { confServerConfiguration.Uri = new Uri(ConfServerURI); } catch (Exception ex) { log.Error(ex.Message, ex); } confServerConfiguration.ClientName = ClientName; confServerConfiguration.UserName = UserName; confServerConfiguration.UserPassword = UserPassword; if (System.Web.Configuration.WebConfigurationManager.AppSettings["CfgServer.HASupport"] == "1") { var uriBakup = System.Web.Configuration.WebConfigurationManager.AppSettings["CfgServer.URI_BAKUP"]; confServerConfiguration.WarmStandbyAttempts = 3; confServerConfiguration.WarmStandbyTimeout = 3000; confServerConfiguration.WarmStandbyUri = new Uri(uriBakup); confServerConfiguration.FaultTolerance = FaultToleranceMode.WarmStandby; } // Register this connection configuration with Protocol Manager protocolManagementService.Register(confServerConfiguration); protocolManagementService.ProtocolOpened += new EventHandler <ProtocolEventArgs>(OnProtocolOpened); protocolManagementService.ProtocolClosed += new EventHandler <ProtocolEventArgs>(OnProtocolClosed); // Create and Initialize Message Broker Application Block eventBrokerService = new EventBrokerService(protocolManagementService.Receiver); // Activate event broker service eventBrokerService.Activate(); confService = ConfServiceFactory.CreateConfService( protocolManagementService[CONFIGSERVER_IDENTIFIER], eventBrokerService); eventBrokerService.Register( eventConfServerEventsHandler, new MessageFilter(protocolManagementService[CONFIGSERVER_IDENTIFIER].ProtocolId)); }
private IWidgetHost CreateWidgetContainerFromWidgetInstance(EventBrokerService eventBroker, WidgetInstance instance) { var widget = LoadControl(this.WidgetContainerPath) as Control; widget.ID = "WidgetContainer" + instance.Id.ToString(); var widgetHost = widget as IWidgetHost; widgetHost.WidgetInstance = instance; widgetHost.IsLocked = this.IsLocked; widgetHost.EventBroker = eventBroker; widgetHost.Deleted += new Action <WidgetInstance, IWidgetHost>(Widget_Deleted); return(widgetHost); }
private void InitializePSDKApplicationBlocks() { // Setup Application Blocks: // Create Protocol Manager Service object protocolManagementService = new ProtocolManagementService(); // Create and initialize connection configuration object for TServer. outboundServerConfiguration = new OutboundServerConfiguration(OCS_IDENTIFIER); // Set required values try { outboundServerConfiguration.Uri = new Uri(OCS_URI); } catch (Exception ex) { Console.Write(ex.Message + "\n" + ex.StackTrace + "\n"); } outboundServerConfiguration.ClientName = CLIENT_NAME; // Register this connection configuration with Protocol Manager protocolManagementService.Register(outboundServerConfiguration); protocolManagementService.ProtocolOpened += new EventHandler <ProtocolEventArgs>(this.OnProtocolOpened); protocolManagementService.ProtocolClosed += new EventHandler <ProtocolEventArgs>(this.OnProtocolClosed); // Create and Initialize Message Broker Application Block eventBrokerService = new EventBrokerService(protocolManagementService.Receiver); eventBrokerService.Register( OutboundServerEventsHandler, new MessageFilter(protocolManagementService[OCS_IDENTIFIER].ProtocolId)); // Activate event broker service eventBrokerService.Activate(); }
/// <summary> /// Connects the config server. /// </summary> /// <param name="ConfigServerHost">The config server host.</param> /// <param name="ConfigServerPort">The config server port.</param> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <returns></returns> public OutputValues ConnectConfigServer(string ConfigServerHost, string ConfigServerPort, string userName, string password, string clientName, string logUserName) { EventBrokerService comEventBrokerService; OutputValues output = OutputValues.GetInstance(); ReadApplication read = new ReadApplication(); try { StatisticsSetting.GetInstance().logUserName = logUserName; logger.Debug("ConfigConnectionManager : ConnectConfigServer Method: Entry"); if (StatisticsSetting.GetInstance().protocolManager == null) { StatisticsSetting.GetInstance().configurationProperties = new ConfServerConfiguration("config"); StatisticsSetting.GetInstance().protocolManager = new ProtocolManagementService(); //Primary Server settings StatisticsSetting.GetInstance().configurationProperties.Uri = new Uri("tcp://" + ConfigServerHost + ":" + ConfigServerPort); StatisticsSetting.GetInstance().configurationProperties.ClientApplicationType = CfgAppType.CFGAgentDesktop; StatisticsSetting.GetInstance().configurationProperties.ClientName = clientName; StatisticsSetting.GetInstance().configurationProperties.UserName = userName; StatisticsSetting.GetInstance().configurationProperties.UserPassword = password; //Set ADDP StatisticsSetting.GetInstance().configurationProperties.UseAddp = true; StatisticsSetting.GetInstance().configurationProperties.AddpServerTimeout = 30; StatisticsSetting.GetInstance().configurationProperties.AddpClientTimeout = 60; //Open the connection try { StatisticsSetting.GetInstance().protocolManager.Register(StatisticsSetting.GetInstance().configurationProperties); } catch (Exception generalException) { output.MessageCode = "2001"; output.Message = (generalException.InnerException == null ? generalException.Message : generalException.InnerException.Message); logger.Error("ConfigConnectionManager : ConnectConfigServer Method: " + generalException.Message.ToString()); return(output); } StatisticsSetting.GetInstance().protocolManager[StatisticsSetting.ConfServer].Open(); comEventBrokerService = new EventBrokerService(StatisticsSetting.GetInstance().protocolManager.Receiver); comEventBrokerService.Activate(); //comEventBrokerService.Register(OnConfEventError); //comEventBrokerService.Register(OnConfEventObjectsRead); //comEventBrokerService.Register(OnConfEventObjectsSent); //KeyValueCollection filterKey = new KeyValueCollection(); //filterKey.Add("switch_dbid", 102); //filterKey.Add("dn_type", (int)CfgDNType.CFGExtension); //RequestReadObjects requestReadObjects = RequestReadObjects.Create((int)CfgObjectType.CFGDN, filterKey); //StatisticsSetting.GetInstance().protocolManager[StatisticsSetting.ConfServer].Send(requestReadObjects); if (StatisticsSetting.GetInstance().confObject == null) { StatisticsSetting.GetInstance().confObject = (ConfService)ConfServiceFactory.CreateConfService( StatisticsSetting.GetInstance().protocolManager[StatisticsSetting.ConfServer] as ConfServerProtocol, comEventBrokerService, true); } //NotificationQuery NQuery=new NotificationQuery(); //NQuery.ObjectType=CfgObjectType.CFGPerson; //StatisticsSetting.GetInstance().confObject.Subscribe(NQuery); if (StatisticsSetting.GetInstance().protocolManager[StatisticsSetting.ConfServer].State == ChannelState.Opened) { StatisticsSetting.GetInstance().confProtocol = (ConfServerProtocol)StatisticsSetting.GetInstance().protocolManager[StatisticsSetting.ConfServer]; read.ReadLoggerDetails(StatisticsSetting.GetInstance().AppName); output.MessageCode = "2000"; output.Message = "Config Server Protocol Opened"; logger.Trace("ConfigConnectionManager : ConnectConfigServer Method: Config Server Protocol Opened"); } else { output.MessageCode = "2001"; output.Message = "Config Server Protocol Closed"; logger.Warn("ConfigConnectionManager : ConnectConfigServer Method: Config Server Protocol Closed"); } } } catch (Exception connectionException) { logger.Error("ConfigConnectionManager : ConnectConfigServer Method: " + connectionException.Message.ToString()); output.MessageCode = "2001"; output.Message = (connectionException.InnerException == null ? connectionException.Message : connectionException.InnerException.Message); } finally { logger.Debug("ConfigConnectionManager : ConnectConfigServer Method: Exit"); //StatisticsSetting.GetInstance().protocolManager = null; GC.Collect(); } return(output); }