private string FillPlaceHolders(string html, ExportRequestBody requestBody)
 {
     html = FillPlaceholder(html, "{monetization}", requestBody.Monetization);
     html = FillPlaceholder(html, "{revenue}", requestBody.Revenue);
     html = FillPlaceholder(html, "{topMarket}", requestBody.TopMarket);
     return(html);
 }
예제 #2
0
        public async Task <IActionResult> Test(ExportViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                using (var memoryStream = new MemoryStream())
                {
                    await viewModel.FileContent.CopyToAsync(memoryStream);

                    var body = new ExportRequestBody
                    {
                        FileContent     = memoryStream.ToArray(),
                        strFileName     = viewModel.FileName,
                        strFolderName   = "BEXCELLLE",
                        strProfile      = (await _profileRepository.Table.FirstOrDefaultAsync(p => p.ProfileId == 9))?.ProfileName,
                        arrProfileValue = new ArrayOfString {
                            "666", "Profile Pictures"
                        },
                        userID = "garyfoongck",
                    };

                    var export = await _docufloSdkService.Export(body);

                    return(Ok(export == "1" ? "Success" : export));
                }
            }

            return(View(viewModel));
        }
예제 #3
0
        public async Task <string> Export(ExportRequestBody requestBody)
        {
            var request = new ExportRequest
            {
                Body = requestBody
            };

            var client = await Connect();

            var responseResult = (await client.ExportAsync(request))?.Body?.ExportResult;

            if (responseResult?.Length > 0)
            {
                ((IClientChannel)client).Close();
            }

            return(responseResult);
        }
        private async Task <string> GetHtmlMessage(List <Tuple <string, string> > chartUrls, ExportRequestBody requestBody)
        {
            using var reader = new StreamReader(@"Properties/Assets/Message.html");
            var html = await reader.ReadToEndAsync();

            foreach (var chartUrl in chartUrls)
            {
                html = html.Replace('{' + chartUrl.Item1 + '}', chartUrl.Item2);
            }

            html = FillPlaceHolders(html, requestBody);
            return(html);
        }
 public async Task ExportForecast(ExportRequestBody requestBody)
 {
     var chartUrls = _chartService.GetChartUrl(await _databaseAccessService.GetForecastAsync(requestBody.RevenueForecastId));
     var message   = GetHtmlMessage(await chartUrls, requestBody);
     await _mailingService.SendMessageAsync(await message, requestBody.Email);
 }
예제 #6
0
        public async Task <IActionResult> ExportHtml([FromBody] ExportRequestBody requestBody)
        {
            await _exportService.ExportForecast(requestBody);

            return(Ok());
        }