/// <summary>
        /// Deletes a package from the store.
        /// </summary>
        /// <param name="packageId">The ID of the package to delete.</param>
        /// <param name="packageVersion">The version of the package to delete.</param>
        /// <exception cref="ArgumentNullException"><paramref name="packageId"/> is null or contains only whitespace or <paramref name="packageVersion"/> is null.</exception>
        public override void DeletePackage(string packageId, SemanticVersion packageVersion)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                throw new ArgumentNullException("packageId");
            }
            if (packageVersion == null)
            {
                throw new ArgumentNullException("packageVersion");
            }

            InitPackageStore();

            _logger.Debug("DeletePackage('" + packageId + "', '" + packageVersion + "') called");

            var packagePath = Path.Combine(RootPath, packageId);

            if (_fileSystemOperations.DirectoryExists(packagePath))
            {
                var versionPath = Path.Combine(packagePath, packageId + "." + packageVersion + ".nupkg");
                _logger.Debug("Deleting file '" + versionPath + "'.");
                try
                {
                    _fileSystemOperations.DeleteFile(versionPath);
                }
                catch (Exception ex)
                {
                    _logger.Error(string.Format("Error deleting package '{0}', version '{1}'", packageId, packageVersion), ex);
                    throw;
                }

                if (!_fileSystemOperations.EnumerateFileSystemEntries(packagePath).Any())
                {
                    _logger.Debug("Deleting folder '" + packagePath + "'.");
                    try
                    {
                        _fileSystemOperations.DeleteDirectory(packagePath);
                    }
                    catch (Exception ex)
                    {
                        _logger.Warn(string.Format("Exception while attemptnig to delete folder '{0}')", packagePath), ex);
                    }
                }
            }
            else
            {
                _logger.WarnFormat("Attempted to delete pacakage ('{0}', '{1}') that didn't exist ", packageId, packageVersion);
            }
        }
 /// <summary>
 /// Конвертировать ячейку Microstation в Jpeg
 /// </summary>
 private ISignatureFileData ToJpegByte(IElementMicrostation cellSignature, ISignatureLibrary signatureLibraryBase) =>
 GetSignatureFileSavePath(signatureLibraryBase).
 Void(filePath => cellSignature.DrawToEmfFile(GetSignatureFileSavePath(signatureLibraryBase),
                                              ProjectSignatureSettings.JpegPixelSize.Width,
                                              ProjectSignatureSettings.JpegPixelSize.Height)).
 Map(filePathEmf => new SignatureFileData(signatureLibraryBase.PersonId, signatureLibraryBase.PersonInformation,
                                          JpegConverter.ToJpegFromEmf(filePathEmf), false).
     Void(_ => _fileSystemOperations.DeleteFile(filePathEmf))).
 Void(_ => cellSignature.Remove());
Ejemplo n.º 3
0
        private void RemoveFiles(IDictionary <string, FileInfo> found, IEnumerable <string> files, Func <FileInfo, bool> predicate)
        {
            var remove = files.Where(file =>
            {
                var info = found[file];
                return(predicate(info));
            }).ToList();

            foreach (var file in remove)
            {
                _ops.DeleteFile(file);
                found.Remove(file);
            }
        }