Example #1
0
        private async Task SetDocumentAsync()
        {
            DocumentNameWithExtension = DocumentName + "." + Project.Format;

            try
            {
                if (DocumentName.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId    = Project.Id,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId    = Project.Id,
                        Name         = DocumentNameWithExtension,
                        LanguageCode = LanguageCode,
                        Version      = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                if (LanguageCode != DefaultLanguageCode)
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId    = Project.Id,
                        Name         = DocumentNameWithExtension,
                        LanguageCode = DefaultLanguageCode,
                        Version      = Version
                    }
                        );

                    DocumentLanguageIsDifferent = true;
                }
                else
                {
                    throw;
                }
            }

            await ConvertDocumentContentToHtmlAsync();
        }
Example #2
0
        private async Task <List <DocumentPartialTemplateContent> > GetDocumentPartialTemplatesAsync()
        {
            var partialTemplatesInDocument = await _documentSectionRenderer.GetPartialTemplatesInDocumentAsync(Document.Content);

            if (!partialTemplatesInDocument?.Any(t => t.Parameters != null) ?? true)
            {
                return(null);
            }

            foreach (var partialTemplates in partialTemplatesInDocument)
            {
                foreach (var parameter in partialTemplates.Parameters)
                {
                    if (!UserPreferences.ContainsKey(parameter.Key))
                    {
                        UserPreferences.Add(parameter.Key, parameter.Value);
                    }
                    else
                    {
                        UserPreferences[parameter.Key] = parameter.Value;
                    }
                }
            }

            var contents = new List <DocumentPartialTemplateContent>();

            foreach (var partialTemplate in partialTemplatesInDocument)
            {
                var content = (await _documentAppService.GetAsync(new GetDocumentInput
                {
                    LanguageCode = DocumentLanguageCode,
                    Name = partialTemplate.Path,
                    ProjectId = Project.Id,
                    Version = Version
                })).Content;

                contents.Add(new DocumentPartialTemplateContent
                {
                    Path    = partialTemplate.Path,
                    Content = content
                });
            }

            return(contents);
        }
Example #3
0
        private async Task SetDocumentAsync()
        {
            if (DocumentName.IsNullOrWhiteSpace())
            {
                DocumentName = Project.DefaultDocumentName;
            }

            DocumentNameWithExtension = DocumentName + "." + Project.Format;

            try
            {
                if (DocumentNameWithExtension.IsNullOrWhiteSpace())
                {
                    Document = await _documentAppService.GetDefaultAsync(
                        new GetDefaultDocumentInput
                    {
                        ProjectId = Project.Id,
                        Version   = Version
                    }
                        );
                }
                else
                {
                    Document = await _documentAppService.GetAsync(
                        new GetDocumentInput
                    {
                        ProjectId = Project.Id,
                        Name      = DocumentNameWithExtension,
                        Version   = Version
                    }
                        );
                }
            }
            catch (DocumentNotFoundException)
            {
                //TODO: Handle it!
                throw;
            }

            ConvertDocumentContentToHtml();
        }
Example #4
0
 public async Task <DocumentDto> GetAsync(long id)
 {
     return(await _documentAppService.GetAsync(id));
 }