Esempio n. 1
0
 public async Task ProcessStatusMessageAsync(StatusItemCollection message)
 {
     foreach (var item in _parent._messageHandlers)
     {
         await item.ProcessStatusMessageAsync(message).ConfigureAwait(false);
     }
 }
        protected override async Task <object> OnProcessAsync(StatusItemCollection message)
        {
            if (message == null)
            {
                return(ResponseMessage.NoResponse);
            }

            await DbHandlers.Instance.Messages.ProcessStatusMessageAsync(message).ConfigureAwait(false);

            return(ResponseMessage.NoResponse);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public static NodeStatusItem Create(StatusItemCollection collection)
        {
            if (collection == null)
            {
                return(null);
            }
            var newStatus = new NodeStatusItem
            {
                Environment            = collection.EnvironmentName,
                Machine                = collection.MachineName,
                Application            = collection.ApplicationName,
                InstanceId             = collection.InstanceId,
                ApplicationDisplayName = collection.ApplicationDisplayName,
                ElapsedMilliseconds    = collection.ElapsedMilliseconds,
                Date      = collection.Timestamp.Date,
                StartTime = collection.StartTime,
                Timestamp = collection.Timestamp,
            };

            newStatus.FillValues(collection);
            return(newStatus);
        }
Esempio n. 5
0
        public void FillValues(StatusItemCollection collection)
        {
            if (collection == null)
            {
                return;
            }
            if (Values == null)
            {
                Values = new List <NodeStatusItemValue>();
            }
            else
            {
                Values.Clear();
            }

            InnerFillValues(null, collection.Items);

            void InnerFillValues(string keyPrefix, List <StatusItem> children)
            {
                if (children == null)
                {
                    return;
                }
                foreach (var item in children)
                {
                    var key = string.IsNullOrEmpty(keyPrefix) ? item.Name : keyPrefix + "\\" + item.Name;
                    if (item.Values != null)
                    {
                        foreach (var itemValue in item.Values)
                        {
                            var vKey = key + "\\" + itemValue.Key;

                            if (itemValue.RawValue != null)
                            {
                                Values.Add(new NodeStatusItemValue
                                {
                                    Key   = vKey,
                                    Type  = itemValue.Type,
                                    Value = itemValue.RawValue
                                });
                            }
                            if (itemValue.Values != null && itemValue.Values.Length > 0)
                            {
                                foreach (var itemValueValue in itemValue.Values)
                                {
                                    var vvKey = vKey + "\\" + itemValueValue.Name;
                                    Values.Add(new NodeStatusItemValue
                                    {
                                        Key   = vvKey,
                                        Type  = itemValueValue.Type,
                                        Value = itemValueValue.RawValue
                                    });
                                }
                            }
                        }
                    }
                    if (item.Children != null)
                    {
                        InnerFillValues(key, item.Children);
                    }
                }
            }
        }