ZY.Framework.Core
1.3.2.17
dotnet add package ZY.Framework.Core --version 1.3.2.17
NuGet\Install-Package ZY.Framework.Core -Version 1.3.2.17
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZY.Framework.Core" Version="1.3.2.17" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZY.Framework.Core --version 1.3.2.17
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZY.Framework.Core, 1.3.2.17"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ZY.Framework.Core as a Cake Addin
#addin nuget:?package=ZY.Framework.Core&version=1.3.2.17
// Install ZY.Framework.Core as a Cake Tool
#tool nuget:?package=ZY.Framework.Core&version=1.3.2.17
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
基础组件
nuget引用组件 :ZY.Framework.Core
数据库
config
"MySQLDbOption": {
"ConnectionString": "server=localhost;port=3306;database=template;uid=root;password=yk1234;Old Guids=true;Allow User Variables=True;charset=utf8",
"HisConnectionString": "server=localhost;port=3306;database=templatehis;uid=root;password=yk1234;Old Guids=true;Allow User Variables=True;charset=utf8;Pooling=true"
}
Program
LoggerFactory MyLoggerFactory = new LoggerFactory(new[] { new DebugLoggerProvider() });
var migrationsAssembly = typeof(EFDbContext).GetTypeInfo().Assembly.GetName().Name;
services.AddFramework<EFDbContext>(option =>
{
//option.UseSqlServer(Configuration["SQLDbOption:ConnectionString"],
option.UseMySql(
configuration["MySQLDbOption:ConnectionString"],
ServerVersion.AutoDetect(configuration["MySQLDbOption:ConnectionString"]),
builder => builder.MigrationsAssembly(migrationsAssembly));
})
.AddDbContext<HistoryDbContext>(opt =>
{
string connectionString = configuration["MySQLDbOption:HisConnectionString"];
var serverVersion = ServerVersion.AutoDetect(connectionString);
opt.UseLoggerFactory(MyLoggerFactory).UseMySql(
connectionString,
serverVersion,
builder => builder.MigrationsAssembly(migrationsAssembly));
});
Context
public class EFDbContext : BaseDbContext
{
public EFDbContext(DbContextOptions<EFDbContext> options) : base(options){}
public DbSet<Arrears> Arrears { get; set; }
public DbSet<ArrearsApply> ArrearsApply { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
public class HistoryDbContext : BaseDbContext
{
public HistoryDbContext(DbContextOptions<HistoryDbContext> options) : base(options){}
public DbSet<CarRecord> CarRecord { get; set; }
public DbSet<TempPay> TempPay { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
调用
private readonly IRepository _service;
private readonly IUnitOfWork _unitofwork;
private readonly IRepositoryBase<HistoryDbContext> _history;
private readonly IUnitOfWork<HistoryDbContext> _historyunitOfWork;
数据库扩展
调用
// 获取查询首个字段
var num = _repository.SqlQueryFirst<long>("select count(1) from carrecord",null);
//获取查询字段集合
var data = _repository.SqlQuery<string>("select id from carrecord",null);
// 获取查询首个对象
var num = _repository.SqlQueryFirst<carrecord>("select * from carrecord limit 1",null);
//获取查询对象集合
var data = _repository.SqlQuery<carrecord>("select * from carrecord",null);
//无具体接收对象 查询集合
var parkingsetting = _repository.SqlQueryDynamic($"select Item, Value,ParkingId from parkingse where RobotId is null", null);
return parkingsetting?.Where(x => x.Item == item)?.FirstOrDefault()?.Value;
//修改更新sql操作
var num = _repository.ExecuteSql("update Parking set TempSurplus=@left where Id=@parkingId", new
{
parkingId,
left
});
** 接收对象为任意定义对象,对象一致赋值,不一致默认值
** 传入参数,可以是匿名对象,也可以是具体对象,字段与占位符一致就行
HTTP
调用
private readonly IHttpService _httpClient;
//普通请求
var resutl = await _httpClient.GetAsync<ApiResult<DeptInfo>>(_server.BasicsUrl, "api/PropertyManage/GetDeptInfo", new { DeptId = deptid });
//全局签名请求
_httpClient.SetSignature(new Signature { Key = _parkingRobotOption.Key, Tenant = _parkingRobotOption.ParkingId });
var result = await _httpClient.GetAsync<ApiResult>(_server.CloudUrl, "/api/CarRecord/status", new { id = recordId });
//单次签名请求
var sign = new Signature(new Signature { Key = _parkingRobotOption.Key, Tenant = _parkingRobotOption.ParkingId });
var result = await _httpClient.GetAsync<ApiResult>(_server.CloudUrl, "/api/CarRecord/status", new { id = recordId }, sign);
//超时处理
var soure = new CancellationTokenSource(TimeSpan.FromSeconds(3));
var resutl = await _httpClient.GetAsync<ApiResult<DeptInfo>>(_server.BasicsUrl, "api/PropertyManage/GetDeptInfo", new { DeptId = deptid }, soure.Token);
缓存
Program
services.AddFrameworkUseCache(); //内存缓存
services.AddFrameworkUseRedis<TCache>(); //redis 缓存
调用
private readonly ICacheService _cache;
//同步
return _cache.TryGetValue<List<HolidayEntity>>("ISHOLIDAY", o =>
{
return _repository.GetList<HolidayEntity>(s => s.Time >= $"{DateTime.Now.Year}-1-1".ToDateTime() && s.Time <= $"{DateTime.Now.Year}-12-31".ToDateTime());
});
//异步
return await _cache.TryGetValue<DeptInfo>(key, async (s) =>
{
return new DeptInfo();
});
脚本运行
调用
//执行脚本
var cmd = Path.Combine("scripts", "memoryinfo.sh");
var result = ProcessHelper.Run<Memoryinfo>(Bash, cmd);
//执行命令
return ProcessHelper.Run("top", " -b n 1 -i -c").Output;
//异步执行脚本
var cmd = Path.Combine("scripts", $"startbusiness.sh");
ProcessHelper.RunAsync(Bash, $"{cmd} {port}");
对象去重
调用
List<CarRecord> list = await _service.GetListAsync<CarRecord>(s => s.BatchId == record.BatchId);
list = list.Distinct(new PropertyComparer<CarRecord>("Id")).ToList();
** 对集合中某个对象字段去重
对象转sql
调用
var test = new Test
{
Id = 1,
Age = 1
};
List<Test> list = new List<Test>() { test};
//集合转sql
var sql = list.ToAddSql(ESql.InsertOrUpdate);
//对象转sql
var sql = test.ToAddSql(ESql.InsertOrUpdate);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- AutoMapper (>= 7.0.1)
- Microsoft.EntityFrameworkCore.Relational (>= 2.2.6)
- Newtonsoft.Json (>= 12.0.2)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on ZY.Framework.Core:
Package | Downloads |
---|---|
ZY.HTTP.Core
签名验证 |
|
YKMS.Parking.Public.Entity
云凯科技 |
|
ZY.HolidayApi.Core
签名验证 |
|
ZY.PlateRecognition.MQTT
车牌识别摄像头MQTT协议 |
|
ZY.PlateRecognition.TCP
车牌识别摄像头TCP协议 |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.2.17 | 89 | 5/15/2024 |
1.3.2.16 | 96 | 4/30/2024 |
1.3.2.15 | 109 | 4/26/2024 |
1.3.2.14 | 84 | 4/24/2024 |
1.3.2.13 | 78 | 4/18/2024 |
1.3.2.12 | 80 | 4/12/2024 |
1.3.2.11 | 631 | 2/28/2024 |
1.3.2.10 | 190 | 2/19/2024 |
1.3.2.9 | 83 | 2/4/2024 |
1.3.2.8 | 81 | 1/29/2024 |
1.3.2.7 | 80 | 1/24/2024 |
1.3.2.6 | 325 | 12/3/2023 |
1.3.2.5 | 111 | 11/30/2023 |
1.3.2.4 | 224 | 9/9/2023 |
1.3.2.3 | 123 | 9/8/2023 |
1.3.2.2 | 293 | 7/26/2023 |
1.3.2.1 | 163 | 7/25/2023 |
1.3.1.9 | 190 | 7/18/2023 |
1.3.1.8 | 426 | 4/20/2023 |
1.3.1.7 | 243 | 3/20/2023 |
1.3.1.6 | 228 | 2/21/2023 |
1.3.1.5 | 285 | 2/3/2023 |
1.3.1.4 | 287 | 2/1/2023 |
1.3.1.3 | 430 | 7/25/2022 |
1.3.1.2 | 416 | 7/25/2022 |
1.3.1.1 | 475 | 6/14/2022 |
1.2.3.6 | 1,259 | 4/14/2022 |
1.2.3.5 | 1,611 | 11/4/2021 |
1.2.3.4 | 396 | 8/24/2021 |
1.2.3.3 | 559 | 8/16/2021 |
1.2.3.2 | 390 | 2/26/2021 |
1.2.3.1 | 408 | 2/25/2021 |
1.2.2.1 | 375 | 1/19/2021 |
1.2.1.10 | 565 | 12/17/2020 |
1.2.1.9 | 564 | 12/11/2020 |
1.2.1.8 | 609 | 11/28/2020 |
1.2.1.7 | 524 | 11/28/2020 |
1.2.1.6 | 872 | 11/27/2020 |
1.2.1.5 | 620 | 11/27/2020 |
1.2.1.4 | 385 | 11/26/2020 |
1.2.1.3 | 419 | 11/26/2020 |
1.2.1.2 | 402 | 11/26/2020 |
1.2.1.1 | 418 | 11/26/2020 |
1.0.3.1 | 485 | 9/15/2020 |
1.0.2.4 | 417 | 8/28/2020 |
1.0.2.3 | 426 | 8/28/2020 |
1.0.2.2 | 1,505 | 7/27/2020 |
1.0.2.1 | 431 | 7/17/2020 |
1.0.1.1 | 428 | 7/15/2020 |
1.0.0.7 | 469 | 7/15/2020 |
1.0.0.6 | 464 | 7/15/2020 |
1.0.0.5 | 462 | 7/14/2020 |
1.0.0.4 | 443 | 7/13/2020 |
1.0.0.3 | 448 | 7/10/2020 |
1.0.0.2 | 464 | 7/10/2020 |
1.0.0.1 | 510 | 7/9/2020 |
1.0.0 | 474 | 7/9/2020 |