Exemple #1
0
        /// <summary>
        /// Logs into the RPM console of the given system
        /// </summary>
        /// <param name="system">The system we're logging in to (bdsprod, sms12, etc.)</param>
        private void rpmLogin(RpmSystem system)
        {
            string targetUri = systemUrls[system] + rpmurl + overviewurl;
            string postData = "Username="******"&Password="******"&Start=OK";
            HttpWebResponse response = postRequest(targetUri, postData);

            logit("Logged in " + system + ". HTTP response code is " + response.StatusCode);
        }
Exemple #2
0
        /// <summary>
        /// Gets a pages from the RPM website, automatically logging in if necessary
        /// </summary>
        /// <param name="system">The system we're getting the page from (bdsprod, sms12, etc.)</param>
        /// <param name="pageType">The type of page.  This is either batch, report, or jobstatus</param>
        /// <param name="parameters">A string with the parameters for the get or post request</param>
        /// <returns>A string with the HTML of the result</returns>
        public string getRpmPage(RpmSystem system, PageType pageType, string parameters)
        {
            logit("Loading page " + system + " " + pageType);
            initSession(system);

            string endUrl = "";
            if (pageType == PageType.batch) endUrl = batchSummaryurl;
            else if (pageType == PageType.report) endUrl = reporturl;
            else if (pageType == PageType.jobstatus) endUrl = batchTaskurl;

            string targetUri = systemUrls[system] + rpmurl + endUrl;

            for (int i = 0; i < 4; i++)
            {
                try
                {
                    HttpWebResponse response;
                    if (pageType == PageType.jobstatus) response = getRequest(targetUri, parameters);
                    else response = postRequest(targetUri, parameters);

                    System.IO.StreamReader str = new System.IO.StreamReader(response.GetResponseStream());

                    string html = str.ReadToEnd();
                    if (str != null) str.Close();//TODO - should throw exception
                    html = extractDataTable(html);

                    logit("Done Loading " + system + " " + pageType);
                    return html;
                }
                catch (Exception e)
                {
                    logit("Failed to retrieve page.  Retrying login and load page: " + e.Message);
                    rpmLogin(system);
                }
            }

            return null;
        }
Exemple #3
0
 /// <summary>
 /// Checks if it's necessary to login (session expired) and if it is, log in.
 /// </summary>
 /// <param name="system">Which system (bdsprod, sms12, etc.)</param>
 private void initSession(RpmSystem system)
 {
     int comparison = DateTime.Compare(DateTime.Now - new TimeSpan(0, rpmSessionTimeout, 0), sessionAges[system]);
     if (comparison > 0) rpmLogin(system);
     else logit("Session still active on " + system + " so no need to login.");
     sessionAges[system] = DateTime.Now;
 }