Preview for send all functionality
This commit is contained in:
parent
4d65172fbf
commit
ffca8e5bdd
@ -433,44 +433,50 @@ namespace ENI2.DetailViewControls
|
||||
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmSend, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
bool somethingsNotSaved = false;
|
||||
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
|
||||
this.SendMessages((IList<Message>)this.dataGridMessages.SelectedItems);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendMessages(IList<Message> messages)
|
||||
{
|
||||
bool somethingsNotSaved = false;
|
||||
|
||||
foreach (Message selectedMessage in messages)
|
||||
{
|
||||
if (selectedMessage.IsDirty) somethingsNotSaved = true;
|
||||
}
|
||||
|
||||
if (somethingsNotSaved)
|
||||
{
|
||||
if (MessageBox.Show(Properties.Resources.textUnsavedChangesSendAnyWay, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
|
||||
return;
|
||||
}
|
||||
|
||||
List<Message> watchList = new List<Message>();
|
||||
foreach (Message selectedMessage in messages)
|
||||
{
|
||||
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
|
||||
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
|
||||
string userName = "?";
|
||||
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
|
||||
{
|
||||
if (selectedMessage.IsDirty) somethingsNotSaved = true;
|
||||
userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
|
||||
}
|
||||
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
|
||||
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
|
||||
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
|
||||
watchList.Add(selectedMessage);
|
||||
}
|
||||
|
||||
if(somethingsNotSaved)
|
||||
{
|
||||
if (MessageBox.Show(Properties.Resources.textUnsavedChangesSendAnyWay, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
|
||||
return;
|
||||
}
|
||||
// komplette Anmeldung auf "zu versenden" stellen
|
||||
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
|
||||
this.Core.DefaultReportingPartyId = App.UserId;
|
||||
|
||||
List<Message> watchList = new List<Message>();
|
||||
foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
|
||||
{
|
||||
if (selectedMessage.Reset) selectedMessage.Reset = false; // "nochmal" Versenden ist möglich
|
||||
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
|
||||
string userName = "?";
|
||||
if (App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
|
||||
{
|
||||
userName = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].Logon;
|
||||
}
|
||||
selectedMessage.ChangedBy = string.Format("{0} at {1} (Send)", userName, DateTime.Now);
|
||||
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageSentAt, DateTime.Now);
|
||||
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(selectedMessage);
|
||||
watchList.Add(selectedMessage);
|
||||
}
|
||||
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core); // löst auch den Watchdog aus
|
||||
this.OnRequestSendValidation();
|
||||
this.dataGridMessages.Items.Refresh();
|
||||
|
||||
// komplette Anmeldung auf "zu versenden" stellen
|
||||
this.Core.BSMDStatusInternal = MessageCore.BSMDStatus.TOSEND;
|
||||
this.Core.DefaultReportingPartyId = App.UserId;
|
||||
|
||||
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core); // löst auch den Watchdog aus
|
||||
this.OnRequestSendValidation();
|
||||
this.dataGridMessages.Items.Refresh();
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
if (this.mssd == null)
|
||||
{
|
||||
this.mssd = new MessageSendStatusDialog(this.Core);
|
||||
@ -490,7 +496,6 @@ namespace ENI2.DetailViewControls
|
||||
this.mssd.Activate(); // bring to foreground
|
||||
this.mssd.AddMessages(watchList);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private void contextResetMessage(object sender, RoutedEventArgs e)
|
||||
@ -828,7 +833,38 @@ namespace ENI2.DetailViewControls
|
||||
|
||||
private void buttonSendAll_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// TBD
|
||||
SelectImportClassesDialog sicd = new SelectImportClassesDialog();
|
||||
List<Message> readyToSendMessages = new List<Message>();
|
||||
|
||||
foreach (Message message in this.Messages)
|
||||
{
|
||||
if (message.MessageNotificationClass == NotificationClass.STO) continue;
|
||||
// other filters?
|
||||
|
||||
if (((message.ViolationCount ?? 0) > 0) || ((message.ErrorCount ?? 0) > 0)) continue; // these need more work
|
||||
readyToSendMessages.Add(message);
|
||||
}
|
||||
|
||||
sicd.Messages = readyToSendMessages;
|
||||
sicd.IsTransit = this.Core.IsTransit;
|
||||
|
||||
if ((sicd.ShowDialog() ?? false) && (sicd.SelectedClasses.Count > 0))
|
||||
{
|
||||
// now send all selected messages
|
||||
List<Message> toSendMessages = new List<Message>();
|
||||
foreach(NotificationClass notificationClass in sicd.SelectedClasses)
|
||||
{
|
||||
Message selectedMessage = readyToSendMessages.Find(x => x.MessageNotificationClass == notificationClass);
|
||||
if (selectedMessage != null)
|
||||
{
|
||||
toSendMessages.Add(selectedMessage);
|
||||
}
|
||||
}
|
||||
if (toSendMessages.Count > 0)
|
||||
{
|
||||
this.SendMessages(toSendMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
2
ENI2/Properties/Resources.Designer.cs
generated
2
ENI2/Properties/Resources.Designer.cs
generated
@ -5306,7 +5306,7 @@ namespace ENI2.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Select classes to import.
|
||||
/// Looks up a localized string similar to Select message classes.
|
||||
/// </summary>
|
||||
public static string textSelectImportClasses {
|
||||
get {
|
||||
|
||||
@ -1757,7 +1757,7 @@
|
||||
<value>Select all</value>
|
||||
</data>
|
||||
<data name="textSelectImportClasses" xml:space="preserve">
|
||||
<value>Select classes to import</value>
|
||||
<value>Select message classes</value>
|
||||
</data>
|
||||
<data name="textSelectNone" xml:space="preserve">
|
||||
<value>Select none</value>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user