CS2-28 Починить библиотеку генерации репортов

This commit is contained in:
Фролов 2021-07-23 14:55:31 +05:00
parent 2d2a7d744e
commit 1d69ddf4e5
18 changed files with 159 additions and 166 deletions

View File

@ -21,24 +21,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AsbSaubReport"> <Folder Include="CommonLibs\" />
<HintPath>CommonLibs\AsbSaubReport\AsbSaubReport.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="CommonLibs\AsbSaubReport\Resources\logo.jpg"> <Reference Include="AsbSaubReport">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <HintPath>CommonLibs\AsbSaubReport.dll</HintPath>
</None> </Reference>
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Bold.ttf"> <Reference Include="AsbSaubReportLas">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <HintPath>CommonLibs\AsbSaubReportLas.dll</HintPath>
</None> </Reference>
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Light.ttf"> <Reference Include="AsbSaubReportPdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <HintPath>CommonLibs\AsbSaubReportPdf.dll</HintPath>
</None> </Reference>
<None Update="CommonLibs\AsbSaubReport\Resources\Roboto-Thin.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View 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": ""
}
}
}

Binary file not shown.

View 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": ""
}
}
}

Binary file not shown.

View File

@ -6,12 +6,13 @@
"compilationOptions": {}, "compilationOptions": {},
"targets": { "targets": {
".NETCoreApp,Version=v5.0": { ".NETCoreApp,Version=v5.0": {
"AsbSaubReport/1.0.0": { "AsbSaubReportPdf/1.0.0": {
"dependencies": { "dependencies": {
"AsbSaubReport": "1.0.0",
"itext7": "7.1.15" "itext7": "7.1.15"
}, },
"runtime": { "runtime": {
"AsbSaubReport.dll": {} "AsbSaubReportPdf.dll": {}
} }
}, },
"Common.Logging/3.4.1": { "Common.Logging/3.4.1": {
@ -742,11 +743,16 @@
"System.Threading": "4.3.0", "System.Threading": "4.3.0",
"System.Xml.ReaderWriter": "4.3.0" "System.Xml.ReaderWriter": "4.3.0"
} }
},
"AsbSaubReport/1.0.0": {
"runtime": {
"AsbSaubReport.dll": {}
}
} }
} }
}, },
"libraries": { "libraries": {
"AsbSaubReport/1.0.0": { "AsbSaubReportPdf/1.0.0": {
"type": "project", "type": "project",
"serviceable": false, "serviceable": false,
"sha512": "" "sha512": ""
@ -1282,6 +1288,11 @@
"sha512": "sha512-lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==", "sha512": "sha512-lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==",
"path": "system.xml.xmldocument/4.3.0", "path": "system.xml.xmldocument/4.3.0",
"hashPath": "system.xml.xmldocument.4.3.0.nupkg.sha512" "hashPath": "system.xml.xmldocument.4.3.0.nupkg.sha512"
},
"AsbSaubReport/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
} }
} }
} }

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

@ -51,12 +51,38 @@ namespace AsbSaubReport
Deposit = well.Cluster.Deposit.Caption, Deposit = well.Cluster.Deposit.Caption,
Cluster = well.Cluster.Caption, Cluster = well.Cluster.Caption,
Well = well.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, DrillingStartDate = well.Telemetry?.Info?.DrillingStartDate ?? default,
TimeZoneId = well.Telemetry?.Info?.TimeZoneId ?? 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) public IQueryable<DataSaubReport> GetDataSaubItems(DateTime begin, DateTime end)
=> from item in context.DataSaubBases => from item in context.DataSaubBases
where item.IdTelemetry == idTelemetry where item.IdTelemetry == idTelemetry

View File

@ -2,6 +2,7 @@
using AsbCloudApp.Services; using AsbCloudApp.Services;
using AsbCloudDb.Model; using AsbCloudDb.Model;
using AsbSaubReport; using AsbSaubReport;
using AsbSaubReportPdf;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System; using System;
@ -134,25 +135,27 @@ namespace AsbCloudInfrastructure.Services
private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context) private IReportGenerator GetReportGenerator(int wellId, DateTime begin, DateTime end, int stepSeconds, int format, AsbCloudDbContext context)
{ {
var dataSource = new ReportDataSourcePgCloud(context, wellId); 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) switch (format)
{ {
case 0: case 1: //LAS
return generator; generator = new AsbSaubReportLas.LasReprotGenerator(dataSource);
case 1: break;
return generator; case 0: //PDF
default: 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;
} }
} }
} }

View File

@ -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; }
}
}

View File

@ -15,11 +15,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\AsbCloudApp\AsbCloudApp.csproj" /> <Reference Include="AsbSaubReport">
<ProjectReference Include="..\AsbCloudDb\AsbCloudDb.csproj" /> <HintPath>..\AsbCloudInfrastructure\CommonLibs\AsbSaubReport\AsbSaubReport.dll</HintPath>
<ProjectReference Include="..\AsbCloudInfrastructure\AsbCloudInfrastructure.csproj" /> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Connected Services" /> <WCFMetadata Include="Connected Services" />
</ItemGroup> </ItemGroup>

View File

@ -1,110 +1,50 @@
using AsbCloudApp.Data; //using AsbCloudApp.Data;
using AsbCloudDb.Model; //using AsbCloudDb.Model;
using AsbCloudInfrastructure.Services; //using AsbCloudInfrastructure.Services;
using AsbCloudInfrastructure.Services.Cache; //using AsbCloudInfrastructure.Services.Cache;
using AutoMapper; //using AsbSaubReport;
using Microsoft.EntityFrameworkCore; //using AutoMapper;
//using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace ConsoleApp1 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 class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
var options = new DbContextOptionsBuilder<AsbCloudDbContext>() //var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") // .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
.Options; // .Options;
//var context = new AsbCloudDbContext(options);
var acfg = new MapperConfiguration(cfg => //var wellId = 1;
{ //var dataSource = new ReportDataSourcePgCloud(context, wellId);
cfg.CreateMap<DataSaubBase, DataSaubBaseDto>(); //var generator = new PdfGenerator(dataSource)
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
//{ //{
// IdEvent = 1, // ReportDirectory = $"{wellId}",
// IdTelemetry = 1, // Begin = DateTime.Now.AddYears(-30),
// IdCategory = 1, // End = DateTime.Now.AddYears(30),
// MessageTemplate = "template", // Step = TimeSpan.FromDays(1),
// WithCharts = true,
// WithEvents = true
//}; //};
//context.Events.Update(e).State = EntityState.Added; //generator.OnProgress += Generator_OnProgress;
//context.SaveChanges(); //var s = generator.GetPagesCount();
//var fileName = generator.Make();
//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);
Console.WriteLine("Done. Press any key to quit."); Console.WriteLine("Done. Press any key to quit.");
Console.ReadKey(); Console.ReadKey();
} }
private static void Generator_OnProgress(object sender, (float progress, string operation) e)
{
//throw new NotImplementedException();
}
} }
} }