Exemplo n.º 1
0
        public static ASC.Files.Core.File GetConvertedFile(ConverterData data)
        {
            if (string.IsNullOrEmpty(data.ConverterUrl) || string.IsNullOrEmpty(data.StorageUrl) || string.IsNullOrEmpty(data.RevisionId))
            {
                return null;
            }
            
            var documentService = new DocumentService(StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount());
            
            string urlToFile;
            documentService.GetConvertedUri(data.ConverterUrl, data.StorageUrl, FormatDocx, FormatPdf, data.RevisionId, true, out urlToFile);

            if (string.IsNullOrEmpty(urlToFile))
            {
                return null;
            }

            var invoice = Global.DaoFactory.GetInvoiceDao().GetByID(data.InvoiceId);

            return SaveFile(invoice, urlToFile);
        }
Exemplo n.º 2
0
        private static string GetUrlToFile(Stream docxStream)
        {
            var documentService = new DocumentService(StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount());
            var revisionId = DocumentService.GenerateRevisionId(Guid.NewGuid().ToString());

            var externalUri = documentService.GetExternalUri(FilesLinkUtility.DocServiceStorageUrl, docxStream, "text/plain", revisionId);
            log4net.LogManager.GetLogger("ASC.CRM").DebugFormat("PdfCreator. GetUrlToFile. externalUri = {0}", externalUri);

            string urlToFile;
            documentService.GetConvertedUri(FilesLinkUtility.DocServiceConverterUrl, externalUri, FormatDocx, FormatPdf, revisionId, false, out urlToFile);

            log4net.LogManager.GetLogger("ASC.CRM").DebugFormat("PdfCreator. GetUrlToFile. urlToFile = {0}", urlToFile);
            return urlToFile;
        }
Exemplo n.º 3
0
        public static ConverterData StartCreationFileAsync(Invoice data)
        {
            using (var docxStream = GetStreamDocx(data))
            {
                var documentService = new DocumentService(StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount());
                var revisionId = DocumentService.GenerateRevisionId(Guid.NewGuid().ToString());

                var externalUri = documentService.GetExternalUri(FilesLinkUtility.DocServiceStorageUrl, docxStream, "text/plain", revisionId);

                string urlToFile;
                documentService.GetConvertedUri(FilesLinkUtility.DocServiceConverterUrl, externalUri, FormatDocx, FormatPdf, revisionId, true, out urlToFile);

                return new ConverterData
                    {
                        ConverterUrl = FilesLinkUtility.DocServiceConverterUrl,
                        StorageUrl = externalUri,
                        RevisionId = revisionId,
                        InvoiceId = data.ID,
                        UrlToFile = urlToFile
                    };
            }
        }
Exemplo n.º 4
0
        private static string GetUrlToFile(Stream docxStream)
        {
            var documentService = new DocumentService(StudioKeySettings.GetKey(), StudioKeySettings.GetSKey(), TenantStatisticsProvider.GetUsersCount());
            var revisionId = DocumentService.GenerateRevisionId(Guid.NewGuid().ToString());

            var crmStorageUrl = WebConfigurationManager.AppSettings["crm.invoice.url.storage"];
            if (string.IsNullOrEmpty(crmStorageUrl))
            {
                crmStorageUrl = FilesLinkUtility.DocServiceStorageUrl;
            }

            var crmConverterUrl = WebConfigurationManager.AppSettings["crm.invoice.url.converter"];
            if (string.IsNullOrEmpty(crmConverterUrl))
            {
                crmConverterUrl = FilesLinkUtility.DocServiceConverterUrl;
            }

            var externalUri = documentService.GetExternalUri(crmStorageUrl, docxStream, "text/plain", revisionId);

            string urlToFile;
            documentService.GetConvertedUri(crmConverterUrl, externalUri, FormatDocx, FormatPdf, revisionId, false, out urlToFile);

            return urlToFile;
        }