public TrayIconService(IActivityEvents activityEvents)
        {
            _activityEvents       = activityEvents;
            _autoStartRegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            _autoStartActive = GetAutoStartState();
        }
        public UserInputTimeDataProvider(
            IActivityEvents activityEvents,
            IConfiguration configuration)
            : base(activityEvents)
        {
            var checkIntervalInSeconds = configuration["checkIntervalInSeconds"];

            _checkInterval = checkIntervalInSeconds != null?TimeSpan.FromSeconds(int.Parse(checkIntervalInSeconds)) : TimeSpan.FromSeconds(600);

            _cancellationTokenSource = new CancellationTokenSource();

            var idleTimeoutMinutes = configuration["idleTimeoutMinutes"];

            _idleTimeoutInMinutes = idleTimeoutMinutes != null?TimeSpan.FromMinutes(int.Parse(idleTimeoutMinutes)) : TimeSpan.FromMinutes(30);

            _isUserCurrentlyActive = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start the activity. If the activity is already running an exception is throw.
        /// To override the common working code use the OnWork abstract method.
        /// </summary>
        /// <param name="events">Interface class that receive the events, can be null if no event class is needed.</param>
        public void Start(IActivityEvents events)
        {
            ResetRunningStatus();

            if (mStatus != ActivityStatus.Pending)
            {
                throw new ActivityStatusNotValidException();
            }

            mEvents = events;

            try
            {
                OnStarted();
                StartActivity();
            }
            catch (Exception e)
            {
                OnException(e);
            }
        }
Exemplo n.º 4
0
        public EventSender(
            HttpClient httpClient,
            IActivityEvents activityEvents)
        {
            _httpClient = httpClient;
            activityEvents.OnActivityStateChanged.Register(OnActivityStateChanged);

            _retryPolicy = Policy
                           .Handle <WebException>()
                           .WaitAndRetryAsync(new List <TimeSpan>()
            {
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(15),
                TimeSpan.FromSeconds(60),
            });

            _retryCancellationTokenSource = new CancellationTokenSource();

            _retryContext = new Context("RetryContext")
            {
                { nameof(_retryCancellationTokenSource), _retryCancellationTokenSource }
            };
        }
 public WindowsDisplayPortDataProvider(IActivityEvents activityEvents)
     : base(activityEvents)
 {
     _displaySettingsChangedEvent = async(_, __) => await OnDisplaySettingsChanged();
 }
Exemplo n.º 6
0
		/// <summary>
		/// Start the activity. If the activity is already running an exception is throw.
		/// To override the common working code use the OnWork abstract method.
		/// </summary>
		/// <param name="events">Interface class that receive the events, can be null if no event class is needed.</param>
		public void Start(IActivityEvents events)
		{
			ResetRunningStatus();

			if (mStatus != ActivityStatus.Pending)
				throw new ActivityStatusNotValidException();

			mEvents = events;

			try
			{
				OnStarted();
				StartActivity();
			}
			catch(Exception e)
			{
				OnException(e);
			}
		}
 protected AbstractDataProvider(IActivityEvents activityEvents)
 {
     ActivityEvents = activityEvents;
 }