forked from ddrilling/AsbCloudServer
CS2-28 Починить библиотеку генерации репортов
This commit is contained in:
parent
2d2a7d744e
commit
1d69ddf4e5
@ -21,24 +21,19 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="AsbSaubReport">
|
||||
<HintPath>CommonLibs\AsbSaubReport\AsbSaubReport.dll</HintPath>
|
||||
</Reference>
|
||||
<Folder Include="CommonLibs\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="CommonLibs\AsbSaubReport\Resources\logo.jpg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Bold.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Light.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Thin.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Reference Include="AsbSaubReport">
|
||||
<HintPath>CommonLibs\AsbSaubReport.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AsbSaubReportLas">
|
||||
<HintPath>CommonLibs\AsbSaubReportLas.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AsbSaubReportPdf">
|
||||
<HintPath>CommonLibs\AsbSaubReportPdf.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
23
AsbCloudInfrastructure/CommonLibs/AsbSaubReport.deps.json
Normal file
23
AsbCloudInfrastructure/CommonLibs/AsbSaubReport.deps.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"runtime": {
|
||||
"AsbSaubReport.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll
Normal file
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll
Normal file
Binary file not shown.
Binary file not shown.
36
AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.deps.json
Normal file
36
AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.deps.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v5.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"AsbSaubReportLas/1.0.0": {
|
||||
"dependencies": {
|
||||
"AsbSaubReport": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"AsbSaubReportLas.dll": {}
|
||||
}
|
||||
},
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"runtime": {
|
||||
"AsbSaubReport.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"AsbSaubReportLas/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll
Normal file
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll
Normal file
Binary file not shown.
@ -6,12 +6,13 @@
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v5.0": {
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"AsbSaubReportPdf/1.0.0": {
|
||||
"dependencies": {
|
||||
"AsbSaubReport": "1.0.0",
|
||||
"itext7": "7.1.15"
|
||||
},
|
||||
"runtime": {
|
||||
"AsbSaubReport.dll": {}
|
||||
"AsbSaubReportPdf.dll": {}
|
||||
}
|
||||
},
|
||||
"Common.Logging/3.4.1": {
|
||||
@ -742,11 +743,16 @@
|
||||
"System.Threading": "4.3.0",
|
||||
"System.Xml.ReaderWriter": "4.3.0"
|
||||
}
|
||||
},
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"runtime": {
|
||||
"AsbSaubReport.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"AsbSaubReportPdf/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
@ -1282,6 +1288,11 @@
|
||||
"sha512": "sha512-lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==",
|
||||
"path": "system.xml.xmldocument/4.3.0",
|
||||
"hashPath": "system.xml.xmldocument.4.3.0.nupkg.sha512"
|
||||
},
|
||||
"AsbSaubReport/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll
Normal file
BIN
AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll
Normal file
Binary file not shown.
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
BIN
AsbCloudInfrastructure/CommonLibs/ref/AsbSaubReportPdf.dll
Normal file
BIN
AsbCloudInfrastructure/CommonLibs/ref/AsbSaubReportPdf.dll
Normal file
Binary file not shown.
@ -51,12 +51,38 @@ namespace AsbSaubReport
|
||||
Deposit = well.Cluster.Deposit.Caption,
|
||||
Cluster = well.Cluster.Caption,
|
||||
Well = well.Caption,
|
||||
Customer = well.RelationCompaniesWells.First(c => c.Company.IdCompanyType == 1)?.Company.Caption,
|
||||
Customer = well.RelationCompaniesWells.FirstOrDefault(c => c.Company.IdCompanyType == 1)?.Company.Caption,
|
||||
DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate ?? default,
|
||||
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? default,
|
||||
};
|
||||
}
|
||||
|
||||
public AnalyzeResult Analyze()
|
||||
{
|
||||
var messagesQuery = from item in context.Messages
|
||||
where item.IdTelemetry == idTelemetry
|
||||
select item;
|
||||
|
||||
var messagesCount = messagesQuery.Count();
|
||||
var messagesMinDate = messagesQuery.Min(e=>e.Date);
|
||||
var messagesMaxDate = messagesQuery.Max(e=>e.Date);
|
||||
|
||||
var dataQuery = from item in context.DataSaubBases
|
||||
where item.IdTelemetry == idTelemetry
|
||||
select item;
|
||||
|
||||
var dataMinDate = dataQuery.Min(e => e.Date);
|
||||
var dataMaxDate = dataQuery.Max(e => e.Date);
|
||||
|
||||
var result = new AnalyzeResult {
|
||||
MaxDate = dataMinDate < messagesMinDate ? dataMinDate : messagesMinDate,
|
||||
MinDate = dataMaxDate > messagesMaxDate ? dataMaxDate : messagesMaxDate,
|
||||
MessagesCount = messagesCount,
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IQueryable<DataSaubReport> GetDataSaubItems(DateTime begin, DateTime end)
|
||||
=> from item in context.DataSaubBases
|
||||
where item.IdTelemetry == idTelemetry
|
||||
|
@ -2,6 +2,7 @@
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbSaubReport;
|
||||
using AsbSaubReportPdf;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
@ -134,25 +135,27 @@ namespace AsbCloudInfrastructure.Services
|
||||
private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context)
|
||||
{
|
||||
var dataSource = new ReportDataSourcePgCloud(context, wellId);
|
||||
var generator = new PdfGenerator(dataSource)
|
||||
{
|
||||
ReportDirectory = Path.Combine(RootPath, $"{wellId}"),
|
||||
Begin = begin,
|
||||
End = end,
|
||||
Step = TimeSpan.FromSeconds(stepSeconds),
|
||||
WithCharts = true,
|
||||
WithEvents = true
|
||||
};
|
||||
|
||||
IReportGenerator generator;
|
||||
switch (format)
|
||||
{
|
||||
case 0:
|
||||
return generator;
|
||||
case 1:
|
||||
return generator;
|
||||
case 1: //LAS
|
||||
generator = new AsbSaubReportLas.LasReprotGenerator(dataSource);
|
||||
break;
|
||||
case 0: //PDF
|
||||
default:
|
||||
return generator;
|
||||
generator = new PdfReprotGenerator(dataSource);
|
||||
break;
|
||||
}
|
||||
|
||||
generator.ReportDirectory = Path.Combine(RootPath, $"{wellId}");
|
||||
generator.Begin = begin;
|
||||
generator.End = end;
|
||||
generator.Step = TimeSpan.FromSeconds(stepSeconds);
|
||||
generator.WithCharts = true;
|
||||
generator.WithEvents = true;
|
||||
|
||||
return generator;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public enum WellDepthState { Idle, Increase }
|
||||
public enum BitDepthState { Idle, Increase, Decrease, OnSurface }
|
||||
public enum BlockState { Idle, Increase, Decrease }
|
||||
public enum RotorState { Inactive, Active }
|
||||
public enum PressureState { Inactive, Active }
|
||||
public enum HookWeightState { Idle, None }
|
||||
public enum DrillingOperation
|
||||
{
|
||||
Unknown,
|
||||
RotorDrilling,
|
||||
SlideDrilling,
|
||||
TrippingOutReaming,
|
||||
TrippingInReaming,
|
||||
TrippingOutCirculating,
|
||||
TrippingInCirculating,
|
||||
TrippingOut,
|
||||
TrippingIn,
|
||||
Circulating,
|
||||
CirculatingRotating,
|
||||
Hold,
|
||||
Static,
|
||||
Rotating,
|
||||
OnTheSurface,
|
||||
}
|
||||
|
||||
public class AnalyzeResult
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public WellDepthState WellDepthState { get; set; }
|
||||
public BitDepthState BitDepthState { get; set; }
|
||||
public BlockState BlockState { get; set; }
|
||||
public RotorState RotorState { get; set; }
|
||||
public PressureState PressureState { get; set; }
|
||||
public HookWeightState HookWeightState { get; set; }
|
||||
public DrillingOperation DrillingOperation { get; set; }
|
||||
}
|
||||
}
|
@ -15,11 +15,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AsbCloudApp\AsbCloudApp.csproj" />
|
||||
<ProjectReference Include="..\AsbCloudDb\AsbCloudDb.csproj" />
|
||||
<ProjectReference Include="..\AsbCloudInfrastructure\AsbCloudInfrastructure.csproj" />
|
||||
<Reference Include="AsbSaubReport">
|
||||
<HintPath>..\AsbCloudInfrastructure\CommonLibs\AsbSaubReport\AsbSaubReport.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services" />
|
||||
</ItemGroup>
|
||||
|
@ -1,110 +1,50 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure.Services;
|
||||
using AsbCloudInfrastructure.Services.Cache;
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
//using AsbCloudApp.Data;
|
||||
//using AsbCloudDb.Model;
|
||||
//using AsbCloudInfrastructure.Services;
|
||||
//using AsbCloudInfrastructure.Services.Cache;
|
||||
//using AsbSaubReport;
|
||||
//using AutoMapper;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public class A
|
||||
{
|
||||
public int P1 { get; set; }
|
||||
public int P2 { get; set; }
|
||||
};
|
||||
|
||||
public class B
|
||||
{
|
||||
public int P1 { get; set; }
|
||||
public int P3 { get; set; }
|
||||
};
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||
.Options;
|
||||
//var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||
// .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||
// .Options;
|
||||
//var context = new AsbCloudDbContext(options);
|
||||
|
||||
var acfg = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<DataSaubBase, DataSaubBaseDto>();
|
||||
cfg.CreateMap<DataSaubBaseDto, DataSaubBase>();
|
||||
|
||||
cfg.CreateMap<Message, TelemetryMessageDto>();
|
||||
cfg.CreateMap<TelemetryMessageDto, Message>();
|
||||
|
||||
cfg.CreateMap<TelemetryInfo, TelemetryInfoDto>();
|
||||
cfg.CreateMap<TelemetryInfoDto, TelemetryInfo>();
|
||||
});
|
||||
|
||||
|
||||
var context = new AsbCloudDbContext(options);
|
||||
var cachedDb = new CacheDb();
|
||||
var telemetryService = new TelemetryService(context, cachedDb, acfg);
|
||||
var telemetryUserService = new TelemetryUserService(context, cachedDb, telemetryService);
|
||||
|
||||
var tusers = new List<TelemetryUserDto> {
|
||||
new TelemetryUserDto{
|
||||
Id=1,
|
||||
Level=0,
|
||||
Name="Adminum",
|
||||
},
|
||||
new TelemetryUserDto{
|
||||
Id=2,
|
||||
Level=0,
|
||||
Name="Adminum2",
|
||||
},
|
||||
};
|
||||
|
||||
telemetryUserService.Upsert("123", tusers);
|
||||
tusers[0].Patronymic = "Trump";
|
||||
|
||||
|
||||
telemetryUserService.Upsert("123", tusers);
|
||||
|
||||
|
||||
//var e = new Event
|
||||
//var wellId = 1;
|
||||
//var dataSource = new ReportDataSourcePgCloud(context, wellId);
|
||||
//var generator = new PdfGenerator(dataSource)
|
||||
//{
|
||||
// IdEvent = 1,
|
||||
// IdTelemetry = 1,
|
||||
// IdCategory = 1,
|
||||
// MessageTemplate = "template",
|
||||
// ReportDirectory = $"{wellId}",
|
||||
// Begin = DateTime.Now.AddYears(-30),
|
||||
// End = DateTime.Now.AddYears(30),
|
||||
// Step = TimeSpan.FromDays(1),
|
||||
// WithCharts = true,
|
||||
// WithEvents = true
|
||||
//};
|
||||
|
||||
//context.Events.Update(e).State = EntityState.Added;
|
||||
//context.SaveChanges();
|
||||
|
||||
|
||||
//var table = new Table
|
||||
//{
|
||||
// Headers = new List<Header>
|
||||
// {
|
||||
// new Header {Name = "P1", PropertyType = typeof(int) },
|
||||
// new Header {Name = "P2", PropertyType = typeof(int) },
|
||||
// new Header {Name = "P3", PropertyType = typeof(int) },
|
||||
// },
|
||||
|
||||
// Rows = new List<object[]>
|
||||
// {
|
||||
// new object[] {1,2,3 },
|
||||
// new object[] {4,5,6 },
|
||||
// new object[] {7,8,9 },
|
||||
// }
|
||||
//};
|
||||
//var mapper = new TableMapper<B>();
|
||||
|
||||
//var b = new B();
|
||||
//mapper.UpdateObjectFromTable(ref b, table, 1);
|
||||
//generator.OnProgress += Generator_OnProgress;
|
||||
//var s = generator.GetPagesCount();
|
||||
//var fileName = generator.Make();
|
||||
|
||||
|
||||
Console.WriteLine("Done. Press any key to quit.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
|
||||
private static void Generator_OnProgress(object sender, (float progress, string operation) e)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user