예제 #1
0
 private void AddFilesFromDirectory(string path, List <string> assemblies)
 {
     if (!_directoryWrapper.Exists(path))
     {
         return;
     }
     assemblies.AddRange(_directoryWrapper.EnumerateFiles(path, "*.dll", SearchOption.TopDirectoryOnly));
 }
예제 #2
0
        private void AddFilesFromDirectory(string path, List <string> assemblies)
        {
            if (!_directoryWrapper.Exists(path))
            {
//                Logger.Warn("Path does not exist: {0}", path);
                return;
            }
            assemblies.AddRange(_directoryWrapper.EnumerateFiles(path, "*.dll", SearchOption.TopDirectoryOnly));
        }
예제 #3
0
        public List <LogMessage> GetStatus(StatusOptions options)
        {
            IStatusData status;

            if (!_directoryWrapper.Exists(options.Path))
            {
                AddLogMessage($"ERROR - Verify that you have the correct path: {options.Path}", MessageType.Critical);

                return(_log);
            }

            try
            {
                status = _diskApi.GetDiskStats(options.Path);
            }
            catch (Exception ex)
            {
                AddLogMessage("ERROR - " + ex.Message, MessageType.Critical);

                return(_log);
            }

            if (options.IsVerbose)
            {
                AddLogMessage("Status: ", MessageType.Info);
            }

            if (status.AvailableGigabytes > options.WarningThreshold)
            {
                AddLogMessage("OK", MessageType.Ok);
            }
            else if (status.AvailableGigabytes <= options.WarningThreshold && status.AvailableGigabytes > options.CriticalThreshold)
            {
                AddLogMessage("Warning", MessageType.Warning);
            }
            else if (status.AvailableGigabytes <= options.CriticalThreshold)
            {
                AddLogMessage("Critical", MessageType.Critical);
            }

            if (options.IsVerbose)
            {
                AddLogMessage("Disk at path: " + options.Path, MessageType.Info);
                AddLogMessage("Total space: " + status.TotalGigabytes + " GB", MessageType.Info);
                AddLogMessage("Used space: " + status.UsedGigabytes + " GB", MessageType.Info);
                AddLogMessage("Available space: " + status.AvailableGigabytes + " GB", MessageType.Info);
            }

            return(_log);
        }
예제 #4
0
        private List <string> FindAssemblyReferencesInDirectories(List <string> directories)
        {
            List <string> assemblyLocations = new List <string>();

            directories.AddRange(DefaultScriptReferencesLocations);
            foreach (var assemblyReferencesLocation in directories)
            {
                if (_directory.Exists(assemblyReferencesLocation))
                {
                    DirectoryInfo folder = new DirectoryInfo(assemblyReferencesLocation);
                    var           files  = folder.GetFiles("*.dll", SearchOption.AllDirectories);
                    assemblyLocations.AddRange(files.Select(x => x.FullName));
                }
            }

            return(assemblyLocations);
        }
예제 #5
0
        public ProviderXmlData[] LoadAll()
        {
            var absolutePath = pathUtility.GetAbsolutePath(dataDirectory);

            if (!directory.Exists(absolutePath))
            {
                return(new ProviderXmlData[0]);
            }

            var dataFiles = directory.GetFiles(absolutePath, "*.xml", SearchOption.AllDirectories);
            var documents = dataFiles
                            .Select(Create)
                            .Where(f => f != null)
                            .ToArray();

            return(documents);
        }
        public IEnumerable <string> FindTrxFiles(string buildRootDirectory, bool shouldLog = true)
        {
            Debug.Assert(!string.IsNullOrEmpty(buildRootDirectory));
            Debug.Assert(directoryWrapper.Exists(buildRootDirectory),
                         "The specified build root directory should exist: " + buildRootDirectory);

            if (shouldLog)
            {
                this.logger.LogInfo(Resources.TRX_DIAG_LocatingTrx);
            }

            var testDirectories = directoryWrapper.GetDirectories(buildRootDirectory, TestResultsFolderName, SearchOption.AllDirectories);

            if (testDirectories == null ||
                !testDirectories.Any())
            {
                if (shouldLog)
                {
                    this.logger.LogInfo(Resources.TRX_DIAG_TestResultsDirectoryNotFound, buildRootDirectory);
                }

                return(Enumerable.Empty <string>());
            }

            if (shouldLog)
            {
                this.logger.LogInfo(Resources.TRX_DIAG_FolderPaths, string.Join(", ", testDirectories));
            }

            var trxFiles = testDirectories.SelectMany(dir => directoryWrapper.GetFiles(dir, "*.trx")).ToArray();

            if (shouldLog)
            {
                if (trxFiles.Length == 0)
                {
                    this.logger.LogInfo(Resources.TRX_DIAG_NoTestResultsFound);
                }
                else
                {
                    this.logger.LogInfo(Resources.TRX_DIAG_TrxFilesFound, string.Join(", ", trxFiles));
                }
            }

            return(trxFiles);
        }
예제 #7
0
        public HttpResponseMessage Move([FromBody] MovePhotosViewModel viewModel)
        {
            if (viewModel == null || string.IsNullOrEmpty(viewModel.AlbumName) || !viewModel.PhotosId.Any())
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Uknown error"));
            }

            var uploadFileInfos = new List <UploadResultViewModel>();

            try
            {
                int albumId;

                try
                {
                    albumId = _albumService.GetAlbumId(User.Id, viewModel.AlbumName);
                }
                catch (AlbumNotFoundException)
                {
                    albumId = _albumService.CreateAlbum(User.Id, viewModel.AlbumName).Id;
                }

                // Get temporary album Id
                int tempAlbumId = _albumService.GetAlbumId(User.Id, "Temporary");

                // Get path to the temporary album folder
                string pathToTempAlbum = _pathUtil.BuildAbsoluteAlbumPath(User.Id, tempAlbumId);

                // Get path to the destination album folder
                string pathToDestAlbum = _pathUtil.BuildAbsoluteAlbumPath(User.Id, albumId);

                if (!_directoryWrapper.Exists(pathToDestAlbum))
                {
                    _directoryWrapper.CreateDirectory(pathToDestAlbum);
                }

                foreach (int photoId in viewModel.PhotosId)
                {
                    PhotoModel photoModel = _photoService.GetPhoto(User.Id, photoId);

                    string fileInTempAlbum = string.Format("{0}\\{1}.{2}", pathToTempAlbum, photoModel.Id,
                                                           photoModel.Format);

                    string fileInDestAlbum = string.Format("{0}\\{1}.{2}", pathToDestAlbum, photoModel.Id,
                                                           photoModel.Format);

                    bool fileExist = _fileWrapper.Exists(fileInTempAlbum);

                    if (fileExist)
                    {
                        try
                        {
                            _fileWrapper.Move(fileInTempAlbum, fileInDestAlbum);
                        }
                        catch (Exception)
                        {
                            uploadFileInfos.Add(new UploadResultViewModel
                            {
                                Id         = photoId,
                                IsAccepted = false,
                                Error      = "Can't save photo to selected album"
                            });

                            continue;
                        }

                        photoModel.AlbumId = albumId;

                        _photoService.UpdatePhoto(photoModel);

                        // Create thumbnails for photo
                        _photoProcessor.CreateThumbnails(User.Id, albumId, photoModel.Id, photoModel.Format);

                        uploadFileInfos.Add(new UploadResultViewModel
                        {
                            Id         = photoId,
                            IsAccepted = true
                        });
                    }
                    else
                    {
                        uploadFileInfos.Add(new UploadResultViewModel
                        {
                            Id         = photoId,
                            IsAccepted = false,
                            Error      = "Photo is not found in temporary album"
                        });
                    }
                }

                // Create collage for album
                _collageProcessor.CreateCollage(User.Id, albumId);
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, uploadFileInfos, new JsonMediaTypeFormatter()));
        }