Skip to content

Commit

Permalink
update blazor
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliang-wt committed May 13, 2021
1 parent 9309a5f commit b2db607
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 96 deletions.
8 changes: 4 additions & 4 deletions WalkingTec.Mvvm.sln
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Demo.Test",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.Vue3Demo", "demo\WalkingTec.Mvvm.Vue3Demo\WalkingTec.Mvvm.Vue3Demo\WalkingTec.Mvvm.Vue3Demo.csproj", "{46309A77-6127-4ED9-95BE-C830B3E6FD0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingTec.Mvvm.BlazorDemo.Model", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.Model\WalkingTec.Mvvm.BlazorDemo.Model.csproj", "{341561A3-B563-4DFC-9EC5-702F85AAC174}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.BlazorDemo.Model", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.Model\WalkingTec.Mvvm.BlazorDemo.Model.csproj", "{341561A3-B563-4DFC-9EC5-702F85AAC174}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingTec.Mvvm.BlazorDemo.DataAccess", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.DataAccess\WalkingTec.Mvvm.BlazorDemo.DataAccess.csproj", "{94352C3E-899A-44A2-A052-578DC6A7159F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.BlazorDemo.DataAccess", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.DataAccess\WalkingTec.Mvvm.BlazorDemo.DataAccess.csproj", "{94352C3E-899A-44A2-A052-578DC6A7159F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingTec.Mvvm.BlazorDemo.ViewModel", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.ViewModel\WalkingTec.Mvvm.BlazorDemo.ViewModel.csproj", "{D4104589-85BE-446A-A123-1E0FD1538A7B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.BlazorDemo.ViewModel", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.ViewModel\WalkingTec.Mvvm.BlazorDemo.ViewModel.csproj", "{D4104589-85BE-446A-A123-1E0FD1538A7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WalkingTec.Mvvm.BlazorDemo.Test", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.Test\WalkingTec.Mvvm.BlazorDemo.Test.csproj", "{22C2CB15-1537-47D2-86BF-A7FFEE3A0677}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WalkingTec.Mvvm.BlazorDemo.Test", "demo\WalkingTec.Mvvm.BlazorDemo\WalkingTec.Mvvm.BlazorDemo.Test\WalkingTec.Mvvm.BlazorDemo.Test.csproj", "{22C2CB15-1537-47D2-86BF-A7FFEE3A0677}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
</Header>
<Side>
<div class="layout-banner">
<img class="layout-logo" src="/images/logo.png" style="width:30px;height:24px" />
<div class="layout-title">
<span><img src="/images/logo.png" width="30" height="24" /> WTM</span>
<span>WTM</span>
</div>
</div>
</Side>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="5.0.29" />
<PackageReference Include="BootstrapBlazor" Version="5.0.30-beta01" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ public void CreateTest()
StudentVM vm = _controller.Wtm.CreateVM<StudentVM>();
Student v = new Student();

v.ID = "OeeYQDD4r";
v.Password = "fAgazy5R";
v.Email = "eLXQUxW";
v.Name = "Wb1ibH";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v.CellPhone = "orJ";
v.Address = "jzFj";
v.ZipCode = "pI6X25dv";
v.ID = "P2eM9";
v.Password = "TyTX0V";
v.Email = "ersxm7";
v.Name = "Vs4";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v.CellPhone = "87ZU";
v.Address = "AJ5rL";
v.ZipCode = "iutU5Rga";
v.PhotoId = AddFileAttachment();
v.IsValid = true;
v.IsValid = false;
vm.Entity = v;
var rv = _controller.Add(vm);
Assert.IsInstanceOfType(rv, typeof(OkObjectResult));
Expand All @@ -56,15 +56,15 @@ public void CreateTest()
{
var data = context.Set<Student>().Find(v.ID);

Assert.AreEqual(data.ID, "OeeYQDD4r");
Assert.AreEqual(data.Password, "fAgazy5R");
Assert.AreEqual(data.Email, "eLXQUxW");
Assert.AreEqual(data.Name, "Wb1ibH");
Assert.AreEqual(data.Sex, WalkingTec.Mvvm.Core.GenderEnum.Female);
Assert.AreEqual(data.CellPhone, "orJ");
Assert.AreEqual(data.Address, "jzFj");
Assert.AreEqual(data.ZipCode, "pI6X25dv");
Assert.AreEqual(data.IsValid, true);
Assert.AreEqual(data.ID, "P2eM9");
Assert.AreEqual(data.Password, "TyTX0V");
Assert.AreEqual(data.Email, "ersxm7");
Assert.AreEqual(data.Name, "Vs4");
Assert.AreEqual(data.Sex, WalkingTec.Mvvm.Core.GenderEnum.Male);
Assert.AreEqual(data.CellPhone, "87ZU");
Assert.AreEqual(data.Address, "AJ5rL");
Assert.AreEqual(data.ZipCode, "iutU5Rga");
Assert.AreEqual(data.IsValid, false);
Assert.AreEqual(data.CreateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10);
}
Expand All @@ -77,16 +77,16 @@ public void EditTest()
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{

v.ID = "OeeYQDD4r";
v.Password = "fAgazy5R";
v.Email = "eLXQUxW";
v.Name = "Wb1ibH";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v.CellPhone = "orJ";
v.Address = "jzFj";
v.ZipCode = "pI6X25dv";
v.ID = "P2eM9";
v.Password = "TyTX0V";
v.Email = "ersxm7";
v.Name = "Vs4";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v.CellPhone = "87ZU";
v.Address = "AJ5rL";
v.ZipCode = "iutU5Rga";
v.PhotoId = AddFileAttachment();
v.IsValid = true;
v.IsValid = false;
context.Set<Student>().Add(v);
context.SaveChanges();
}
Expand All @@ -96,13 +96,13 @@ public void EditTest()
v = new Student();
v.ID = oldID;

v.Password = "M618xY";
v.Email = "4rsZnVM";
v.Name = "jpqDL";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v.CellPhone = "PDHo";
v.Address = "0t14";
v.ZipCode = "lFd";
v.Password = "tjs2nvvk";
v.Email = "Qw15cTS1";
v.Name = "R0p";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v.CellPhone = "atR";
v.Address = "EwS";
v.ZipCode = "2Rjk0aIR";
v.IsValid = false;
vm.Entity = v;
vm.FC = new Dictionary<string, object>();
Expand All @@ -124,13 +124,13 @@ public void EditTest()
{
var data = context.Set<Student>().Find(v.ID);

Assert.AreEqual(data.Password, "M618xY");
Assert.AreEqual(data.Email, "4rsZnVM");
Assert.AreEqual(data.Name, "jpqDL");
Assert.AreEqual(data.Sex, WalkingTec.Mvvm.Core.GenderEnum.Male);
Assert.AreEqual(data.CellPhone, "PDHo");
Assert.AreEqual(data.Address, "0t14");
Assert.AreEqual(data.ZipCode, "lFd");
Assert.AreEqual(data.Password, "tjs2nvvk");
Assert.AreEqual(data.Email, "Qw15cTS1");
Assert.AreEqual(data.Name, "R0p");
Assert.AreEqual(data.Sex, WalkingTec.Mvvm.Core.GenderEnum.Female);
Assert.AreEqual(data.CellPhone, "atR");
Assert.AreEqual(data.Address, "EwS");
Assert.AreEqual(data.ZipCode, "2Rjk0aIR");
Assert.AreEqual(data.IsValid, false);
Assert.AreEqual(data.UpdateBy, "user");
Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10);
Expand All @@ -145,16 +145,16 @@ public void GetTest()
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{

v.ID = "OeeYQDD4r";
v.Password = "fAgazy5R";
v.Email = "eLXQUxW";
v.Name = "Wb1ibH";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v.CellPhone = "orJ";
v.Address = "jzFj";
v.ZipCode = "pI6X25dv";
v.ID = "P2eM9";
v.Password = "TyTX0V";
v.Email = "ersxm7";
v.Name = "Vs4";
v.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v.CellPhone = "87ZU";
v.Address = "AJ5rL";
v.ZipCode = "iutU5Rga";
v.PhotoId = AddFileAttachment();
v.IsValid = true;
v.IsValid = false;
context.Set<Student>().Add(v);
context.SaveChanges();
}
Expand All @@ -170,24 +170,24 @@ public void BatchDeleteTest()
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{

v1.ID = "OeeYQDD4r";
v1.Password = "fAgazy5R";
v1.Email = "eLXQUxW";
v1.Name = "Wb1ibH";
v1.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v1.CellPhone = "orJ";
v1.Address = "jzFj";
v1.ZipCode = "pI6X25dv";
v1.ID = "P2eM9";
v1.Password = "TyTX0V";
v1.Email = "ersxm7";
v1.Name = "Vs4";
v1.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v1.CellPhone = "87ZU";
v1.Address = "AJ5rL";
v1.ZipCode = "iutU5Rga";
v1.PhotoId = AddFileAttachment();
v1.IsValid = true;
v2.ID = "DS5Hwe8i";
v2.Password = "M618xY";
v2.Email = "4rsZnVM";
v2.Name = "jpqDL";
v2.Sex = WalkingTec.Mvvm.Core.GenderEnum.Male;
v2.CellPhone = "PDHo";
v2.Address = "0t14";
v2.ZipCode = "lFd";
v1.IsValid = false;
v2.ID = "IAjRO";
v2.Password = "tjs2nvvk";
v2.Email = "Qw15cTS1";
v2.Name = "R0p";
v2.Sex = WalkingTec.Mvvm.Core.GenderEnum.Female;
v2.CellPhone = "atR";
v2.Address = "EwS";
v2.ZipCode = "2Rjk0aIR";
v2.PhotoId = v1.PhotoId;
v2.IsValid = false;
context.Set<Student>().Add(v1);
Expand Down Expand Up @@ -217,13 +217,13 @@ private Guid AddFileAttachment()
using (var context = new DataContext(_seed, DBTypeEnum.Memory))
{

v.FileName = "JHVR";
v.FileExt = "pKtzB";
v.Path = "OuiCgwi";
v.Length = 88;
v.SaveMode = "6aOrWth1";
v.ExtraInfo = "hn1GBF";
v.HandlerInfo = "A5wLih";
v.FileName = "YhtZfnWBt";
v.FileExt = "6vmrChVJy";
v.Path = "BJuyVm";
v.Length = 79;
v.SaveMode = "7FQ";
v.ExtraInfo = "xScWsm6";
v.HandlerInfo = "xTBqXEf8C";
context.Set<FileAttachment>().Add(v);
context.SaveChanges();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace WalkingTec.Mvvm.BlazorDemo.ViewModel.BasicData.StudentVMs
public partial class StudentVM : BaseCRUDVM<Student>
{
[Display(Name = "专业")]
public List<Guid> SelectedStudentMajorIDs { get; set; }
public List<string> SelectedStudentMajorIDs { get; set; }

public StudentVM()
{
Expand All @@ -22,7 +22,7 @@ public StudentVM()

protected override void InitVM()
{
SelectedStudentMajorIDs = Entity.StudentMajor?.Select(x => x.MajorId).ToList();
SelectedStudentMajorIDs = Entity.StudentMajor?.Select(x => x.MajorId.ToString()).ToList();
}

public override void DoAdd()
Expand All @@ -32,7 +32,9 @@ public override void DoAdd()
{
foreach (var id in SelectedStudentMajorIDs)
{
Entity.StudentMajor.Add(new StudentMajor { MajorId = id });
StudentMajor middle = new StudentMajor();
middle.SetPropertyValue("MajorId", id);
Entity.StudentMajor.Add(middle);
}
}

Expand All @@ -44,7 +46,12 @@ public override void DoEdit(bool updateAllFields = false)
Entity.StudentMajor = new List<StudentMajor>();
if(SelectedStudentMajorIDs != null )
{
SelectedStudentMajorIDs.ForEach(x => Entity.StudentMajor.Add(new StudentMajor { MajorId = x }));
foreach (var item in SelectedStudentMajorIDs)
{
StudentMajor middle = new StudentMajor();
middle.SetPropertyValue("MajorId", item);
Entity.StudentMajor.Add(middle);
}
}

base.DoEdit(updateAllFields);
Expand Down
18 changes: 11 additions & 7 deletions src/WalkingTec.Mvvm.Core/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,27 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
// 获取所有 DbSet<T> 的泛型类型 T
foreach (var asm in modelAsms)
{
var dcModule = asm.GetExportedTypes().Where(x => typeof(DbContext).IsAssignableFrom(x)).ToList();
if (dcModule != null && dcModule.Count > 0)
try
{
foreach (var module in dcModule)
var dcModule = asm.GetExportedTypes().Where(x => typeof(DbContext).IsAssignableFrom(x)).ToList();
if (dcModule != null && dcModule.Count > 0)
{
foreach (var pro in module.GetProperties())
foreach (var module in dcModule)
{
if (pro.PropertyType.IsGeneric(typeof(DbSet<>)))
foreach (var pro in module.GetProperties())
{
if (!allTypes.Contains(pro.PropertyType.GenericTypeArguments[0], new TypeComparer()))
if (pro.PropertyType.IsGeneric(typeof(DbSet<>)))
{
allTypes.Add(pro.PropertyType.GenericTypeArguments[0]);
if (!allTypes.Contains(pro.PropertyType.GenericTypeArguments[0], new TypeComparer()))
{
allTypes.Add(pro.PropertyType.GenericTypeArguments[0]);
}
}
}
}
}
}
catch { }
}

// 获取类型 T 下 List<S> 类型的属性对应的类型 S,且S 必须是 TopBasePoco 的子类,只有这些类会生成库
Expand Down
15 changes: 11 additions & 4 deletions src/WalkingTec.Mvvm.Mvc/CodeGenVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,24 +866,31 @@ protected override List<GridAction> InitGridAction()
var protype = modelType.GetSingleProperty(pro.FieldName);
prostr += $@"
[Display(Name = ""{protype.GetPropertyDisplayName()}"")]
public List<{pro.GetFKType(DC, modelType)}> Selected{pro.FieldName}IDs {{ get; set; }}";
public List<string> Selected{pro.FieldName}IDs {{ get; set; }}";
initstr += $@"
Selected{pro.FieldName}IDs = Entity.{pro.FieldName}?.Select(x => x.{pro.SubIdField}).ToList();";
Selected{pro.FieldName}IDs = Entity.{pro.FieldName}?.Select(x => x.{pro.SubIdField}.ToString()).ToList();";
addstr += $@"
Entity.{pro.FieldName} = new List<{protype.PropertyType.GetGenericArguments()[0].Name}>();
if (Selected{pro.FieldName}IDs != null)
{{
foreach (var id in Selected{pro.FieldName}IDs)
{{
Entity.{pro.FieldName}.Add(new {protype.PropertyType.GetGenericArguments()[0].Name} {{ {pro.SubIdField} = id }});
{protype.PropertyType.GetGenericArguments()[0].Name} middle = new {protype.PropertyType.GetGenericArguments()[0].Name}();
middle.SetPropertyValue(""{pro.SubIdField}"", id);
Entity.{pro.FieldName}.Add(middle);
}}
}}
";
editstr += $@"
Entity.{pro.FieldName} = new List<{protype.PropertyType.GetGenericArguments()[0].Name}>();
if(Selected{pro.FieldName}IDs != null )
{{
Selected{pro.FieldName}IDs.ForEach(x => Entity.{pro.FieldName}.Add(new {protype.PropertyType.GetGenericArguments()[0].Name} {{ {pro.SubIdField} = x }}));
foreach (var item in SelectedStudentMajorIDs)
{{
{protype.PropertyType.GetGenericArguments()[0].Name} middle = new {protype.PropertyType.GetGenericArguments()[0].Name}();
middle.SetPropertyValue(""{pro.SubIdField}"", item);
Entity.{pro.FieldName}.Add(middle);
}}
}}
";
}
Expand Down
1 change: 0 additions & 1 deletion src/WalkingTec.Mvvm.Mvc/framework_layui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ window.ff = {
triggerResize: function () {
setTimeout(function () {
{
debugger;
if (typeof (Event) === 'function') {
{
window.dispatchEvent(new Event('resize'));
Expand Down

0 comments on commit b2db607

Please sign in to comment.