Exemplo n.º 1
0
        private async Task <BlobSasTokenDto> ExportAndGenerateBlobAsync(string reportName, IEnumerable <string> columnLocalisationKeys, IEnumerable <IEnumerable <object> > contentList, int expiryHours, DateTime userDateTime)
        {
            var columnNames = new List <string>();

            foreach (var key in columnLocalisationKeys)
            {
                var text = await _localisationReaderService.GetTextAsync(key);

                columnNames.Add(text);
            }

            var templateFile = ExportToTemplateFile(reportName, columnNames, contentList);

            //Create the report file inside a GUID folder.
            var blobService = await _blobServiceFactory.CreateBlobServiceAsync("reportexports", Guid.NewGuid().ToString("N"));

            var blobId = userDateTime.ToStandardReportNameFormatByDate(reportName, "xlsx");

            using (var outStream = await blobService.OpenWriteBlobAsync(blobId))
            {
                templateFile.Write(outStream);
            }

            var sasToken = blobService.GenerateSasForBlob(blobId, TimeSpan.FromHours(expiryHours), BlobSasPermissions.Read);

            return(sasToken);
        }
Exemplo n.º 2
0
        public async Task <Dictionary <string, string> > GetContextObjectKeyValuesAsync(object objectInfo, string groupId, string culture, string timeZone)
        {
            var productName = await _localisationReaderService.GetTextAsync(SystemKeys.LocalisationKeys.ProductName, groupId, culture);

            var companyName = await _localisationReaderService.GetTextAsync(SystemKeys.LocalisationKeys.CompanyName, groupId, culture);

            var logoUrl = await _configurationReaderService.GetValueAsync(SystemKeys.ConfigurationKeys.SystemLogoUrl, groupId, culture);

            var dic = new Dictionary <string, string>
            {
                { "productName", productName },
                { "companyName", companyName },
                { "logoUrl", logoUrl }
            };

            return(dic);
        }