private void ProbeEvent(EventSchema eventSchema, EventSource source) { using (var listener = new ProbeEventListener(eventSchema, this)) { try { listener.EnableEvents(source, eventSchema.Level, eventSchema.Keywords); MethodInfo method; if (this.TryInvokeMethod(eventSchema, source, listener, out method)) { if (listener.EventData == null) { throw new EventSourceAnalyzerException(string.Format(CultureInfo.CurrentCulture, Resources.EventSourceAnalyzerMissingWriteEventCallError, method.Name)); } if (listener.Error != null) { throw listener.Error; } } } finally { listener.DisableEvents(source); } } }
public async Task <Member> RetrieveMember(EventSchema reservationEvent) { Member member; using (var connection = new SqlConnection(_connectionString)) { using (var command = new SqlCommand("Member.uspRetrieveMemberDetails", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@MemberID", reservationEvent.BookReservation.MemberID); command.Parameters["@MemberID"].Direction = System.Data.ParameterDirection.Input; command.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar, -1).Direction = System.Data.ParameterDirection.Output; command.Parameters.Add("@Email", System.Data.SqlDbType.NVarChar, -1).Direction = System.Data.ParameterDirection.Output; await connection.OpenAsync().ConfigureAwait(false); await command.ExecuteNonQueryAsync().ConfigureAwait(false); member = new Member() { Name = Convert.ToString(command.Parameters["@Name"].Value), Email = Convert.ToString(command.Parameters["@Email"].Value) }; } } return(member); }
public void updateInventoryCount(EventSchema schema) { if (Items.ContainsKey(schema.id)) { var item = Items[schema.id]; item.InventoryCount = schema.inventoryCount; item.LastUpdateTimestamp = schema.lastUpdateTimestamp; item.Description = schema.description; item.ProductName = schema.productName; item.Upc = schema.upc; if (schema.type.Equals("shipment")) { item.InventoryCount += schema.inventoryCount; item.LastShipmentTimestamp = schema.lastShipmentTimestamp; } } else { var item = new Item(); item.Id = schema.id; item.InventoryCount = schema.inventoryCount; item.LastUpdateTimestamp = schema.lastUpdateTimestamp; item.Description = schema.description; item.ProductName = schema.productName; item.Upc = schema.upc; if (schema.type.Equals("shipment")) { item.LastShipmentTimestamp = schema.lastShipmentTimestamp; } Items.Add(schema.id, item); } }
internal List <WbpsEvent> getWbapEvents() { List <WbpsEvent> ret = new List <WbpsEvent>(); for (int i = 0; i < pageSchema.Events.Count; i++) { EventSchema eventSchema = pageSchema.Events[i]; WbpsEvent wEvent = new WbpsEvent(); wEvent.EventName = eventSchema.EventName; if (String.IsNullOrEmpty(wEvent.ElementName))//兼容旧版 { wEvent.ElementName = eventSchema.Id; } wEvent.ElementName = eventSchema.ElementName; wEvent.EventRequest.FlowId = eventSchema.ActionFlow; wEvent.EventRequest.ElementDatas = getFlowNeedElementDatas(eventSchema.ActionFlow); wEvent.EventRequest.PageId = request.PageId; wEvent.EventRequest.SessionId = this.sessionId; wEvent.ActionFlow = eventSchema.ActionFlow; //if (eventSchema.FlowVars != null) //{ // foreach (NameValue prop in eventSchema.FlowVars) // { // wevent.Vars.Add(prop.Name, prop.Value); // } //} ret.Add(wEvent); } return(ret); }
public IEventSchema GetSchema() { var schema = new EventSchema(); var entityTypes = typeof(IEntitiesAssembly).Assembly .GetTypes() .Where(x => !x.IsAbstract && !x.IsInterface && typeof(IEntity).IsAssignableFrom(x)) .ToList(); foreach (var entityType in entityTypes) { var @event = new EventBuilder() .ForEntity(entityType) .WithEvent <AuditEvent>() .WithEvent <ValidationEvent>() .WithEvent <VersioningEvent>() .Build(); schema.Add(@event); } var imageProcessorEvent = new EventBuilder() .ForEntity <Product>() .WithEvent <ImageProcessorEvent>() .Build(); schema.Add(imageProcessorEvent); return(schema); }
public async Task <bool> RetrieveBorrowStatus(EventSchema reservationEvent) { bool retVal = false; using (var connection = new SqlConnection(_connectionString)) { using (var command = new SqlCommand("Member.uspRetrieveBorrowStatus", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@MemberID", reservationEvent.BookReservation.MemberID); command.Parameters["@MemberID"].Direction = System.Data.ParameterDirection.Input; command.Parameters.Add("@CanBorrow", System.Data.SqlDbType.Bit); command.Parameters["@CanBorrow"].Direction = System.Data.ParameterDirection.Output; await connection.OpenAsync().ConfigureAwait(false); await command.ExecuteNonQueryAsync().ConfigureAwait(false); retVal = Convert.ToBoolean(command.Parameters["@CanBorrow"].Value); } } return(retVal); }
protected override void OnEventWritten(EventWrittenEventArgs eventData) { Guard.ArgumentNotNull(eventData, "eventData"); EventSchema schema = null; try { if (eventData.EventSource.Settings != EventSourceSettings.EtwSelfDescribingEventFormat) { schema = this.schemaCache.GetSchema(eventData.EventId, eventData.EventSource); } else { schema = new EventSchema(eventData.EventId, eventData.EventSource.Guid, eventData.EventSource.Name, eventData.Level, eventData.Task, eventData.EventName, eventData.Opcode, eventData.Opcode.ToString(), eventData.Keywords, null, 0, eventData.PayloadNames); } } catch (Exception ex) { // TODO: should I notify all the observers or should I just publish a non-transient // error and not notify the rest of the listeners? // this.subject.OnError(ex); //SemanticLoggingEventSource.Log.ParsingEventSourceManifestFailed(eventData.EventSource.Name, eventData.EventId, ex.ToString()); return; } var entry = EventEntry.Create(eventData, schema); this.subject.OnNext(entry); }
/// <summary> /// Creates a new <see cref="EventEntry"/> instance based on the <paramref name="args"/> and the <paramref name="schema"/>. /// </summary> /// <param name="args">The <see cref="EventWrittenEventArgs"/> representing the event to log.</param> /// <param name="schema">The <see cref="EventSchema"/> for the source originating the event.</param> /// <returns>An entry describing the event.</returns> public static EventEntry Create(EventWrittenEventArgs args, EventSchema schema) { Guard.ArgumentNotNull(args, "args"); Guard.ArgumentNotNull(schema, "schema"); var timestamp = DateTimeOffset.Now; // TODO: validate whether we want to do this pro-actively or should we wait until the // last possible moment (as the formatted message might not be used in a sink). string formattedMessage = null; if (args.Message != null) { formattedMessage = string.Format(CultureInfo.InvariantCulture, args.Message, args.Payload.ToArray()); } return(new EventEntry( args.EventSource.Guid, args.EventId, formattedMessage, args.Payload, timestamp, CurrentProcessId, ProcessPropertyAccess.GetCurrentThreadId(), ActivityIdPropertyAccess.GetActivityId(args), ActivityIdPropertyAccess.GetRelatedActivityId(args), schema)); }
public async Task CreateReservation(EventSchema reservationEvent) { using (var connection = new SqlConnection(_connectionString)) { using (var command = new SqlCommand("Reservation.uspCreateReservation", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@CorrelationID", reservationEvent.BookReservation.CorrelationID); command.Parameters["@CorrelationID"].Direction = System.Data.ParameterDirection.Input; command.Parameters.AddWithValue("@MemberID", reservationEvent.BookReservation.MemberID); command.Parameters["@MemberID"].Direction = System.Data.ParameterDirection.Input; command.Parameters.AddWithValue("@ISBN", reservationEvent.BookReservation.ISBN); command.Parameters["@ISBN"].Direction = System.Data.ParameterDirection.Input; command.Parameters.AddWithValue("@Status", reservationEvent.EventType.ToString()); command.Parameters["@Status"].Direction = System.Data.ParameterDirection.Input; await connection.OpenAsync().ConfigureAwait(false); await command.ExecuteNonQueryAsync().ConfigureAwait(false); await connection.CloseAsync().ConfigureAwait(false); } } }
public static void CopyCommonEventData(ICalendarData calendarData, Event theEvent, bool isMeeting, UserSmtpAddress userSmtpAddress) { EventSchema schema = theEvent.Schema; int num = (theEvent.PopupReminderSettings != null && theEvent.PopupReminderSettings.Count > 0) ? theEvent.PopupReminderSettings[0].ReminderMinutesBeforeStart : 0; if (theEvent.IsPropertySet(schema.BodyProperty) && theEvent.Body != null && theEvent.Body.Content != null) { calendarData.Body = new Body { Data = theEvent.Body.Content, Type = new byte?((byte)SyncCalendarUtils.GetEasBodyType(theEvent.Body.ContentType)) }; } if (theEvent.IsPropertySet(schema.StartProperty)) { calendarData.StartTime = SyncCalendarUtils.ToStringDateTime(theEvent.Start); } if (theEvent.IsPropertySet(schema.EndProperty)) { calendarData.EndTime = SyncCalendarUtils.ToStringDateTime(theEvent.End); } if (theEvent.IsPropertySet(schema.SubjectProperty)) { calendarData.CalendarSubject = theEvent.Subject; } if (theEvent.IsPropertySet(schema.LocationProperty)) { calendarData.Location = ((theEvent.Location != null) ? ((!string.IsNullOrEmpty(theEvent.Location.DisplayName)) ? theEvent.Location.DisplayName : null) : null); } if (theEvent.IsPropertySet(schema.PopupReminderSettingsProperty)) { calendarData.Reminder = ((num > 0) ? new uint?((uint)num) : null); } if (theEvent.IsPropertySet(schema.IsAllDayProperty)) { calendarData.AllDayEvent = new byte?(Convert.ToByte(theEvent.IsAllDay)); } if (theEvent.IsPropertySet(schema.ShowAsProperty)) { EasBusyStatus?busyStatus = SyncCalendarUtils.GetBusyStatus(theEvent.ShowAs); calendarData.BusyStatus = ((busyStatus != null) ? new byte?((byte)busyStatus.GetValueOrDefault()) : null); } if (theEvent.IsPropertySet(schema.SensitivityProperty)) { calendarData.Sensitivity = new byte?((byte)theEvent.Sensitivity); } if (theEvent.IsPropertySet(schema.LastModifiedTimeProperty)) { calendarData.DtStamp = SyncCalendarUtils.ToStringDateTime(theEvent.LastModifiedTime); } if (theEvent.IsPropertySet(schema.CategoriesProperty)) { calendarData.CalendarCategories = SyncCalendarUtils.GetCategories(theEvent.Categories); } if (isMeeting && theEvent.IsPropertySet(schema.AttendeesProperty)) { calendarData.Attendees = SyncCalendarUtils.GetAttendees(theEvent.Attendees, userSmtpAddress, theEvent.ResponseStatus); } }
/// <summary> /// Initializes a new instance of the <see cref="EventEntry" /> class. /// </summary> /// <param name="sourceId">The source id.</param> /// <param name="eventId">The event id.</param> /// <param name="formattedMessage">The message.</param> /// <param name="payload">The payload.</param> /// <param name="timestamp">The timestamp.</param> /// <param name="schema">The schema.</param> public EventEntry(Guid sourceId, int eventId, string formattedMessage, ReadOnlyCollection <object> payload, DateTimeOffset timestamp, EventSchema schema) { this.providerId = sourceId; this.eventId = eventId; this.formattedMessage = formattedMessage; this.payload = payload; this.timestamp = timestamp; this.schema = schema; }
private static async Task <EventGridTopicEndpoint> CreateAsync(EventSchema type, TestConfig config, ITestOutputHelper testOutput) { ServiceBusEventConsumerHost serviceBusEventConsumerHost = await CreateServiceBusEventConsumerHostAsync( config.GetServiceBusTopicName(type), config.GetServiceBusConnectionString(), testOutput); return(new EventGridTopicEndpoint(type, serviceBusEventConsumerHost, config)); }
private static void PrintResponse(EventSchema eventSchema) { Console.WriteLine("EventSchema"); foreach (EventProperty eventProperty in eventSchema.Properties) { Console.WriteLine(" {0}: {1}", eventProperty.Name, eventProperty.Type); } Console.WriteLine(); }
private EventGridTopicEndpoint( EventSchema eventSchema, ServiceBusEventConsumerHost serviceBusEventConsumerHost, TestConfig config) { Guard.NotNull(serviceBusEventConsumerHost, nameof(serviceBusEventConsumerHost)); Guard.NotNull(config, nameof(config)); _eventSchema = eventSchema; _configuration = config; ServiceBusEventConsumerHost = serviceBusEventConsumerHost; }
/// <summary> /// Initializes a new instance of the <see cref="EventEntry" /> class. /// </summary> /// <param name="sourceId">The source id.</param> /// <param name="eventId">The event id.</param> /// <param name="formattedMessage">The message.</param> /// <param name="payload">The payload.</param> /// <param name="timestamp">The timestamp.</param> /// <param name="processId">The process id.</param> /// <param name="threadId">The thread id.</param> /// <param name="activityId">The activity id.</param> /// <param name="relatedActivityId">The related activity id.</param> /// <param name="schema">The schema.</param> public EventEntry(Guid sourceId, int eventId, string formattedMessage, ReadOnlyCollection <object> payload, DateTimeOffset timestamp, int processId, int threadId, Guid activityId, Guid relatedActivityId, EventSchema schema) { this.providerId = sourceId; this.eventId = eventId; this.formattedMessage = formattedMessage; this.payload = payload; this.timestamp = timestamp; this.processId = processId; this.threadId = threadId; this.activityId = activityId; this.relatedActivityId = relatedActivityId; this.schema = schema; }
private string SwitchEventGridEndpointType(EventSchema type, string eventGridEventKey, string cloudEventKey) { switch (type) { case EventSchema.EventGrid: return(_config[eventGridEventKey]); case EventSchema.CloudEvent: return(_config[cloudEventKey]); default: throw new ArgumentOutOfRangeException(nameof(type), type, "Unknown Event Grid endpoint type"); } }
public void Discover(IEnumerable <Type> types) { ProjectionSchemaRegister helper = new ProjectionSchemaRegister(); helper.Discover(types); foreach (var t in types.Where(x => typeof(IEvent).IsAssignableFrom(x) && !x.IsAbstract)) { var eventSchema = new EventSchema(t, ServiceConventions.GetCategoryFromNamespace(t.Namespace)); var findByEvent = helper.FindByEvent(t); eventSchema.AppendProjections(findByEvent); _events.Add(eventSchema); } }
private Event GetExceptionDelta(Event exception) { Event @event = new Event(); EventSchema schema = exception.Schema; @event.Id = exception.Id; @event.Start = exception.Start; @event.End = exception.End; @event.LastModifiedTime = exception.LastModifiedTime; foreach (string a in exception.ExceptionalProperties) { if (a == schema.BodyProperty.Name) { @event.Body = exception.Body; } else if (a == schema.IsAllDayProperty.Name) { @event.IsAllDay = exception.IsAllDay; } else if (a == schema.ShowAsProperty.Name) { @event.ShowAs = exception.ShowAs; } else if (a == schema.LocationProperty.Name) { @event.Location = exception.Location; } else if (a == schema.PopupReminderSettingsProperty.Name) { @event.PopupReminderSettings = exception.PopupReminderSettings; } else if (a == schema.SensitivityProperty.Name) { @event.Sensitivity = exception.Sensitivity; } else if (a == schema.SubjectProperty.Name) { @event.Subject = exception.Subject; } else if (a == schema.AttendeesProperty.Name) { @event.Attendees = exception.Attendees; } else if (a == schema.CalendarProperty.Name) { @event.Categories = exception.Categories; } } return(@event); }
private static EventSchema getEventSchema(OnHandDocument onHandDocument) { EventSchema schema = new EventSchema(); schema.storeId = onHandDocument.StoreId; schema.id = onHandDocument.Id; schema.upc = onHandDocument.Upc; schema.inventoryCount = onHandDocument.InventoryCount; schema.type = "onHand"; schema.productName = onHandDocument.ProductName; schema.description = onHandDocument.ProductName; schema.lastUpdateTimestamp = onHandDocument.LastUpdateTimestamp; return(schema); }
private static void addQueryValidation(EventSchema eventSchema, Type eventType) { var queryValidationAttribute = eventType.GetAttribute <QueryValidationAttribute>(); if (queryValidationAttribute == null) { return; } var descriptor = queryValidationAttribute.Descriptor; eventSchema.ValidateByQuery = true; // NOTE: we need a globally-safe way of referring to URLs eventSchema.ValidationQueryUrl = "/queries/" + descriptor.Namespace + "/" + descriptor.QueryObject + "/validate"; }
/// <summary> /// Creates an <see cref="IEventGridPublisher"/> implementation that can publish events to an endpoint corresponding with the given <paramref name="eventSchema"/>. /// </summary> /// <param name="eventSchema">The schema that corresponds to the target endpoint to which the publisher will publish events.</param> /// <param name="configuration">The instance to retrieve the required values to configure the publisher.</param> public static IEventGridPublisher CreateEventPublisher(EventSchema eventSchema, TestConfig configuration) { Guard.NotNull(configuration, nameof(configuration)); string topicEndpoint = configuration.GetEventGridTopicEndpoint(eventSchema); string endpointKey = configuration.GetEventGridEndpointKey(eventSchema); IEventGridPublisher publisher = EventGridPublisherBuilder .ForTopic(topicEndpoint) .UsingAuthenticationKey(endpointKey) .Build(); return(publisher); }
public void MessageInconsistencyTest() { EventEntry _lastEvent = null; int _calls = 0; ObservableEventListener _listener = new ObservableEventListener(); IDisposable subscription = _listener.Subscribe <EventEntry>(x => { _calls++; _lastEvent = x; }); using (SinkSubscription <ObservableEventListener> _sinkSubscription = new SinkSubscription <ObservableEventListener>(subscription, _listener)) { Assert.IsNotNull(_sinkSubscription.Sink); ReactiveNetworkingEventSource _log = Log; _sinkSubscription.Sink.EnableEvents(_log, EventLevel.LogAlways, EventKeywords.All); Assert.IsNull(_lastEvent); const int _position = 12345; _log.MessageInconsistency(_position); Assert.IsNotNull(_lastEvent); Assert.AreEqual <int>(1, _calls); //_lastEvent content Assert.AreEqual <int>(4, _lastEvent.EventId); Assert.AreEqual <Guid>(Guid.Empty, _lastEvent.ActivityId); string _message = "Unexpected end of message while reading 12345 element."; Assert.AreEqual <string>(_message, _lastEvent.FormattedMessage, _lastEvent.FormattedMessage); //schema EventSchema _Schema = _lastEvent.Schema; Assert.AreEqual <string>("ConsumerInfo", _Schema.EventName); Assert.AreEqual <int>(4, _Schema.Id); //Assert.IsTrue((_Schema.Keywords & SemanticEventSource.Keywords.Diagnostic2) > 0); //Assert.AreEqual<string>("PackageContent", _Schema.KeywordsDescription); Assert.AreEqual <EventLevel>(EventLevel.Warning, _Schema.Level); Assert.AreEqual <string>("Info", _Schema.OpcodeName); Assert.AreEqual <EventOpcode>(EventOpcode.Info, _Schema.Opcode); Assert.AreEqual <Guid>(new Guid("C8666C20-6FEF-4DD0-BB66-5807BA629DA8"), _Schema.ProviderId); Assert.AreEqual <string>("UAOOI-Networking-SemanticData-Diagnostics", _Schema.ProviderName); Assert.AreEqual <string>("Consumer", _Schema.TaskName); Assert.AreEqual <EventTask>(Tasks.Consumer, _Schema.Task); Assert.AreEqual <int>(0, _Schema.Version); //Payload Assert.AreEqual <string>("System.Collections.ObjectModel.ReadOnlyCollection`1[System.Object]", _lastEvent.Payload.ToString(), _lastEvent.Payload.ToString()); Assert.AreEqual <int>(1, _lastEvent.Payload.Count); Assert.IsInstanceOfType(_lastEvent.Payload[0], typeof(Int32)); Assert.AreEqual <Int32>(_position, (Int32)_lastEvent.Payload[0]); Assert.AreEqual <string>("position", _lastEvent.Schema.Payload[0]); } }
public void GetIMessageHandlerTest() { EventEntry _lastEvent = null; int _calls = 0; ObservableEventListener _listener = new ObservableEventListener(); IDisposable subscription = _listener.Subscribe(x => { _calls++; _lastEvent = x; }); using (SinkSubscription <ObservableEventListener> _sinkSubscription = new SinkSubscription <ObservableEventListener>(subscription, _listener)) { Assert.IsNotNull(_sinkSubscription.Sink); UDPMessageHandlerSemanticEventSource _log = UDPMessageHandlerSemanticEventSource.Log; _sinkSubscription.Sink.EnableEvents(_log, EventLevel.LogAlways, Keywords.All); Assert.IsNull(_lastEvent); _log.GetIMessageHandler("NameOfIMessageHandlerMethod"); Assert.AreEqual <int>(1, _calls); Assert.IsNotNull(_lastEvent); //_lastEvent content Assert.AreEqual <int>(2, _lastEvent.EventId); Assert.AreEqual <Guid>(Guid.Empty, _lastEvent.ActivityId); string _message = "The IMessageHandlerFactory.NameOfIMessageHandlerMethod method has been called."; Assert.AreEqual <string>(_message, _lastEvent.FormattedMessage, _lastEvent.FormattedMessage); //schema EventSchema _Schema = _lastEvent.Schema; Assert.AreEqual <string>("CodeBehaviorStart", _Schema.EventName); Assert.AreEqual <int>(2, _Schema.Id); ////Assert.IsTrue((_Schema.Keywords & UDPMessageHandlerSemanticEventSource.Keywords.Diagnostic) > 0); //Assert.AreEqual<string>("PackageContent", _Schema.KeywordsDescription); Assert.AreEqual <EventLevel>(EventLevel.Informational, _Schema.Level); Assert.AreEqual <string>("Start", _Schema.OpcodeName); Assert.AreEqual <EventOpcode>(EventOpcode.Start, _Schema.Opcode); Assert.AreEqual <Guid>(new Guid("84C6B563-8282-47CB-9111-7B29D8B43E23"), _Schema.ProviderId); Assert.AreEqual <string>("UAOOI-Networking-UDPMessageHandler-Diagnostic", _Schema.ProviderName); Assert.AreEqual <string>("CodeBehavior", _Schema.TaskName); Assert.AreEqual <EventTask>(Tasks.Infrastructure, _Schema.Task); Assert.AreEqual <int>(0, _Schema.Version); //Payload Assert.AreEqual <string>("System.Collections.ObjectModel.ReadOnlyCollection`1[System.Object]", _lastEvent.Payload.ToString(), _lastEvent.Payload.ToString()); Assert.AreEqual <int>(1, _lastEvent.Payload.Count); Assert.IsInstanceOfType(_lastEvent.Payload[0], typeof(String)); Assert.AreEqual <string>("NameOfIMessageHandlerMethod", (string)_lastEvent.Payload[0]); Assert.AreEqual <string>("iMessageHandlerName", _lastEvent.Schema.Payload[0]); } }
public void JoiningMulticastGroupTest() { EventEntry _lastEvent = null; int _calls = 0; ObservableEventListener _listener = new ObservableEventListener(); IDisposable subscription = _listener.Subscribe(x => { _calls++; _lastEvent = x; }); using (SinkSubscription <ObservableEventListener> _sinkSubscription = new SinkSubscription <ObservableEventListener>(subscription, _listener)) { Assert.IsNotNull(_sinkSubscription.Sink); UDPMessageHandlerSemanticEventSource _log = UDPMessageHandlerSemanticEventSource.Log; _sinkSubscription.Sink.EnableEvents(_log, EventLevel.LogAlways, Keywords.All); Assert.IsNull(_lastEvent); _log.JoiningMulticastGroup(new IPAddress(new byte[] { 192, 168, 0, 0 })); Assert.AreEqual <int>(1, _calls); Assert.IsNotNull(_lastEvent); //_lastEvent content Assert.AreEqual <int>(7, _lastEvent.EventId); Assert.AreEqual <Guid>(Guid.Empty, _lastEvent.ActivityId); string _message = "Joining the multicast group: 192.168.0.0"; Assert.AreEqual <string>(_message, _lastEvent.FormattedMessage, _lastEvent.FormattedMessage); //schema EventSchema _Schema = _lastEvent.Schema; Assert.AreEqual <string>("StackStart", _Schema.EventName); Assert.AreEqual <int>(7, _Schema.Id); ////Assert.IsTrue((_Schema.Keywords & UDPMessageHandlerSemanticEventSource.Keywords.Diagnostic) > 0); //Assert.AreEqual<string>("PackageContent", _Schema.KeywordsDescription); Assert.AreEqual <EventLevel>(EventLevel.Informational, _Schema.Level); Assert.AreEqual <string>("Start", _Schema.OpcodeName); Assert.AreEqual <EventOpcode>(EventOpcode.Start, _Schema.Opcode); Assert.AreEqual <Guid>(new Guid("84C6B563-8282-47CB-9111-7B29D8B43E23"), _Schema.ProviderId); Assert.AreEqual <string>("UAOOI-Networking-UDPMessageHandler-Diagnostic", _Schema.ProviderName); Assert.AreEqual <string>("Stack", _Schema.TaskName); Assert.AreEqual <EventTask>(Tasks.Stack, _Schema.Task); Assert.AreEqual <int>(0, _Schema.Version); //Payload Assert.AreEqual <string>("System.Collections.ObjectModel.ReadOnlyCollection`1[System.Object]", _lastEvent.Payload.ToString(), _lastEvent.Payload.ToString()); Assert.AreEqual <int>(1, _lastEvent.Payload.Count); Assert.IsInstanceOfType(_lastEvent.Payload[0], typeof(String)); Assert.AreEqual <string>("192.168.0.0", (string)_lastEvent.Payload[0]); Assert.AreEqual <string>("multicastGroup", _lastEvent.Schema.Payload[0]); } }
public SchemaObject(EventSchema eventSchema, string name, string @namespace) : this() { Type = SchemaObjectType.Object; Title = name; Description = string.Format("JSON schema for {0}/{1}.", @namespace, name); if (eventSchema.Properties == null) { return; } if (eventSchema.ValidateByQuery) { ValidationQueryUrl = eventSchema.ValidationQueryUrl; } foreach (var property in eventSchema.Properties) { var validated = isPropertyValidated(property.Value); var propertyType = getPropertyType(property.Value); ISchemaPropertyMetadata metadata; if (validated) { var validationMetadata = getValidatedPropertyMetadata(property.Value, propertyType); if (validationMetadata.Required.HasValue && validationMetadata.Required.Value) { Required.Add(property.Key); } metadata = validationMetadata; } else { metadata = new SimplePropertyMetadata(propertyType); } Properties.Add(property.Key, metadata); } }
private static void CreatePublicFacingTables(string connectionString, int timeout, int maxDegreeOfParallelism, Pipelines pipelineOptions) { { // resources... var schema = new ResourceSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // attendance... var schema = new AttendanceSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // bookings... var schema = new BookingSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // events... var schema = new EventSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // exams... var schema = new ExamSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // membership... var schema = new MembershipSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } { // misc... var schema = new MiscSchema(connectionString, timeout, maxDegreeOfParallelism, pipelineOptions); schema.CreateTables(); } }
public void StartingApplicationTest() { EventEntry _lastEvent = null; int _calls = 0; ObservableEventListener _listener = new ObservableEventListener(); IDisposable subscription = _listener.Subscribe(x => { _calls++; _lastEvent = x; }); using (SinkSubscription <ObservableEventListener> _sinkSubscription = new SinkSubscription <ObservableEventListener>(subscription, _listener)) { Assert.IsNotNull(_sinkSubscription.Sink); ReferenceApplicationEventSource _log = ReferenceApplicationEventSource.Log; _sinkSubscription.Sink.EnableEvents(_log, EventLevel.LogAlways, EventKeywords.All); Assert.IsNull(_lastEvent); _log.StartingApplication("Message handler name"); Assert.IsNotNull(_lastEvent); Assert.AreEqual <int>(1, _calls); //_lastEvent content Assert.AreEqual <int>(2, _lastEvent.EventId); Assert.AreEqual <Guid>(Guid.Empty, _lastEvent.ActivityId); string _message = "The application has been started using the message handling provider Message handler name."; Assert.AreEqual <string>(_message, _lastEvent.FormattedMessage, _lastEvent.FormattedMessage); //schema EventSchema _Schema = _lastEvent.Schema; Assert.AreEqual <string>("InfrastructureStart", _Schema.EventName); Assert.AreEqual <int>(2, _Schema.Id); //Assert.IsTrue((_Schema.Keywords & SemanticEventSource.Keywords.Diagnostic2) > 0); //Assert.AreEqual<string>("PackageContent", _Schema.KeywordsDescription); Assert.AreEqual <EventLevel>(EventLevel.Informational, _Schema.Level); Assert.AreEqual <string>("Start", _Schema.OpcodeName); Assert.AreEqual <EventOpcode>(EventOpcode.Start, _Schema.Opcode); Assert.AreEqual <Guid>(new Guid("D8637D00-5EAD-4538-9286-8C6DE346D8C8"), _Schema.ProviderId); Assert.AreEqual <string>("UAOOI-Networking-ReferenceApplication-Diagnostic", _Schema.ProviderName); Assert.AreEqual <string>("Infrastructure", _Schema.TaskName); Assert.AreEqual <EventTask>(Tasks.Infrastructure, _Schema.Task); Assert.AreEqual <int>(0, _Schema.Version); //Payload Assert.AreEqual <string>("System.Collections.ObjectModel.ReadOnlyCollection`1[System.Object]", _lastEvent.Payload.ToString(), _lastEvent.Payload.ToString()); Assert.AreEqual <int>(1, _lastEvent.Payload.Count); } }
public void ReferenceApplicationEventSourceExtensionsTest() { List <EventEntry> _lastEvents = new List <EventEntry>(); ObservableEventListener _listener = new ObservableEventListener(); IDisposable subscription = _listener.Subscribe(x => { _lastEvents.Add(x); }); using (SinkSubscription <ObservableEventListener> _sinkSubscription = new SinkSubscription <ObservableEventListener>(subscription, _listener)) { Assert.IsNotNull(_sinkSubscription.Sink); ReferenceApplicationEventSource _log = ReferenceApplicationEventSource.Log; _sinkSubscription.Sink.EnableEvents(_log, EventLevel.LogAlways, EventKeywords.All); Assert.AreEqual <int>(0, _lastEvents.Count); NotImplementedException _ex = new NotImplementedException("testing exception", new NotImplementedException()); _log.LogException(_ex); Assert.AreEqual <int>(2, _lastEvents.Count); //_lastEvent content Assert.AreEqual <int>(1, _lastEvents[0].EventId); Assert.AreEqual <Guid>(Guid.Empty, _lastEvents[0].ActivityId); string _message = "Application Failure: An exception has benn caught: of type NotImplementedException capturing the message: testing exception"; Assert.AreEqual <string>(_message, _lastEvents[0].FormattedMessage); //schema EventSchema _Schema = _lastEvents[0].Schema; Assert.AreEqual <string>("InfrastructureInfo", _Schema.EventName); Assert.AreEqual <int>(1, _Schema.Id); //Assert.IsTrue((_Schema.Keywords & SemanticEventSource.Keywords.Diagnostic2) > 0); //Assert.AreEqual<string>("PackageContent", _Schema.KeywordsDescription); Assert.AreEqual <EventLevel>(EventLevel.Error, _Schema.Level); Assert.AreEqual <string>("Info", _Schema.OpcodeName); Assert.AreEqual <EventOpcode>(EventOpcode.Info, _Schema.Opcode); Assert.AreEqual <Guid>(new Guid("D8637D00-5EAD-4538-9286-8C6DE346D8C8"), _Schema.ProviderId); Assert.AreEqual <string>("UAOOI-Networking-ReferenceApplication-Diagnostic", _Schema.ProviderName); Assert.AreEqual <string>("Infrastructure", _Schema.TaskName); Assert.AreEqual <EventTask>(Tasks.Infrastructure, _Schema.Task); Assert.AreEqual <int>(0, _Schema.Version); //Payload Assert.AreEqual <string>("System.Collections.ObjectModel.ReadOnlyCollection`1[System.Object]", _lastEvents[0].Payload.ToString(), _lastEvents[0].Payload.ToString()); Assert.AreEqual <int>(1, _lastEvents[0].Payload.Count); } }
private static List <EventSchema> getEventSchema(ShipmentDocument shipmentDocument) { List <EventSchema> schemas = new List <EventSchema>(); foreach (var item in shipmentDocument.Items) { EventSchema schema = new EventSchema(); schema.storeId = shipmentDocument.StoreId; schema.id = $"{shipmentDocument.DivisionId}:{shipmentDocument.StoreId}:{item.upc}"; schema.inventoryCount = item.shipmentAmount; schema.type = "shipment"; schema.upc = item.upc; schema.lastUpdateTimestamp = shipmentDocument.ArrivalTimestamp; schema.lastShipmentTimestamp = shipmentDocument.ArrivalTimestamp; schemas.Add(schema); } return(schemas); }
public static EventSchema GenerateSchema(Type ev) { var eventSchema = new EventSchema(); var propertyTypeTable = new Dictionary <Type, Action <PropertyInfo> > { { typeof(string), prop => addPropertyToSchema(eventSchema, prop, new JsonSchema { Type = JsonSchemaType.String }) }, { typeof(int), prop => addPropertyToSchema(eventSchema, prop, new JsonSchema { Type = JsonSchemaType.Integer }) }, { typeof(float), prop => addPropertyToSchema(eventSchema, prop, new JsonSchema { Type = JsonSchemaType.Float }) }, { typeof(bool), prop => addPropertyToSchema(eventSchema, prop, new JsonSchema { Type = JsonSchemaType.Boolean }) } }; foreach (var property in ev.GetProperties()) { var propertyType = property.PropertyType; if (propertyTypeTable.ContainsKey(propertyType)) { propertyTypeTable[propertyType](property); } else { // TODO: Is object the best type? Should this be an exception instead? addPropertyToSchema(eventSchema, property, new JsonSchema { Type = JsonSchemaType.Object }); } } addQueryValidation(eventSchema, ev); return(eventSchema); }