db1.Database.EnsureDeleted();
Console.WriteLine("Database.EnsureDeleted");
db1.Database.EnsureCreated();
db1.Database.ExecuteSqlRaw("ALTER DATABASE dbname1 OWNER TO user1;");
Console.WriteLine("Database.EnsureCreated");
/*
* ...to startup
* app.UseMiddleware<AnsHttpExceptionHandler>();
*/
public class MyHttpException(HttpStatusCode statusCode) : Exception
{
public HttpStatusCode StatusCode { get; set; } = statusCode;
}
public class MyHttpExceptionHandler(RequestDelegate pipeline)
{
private readonly RequestDelegate request = pipeline;
public Task Invoke(HttpContext context) => return InvokeAsync(context);
async Task InvokeAsync(HttpContext context)
{
try { await request(context); }
catch (AnsHttpException exception)
{
context.Response.StatusCode = (int)exception.StatusCode;
context.Response.Headers.Clear();
}
}
}
@{
throw new MyHttpException(HttpStatusCode.NotFound);
}
mediaEmbed: {
previewsInData: true,
providers: [
{
/*
https://youtu.be/IlxSbtP2SNg
<iframe src="https://www.youtube.com/embed/IlxSbtP2SNg" frameborder="0" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
*/
name: 'youtube',
url: /^youtu\.be\/([\w-]+)?/,
html: match =>
`<iframe src="https://www.youtube.com/embed/${match[1]}" frameborder="0" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>`
},
]
},
var elem1 = document.createElement('div');
elem1.className = 'ans-locker';
elem1.innerHTML = '<div class="ans-spinner"></div>';
document.body.appendChild(elem1);
location.reload(true);
.ans-locker {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
opacity: .5;
z-index: 1000;
background: #fff;
}
.ans-spinner {
min-width: 48px;
min-height: 48px;
background-repeat: no-repeat;
background-image: url('data:image/gif;base64,#КОД СПИННЕРА***#');
}
function getAllCSSVariableNames(styleSheets = document.styleSheets) {
let names1 = [];
for (const sheet1 of styleSheets) {
try {
for (const rule1 of sheet1.cssRules)
if (rule1.cssText.startsWith(':root'))
for (const name1 of rule1.style)
if (names1.indexOf(name1) == -1)
names1.push(name1);
} catch { }
}
return names1;
}
function getElementCSSVariables(names, element = document.body, pseudo) {
let styles1 = window.getComputedStyle(element, pseudo);
let vars1 = {};
for (let i1 = 0; i1 < names.length; i1++) {
let key1 = names[i1];
let value1 = styles1.getPropertyValue(key1)
vars1[key1] = value1;
}
return vars1;
}
const names = getAllCSSVariableNames();
const vars = getElementCSSVariables(names);
const elem1 = document.getElementById('cssVariables');
let s1 = '';
for (let key1 in vars) {
s1 += `<tr><td class="text-nowrap">${key1}</td><td><code>${vars[key1]}</code></td></tr>`;
}
elem1.innerHTML = s1;
public static IEnumerable<IEnumerable<T>> Split<T>(
this IEnumerable<T> source,
int count)
{
return source
.Select((x, y) => new { Index = y, Value = x })
.GroupBy(x => x.Index / count)
.Select(x => x.Select(y => y.Value).ToList())
.ToList();
}
/// <summary>
/// Генерация нового PDF
/// </summary>
private void CreateDPF()
{
string fileResult = HostingEnvironment.MapPath("/Files/result.pdf");
var d = new Document();
var s = d.AddSection();
s.PageSetup.PageFormat = PageFormat.A4;
s.PageSetup.Orientation = Orientation.Portrait;
s.PageSetup.TopMargin = 10;
s.PageSetup.LeftMargin = 10;
s.PageSetup.BottomMargin = 10;
s.PageSetup.RightMargin = 10;
var p = s.AddParagraph();
p.AddText("Превед медвед!");
var r = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
r.Document = d;
r.RenderDocument();
r.PdfDocument.Save(fileResult);
}
/// <summary>
/// Генерация PDF на основе другого PDF
/// </summary>
private void ConvertDPF()
{
string fileSource = HostingEnvironment.MapPath("/Files/source.pdf");
string fileResult = HostingEnvironment.MapPath("/Files/result.pdf");
using (var src = PdfReader.Open(fileSource, PdfDocumentOpenMode.Import))
using (var res = new PdfDocument())
{
foreach (PdfPage page in src.Pages)
{
// что-то нужно сделать с этой page
res.AddPage(page);
}
res.Save(fileResult);
}
}