示例#1
0
        public async Task ProcessLogItemsMessageAsync(List <LogItem> message)
        {
            Core.Log.InfoBasic("Storing LogItem messages...");

            foreach (var logItem in message)
            {
                await RavenHelper.ExecuteAsync(async session =>
                {
                    var logInfo = new NodeLogItem
                    {
                        Environment = logItem.EnvironmentName,
                        Machine     = logItem.MachineName,
                        Application = logItem.ApplicationName,
                        InstanceId  = logItem.InstanceId,
                        LogId       = logItem.Id,
                        Assembly    = logItem.AssemblyName,
                        Code        = logItem.Code,
                        Group       = logItem.GroupName,
                        Level       = logItem.Level,
                        Message     = logItem.Message,
                        Type        = logItem.TypeName,
                        Exception   = logItem.Exception,
                        Timestamp   = logItem.Timestamp
                    };
                    await session.StoreAsync(logInfo).ConfigureAwait(false);
                    await session.SaveChangesAsync().ConfigureAwait(false);
                }).ConfigureAwait(false);
            }
        }
示例#2
0
        public async Task ProcessStatusMessageAsync(StatusItemCollection message)
        {
            Core.Log.InfoBasic("Storing StatusCollection message...");
            await RavenHelper.ExecuteAsync(async session =>
            {
                var nodeStatus = await session.Advanced.AsyncDocumentQuery <NodeStatusItem>()
                                 .WhereEquals(node => node.InstanceId, message.InstanceId)
                                 .FirstOrDefaultAsync().ConfigureAwait(false);

                if (nodeStatus == null)
                {
                    var newStatus = NodeStatusItem.Create(message);
                    await session.StoreAsync(newStatus).ConfigureAwait(false);
                }
                else
                {
                    nodeStatus.Timestamp = message.Timestamp;
                    nodeStatus.FillValues(message);
                }
                await session.SaveChangesAsync().ConfigureAwait(false);
            }).ConfigureAwait(false);
        }
示例#3
0
        public async Task ProcessTraceItemsMessageAsync(List <MessagingTraceItem> message)
        {
            Core.Log.InfoBasic("Storing TraceItem messages...");
            foreach (var traceItem in message)
            {
                await RavenHelper.ExecuteAsync(async session =>
                {
                    var traceInfo = new NodeTraceItem
                    {
                        Environment = traceItem.EnvironmentName,
                        Machine     = traceItem.MachineName,
                        Application = traceItem.ApplicationName,
                        InstanceId  = traceItem.InstanceId,
                        TraceId     = traceItem.Id,
                        Tags        = traceItem.Tags?.Select(i => i.ToString()).Join(", "),
                        Group       = traceItem.GroupName,
                        Name        = traceItem.TraceName,
                        Timestamp   = traceItem.Timestamp
                    };
                    await session.StoreAsync(traceInfo).ConfigureAwait(false);

                    using (var ms = new MemoryStream())
                    {
                        if (traceItem.TraceObject != null)
                        {
                            traceItem.TraceObject.SerializeToNBinary(ms);
                            ms.Position = 0;
                        }

                        session.Advanced.Attachments.Store(traceInfo.Id, "Trace", ms, traceItem.TraceObject?.GetType().FullName);

                        await session.SaveChangesAsync().ConfigureAwait(false);
                    }
                }).ConfigureAwait(false);
            }
        }