private string BuildExistingSchedulesHtml(IEnumerable <PublishSchedule> schedules) { if (schedules == null) { return(string.Empty); } PublishSchedule[] schedulesArray = schedules.ToArray(); if (schedulesArray.Length == 0) { return(string.Empty); } StringBuilder sbTable = new StringBuilder(100); sbTable.Append("<table width=\"100%\">"); sbTable.Append("<tr>"); sbTable.Append("<td nowrap=\"nowrap\">Time</td>"); sbTable.Append("<td nowrap=\"nowrap\">Action</td>"); sbTable.Append("<td nowrap=\"nowrap\">Languages</td>"); sbTable.Append("<td nowrap=\"nowrap\">Version</td>"); sbTable.Append("<td nowrap=\"nowrap\">Recurrence</td>"); sbTable.Append("</tr>"); foreach (var schedule in schedulesArray) { string version; if (schedule.ItemToPublish != null) { Item itemInVersion = schedule.ItemToPublish.Publishing.GetValidVersion(schedule.PublishDate, true, false); if (itemInVersion != null) { sbTable.Append("<tr>"); version = itemInVersion.Version.Number.ToString(); } else { sbTable.Append("<tr style='color: red'>"); version = Constants.NO_VALID_VERSION_TEXT; } } else { sbTable.Append("<tr>"); version = Constants.WEBSITE_PUBLISH_TEXT; } sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", schedule.PublishDate.ToString(_culture)); sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", schedule.Unpublish ? Constants.UNPUBLISH_TEXT : Constants.PUBLISH_TEXT); sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", string.Join(",", schedule.TargetLanguages.Select(x => x.Name)).TrimEnd(',')); sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", version); sbTable.AppendFormat("<td nowrap=\"nowrap\">{0}</td>", DialogsHelper.GetRecurrenceMessage(schedule.RecurrenceType, schedule.HoursToNextPublish)); sbTable.Append("</tr>"); } sbTable.Append("</table>"); return(sbTable.ToString()); }
/// <summary> /// Displays all current publishing schedules ordered by date and time /// </summary> private void RenderAllSchedules() { StringBuilder sbHeader = new StringBuilder(); sbHeader.Append("<table width=\"100%\" cellpadding=\"4\" cellspacing=\"0\">"); sbHeader.Append("<col />"); sbHeader.Append("<col />"); sbHeader.Append("<col />"); sbHeader.Append("<col />"); sbHeader.Append("<col />"); sbHeader.Append("<col />"); sbHeader.Append("<tr style=\"background:#e9e9e9\">"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Item" + "</b></td>"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Action" + "</b></td>"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Subitems" + "</b></td>"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Mode" + "</b></td>"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Date" + "</b></td>"); sbHeader.Append("<td nowrap=\"nowrap\"><b>" + "Delete" + "</b></td>"); sbHeader.Append("</tr>"); AllSchedules.Controls.Add(new LiteralControl(sbHeader.ToString())); IEnumerable <PublishSchedule> allSchedules; using (new LanguageSwitcher(LanguageManager.DefaultLanguage)) { allSchedules = _scheduledPublishRepo.AllUnpublishedSchedules; } foreach (var schedule in allSchedules) { if (schedule.InnerItem != null) { StringBuilder sbItem = new StringBuilder(); // Item name, path, recurrence sbItem.Append("<tr style='background:#cedff2;border-bottom:1px solid #F0F1F2;'>"); Item scheduledItem = schedule.ItemToPublish; sbItem.Append("<td>"); sbItem.Append("<b>" + scheduledItem.DisplayName + "</b>"); sbItem.Append("<br />" + scheduledItem.Paths.FullPath); string recurrenceMessage = DialogsHelper.GetRecurrenceMessage(schedule.RecurrenceType, schedule.HoursToNextPublish); if (!string.IsNullOrWhiteSpace(recurrenceMessage)) { sbItem.Append("<br /> Recurrence: " + recurrenceMessage); } sbItem.Append("</td>"); // Is publishing/unpublishing sbItem.Append("<td style='border-left:1px solid #F0F1F2;'>"); string isUnpublishing = schedule.Unpublish ? "Unpublish" : "Publish"; sbItem.Append(isUnpublishing); sbItem.Append("</td><td style='border-left:1px solid #F0F1F2; text-align: center;'>"); // Subitems string includeSubitems = schedule.PublishChildren ? "Yes" : "No"; sbItem.Append(includeSubitems); sbItem.Append("</td><td style='border-left:1px solid #F0F1F2;'>"); // Publish mode string publishMode = schedule.PublishMode.ToString(); sbItem.Append(publishMode); sbItem.Append("</td><td style='border-left:1px solid #F0F1F2;'>"); // Current scheudled publish date and time AllSchedules.Controls.Add(new LiteralControl(sbItem.ToString())); DateTime pbDate = schedule.PublishDate; AllSchedules.Controls.Add(new LiteralControl(pbDate.ToString(_culture))); // Pick new date and time DateTimePicker dtPicker = new DateTimePicker(); dtPicker.ID = "dt_" + schedule.InnerItem.ID; dtPicker.Width = new Unit(100.0, UnitType.Percentage); dtPicker.Value = DateUtil.ToIsoDate(schedule.PublishDate); AllSchedules.Controls.Add(dtPicker); AllSchedules.Controls.Add(new LiteralControl("</td>")); // Delete schedule AllSchedules.Controls.Add(new LiteralControl("<td style='border-left:1px solid #F0F1F2;'>")); Checkbox deleteCheckbox = new Checkbox(); deleteCheckbox.ID = "del_" + schedule.InnerItem.ID; AllSchedules.Controls.Add(deleteCheckbox); AllSchedules.Controls.Add(new LiteralControl("</td></tr>")); } } AllSchedules.Controls.Add(new LiteralControl("</table")); }