Exemplo n.º 1
0
        private async void OnAlmTimerTick(object sender, ElapsedEventArgs e)
        {
            try
            {
                almTimer.Stop();
                if (almTickCounter < almPullInterval)
                {
                    almTickCounter++;
                }
                else
                {
                    List <string> almQueries = Configuration.ReadAlmQueryStrings();
                    Dictionary <string, List <string> > groupIDsForSubareas = Configuration.ReadGroupIDsForSubareas();
                    //slLogic.UpdateSlack(almDomain, almProject, almQueries, groupIDsForSubareas);
                    almPullInterval = Configuration.ReadAlmPullInterval();
                    almTickCounter  = 0;
                }

                if ((almTickCounter % cSlRuntimeRetryInterval) == 0)
                {
                    if (!(slRuntimeApiClient.IsOpen() || slRuntimeApiClient.IsConnecting()))
                    {
                        // Slack limits rate of API request to 1 second.
                        // This may cause fails due to error 429.
                        // Let's try to authenticate each cSlRuntimeRetryInterval seconds.
                        slRuntimeApiClient.Authenticate();
                    }
                }
            }
            finally
            {
                almTimer.Start();
            }
        }
Exemplo n.º 2
0
        private async void OnEmailTimerTick(object sender, ElapsedEventArgs e)
        {
            try
            {
                emailTimer.Stop();
                if (emailTickCounter < emailPullInterval)
                {
                    emailTickCounter++;
                }
                else
                {
                    //List<string> buildGroupIDs = Configuration.ReadBuildGroupIDs();
                    emailPullInterval = Configuration.ReadEmailPullInterval();
                    //bsLogic.Update(buildGroupIDs);

                    //List<string> commitGroupIDs = Configuration.ReadCommitGroupIDs();
                    Dictionary <string, HashSet <string> > groupIDsForRepositories = Configuration.ReadGroupIDsForRepositories();
                    //commitLogic.Update(groupIDsForRepositories);

                    commitFileLogic.Update(groupIDsForRepositories);

                    emailTickCounter = 0;
                }

                if (slRuntimeApiClient.IsOpen())
                {
                    MethodInvoker invoker = new MethodInvoker(() => slWebsocketStatusLabel.BackColor = Color.Green);
                    slWebsocketStatusLabel.Invoke(invoker);
                }
                else if (slRuntimeApiClient.IsConnecting())
                {
                    MethodInvoker invoker = new MethodInvoker(() => slWebsocketStatusLabel.BackColor = Color.Yellow);
                    slWebsocketStatusLabel.Invoke(invoker);
                }
                else
                {
                    // Slack limits rate of API request to 1 second.
                    // This may cause fails due to error 429.
                    // Let's try to authenticate each 5 seconds.
                    if ((almTickCounter % cSlRuntimeRetryInterval) == 0)
                    {
                        slRuntimeApiClient.Authenticate();
                    }
                }

                UpdateEmailUI();
            }
            finally
            {
                emailTimer.Start();
            }
        }