FastReport.OpenSource.Web support .Net Core 3.0? - asp.net-core-3.0

I have this problem when I render the report. I render the report like this:
#ViewBag.WebReport.Render();
var webReport = new WebReport();
webReport.Report.Load(#"\report.frx");
foreach (var item in paramether) {
webReport.Report.SetParameterValue(item.Key, item.Value);
}
webReport.Report.RegisterData(datos, "Mydata");
ViewBag.WebReport = webReport;
**System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[Microsoft.AspNetCore.Html.HtmlString,FastReport.Web.WebReport+d__107]**

I found the problem I need to add await #await ViewBag.WebReport.Render();

Related

Xamarin Forms Android - Display .ico Image - Error: could not find any valid embedded ico codecs

I am trying to display an icon related to a website by using its favicon.ico file.
On some devices this works fine however on others I get the following error in the console and the image appears blank:
Error: could not find any valid embedded ico codecs.
Is there a way to include additional codecs or can anyone suggest a way to convert this is a PNG in Xamarin Forms?
Found a usefull image API called SkiaSharp to convert between .ico and .png in Xamarin Forms:
Docs:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/
https://learn.microsoft.com/en-us/dotnet/api/skiasharp?view=skiasharp-1.68.0
Nuget:
https://www.nuget.org/packages/SkiaSharp
Example:
var iconUri = new Uri(this.URI + "/favicon.ico");
using (var webClient = new System.Net.WebClient())
{
var imageBytes = webClient.DownloadData(iconUri);
using (var bmp = SkiaSharp.SKBitmap.Decode(imageBytes))
{
using (var img = SkiaSharp.SKImage.FromBitmap(bmp))
{
using (var imgData = img.Encode())
{
using (var ms = new System.IO.MemoryStream())
{
imgData.SaveTo(ms);
imageBytes = ms.ToArray();
}
}
}
}
this.Icon = ImageSource.FromStream(() => new System.IO.MemoryStream(imageBytes));
}
Note: I intend to make improvements later to get the favicon by parsing the HTML to find the <link rel="shortcut icon" tag

accessing nested fields in handlebars when rendering from vert.x

I'm trying to render a page with an object having named fields:
{
"context":{
"greeting":"hello"
}
}
And I'm rendering this with a very simple template:
<html>
<body>
<div class="page">
{{#with context}}
<h1>{{greeting}} or {{this.greeting}}</h1>
{{/with}}
<h1>{{greeting}} or {{context.greeting}}</h1>
</div>
<div>the context is actually: {{context}} </div>
</body>
</html>
As you can see above, I'm currently trying out several ways of rendering the greeting value. in earlier versions of this template I have tried them all one at a time too.
At the end of the template, I'm rendering the entirety of the context variable, just to ensure that the data I pass in is actually present. here is a screenshot of the result:
Having read the docs here and a tutorial here I really can't see what I'm doing wrong, can someone clarify?
I should add that I'm using io.vertx:vertx-web-templ-handlebars:3.3.3 to render this
Below is the java method that returns this template. I'm using the Vert.x rendering engine.
private void handleStatus(RoutingContext ctx, TemplateEngine engine, String template)
{
JsonObject json = new JsonObject();
json.put("greeting", "hello");
ctx.put("context", json);
engine.render(ctx, template, res ->
{
if (res.succeeded())
{
ctx.response().end(res.result());
}
else
{
ctx.fail(res.cause());
}
});
}
and here is where that method gets called from:
TemplateEngine engine = HandlebarsTemplateEngine.create();
statusHandler = new StatusHandler(vertx);
statusHandler.start();
deploymentHandler = new DeploymentHandler(vertx);
router.get("/monitor/apistatus").handler(ctx -> handleStatus(ctx, engine, "templates/apistatus.hbs"));
Prior to 3.4.0, the Vert.x Web Handlebars template engine did not work well with JsonObject and JsonArray.
Upgrade to 3.4/3.5, or as a workaround, you could convert your JsonObject to a Map.

Bind two html view with one js template on meteor.js

I have 2 separate html templates for desktop and mobile size with common logic. Is there possibility bind these html templates with one js template ?
The easiest way I've found to do that is to use a dynamic template to pick the mobile or desktop template and attach the js to the parent template - the one that embeds the dynamic template.
In my case solution was next
I used Blaze to switch between templates like adviced me Michel Floyd, and helpers were just passed to datacontext to both templates.
My general html page view and part of js template below
<template name="signUpTutor">
{{#if equals view 'mobile'}}
{{> Template.dynamic template="signUpTutorMobile" data=dataContext}}
{{else}}
{{> Template.dynamic template="signUpTutorDesktop" data=dataContext}}
{{/if}}
Template.signUpTutor.helpers({
'equals': function (a, b) {
return a == b;
},
'dataContext': function () {
var dataContext = {}
dataContext.subjects = Subjects.find();
dataContext.ageOptions = function () {
var ageOptions = [];
for (var i = 0, a = 19; a <= 99; i++, a++) {
ageOptions[i] = a;
}
return ageOptions;
};
dataContext.experienceOptions = function () {
var experienceOptions = [];
for (var i = 0, a = 1; a <= 60; i++, a++) {
experienceOptions[i] = a;
}
return experienceOptions;
};
return dataContext;
}
});
You can use media queries to do this. It allows you to specify breakpoints (ie screen sizes) at which the HTML rendered will change. This will allow the desktop user to see the mobile view simply by resizing the window.
http://www.w3schools.com/css/css_rwd_mediaqueries.asp

Typescript in cshtml

I created a new JS object in the cshtml file. I want to use TS interface validation on this object.
<script type="text/javascript">
var clusteredPins = [];
#foreach (var d in Model)
{
#:clusteredPins.push({latitude: #d.location.latitude});
}
I defined IClasteredPin interface in a interface.ts file but I don't see any way to use typescript in the cshtml file. My ideal code would look like this:
<script type="text/javascript">
var clusteredPins:IClasteredPin = [];
#foreach (var d in Model)
{
#:clusteredPins.push({latitude: #d.location.latitude});
}
There is a similar question but the answers are not what I am looking. I am not sure people who answered that question understands the problem. I don't want to run TS on client site. I want to use ts in cshtml like it was in a ts file.

PagedListPager customise paging links

I'm using the following package to do paging in ASP.NET MVC
https://github.com/TroyGoode/PagedList
This is wokring great, however I'd like to be able to add a extra HTML5 data attribute to the pager links. Simply which contains the page number of the link.
For example:
1 2 etc etc
But I'm struggling to do this and can only get the page number into the URL.
Can anyone help? I would have thought this would have been a common and useful feature.
Thanks
Sorted with some help from Troy, working perfect now :)
#Html.PagedListPager(Model, page => "admin/demo/userlist", new PagedListRenderOptions { FunctionToTransformEachPageLink = (liTag, aTag) => { aTag.Attributes.Add("data-page-no", aTag.InnerHtml); liTag.InnerHtml = aTag.ToString(); return liTag; } })
Short deadline hack. I tried something similar, but if the inner HTML for the hyperlink is an ellipse or some other special character, it didn't quite work.
FunctionToTransformEachPageLink = (li, a) =>
{
if (a.Attributes.ContainsKey("href"))
{
Uri uri;
if (Uri.TryCreate("http://temp.org/" + a.Attributes["href"], UriKind.Absolute, out uri))
{
var qs = uri.Query;
if (!string.IsNullOrWhiteSpace(qs))
{
var nvc = HttpUtility.ParseQueryString(qs);
var page = nvc["page"];
a.MergeAttribute("data-page", page);
}
}
}
else
{
int page;
if (int.TryParse(a.InnerHtml, out page))
a.MergeAttribute("data-page", page.ToString());
}
li.InnerHtml = a.ToString();
return li;
}
"FunctionToTransformEachPageLink" should include the current page as a delegate parameter.
Using "latest" 8.0.7 nuget X.PagedListMvc.Core the FunctionToTransformEachPageLink delegate is adding and additional element when passing return value. So if you return liTag the page number link will be doubled. The working code is below, just returning an empty tag builder:
FunctionToTransformEachPageLink = (TagBuilder liTag, TagBuilder aTag) =>
{
var ret = new TagBuilder("text");
aTag.Attributes.Add("data-otf-target", "#page-wrapper");
liTag.InnerHtml.AppendHtml(aTag);
return ret;
},
If anyone has a better solution please edit this post.

Resources