@code {
private IEnumerable<SupplierInvoices> invoices = Array.Empty<SupplierInvoices>();
private bool getInvoicesError;
private bool shouldRender;
protected override bool ShouldRender() => shouldRender;
protected override async Task OnInitializedAsync()
{
var request = new HttpRequestMessage(HttpMethod.Get,"https://<url of service>");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("User-Agent", "Blazor-http-client");
request.Headers.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("<username>:<password>")));
var client = ClientFactory.CreateClient();
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
using var responseStream = await response.Content.ReadAsStreamAsync();
JsonNode odataSet = await JsonSerializer.DeserializeAsync<JsonNode>(responseStream);
var jsonString = odataSet["d"]["results"].ToString();
invoices = JsonSerializer.Deserialize<IEnumerable<SupplierInvoices>>(jsonString);
}
else
{
getInvoicesError = true;
}
shouldRender = true;
}
public class SupplierInvoices
{
[JsonPropertyName("SupplierInvoice")]
public string? SupplierInvoice { get; set; }
[JsonPropertyName("FiscalYear")]
public string? FiscalYear { get; set; }
[JsonPropertyName("CompanyCode")]
public string? CompanyCode { get; set; }
[JsonPropertyName("AccountingDocumentType")]
public string? AccountingDocumentType { get; set; }
[JsonPropertyName("InvoicingParty")]
public string? InvoicingParty { get; set; }
[JsonPropertyName("DocumentCurrency")]
public string? DocumentCurrency { get; set; }
[JsonPropertyName("InvoiceGrossAmount")]
public string? InvoiceGrossAmount { get; set; }
[JsonPropertyName("DocumentHeaderText")]
public string? DocumentHeaderText { get; set; }
[JsonPropertyName("PaymentTerms")]
public string? PaymentTerms { get; set; }
[JsonPropertyName("DueCalculationBaseDate")]
public string? DueCalculationBaseDate { get; set; }
}
}
@if (getInvoicesError)
{
<p>Unable to get invoices from S/4HANA Cloud. Sorry for that.</p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Invoice #</th>
<th>Document type</th>
<th>Fiscal year</th>
<th>Invoicing party</th>
<th>Gross amount</th>
<th>Company code</th>
<th>Header text</th>
<th>Payment terms</th>
</tr>
</thead>
<tbody>
@foreach (var invoice in invoices)
{
<tr>
<td>@invoice.SupplierInvoice</td>
<td>@invoice.AccountingDocumentType</td>
<td>@invoice.FiscalYear</td>
<td>@invoice.InvoicingParty</td>
<td>@invoice.DocumentCurrency @invoice.InvoiceGrossAmount</td>
<td>@invoice.CompanyCode</td>
<td>@invoice.DocumentHeaderText</td>
<td>@invoice.PaymentTerms</td>
</tr>
}
</tbody>
</table>
}
app.UseHttpsRedirection();
# Create docker image to be used on SAP BTP Kyma for .NET web server
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
# Port number of server
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /usr/src
COPY ["BlazorApp.csproj", "."]
RUN dotnet restore "BlazorApp.csproj"
# Copy the code into the workdir
COPY . .
RUN dotnet build "BlazorApp.csproj" -c Release -o /usr/app/build
FROM build AS publish
RUN dotnet publish "BlazorApp.csproj" -c Release -o /usr/app/publish
FROM base AS final
WORKDIR /usr/app
COPY --from=publish /usr/app/publish .
ENTRYPOINT ["dotnet", "BlazorApp.dll"]
docker build --tag <your docker id>/<your image name>:<your tag version> .
docker push <your docker id>/<your image name>:<your tag version>
apiVersion: v1
kind: Namespace
metadata:
name: dotnet-blazor
labels:
istio-injection: enabled
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dotnet-blazor
namespace: dotnet-blazor
spec:
replicas: 1
selector:
matchLabels:
app: dotnet-blazor-app
template:
metadata:
labels:
app: dotnet-blazor-app
spec:
containers:
- name: dotnet-blazor-image
image: <your docker id>/<your image name>:<your tag version>
imagePullPolicy: Always
ports:
- containerPort: 80
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
labels:
app: dotnet-blazor-app
name: dotnet-blazor-service
namespace: dotnet-blazor
spec:
ports:
- name: "webserverport"
port: 8080
targetPort: 80
type: ClusterIP
selector:
app: dotnet-blazor-app
--
apiVersion: gateway.kyma-project.io/v1alpha1
kind: APIRule
metadata:
labels:
app.kubernetes.io/name: dotnet-blazor-apirule
name: dotnet-blazor-apirule
namespace: dotnet-blazor
spec:
gateway: kyma-gateway.kyma-system.svc.cluster.local
rules:
- accessStrategies:
- config: {}
handler: allow
methods:
- GET
- POST
- PUT
- DELETE
- PATCH
- HEAD
path: /.*
service:
host: myblazorapp
name: dotnet-blazor-service
port: 8080
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |