mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-103290: When the alert filters are on enable the use to choose whetehr they want
to export all or only the shown alerts (functionality similar to the DismissAll button). Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
6cbea8adcc
commit
b54b30a150
@ -745,38 +745,69 @@ namespace XenAdmin.Dialogs
|
||||
|
||||
private void toolStripButtonExportAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dialog = new SaveFileDialog();
|
||||
dialog.AddExtension = true;
|
||||
dialog.Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.*)|*.*", Messages.CSV_DESCRIPTION, Messages.ALL_FILES);
|
||||
dialog.FilterIndex = 0;
|
||||
dialog.Title = Messages.EXPORT_ALL;
|
||||
dialog.RestoreDirectory = true;
|
||||
dialog.DefaultExt = "csv";
|
||||
dialog.CheckPathExists = false;
|
||||
dialog.OverwritePrompt = true;
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK)
|
||||
return;
|
||||
bool exportAll = true;
|
||||
|
||||
if (FilterIsOn)
|
||||
{
|
||||
using (var dlog = new ThreeButtonDialog(
|
||||
new ThreeButtonDialog.Details(null, Messages.ALERT_EXPORT_ALL_OR_FILTERED),
|
||||
new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_ALL_BUTTON, DialogResult.Yes),
|
||||
new ThreeButtonDialog.TBDButton(Messages.ALERT_EXPORT_FILTERED_BUTTON, DialogResult.No, ThreeButtonDialog.ButtonType.NONE),
|
||||
ThreeButtonDialog.ButtonCancel))
|
||||
{
|
||||
var result = dlog.ShowDialog(this);
|
||||
if (result == DialogResult.No)
|
||||
exportAll = false;
|
||||
else if (result == DialogResult.Cancel)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string fileName;
|
||||
using (SaveFileDialog dialog = new SaveFileDialog
|
||||
{
|
||||
AddExtension = true,
|
||||
Filter = string.Format("{0} (*.csv)|*.csv|{1} (*.*)|*.*",
|
||||
Messages.CSV_DESCRIPTION, Messages.ALL_FILES),
|
||||
FilterIndex = 0,
|
||||
Title = Messages.EXPORT_ALL,
|
||||
RestoreDirectory = true,
|
||||
DefaultExt = "csv",
|
||||
CheckPathExists = false,
|
||||
OverwritePrompt = true
|
||||
})
|
||||
{
|
||||
if (dialog.ShowDialog(this) != DialogResult.OK)
|
||||
return;
|
||||
fileName = dialog.FileName;
|
||||
}
|
||||
|
||||
new DelegatedAsyncAction(null,
|
||||
String.Format(Messages.EXPORT_SYSTEM_ALERTS, dialog.FileName),
|
||||
String.Format(Messages.EXPORTING_SYSTEM_ALERTS, dialog.FileName),
|
||||
String.Format(Messages.EXPORTED_SYSTEM_ALERTS, dialog.FileName),
|
||||
string.Format(Messages.EXPORT_SYSTEM_ALERTS, fileName),
|
||||
string.Format(Messages.EXPORTING_SYSTEM_ALERTS, fileName),
|
||||
string.Format(Messages.EXPORTED_SYSTEM_ALERTS, fileName),
|
||||
delegate
|
||||
{
|
||||
StreamWriter stream = new StreamWriter(dialog.FileName, false, UTF8Encoding.UTF8);
|
||||
try
|
||||
using (StreamWriter stream = new StreamWriter(fileName, false, UTF8Encoding.UTF8))
|
||||
{
|
||||
stream.WriteLine("{0},{1},{2},{3},{4}", Messages.TITLE,
|
||||
Messages.SEVERITY, Messages.DESCRIPTION, Messages.APPLIES_TO, Messages.TIMESTAMP);
|
||||
foreach (Alert a in Alert.Alerts)
|
||||
Messages.SEVERITY, Messages.DESCRIPTION,
|
||||
Messages.APPLIES_TO, Messages.TIMESTAMP);
|
||||
|
||||
if (exportAll)
|
||||
{
|
||||
stream.WriteLine(GetAlertDetailsCSVQuotes(a));
|
||||
foreach (Alert a in Alert.Alerts)
|
||||
stream.WriteLine(GetAlertDetailsCSVQuotes(a));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataGridViewRow row in GridViewAlerts.Rows)
|
||||
{
|
||||
var a = row.Tag as Alert;
|
||||
if (a != null)
|
||||
stream.WriteLine(GetAlertDetailsCSVQuotes(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.Close();
|
||||
stream.Dispose();
|
||||
}
|
||||
}).RunAsync();
|
||||
}
|
||||
|
27
XenModel/Messages.Designer.cs
generated
27
XenModel/Messages.Designer.cs
generated
@ -3816,6 +3816,33 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Export &all.
|
||||
/// </summary>
|
||||
public static string ALERT_EXPORT_ALL_BUTTON {
|
||||
get {
|
||||
return ResourceManager.GetString("ALERT_EXPORT_ALL_BUTTON", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You have applied filters to the list of alerts. Do you wish to export all alerts from every connected server, or only the alerts you have chosen to view?.
|
||||
/// </summary>
|
||||
public static string ALERT_EXPORT_ALL_OR_FILTERED {
|
||||
get {
|
||||
return ResourceManager.GetString("ALERT_EXPORT_ALL_OR_FILTERED", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Only export &filtered.
|
||||
/// </summary>
|
||||
public static string ALERT_EXPORT_FILTERED_BUTTON {
|
||||
get {
|
||||
return ResourceManager.GetString("ALERT_EXPORT_FILTERED_BUTTON", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Help.
|
||||
/// </summary>
|
||||
|
@ -1428,6 +1428,15 @@ Note that if RBAC is enabled, only alerts which you have privileges to dismiss w
|
||||
<data name="ALERT_DISMISS_CONFIRM" xml:space="preserve">
|
||||
<value>Once a system alert is dismissed it will be removed from the server permanently. Do you wish to continue?</value>
|
||||
</data>
|
||||
<data name="ALERT_EXPORT_ALL_BUTTON" xml:space="preserve">
|
||||
<value>Export &all</value>
|
||||
</data>
|
||||
<data name="ALERT_EXPORT_ALL_OR_FILTERED" xml:space="preserve">
|
||||
<value>You have applied filters to the list of alerts. Do you wish to export all alerts from every connected server, or only the alerts you have chosen to view?</value>
|
||||
</data>
|
||||
<data name="ALERT_EXPORT_FILTERED_BUTTON" xml:space="preserve">
|
||||
<value>Only export &filtered</value>
|
||||
</data>
|
||||
<data name="ALERT_GENERIC_HELP" xml:space="preserve">
|
||||
<value>Help</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user