Example #1
0
        private async Task DeleteBookAsync(Connection conn, TranslateProject project, TranslateDocumentSet docSet,
                                           ParatextProject paratextProject, string docType, string bookId)
        {
            string projectPath = GetProjectPath(project, paratextProject);

            File.Delete(GetBookTextFileName(projectPath, bookId));
            Document <Delta> doc = GetShareDBDocument(conn, project, docSet, docType);
            await doc.FetchAsync();

            await doc.DeleteAsync();
        }
Example #2
0
        private IEnumerable <string> GetBooksToDelete(TranslateProject project, ParatextProject paratextProject,
                                                      IEnumerable <string> books)
        {
            string projectPath   = GetProjectPath(project, paratextProject);
            var    booksToDelete = new HashSet <string>(Directory.Exists(projectPath)
                ? Directory.EnumerateFiles(projectPath).Select(Path.GetFileNameWithoutExtension)
                : Enumerable.Empty <string>());

            booksToDelete.ExceptWith(books);
            return(booksToDelete);
        }
Example #3
0
        private async Task SendReceiveBookAsync(User user, Connection conn, TranslateProject project,
                                                TranslateDocumentSet docSet, ParatextProject paratextProject, string docType, string bookId)
        {
            string projectPath = GetProjectPath(project, paratextProject);

            if (!Directory.Exists(projectPath))
            {
                Directory.CreateDirectory(projectPath);
            }

            Document <Delta> doc      = GetShareDBDocument(conn, project, docSet, docType);
            string           fileName = GetBookTextFileName(projectPath, bookId);

            if (File.Exists(fileName))
            {
                await SyncBookAsync(user, paratextProject, fileName, bookId, doc);
            }
            else
            {
                await CloneBookAsync(user, paratextProject, fileName, bookId, doc);
            }
        }
Example #4
0
 private Document <Delta> GetShareDBDocument(Connection conn, TranslateProject project,
                                             TranslateDocumentSet docSet, string docType)
 {
     return(conn.Get <Delta>($"sf_{project.ProjectCode}", $"{docSet.Id}:{docType}"));
 }
Example #5
0
 private string GetProjectPath(TranslateProject project, ParatextProject paratextProject)
 {
     return(Path.Combine(_options.Value.TranslateDir, project.Id, paratextProject.Id));
 }