更新wtm
This commit is contained in:
1 parent
f119665d29
commit
3467d4aa9d
60 files changed
+1932
-397
No files matched your search
@@ -284,25 +284,15 @@ namespace WalkingTec.Mvvm.Core
|
||||
vm = vmtype.GetConstructor(System.Type.EmptyTypes).Invoke(null) as IBaseCRUDVM<TModel>;
|
||||
vm.CopyContext(this);
|
||||
}
|
||||
var entityList = DC.Set<TModel>().CheckIDs(idsData).ToList();
|
||||
//循环所有数据
|
||||
for (int i = 0; i < entityList.Count; i++)
|
||||
for (int i = 0; i < idsData.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
//如果找不到对应数据,则输出错误
|
||||
TModel entity = entityList[i];
|
||||
if (vm != null)
|
||||
{
|
||||
vm.SetEntity(entity);
|
||||
}
|
||||
if (entity == null)
|
||||
{
|
||||
ErrorMessage.Add(idsData[i], CoreProgram._localizer?["Sys.DataNotExist"]);
|
||||
rv = false;
|
||||
break;
|
||||
}
|
||||
//如果能找到,则循环LinkedVM中的属性,给entity中同名属性赋值
|
||||
TModel entity = new TModel();
|
||||
entity.SetID(idsData[i]);
|
||||
//循环LinkedVM中的属性,给entity中同名属性赋值
|
||||
foreach (var pro in pros)
|
||||
{
|
||||
var proToSet = entity.GetType().GetSingleProperty(pro.Name);
|
||||
@@ -322,6 +312,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (hasvalue)
|
||||
{
|
||||
proToSet.SetValue(entity, valuetoset);
|
||||
DC.UpdateProperty(entity, proToSet.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,13 +352,14 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (ent.UpdateTime == null)
|
||||
{
|
||||
ent.UpdateTime = DateTime.Now;
|
||||
DC.UpdateProperty(entity, nameof(ent.UpdateTime));
|
||||
}
|
||||
if (string.IsNullOrEmpty(ent.UpdateBy))
|
||||
{
|
||||
ent.UpdateBy = LoginUserInfo?.ITCode;
|
||||
DC.UpdateProperty(entity, nameof(ent.UpdateBy));
|
||||
}
|
||||
}
|
||||
DC.UpdateEntity(entity);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -440,7 +440,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (pro.GetCustomAttribute<NotMappedAttribute>() != null)
|
||||
{
|
||||
fkname = pro.GetCustomAttribute<SoftFKAttribute>()?.PropertyName;
|
||||
softkey = typeof(TModel).GetCustomAttribute<SoftKeyAttribute>().PropertyName;
|
||||
softkey = typeof(TModel).GetCustomAttribute<SoftKeyAttribute>()?.PropertyName;
|
||||
}
|
||||
}
|
||||
var itemPros = ftype.GetAllProperties();
|
||||
@@ -1236,6 +1236,15 @@ namespace WalkingTec.Mvvm.Core
|
||||
Expression exp = f.GetExpression(Entity, para);
|
||||
conditions.Add(exp);
|
||||
}
|
||||
if (typeof(IPersistPoco).IsAssignableFrom(typeof(TModel)) && props.Any(x => x.Name.ToLower() == "isvalid") == false)
|
||||
{
|
||||
IPersistPoco ent = Entity as IPersistPoco;
|
||||
ent.IsValid = true;
|
||||
var f = new DuplicatedField<TModel>(x => (x as IPersistPoco).IsValid);
|
||||
Expression exp = f.GetExpression(Entity, para);
|
||||
conditions.Add(exp);
|
||||
}
|
||||
|
||||
//如果要求判断id不重复,则去掉id不相等的判断,加入id相等的判断
|
||||
//if (props.Any(x => x.Name.ToLower() == "id"))
|
||||
//{
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
{
|
||||
var fp = Wtm.ServiceProvider.GetRequiredService<WtmFileProvider>();
|
||||
// var tempdc = Wtm.DC;
|
||||
file = fp.GetFile(UploadFileId, true,Wtm.CreateDC(false,"default"));
|
||||
file = fp.GetFile(UploadFileId, true,Wtm.CreateDC(false));
|
||||
//Wtm.DC = tempdc;
|
||||
}
|
||||
if (file == null)
|
||||
@@ -908,7 +908,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
|
||||
foreach (var item in DeletedFileIds)
|
||||
{
|
||||
fp.DeleteFile(item.ToString(), Wtm.CreateDC(false, "default"));
|
||||
fp.DeleteFile(item.ToString(), Wtm.CreateDC(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1275,14 @@ namespace WalkingTec.Mvvm.Core
|
||||
//将字段名保存,为后面生成错误信息作准备
|
||||
props.AddRange(field.GetProperties());
|
||||
}
|
||||
|
||||
if (typeof(ITenant).IsAssignableFrom(modelType) && props.Any(x => x.Name.ToLower() == "tenantcode") == false && Wtm?.ConfigInfo.EnableTenant == true && group.UseTenant == true)
|
||||
{
|
||||
ITenant ent = Entity as ITenant;
|
||||
ent.TenantCode = LoginUserInfo.CurrentTenant;
|
||||
var f = new DuplicatedField<P>(x => (x as ITenant).TenantCode);
|
||||
Expression exp = f.GetExpression(Entity, para);
|
||||
conditions.Add(exp);
|
||||
}
|
||||
if (conditions.Count > 0)
|
||||
{
|
||||
//循环添加条件并生成Where语句
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
#endregion
|
||||
|
||||
#region 添加模版数据
|
||||
if (TemplateDataTable.Rows.Count > 0)
|
||||
if (TemplateDataTable?.Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < TemplateDataTable.Rows.Count; i++)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
@@ -33,10 +34,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
public DbSet<FunctionPrivilege> BaseFunctionPrivileges { get; set; }
|
||||
public DbSet<DataPrivilege> BaseDataPrivileges { get; set; }
|
||||
public DbSet<FileAttachment> BaseFileAttachments { get; set; }
|
||||
public DbSet<FrameworkGroup> BaseFrameworkGroups { get; set; }
|
||||
public DbSet<FrameworkRole> BaseFrameworkRoles { get; set; }
|
||||
public DbSet<FrameworkUserRole> BaseFrameworkUserRoles { get; set; }
|
||||
public DbSet<FrameworkUserGroup> BaseFrameworkUserGroups { get; set; }
|
||||
public DbSet<FrameworkGroup> BaseFrameworkGroups { get; set; }
|
||||
public DbSet<ActionLog> BaseActionLogs { get; set; }
|
||||
public DbSet<FrameworkTenant> FrameworkTenants { get; set; }
|
||||
|
||||
@@ -75,70 +76,8 @@ namespace WalkingTec.Mvvm.Core
|
||||
//wtmtodo: 删除菜单同步删除页面权限
|
||||
//modelBuilder.Entity<FunctionPrivilege>().HasOne(x => x.MenuItem).WithMany(x => x.Privileges).HasForeignKey(x => x.MenuItemId).OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
var modelAsms = Utils.GetAllAssembly();
|
||||
var allTypes = Utils.GetAllModels();
|
||||
|
||||
var allTypes = new List<Type>();// 所有 DbSet<> 的泛型类型
|
||||
|
||||
#region 获取所有 DbSet<T> 的泛型类型 T 及其 List<T> 类型属性对应的类型 T
|
||||
|
||||
// 获取所有 DbSet<T> 的泛型类型 T
|
||||
foreach (var asm in modelAsms)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dcModule = asm.GetExportedTypes().Where(x => typeof(DbContext).IsAssignableFrom(x)).ToList();
|
||||
if (dcModule != null && dcModule.Count > 0)
|
||||
{
|
||||
foreach (var module in dcModule)
|
||||
{
|
||||
foreach (var pro in module.GetProperties())
|
||||
{
|
||||
if (pro.PropertyType.IsGeneric(typeof(DbSet<>)))
|
||||
{
|
||||
if (!allTypes.Contains(pro.PropertyType.GenericTypeArguments[0], new TypeComparer()))
|
||||
{
|
||||
allTypes.Add(pro.PropertyType.GenericTypeArguments[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// 获取类型 T 下 List<S> 类型的属性对应的类型 S,且S 必须是 TopBasePoco 的子类,只有这些类会生成库
|
||||
for (int i = 0; i < allTypes.Count; i++) //
|
||||
{
|
||||
var item = allTypes[i];
|
||||
var pros = item.GetProperties();
|
||||
foreach (var pro in pros)
|
||||
{
|
||||
if (typeof(TopBasePoco).IsAssignableFrom(pro.PropertyType))
|
||||
{
|
||||
if (allTypes.Contains(pro.PropertyType) == false)
|
||||
{
|
||||
allTypes.Add(pro.PropertyType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pro.PropertyType.IsGenericType && pro.PropertyType.GetGenericTypeDefinition() == typeof(List<>))
|
||||
{
|
||||
var inner = pro.PropertyType.GetGenericArguments()[0];
|
||||
if (typeof(TopBasePoco).IsAssignableFrom(inner))
|
||||
{
|
||||
if (allTypes.Contains(inner) == false)
|
||||
{
|
||||
allTypes.Add(inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
foreach (var item in allTypes)
|
||||
{
|
||||
if (typeof(TopBasePoco).IsAssignableFrom(item) && typeof(ISubFile).IsAssignableFrom(item) == false)
|
||||
@@ -153,25 +92,28 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
List<Expression> list = new List<Expression>();
|
||||
ParameterExpression pe = Expression.Parameter(item);
|
||||
if (typeof(IPersistPoco).IsAssignableFrom(item))
|
||||
if (item.BaseType == null || item.BaseType.IsAbstract == true || (item.BaseType == typeof(TopBasePoco) || item.BaseType == typeof(BasePoco) || item.BaseType?.BaseType == typeof(TreePoco)))
|
||||
{
|
||||
var exp = Expression.Equal(Expression.Property(pe, "IsValid"), Expression.Constant(true));
|
||||
list.Add(exp);
|
||||
}
|
||||
if (typeof(ITenant).IsAssignableFrom(item))
|
||||
{
|
||||
var exp= Expression.Equal(Expression.Property(pe, "TenantCode"), Expression.PropertyOrField(Expression.Constant(this),"TenantCode"));
|
||||
list.Add(exp);
|
||||
}
|
||||
if(list.Count > 0)
|
||||
{
|
||||
var finalexp = list[0];
|
||||
for (int i = 1; i < list.Count; i++)
|
||||
if (typeof(IPersistPoco).IsAssignableFrom(item))
|
||||
{
|
||||
finalexp = Expression.AndAlso(finalexp, list[i]);
|
||||
var exp = Expression.Equal(Expression.Property(pe, "IsValid"), Expression.Constant(true));
|
||||
list.Add(exp);
|
||||
}
|
||||
if (typeof(ITenant).IsAssignableFrom(item))
|
||||
{
|
||||
var exp = Expression.Equal(Expression.Property(pe, "TenantCode"), Expression.PropertyOrField(Expression.Constant(this), "TenantCode"));
|
||||
list.Add(exp);
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
var finalexp = list[0];
|
||||
for (int i = 1; i < list.Count; i++)
|
||||
{
|
||||
finalexp = Expression.AndAlso(finalexp, list[i]);
|
||||
}
|
||||
var builder = typeof(ModelBuilder).GetMethod("Entity", Type.EmptyTypes).MakeGenericMethod(item).Invoke(modelBuilder, null) as EntityTypeBuilder;
|
||||
builder.HasQueryFilter(Expression.Lambda(finalexp, pe));
|
||||
}
|
||||
var builder = typeof(ModelBuilder).GetMethod("Entity", Type.EmptyTypes).MakeGenericMethod(item).Invoke(modelBuilder, null) as EntityTypeBuilder;
|
||||
builder.HasQueryFilter(Expression.Lambda(finalexp,pe));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,12 +149,12 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (Set<FrameworkMenu>().Any() == false && TenantCode == null)
|
||||
{
|
||||
var systemManagement = GetFolderMenu("SystemManagement");
|
||||
var logList = IsSpa ? GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1) : GetMenu(AllModules, "_Admin", "ActionLog", "Index", "MenuKey.ActionLog", 1);
|
||||
var userList = IsSpa ? GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2) : GetMenu(AllModules, "_Admin", "FrameworkUser", "Index", "MenuKey.UserManagement", 2);
|
||||
var roleList = IsSpa ? GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3) : GetMenu(AllModules, "_Admin", "FrameworkRole", "Index", "MenuKey.RoleManagement", 3);
|
||||
var groupList = IsSpa ? GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4) : GetMenu(AllModules, "_Admin", "FrameworkGroup", "Index", "MenuKey.GroupManagement", 4);
|
||||
var menuList = IsSpa ? GetMenu2(AllModules, "FrameworkMenu", "MenuKey.MenuMangement", 5) : GetMenu(AllModules, "_Admin", "FrameworkMenu", "Index", "MenuKey.MenuMangement", 5);
|
||||
var dpList = IsSpa ? GetMenu2(AllModules, "DataPrivilege", "MenuKey.DataPrivilege", 6) : GetMenu(AllModules, "_Admin", "DataPrivilege", "Index", "MenuKey.DataPrivilege", 6);
|
||||
var logList = IsSpa ? GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1) : GetMenu(AllModules, "_Admin", "ActionLog", "Index", "MenuKey.ActionLog", 1);
|
||||
var userList = IsSpa ? GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2) : GetMenu(AllModules, "_Admin", "FrameworkUser", "Index", "MenuKey.UserManagement", 2);
|
||||
var roleList = IsSpa ? GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3) : GetMenu(AllModules, "_Admin", "FrameworkRole", "Index", "MenuKey.RoleManagement", 3);
|
||||
var groupList = IsSpa ? GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4) : GetMenu(AllModules, "_Admin", "FrameworkGroup", "Index", "MenuKey.GroupManagement", 4);
|
||||
var menuList = IsSpa ? GetMenu2(AllModules, "FrameworkMenu", "MenuKey.MenuMangement", 5) : GetMenu(AllModules, "_Admin", "FrameworkMenu", "Index", "MenuKey.MenuMangement", 5);
|
||||
var dpList = IsSpa ? GetMenu2(AllModules, "DataPrivilege", "MenuKey.DataPrivilege", 6) : GetMenu(AllModules, "_Admin", "DataPrivilege", "Index", "MenuKey.DataPrivilege", 6);
|
||||
var tenantList = IsSpa ? GetMenu2(AllModules, "FrameworkTenant", "MenuKey.FrameworkTenant", 6) : GetMenu(AllModules, "_Admin", "FrameworkTenant", "Index", "MenuKey.FrameworkTenant", 7);
|
||||
if (logList != null)
|
||||
{
|
||||
@@ -241,10 +183,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
var apifolder = GetFolderMenu("Api");
|
||||
apifolder.ShowOnMenu = false;
|
||||
apifolder.DisplayOrder = 100;
|
||||
var logList2 = GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1);
|
||||
var userList2 = GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2);
|
||||
var roleList2 = GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3);
|
||||
var groupList2 = GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4);
|
||||
var logList2 = GetMenu2(AllModules, "ActionLog", "MenuKey.ActionLog", 1);
|
||||
var userList2 = GetMenu2(AllModules, "FrameworkUser", "MenuKey.UserManagement", 2);
|
||||
var roleList2 = GetMenu2(AllModules, "FrameworkRole", "MenuKey.RoleManagement", 3);
|
||||
var groupList2 = GetMenu2(AllModules, "FrameworkGroup", "MenuKey.GroupManagement", 4);
|
||||
var menuList2 = GetMenu2(AllModules, "FrameworkMenu", "MenuKey.MenuMangement", 5);
|
||||
var dpList2 = GetMenu2(AllModules, "DataPrivilege", "MenuKey.DataPrivilege", 6);
|
||||
var tenantList2 = GetMenu2(AllModules, "FrameworkTenant", "MenuKey.FrameworkTenant", 7);
|
||||
@@ -255,6 +197,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (item != null)
|
||||
{
|
||||
item.ModuleName += "Api";
|
||||
item.ShowOnMenu = false;
|
||||
apifolder.Children.Add(item);
|
||||
|
||||
}
|
||||
@@ -276,14 +219,13 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
}
|
||||
Set<FrameworkRole>().AddRange(roles);
|
||||
|
||||
await SaveChangesAsync();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
private FrameworkMenu GetFolderMenu(string FolderText,bool isShowOnMenu = true, bool isInherite = false)
|
||||
private FrameworkMenu GetFolderMenu(string FolderText, bool isShowOnMenu = true, bool isInherite = false)
|
||||
{
|
||||
FrameworkMenu menu = new FrameworkMenu
|
||||
{
|
||||
@@ -299,14 +241,14 @@ namespace WalkingTec.Mvvm.Core
|
||||
return menu;
|
||||
}
|
||||
|
||||
private FrameworkMenu GetMenu(List<SimpleModule> allModules, string areaName, string controllerName, string actionName, string pageKey,int displayOrder)
|
||||
private FrameworkMenu GetMenu(List<SimpleModule> allModules, string areaName, string controllerName, string actionName, string pageKey, int displayOrder)
|
||||
{
|
||||
var acts = allModules.Where(x => x.ClassName == controllerName && (areaName == null || x.Area?.Prefix?.ToLower() == areaName.ToLower())).SelectMany(x => x.Actions).ToList();
|
||||
var act = acts.Where(x => x.MethodName == actionName).SingleOrDefault();
|
||||
var rest = acts.Where(x => x.MethodName != actionName && x.IgnorePrivillege == false).ToList();
|
||||
bool allowtenant = controllerName != "FrameworkMenu";
|
||||
FrameworkMenu menu = GetMenuFromAction(act, true, displayOrder, allowtenant);
|
||||
if(act?.Module?.IsApi == true)
|
||||
if (act?.Module?.IsApi == true)
|
||||
{
|
||||
menu.ModuleName += "Api";
|
||||
}
|
||||
@@ -333,7 +275,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
private FrameworkMenu GetMenu2(List<SimpleModule> allModules, string controllerName, string pageKey, int displayOrder)
|
||||
{
|
||||
bool allowtenant = controllerName != "FrameworkMenu";
|
||||
var acts = allModules.Where(x => (x.FullName == $"WalkingTec.Mvvm.Admin.Api,{controllerName}")&& x.IsApi == true).SelectMany(x => x.Actions).ToList();
|
||||
var acts = allModules.Where(x => (x.FullName == $"WalkingTec.Mvvm.Admin.Api,{controllerName}") && x.IsApi == true).SelectMany(x => x.Actions).ToList();
|
||||
var rest = acts.Where(x => x.IgnorePrivillege == false).ToList();
|
||||
SimpleAction act = null;
|
||||
if (acts.Count > 0)
|
||||
@@ -352,7 +294,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
{
|
||||
if (rest[i] != null)
|
||||
{
|
||||
var sub = GetMenuFromAction(rest[i], false, (i + 1), allowtenant);
|
||||
var sub = GetMenuFromAction(rest[i], false, (i + 1), allowtenant);
|
||||
sub.PageName = pageKey;
|
||||
menu.Children.Add(sub);
|
||||
}
|
||||
@@ -361,7 +303,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
return menu;
|
||||
}
|
||||
|
||||
private FrameworkMenu GetMenuFromAction(SimpleAction act, bool isMainLink, int displayOrder = 1, bool allowtenant = true)
|
||||
private FrameworkMenu GetMenuFromAction(SimpleAction act, bool isMainLink, int displayOrder = 1, bool allowtenant = true)
|
||||
{
|
||||
if (act == null)
|
||||
{
|
||||
@@ -485,14 +427,17 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
IDataContext rv = null;
|
||||
if (ConnectionString != null)
|
||||
{
|
||||
return (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(CS) }).Invoke(new object[] { ConnectionString }); ;
|
||||
rv = (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(CS) }).Invoke(new object[] { ConnectionString }); ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (IDataContext)this.GetType().GetConstructor(new Type[] { typeof(string), typeof(DBTypeEnum) }).Invoke(new object[] { CSName, DBType });
|
||||
rv =(IDataContext)this.GetType().GetConstructor(new Type[] { typeof(string), typeof(DBTypeEnum) }).Invoke(new object[] { CSName, DBType });
|
||||
}
|
||||
rv.SetTenantCode(this.TenantCode);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -665,8 +610,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
case DBTypeEnum.SQLite:
|
||||
optionsBuilder.UseSqlite(CSName);
|
||||
break;
|
||||
//case DBTypeEnum.DaMeng:
|
||||
// optionsBuilder.UseDm(CSName);
|
||||
// break;
|
||||
case DBTypeEnum.Oracle:
|
||||
|
||||
optionsBuilder.UseOracle(CSName, option =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(Version) == false)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public enum DBTypeEnum { SqlServer, MySql, PgSql, Memory, SQLite, Oracle }
|
||||
public enum DBTypeEnum { SqlServer, MySql, PgSql, Memory, SQLite, Oracle,DaMeng }
|
||||
|
||||
/// <summary>
|
||||
/// 页面显示方式
|
||||
@@ -131,7 +131,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
|
||||
public enum UIEnum
|
||||
{ LayUI, React, VUE,Blazor }
|
||||
{ LayUI, React, VUE,Blazor,VUE3 }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -285,17 +285,17 @@ namespace WalkingTec.Mvvm.Core.Extensions
|
||||
switch (col.EditType)
|
||||
{
|
||||
case EditTypeEnum.TextBox:
|
||||
html = (self as BaseVM).UIService.MakeTextBox(name, val);
|
||||
html = (self as BaseVM).UIService.MakeTextBox(name, val,null,col.IsReadOnly);
|
||||
break;
|
||||
case EditTypeEnum.CheckBox:
|
||||
_ = bool.TryParse(val, out bool nb);
|
||||
html = (self as BaseVM).UIService.MakeCheckBox(nb, null, name, "true");
|
||||
html = (self as BaseVM).UIService.MakeCheckBox(nb, null, name, "true",col.IsReadOnly);
|
||||
break;
|
||||
case EditTypeEnum.ComboBox:
|
||||
html = (self as BaseVM).UIService.MakeCombo(name, col.ListItems, val);
|
||||
html = (self as BaseVM).UIService.MakeCombo(name, col.ListItems, val,null,col.IsReadOnly);
|
||||
break;
|
||||
case EditTypeEnum.Datetime:
|
||||
html = (self as BaseVM).UIService.MakeDateTime(name, val);
|
||||
html = (self as BaseVM).UIService.MakeDateTime(name, val,null, col.IsReadOnly,col.DateType);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WalkingTec.Mvvm.Core.Extensions
|
||||
{
|
||||
public static class DictionaryExtension
|
||||
{
|
||||
public static T GetValue<T>(this Dictionary<string,object> self, string key)
|
||||
{
|
||||
if (self.ContainsKey(key))
|
||||
{
|
||||
object v = self[key];
|
||||
if(v is JsonElement j)
|
||||
{
|
||||
v = j.ToString();
|
||||
}
|
||||
var cv = v.ConvertValue(typeof(T));
|
||||
if (cv == null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (T)cv;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -488,7 +488,11 @@ namespace WalkingTec.Mvvm.Core.Extensions
|
||||
if (_propertyCache.ContainsKey(self.FullName) == false)
|
||||
{
|
||||
var properties = self.GetProperties().ToList();
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
try
|
||||
{
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
}
|
||||
catch { }
|
||||
return properties.Where(x => x.Name == name).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
@@ -502,7 +506,11 @@ namespace WalkingTec.Mvvm.Core.Extensions
|
||||
if (_propertyCache.ContainsKey(self.FullName) == false)
|
||||
{
|
||||
var properties = self.GetProperties().ToList();
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
try
|
||||
{
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
}
|
||||
catch { }
|
||||
return properties.Where(where).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
@@ -516,7 +524,17 @@ namespace WalkingTec.Mvvm.Core.Extensions
|
||||
if (_propertyCache.ContainsKey(self.FullName) == false)
|
||||
{
|
||||
var properties = self.GetProperties().ToList();
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
try
|
||||
{
|
||||
_propertyCache = _propertyCache.Add(self.FullName, properties);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_propertyCache.ContainsKey(self.FullName) == true)
|
||||
{
|
||||
return _propertyCache[self.FullName];
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
using WalkingTec.Mvvm.Core.Support.Json;
|
||||
|
||||
namespace WalkingTec.Mvvm.Core
|
||||
@@ -34,7 +35,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
_customUserProperties = new List<PropertyInfo>();
|
||||
if(CustomUserType != null)
|
||||
{
|
||||
_customUserProperties = CustomUserType.GetProperties( BindingFlags.Public| BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList();
|
||||
_customUserProperties = CustomUserType.GetProperties( BindingFlags.Public| BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(x=>x.PropertyType.IsListOf<TopBasePoco>() == false && typeof(TopBasePoco).IsAssignableFrom(x.PropertyType) == false).ToList();
|
||||
}
|
||||
}
|
||||
return _customUserProperties;
|
||||
@@ -57,6 +58,13 @@ namespace WalkingTec.Mvvm.Core
|
||||
public void SetMenuGetFunc(Func<List<SimpleMenu>> func) => MenuGetFunc = func;
|
||||
public void SetTenantGetFunc(Func<List<FrameworkTenant>> func) => TenantGetFunc = func;
|
||||
|
||||
public List<Type> GetPocoTypesAssignableFrom<T>()
|
||||
{
|
||||
var rv = new List<Type>();
|
||||
var allType = Utils.GetAllModels();
|
||||
rv.AddRange(allType.Where(x => typeof(T).IsAssignableFrom(x) && x != typeof(T) && x.IsAbstract == false).ToList());
|
||||
return rv;
|
||||
}
|
||||
public List<Type> GetTypesAssignableFrom<T>()
|
||||
{
|
||||
var rv = new List<Type>();
|
||||
|
||||
@@ -141,6 +141,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
|
||||
public List<ComboSelectListItem> ListItems { get; set; }
|
||||
|
||||
public DateTimeTypeEnum? DateType { get; set; }
|
||||
|
||||
public bool IsReadOnly { get; set; }
|
||||
|
||||
#region 只读属性 生成 Excel 及其 表头用
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -296,12 +296,16 @@ namespace WalkingTec.Mvvm.Core
|
||||
/// <param name="self"></param>
|
||||
/// <param name="editType">单元格编辑类型</param>
|
||||
/// <param name="listitems">listitems</param>
|
||||
/// <param name="dateType"></param>
|
||||
/// <param name="readOnly"></param>
|
||||
/// <returns></returns>
|
||||
public static GridColumn<T> SetEditType<T>(this GridColumn<T> self, EditTypeEnum editType = EditTypeEnum.Text, List<ComboSelectListItem> listitems = null)
|
||||
public static GridColumn<T> SetEditType<T>(this GridColumn<T> self, EditTypeEnum editType = EditTypeEnum.Text, List<ComboSelectListItem> listitems = null, DateTimeTypeEnum dateType = DateTimeTypeEnum.DateTime, bool readOnly = false)
|
||||
where T : TopBasePoco
|
||||
{
|
||||
self.EditType = editType;
|
||||
self.ListItems = listitems;
|
||||
self.DateType = dateType;
|
||||
self.IsReadOnly = readOnly;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
|
||||
List<ComboSelectListItem> ListItems { get; set; }
|
||||
|
||||
DateTimeTypeEnum? DateType { get; set; }
|
||||
|
||||
bool IsReadOnly { get; set; }
|
||||
|
||||
#region 只读属性 生成 Excel 及其 表头用
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -747,6 +747,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
if (propertyType.IsGeneric(typeof(Nullable<>)) == true)
|
||||
{
|
||||
var gs = propertyType.GenericTypeArguments;
|
||||
if(value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
val = ConvertValue(value, gs[0]);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
string MakeCombo(string name = null, List<ComboSelectListItem> value = null, string selectedValue = null, string emptyText = null, bool isReadOnly = false);
|
||||
|
||||
string MakeTextBox(string name = null, string value = null, string emptyText = null, bool isReadOnly = false);
|
||||
string MakeDateTime(string name = null, string value = null, string emptyText = null, bool isReadOnly = false);
|
||||
string MakeDateTime(string name = null, string value = null, string emptyText = null, bool isReadOnly = false, DateTimeTypeEnum? dateType = DateTimeTypeEnum.DateTime);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace WalkingTec.Mvvm.Core.Implement
|
||||
return "";
|
||||
}
|
||||
|
||||
public string MakeDateTime(string name = null, string value = null, string emptyText = null, bool isReadOnly = false)
|
||||
public string MakeDateTime(string name = null, string value = null, string emptyText = null, bool isReadOnly = false, DateTimeTypeEnum? dateType = DateTimeTypeEnum.DateTime)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WalkingTec.Mvvm.Core.Json
|
||||
{
|
||||
|
||||
public class NullableConverter<T> : JsonConverter<Nullable<T>> where T : struct
|
||||
{
|
||||
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
if (string.IsNullOrEmpty(reader.GetString()) || string.IsNullOrWhiteSpace(reader.GetString()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||||
}
|
||||
}
|
||||
return JsonSerializer.Deserialize<T>(ref reader, options);
|
||||
}
|
||||
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T? value, JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, value!.Value, options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text.Unicode;
|
||||
using System.Threading.Tasks;
|
||||
using WalkingTec.Mvvm.Core.Extensions;
|
||||
|
||||
namespace WalkingTec.Mvvm.Core.Json
|
||||
{
|
||||
public class NullableEnumConverter : JsonConverterFactory
|
||||
{
|
||||
|
||||
public override bool CanConvert(Type typeToConvert)
|
||||
{
|
||||
return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Nullable<>) && typeToConvert.GetGenericArguments()[0].IsEnum;
|
||||
}
|
||||
|
||||
public override JsonConverter CreateConverter(
|
||||
Type type,
|
||||
JsonSerializerOptions options)
|
||||
{
|
||||
|
||||
var temp = CloneOptions(options);
|
||||
foreach (var item in options.Converters)
|
||||
{
|
||||
if(item.GetType() != typeof(PocoConverter) && item.GetType() != typeof(NullableEnumConverter))
|
||||
{
|
||||
temp.Converters.Add(item);
|
||||
}
|
||||
}
|
||||
JsonConverter converter = (JsonConverter)Activator.CreateInstance(
|
||||
typeof(NullableEnumConverterInner<>).MakeGenericType(
|
||||
new Type[] { type }),
|
||||
BindingFlags.Instance | BindingFlags.Public,
|
||||
binder: null,
|
||||
args: new object[] { temp },
|
||||
culture: null);
|
||||
|
||||
return converter;
|
||||
}
|
||||
|
||||
private JsonSerializerOptions CloneOptions(JsonSerializerOptions op)
|
||||
{
|
||||
JsonSerializerOptions rv = new JsonSerializerOptions();
|
||||
rv.PropertyNamingPolicy = op.PropertyNamingPolicy;
|
||||
rv.AllowTrailingCommas = op.AllowTrailingCommas;
|
||||
rv.DefaultBufferSize = op.DefaultBufferSize;
|
||||
rv.DefaultIgnoreCondition = op.DefaultIgnoreCondition;
|
||||
rv.DictionaryKeyPolicy = op.DictionaryKeyPolicy;
|
||||
rv.Encoder = op.Encoder;
|
||||
rv.IgnoreNullValues = op.IgnoreNullValues;
|
||||
rv.IgnoreReadOnlyFields = op.IgnoreReadOnlyFields;
|
||||
rv.IgnoreReadOnlyProperties = op.IgnoreReadOnlyProperties;
|
||||
rv.IncludeFields = op.IncludeFields;
|
||||
rv.DefaultIgnoreCondition = op.DefaultIgnoreCondition;
|
||||
rv.DictionaryKeyPolicy = op.DictionaryKeyPolicy;
|
||||
rv.MaxDepth = op.MaxDepth;
|
||||
rv.NumberHandling = op.NumberHandling;
|
||||
rv.ReadCommentHandling = op.ReadCommentHandling;
|
||||
rv.ReferenceHandler = op.ReferenceHandler;
|
||||
rv.WriteIndented = op.WriteIndented;
|
||||
return rv;
|
||||
}
|
||||
|
||||
private class NullableEnumConverterInner<T> :
|
||||
JsonConverter<T>
|
||||
{
|
||||
protected readonly JsonSerializerOptions _options;
|
||||
public NullableEnumConverterInner(JsonSerializerOptions options)
|
||||
{
|
||||
_options = options;
|
||||
}
|
||||
|
||||
public override T Read(
|
||||
ref Utf8JsonReader reader,
|
||||
Type typeToConvert,
|
||||
JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
if (string.IsNullOrEmpty(reader.GetString()) || string.IsNullOrWhiteSpace(reader.GetString()))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
return JsonSerializer.Deserialize<T>(ref reader, _options);
|
||||
}
|
||||
|
||||
public override void Write(
|
||||
Utf8JsonWriter writer,
|
||||
T data,
|
||||
JsonSerializerOptions options)
|
||||
{
|
||||
JsonSerializer.Serialize(writer, data, typeof(T), _options);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -215,10 +215,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
}
|
||||
var topdata = context.GlobaInfo.AllMenus.Where(x => x.ShowOnMenu && (x.IsInside == false || x.FolderOnly == true || string.IsNullOrEmpty(x.MethodName))).ToList();
|
||||
var allowedids = context.LoginUserInfo.FunctionPrivileges.Select(x => x.MenuItemId).ToList();
|
||||
var allowedids = context.LoginUserInfo?.FunctionPrivileges?.Select(x => x.MenuItemId).ToList();
|
||||
foreach (var item in topdata)
|
||||
{
|
||||
if (allowedids.Contains(item.ID) && item.IsParentShowOnMenu(topdata))
|
||||
if (allowedids?.Contains(item.ID) == true && item.IsParentShowOnMenu(topdata))
|
||||
{
|
||||
ms.Add(new SimpleMenuApi
|
||||
{
|
||||
@@ -269,13 +269,13 @@ namespace WalkingTec.Mvvm.Core
|
||||
|
||||
public IDataContext GetUserDC(WTMContext context)
|
||||
{
|
||||
if (context?.LoginUserInfo?.TenantCode == null)
|
||||
if (context?.LoginUserInfo?.CurrentTenant == null)
|
||||
{
|
||||
return context.CreateDC(cskey: "default");
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = context.GlobaInfo.AllTenant.Where(x => x.TCode == context?.LoginUserInfo?.TenantCode).FirstOrDefault();
|
||||
var item = context.GlobaInfo.AllTenant.Where(x => x.TCode == context?.LoginUserInfo?.CurrentTenant).FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
return item.CreateDC(context);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
/// <summary>
|
||||
/// Model层的基类,所有的model都应该继承这个类。这会使所有的model层对应的数据库表都有一个自增主键
|
||||
/// </summary>
|
||||
public class BasePoco : TopBasePoco, IBasePoco
|
||||
public abstract class BasePoco : TopBasePoco, IBasePoco
|
||||
{
|
||||
/// <summary>
|
||||
/// CreateTime
|
||||
|
||||
@@ -67,6 +67,10 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<string, object> Attributes { get; set; }
|
||||
|
||||
|
||||
public IDataContext CreateDC(WTMContext wtm)
|
||||
{
|
||||
if (IsUsingDB == false)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
/// <summary>
|
||||
/// TopBasePoco
|
||||
/// </summary>
|
||||
public class TopBasePoco
|
||||
public class TopBasePoco
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WalkingTec.Mvvm.Core
|
||||
{
|
||||
public abstract class TreePoco : TopBasePoco
|
||||
public class TreePoco : TopBasePoco
|
||||
{
|
||||
[Display(Name = "_Admin.Parent")]
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override Stream GetFileData(IWtmFile file)
|
||||
{
|
||||
var rv = _wtm.DC.Set<FileAttachment>().CheckID(file.GetID()).FirstOrDefault();
|
||||
var rv = wtm.DC.Set<FileAttachment>().CheckID(file.GetID()).FirstOrDefault();
|
||||
if (rv != null)
|
||||
{
|
||||
return new MemoryStream((rv as FileAttachment).FileData);
|
||||
@@ -37,7 +37,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
file.UploadTime = DateTime.Now;
|
||||
file.SaveMode = _modeName;
|
||||
file.ExtraInfo = extra;
|
||||
file.TenantCode = _wtm.LoginUserInfo?.CurrentTenant;
|
||||
file.TenantCode = wtm.LoginUserInfo?.CurrentTenant;
|
||||
var ext = string.Empty;
|
||||
if (string.IsNullOrEmpty(fileName) == false)
|
||||
{
|
||||
@@ -50,8 +50,8 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
data.CopyTo(dataStream);
|
||||
file.FileData = dataStream.ToArray();
|
||||
}
|
||||
_wtm.DC.AddEntity(file);
|
||||
_wtm.DC.SaveChanges();
|
||||
wtm.DC.AddEntity(file);
|
||||
wtm.DC.SaveChanges();
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
{
|
||||
public abstract class WtmFileHandlerBase : IWtmFileHandler
|
||||
{
|
||||
protected WTMContext _wtm;
|
||||
public WTMContext wtm;
|
||||
public WtmFileHandlerBase(WTMContext wtm)
|
||||
{
|
||||
_wtm = wtm;
|
||||
this.wtm = wtm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
public IWtmFileHandler CreateFileHandler(string saveMode = null, IDataContext dc = null)
|
||||
{
|
||||
ConstructorInfo ci = null;
|
||||
//if(dc != null)
|
||||
//{
|
||||
// _wtm.DC = dc;
|
||||
//}
|
||||
if (dc != null)
|
||||
{
|
||||
_wtm.DC = dc;
|
||||
}
|
||||
if (string.IsNullOrEmpty(saveMode))
|
||||
{
|
||||
ci = _defaultHandler;
|
||||
@@ -154,8 +154,14 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
}).FirstOrDefault();
|
||||
if (rv != null && withData == true)
|
||||
{
|
||||
var fh = CreateFileHandler(rv.SaveMode, dc);
|
||||
rv.DataStream = fh.GetFileData(rv);
|
||||
try
|
||||
{
|
||||
var fh = CreateFileHandler(rv.SaveMode, dc);
|
||||
rv.DataStream = fh.GetFileData(rv);
|
||||
}
|
||||
catch {
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override (string path, string handlerInfo) Upload(string fileName, long fileLength, Stream data, string group = null, string subdir = null, string extra = null)
|
||||
{
|
||||
var localSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "local").Select(x => x.Value).FirstOrDefault();
|
||||
var localSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "local").Select(x => x.Value).FirstOrDefault();
|
||||
|
||||
var groupdir = "";
|
||||
if (string.IsNullOrEmpty(group))
|
||||
@@ -91,7 +91,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
string rv = "";
|
||||
if (path.StartsWith("."))
|
||||
{
|
||||
rv = Path.Combine(_wtm.ConfigInfo.HostRoot, path);
|
||||
rv = Path.Combine(wtm.ConfigInfo.HostRoot, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override Stream GetFileData(IWtmFile file)
|
||||
{
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(file.HandlerInfo))
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
ext = fileName.Substring(dotPos + 1);
|
||||
}
|
||||
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(group))
|
||||
{
|
||||
@@ -95,8 +95,15 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
}
|
||||
var fullPath = Path.Combine(pathHeader, $"{Guid.NewGuid().ToNoSplitString()}.{ext}");
|
||||
fullPath = fullPath.Replace("\\", "/");
|
||||
var imagetypes = new string[]{ "jpg","jpeg","bmp","tif","gif","png"};
|
||||
ObjectMetadata md = new ObjectMetadata();
|
||||
ext = ext.ToLower();
|
||||
if (imagetypes.Contains(ext))
|
||||
{
|
||||
md.ContentType = "image/jpg";
|
||||
}
|
||||
OssClient client = new OssClient(groupInfo.ServerUrl, groupInfo.Key, groupInfo.Secret);
|
||||
var result = client.PutObject(groupInfo.GroupLocation, fullPath, data);
|
||||
var result = client.PutObject(groupInfo.GroupLocation, fullPath, data,md);
|
||||
if (result.HttpStatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
return (fullPath, groupInfo.GroupName);
|
||||
@@ -109,7 +116,7 @@ namespace WalkingTec.Mvvm.Core.Support.FileHandlers
|
||||
|
||||
public override void DeleteFile(IWtmFile file)
|
||||
{
|
||||
var ossSettings = _wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
var ossSettings = wtm.ConfigInfo.FileUploadOptions.Settings.Where(x => x.Key.ToLower() == "oss").Select(x => x.Value).FirstOrDefault();
|
||||
FileHandlerOptions groupInfo = null;
|
||||
if (string.IsNullOrEmpty(file.HandlerInfo))
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
}
|
||||
|
||||
[ProviderAlias("WTM")]
|
||||
public class WTMLoggerProvider : ILoggerProvider
|
||||
{
|
||||
private IServiceProvider sp = null;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using NPOI.HSSF.Util;
|
||||
using System;
|
||||
@@ -21,7 +22,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
{
|
||||
|
||||
private static List<Assembly> _allAssemblies;
|
||||
|
||||
private static List<Type> _allModels;
|
||||
public static string GetCurrentComma()
|
||||
{
|
||||
if (CultureInfo.CurrentUICulture.Name == "zh-cn")
|
||||
@@ -96,6 +97,43 @@ namespace WalkingTec.Mvvm.Core
|
||||
return _allAssemblies;
|
||||
}
|
||||
|
||||
private static List<Type> _allModelTypes= new List<Type>();
|
||||
public static List<Type> GetAllModels()
|
||||
{
|
||||
if (_allModels == null)
|
||||
{
|
||||
var modelAsms = Utils.GetAllAssembly();
|
||||
var allTypes = new List<Type>();// 所有 DbSet<> 的泛型类型
|
||||
// 获取所有 DbSet<T> 的泛型类型 T
|
||||
foreach (var asm in modelAsms)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dcModule = asm.GetExportedTypes().Where(x => typeof(DbContext).IsAssignableFrom(x)).ToList();
|
||||
if (dcModule != null && dcModule.Count > 0)
|
||||
{
|
||||
foreach (var module in dcModule)
|
||||
{
|
||||
foreach (var pro in module.GetProperties())
|
||||
{
|
||||
if (pro.PropertyType.IsGeneric(typeof(DbSet<>)))
|
||||
{
|
||||
if (!allTypes.Contains(pro.PropertyType.GenericTypeArguments[0], new TypeComparer()))
|
||||
{
|
||||
allTypes.Add(pro.PropertyType.GenericTypeArguments[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
_allModels = allTypes;
|
||||
}
|
||||
return _allModels;
|
||||
}
|
||||
|
||||
public static SimpleMenu FindMenu(string url, List<SimpleMenu> menus)
|
||||
{
|
||||
if (url == null)
|
||||
|
||||
@@ -4,9 +4,7 @@ using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -435,7 +433,7 @@ namespace WalkingTec.Mvvm.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
exist = BaseUserQuery.IgnoreQueryFilters().Any(x => x.ITCode.ToLower() == username && x.Password == Utils.GetMD5String(password) && x.TenantCode == tenant && x.IsValid==true);
|
||||
exist = BaseUserQuery.IgnoreQueryFilters().Any(x => x.ITCode.ToLower() == username.ToLower() && x.Password == Utils.GetMD5String(password) && x.TenantCode == tenant && x.IsValid==true);
|
||||
}
|
||||
if (exist == false)
|
||||
{
|
||||
@@ -839,6 +837,7 @@ params string[] groupcode)
|
||||
log.Duration = duration;
|
||||
log.ModuleName = moduleName;
|
||||
log.ActionName = actionName;
|
||||
log.ITCode = LoginUserInfo?.ITCode;
|
||||
log.Request = request;
|
||||
log.Result = result;
|
||||
log.IP = ip;
|
||||
|
||||
Reference in new issue
Block a user