public Interfaces.IProject GetProject(FileBasedProject selectedProject, IReadOnlyCollection <string> selectedFileIds, List <ProjectFile> projectFiles = null) { if (selectedProject == null) { return(null); } var projectInfo = selectedProject.GetProjectInfo(); Interfaces.IProject project = IsBackTranslationProject(projectInfo.ProjectOrigin) ? new BackTranslationProject() : new Project(); project.Id = projectInfo.Id.ToString(); project.Name = projectInfo.Name; project.Customer = _customerProvider.GetProjectCustomer(selectedProject); project.Created = projectInfo.CreatedAt.ToUniversalTime(); project.DueDate = projectInfo.DueDate?.ToUniversalTime() ?? DateTime.MaxValue; project.Path = projectInfo.LocalProjectFolder; project.SourceLanguage = GetLanguageInfo(projectInfo.SourceLanguage.CultureInfo); project.TargetLanguages = GetLanguageInfos(projectInfo.TargetLanguages); project.ProjectType = GetProjectType(selectedProject); var existingProject = IsBackTranslationProject(projectInfo.ProjectOrigin) ? GetBackTranslationProjectProject(projectInfo.Id.ToString(), out _) : _controller.GetProjects().FirstOrDefault(a => a.Id == projectInfo.Id.ToString()); if (existingProject != null) { foreach (var projectFile in existingProject.ProjectFiles) { if (projectFile.Clone() is ProjectFile clonedProjectFile) { clonedProjectFile.Project = project; clonedProjectFile.Location = GeFullPath(project.Path, clonedProjectFile.Location); clonedProjectFile.Report = GeFullPath(project.Path, clonedProjectFile.Report); clonedProjectFile.ExternalFilePath = GeFullPath(project.Path, clonedProjectFile.ExternalFilePath); clonedProjectFile.Selected = selectedFileIds != null && selectedFileIds.Any(a => a == projectFile.FileId.ToString()); project.ProjectFiles.Add(clonedProjectFile); } } } else { project.ProjectFiles = GetProjectFiles(selectedProject, project, selectedFileIds); } AssignProjectFileXliffData(project, projectFiles); return(project); }
public Project GetProject(FileBasedProject selectedProject, IReadOnlyCollection <string> selectedFileIds, List <ProjectFile> projectFiles = null) { if (selectedProject == null) { return(null); } var projectInfo = selectedProject.GetProjectInfo(); var project = new Project { Id = projectInfo.Id.ToString(), Name = projectInfo.Name, AbsoluteUri = projectInfo.Uri.AbsoluteUri, Customer = _customerProvider.GetProjectCustomer(selectedProject), Created = projectInfo.CreatedAt.ToUniversalTime(), DueDate = projectInfo.DueDate?.ToUniversalTime() ?? DateTime.MaxValue, Path = projectInfo.LocalProjectFolder, SourceLanguage = GetLanguageInfo(projectInfo.SourceLanguage.CultureInfo), TargetLanguages = GetLanguageInfos(projectInfo.TargetLanguages), ProjectType = GetProjectType(selectedProject) }; var existingProject = _controller.GetProjects().FirstOrDefault(a => a.Id == projectInfo.Id.ToString()); if (existingProject != null) { foreach (var projectFile in existingProject.ProjectFiles) { if (projectFile.Clone() is ProjectFile clonedProjectFile) { clonedProjectFile.Project = project; clonedProjectFile.Location = GeFullPath(project.Path, clonedProjectFile.Location); clonedProjectFile.Report = GeFullPath(project.Path, clonedProjectFile.Report); clonedProjectFile.XliffFilePath = GeFullPath(project.Path, clonedProjectFile.XliffFilePath); clonedProjectFile.Selected = selectedFileIds != null && selectedFileIds.Any(a => a == projectFile.FileId.ToString()); project.ProjectFiles.Add(clonedProjectFile); } } } else { project.ProjectFiles = GetProjectFiles(selectedProject, project, selectedFileIds); } AssignProjectFileXliffData(project, projectFiles); return(project); }