public string GenerateHeader (GetViewWorkTableDataResponse response, DBLane lane, DBHost host, DBCommand command) { if (!Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator)) { return string.Format (@" <h2>Step {4} on lane '{2}' on '{3}' (<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, command.command); } else { return string.Format (@" <h2>Step {4} on lane '<a href='EditLane.aspx?lane_id={0}'>{2}</a>' on '<a href='EditHost.aspx?host_id={1}'>{3}</a>' (<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, command.command); } }
public GetViewWorkTableDataResponse GetViewWorkTableData (WebServiceLogin login, int? lane_id, string lane, int? host_id, string host, int? command_id, string command) { GetViewWorkTableDataResponse response = new GetViewWorkTableDataResponse (); using (DB db = new DB ()) { Authenticate (db, login, response); response.Host = FindHost (db, host_id, host); response.Lane = FindLane (db, lane_id, lane); response.Command = FindCommand (db, response.Lane, command_id, command); response.WorkViews = new List<DBWorkView2> (); using (IDbCommand cmd = db.CreateCommand ()) { cmd.CommandText = @" SELECT * FROM WorkView2 WHERE command_id = @command_id AND masterhost_id = @host_id AND lane_id = @lane_id ORDER BY date DESC LIMIT 250; "; DB.CreateParameter (cmd, "command_id", response.Command.id); DB.CreateParameter (cmd, "host_id", response.Host.id); DB.CreateParameter (cmd, "lane_id", response.Lane.id); using (IDataReader reader = cmd.ExecuteReader ()) { while (reader.Read ()) response.WorkViews.Add (new DBWorkView2 (reader)); } } response.WorkFileViews = new List<List<DBWorkFileView>> (); for (int i = 0; i < response.WorkViews.Count; i++) { // This takes too long when there are many files: response.WorkFileViews.Add (DBWork_Extensions.GetFiles (db, response.WorkViews [i].id, false)); response.WorkFileViews.Add (new List<DBWorkFileView> ()); } } return response; }
public string GenerateLane (GetViewWorkTableDataResponse response, DBLane lane, DBHost host, DBCommand command) { StringBuilder matrix = new StringBuilder (); List<DBWorkView2> steps; steps = response.WorkViews; matrix.AppendLine ("<table class='buildstatus'>"); matrix.AppendLine ("<tr>"); matrix.AppendLine ("\t<th>Revision</th>"); matrix.AppendLine ("\t<th>Start Time</th>"); matrix.AppendLine ("\t<th>Duration</th>");; matrix.AppendLine ("\t<th>Html report</th>"); matrix.AppendLine ("\t<th>Summary</th>"); matrix.AppendLine ("\t<th>Files</th>"); matrix.AppendLine ("</tr>"); for (int i = 0; i < steps.Count; i++) { DBWorkView2 view = steps [i]; List<DBWorkFileView> files = response.WorkFileViews [i]; DBState state = (DBState) view.state; matrix.Append ("<tr>"); // revision string result; switch (state) { case DBState.NotDone: result = "queued"; break; case DBState.Executing: result = "running"; break; case DBState.Failed: result = view.nonfatal ? "issues" : "failure"; break; case DBState.Success: case DBState.Aborted: case DBState.Timeout: case DBState.Paused: default: result =state.ToString ().ToLowerInvariant (); break; } // result matrix.AppendFormat ("\t<td class='{0}'><a href='ViewLane.aspx?lane_id={2}&host_id={3}&revision_id={4}'>{1}</a></td>", result, view.revision, lane.id, host.id, view.revision_id); if (state > DBState.NotDone && state != DBState.Paused && state != DBState.Ignore) { matrix.AppendFormat ("<td>{0}</td>", view.starttime.ToString ("yyyy/MM/dd HH:mm:ss UTC")); } else { matrix.AppendLine ("<td>-</td>"); } // duration matrix.Append ("\t<td>"); if (state >= DBState.Executing && state != DBState.Paused && state != DBState.Ignore) { matrix.Append ("["); matrix.Append (MonkeyWrench.Utilities.GetDurationFromWorkView (view).ToString ()); matrix.Append ("]"); } else { matrix.Append ("-"); } matrix.AppendLine ("</td>"); // html report matrix.AppendLine ("<td>"); DBWorkFileView index_html = null; foreach (DBWorkFileView file in files) { if (file.filename == "index.html") { index_html = file; break; } } if (index_html != null) { matrix.AppendFormat ("<a href='ViewHtmlReport.aspx?workfile_id={0}'>View html report</a>", index_html.id); } else { matrix.AppendLine ("-"); } matrix.AppendLine ("</td>"); // summary matrix.AppendLine ("<td>"); matrix.AppendLine (view.summary); matrix.AppendLine ("</td>"); matrix.AppendLine ("</tr>"); } matrix.AppendLine ("</table>"); return matrix.ToString (); }
public string GenerateLane (GetViewWorkTableDataResponse response, DBLane lane, DBHost host, DBCommand command) { StringBuilder matrix = new StringBuilder (); List<DBWorkView2> steps; DateTime beginning = new DateTime (2001, 1, 1, 0, 0, 0); steps = response.WorkViews; matrix.AppendLine ("<table class='buildstatus'>"); matrix.AppendLine ("<tr>"); matrix.AppendLine ("\t<th>Revision</th>"); matrix.AppendLine ("\t<th>Start Time</th>"); matrix.AppendLine ("\t<th>Duration</th>");; matrix.AppendLine ("\t<th>Html report</th>"); matrix.AppendLine ("\t<th>Summary</th>"); matrix.AppendLine ("\t<th>Files</th>"); matrix.AppendLine ("</tr>"); for (int i = 0; i < steps.Count; i++) { DBWorkView2 view = steps [i]; List<DBWorkFileView> files = response.WorkFileViews [i]; DBState state = (DBState) view.state; matrix.Append ("<tr>"); // revision string result; switch (state) { case DBState.NotDone: result = "queued"; break; case DBState.Executing: result = "running"; break; case DBState.Failed: result = view.nonfatal ? "issues" : "failure"; break; case DBState.Success: case DBState.Aborted: case DBState.Timeout: case DBState.Paused: default: result =state.ToString ().ToLowerInvariant (); break; } // result int file_id = 0; foreach (DBWorkFileView file in files) { if (!file.filename.StartsWith (view.command)) continue; file_id = file.id; break; } if (file_id == 0) { matrix.AppendFormat ("\t<td class='{0}'>{1}</td>", result, view.revision); } else { matrix.AppendFormat ("\t<td class='{0}'><a href='GetFile.aspx?id={2}'>{1}</a></td>", result, view.revision, file_id); } if (state > DBState.NotDone && state != DBState.Paused) { matrix.AppendFormat ("<td>{0}</td>", view.starttime.ToString ("yyyy/MM/dd HH:mm:ss UTC")); } else { matrix.AppendLine ("<td>-</td>"); } // duration DateTime starttime = view.starttime.ToLocalTime (); DateTime endtime = view.endtime.ToLocalTime (); int duration = (int) (endtime - starttime).TotalSeconds; matrix.Append ("\t<td>"); if (state >= DBState.Executing && state != DBState.Paused) { matrix.Append ("["); matrix.Append (TimeSpan.FromSeconds (duration).ToString ()); matrix.Append ("]"); } else { matrix.Append ("-"); } matrix.AppendLine ("</td>"); // html report matrix.AppendLine ("<td>"); DBWorkFileView index_html = null; foreach (DBWorkFileView file in files) { if (file.filename == "index.html") { index_html = file; break; } } if (index_html != null) { matrix.AppendFormat ("<a href='ViewHtmlReport.aspx?workfile_id={0}'>View html report</a>", index_html.id); } else { matrix.AppendLine ("-"); } matrix.AppendLine ("</td>"); // summary matrix.AppendLine ("<td>"); matrix.AppendLine (view.summary); matrix.AppendLine ("</td>"); matrix.AppendLine ("</tr>"); } matrix.AppendLine ("</table>"); return matrix.ToString (); }