Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PersistedEvent.cs
1using System;
3
5{
9 [CollectionName("EventLog")]
10 [TypeName(TypeNameSerialization.None)]
11 [ArchivingTime(nameof(ArchiveDays))]
12 [Index("Timestamp")]
13 [Index("Object", "Timestamp")]
14 [Index("Actor", "Timestamp")]
15 [Index("EventId", "Timestamp")]
16 [Index("Facility", "Timestamp")]
17 [Index("Type", "Timestamp")]
18 public class PersistedEvent
19 {
20 private Guid objectId = Guid.Empty;
21 private DateTime timestamp = DateTime.MinValue;
22 private EventType type = EventType.Informational;
23 private EventLevel level = EventLevel.Minor;
24 private string message = string.Empty;
25 private string obj = string.Empty;
26 private string actor = string.Empty;
27 private string eventId = string.Empty;
28 private string module = string.Empty;
29 private string facility = string.Empty;
30 private string stackTrace = string.Empty;
31 private PersistedTag[] tags = null;
32
37 {
38 }
39
45 {
46 this.timestamp = Event.Timestamp;
47 this.type = Event.Type;
48 this.message = Event.Message;
49 this.obj = Event.Object;
50 this.actor = Event.Actor;
51 this.eventId = Event.EventId;
52 this.level = Event.Level;
53 this.facility = Event.Facility;
54 this.module = Event.Module;
55 this.stackTrace = Event.StackTrace;
56
57 if (Event.Tags is null)
58 this.tags = null;
59 else
60 {
61 int i, c = Event.Tags.Length;
62
63 this.tags = new PersistedTag[c];
64
65 for (i = 0; i < c; i++)
66 {
67 this.tags[i] = new PersistedTag()
68 {
69 Name = Event.Tags[i].Key,
70 Value = Event.Tags[i].Value
71 };
72 }
73 }
74 }
75
79 [ObjectId]
80 public Guid ObjectId
81 {
82 get => this.objectId;
83 set => this.objectId = value;
84 }
85
89 public DateTime Timestamp
90 {
91 get => this.timestamp;
92 set => this.timestamp = value;
93 }
94
99 {
100 get => this.type;
101 set => this.type = value;
102 }
103
107 [DefaultValue(EventLevel.Minor)]
109 {
110 get => this.level;
111 set => this.level = value;
112 }
113
117 public string Message
118 {
119 get => this.message;
120 set => this.message = value;
121 }
122
126 [IgnoreMember]
127 public string MessageFirstRow
128 {
129 get
130 {
131 string s = this.message.Trim();
132 int i = s.IndexOf('\n');
133 int j = s.IndexOf('\r');
134
135 if (i < 0)
136 i = j;
137 else if (j >= 0 && j < i)
138 i = j;
139
140 if (i < 0)
141 return s;
142 else
143 return s.Substring(0, i).TrimEnd();
144 }
145 }
146
150 public string Object
151 {
152 get => this.obj;
153 set => this.obj = value;
154 }
155
159 public string Actor
160 {
161 get => this.actor;
162 set => this.actor = value;
163 }
164
168 public string EventId
169 {
170 get => this.eventId;
171 set => this.eventId = value;
172 }
173
177 public string Facility
178 {
179 get => this.facility;
180 set => this.facility = value;
181 }
182
186 [DefaultValueStringEmpty]
187 public string Module
188 {
189 get => this.module;
190 set => this.module = value;
191 }
192
196 [DefaultValueStringEmpty]
197 public string StackTrace
198 {
199 get => this.stackTrace;
200 set => this.stackTrace = value;
201 }
202
206 [DefaultValueNull]
208 {
209 get => this.tags;
210 set => this.tags = value;
211 }
212
214 public override string ToString()
215 {
216 return this.message;
217 }
218
222 public int ArchiveDays => PersistedEventLog.ArchiveDays;
223 }
224}
Class representing an event.
Definition: Event.cs:10
string Message
Free-text event message.
Definition: Event.cs:131
EventType Type
Type of event.
Definition: Event.cs:121
string Object
Object related to the event.
Definition: Event.cs:136
EventLevel Level
Event Level.
Definition: Event.cs:126
string Actor
Actor responsible for the action causing the event.
Definition: Event.cs:141
string Module
Module where the event is reported.
Definition: Event.cs:156
DateTime Timestamp
Timestamp of event.
Definition: Event.cs:116
KeyValuePair< string, object >[] Tags
Variable set of tags providing event-specific information.
Definition: Event.cs:166
string EventId
Computer-readable Event ID identifying type of even.
Definition: Event.cs:146
string Facility
Facility can be either a facility in the network sense or in the system sense.
Definition: Event.cs:151
string StackTrace
Stack Trace of event.
Definition: Event.cs:161
Class representing a persisted event.
string Object
Object related to the event.
string Message
Free-text event message.
DateTime Timestamp
Timestamp of event.
string Actor
Actor responsible for the action causing the event.
string Module
Module where the event is reported.
string StackTrace
Stack Trace of event.
string EventId
Computer-readable Event ID identifying type of even.
int ArchiveDays
Number of days to archive event.
string MessageFirstRow
First row of Message.
PersistedEvent(Event Event)
Class representing a persisted event.
string Facility
Facility can be either a facility in the network sense or in the system sense.
PersistedTag[] Tags
Variable set of tags providing event-specific information.
PersistedEvent()
Class representing a persisted event.
Creates an even sink that stores incoming (logged) events in the local object database,...
Class representing a persisted tag.
Definition: PersistedTag.cs:10
EventLevel
Event level.
Definition: EventLevel.cs:7
EventType
Type of event.
Definition: EventType.cs:7
TypeNameSerialization
How the type name should be serialized.