Ejemplo n.º 1
0
        public async Task <byte[]> MethodicDocumentCreatePdfAsync(int methodicDocumentId)
        {
            try
            {
                var methodicDocument = await _repoWrapper.MethodicDocument.GetFirstAsync(x => x.ID == methodicDocumentId, include : doc =>
                                                                                         doc.Include(d => d.Organization));

                if (methodicDocument != null)
                {
                    var base64 = await _decisionBlobStorage.GetBlobBase64Async("dafaultPhotoForPdf.jpg");

                    IPdfSettings pdfSettings = new PdfSettings
                    {
                        Title     = $"{methodicDocument.Type} {methodicDocument.ID}",
                        ImagePath = base64,
                    };
                    IPdfCreator creator = new PdfCreator(new MethodicDocumentPdf(methodicDocument, pdfSettings));
                    return(await Task.Run(() => creator.GetPDFBytes()));
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Ejemplo n.º 2
0
        public async Task <byte[]> DecisionCreatePDFAsync(int decisionId)
        {
            try
            {
                var decision = await _repoWrapper.Decesion.GetFirstAsync(x => x.ID == decisionId, include : dec =>
                                                                         dec.Include(d => d.DecesionTarget).Include(d => d.Organization));

                if (decision != null)
                {
                    var base64 = await _decisionBlobStorage.GetBlobBase64Async("dafaultPhotoForPdf.jpg");

                    IPdfSettings pdfSettings = new PdfSettings
                    {
                        Title     = $"Decision of {decision.Organization.OrganizationName}",
                        ImagePath = base64,
                    };
                    IPdfCreator creator = new PdfCreator(new DecisionDocument(decision, pdfSettings));
                    return(await Task.Run(() => creator.GetPDFBytes()));
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Ejemplo n.º 3
0
        public async Task <byte[]> AnnualReportCreatePDFAsync(int annualReportId)
        {
            try
            {
                var annualReport = await _repoWrapper.AnnualReports.GetFirstOrDefaultAsync(
                    predicate : a => a.ID == annualReportId,
                    include : source => source
                    .Include(a => a.NewCityAdmin)
                    .Include(a => a.MembersStatistic)
                    .Include(a => a.City));

                if (annualReport != null)
                {
                    var base64 = await _decisionBlobStorage.GetBlobBase64Async("dafaultPhotoForPdf.jpg");

                    IPdfSettings pdfSettings = new PdfSettings
                    {
                        Title     = $"{annualReport.City.Name} {annualReport.Date.Year}",
                        ImagePath = base64,
                    };
                    IPdfCreator creator = new PdfCreator(new AnnualReportPdf(annualReport, pdfSettings));
                    return(await Task.Run(() => creator.GetPDFBytes()));
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }
Ejemplo n.º 4
0
        public async Task <byte[]> BlankCreatePDFAsync(string userId)
        {
            try
            {
                var blank = await GetBlankDataAsync(userId);

                IPdfSettings pdfSettings = new PdfSettings
                {
                    Title     = $"{DateTime.Now.ToShortDateString()}_Заява_{blank.User.LastName}",
                    ImagePath = "Blank"
                };
                IPdfCreator creator = new PdfCreator(new BlankDocument(blank, pdfSettings));
                return(await Task.Run(() => creator.GetPDFBytes()));
            }
            catch (Exception e)
            {
                _logger.LogError($"Exception: {e.Message}");
            }

            return(null);
        }