public void ArchiveMetaData()
        {
            try
            {
                foreach (var directory in DestinationFolder.GetDirectories($"{DataSource.ArchiveInformationPackageId}.*"))
                {
                    directory.Delete(true);
                }

                var fileIndexPath = new FileInfo($@"{IndicesFolder}\{"fileIndex.xml"}");
                _fileIndex = new FileIndex(fileIndexPath, DestinationFolder);

                CreateNewMedia();
                ArchiveStandardSchemas();
                ArchiveLocalSchemas();
                ArchiveIndices();
                ArchiveContextDocumentation();

                _fileIndex.Persist();
            }
            catch (DeliveryEngineRepositoryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DeliveryEngineRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.RepositoryError, GetType().Name, ex.Message), ex);
            }
        }
Example #2
0
        public async Task UpdateDestinationFolder(DestinationFolder destinationFolder)
        {
            if (destinationFolder.Id == 0)
            {
                throw new ArgumentException($"Destination folder ({destinationFolder.Path}) doesn't exist.");
            }

            using (var db = new DataContext())
            {
                var dbDestinationFolder = await db.DestinationFolders.FindAsync(destinationFolder.Id);

                if (dbDestinationFolder == null)
                {
                    throw new ArgumentException($"Destination folder ({destinationFolder.Path}) doesn't exist.");
                }

                dbDestinationFolder.Path = destinationFolder.Path;

                await db.SaveChangesAsync();
            }

            await ReFillCache <Collection>();

            OnCollectionChanged();
        }
Example #3
0
        protected override void Run()
        {
            var webClient = new WebClient();

            var dirUrl = new Uri(DestinationFolder.NormalizeSlashes());
            var urls   = SourceUrls.Split(';').Select(o => new Uri(o));

            foreach (var url in urls)
            {
                var fileName = url.Segments.Last();
                var path     = new Uri(dirUrl, fileName).LocalPath;

                Log.LogMessage($"{url} -> {path}");

                var dir = Path.GetDirectoryName(path);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                webClient.DownloadFile(
                    address: url.ToString(),
                    fileName: path
                    );
            }
        }
    private async void FolderVM_SaveDestinationRequest(object sender, EventArgs e)
    {
        var folderVm = (DestinationFolderVM)sender;

        var destinationFolder = new DestinationFolder(
            folderVm.Id,
            Id,
            folderVm.Path,
            folderVm.NeedDevideImagesByHash,
            folderVm.NeedRename,
            folderVm.IncorrectFormatSubpath,
            folderVm.IncorrectHashSubpath,
            folderVm.NonHashSubpath);

        try
        {
            await _destinationFolderService.AddOrUpdateDestinationFolderAsync(destinationFolder);
            await LoadFolders();
        }
        catch (Exception ex)
        {
            App.MainWindowVM?.SetStatusError("Can't save folder", ex.Message);
            Debug.WriteLine("Can't save folder: " + ex.Message);
        }
    }
    private void InnerExecute()
    {
        var path = DestinationFolder.FullPath();

        Directory.CreateDirectory(path);

        var propertyProvider = new PropertyProvider()
        {
            { "version", GitVersionInformation.NuGetVersionV2 }
        };

        var packageBuilder = new PackageBuilder();

        using (var spec = File.OpenRead(NuSpecFile.FullPath()))
        {
            var manifest = Manifest.ReadFrom(spec, propertyProvider, false);
            packageBuilder.Populate(manifest.Metadata);
        }

        packageBuilder.PopulateFiles("", new[] { new ManifestFile {
                                                     Source = ReferenceLibrary.FullPath(), Target = "lib"
                                                 } });

        var debug = Path.ChangeExtension(ReferenceLibrary.FullPath(), ".pdb");

        if (File.Exists(debug))
        {
            packageBuilder.PopulateFiles("", new[] { new ManifestFile {
                                                         Source = debug, Target = "lib"
                                                     } });
        }

        if (File.Exists(PackagesConfig.FullPath()))
        {
            var dependencies = new List <PackageDependency>();

            var doc = XDocument.Load(PackagesConfig.FullPath());

            var packages = doc.Descendants()
                           .Where(x => x.Name == "package" && x.Attribute("developmentDependency")?.Value != "true")
                           .Select(p => new { id = p.Attribute("id").Value, version = SemanticVersion.Parse(p.Attribute("version").Value) })
                           .Select(p => new PackageDependency(p.id, new VersionSpec()
            {
                IsMinInclusive = true, MinVersion = p.version
            }));

            dependencies.AddRange(packages);

            packageBuilder.DependencySets.Add(new PackageDependencySet(null, dependencies));
        }

        var packagePath = Path.Combine(path, packageBuilder.GetFullName() + ".nupkg");

        using (var file = new FileStream(packagePath, FileMode.Create))
        {
            Log.LogMessage($"Saving file {packagePath}");

            packageBuilder.Save(file);
        }
    }
Example #6
0
        private void m_backUp_Click(object sender, EventArgs e)
        {
            if (!Path.IsPathRooted(DestinationFolder))
            {
                MessageBox.Show(this, FwCoreDlgs.ksBackupErrorRelativePath, FwCoreDlgs.ksErrorCreatingBackupDirCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                m_destinationFolder.Select();
                DialogResult = DialogResult.None;
                return;
            }

            if (!Directory.Exists(DestinationFolder))
            {
                try
                {
                    Directory.CreateDirectory(DestinationFolder);
                }
                catch (Exception e1)
                {
                    MessageBox.Show(this, e1.Message, FwCoreDlgs.ksErrorCreatingBackupDirCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    m_destinationFolder.Select();
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            if (!DestinationFolder.Equals(FwDirectoryFinder.DefaultBackupDirectory))
            {
                using (var dlgChangeDefaultBackupLocation = new ChangeDefaultBackupDir(m_helpTopicProvider))
                {
                    if (dlgChangeDefaultBackupLocation.ShowDialog(this) == DialogResult.Yes)
                    {
                        FwDirectoryFinder.DefaultBackupDirectory = DestinationFolder;
                    }
                }
            }

            if (m_presenter.FileNameProblems(this))
            {
                return;
            }

            try
            {
                using (new WaitCursor(this))
                    using (var progressDlg = new ProgressDialogWithTask(this))
                    {
                        BackupFilePath = m_presenter.BackupProject(progressDlg);
                    }
            }
            catch (FwBackupException be)
            {
                MessageBox.Show(this, string.Format(FwCoreDlgs.ksBackupErrorCreatingZipfile, be.ProjectName, be.Message),
                                FwCoreDlgs.ksBackupErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DialogResult = DialogResult.None;
            }
        }
Example #7
0
        public void GivenTheDestinationFolderDoesNotExist()
        {
            if (!DestinationFolder.Exists())
            {
                return;
            }

            Directory.Delete(DestinationFolder.FullName, true);
        }
 public OversawCollection(
     Collection collection,
     IReadOnlyCollection <SourceFolder> sourceFolders,
     DestinationFolder destinationFolder)
 {
     Collection        = collection ?? throw new ArgumentNullException(nameof(collection));
     SourceFolders     = sourceFolders ?? throw new ArgumentNullException(nameof(sourceFolders));
     DestinationFolder = destinationFolder ?? throw new ArgumentNullException(nameof(sourceFolders));
 }
Example #9
0
    public async Task <DestinationFolder> AddOrUpdateDestinationFolderAsync(DestinationFolder destinationFolder)
    {
        var request = _mapper.Map <DestinationFolderCreateRequest>(destinationFolder);

        var result = await _destinationFolderRoomClient.CreateOrUpdateAsync(
            destinationFolder.CollectionId,
            request);

        return(_mapper.Map <DestinationFolder>(result));
    }
        public static string ParsePath(DestinationFolder destinationFolder, string customPath)
        {
            string path = "";

                        #if !UNITY_EDITOR && UNITY_ANDROID
            // path = AndroidUtils.GetExternalPictureDirectory() ;
            // path = AndroidUtils.GetExternalFilesDir() ;
            path = AndroidUtils.GetFirstAvailableMediaStorage() + "/" + customPath;
                        #elif !UNITY_EDITOR && UNITY_IOS
            path = Application.persistentDataPath + "/" + customPath;
                        #else
            if (destinationFolder == DestinationFolder.CUSTOM_FOLDER)
            {
                path = customPath;
            }
            else if (destinationFolder == DestinationFolder.PERSISTENT_DATA_PATH)
            {
                // #if UNITY_EDITOR || UNITY_STANDALONE
                // path = Application.persistentDataPath + "/" + customPath;
                // #elif UNITY_ANDROID
                //              path = AndroidUtils.GetFirstAvailableMediaStorage()  + "/" + customPath;
                // #else
                path = Application.persistentDataPath + "/" + customPath;
                // #endif
            }
            else if (destinationFolder == DestinationFolder.DATA_PATH)
            {
                path = Application.dataPath + "/" + customPath;
            }
            else if (destinationFolder == DestinationFolder.PICTURES_FOLDER)
            {
                                        #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WSA || UNITY_WSA_10_0
                path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures) + "/" + customPath;
                // #elif UNITY_ANDROID
                //              path = AndroidUtils.GetExternalPictureDirectory()  + "/" + customPath;
                // #elif UNITY_IOS
                //              path = Application.persistentDataPath + "/" +customPath;
                                        #else
                path = Application.persistentDataPath + "/" + customPath;
                                        #endif
            }
                        #endif

            // Add a slash if not already at the end of the folder name
            if (path.Length > 0)
            {
                path = path.Replace("//", "/");
                if (path[path.Length - 1] != '/' && path[path.Length - 1] != '\\')
                {
                    path += "/";
                }
            }

            return(path);
        }
Example #11
0
        public SearchInfo()
        {
            WithExtensions = false;

            Src = null;
            Ref = null;

            SrcFound = new DestinationFolder();
            SrcNot   = new DestinationFolder();
            RefFound = new DestinationFolder();
        }
Example #12
0
 private static string?GetProblemSubfolder(DestinationFolder destinationDirectory,
                                           MoveProblem moveProblem)
 {
     return(moveProblem switch
     {
         MoveProblem.None => null,
         MoveProblem.InvalidFormat => destinationDirectory.FormatErrorSubfolder,
         MoveProblem.WithoutHash => destinationDirectory.WithoutHashErrorSubfolder,
         MoveProblem.IncorrectHash => destinationDirectory.HashErrorSubfolder,
         _ => throw new ArgumentOutOfRangeException(nameof(moveProblem), moveProblem, null)
     });
Example #13
0
 public void CleanUp()
 {
     LockFileStream?.Dispose();
     if (SourceFolder.Exists())
     {
         Directory.Delete(SourceFolder.FullName, true);
     }
     if (DestinationFolder.Exists())
     {
         Directory.Delete(DestinationFolder.FullName, true);
     }
 }
Example #14
0
        public ChooseInfo()
        {
            MinWidth  = 0;
            MinHeight = 0;
            MaxWidth  = 0;
            MaxHeight = 0;

            Src = null;

            Have   = new DestinationFolder();
            Havent = new DestinationFolder();
        }
Example #15
0
        public void WhenIUpdateTheDestinationFolder()
        {
            LastWriteTimeBeforeUpdate = new Dictionary <string, DateTime>();
            if (DestinationFolder.Exists())
            {
                foreach (var fileName in Directory.GetFiles(DestinationFolder.FullName, "*.*"))
                {
                    LastWriteTimeBeforeUpdate[fileName] = File.GetLastWriteTime(fileName);
                }
            }

            Sut.UpdateFolder(SourceFolder, DestinationFolder, FolderUpdateMethod.AssembliesButNotIfOnlySlightlyChanged, UpdateFolderErrorsAndInfos);
        }
Example #16
0
        private void ValidateFolder()
        {
            // ignore if null.
            if (DestinationFolder == null)
            {
                return;
            }

            if (DestinationFolder.StartsWith(@"\") || DestinationFolder.StartsWith("/"))
            {
                throw new Exception(@"Folder should not start with a \ or /");
            }

            if (DestinationFolder.EndsWith(@"\"))
            {
                throw new Exception(@"Folder should not end with a \");
            }
        }
Example #17
0
 protected override void Validate()
 {
     if (DestinationFolder.IsNullOrEmpty())
     {
         throw new BindingException("Outbound file adapter has no destination folder.");
     }
     if (FileName.IsNullOrEmpty())
     {
         throw new BindingException("Outbound file adapter has no destination file name.");
     }
     if (UseTempFileOnWrite && Mode != CopyMode.CreateNew)
     {
         throw new BindingException("Outbound file adapter cannot use a temporary file when it is meant to append or overwrite an existing file.");
     }
     if (!Path.IsNetworkPath(DestinationFolder) && !NetworkCredentials.UserName.IsNullOrEmpty())
     {
         throw new BindingException("Alternate credentials to access the file folder cannot be supplied while accessing local drive or a mapped network drive.");
     }
 }
Example #18
0
    private static void AddDestinationFolder(
        DestinationFolder destinationFolder,
        MoveInformation moveInformation,
        ICollection <string> newPathParts)
    {
        var destDirectory = destinationFolder.GetDestinationDirectory();
        var fileDirectory = moveInformation.SystemFile.File.DirectoryName;

        if (destDirectory == null)
        {
            if (fileDirectory != null)
            {
                newPathParts.Add(fileDirectory);
            }
        }
        else
        {
            newPathParts.Add(destDirectory.FullName);
        }
    }
Example #19
0
        public async Task AddDestinationFolder(DestinationFolder destinationFolder)
        {
            using (var db = new DataContext())
            {
                var collection = await db.Collections.FindAsync(destinationFolder.CollectionId);

                if (collection.DestinationFolder != null)
                {
                    // Replace?
                    throw new AggregateException("This collection already contains destination folder");
                }

                await db.DestinationFolders.AddAsync(destinationFolder);

                await db.SaveChangesAsync();
            }

            await ReFillCache <Collection>();

            OnCollectionChanged();
        }
Example #20
0
    public MovedInformation Move(
        DestinationFolder destinationFolder,
        MoveInformation moveInformation)
    {
        if (moveInformation.MoveProblem == MoveProblem.AlreadyContains)
        {
            var shouldDelete = destinationFolder.GetDestinationDirectory() != null;
            if (shouldDelete)
            {
                moveInformation.SystemFile.File.Delete();
            }

            _logger.LogWarning(
                "File with this md5 already contains in database. Md5: {Md5} File: {NewFile}. File deleted {FileDeleted}.",
                moveInformation.SystemFile.Md5,
                moveInformation.SystemFile.File.FullName,
                shouldDelete);

            return(new MovedInformation(
                       moveInformation,
                       false,
                       moveInformation.SystemFile.File));
        }

        var newPath = GetNewPath(destinationFolder, moveInformation);

        _logger.LogInformation("Destination path is calculated: {NewPath}.", newPath);

        var newFile     = new FileInfo(newPath);
        var wasANewFile = _fileService.MoveFile(moveInformation.SystemFile, ref newFile);

        _logger.LogInformation("Saved to: {NewPath}.", newFile.FullName);

        return(new MovedInformation(
                   moveInformation,
                   wasANewFile && moveInformation.MoveProblem == MoveProblem.None,
                   newFile));
    }
Example #21
0
    private static string GetNewPath(
        DestinationFolder destinationFolder,
        MoveInformation moveInformation)
    {
        var newPathParts = new List <string>();

        AddDestinationFolder(destinationFolder, moveInformation, newPathParts);

        var problemSubfolder = GetProblemSubfolder(destinationFolder, moveInformation.MoveProblem);

        var renamed = false;

        if (problemSubfolder != null)
        {
            newPathParts.Add(problemSubfolder);
        }
        else
        {
            if (destinationFolder.ShouldCreateSubfoldersByHash)
            {
                AddMd5Path(moveInformation, newPathParts);
            }

            if (destinationFolder.ShouldRenameByHash)
            {
                RenameToMd5(moveInformation, newPathParts);
                renamed = true;
            }
        }

        if (!renamed)
        {
            newPathParts.Add(moveInformation.SystemFile.File.Name);
        }

        return(Path.Combine(newPathParts.ToArray()));
    }
Example #22
0
 public void ThenTheDestinationFolderExists()
 {
     Assert.IsTrue(DestinationFolder.Exists());
 }
        public override bool Execute()
        {
            Log.LogTaskName("SmartCopy");
            Log.LogTaskProperty("DestinationFiles", DestinationFiles);
            Log.LogTaskProperty("DestinationFolder", DestinationFolder);
            Log.LogTaskProperty("SourceFiles", SourceFiles);

            if (DestinationFiles != null && DestinationFolder != null)
            {
                Log.LogError("You must specify a DestinationFolder or the DestinationFiles, but not both.");
                return(false);
            }

            try {
                if (DestinationFiles != null)
                {
                    if (DestinationFiles.Length != SourceFiles.Length)
                    {
                        Log.LogError("The number of DestinationFiles must match the number of SourceFiles.");
                        return(false);
                    }

                    for (int i = 0; i < SourceFiles.Length; i++)
                    {
                        var target    = DestinationFiles[i].GetMetadata("FullPath");
                        var source    = SourceFiles[i].GetMetadata("FullPath");
                        var targetDir = Path.GetDirectoryName(target);

                        EnsureDirectoryExists(targetDir);

                        if (FileChanged(source, target))
                        {
                            CopyFile(source, target, DestinationFiles[i].ItemSpec);
                        }
                    }
                }
                else if (DestinationFolder != null)
                {
                    var destinationFolder = DestinationFolder.GetMetadata("FullPath");

                    EnsureDirectoryExists(destinationFolder);

                    foreach (var item in SourceFiles)
                    {
                        var target = Path.Combine(destinationFolder, Path.GetFileName(item.ItemSpec));
                        var source = item.GetMetadata("FullPath");

                        if (FileChanged(source, target))
                        {
                            CopyFile(source, target, Path.Combine(DestinationFolder.ItemSpec, Path.GetFileName(item.ItemSpec)));
                        }
                    }
                }
                else
                {
                    Log.LogError("You must specify a DestinationFolder or the DestinationFiles.");
                    return(false);
                }
            } catch (Exception ex) {
                Log.LogError(ex.ToString());
            }

            CopiedFiles = copied.ToArray();

            return(!Log.HasLoggedErrors);
        }
        /// <summary>
        /// Returns the parsed screenshot filename using the symbols, extensions and special folders.
        /// </summary>
        public static string ParseFileName(string screenshotName, ScreenshotResolution resolution, DestinationFolder destination, string customPath, TextureExporter.ImageFileFormat format, bool overwriteFiles, System.DateTime time)
        {
            string filename = "";

#if UNITY_EDITOR || !UNITY_WEBGL
            // Destination Folder can not be parsed in webgl
            filename += ParsePath(destination, customPath);
#endif

            // File name
            filename += ParseSymbols(screenshotName, resolution, time);

            // Get the file extension
            filename += ParseExtension(format);


            // Increment the file number if a file already exist
            if (!overwriteFiles)
            {
                return(PathUtils.PreventOverwrite(filename));
            }

            return(filename);
        }
        public async Task <bool> ExecuteAsync()
        {
            DestinationFolder = DestinationFolder.Replace('\\', '/');

            var requests      = new List <PackageDownloadRequest>();
            var files         = new List <ITaskItem>();
            var downloadCount = 0;

            foreach (var item in Packages)
            {
                var id         = item.ItemSpec;
                var rawVersion = item.GetMetadata("Version");
                if (!NuGetVersion.TryParse(rawVersion, out var version))
                {
                    Log.LogError($"Package '{id}' has an invalid 'Version' metadata value: '{rawVersion}'.");
                    return(false);
                }

                var source = item.GetMetadata("Source");
                if (string.IsNullOrEmpty(source))
                {
                    Log.LogError($"Package '{id}' is missing the 'Source' metadata value.");
                    return(false);
                }

                var outputPath = Path.Combine(DestinationFolder, $"{id.ToLowerInvariant()}.{version.ToNormalizedString()}.nupkg");

                files.Add(new TaskItem(outputPath));
                if (File.Exists(outputPath))
                {
                    Log.LogMessage($"Skipping {id} {version}. Already exists in '{outputPath}'");
                    continue;
                }
                else
                {
                    downloadCount++;

                    var request = new PackageDownloadRequest
                    {
                        Identity   = new PackageIdentity(id, version),
                        OutputPath = outputPath,
                        Sources    = source.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries),
                    };

                    requests.Add(request);
                }
            }

            Files = files.ToArray();

            if (downloadCount == 0)
            {
                Log.LogMessage("All packages are downloaded.");
                return(true);
            }

            Directory.CreateDirectory(DestinationFolder);
            var logger     = new MSBuildLogger(Log);
            var timeout    = TimeSpan.FromSeconds(TimeoutSeconds);
            var downloader = new PackageDownloader(logger);
            var timer      = Stopwatch.StartNew();

            var result = await downloader.DownloadPackagesAsync(requests, timeout, _cts.Token);

            timer.Stop();
            logger.LogMinimal($"Finished downloading {requests.Count} package(s) in {timer.ElapsedMilliseconds}ms");
            return(result);
        }
        public override bool Execute()
        {
            if (DestinationFiles != null && DestinationFolder != null)
            {
                Log.LogError(MSBStrings.E0166);
                return(false);
            }

            try {
                if (DestinationFiles != null)
                {
                    if (DestinationFiles.Length != SourceFiles.Length)
                    {
                        Log.LogError(MSBStrings.E0167);
                        return(false);
                    }

                    for (int i = 0; i < SourceFiles.Length; i++)
                    {
                        var target    = DestinationFiles[i].GetMetadata("FullPath");
                        var source    = SourceFiles[i].GetMetadata("FullPath");
                        var targetDir = Path.GetDirectoryName(target);

                        EnsureDirectoryExists(targetDir);

                        if (FileChanged(source, target))
                        {
                            CopyFile(source, target, DestinationFiles[i].ItemSpec);
                        }
                    }
                }
                else if (DestinationFolder != null)
                {
                    var destinationFolder = DestinationFolder.GetMetadata("FullPath");

                    EnsureDirectoryExists(destinationFolder);

                    foreach (var item in SourceFiles)
                    {
                        var target = Path.Combine(destinationFolder, Path.GetFileName(item.ItemSpec));
                        var source = item.GetMetadata("FullPath");

                        if (FileChanged(source, target))
                        {
                            CopyFile(source, target, Path.Combine(DestinationFolder.ItemSpec, Path.GetFileName(item.ItemSpec)));
                        }
                    }
                }
                else
                {
                    Log.LogError(MSBStrings.E0166);
                    return(false);
                }
            } catch (Exception ex) {
                Log.LogError(ex.ToString());
            }

            CopiedFiles = copied.ToArray();

            return(!Log.HasLoggedErrors);
        }
Example #27
0
 private void DestinationDirectoryBtn_Click(object sender, EventArgs e)
 {
     DestinationFolder.ShowDialog();
     DestinationFolderPath.Text = DestinationFolder.SelectedPath;
 }