public async Task <IActionResult> GeneratePdf([FromBody] PrintMapDTO printMapDTO) { using (loggingHelper.RMTraceManager.StartTrace("WebService.GeneratePdf")) { string methodName = MethodHelper.GetActualAsyncMethodName(); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodEntryEventId, LoggerTraceConstants.Title); try { var result = await mapGeneratorBusinessService.GenerateMapPdfReport(printMapDTO); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodExitEventId, LoggerTraceConstants.Title); return(Ok(result)); } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } } }
/// <summary> /// generate Print Map pdf using xsl fo /// </summary> /// <param name="printMapDTO">printMapDTO</param> /// <returns>Pdf file name </returns> public async Task <string> GenerateMapPdfReport(PrintMapDTO printMapDTO) { using (loggingHelper.RMTraceManager.StartTrace("Business.GenerateMapPdfReport")) { string methodName = MethodHelper.GetActualAsyncMethodName(); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title); string pdfFilename = string.Empty; if (printMapDTO != null) { MapConfiguration configuration = new MapConfiguration(); configuration.OutputTo = GetOutputTo(printMapDTO.PdfSize, printMapDTO.PdfOrientation); string caption = printMapDTO.MapTitle; string source = printMapDTO.ImagePath; string timestamp = "Date: " + printMapDTO.PrintTime; // TODO load from resource file string scale = "Scale: " + printMapDTO.CurrentScale; // TODO load from resource file string[] legalNotices = { printMapDTO.License }; XmlDocument mapXml = MapFactory.GetMap(caption, source, timestamp, scale, legalNotices, configuration); //GenerateXml(printMapDTO); pdfFilename = await mapIntegrationService.GenerateReportWithMap(mapXml.InnerXml, xsltFilepath); } loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodExitEventId, LoggerTraceConstants.Title); return(pdfFilename); } }
/// <summary> /// Method to save captured map image in png format. /// </summary> /// <param name="printMapDTO">printMapDTO</param> private void SaveMapImage(PrintMapDTO printMapDTO) { using (loggingHelper.RMTraceManager.StartTrace("Business.SaveMapImage")) { string methodName = MethodBase.GetCurrentMethod().Name; loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title); if (!string.IsNullOrEmpty(printMapDTO.EncodedString)) { string[] encodedStringArray = printMapDTO.EncodedString.Split(','); string imageLocation = string.Empty; if (encodedStringArray != null && encodedStringArray.Count() > 0) { imageLocation = imagePath + Guid.NewGuid() + ".png"; byte[] imageBytes = Convert.FromBase64String(encodedStringArray[1]); File.WriteAllBytes(imageLocation, imageBytes); } printMapDTO.ImagePath = imageLocation; } loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title); } }
public IActionResult SaveMapImage([FromBody] PrintMapDTO printMapDTO) { using (loggingHelper.RMTraceManager.StartTrace("WebService.SaveMapImage")) { string methodName = MethodBase.GetCurrentMethod().Name; loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodEntryEventId, LoggerTraceConstants.Title); var result = mapGeneratorBusinessService.SaveImage(printMapDTO); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerControllerMethodExitEventId, LoggerTraceConstants.Title); return(Ok(result)); } }
/// <summary> /// Method to retrieve map details /// </summary> /// <param name="printMapDTO">printMapDTO</param> /// <returns>deliveryRouteDto</returns> public PrintMapDTO SaveImage(PrintMapDTO printMapDTO) { using (loggingHelper.RMTraceManager.StartTrace("Business.SaveImage")) { string methodName = MethodBase.GetCurrentMethod().Name; loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodEntryEventId, LoggerTraceConstants.Title); if (printMapDTO != null) { printMapDTO.PrintTime = string.Format(MapManagerConstants.PrintMapDateTimeFormat, DateTime.Now); SaveMapImage(printMapDTO); } loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.MapManagerAPIPriority, LoggerTraceConstants.MapManagerBusinessServiceMethodExitEventId, LoggerTraceConstants.Title); return(printMapDTO); } }