Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Profiler.cs 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using AutoMapper;
  2. using PuppeteerSharp;
  3. using BlackRock.Reporting.API.Core.Models;
  4. using BlackRock.Reporting.API.Mediator.Model;
  5. using BlackRock.Reporting.API.Mediator.Dto;
  6. namespace BlackRock.Reporting.API.Profiles
  7. {
  8. public class Profiler : Profile
  9. {
  10. public Profiler()
  11. {
  12. CreateMap<OptionsForPdf, PdfOptions>().ConvertUsing<OptionsForPdfConverter>();
  13. CreateMap<User, UserDto>().ReverseMap();
  14. CreateMap<User, UserCommand>().ReverseMap();
  15. }
  16. }
  17. public class OptionsForPdfConverter : ITypeConverter<OptionsForPdf, PdfOptions>
  18. {
  19. public PdfOptions Convert(OptionsForPdf source, PdfOptions destination, ResolutionContext context)
  20. {
  21. if (source == null) return destination;
  22. if (destination == null)
  23. destination = new PdfOptions();
  24. destination.DisplayHeaderFooter = source.DisplayHeaderFooter;
  25. destination.HeaderTemplate = source.HeaderTemplate;
  26. destination.Height = source.Height;
  27. destination.Landscape = source.Landscape;
  28. destination.OmitBackground = source.OmitBackground;
  29. destination.PageRanges = source.PageRanges;
  30. destination.PreferCSSPageSize = source.PreferCSSPageSize;
  31. destination.PrintBackground = source.PrintBackground;
  32. destination.Scale = source.Scale;
  33. destination.Width = source.Width;
  34. destination.MarginOptions = new PuppeteerSharp.Media.MarginOptions()
  35. {
  36. Bottom = source.MarginBottom,
  37. Top = source.MarginTop,
  38. Right = source.MarginRight,
  39. Left = source.MarginLeft
  40. };
  41. switch (source.PaperFormatType)
  42. {
  43. case PaperFormatType.A4:
  44. destination.Format = PuppeteerSharp.Media.PaperFormat.A4;
  45. break;
  46. case PaperFormatType.A3:
  47. destination.Format = PuppeteerSharp.Media.PaperFormat.A3;
  48. break;
  49. case PaperFormatType.Letter:
  50. destination.Format = PuppeteerSharp.Media.PaperFormat.Letter;
  51. break;
  52. }
  53. return destination;
  54. }
  55. }
  56. }