public void MoveVersions(Guid resourceId, string newPath, string resourcePath)
        {
            var resource = _catalogue.GetResource(Guid.Empty, resourceId);

            if (resource?.VersionInfo == null)
            {
                return;
            }

            var files = _directory.GetFiles(_envVersionFolder).Where(a => a.Contains(resource.VersionInfo.VersionId.ToString()));
            IEnumerable <string> enumerable = files as IList <string> ?? files.ToList();

            enumerable.ForEach(a => _file.Move(a, _filePath.Combine(_envVersionFolder, _filePath.GetFileName(a))));
        }
Ejemplo n.º 2
0
 static string GetName(IFilePath filePath)
 {
     try
     {
         return(filePath.GetFileName());
     }
     catch
     {
         return(filePath.GetDirectoryName());
     }
 }
Ejemplo n.º 3
0
        public void WatchTriggerResource(IFileSystemWatcher watcher)
        {
            var path     = _filePath.GetDirectoryName(_path);
            var filename = _filePath.GetFileName(_path);

            watcher.EnableRaisingEvents = false;

            watcher.Path         = path;
            watcher.Filter       = filename;
            watcher.NotifyFilter = NotifyFilters.LastWrite
                                   | NotifyFilters.FileName
                                   | NotifyFilters.DirectoryName;

            watcher.EnableRaisingEvents = true;
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 从<see cref="IFilePath" />创建<see cref="DirectoryResource" />
 /// </summary>
 /// <param name="path"></param>
 /// <param name="name"></param>
 public DirectoryResource(IFilePath path, string name = null) : base(Uuid.NewUuid(), name ?? path.GetFileName(),
                                                                     null, path)
 {
 }