Пример #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 <List <NodeStatusItem> > GetCurrentStatus(string environment, string machine, string application)
        {
            return(await RavenHelper.ExecuteAndReturnAsync(async session =>
            {
                var documentQuery = session.Advanced.AsyncDocumentQuery <NodeStatusItem>();
                var query = documentQuery
                            .WhereEquals(x => x.Environment, environment);

                if (!string.IsNullOrWhiteSpace(machine))
                {
                    query = query.WhereEquals(x => x.Machine, machine);
                }

                if (!string.IsNullOrWhiteSpace(application))
                {
                    query = query.WhereEquals(x => x.Application, application);
                }

                query = query
                        //.WhereGreaterThanOrEqual(i => i.Timestamp, DateTime.Now.AddMinutes(-30))
                        .OrderByDescending(i => i.Timestamp);

                var data = await query.ToListAsync().ConfigureAwait(false);
                var rData = data
                            .GroupBy(i => new { i.Environment, i.Machine, i.Application })
                            .Select(i => i.First())
                            .ToList();

                return rData;
            }).ConfigureAwait(false));
        }
Пример #3
0
 public async Task <SerializedObject> GetTraceObjectAsync(string id)
 {
     return(await RavenHelper.ExecuteAndReturnAsync(async session =>
     {
         var attachment = await session.Advanced.Attachments.GetAsync(id, "Trace").ConfigureAwait(false);
         var traceObject = attachment.Stream.DeserializeFromNBinary <object>();
         return (SerializedObject)traceObject;
     }).ConfigureAwait(false));
 }
Пример #4
0
 public async Task <List <BasicInfo> > GetEnvironmentsAndApps()
 {
     return(await RavenHelper.ExecuteAndReturnAsync(async session =>
     {
         var results = session.Query <NodeLogItem>()
                       .GroupBy(x => new
         {
             x.Environment,
             x.Machine,
             x.Application
         })
                       .Select(x => new BasicInfo
         {
             Environment = x.Key.Environment,
             Machine = x.Key.Machine,
             Application = x.Key.Application
         });
         return await results.ToListAsync().ConfigureAwait(false);
     }).ConfigureAwait(false));
 }
Пример #5
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);
        }
Пример #6
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);
            }
        }