/// <summary> /// Handles the Load event of the DatabaseMessenger control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void DatabaseMessenger_Load(object sender, EventArgs e) { if (this.DesignMode) { return; } ServiceEventListenerUrl = AppConfigSettings.GetString(ConfigParameter.ServiceEventListener, ModuleName.Service); PollingInterval = AppConfigSettings.GetInt(ConfigParameter.ChannelPollingInterval); SetupView(); StartPoller(); }
/// <summary> /// Initializes the form. /// </summary> private void InitializeForm() { txtPath.Text = AppConfigSettings.GetString(ConfigParameter.WebServerAppPath); txtVirtualPath.Text = AppConfigSettings.GetString(ConfigParameter.WebServerVirtualPath); txtPort.Text = AppConfigSettings.GetString(ConfigParameter.WebServerPort); chkAutoStart.Checked = Convert.ToBoolean(AppConfigSettings.GetString(ConfigParameter.WebServerAutoStart)); if (string.IsNullOrEmpty(txtPath.Text)) { txtPath.Text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Portal"); } btnStart.Focus(); ServiceEventListenerUrl = AppConfigSettings.GetString(ConfigParameter.ServiceEventListener, ModuleName.Service); PollingInterval = AppConfigSettings.GetInt(ConfigParameter.ChannelPollingInterval); StartPoller(); }
/// <summary> /// Starts the listen. /// </summary> private void StartEventListener() { StopEventListener(); // if there is any channel still open --> close it try { log.Info("Starting event listener"); int port = AppConfigSettings.GetInt(ConfigParameter.ListenerPort, ModuleName.Console); eventListenerChannel = new TcpChannel(port); ChannelServices.RegisterChannel(eventListenerChannel, false); eventInvocation = new EventInvocation(); string serviceName = AppConfigSettings.GetString(ConfigParameter.ListenerServiceName, ModuleName.Console); eventListenerService = RemotingServices.Marshal(eventInvocation, serviceName); //RemotingConfiguration.RegisterWellKnownServiceType(typeof(EventInvocation), // serviceName, WellKnownObjectMode.SingleCall); // define the event which is triggered when the Master calls the CallSlave() function eventInvocation.EventReceived += new EventInvocation.Received(OnEventReceived); // Create the event queue eventLock = new object(); eventQueue = new PriorityQueue <EventAction, EventPriority>(10); eventTrigger = new AutoResetEvent(false); eventProcessor = new Thread(ProcessEvents); eventProcessor.IsBackground = true; eventProcessor.Start(); log.Info(string.Format("Successfully started event listener {0} on port {1}", serviceName, port)); } catch (Exception ex) { log.Error("Error starting event listener: " + ex.Message, ex); StopEventListener(); // calls StopEventListener } }