Пример #1
0
        public void Log(LogReceivedEventArgs logReceivedEvent)
        {
            var azureFileDirectory = _azureService.GetCloudFileDirectoryByEvent(logReceivedEvent.LogInfo.LogEvent);

            if (azureFileDirectory == null)
            {
                return;
            }

            var fileConfig = _fileConfigContainer.Get(logReceivedEvent.LogInfo.LogEvent);

            if (fileConfig == null)
            {
                return;
            }

            CloudFile file = azureFileDirectory.GetFileReference(fileConfig.FileName);

            string filePath = Path.Combine(fileConfig.LogPath, fileConfig.FileName);

            if (File.Exists(filePath))
            {
                throw new FileNotFoundException($"{filePath} not found.");
            }

            using (var fileStream = File.OpenRead(filePath))
            {
                file.UploadFromStream(fileStream);
            }
        }