Created
April 9, 2018 19:00
-
-
Save hishaamn/464214903649f542ded618d7a96512c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private readonly DateTime now = DateTime.Now; | |
| protected override void ShowJobs(StringBuilder stringBuilder, string name, ICollection<Job> jobs) | |
| { | |
| stringBuilder.AppendLine("<h1>" + name + ":</h1><br />"); | |
| if (jobs.Count > 0) | |
| { | |
| stringBuilder.AppendLine("<table class='jobs-table'>"); | |
| stringBuilder.AppendLine("<thead><tr><td class='counter'>No</td><td class='add-time'>Added</td><td class='title'>Title</td><td class='progress'>Progress</td><td class='priority'>Priority</td><td class='owner'>Owner</td></tr></thead>"); | |
| var num = 1; | |
| foreach (var job in jobs) | |
| { | |
| var total = job.Status.Total; | |
| var timeSpan = this.now - job.QueueTime.ToLocalTime(); | |
| var hour = timeSpan.Hours == 0 ? string.Empty : timeSpan.Hours + "h "; | |
| var minute = timeSpan.Minutes == 0 ? string.Empty : timeSpan.Minutes + "m "; | |
| stringBuilder.AppendLine("<tr>"); | |
| stringBuilder.AppendLine($"<td class='counter'>{num}</td>"); | |
| var timeArray = new object[7]; | |
| timeArray[0] = "<td class='add-time'>"; | |
| var dateTime = job.QueueTime; | |
| dateTime = dateTime.ToLocalTime(); | |
| var longTimeString = dateTime.ToLongTimeString(); | |
| timeArray[1] = longTimeString; | |
| timeArray[2] = " ("; | |
| timeArray[3] = hour; | |
| timeArray[4] = minute; | |
| timeArray[5] = timeSpan.Seconds; | |
| timeArray[6] = "s ago)</td>"; | |
| stringBuilder.AppendLine(string.Concat(timeArray)); | |
| stringBuilder.AppendLine($"<td class='title'>{job.Name}</td>"); | |
| stringBuilder.AppendLine($"<td class='progress'>{job.Status.Processed}{(total > 0L ? " of " + total : string.Empty)}</td>"); | |
| stringBuilder.AppendLine($"<td class='priority'>{job.Options.Priority}</td>"); | |
| if (job.Options.ContextUser != null) | |
| { | |
| stringBuilder.AppendLine($"<td class='owner'>{job.Options.ContextUser.DisplayName}</td>"); | |
| } | |
| stringBuilder.AppendLine("</tr>"); | |
| num++; | |
| } | |
| stringBuilder.AppendLine("</table>"); | |
| } | |
| else | |
| { | |
| stringBuilder.AppendLine("<b>No jobs</b><br />"); | |
| } | |
| stringBuilder.AppendLine("<br /><hr />"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment