示例#1
0
        public List <MonitoringFile> GetCollectedLogsForSession(string sessionId, string blobSasUri)
        {
            var filesCollected = new List <MonitoringFile>();

            if (string.IsNullOrWhiteSpace(blobSasUri))
            {
                string folderName = CpuMonitoring.GetLogsFolderForSession(sessionId);
                if (FileSystemHelpers.DirectoryExists(folderName))
                {
                    var logFiles = FileSystemHelpers.GetFilesInDirectory(folderName, "*.dmp", false, SearchOption.TopDirectoryOnly);
                    foreach (var fileName in logFiles)
                    {
                        string relativePath = MonitoringFile.GetRelativePath(sessionId, Path.GetFileName(fileName));
                        filesCollected.Add(new MonitoringFile(fileName, relativePath));
                    }
                }
            }
            else
            {
                string        directoryPath = Path.Combine("Monitoring", "Logs", sessionId);
                List <string> files         = new List <string>();
                var           dir           = BlobController.GetBlobDirectory(directoryPath, blobSasUri);
                foreach (
                    IListBlobItem item in
                    dir.ListBlobs(useFlatBlobListing: true))
                {
                    var    relativePath = item.Uri.ToString().Replace(item.Container.Uri.ToString() + "/", "");
                    string fileName     = item.Uri.Segments.Last();
                    filesCollected.Add(new MonitoringFile(fileName, relativePath));
                }
            }
            return(filesCollected);
        }
示例#2
0
        internal void AddReportToLog(string sessionId, string logfileName, string reportFilePath, List <string> errors, bool shouldUpdateSessionStatus = true)
        {
            var session  = GetSession(sessionId);
            var lockFile = AcquireSessionLock(session);

            foreach (var log in session.FilesCollected)
            {
                if (log.FileName.Equals(logfileName, StringComparison.OrdinalIgnoreCase))
                {
                    if (!string.IsNullOrWhiteSpace(reportFilePath))
                    {
                        log.ReportFile             = reportFilePath;
                        log.ReportFileRelativePath = MonitoringFile.GetRelativePath(sessionId, Path.GetFileName(reportFilePath));
                    }
                    if (errors != null && errors.Count > 0)
                    {
                        if (log.AnalysisErrors != null)
                        {
                            log.AnalysisErrors.Concat(errors);
                        }
                        else
                        {
                            log.AnalysisErrors = errors;
                        }
                    }
                    break;
                }
            }

            if (shouldUpdateSessionStatus)
            {
                bool sessionAnalysisPending = session.FilesCollected.Any(log => string.IsNullOrWhiteSpace(log.ReportFile) && (log.AnalysisErrors == null));
                if (!sessionAnalysisPending)
                {
                    session.AnalysisStatus = AnalysisStatus.Completed;
                }
            }
            SaveSession(session, lockFile);
        }