diff --git a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj index 42d9a0ad..4e85eada 100644 --- a/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj +++ b/AsbCloudInfrastructure/AsbCloudInfrastructure.csproj @@ -21,24 +21,19 @@ - - CommonLibs\AsbSaubReport\AsbSaubReport.dll - + - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + CommonLibs\AsbSaubReport.dll + + + CommonLibs\AsbSaubReportLas.dll + + + CommonLibs\AsbSaubReportPdf.dll + diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.deps.json b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.deps.json new file mode 100644 index 00000000..91ea443c --- /dev/null +++ b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.deps.json @@ -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": "" + } + } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll new file mode 100644 index 00000000..7afa6411 Binary files /dev/null and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport.dll differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.dll deleted file mode 100644 index a9cc0fbf..00000000 Binary files a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.dll and /dev/null differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.deps.json b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.deps.json new file mode 100644 index 00000000..c0fa340e --- /dev/null +++ b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.deps.json @@ -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": "" + } + } +} \ No newline at end of file diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll new file mode 100644 index 00000000..5c4a9da1 Binary files /dev/null and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportLas.dll differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.deps.json b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.deps.json similarity index 99% rename from AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.deps.json rename to AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.deps.json index 314afa14..f1011029 100644 --- a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/AsbSaubReport.deps.json +++ b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.deps.json @@ -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": "" } } } \ No newline at end of file diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll new file mode 100644 index 00000000..e72238f5 Binary files /dev/null and b/AsbCloudInfrastructure/CommonLibs/AsbSaubReportPdf.dll differ diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Bold.ttf b/AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Bold.ttf similarity index 100% rename from AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Bold.ttf rename to AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Bold.ttf diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Light.ttf b/AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Light.ttf similarity index 100% rename from AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Light.ttf rename to AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Light.ttf diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Thin.ttf b/AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Thin.ttf similarity index 100% rename from AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/Roboto-Thin.ttf rename to AsbCloudInfrastructure/CommonLibs/Resources/Roboto-Thin.ttf diff --git a/AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/logo.jpg b/AsbCloudInfrastructure/CommonLibs/Resources/logo.jpg similarity index 100% rename from AsbCloudInfrastructure/CommonLibs/AsbSaubReport/Resources/logo.jpg rename to AsbCloudInfrastructure/CommonLibs/Resources/logo.jpg diff --git a/AsbCloudInfrastructure/CommonLibs/ref/AsbSaubReportPdf.dll b/AsbCloudInfrastructure/CommonLibs/ref/AsbSaubReportPdf.dll new file mode 100644 index 00000000..e369f3e5 Binary files /dev/null and b/AsbCloudInfrastructure/CommonLibs/ref/AsbSaubReportPdf.dll differ diff --git a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs index 0c7bb846..ca04d379 100644 --- a/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs +++ b/AsbCloudInfrastructure/ReportDataSourcePgCloud.cs @@ -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 GetDataSaubItems(DateTime begin, DateTime end) => from item in context.DataSaubBases where item.IdTelemetry == idTelemetry diff --git a/AsbCloudInfrastructure/Services/ReportService.cs b/AsbCloudInfrastructure/Services/ReportService.cs index 06a14f34..d6150f93 100644 --- a/AsbCloudInfrastructure/Services/ReportService.cs +++ b/AsbCloudInfrastructure/Services/ReportService.cs @@ -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; } } } diff --git a/ConsoleApp1/AnalyzeResult.cs b/ConsoleApp1/AnalyzeResult.cs deleted file mode 100644 index 0dfe9eea..00000000 --- a/ConsoleApp1/AnalyzeResult.cs +++ /dev/null @@ -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; } - } -} diff --git a/ConsoleApp1/ConsoleApp1.csproj b/ConsoleApp1/ConsoleApp1.csproj index 18a52da0..0ea94f9a 100644 --- a/ConsoleApp1/ConsoleApp1.csproj +++ b/ConsoleApp1/ConsoleApp1.csproj @@ -15,11 +15,12 @@ - - - + + ..\AsbCloudInfrastructure\CommonLibs\AsbSaubReport\AsbSaubReport.dll + + diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index ea1428e4..073e92e0 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -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() - .UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True") - .Options; + //var options = new DbContextOptionsBuilder() + // .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(); - cfg.CreateMap(); - - cfg.CreateMap(); - cfg.CreateMap(); - - cfg.CreateMap(); - cfg.CreateMap(); - }); - - - 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 { - 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
- // { - // new Header {Name = "P1", PropertyType = typeof(int) }, - // new Header {Name = "P2", PropertyType = typeof(int) }, - // new Header {Name = "P3", PropertyType = typeof(int) }, - // }, - - // Rows = new List - // { - // new object[] {1,2,3 }, - // new object[] {4,5,6 }, - // new object[] {7,8,9 }, - // } - //}; - //var mapper = new TableMapper(); - - //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(); + } } }