CS2-30 Создать контроллер куста и контроллер месторождения.

Разработана модель данных
This commit is contained in:
Фролов 2021-07-21 12:30:51 +05:00
parent 54d917c17e
commit 11f5bd00f1
25 changed files with 391 additions and 105 deletions

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace AsbCloudApp.Data.Analytics
{
public class WellDrillingStatDto
{
public int Id { get; set; }
public WellDto Well { get; set; }
public DateTime PlanStart { get; set; }
public DateTime PlanEnd { get; set; }
public DateTime FactStart { get; set; }
public DateTime FactEnd { get; set; }
public double UnProductiveTimeDays { get; set; }
public double RateOfPenetrationPlan { get; set; }
public double RateOfPenetrationFact { get; set; }
public double RouteSpeedPlan { get; set; }
public double RouteSpeedFact { get; set; }
public IEnumerable<WellSectionDto> Sections { get; set; }
public IEnumerable<ContractorDto> Contractors { get; set; }
}
}

View File

@ -0,0 +1,21 @@
namespace AsbCloudApp.Data.Analytics
{
public class WellSectionDto
{
public string SectionType { get; set; }
public double WellDepthPlan { get; set; }
public double WellDepthFact { get; set; }
public double BuildDaysPlan { get; set; }
public double BuildDaysFact { get; set; }
public double RateOfPenetrationPlan { get; set; }
public double RateOfPenetrationFact { get; set; }
public double RouteSpeedPlan { get; set; }
public double RouteSpeedFact { get; set; }
public double BhaUpSpeedPlan { get; set; }
public double BhaUpSpeedFact { get; set; }
public double BhaDownSpeedPlan { get; set; }
public double BhaDownSpeedFact { get; set; }
public double CasingDownSpeedPlan { get; set; }
public double CasingDownSpeedFact { get; set; }
}
}

View File

@ -1,7 +0,0 @@
namespace AsbCloudApp.Data
{
public class ClusterAnalysisDto
{
public int Id { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace AsbCloudApp.Data
{
public class ContractorDto
{
public int Id { get; set; }
public string Name { get; set; }
public string Service { get; set; }
}
}

View File

@ -7,5 +7,7 @@
public object LastData { get; set; }//DataSaubBaseDto
public double Latitude { get; set; }
public double Longitude { get; set; }
public int WellType { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.Analytics;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,6 +14,6 @@ namespace AsbCloudApp.Services
IEnumerable<ClusterDto> GetClusters(int idCustomer, int depositId);
IEnumerable<ClusterDto> GetClusters(int idCustomer);
IEnumerable<WellDto> GetWells(int idCustomer, int clusterId);
IEnumerable<ClusterAnalysisDto> GetAnalysis(int idCustomer, int clusterId);
IEnumerable<WellDrillingStatDto> GetAnalysis(int idCustomer, int clusterId);
}
}

View File

@ -0,0 +1,15 @@
namespace AsbCloudDb.Model.Analytics
{
public enum SectionType
{
MeanSeaLevel,
MudLine,
ConductorCasing,
SurfaceCasing,
InjectionCasing,
IntermediateCasing,
ProtectiveCasing,
ProductionCasing,
ProductionLiner,
}
}

View File

@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System;
using System.Text.Json.Serialization;
using System.Collections.Generic;
#nullable disable
namespace AsbCloudDb.Model.Analytics
{
[Table("t_well_drilling_stat"), Comment("статистика бурения скважины")]
public class WellDrillingStat
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_well")]
public int IdWell { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
[InverseProperty(nameof(Model.Well.WellDrillingStat))]
public virtual Well Well { get; set; }
[Column("plan_start", TypeName = "timestamp with time zone")]
public DateTime PlanStart { get; set; }
[Column("plan_end", TypeName = "timestamp with time zone")]
public DateTime PlanEnd { get; set; }
[Column("fact_start", TypeName = "timestamp with time zone")]
public DateTime FactStart { get; set; }
[Column("fact_end", TypeName = "timestamp with time zone")]
public DateTime FactEnd { get; set; }
[Column("un_productive_time_days"), Comment("НПВ, сут")]
public double UnProductiveDays { get; set; }
[Column("rate_of_penetration_plan"), Comment("МСП план")]
public double RateOfPenetrationPlan { get; set; }
[Column("rate_of_penetration_fact"), Comment("МСП факт")]
public double RateOfPenetrationFact { get; set; }
[Column("route_speed_plan"), Comment("Рейсовая скорость план")]
public double RouteSpeedPlan { get; set; }
[Column("route_speed_fact"), Comment("Рейсовая скорость факт")]
public double RouteSpeedFact { get; set; }
}
}

View File

@ -0,0 +1,76 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System;
using System.Text.Json.Serialization;
#nullable disable
namespace AsbCloudDb.Model.Analytics
{
[Table("t_well_section"), Comment("секция скважины")]
public class WellSection
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("id_well_section_type")]
public int IdWellSectionType { get; set; }
[Column("id_well")]
public int IdWell{ get; set; }
[Column("well_depth_plan"), Comment("глубина план")]
public double WellDepthPlan { get; set; }
[Column("well_depth_fact"), Comment("глубина факт")]
public double WellDepthFact { get; set; }
[Column("build_days_plan"), Comment("период план")]
public double BuildDaysPlan { get; set; }
[Column("build_days_fact"), Comment("период факт")]
public double BuildDaysFact { get; set; }
[Column("rate_of_penetration_plan"), Comment("Механическая скорость проходки план")]
public double RateOfPenetrationPlan { get; set; }
[Column("rate_of_penetration_fact"), Comment("Механическая скорость проходки факт")]
public double RateOfPenetrationFact { get; set; }
[Column("route_speed_plan"), Comment("Рейсовая скорость план")]
public double RouteSpeedPlan { get; set; }
[Column("route_speed_fact"), Comment("Рейсовая скорость факт")]
public double RouteSpeedFact { get; set; }
[Column("bha_down_speed_plan"), Comment("Скорость спуска КНБК план")]
public double BhaDownSpeedPlan { get; set; }
[Column("bha_down_speed_fact"), Comment("Скорость спуска КНБК факт")]
public double BhaDownSpeedFact { get; set; }
[Column("bha_up_speed_plan"), Comment("Скорость подъема КНБК план")]
public double BhaUpSpeedPlan { get; set; }
[Column("bha_up_speed_fact"), Comment("Скорость подъема КНБК факт")]
public double BhaUpSpeedFact { get; set; }
[Column("casing_down_speed_plan"), Comment("Скорость спуска ОК план")]
public double CasingDownSpeedPlan { get; set; }
[Column("casing_down_speed_fact"), Comment("Скорость спуска ОК факт")]
public double CasingDownSpeedFact { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWell))]
[InverseProperty(nameof(Model.Well.SectionAnalysis))]
public virtual Well Well { get; set; }
[JsonIgnore]
[ForeignKey(nameof(IdWellSectionType))]
[InverseProperty(nameof(Analytics.WellSectionType.WellSections))]
public virtual WellSectionType WellSectionType { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System;
using System.Text.Json.Serialization;
using System.Collections.Generic;
#nullable disable
namespace AsbCloudDb.Model.Analytics
{
[Table("t_well_section_type"), Comment("конструкция секции скважины")]
public class WellSectionType
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption"), Comment("Название")]
[StringLength(255)]
public string Caption { get; set; }
[JsonIgnore]
[InverseProperty(nameof(Analytics.WellSection.WellSectionType))]
public virtual ICollection<WellSection> WellSections { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using AsbCloudDb.Model.Analytics;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
@ -14,7 +15,7 @@ namespace AsbCloudDb.Model
{
//private readonly string connectionString;
public virtual DbSet<Cluster> Clusters { get; set; }
public virtual DbSet<Customer> Customers { get; set; }
public virtual DbSet<Company> Companies { get; set; }
public virtual DbSet<DataSaubBase> DataSaubBases { get; set; }
public virtual DbSet<Deposit> Deposits { get; set; }
public virtual DbSet<Event> Events { get; set; }
@ -26,7 +27,9 @@ namespace AsbCloudDb.Model
public virtual DbSet<Well> Wells { get; set; }
public virtual DbSet<Report> Reports { get; set; }
public virtual DbSet<Operation> Operations { get; set; }
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
public virtual DbSet<TelemetryAnalysis> TelemetryAnalysis { get; set; }
public virtual DbSet<WellSection> SectionAnalysis { get; set; }
public virtual DbSet<WellDrillingStat> WellDrillingStats { get; set; }
//public AsbCloudDbContext(string connectionString = "Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
//{
@ -118,18 +121,27 @@ namespace AsbCloudDb.Model
});
});
modelBuilder.Entity<Customer>(entity =>
modelBuilder.Entity<CompanyType>(entity =>
{
entity.HasData(new List<Customer>{
new Customer{ Id = 1, Caption = "\"ООО\" АСБ", },
entity.HasData(new List<CompanyType>{
new CompanyType{ Id = 1, Caption = "Недрапользователь", },
new CompanyType{ Id = 2, Caption = "Буровой подрядчик", },
new CompanyType{ Id = 3, Caption = "Сервис автоматизации бурения", },
});
});
modelBuilder.Entity<Company>(entity =>
{
entity.HasData(new List<Company>{
new Company{ Id = 1, Caption = "\"ООО\" АСБ", IdCompanyType = 3},
});
});
modelBuilder.Entity<User>(entity =>
{
entity.HasOne(d => d.Customer)
entity.HasOne(d => d.Company)
.WithMany(p => p.Users)
.HasForeignKey(d => d.IdCustomer)
.HasForeignKey(d => d.IdCompany)
.HasConstraintName("t_user_t_customer_id_fk");
entity.HasIndex(d => d.Login)
@ -138,7 +150,7 @@ namespace AsbCloudDb.Model
entity.HasData(new List<User>{
new User{
Id = 1,
IdCustomer = 1,
IdCompany = 1,
IdRole = 1,
Level = int.MaxValue,
Login = "dev",
@ -155,10 +167,9 @@ namespace AsbCloudDb.Model
.HasForeignKey(d => d.IdCluster)
.HasConstraintName("t_well_t_cluster_id_fk");
entity.HasOne(d => d.Customer)
.WithMany(p => p.Wells)
.HasForeignKey(d => d.IdCustomer)
.HasConstraintName("t_well_t_customer_id_fk");
// Todo: Setup relation table names (https://stackoverflow.com/questions/11769864/many-to-many-relationships-in-ef5-code-first-how-can-i-specify-table-name)
entity.HasMany(d => d.Companies)
.WithMany(p => p.Wells);
entity.HasOne(d => d.Telemetry)
.WithOne(p => p.Well)
@ -233,7 +244,7 @@ namespace AsbCloudDb.Model
public IQueryable<Well> GetWellsByCustomer(int idCustomer)
{
return from well in Wells
.Include(w => w.Customer)
.Include(w => w.Companies)
.Include(w => w.Cluster)
.ThenInclude(c => c.Deposit)
where well.IdCustomer == idCustomer
@ -243,7 +254,7 @@ namespace AsbCloudDb.Model
public IQueryable<User> GetUsersByLogin(string login)
=> Users
.Include(e => e.Role)
.Include(e => e.Customer)
.Include(e => e.Company)
.Where(e => e.Login == login);
public (DateTime From, DateTime To) GetDatesRange<TEntity>(int idTelemetry)

View File

@ -0,0 +1,41 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_company")]
public partial class Company : IId
{
public Company()
{
Users = new HashSet<User>();
Wells = new HashSet<Well>();
}
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
[Column("id_company_type"), Comment("вид деятельности")]
[StringLength(255)]
public int IdCompanyType { get; set; }
[ForeignKey(nameof(IdCompanyType))]
[InverseProperty(nameof(Model.CompanyType.Companies))]
public virtual CompanyType CompanyType { get; set; }
[InverseProperty(nameof(User.Company))]
public virtual ICollection<User> Users { get; set; }
[InverseProperty(nameof(Well.Companies))]
public virtual ICollection<Well> Wells { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_company_type")]
public partial class CompanyType
{
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
[InverseProperty(nameof(Company.CompanyType))]
public virtual ICollection<Company> Companies { get; set; }
}
}

View File

@ -1,31 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace AsbCloudDb.Model
{
[Table("t_customer")]
public partial class Customer : IId
{
public Customer()
{
Users = new HashSet<User>();
Wells = new HashSet<Well>();
}
[Key]
[Column("id")]
public int Id { get; set; }
[Column("caption")]
[StringLength(255)]
public string Caption { get; set; }
[InverseProperty(nameof(User.Customer))]
public virtual ICollection<User> Users { get; set; }
[InverseProperty(nameof(Well.Customer))]
public virtual ICollection<Well> Wells { get; set; }
}
}

View File

@ -10,7 +10,7 @@ namespace AsbCloudDb.Model
public interface IAsbCloudDbContext
{
DbSet<Cluster> Clusters { get; set; }
DbSet<Customer> Customers { get; set; }
DbSet<Company> Companies { get; set; }
DbSet<DataSaubBase> DataSaubBases { get; set; }
DbSet<Deposit> Deposits { get; set; }
DbSet<Event> Events { get; set; }

View File

@ -11,20 +11,29 @@ namespace AsbCloudDb.Model
[Key]
[Column("id")]
public int Id { get; set; }
[Column("name"), Comment("Название отчета (файла)")]
public string Name { get; set; }
[Column("id_well"), Comment("id скважины")]
public int WellId { get; set; }
public int IdWell { get; set; }
[Column("date", TypeName = "timestamp with time zone")]
public DateTime Date { get; set; }
[Column("begin", TypeName = "timestamp with time zone")]
public DateTimeOffset Begin { get; set; }
[Column("end"), Comment("timestamp with time zone")]
public DateTimeOffset End { get; set; }
[Column("step"), Comment("размер шага в секундах")]
public int Step { get; set; }
[Column("format"), Comment("Формат отчета")]
public int Format { get; set; }
[ForeignKey(nameof(IdWell))]
public virtual Well Well { get; set; }
}
}

View File

@ -13,8 +13,8 @@ namespace AsbCloudDb.Model
[Column("id")]
public int Id { get; set; }
[Column("id_customer")]
public int? IdCustomer { get; set; }
[Column("id_company")]
public int? IdCompany { get; set; }
[Column("id_role")]
public int? IdRole { get; set; }
@ -46,9 +46,9 @@ namespace AsbCloudDb.Model
[StringLength(255)]
public string Patronymic { get; set; }
[ForeignKey(nameof(IdCustomer))]
[InverseProperty(nameof(Model.Customer.Users))]
public virtual Customer Customer { get; set; }
[ForeignKey(nameof(IdCompany))]
[InverseProperty(nameof(Model.Company.Users))]
public virtual Company Company { get; set; }
[ForeignKey(nameof(IdRole))]
[InverseProperty(nameof(Model.UserRole.Users))]

View File

@ -1,4 +1,6 @@
using Microsoft.EntityFrameworkCore;
using AsbCloudDb.Model.Analytics;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@ -30,10 +32,6 @@ namespace AsbCloudDb.Model
[InverseProperty(nameof(Model.Cluster.Wells))]
public virtual Cluster Cluster { get; set; }
[ForeignKey(nameof(IdCustomer))]
[InverseProperty(nameof(Model.Customer.Wells))]
public virtual Customer Customer { get; set; }
[ForeignKey(nameof(IdTelemetry))]
[InverseProperty(nameof(Model.Telemetry.Well))]
public virtual Telemetry Telemetry { get; set; }
@ -43,5 +41,14 @@ namespace AsbCloudDb.Model
[Column("longitude")]
public double Longitude { get; set; }
[InverseProperty(nameof(Analytics.WellSection.Well))]
public virtual ICollection<WellSection> SectionAnalysis { get; set; }
[InverseProperty(nameof(Analytics.WellDrillingStat.Well))]
public virtual WellDrillingStat WellDrillingStat { get; set; }
[Column("companines"), Comment("участники (заказчик, подрядчики и субподрядчики)")]
public virtual ICollection<Company> Companies { get; set; }
}
}

View File

@ -29,7 +29,7 @@ namespace AsbSaubReport
var well = context.Wells
.Include(w=>w.Cluster)
.ThenInclude(c=>c.Deposit)
.Include(w=>w.Customer)
.Include(w=>w.Companies)
.Include(w => w.Telemetry)
.FirstOrDefault(w => w.Id == wellId);
@ -50,7 +50,7 @@ namespace AsbSaubReport
Deposit = well.Cluster.Deposit.Caption,
Cluster = well.Cluster.Caption,
Well = well.Caption,
Customer = well.Customer.Caption,
Customer = well.Companies.First(c=>c.IdCompanyType == 1)?.Caption,
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate??default,
TimeZoneId = well.Telemetry?.Info?.TimeZoneId??default,
};

View File

@ -45,7 +45,7 @@ namespace AsbCloudInfrastructure.Services
{
Id = identity.User.Id,
Name = identity.User.Name,
CustomerName = identity.User.Customer.Caption,
CustomerName = identity.User.Company.Caption,
Level = identity.User.Level,
Login = identity.User.Login,
Patronymic = identity.User.Patronymic,
@ -81,7 +81,7 @@ namespace AsbCloudInfrastructure.Services
var user = new User
{
IdCustomer = userDto.IdCustomer,
IdCompany = userDto.IdCustomer,
IdRole = userDto.IdRole,
Name = userDto.Name,
Surname = userDto.Surname,
@ -159,7 +159,7 @@ namespace AsbCloudInfrastructure.Services
{
new Claim(ClaimsIdentity.DefaultNameClaimType, user.Login),
new Claim(ClaimsIdentity.DefaultRoleClaimType, user.Role?.Caption??"GUEST"),
new Claim(claimNameIdCustomer, user.IdCustomer.ToString()),
new Claim(claimNameIdCustomer, user.IdCompany.ToString()),
};
var claimsIdentity = new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType, ClaimsIdentity.DefaultRoleClaimType);
return (claimsIdentity, user);

View File

@ -50,7 +50,7 @@ namespace AsbCloudInfrastructure.Services
var newReportProperties = new Report
{
Name = newReportName,
WellId = wellId,
IdWell = wellId,
Date = DateTime.Now,
Begin = begin,
End = end,
@ -81,7 +81,7 @@ namespace AsbCloudInfrastructure.Services
Id = r.Id,
Name = Path.GetFileName(r.Name),
FullName = r.Name,
WellId = r.WellId,
WellId = r.IdWell,
Date = r.Date,
Begin = r.Begin,
End = r.End,
@ -120,7 +120,7 @@ namespace AsbCloudInfrastructure.Services
private IEnumerable<Report> GetSuitableReportsFromDb(int wellId, DateTime begin, DateTime end, int stepSeconds, int format)
{
var suitableReportsNames = (from r in db.Reports
where r.WellId == wellId
where r.IdWell == wellId
&& r.Begin >= begin
&& r.End <= end
&& r.Step <= stepSeconds

View File

@ -1,6 +1,8 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.Analytics;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using AsbCloudDb.Model.Analytics;
using AsbCloudInfrastructure.Services.Cache;
using Microsoft.EntityFrameworkCore;
using System;
@ -94,7 +96,7 @@ namespace AsbCloudInfrastructure.Services
return dtos;
}
public IEnumerable<ClusterAnalysisDto> GetAnalysis(int idCustomer, int clusterId)
public IEnumerable<WellDrillingStatDto> GetAnalysis(int idCustomer, int clusterId)
{
throw new NotImplementedException();
}

View File

@ -1,5 +1,7 @@
using AsbCloudApp.Data;
using AsbCloudApp.Data.Analytics;
using AsbCloudApp.Services;
using AsbCloudDb.Model.Analytics;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -66,7 +68,7 @@ namespace AsbCloudWebApi.Controllers
/// <param name="clusterId"></param>
/// <returns></returns>
[HttpGet("{clusterId}/Analysis")]
[ProducesResponseType(typeof(IEnumerable<ClusterAnalysisDto>), (int)System.Net.HttpStatusCode.OK)]
[ProducesResponseType(typeof(IEnumerable<WellDrillingStatDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetAnalysis(int clusterId)
{
int? idCustomer = User.GetCustomerId();

View File

@ -7,7 +7,7 @@ namespace AsbCloudWebApi
{
public static int? GetCustomerId(this ClaimsPrincipal user)
{
var claimIdCustomer = user.FindFirst(nameof(User.IdCustomer));
var claimIdCustomer = user.FindFirst(nameof(User.IdCompany));
if (claimIdCustomer is null)
return null;

View File

@ -10,9 +10,9 @@ namespace DataTable
{
class Program
{
static void Main(string[] args)
static void Main(/*string[] args*/)
{
var listDtos = new List<TestDto>(100);
//var listDtos = new List<TestDto>(100);
/* *** Size of TestDto calc ***
*
@ -52,40 +52,40 @@ namespace DataTable
* listBinBytes: 4366 (by dangerous BinaryFormatter)
*/
for (int i = 0; i < 100; i++)
listDtos.Add(new TestDto{
Date = DateTime.Now.AddSeconds(i),
Mode = 1,
WellDepth = i * Math.PI
});
//for (int i = 0; i < 100; i++)
// listDtos.Add(new TestDto{
// Date = DateTime.Now.AddSeconds(i),
// Mode = 1,
// WellDepth = i * Math.PI
// });
var tMapper = new TableMapper<TestDto>();
//var tMapper = new TableMapper<TestDto>();
var tab = tMapper.MakeTable(listDtos);
//var tab = tMapper.MakeTable(listDtos);
var e = tMapper.AsEnumerable(tab);
//var e = tMapper.AsEnumerable(tab);
var tabJson = JsonSerializer.Serialize(tab);
var listJson = JsonSerializer.Serialize(listDtos);
//var tabJson = JsonSerializer.Serialize(tab);
//var listJson = JsonSerializer.Serialize(listDtos);
var tabJsonBytes = JsonSerializer.SerializeToUtf8Bytes(tab);
var listJsonBytes = JsonSerializer.SerializeToUtf8Bytes(listDtos);
//var tabJsonBytes = JsonSerializer.SerializeToUtf8Bytes(tab);
//var listJsonBytes = JsonSerializer.SerializeToUtf8Bytes(listDtos);
var formatter = new BinaryFormatter();
var mem = new MemoryStream();
formatter.Serialize(mem, tab);
var tabBinBytes = new byte[mem.Length];
Array.Copy(mem.GetBuffer(), tabBinBytes, mem.Length);
//var formatter = new BinaryFormatter();
//var mem = new MemoryStream();
//formatter.Serialize(mem, tab);
//var tabBinBytes = new byte[mem.Length];
//Array.Copy(mem.GetBuffer(), tabBinBytes, mem.Length);
mem = new MemoryStream();
formatter.Serialize(mem, listDtos);
var listBinBytes = new byte[mem.Length];
Array.Copy(mem.GetBuffer(), listBinBytes, mem.Length);
//mem = new MemoryStream();
//formatter.Serialize(mem, listDtos);
//var listBinBytes = new byte[mem.Length];
//Array.Copy(mem.GetBuffer(), listBinBytes, mem.Length);
Console.WriteLine($"tabJsonBytes:{tabJsonBytes.Length}");
Console.WriteLine($"listJsonBytes:{listJsonBytes.Length}");
Console.WriteLine($"tabBinBytes:{tabBinBytes.Length}");
Console.WriteLine($"listBinBytes:{listBinBytes.Length}");
//Console.WriteLine($"tabJsonBytes:{tabJsonBytes.Length}");
//Console.WriteLine($"listJsonBytes:{listJsonBytes.Length}");
//Console.WriteLine($"tabBinBytes:{tabBinBytes.Length}");
//Console.WriteLine($"listBinBytes:{listBinBytes.Length}");
}
}
}