Пример #1
0
        public async Task <Dictionary <string, int> > GetSourceIdsAsync(IEnumerable <string> sourceNames)
        {
            var logSources = await _logReader.GetLogSourcesAsync();

            var logSourcesDictionary = new Dictionary <string, int>();

            foreach (var logSource in logSources)
            {
                logSourcesDictionary.Add(logSource.Name, logSource.Id);
            }

            foreach (var name in sourceNames)
            {
                if (!logSourcesDictionary.ContainsKey(name))
                {
                    var logEnvironment = await _logWriter.CreateLogSourceAsync(name);

                    logSourcesDictionary.Add(logEnvironment.Name, logEnvironment.Id);
                }
            }

            return(logSourcesDictionary);
        }