protected void DeleteAlertButton_Click(object sender, ImageClickEventArgs e) { AlertsGridPanel.RefreshCurrentPage(); IList <Model.Alert> items = AlertsGridPanel.SelectedItems; ArrayList keyArray = new ArrayList(); if (items != null && items.Count > 0) { if (items.Count > 1) { DeleteConfirmationBox.Message = string.Format(SR.MultipleAlertDelete); } else { DeleteConfirmationBox.Message = string.Format(SR.SingleAlertDelete); } DeleteConfirmationBox.Message += "<div id='DeleteAlertTableContainer' class='DeleteAlertTableContainer'> <table class='DeleteAlertConfirmTable' border='0' cellspacing='0' cellpadding='0'>"; DeleteConfirmationBox.Message += string.Format("<thead class='DeleteAlertFixedHeader' id='DeleteAlertFixedHeader'><tr class='GlobalGridViewHeader'><th align='left'>{0}</th><th>{1}</th><th>{2}</th><th>{3}</th></tr></thead><tbody class='DeleteAlertScrollContent'>", ColumnHeaders.AlertComponent, ColumnHeaders.AlertInsertDate, ColumnHeaders.AlertLevel, ColumnHeaders.AlertContent); foreach (Model.Alert item in items) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(sw); item.Content.Save(xtw); DeleteConfirmationBox.Message += String.Format("<tr class='DeleteAlertConfirmTableRow' align='left'><td>{0}</td><td>{1}</td><td>{2}</td><td width='300'>{3}</td></tr>", item.Component, item.InsertTime.ToString("g"), item.AlertLevelEnum, sb); keyArray.Add(item.Key); } DeleteConfirmationBox.Message += "</tbody></table></div>"; DeleteConfirmationBox.MessageType = MessageBox.MessageTypeEnum.YESNO; DeleteConfirmationBox.Data = keyArray; DeleteConfirmationBox.MessageStyle = "color: #ff0000; font-weight: bold;"; DeleteConfirmationBox.Show(); } }
void DeleteAllConfirmDialog_Confirmed(object data) { AlertsGridPanel.RefreshCurrentPage(); AlertController controller = new AlertController(); AlertItemCollection items = AlertsGridPanel.AlertItems; bool successful = false; for (int i = 0; i < items.Count; i++) { successful = controller.DeleteAlert(items[i].TheAlertItem); if (!successful) { break; } } if (successful) { Platform.Log(LogLevel.Info, "All Alert items deleted by user."); } else { Platform.Log(LogLevel.Error, "PreResetConfirmDialog_Confirmed: Unable to delete all Alert items."); MessageBox.Message = ErrorMessages.AlertDeleteFailed; MessageBox.MessageType = MessageBox.MessageTypeEnum.ERROR; MessageBox.Show(); } OnAllAlertsDeleted(); }