Example #1
0
        private void DropConnection()
        {
            if (_client == null)
            {
                return;
            }

            Platform.Log(LogLevel.Debug, "Attempting to disconnect from ActivityMonitorService.");

            try
            {
                var communication = (ICommunicationObject)_client;
                communication.Closed  -= OnConnectionClosed;
                communication.Faulted -= OnConnectionFaulted;

                if (communication.State == CommunicationState.Opened)
                {
                    communication.Close();
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Debug, e, "Unexpected error disconnecting from ActivityMonitorService.");
            }

            _client = null;
            FireIsConnectedChanged();
        }
        /// <summary>
        /// Publishes changing work item activity to the <see cref="IWorkItemActivityMonitorService"/>.
        /// </summary>
        /// <param name="item">The work item data</param>
        public void PublishWorkItemActivity(WorkItemData item)
        {
            if (_activityMonitorService == null)
            {
                _activityMonitorService = Platform.GetService <IWorkItemActivityMonitorService>();
            }

            _activityMonitorService.Publish(new WorkItemPublishRequest {
                Item = item
            });
        }
        /// <summary>
        /// Cleanup the activity monitor connections
        /// </summary>
        public void Cleanup()
        {
            var disposableService = _activityMonitorService as IDisposable;

            if (disposableService != null)
            {
                disposableService.Dispose();
            }
            _activityMonitorService = null;

            _monitor.WorkItemsChanged -= WorkItemsChanged;
            _monitor.Dispose();
        }
Example #4
0
        private void Connect()
        {
            if (_client != null)
            {
                return;
            }

            Platform.Log(LogLevel.Debug, "Attempting to connect to ActivityMonitorService.");

            try
            {
                var callback      = new Callback(this);
                var client        = Platform.GetDuplexService <IWorkItemActivityMonitorService, IWorkItemActivityCallback>(callback);
                var communication = (ICommunicationObject)client;
                if (communication.State == CommunicationState.Created)
                {
                    communication.Open();
                }

                communication.Closed  += OnConnectionClosed;
                communication.Faulted += OnConnectionFaulted;

                Platform.Log(LogLevel.Debug, "Successfully connected to ActivityMonitorService.");

                _client = client;
                FireIsConnectedChanged();
            }
            catch (EndpointNotFoundException)
            {
                Platform.Log(LogLevel.Debug, "ActivityMonitorService is not running.");
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Debug, e, "Unexpected error trying to connect to ActivityMonitorService.");
            }
        }
        private void DropConnection()
        {
            if (_client == null)
                return;

            Platform.Log(LogLevel.Debug, "Attempting to disconnect from ActivityMonitorService.");

            try
            {
                var communication = (ICommunicationObject)_client;
                communication.Closed -= OnConnectionClosed;
                communication.Faulted -= OnConnectionFaulted;

                if (communication.State == CommunicationState.Opened)
                    communication.Close();
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Debug, e, "Unexpected error disconnecting from ActivityMonitorService.");
            }

            _client = null;
            FireIsConnectedChanged();
        }
        private void Connect()
        {
            if (_client != null)
                return;

            Platform.Log(LogLevel.Debug, "Attempting to connect to ActivityMonitorService.");

            try
            {
                var callback = new Callback(this);
                var client = Platform.GetDuplexService<IWorkItemActivityMonitorService, IWorkItemActivityCallback>(callback);
                var communication = (ICommunicationObject)client;
                if (communication.State == CommunicationState.Created)
                    communication.Open();

                communication.Closed += OnConnectionClosed;
                communication.Faulted += OnConnectionFaulted;

                Platform.Log(LogLevel.Debug, "Successfully connected to ActivityMonitorService.");

                _client = client;
                FireIsConnectedChanged();
            }
            catch (EndpointNotFoundException)
            {
                Platform.Log(LogLevel.Debug, "ActivityMonitorService is not running.");
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Debug, e, "Unexpected error trying to connect to ActivityMonitorService.");
            }
        }
		/// <summary>
		/// Cleanup the activity monitor connections
		/// </summary>
		public void Cleanup()
		{
			var disposableService = _activityMonitorService as IDisposable;
			if (disposableService != null) disposableService.Dispose();
			_activityMonitorService = null;

			_monitor.WorkItemsChanged -= WorkItemsChanged;
			_monitor.Dispose();
		}
		/// <summary>
		/// Publishes changing work item activity to the <see cref="IWorkItemActivityMonitorService"/>.
		/// </summary>
		/// <param name="item">The work item data</param>
		public void PublishWorkItemActivity(WorkItemData item)
		{
			if (_activityMonitorService == null)
				_activityMonitorService = Platform.GetService<IWorkItemActivityMonitorService>();

			_activityMonitorService.Publish(new WorkItemPublishRequest {Item = item});
		}