This commit is contained in:
honzapatCZ 2024-11-11 19:13:25 +01:00
commit c996ddc53c
5 changed files with 163 additions and 120 deletions

View File

@ -139,6 +139,11 @@ namespace NejCommon.Controllers
return query;
}
protected virtual Task<PaginationResponse<TGetAllResponse>> ApplyPagination(IQueryable<TType> query, Pagination pag)
{
return query.ApplyPaginationRes<TType, TGetAllResponse>(providers, pag);
}
/// <summary>
/// Get all the <typeparamref name="TType"/>
/// </summary>
@ -147,7 +152,7 @@ namespace NejCommon.Controllers
[HttpGet]
public virtual async Task<Results<BadRequest<Error>, Ok<PaginationResponse<TGetAllResponse>>>> GetAll([FromServices] TOwner company, [FromQuery] Pagination pag)
{
var data = await ApplyDefaultOrdering(GetQuery(company)).AsNoTrackingWithIdentityResolution().ApplyPaginationRes<TType, TGetAllResponse>(providers, pag);
var data = await ApplyPagination(ApplyDefaultOrdering(GetQuery(company)).AsNoTrackingWithIdentityResolution(), pag);
//Console.Writeline(data.Data);

View File

@ -9,15 +9,19 @@ namespace NejCommon.Controllers;
public static class Responses
{
public static FileStreamHttpResult RespondFileStream(this ControllerBase controller, Stream stream, string contentType, string fileName)
{
stream.Seek(0, SeekOrigin.Begin);
controller.Response.Headers.Add("Content-Disposition", "inline; filename=" + fileName);
return TypedResults.File(stream, contentType, fileName);
}
public static FileStreamHttpResult RespondXlsx(this ControllerBase controller, XLWorkbook file, string fileName)
{
var stream = new MemoryStream();
file.SaveAs(stream);
stream.Seek(0, SeekOrigin.Begin);
controller.Response.Headers.Add("Content-Disposition", "inline; filename=" + fileName);
return TypedResults.File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
return RespondFileStream(controller, stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
}
public static FileStreamHttpResult RespondXlsxTable<T>(this ControllerBase controller, IEnumerable<T> data, string name = "Data", string? sheetName = null)
{
@ -39,11 +43,7 @@ public static class Responses
public static FileStreamHttpResult RespondXml<T>(this ControllerBase controller, T obj, string fileName = "Data.xml")
{
var stream = Utils.Xml.Serialize(obj);
//Console.Writeline(stream.Length);
stream.Seek(0, SeekOrigin.Begin);
controller.Response.Headers.Add("Content-Disposition", "inline; filename=" + fileName);
return TypedResults.File(stream, "text/xml", fileName);
return RespondFileStream(controller, stream, "text/xml", fileName);
}
}

View File

@ -1,5 +1,113 @@
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
/*
! tailwindcss v3.4.11 | MIT License | https://tailwindcss.com
! tailwindcss v3.4.13 | MIT License | https://tailwindcss.com
*/
/*
@ -446,114 +554,6 @@ video {
display: none;
}
*, ::before, ::after {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
::backdrop {
--tw-border-spacing-x: 0;
--tw-border-spacing-y: 0;
--tw-translate-x: 0;
--tw-translate-y: 0;
--tw-rotate: 0;
--tw-skew-x: 0;
--tw-skew-y: 0;
--tw-scale-x: 1;
--tw-scale-y: 1;
--tw-pan-x: ;
--tw-pan-y: ;
--tw-pinch-zoom: ;
--tw-scroll-snap-strictness: proximity;
--tw-gradient-from-position: ;
--tw-gradient-via-position: ;
--tw-gradient-to-position: ;
--tw-ordinal: ;
--tw-slashed-zero: ;
--tw-numeric-figure: ;
--tw-numeric-spacing: ;
--tw-numeric-fraction: ;
--tw-ring-inset: ;
--tw-ring-offset-width: 0px;
--tw-ring-offset-color: #fff;
--tw-ring-color: rgb(59 130 246 / 0.5);
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
--tw-blur: ;
--tw-brightness: ;
--tw-contrast: ;
--tw-grayscale: ;
--tw-hue-rotate: ;
--tw-invert: ;
--tw-saturate: ;
--tw-sepia: ;
--tw-drop-shadow: ;
--tw-backdrop-blur: ;
--tw-backdrop-brightness: ;
--tw-backdrop-contrast: ;
--tw-backdrop-grayscale: ;
--tw-backdrop-hue-rotate: ;
--tw-backdrop-invert: ;
--tw-backdrop-opacity: ;
--tw-backdrop-saturate: ;
--tw-backdrop-sepia: ;
--tw-contain-size: ;
--tw-contain-layout: ;
--tw-contain-paint: ;
--tw-contain-style: ;
}
.visible {
visibility: visible;
}
@ -570,6 +570,10 @@ video {
display: table;
}
.hidden {
display: none;
}
.filter {
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
}

View File

@ -10,7 +10,7 @@ public class FakeGraphicsEngine : IXLGraphicEngine
{
private static double PointsToPixels(double points, double dpi)
{
return points / 72.0 * dpi;
return points / 72.0 * dpi / 10.0;
}
public double GetDescent(IXLFontBase font, double dpiY)
{

34
Utils/XmlUtils.cs Normal file
View File

@ -0,0 +1,34 @@
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace NejCommon.Utils;
public static class XmlUtils
{
public static MemoryStream GetXmlStream<T>(T obj) where T : class
{
var stream = new MemoryStream();
//use utf8 encoding
var serializer = new XmlSerializer(typeof(T));
var settings = new XmlWriterSettings
{
Indent = true,
Encoding = Encoding.UTF8,
};
//Console.Writeline(stream.Length);
using (var writer = XmlWriter.Create(stream, settings))
{
serializer.Serialize(writer, obj);
//Console.Writeline(stream.Length);
stream.Seek(0, SeekOrigin.Begin);
return stream;
}
}
}