private void WriteReportFile(XmlWriter writer, WizardContext wizardContext, ProjectFile projectFile) { writer.WriteStartElement("file"); writer.WriteAttributeString("name", Path.Combine(projectFile.Path, projectFile.Name)); writer.WriteAttributeString("guid", projectFile.FileId); WriteAnalysisXml(writer, projectFile.TranslationOriginStatistics?.WordCounts, wizardContext.AnalysisBands, wizardContext.Action); WriteConfirmationXml(writer, projectFile.ConfirmationStatistics?.WordCounts, wizardContext.Action); writer.WriteEndElement(); //file }
private void ConvertToRelativePaths(Project project, ProjectFile wcProjectFile) { foreach (var fileActivity in wcProjectFile.ProjectFileActivities) { fileActivity.Path = GetRelativePath(project.Path, fileActivity.Path); fileActivity.Report = GetRelativePath(project.Path, fileActivity.Report); } wcProjectFile.XliffFilePath = GetRelativePath(project.Path, wcProjectFile.XliffFilePath); wcProjectFile.Location = GetRelativePath(project.Path, wcProjectFile.Location); wcProjectFile.Report = GetRelativePath(project.Path, wcProjectFile.Report); }
private Xliff GetBackTranslationXliffData(Interfaces.IProject project, ProjectFile projectFile, SdlxliffReader sdlxliffReader) { if (project != null && projectFile != null) { var backTranslationFilePath = Path.Combine(project.Path, projectFile.Location); if (System.IO.File.Exists(backTranslationFilePath)) { return(sdlxliffReader.ReadFile(project.Id, projectFile.FileId, backTranslationFilePath, projectFile.TargetLanguage)); } } return(null); }
private bool AddNewProjectFiles(FileBasedProject project, Project xliffProject) { var addedNewFiles = false; var projectInfo = project.GetProjectInfo(); foreach (var targetLanguage in projectInfo.TargetLanguages) { var projectFiles = project.GetTargetLanguageFiles(targetLanguage); foreach (var projectFile in projectFiles) { if (projectFile.Role != FileRole.Translatable) { continue; } var xliffFile = xliffProject.ProjectFiles.FirstOrDefault(a => a.FileId == projectFile.Id.ToString()); if (xliffFile == null) { addedNewFiles = true; var file = new ProjectFile { ProjectId = projectInfo.Id.ToString(), FileId = projectFile.Id.ToString(), Name = projectFile.Name, Path = GetRelativePath(projectInfo.LocalProjectFolder, projectFile.Folder), Location = GetRelativePath(projectInfo.LocalProjectFolder, projectFile.LocalFilePath), Action = Enumerators.Action.None, Status = Enumerators.Status.Ready, Date = DateTime.MinValue, TargetLanguage = targetLanguage.CultureInfo.Name, Selected = false, FileType = projectFile.FileTypeId, Project = xliffProject }; xliffProject.ProjectFiles.Add(file); } } } return(addedNewFiles); }
private ProjectFile GetProjectFile(Project project, ProjectAutomation.Core.ProjectFile projectFile, IReadOnlyCollection <string> selectedFileIds) { var projectFileModel = new ProjectFile { ProjectId = project.Id, FileId = projectFile.Id.ToString(), Name = projectFile.Name, Path = projectFile.Folder, Location = projectFile.LocalFilePath, Action = Enumerators.Action.None, Status = Enumerators.Status.Ready, Date = DateTime.MinValue, TargetLanguage = projectFile.Language.CultureInfo.Name, Selected = selectedFileIds != null && selectedFileIds.Any(a => a == projectFile.Id.ToString()), FileType = projectFile.FileTypeId, Project = project }; return(projectFileModel); }
//private void SetProjectPropertiesViewController() //{ // if (_projectPropertiesViewController != null) // { // return; // } // try // { // _projectPropertiesViewController = // SdlTradosStudio.Application.GetController<ProjectPropertiesViewController>(); // var viewModel = _projectsNavigationViewModel.ProjectPropertiesViewModel = // new ProjectPropertiesViewModel(_projectsNavigationViewModel.SelectedProject); // _projectPropertiesViewController.ViewModel = viewModel; // } // catch // { // // catch all; unable to locate the controller // } //} private bool AddNewProjectToContainer(FileBasedProject project) { if (project == null) { return(false); } var projectInfo = project.GetProjectInfo(); try { if (_xliffProjects.FirstOrDefault(a => a.Id == projectInfo.Id.ToString()) != null) { // allready present in the list return(false); } var settingsBundle = project.GetSettings(); var xliffManagerProject = settingsBundle.GetSettingsGroup <SDLTranscreateProject>(); var projectFiles = SerializeProjectFiles(xliffManagerProject.ProjectFilesJson.Value); if (projectFiles?.Count > 0) { var xliffProjectFiles = new List <ProjectFile>(); var xliffProject = new Project { Id = projectInfo.Id.ToString(), Name = projectInfo.Name, AbsoluteUri = projectInfo.Uri.AbsoluteUri, Customer = _customerProvider.GetProjectCustomer(project), Created = projectInfo.CreatedAt.ToUniversalTime(), DueDate = projectInfo.DueDate?.ToUniversalTime() ?? DateTime.MaxValue, Path = projectInfo.LocalProjectFolder, SourceLanguage = GetLanguageInfo(projectInfo.SourceLanguage.CultureInfo), TargetLanguages = GetLanguageInfos(projectInfo.TargetLanguages), ProjectType = GetProjectType(project), ProjectFiles = xliffProjectFiles }; foreach (var projectFile in projectFiles) { var xliffFileActivities = new List <ProjectFileActivity>(); var xliffProjectFile = new ProjectFile { Path = projectFile.Path, Action = GetAction(projectFile.Action), Status = GetStatus(projectFile.Status), Date = GetDateTime(projectFile.Date), Report = GetRelativePath(xliffProject.Path, projectFile.Report), FileId = projectFile.FileId, FileType = projectFile.FileType, Location = GetRelativePath(xliffProject.Path, projectFile.Location), Name = projectFile.Name, ProjectId = projectInfo.Id.ToString(), ProjectFileActivities = xliffFileActivities, XliffFilePath = GetRelativePath(xliffProject.Path, projectFile.XliffFilePath), Project = xliffProject, TargetLanguage = projectFile.TargetLanguage, ConfirmationStatistics = projectFile.ConfirmationStatistics, TranslationOriginStatistics = projectFile.TranslationOriginStatistics }; foreach (var fileActivity in projectFile.Activities) { var xliffFileActivity = new ProjectFileActivity { ProjectFile = xliffProjectFile, Path = GetRelativePath(xliffProject.Path, fileActivity.Path), Action = GetAction(fileActivity.Action), Status = GetStatus(fileActivity.Status), ActivityId = fileActivity.ActivityId, Date = GetDateTime(fileActivity.Date), Report = GetRelativePath(xliffProject.Path, fileActivity.Report), Name = fileActivity.Name, ProjectFileId = fileActivity.ProjectFileId, ConfirmationStatistics = fileActivity.ConfirmationStatistics, TranslationOriginStatistics = fileActivity.TranslationOriginStatistics }; xliffFileActivities.Add(xliffFileActivity); } xliffProject.ProjectFiles.Add(xliffProjectFile); } var addedNewFiles = AddNewProjectFiles(project, xliffProject); if (addedNewFiles) { UpdateProjectSettingsBundle(xliffProject); } _xliffProjects.Add(xliffProject); return(true); } } catch (Exception ex) { MessageBox.Show(string.Format(PluginResources.Warning_UnableToLoadProject, projectInfo.Name) + Environment.NewLine + Environment.NewLine + ex.Message, PluginResources.Plugin_Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } return(false); }
private FileData GetFileData(IEnumerable <FileData> languageFileData, string localProjectFolder, ProjectFile projectFile) { foreach (var fileData in languageFileData) { var fileDataFullPath = GetRelativePath(localProjectFolder, fileData.Data.DocInfo.Source); var projectFilePth = Path.Combine(projectFile.TargetLanguage, projectFile.Path.Trim('\\')); var projectFileFullPath = Path.Combine(projectFilePth, projectFile.Name); if (string.Compare(fileDataFullPath, projectFileFullPath, StringComparison.CurrentCultureIgnoreCase) == 0) { return(fileData); } } return(null); }
private static ProjectFile GetBackTranslationProjectFile(Interfaces.IProject backTranslationProject, ProjectFile projectFile) { if (backTranslationProject == null) { return(null); } foreach (var translationProjectFile in backTranslationProject.ProjectFiles) { if (string.Compare(projectFile.Name, translationProjectFile.Name, StringComparison.CurrentCultureIgnoreCase) == 0 && string.Compare(projectFile.Path, translationProjectFile.Path, StringComparison.CurrentCultureIgnoreCase) == 0) { return(translationProjectFile); } } return(null); }