Skip to content

Commit 750235c

Browse files
EF
1 parent 3562bff commit 750235c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2510
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(DevExpress.ExpressApp.Blazor.BlazorApplication).Assembly }">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView>
7+
<PageTitle>Not found</PageTitle>
8+
<p role="alert">Sorry, there's nothing at this address.</p>
9+
</LayoutView>
10+
</NotFound>
11+
</Router>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using DevExpress.ExpressApp;
2+
using DevExpress.ExpressApp.ApplicationBuilder;
3+
using DevExpress.ExpressApp.Blazor;
4+
using DevExpress.ExpressApp.SystemModule;
5+
using ItemCountEF.Module.BusinessObjects;
6+
using Microsoft.EntityFrameworkCore;
7+
using DevExpress.ExpressApp.EFCore;
8+
9+
namespace ItemCountEF.Blazor.Server;
10+
11+
public class ItemCountEFBlazorApplication : BlazorApplication {
12+
public ItemCountEFBlazorApplication() {
13+
ApplicationName = "ItemCountEF";
14+
CheckCompatibilityType = DevExpress.ExpressApp.CheckCompatibilityType.DatabaseSchema;
15+
DatabaseVersionMismatch += ItemCountEFBlazorApplication_DatabaseVersionMismatch;
16+
}
17+
protected override void OnSetupStarted() {
18+
base.OnSetupStarted();
19+
#if DEBUG
20+
if(System.Diagnostics.Debugger.IsAttached && CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) {
21+
DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways;
22+
}
23+
#endif
24+
}
25+
private void ItemCountEFBlazorApplication_DatabaseVersionMismatch(object sender, DatabaseVersionMismatchEventArgs e) {
26+
#if EASYTEST
27+
e.Updater.Update();
28+
e.Handled = true;
29+
#else
30+
if(System.Diagnostics.Debugger.IsAttached) {
31+
e.Updater.Update();
32+
e.Handled = true;
33+
}
34+
else {
35+
string message = "The application cannot connect to the specified database, " +
36+
"because the database doesn't exist, its version is older " +
37+
"than that of the application or its schema does not match " +
38+
"the ORM data model structure. To avoid this error, use one " +
39+
"of the solutions from the https://www.devexpress.com/kb=T367835 KB Article.";
40+
41+
if(e.CompatibilityError != null && e.CompatibilityError.Exception != null) {
42+
message += "\r\n\r\nInner exception: " + e.CompatibilityError.Exception.Message;
43+
}
44+
throw new InvalidOperationException(message);
45+
}
46+
#endif
47+
}
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.ComponentModel;
2+
using DevExpress.ExpressApp;
3+
using DevExpress.ExpressApp.DC;
4+
using DevExpress.ExpressApp.Model;
5+
using DevExpress.ExpressApp.Editors;
6+
using DevExpress.ExpressApp.Actions;
7+
using DevExpress.ExpressApp.Updating;
8+
using DevExpress.ExpressApp.Model.Core;
9+
using DevExpress.ExpressApp.Model.DomainLogics;
10+
using DevExpress.ExpressApp.Model.NodeGenerators;
11+
using DevExpress.Persistent.BaseImpl.EF;
12+
13+
namespace ItemCountEF.Blazor.Server;
14+
15+
[ToolboxItemFilter("Xaf.Platform.Blazor")]
16+
// For more typical usage scenarios, be sure to check out https://docs.devexpress.com/eXpressAppFramework/DevExpress.ExpressApp.ModuleBase.
17+
public sealed class ItemCountEFBlazorModule : ModuleBase {
18+
public ItemCountEFBlazorModule() {
19+
}
20+
public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB) {
21+
return ModuleUpdater.EmptyModuleUpdaters;
22+
}
23+
public override void Setup(XafApplication application) {
24+
base.Setup(application);
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Folder Description
2+
3+
The "Controllers" project folder is intended for storing Blazor-specific Controller classes
4+
that can change the default XAF application flow and add new features.
5+
6+
7+
Relevant Documentation
8+
9+
Controllers and Actions
10+
https://docs.devexpress.com/eXpressAppFramework/112623
11+
12+
Implement Custom Controllers
13+
https://docs.devexpress.com/eXpressAppFramework/112621
14+
15+
Define the Scope of Controllers and Actions
16+
https://docs.devexpress.com/eXpressAppFramework/113103
17+
18+
Ways to Show a View
19+
https://docs.devexpress.com/eXpressAppFramework/112803
20+
21+
Ways to Implement Business Logic
22+
https://docs.devexpress.com/eXpressAppFramework/113710
23+
24+
Debugging, Unit and Functional Testing
25+
https://docs.devexpress.com/eXpressAppFramework/112572
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Folder Description
2+
3+
This project folder is intended for storing custom Blazor List Editors,
4+
Property Editors and View Items.
5+
6+
7+
Relevant Documentation
8+
9+
Using a Custom Control that is not Integrated by Default
10+
https://docs.devexpress.com/eXpressAppFramework/113610
11+
12+
Ways to Access UI Elements and Their Controls
13+
https://docs.devexpress.com/eXpressAppFramework/120092
14+
15+
Views
16+
https://docs.devexpress.com/eXpressAppFramework/112611
17+
18+
List Editors
19+
https://docs.devexpress.com/eXpressAppFramework/113189
20+
21+
View Items
22+
https://docs.devexpress.com/eXpressAppFramework/112612
23+
24+
Debugging, Unit and Functional Testing
25+
https://docs.devexpress.com/eXpressAppFramework/112572
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Folder Description
2+
3+
The "Images" project folder is intended for storing custom image files.
4+
5+
6+
Relevant Documentation
7+
8+
Add and Override Images
9+
https://docs.devexpress.com/eXpressAppFramework/112792
10+
11+
Assign a Custom Image
12+
https://docs.devexpress.com/eXpressAppFramework/112744
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
5+
<Deterministic>false</Deterministic>
6+
<AssemblyVersion>1.0.*</AssemblyVersion>
7+
<FileVersion>1.0.0.0</FileVersion>
8+
<Configurations>Debug;Release;EasyTest</Configurations>
9+
<ImplicitUsings>enable</ImplicitUsings>
10+
</PropertyGroup>
11+
<ItemGroup>
12+
<None Remove="Model.xafml" />
13+
</ItemGroup>
14+
<ItemGroup>
15+
<Content Include="Model.xafml">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</Content>
18+
</ItemGroup>
19+
<ItemGroup>
20+
<PackageReference Include="DevExpress.ExpressApp.Blazor" Version="22.2.5" />
21+
<PackageReference Include="DevExpress.ExpressApp.CodeAnalysis" Version="22.2.5" />
22+
</ItemGroup>
23+
<ItemGroup>
24+
<ProjectReference Include="..\ItemCountEF.Module\ItemCountEF.Module.csproj" />
25+
</ItemGroup>
26+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application>
3+
<NavigationItems NavigationStyle="Accordion">
4+
</NavigationItems>
5+
<Views DefaultListEditor="DevExpress.ExpressApp.Blazor.Editors.DxGridListEditor">
6+
</Views>
7+
</Application>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page "/"
2+
@namespace ItemCountEF.Blazor.Server
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4+
@using DevExpress.ExpressApp.Blazor.Components
5+
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
9+
<head>
10+
<meta charset="utf-8" />
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no" />
12+
<meta name="apple-mobile-web-app-capable" content="yes" />
13+
<!-- meta name="theme-color" content="#000000" -->
14+
<title>ItemCountEF</title>
15+
<base href="~/" />
16+
<component type="typeof(BootstrapThemeLink)" render-mode="Static" />
17+
</head>
18+
<body>
19+
@{
20+
string userAgent = Request.Headers["User-Agent"];
21+
bool isIE = userAgent.Contains("MSIE") || userAgent.Contains("Trident");
22+
}
23+
@if(isIE) {
24+
<link href="css/site.css" rel="stylesheet" />
25+
<div class="d-flex flex-column justify-content-center align-items-center h-100">
26+
<div class="d-flex">
27+
<img class="mt-2 mr-4" src="_content/DevExpress.ExpressApp.Blazor/images/Sad.svg" width="60" height="60" />
28+
<div>
29+
<div class="h1">Internet Explorer is not supported.</div>
30+
<p style="font-size: 1rem; opacity: 0.75;" class="m-0">ItemCountEF cannot be loaded in Internet Explorer.<br>Please use a different browser.</p>
31+
</div>
32+
</div>
33+
</div>
34+
}
35+
else {
36+
<component type="typeof(SplashScreen)" render-mode="Static" param-Caption='"ItemCountEF"' param-ImagePath='"images/SplashScreen.svg"' />
37+
38+
<link href="_content/DevExpress.ExpressApp.Blazor/styles.css" rel="stylesheet" />
39+
<link href="css/site.css" rel="stylesheet" />
40+
<script src="_content/DevExpress.ExpressApp.Blazor/scripts.js"></script>
41+
42+
<app class="d-none">
43+
<component type="typeof(App)" render-mode="Server" />
44+
</app>
45+
46+
<component type="typeof(AlertsHandler)" render-mode="Server" />
47+
48+
<div id="blazor-error-ui">
49+
<component type="typeof(BlazorError)" render-mode="Static" />
50+
</div>
51+
52+
<script src="_framework/blazor.server.js"></script>
53+
}
54+
</body>
55+
</html>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System.Reflection;
2+
using DevExpress.ExpressApp;
3+
using DevExpress.ExpressApp.Blazor.DesignTime;
4+
using DevExpress.ExpressApp.Blazor.Services;
5+
using DevExpress.ExpressApp.Design;
6+
using DevExpress.ExpressApp.Utils;
7+
8+
namespace ItemCountEF.Blazor.Server;
9+
10+
public class Program : IDesignTimeApplicationFactory {
11+
private static bool ContainsArgument(string[] args, string argument) {
12+
return args.Any(arg => arg.TrimStart('/').TrimStart('-').ToLower() == argument.ToLower());
13+
}
14+
public static int Main(string[] args) {
15+
if(ContainsArgument(args, "help") || ContainsArgument(args, "h")) {
16+
Console.WriteLine("Updates the database when its version does not match the application's version.");
17+
Console.WriteLine();
18+
Console.WriteLine($" {Assembly.GetExecutingAssembly().GetName().Name}.exe --updateDatabase [--forceUpdate --silent]");
19+
Console.WriteLine();
20+
Console.WriteLine("--forceUpdate - Marks that the database must be updated whether its version matches the application's version or not.");
21+
Console.WriteLine("--silent - Marks that database update proceeds automatically and does not require any interaction with the user.");
22+
Console.WriteLine();
23+
Console.WriteLine($"Exit codes: 0 - {DBUpdaterStatus.UpdateCompleted}");
24+
Console.WriteLine($" 1 - {DBUpdaterStatus.UpdateError}");
25+
Console.WriteLine($" 2 - {DBUpdaterStatus.UpdateNotNeeded}");
26+
}
27+
else {
28+
DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.Latest;
29+
IHost host = CreateHostBuilder(args).Build();
30+
if(ContainsArgument(args, "updateDatabase")) {
31+
using(var serviceScope = host.Services.CreateScope()) {
32+
return serviceScope.ServiceProvider.GetRequiredService<DevExpress.ExpressApp.Utils.IDBUpdater>().Update(ContainsArgument(args, "forceUpdate"), ContainsArgument(args, "silent"));
33+
}
34+
}
35+
else {
36+
host.Run();
37+
}
38+
}
39+
return 0;
40+
}
41+
public static IHostBuilder CreateHostBuilder(string[] args) =>
42+
Host.CreateDefaultBuilder(args)
43+
.ConfigureWebHostDefaults(webBuilder => {
44+
webBuilder.UseStartup<Startup>();
45+
});
46+
XafApplication IDesignTimeApplicationFactory.Create() {
47+
IHostBuilder hostBuilder = CreateHostBuilder(Array.Empty<string>());
48+
return DesignTimeApplicationFactoryHelper.Create(hostBuilder);
49+
}
50+
}

0 commit comments

Comments
 (0)