DocSpace-buildtools/common/ASC.Core.Common/Notify/NotifyResult.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2022-02-15 11:52:43 +00:00
namespace ASC.Notify;
public class NotifyResult
2019-05-15 14:56:09 +00:00
{
2022-02-15 11:52:43 +00:00
public SendResult Result { get; internal set; }
public List<SendResponse> Responses { get; set; }
2019-05-15 14:56:09 +00:00
2022-02-15 11:52:43 +00:00
internal NotifyResult(SendResult result, List<SendResponse> responses)
{
Result = result;
Responses = responses ?? new List<SendResponse>();
}
2019-05-15 14:56:09 +00:00
2022-02-15 11:52:43 +00:00
public override string ToString()
{
var sb = new StringBuilder();
sb.AppendFormat("SendResult: {0} whith {1} sub-results", Result, Responses.Count);
foreach (var responce in Responses)
2019-05-15 14:56:09 +00:00
{
2022-02-15 11:52:43 +00:00
var recipient = "<recipient:nomessage>";
var error = "";
if (responce.NoticeMessage != null)
2019-05-15 14:56:09 +00:00
{
2022-02-15 11:52:43 +00:00
if (responce.NoticeMessage.Recipient != null)
2019-05-15 14:56:09 +00:00
{
2022-02-15 11:52:43 +00:00
recipient = responce.NoticeMessage.Recipient.Addresses.Length > 0 ?
responce.NoticeMessage.Recipient.Addresses[0] :
"<no-address>";
2019-05-15 14:56:09 +00:00
}
2022-02-15 11:52:43 +00:00
else
{
2022-02-15 11:52:43 +00:00
recipient = "<null-address>";
}
2022-02-15 11:52:43 +00:00
}
if (responce.Exception != null)
{
error = responce.Exception.Message;
2019-05-15 14:56:09 +00:00
}
2022-02-15 11:52:43 +00:00
sb.AppendLine();
sb.AppendFormat(" {3}->{0}({1})={2} {4}", recipient, responce.SenderName, responce.Result, responce.NotifyAction.ID, error);
2019-05-15 14:56:09 +00:00
}
2022-02-15 11:52:43 +00:00
return sb.ToString();
2019-05-15 14:56:09 +00:00
}
2022-02-15 11:52:43 +00:00
}