public static async Task <IContextualResourceModel> HandleResourceNotInResourceFolderAsync(string filePath, Common.Interfaces.Studio.Controller.IPopupController popupController, IShellViewModel shellViewModel, IFile file, IFilePath path, IServerRepository serverRepository)
        {
            var saveResource = popupController.ShowResourcesNotInCorrectPath();

            if (saveResource == MessageBoxResult.OK)
            {
                ReadFileContent(filePath, shellViewModel, file, out IContextualResourceModel resourceModel, serverRepository, out IResource resource);
                if (resourceModel == null && (resource.ResourceType != "WorkflowService" || resource.ResourceType != "Workflow"))
                {
                    var moveSource = popupController.ShowCanNotMoveResource() == MessageBoxResult.OK;
                    if (moveSource)
                    {
                        var destination = path.Combine(EnvironmentVariables.ResourcePath, path.GetFileName(filePath));
                        file.Move(filePath, destination);
                        await shellViewModel.ExplorerViewModel.RefreshEnvironment(serverRepository.ActiveServer.EnvironmentID);

                        resourceModel = serverRepository.ActiveServer.ResourceRepository.LoadContextualResourceModel(resource.ResourceID);
                    }
                }
                var ctResourceModel = resourceModel;
                if (resourceModel != null)
                {
                    shellViewModel.OpenResource(resourceModel.ID, shellViewModel.ActiveServer.EnvironmentID, shellViewModel.ActiveServer, resourceModel);
                }
                return(ctResourceModel);
            }
            return(null);
        }
        public IList <IExplorerItem> GetVersions(Guid resourceId)
        {
            var resource = _catalogue.GetResource(Guid.Empty, resourceId);

            if (resource?.VersionInfo == null)
            {
                return(new List <IExplorerItem>());
            }
            var versionFolder = _filePath.Combine(_envVersionFolder, resourceId.ToString());
            var files         = _directory.GetFiles(versionFolder);

            return(files.Select(a => CreateVersionFromFilePath(a, resource, _envVersionFolder))
                   .OrderByDescending(a => a.VersionInfo.DateTimeStamp)
                   .Take(GlobalConstants.VersionCount)
                   .ToList());
        }
Beispiel #3
0
 private string GetTestCoveragePathForResourceId(Guid resourceId) => _filePathWapper.Combine(EnvironmentVariables.TestCoveragePath, resourceId.ToString());