public static File GetConvertedFile(ConverterData data, DaoFactory daoFactory) { if (string.IsNullOrEmpty(data.StorageUrl) || string.IsNullOrEmpty(data.RevisionId)) { return(null); } string urlToFile; DocumentServiceConnector.GetConvertedUri(data.StorageUrl, FormatDocx, FormatPdf, data.RevisionId, true, out urlToFile); if (string.IsNullOrEmpty(urlToFile)) { return(null); } var invoice = daoFactory.InvoiceDao.GetByID(data.InvoiceId); return(SaveFile(invoice, urlToFile, daoFactory)); }
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); }
public ConverterData GetInvoiceConverterData(int invoiceId, string converterUrl, string storageUrl, string revisionId) { if (invoiceId <= 0) throw new ArgumentException(); var invoice = DaoFactory.GetInvoiceDao().GetByID(invoiceId); if (invoice == null) throw new ItemNotFoundException(); if (!CRMSecurity.CanAccessTo(invoice)) { throw CRMSecurity.CreateSecurityException(); } var converterData = new ConverterData { ConverterUrl = converterUrl, StorageUrl = storageUrl, RevisionId = revisionId, InvoiceId = invoiceId }; var existingFile = invoice.GetInvoiceFile(); if (existingFile != null) { converterData.FileId = invoice.FileID; return converterData; } if (string.IsNullOrEmpty(converterUrl) || string.IsNullOrEmpty(storageUrl) || string.IsNullOrEmpty(revisionId)) { return PdfCreator.StartCreationFileAsync(invoice); } else { var convertedFile = PdfCreator.GetConvertedFile(converterData); if (convertedFile != null) { invoice.FileID = Int32.Parse(convertedFile.ID.ToString()); DaoFactory.GetInvoiceDao().UpdateInvoiceFileID(invoice.ID, invoice.FileID); DaoFactory.GetRelationshipEventDao().AttachFiles(invoice.ContactID, invoice.EntityType, invoice.EntityID, new[] { invoice.FileID }); converterData.FileId = invoice.FileID; return converterData; } else { return converterData; } } }