/// <summary>
        /// Gets test results for a particular JUnit job in Jenkins
        /// </summary>
        /// <param name="jenkinsUrl">URL of the Jenkins job</param>
        /// <param name="buildsBack">Number of builds to go back</param>
        /// <returns>List of test results</returns>
        public List<JenkinsTestResult> GetTestResults(string jenkinsUrl, int buildsBack)
        {
            SimpleAES crypto = new SimpleAES();
            var testResults = new List<JenkinsTestResult>();

            CookieContainer cc = Login(ConfigurationManager.AppSettings["jenkinsUsername"], crypto.DecryptString(ConfigurationManager.AppSettings["jenkinsPassword"]));

            string url = jenkinsUrl + "lastCompletedBuild/";
            long currentBuildNumber=0;

            JenkinsTestResult tr=null;
            for (int n = 0; n < buildsBack; n++)
            {
                 tr = GetTestResult(cc, url);
                 if (n == 0)
                     currentBuildNumber = tr.BuildNumber-1;
                 else
                     currentBuildNumber = currentBuildNumber - 1;

                 if (tr != null && tr.TestsFailed + tr.TestsPassed != 0) // make sure there are test results
                     testResults.Insert(0, tr);

                 url = jenkinsUrl + currentBuildNumber + "/";
            }

            return testResults;
        }
 public ManpowerGadgetController()
 {
     if (_jiraUsername == null)
     {
         _jiraUsername = ConfigurationManager.AppSettings["jiraUsername"];
         SimpleAES crypto = new SimpleAES();
         _jiraPassword = crypto.DecryptString(ConfigurationManager.AppSettings["jiraPassword"]);
     }
 }
        private static void init()
        {
            if (_connectionString == null)
            {
                SimpleAES crypto = new SimpleAES();
                string connectionString = ConfigurationManager.AppSettings["connectionString"];
                string pwdenc = Regex.Match(connectionString, @"Password=(\w+);").Groups[1].Value;
                string pwddec = crypto.DecryptString(pwdenc);
                _connectionString = Regex.Replace(connectionString, @"Password=\w+;", "Password="******";");
            }

            if (_jiraUsername == null)
            {
                _jiraUsername = ConfigurationManager.AppSettings["jiraUsername"];
                SimpleAES crypto = new SimpleAES();
                _jiraPassword = crypto.DecryptString(ConfigurationManager.AppSettings["jiraPassword"]);
            }

            if (_jiraPrefix == null)
                _jiraPrefix = ConfigurationManager.AppSettings["jiraPrefix"];

            if (_jss == null)
            {
                _jss = new JiraSoapServiceService();
            }

            // Handle token timeouts by holding them for only 10 minutes
            if (HttpRuntime.Cache.Get("jiratoken") == null)
            {
                _token = _jss.login(_jiraUsername, _jiraPassword);
                HttpRuntime.Cache.Insert("jiratoken", _token, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(10 * 60));
            }
            else
                _token = HttpRuntime.Cache.Get("jiratoken").ToString();

        }