Merge branch 'master' of http://118.178.224.202:3000/ewide/ewide_core
This commit is contained in:
@@ -29,7 +29,7 @@ namespace Ewide.Application.Entity
|
||||
[Comment("区域ID")]
|
||||
[MaxLength(36)]
|
||||
[Required]
|
||||
public string AreaId { get; set; }
|
||||
public string AreaCode { get; set; }
|
||||
|
||||
[Comment("类型")]
|
||||
[Required]
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ewide.Core\Ewide.Core.csproj" />
|
||||
<ProjectReference Include="..\Ewide.EntityFramework.Core\Ewide.EntityFramework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
<name>Ewide.Application</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Ewide.Application.Service.HouseProjectInfo.XMLHandler.GetDataBase">
|
||||
<summary>
|
||||
读取数据库的所有表 并拿到数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService">
|
||||
<summary>
|
||||
项目管理相关服务
|
||||
@@ -37,7 +43,7 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.QueryProjectPageList(Ewide.Application.Service.HouseProjectInfo.Dto.HouseProjectInfoInput)">
|
||||
<member name="M:Ewide.Application.Service.HouseProjectInfo.HouseProjectInfoService.QueryProjectPageList(Ewide.Application.Service.HouseProjectInfo.Dto.PageProjectInput)">
|
||||
<summary>
|
||||
分页查询
|
||||
</summary>
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
|
||||
public string Name { get; set; }
|
||||
public string Note { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public string AreaId { get; set; }
|
||||
public string AreaCode { get; set; }
|
||||
public int Type { get; set; }
|
||||
}
|
||||
public class AddProjectInput : HouseProjectInfoInput
|
||||
@@ -36,4 +36,9 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class PageProjectInput: HouseProjectInfoInput
|
||||
{
|
||||
public string pid { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Ewide.Application.Service.HouseProjectInfo.Dto
|
||||
public string Name { get; set; }
|
||||
public string Note { get; set; }
|
||||
public int Sort { get; set; }
|
||||
public string AreaId { get; set; }
|
||||
public string AreaCode { get; set; }
|
||||
public string AreaName { get; set; }
|
||||
public int Type { get; set; }
|
||||
}
|
||||
|
||||
@@ -2,22 +2,78 @@
|
||||
using Ewide.Application.Service.HouseProjectInfo.Dto;
|
||||
using Ewide.Core;
|
||||
using Ewide.Core.Service;
|
||||
using Ewide.Core.Util;
|
||||
using Ewide.EntityFramework.Core;
|
||||
using Furion;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DatabaseAccessor.Extensions;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Furion.FriendlyException;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using MySqlConnector;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Application.Service.HouseProjectInfo
|
||||
{
|
||||
[ApiDescriptionSettings(Name = "xml", Order = 3)]
|
||||
public class XMLHandler : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly DefaultDbContext _db;
|
||||
|
||||
public XMLHandler(DefaultDbContext db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
[HttpGet("/xml/detail")]
|
||||
public async Task XMLDoneAsync()
|
||||
{
|
||||
XmlSerializerUtil xmlHandler = new XmlSerializerUtil();
|
||||
xmlHandler.WriteDataSeed();
|
||||
//拿到数据保存到 XML文件
|
||||
//Dictionary<string, object> dicDataBase = await GetDataBase();
|
||||
//foreach (KeyValuePair<string, object> item in dicDataBase)
|
||||
//{
|
||||
// xmlHandler.WriteXML(item.Value.GetType(), item.Value, item.Key);
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取数据库的所有表 并拿到数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<Dictionary<string, object>> GetDataBase()
|
||||
{
|
||||
Dictionary<string, object> dicDataBase = new Dictionary<string, object>();
|
||||
var defaultConnection = App.Configuration["ConnectionStrings:DefaultConnection"];
|
||||
//获取 所有继承 IEntity 接口的表
|
||||
IEnumerable<IEntityType> entityTypedb = _db.Model.GetEntityTypes().Where(x => typeof(IEntity).IsAssignableFrom(x.ClrType)).ToList();
|
||||
|
||||
foreach (IEntityType item in entityTypedb)
|
||||
{
|
||||
MethodInfo mi = _db.GetType().GetMethods().FirstOrDefault(s => s.Name == "Set");
|
||||
MethodInfo miConstructed = mi.MakeGenericMethod(item.ClrType);
|
||||
object objList = miConstructed.Invoke(_db, null);
|
||||
var objsource = item.ClrType.MakeList(objList);
|
||||
dicDataBase.Add(item.ClrType.Name, objsource);
|
||||
}
|
||||
await _db.Database.CloseConnectionAsync();
|
||||
return dicDataBase;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 项目管理相关服务
|
||||
/// </summary>
|
||||
@@ -50,7 +106,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
[HttpPost("/houseProjectInfo/delete")]
|
||||
public async Task DeleteProject(DeleteProjectInput input)
|
||||
{
|
||||
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id) ;
|
||||
var project = _houseProjectInfoRep.FirstOrDefault(p => p.Id == input.Id);
|
||||
await project.DeleteNowAsync();
|
||||
}
|
||||
|
||||
@@ -63,7 +119,7 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
public async Task UpdateProject(UpdateProjectInput input)
|
||||
{
|
||||
var project = input.Adapt<BsHouseProjectInfo>();
|
||||
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaId)}, true);
|
||||
await project.UpdateExcludeAsync(new[] { nameof(BsHouseProjectInfo.AreaCode) }, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,14 +139,14 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/houseProjectInfo/page")]
|
||||
public async Task<dynamic> QueryProjectPageList([FromBody] HouseProjectInfoInput input)
|
||||
public async Task<dynamic> QueryProjectPageList([FromBody] PageProjectInput input)
|
||||
{
|
||||
var areaID = !string.IsNullOrEmpty(input.AreaId);
|
||||
var areaCodeRep = Db.GetRepository<SysAreaCode>();
|
||||
var projects = await _houseProjectInfoRep.DetachedEntities
|
||||
.Join(areaCodeRep.DetachedEntities, p => p.AreaId, a => a.Code, (p, a) => new { p, AreaName = a.Name })
|
||||
.Where(areaID, x => x.p.AreaId == input.AreaId)
|
||||
.Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaId, x.AreaName, x.p.Type }.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageNo, input.PageSize);
|
||||
.Join(areaCodeRep.DetachedEntities, p => p.AreaCode, a => a.Code, (p, a) => new { p, AreaName = a.Name })
|
||||
.Where(!string.IsNullOrEmpty(input.AreaCode), x => x.p.AreaCode == input.AreaCode)
|
||||
.Where(!string.IsNullOrEmpty(input.pid) , x=> x.p.AreaCode.Contains(input.pid))
|
||||
.Select(x => new { x.p.Id, x.p.Name, x.p.Note, x.p.Sort, x.p.AreaCode, x.AreaName, x.p.Type }.Adapt<HouseProjectOutput>()).ToPagedListAsync(input.PageNo, input.PageSize);
|
||||
return XnPageResult<HouseProjectOutput>.PageResult(projects);
|
||||
}
|
||||
|
||||
@@ -104,8 +160,27 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
{
|
||||
var user = await _houseProjectInfoRep.DetachedEntities.FirstOrDefaultAsync(p => p.Id == input.Id);
|
||||
var userDto = user.Adapt<UserOutput>();
|
||||
|
||||
|
||||
return userDto;
|
||||
}
|
||||
|
||||
[HttpGet("/houseProjectInfo/nextSort")]
|
||||
public async Task<int> GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input)
|
||||
{
|
||||
//var projects = await _houseProjectInfoRep.DetachedEntities
|
||||
// .Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
|
||||
// .Select(p => p.Sort)
|
||||
// .DefaultIfEmpty()
|
||||
// .MaxAsync();
|
||||
if (input.Type > 2 || input.Type < 1)
|
||||
{
|
||||
throw Oops.Oh("类型参数异常");
|
||||
}
|
||||
var p = await _houseProjectInfoRep.DetachedEntities
|
||||
.Where(p => p.AreaCode == input.AreaCode && p.Type == input.Type)
|
||||
.MaxAsync(p => (int?)p.Sort);
|
||||
|
||||
return p.GetValueOrDefault(0) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ namespace Ewide.Application.Service.HouseProjectInfo
|
||||
Task UpdateProject(UpdateProjectInput input);
|
||||
Task<BsHouseProjectInfo> GetProjectById([FromRoute] string id);
|
||||
Task<dynamic> GetProject([FromQuery] QueryProjectInput input);
|
||||
Task<dynamic> QueryProjectPageList([FromQuery] HouseProjectInfoInput input);
|
||||
Task<dynamic> QueryProjectPageList([FromQuery] PageProjectInput input);
|
||||
|
||||
Task<int> GetNextProjectSortByAreaCode([FromQuery] HouseProjectInfoInput input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -24,6 +25,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(员工)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysEmp SysEmp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -36,6 +38,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(机构)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysOrg SysOrg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -48,6 +51,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(职位)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysPos SysPos { get; set; }
|
||||
|
||||
public void Configure(EntityTypeBuilder<SysEmpExtOrgPos> entityBuilder, DbContext dbContext, Type dbContextLocator)
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(员工)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysEmp SysEmp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -19,9 +20,11 @@ namespace Ewide.Core
|
||||
/// </summary>
|
||||
[Comment("角色Id")]
|
||||
public string SysRoleId { get; set; }
|
||||
[XmlIgnore]
|
||||
public SysRole SysRole { get; set; }
|
||||
[Comment("系统使用的区域代码")]
|
||||
public string AreaCode { get; set; }
|
||||
[XmlIgnore]
|
||||
public SysAreaCode Area { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Furion.DatabaseAccessor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -33,6 +34,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统机构)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysOrg SysOrg { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Furion.DatabaseAccessor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -21,6 +22,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统用户)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysRole SysRole { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,6 +35,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统菜单)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysMenu SysMenu { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -15,10 +16,12 @@ namespace Ewide.Core
|
||||
[Comment("用户Id")]
|
||||
[Column("SysUserId", TypeName = "varchar(36)")]
|
||||
public string SysUserId { get; set; }
|
||||
[XmlIgnore]
|
||||
public SysUser SysUser { get; set; }
|
||||
[Comment("系统使用的区域代码")]
|
||||
[MaxLength(10)]
|
||||
public string AreaCode { get; set; }
|
||||
[XmlIgnore]
|
||||
public SysAreaCode Area { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Furion.DatabaseAccessor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -21,6 +22,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统用户)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysUser SysUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,6 +35,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统机构)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysOrg SysOrg { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Furion.DatabaseAccessor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -21,6 +22,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统用户)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysUser SysUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -33,6 +35,7 @@ namespace Ewide.Core
|
||||
/// <summary>
|
||||
/// 一对一引用(系统角色)
|
||||
/// </summary>
|
||||
[XmlIgnore]
|
||||
public SysRole SysRole { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\PublishProfiles\" />
|
||||
<Folder Include="DataBaseXML\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
28
Api/Ewide.Core/SeedDataXml/SysEmpExtOrgPos.xml
Normal file
28
Api/Ewide.Core/SeedDataXml/SysEmpExtOrgPos.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0"?>
|
||||
<ArrayOfSysEmpExtOrgPos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<SysEmpExtOrgPos>
|
||||
<SysEmpId>d0ead3dc-5096-4e15-bc6d-f640be5301ec</SysEmpId>
|
||||
<SysOrgId>12d888de-f55d-4c88-b0a0-7c3510664d97</SysOrgId>
|
||||
<SysPosId>269236c4-d74e-4e54-9d50-f6f61580a197</SysPosId>
|
||||
</SysEmpExtOrgPos>
|
||||
<SysEmpExtOrgPos>
|
||||
<SysEmpId>d0ead3dc-5096-4e15-bc6d-f640be5301ec</SysEmpId>
|
||||
<SysOrgId>8a2271d6-5bda-4544-bdd3-27e53a8b418e</SysOrgId>
|
||||
<SysPosId>46c68a62-f119-4ff7-b621-0bbd77504538</SysPosId>
|
||||
</SysEmpExtOrgPos>
|
||||
<SysEmpExtOrgPos>
|
||||
<SysEmpId>d0ead3dc-5096-4e15-bc6d-f640be5301ec</SysEmpId>
|
||||
<SysOrgId>127c0a5d-43ac-4370-b313-082361885aca</SysOrgId>
|
||||
<SysPosId>5bd8c466-2bca-4386-a551-daac78e3cee8</SysPosId>
|
||||
</SysEmpExtOrgPos>
|
||||
<SysEmpExtOrgPos>
|
||||
<SysEmpId>d0ead3dc-5096-4e15-bc6d-f640be5301ec</SysEmpId>
|
||||
<SysOrgId>f236ab2d-e1b5-4e9d-844f-a59ec32c20e4</SysOrgId>
|
||||
<SysPosId>d89a3afe-e6ba-4018-bdae-3c98bb47ad66</SysPosId>
|
||||
</SysEmpExtOrgPos>
|
||||
<SysEmpExtOrgPos>
|
||||
<SysEmpId>16a74726-e156-499f-9942-0e0e24ad0c3f</SysEmpId>
|
||||
<SysOrgId>f236ab2d-e1b5-4e9d-844f-a59ec32c20e4</SysOrgId>
|
||||
<SysPosId>269236c4-d74e-4e54-9d50-f6f61580a197</SysPosId>
|
||||
</SysEmpExtOrgPos>
|
||||
</ArrayOfSysEmpExtOrgPos>
|
||||
83
Api/Ewide.Core/Util/TypeHelper.cs
Normal file
83
Api/Ewide.Core/Util/TypeHelper.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Util
|
||||
{
|
||||
public static class TypeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态创建List<?> 泛型
|
||||
/// </summary>
|
||||
/// <param name="t">Type类</param>
|
||||
/// <param name="items">数据源</param>
|
||||
/// <returns></returns>
|
||||
public static object MakeList(this Type t, params object[] items)
|
||||
{
|
||||
Type type = typeof(List<>).MakeGenericType(t);
|
||||
object list = Activator.CreateInstance(type);
|
||||
System.Collections.IList ilist = list as System.Collections.IList;
|
||||
foreach (object o in items)
|
||||
ilist.Add(o);
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 动态创建List<?> 泛型
|
||||
/// </summary>
|
||||
/// <param name="t">Type类</param>
|
||||
/// <param name="objList">数据源</param>
|
||||
/// <returns></returns>
|
||||
public static object MakeList(this Type t, Object objList)
|
||||
{
|
||||
Type type = typeof(List<>).MakeGenericType(t);
|
||||
object list = Activator.CreateInstance(type);
|
||||
System.Collections.IList ilist = list as System.Collections.IList;
|
||||
var collection = objList as System.Collections.IEnumerable;
|
||||
if (collection != null)
|
||||
{
|
||||
foreach (object obj in collection)
|
||||
{
|
||||
ilist.Add(obj);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 动态创建List<?> 泛型s
|
||||
/// </summary>
|
||||
/// <param name="hostType">Type类</param>
|
||||
/// <param name="table">数据源</param>
|
||||
/// <returns></returns>
|
||||
public static object DataTableToList(this Type hostType, DataTable table)
|
||||
{
|
||||
Type type = typeof(List<>).MakeGenericType(hostType);
|
||||
object list = Activator.CreateInstance(type);
|
||||
System.Collections.IList ilist = list as System.Collections.IList;
|
||||
|
||||
object host = Activator.CreateInstance(hostType);
|
||||
string tempName = string.Empty;
|
||||
foreach (DataRow item in table.Rows)
|
||||
{
|
||||
PropertyInfo[] proList = hostType.GetProperties();
|
||||
foreach (PropertyInfo propertyInfo in proList)
|
||||
{
|
||||
tempName = propertyInfo.Name;
|
||||
if (table.Columns.Contains(tempName))
|
||||
{
|
||||
Object value = item[tempName];
|
||||
if (value!=null)
|
||||
{
|
||||
propertyInfo.SetValue(host,value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
ilist.Add(host);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using Furion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -15,12 +16,24 @@ namespace Ewide.Core.Util
|
||||
{
|
||||
public class XmlSerializerUtil
|
||||
{
|
||||
static string[] str = AppDomain.CurrentDomain.BaseDirectory.Split("ewide_core");
|
||||
static string path = str[0]+ @"ewide_core\Api\Ewide.Core\SeedDataXml\";
|
||||
/// <summary>
|
||||
/// XML 要读取的路径
|
||||
/// </summary>
|
||||
private string DirPath { set; get; }
|
||||
/// <summary>
|
||||
/// 当前程序集
|
||||
/// </summary>
|
||||
private string currentAssemblyName { get { return "Ewide.Core"; } }
|
||||
/// <summary>
|
||||
/// 读取文件夹下所有XML
|
||||
/// add-migration init -c defaultDbContext 备用数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<Type, object> ReaderALL()
|
||||
{
|
||||
string dirPath = CurrentDirPath();
|
||||
Dictionary<Type, object> dic = new Dictionary<Type, object>();
|
||||
DirectoryInfo folder = new DirectoryInfo(path);
|
||||
DirectoryInfo folder = new DirectoryInfo(dirPath);
|
||||
foreach (FileInfo file in folder.GetFiles())
|
||||
{
|
||||
//除去.xml 后缀
|
||||
@@ -34,16 +47,12 @@ namespace Ewide.Core.Util
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
private object Deserialize<T>(string xmlContent, Type[] Arrtype)
|
||||
{
|
||||
object obj = null;
|
||||
using (StringReader sr = new StringReader(xmlContent))
|
||||
{
|
||||
XmlSerializer xmldes = new XmlSerializer(typeof(List<T>), Arrtype);
|
||||
obj = xmldes.Deserialize(sr);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/// <summary>
|
||||
/// 反序列化
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="xmlContent">XML内容</param>
|
||||
/// <returns></returns>
|
||||
private object Deserialize(Type type, string xmlContent)
|
||||
{
|
||||
object obj = null;
|
||||
@@ -54,20 +63,32 @@ namespace Ewide.Core.Util
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
public string StreamRead(string path)
|
||||
/// <summary>
|
||||
/// 数据流读取
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
private string StreamRead(string path)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path, Encoding.Default))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 反射 根据类名 反射整个类 得到实例
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
private object AppInfo(string name)
|
||||
{
|
||||
string assemblyName = "Ewide.Core";
|
||||
string nameSpace = "Ewide.Core";
|
||||
string fullName = nameSpace + "." + name;
|
||||
object ect = Assembly.Load(assemblyName).CreateInstance(fullName);
|
||||
return ect;
|
||||
if (name == "BsHouseProjectInfo") //BsHouseProjectInfo 这个类 写在 application 程序集
|
||||
{
|
||||
string fullNamei = string.Join('.', "Ewide.Application.Entity", name);
|
||||
return Assembly.Load("Ewide.Application").CreateInstance(fullNamei);
|
||||
}
|
||||
string fullName = string.Join('.', currentAssemblyName, name);
|
||||
return Assembly.Load(currentAssemblyName).CreateInstance(fullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,13 +99,72 @@ namespace Ewide.Core.Util
|
||||
/// <param name="className">XML名称</param>
|
||||
public void WriteXML(Type type, object data, string className)
|
||||
{
|
||||
|
||||
string writePath = path + className + ".xml";
|
||||
string writePath = CurrentDirPath(className);
|
||||
using (FileStream fs = new FileStream(writePath, FileMode.OpenOrCreate))
|
||||
{
|
||||
XmlSerializer ser = new XmlSerializer(type);
|
||||
ser.Serialize(fs, data);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 要操作的文件夹目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private string CurrentDirPath()
|
||||
{
|
||||
// 在for 循环里, 不用每次都读取 下面的代码
|
||||
if (DirPath != null)
|
||||
return DirPath;
|
||||
|
||||
string targetPath = String.Empty;
|
||||
string appConfigPath = App.Configuration["WriteXmlPath:ReadSelect"] == "SeedData" ? App.Configuration["WriteXmlPath:SeedData"] : App.Configuration["WriteXmlPath:DataBase"];
|
||||
string path = Directory.GetCurrentDirectory();
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(path);
|
||||
foreach (DirectoryInfo item in dirInfo.Parent.GetDirectories())
|
||||
{
|
||||
if (item.Name == currentAssemblyName)
|
||||
{
|
||||
targetPath = item.GetDirectories(appConfigPath).FirstOrDefault().FullName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DirPath = targetPath;
|
||||
return targetPath;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据类名 创建一个XML文件 写入数据
|
||||
/// </summary>
|
||||
/// <param name="className"></param>
|
||||
/// <returns></returns>
|
||||
private string CurrentDirPath(string className)
|
||||
{
|
||||
string path = CurrentDirPath();
|
||||
return string.Join(@"\", path, className + ".xml");
|
||||
}
|
||||
/// <summary>
|
||||
/// 写入种子数据 --不常用
|
||||
/// </summary>
|
||||
public void WriteDataSeed()
|
||||
{
|
||||
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.GetName().Name.Contains("Ewide.Core"));
|
||||
Type[] types = assembly.GetTypes();
|
||||
foreach (Type type in types)
|
||||
{
|
||||
//if (type.Name.EndsWith("SeedData"))
|
||||
if(type.Name.EndsWith("SysEmpExtOrgPos"))
|
||||
{
|
||||
object obHelper = Activator.CreateInstance(type);
|
||||
MethodInfo methodinfo = type.GetMethod("HasData");
|
||||
object objs = methodinfo.Invoke(obHelper, new object[] { null, null });
|
||||
Type objType = objs.GetType();
|
||||
//if (objType.Name == "SysEmpExtOrgPos[]" || objType.Name == "SysConfig[]" || objType.Name == "SysDictData[]" || objType.Name == "SysDictType[]" || objType.Name == "SysEmpPos[]" || objType.Name == "SysEmp[]" || objType.Name == "SysMenu[]" || objType.Name == "SysOrg[]" || objType.Name == "SysPos[]" || objType.Name == "SysRole[]" || objType.Name == "SysTenant[]" || objType.Name == "SysTimer[]" || objType.Name == "SysUser[]")
|
||||
if (objType.Name == "SysEmpExtOrgPos[]")
|
||||
{
|
||||
string className = objType.Name.Remove(objType.Name.Length - 2, 2);
|
||||
WriteXML(objType, objs, className);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
"ExpiredTime": 1440, // 过期时间,long 类型,单位分钟,默认20分钟
|
||||
"ClockSkew": 5 // 过期时间容错值,long 类型,单位秒,默认5秒
|
||||
},
|
||||
"WriteXmlPath": {
|
||||
"SeedData": "SeedDataXml",
|
||||
"DataBase": "DataBaseXml",
|
||||
"ReadSelect": "SeedData" // SeedData 和 DataBase 两个中间选
|
||||
},
|
||||
"Cache": {
|
||||
"CacheType": "MemoryCache", // RedisCache
|
||||
"RedisConnectionString": "127.0.0.1:6379,password=,defaultDatabase=2"
|
||||
|
||||
@@ -179,7 +179,10 @@ namespace Ewide.EntityFramework.Core
|
||||
data.Add(obj);
|
||||
}
|
||||
}
|
||||
modelBuilder.Entity(item.Key).HasData(data); ;
|
||||
if (data.Count>0)
|
||||
{
|
||||
modelBuilder.Entity(item.Key).HasData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=localhost;Port=3306;Database=ewide;User ID=root;Password=a45683926;pooling=true;sslmode=none;CharSet=utf8;"
|
||||
"DefaultConnection": "Data Source=localhost;Port=3306;Database=ewide;User ID=root;Password=root;pooling=true;sslmode=none;CharSet=utf8;"
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- 表单控件 -->
|
||||
<a-form-model-item label="所属区域" prop="areaCode">
|
||||
<!-- <a-tree-select :dropdown-style="{ maxHeight: '300px', overflow: 'auto' }" :tree-data="areaData" :replace-fields="{ value: 'code', title: 'name', children: 'children' }" placeholder="请选择所属区域" tree-default-expand-all v-model="form.areaId" /> -->
|
||||
<a-cascader :field-names="{ label: 'name', value: 'code', children: 'children' }" :options="areaData" expand-trigger="hover" placeholder="请选择所属区域" v-model="areaCode" />
|
||||
<a-cascader :field-names="{ label: 'name', value: 'code', children: 'children' }" :options="areaData" expand-trigger="hover" placeholder="请选择所属区域" v-model="form.areaCode" :display-render="displayRender" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="项目名称" prop="name">
|
||||
<a-input placeholder="请输入项目名称" v-model="form.name" />
|
||||
@@ -43,16 +43,19 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
/** 表单数据 */
|
||||
form: { areaId: '' },
|
||||
form: {},
|
||||
/** 验证格式 */
|
||||
rules: {
|
||||
/* ... */
|
||||
note: [{ required: true, message: '请输入备注' }],
|
||||
name: [{ required: true, message: '请输入项目名称' }],
|
||||
sort: [{ required: true, message: '请输入排序' }],
|
||||
areaCode: [{ required: true, message: '请选择所属区域' }],
|
||||
type: [{ required: true, message: '请选择类型' }],
|
||||
},
|
||||
|
||||
/** 加载异步数据状态 */
|
||||
loading: false,
|
||||
|
||||
/** 其他成员属性 */
|
||||
areaData: [],
|
||||
/* ... */
|
||||
@@ -66,7 +69,7 @@ export default {
|
||||
*/
|
||||
onFillData(params) {
|
||||
// 从字符串areaCode查找到整个层级
|
||||
const areaCodeDeault = params.record ? params.record.areaId : params.pid ? params.pid : '';
|
||||
const areaCodeDeault = params.record ? params.record.areaCode : params.pid ? params.pid : '';
|
||||
const areaCode = [];
|
||||
const findCode = (data, level) => {
|
||||
level = level || 0;
|
||||
@@ -96,10 +99,9 @@ export default {
|
||||
...defaultForm,
|
||||
...params.record,
|
||||
/** 在此处添加其他默认数据转换 */
|
||||
areaId: areaCode[3],
|
||||
areaCode: areaCode.length == 4 ? areaCode : [],
|
||||
/* ... */
|
||||
});
|
||||
this.areaCode = areaCode;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -111,7 +113,7 @@ export default {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const record = this.$_.cloneDeep(this.form);
|
||||
|
||||
record.areaCode = record.areaCode[record.areaCode.length - 1];
|
||||
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||
/* ... */
|
||||
|
||||
@@ -162,6 +164,9 @@ export default {
|
||||
return res.data;
|
||||
});
|
||||
},
|
||||
displayRender({ labels }) {
|
||||
return labels[labels.length - 1];
|
||||
},
|
||||
/* ... */
|
||||
},
|
||||
};
|
||||
@@ -8,13 +8,7 @@
|
||||
<container>
|
||||
<br />
|
||||
<a-card :bordered="false">
|
||||
<yo-table
|
||||
:columns="columns"
|
||||
:load-data="loadData"
|
||||
@query="onQuery"
|
||||
@resetQuery="onResetQuery"
|
||||
ref="table"
|
||||
>
|
||||
<yo-table :columns="columns" :load-data="loadData" @query="onQuery" @resetQuery="onResetQuery" ref="table">
|
||||
<Auth auth="sysArea:page" slot="query">
|
||||
<!-- 此处添加查询表单控件 -->
|
||||
<!-- ... -->
|
||||
@@ -147,6 +141,10 @@ export default {
|
||||
* 传给yo-table以示意数据接口及其参数和返回的数据结构
|
||||
*/
|
||||
loadData(params) {
|
||||
if (!params.sortField) {
|
||||
params.sortField = 'code';
|
||||
params.sortOrder = 'ascend';
|
||||
}
|
||||
return this.$api[api.page]({
|
||||
...params,
|
||||
...this.query,
|
||||
|
||||
Reference in New Issue
Block a user