/// <summary> /// Searches for the search string. It searches the entire page, not just job name. /// </summary> /// <param name="searchString">The string to search for. Note that it will search for this exact string, not each word</param> /// <param name="maxPages">The maximum number of pages to search</param> /// <param name="system">The system (bdsprod, sms12, etc.)</param> /// <param name="pageType">Page type (report, batch, or jobstatus)</param> /// <param name="pagesBack">The page number to start at</param> /// <param name="submitted">submitted checkbox</param> /// <param name="running">running checkbox</param> /// <param name="complete">complete checkbox</param> /// <param name="aborted">aborted checkbox</param> /// <param name="deleted">deleted checkbox</param> /// <returns>HTML of the page in which the result was found, or a message saying it was not found</returns> public string search(string searchString, int maxPages, RpmConnect.RpmSystem system, RpmConnect.PageType pageType, int pagesBack, bool submitted, bool running, bool complete, bool aborted, bool deleted) { for (int i = pagesBack; i <= pagesBack + maxPages; i++) { string html = getRpmTable(system, pageType, i, submitted, running, complete, aborted, deleted); if (html.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0) return "<pageno>" + i + "</pageno>" + html; } return "<pageno>1</pageno><p>Job Not Found</p>"; }
/// <summary> /// Gets the table from an RPM page and returns the HTML /// </summary> /// <param name="system">The system (bdsprod, sms12, etc.)</param> /// <param name="pageType">Page type (report, batch, or jobstatus)</param> /// <param name="pagesBack">Page number (1 is newest)</param> /// <param name="submitted">submitted checkbox</param> /// <param name="running">running checkbox</param> /// <param name="complete">complete checkbox</param> /// <param name="aborted">aborted checkbox</param> /// <param name="deleted">deleted checkbox</param> /// <returns>HTML of the table</returns> public string getRpmTable(RpmConnect.RpmSystem system, RpmConnect.PageType pageType, int pagesBack, bool submitted, bool running, bool complete, bool aborted, bool deleted) { string postData = "pageNo=" + pagesBack; if (submitted) postData += "&scheduled=on"; if (running) postData += "&running=on"; if (complete) postData += "&complete=on"; if (aborted) postData += "&aborted=on"; if (deleted) postData += "&deleted=on"; string html = Global.m_rpmConnect.getRpmPage(system, pageType, postData); html = html.Replace("href=\"batchsubtask?BatchTaskId=", "onclick=\"showJobStatusDialog(this);\" href=\"#"); return html; }
/// <summary> /// Gets the the job status from the RPM page and returns it. Also calculates the total duration. /// </summary> /// <param name="system">The RPM system (bdsprod, sms12, etc.)</param> /// <param name="batchId">The batch ID of the job</param> /// <returns>String with the resulting HTML</returns> public string getRpmJobStatus(RpmConnect.RpmSystem system, int batchId) { string parameters = "BatchTaskId=" + batchId; string html = Global.m_rpmConnect.getRpmPage(system, RpmConnect.PageType.jobstatus, parameters); html = "<div class='jobstatustable'>" + html + "</div>"; MatchCollection matches = Regex.Matches(html, @"([0-9]{0,9})\.[0-9]{0,3}secs", RegexOptions.None); int totalDuration = 0; string totalDurationString; try { foreach (Match match in matches) { totalDuration += Convert.ToInt32(match.Groups[1].Value); } totalDurationString = formatTime(totalDuration); } catch (FormatException) { totalDurationString = "Error parsing durations"; } html += "<p class='duration'>Total Duration: " + totalDurationString +"</p>"; return html; }
protected void Application_Start(object sender, EventArgs e) { m_rpmConnect = new RpmConnect(); }