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)))); }
static string GetName(IFilePath filePath) { try { return(filePath.GetFileName()); } catch { return(filePath.GetDirectoryName()); } }
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; }
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); }
/// <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) { }