Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PerRecipientFields.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Waher.Content.Dsn
6{
12 public enum Action
13 {
20 failed,
21
30 delayed,
31
40 delivered,
41
50 relayed,
51
61 expanded
62 }
63
68 {
69 private string originalRecipient = null;
70 private string originalRecipientType = null;
71 private string finalRecipient = null;
72 private string finalRecipientType = null;
73 private Action? action = null;
74 private int[] status = null;
75 private string remoteMta = null;
76 private string remoteMtaType = null;
77 private string diagnosticCode = null;
78 private string diagnosticCodeType = null;
79 private string finalLogId = null;
80 private DateTimeOffset? lastAttemptDate = null;
81 private DateTimeOffset? willRetryUntil = null;
82
87 public PerRecipientFields(string[] Rows)
88 : base(Rows)
89 {
90 }
91
98 protected override bool Parse(string Key, string Value)
99 {
100 switch (Key.ToUpper())
101 {
102 case "ORIGINAL-RECIPIENT":
103 if (this.ParseType(ref Value, out this.originalRecipientType))
104 {
105 this.originalRecipient = Value;
106 return true;
107 }
108 else
109 return false;
110
111 case "FINAL-RECIPIENT":
112 if (this.ParseType(ref Value, out this.finalRecipientType))
113 {
114 this.finalRecipient = Value;
115 return true;
116 }
117 else
118 return false;
119
120 case "ACTION":
121 if (Enum.TryParse(Value.ToLower(), out Action Action))
122 {
123 this.action = Action;
124 return true;
125 }
126 else
127 return false;
128
129 case "STATUS":
130 string[] Parts = Value.Split('.');
131 if (Parts.Length == 3 &&
132 int.TryParse(Parts[0], out int s1) &&
133 int.TryParse(Parts[1], out int s2) &&
134 int.TryParse(Parts[2], out int s3))
135 {
136 this.status = new int[] { s1, s2, s3 };
137 return true;
138 }
139 else
140 return false;
141
142 case "REMOTE-MTA":
143 if (this.ParseType(ref Value, out this.remoteMtaType))
144 {
145 this.remoteMta = Value;
146 return true;
147 }
148 else
149 return false;
150
151 case "DIAGNOSTIC-CODE":
152 if (this.ParseType(ref Value, out this.diagnosticCodeType))
153 {
154 this.diagnosticCode = Value;
155 return true;
156 }
157 else
158 return false;
159
160 case "LAST-ATTEMPT-DATE":
161 if (CommonTypes.TryParseRfc822(Value, out DateTimeOffset DTO))
162 {
163 this.lastAttemptDate = DTO;
164 return true;
165 }
166 else
167 return false;
168
169 case "FINAL-LOG-ID":
170 this.finalLogId = Value;
171 return true;
172
173 case "WILL-RETRY-UNTIL":
174 if (CommonTypes.TryParseRfc822(Value, out DTO))
175 {
176 this.willRetryUntil = DTO;
177 return true;
178 }
179 else
180 return false;
181
182 default:
183 return false;
184 }
185 }
186
190 public string OriginalRecipient => this.originalRecipient;
191
195 public string OriginalRecipientType => this.originalRecipientType;
196
200 public string FinalRecipient => this.finalRecipient;
201
205 public string FinalRecipientType => this.finalRecipientType;
206
210 public Action? Action => this.action;
211
215 public int[] Status => this.status;
216
220 public string RemoteMta => this.remoteMta;
221
225 public string RemoteMtaType => this.remoteMtaType;
226
230 public string DiagnosticCode => this.diagnosticCode;
231
235 public string DiagnosticCodeType => this.diagnosticCodeType;
236
240 public string FinalLogId => this.finalLogId;
241
245 public DateTimeOffset? LastAttemptDate => this.lastAttemptDate;
246
250 public DateTimeOffset? WillRetryUntil => this.willRetryUntil;
251 }
252}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static bool TryParseRfc822(string s, out DateTimeOffset Value)
Parses a date and time value encoded according to RFC 822, §5.
Definition: CommonTypes.cs:170
Base class for DSN field classes.
Definition: DsnFields.cs:11
bool ParseType(ref string Value, out string Type)
Parses a type value prefixed to the field value.
Definition: DsnFields.cs:60
Information fields for one recipient.
string RemoteMtaType
Type of Remote Message Transfer Agent
string OriginalRecipient
Original recipient
PerRecipientFields(string[] Rows)
Information fields for one recipient.
DateTimeOffset? LastAttemptDate
Timepoint of last attempt
DateTimeOffset? WillRetryUntil
Until when retries will be made
override bool Parse(string Key, string Value)
Parses a field
string OriginalRecipientType
Type of original recipient
string DiagnosticCodeType
Type of Diagnostic code
string RemoteMta
Remote Message Transfer Agent
string FinalRecipientType
Type of final recipient
Action
The Action field indicates the action performed by the Reporting-MTA as a result of its attempt to de...