From c4b9933eb0d5b3de2862b78b49f8272d1e121609 Mon Sep 17 00:00:00 2001 From: Stoyan Zlatev Date: Thu, 6 Apr 2023 17:02:58 +0200 Subject: [PATCH] Helium Pressure Report --- .../LaaProductionWeb.Data/DbContext.cs | 34 ++--- .../Interfaces/IDbContext.cs | 8 +- .../ParameterCollection.cs | 5 +- .../LaaProductionWeb.Data/SqlReader.cs | 16 ++- .../Interfaces/IReportService.cs | 13 ++ .../LaaProductionWeb.Services.csproj | 8 ++ .../Models/HeliumPressurePoint.cs | 11 ++ .../Models/HeliumReportFilter.cs | 109 ++++++++++++++++ .../Models/HeliumReportFilterProperty.cs | 32 +++++ .../Models/HeliumReportItem.cs | 85 +++++++++++++ .../Models/HeliumReportModel.cs | 38 ++++++ .../Models/HeliumReportModelExtensions.cs | 32 +++++ .../ReportService.cs | 109 ++++++++++++++++ .../App_Content/css/styles.css | 18 ++- .../ControllersExtensions.cs | 23 ++++ .../Controllers/ReportController.cs | 38 ++++++ .../LaaProductionWeb/LaaProductionWeb.csproj | 4 + .../LaaProductionWeb/Views/Home/Index.cshtml | 6 +- .../Views/Protocol/Document.cshtml | 26 ++-- .../Views/Protocol/Index.cshtml | 7 +- .../Views/Report/Filter.cshtml | 25 ++++ .../Views/Report/Index.cshtml | 120 ++++++++++++++++++ .../Views/Report/Results.cshtml | 10 ++ .../Views/Shared/_Layout.cshtml | 3 + 24 files changed, 736 insertions(+), 44 deletions(-) create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Interfaces/IReportService.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumPressurePoint.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportItem.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModel.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs create mode 100644 LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs create mode 100644 LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs create mode 100644 LaaProductionWeb/LaaProductionWeb/Views/Report/Filter.cshtml create mode 100644 LaaProductionWeb/LaaProductionWeb/Views/Report/Index.cshtml create mode 100644 LaaProductionWeb/LaaProductionWeb/Views/Report/Results.cshtml diff --git a/LaaProductionWeb/LaaProductionWeb.Data/DbContext.cs b/LaaProductionWeb/LaaProductionWeb.Data/DbContext.cs index deec32c4..879f612f 100644 --- a/LaaProductionWeb/LaaProductionWeb.Data/DbContext.cs +++ b/LaaProductionWeb/LaaProductionWeb.Data/DbContext.cs @@ -13,7 +13,7 @@ public DbContext(string connectionString) => this.connectionString = connectionString; - public IEnumerable AsEnumerable(string query, Action parameters, Func reader) + public IEnumerable AsEnumerable(string query, Action parameters, Func reader) { using (var sqlConnection = new SqlConnection(this.connectionString)) { @@ -23,13 +23,13 @@ { sqlCommand.CommandText = query; - parameters(new ParameterCollection(sqlCommand.Parameters)); + parameters(sqlCommand.Parameters); - using (var sqlDataReader = sqlCommand.ExecuteReader()) + using (SqlReader sqlReader = sqlCommand.ExecuteReader()) { - while (sqlDataReader.Read()) + while (sqlReader.Read()) { - yield return reader(new SqlReader(sqlDataReader)); + yield return reader(sqlReader); } } } @@ -46,18 +46,18 @@ { sqlCommand.CommandText = query; - using (var sqlDataReader = sqlCommand.ExecuteReader()) + using (SqlReader sqlReader = sqlCommand.ExecuteReader()) { - while (sqlDataReader.Read()) + while (sqlReader.Read()) { - yield return reader(new SqlReader(sqlDataReader)); + yield return reader(sqlReader); } } } } } - public T FirstOrDefault(string query, Action parameters, Func reader) + public T FirstOrDefault(string query, Action parameters, Func reader) { var firstOrDefaultResult = default(T); @@ -69,13 +69,13 @@ { sqlCommand.CommandText = query; - parameters(new ParameterCollection(sqlCommand.Parameters)); + parameters(sqlCommand.Parameters); - using (var sqlDataReader = sqlCommand.ExecuteReader()) + using (SqlReader sqlReader = sqlCommand.ExecuteReader()) { - if (sqlDataReader.Read()) + if (sqlReader.Read()) { - firstOrDefaultResult = reader(new SqlReader(sqlDataReader)); + firstOrDefaultResult = reader(sqlReader); } } } @@ -84,7 +84,7 @@ return firstOrDefaultResult; } - public T ScalarTransaction(string query, Action parameters) + public T ScalarTransaction(string query, Action parameters) { var scalarResult = default(T); @@ -99,7 +99,7 @@ sqlCommand.Transaction = sqlTransaction; sqlCommand.CommandText = query; - parameters(new ParameterCollection(sqlCommand.Parameters)); + parameters(sqlCommand.Parameters); var scalarObject = sqlCommand.ExecuteScalar(); @@ -116,7 +116,7 @@ return scalarResult; } - public bool Transaction(string query, Action parameters) + public bool Transaction(string query, Action parameters) { var canCommitTransaction = true; @@ -131,7 +131,7 @@ sqlCommand.Transaction = sqlTransaction; sqlCommand.CommandText = query; - parameters(new ParameterCollection(sqlCommand.Parameters)); + parameters(sqlCommand.Parameters); sqlCommand.ExecuteNonQuery(); } diff --git a/LaaProductionWeb/LaaProductionWeb.Data/Interfaces/IDbContext.cs b/LaaProductionWeb/LaaProductionWeb.Data/Interfaces/IDbContext.cs index 51c7040e..9b32c72e 100644 --- a/LaaProductionWeb/LaaProductionWeb.Data/Interfaces/IDbContext.cs +++ b/LaaProductionWeb/LaaProductionWeb.Data/Interfaces/IDbContext.cs @@ -5,14 +5,14 @@ public interface IDbContext { - IEnumerable AsEnumerable(string query, Action parameters, Func reader); + IEnumerable AsEnumerable(string query, Action parameters, Func reader); IEnumerable AsEnumerable(string query, Func reader); - T FirstOrDefault(string query, Action parameters, Func reader); + T FirstOrDefault(string query, Action parameters, Func reader); - T ScalarTransaction(string query, Action parameters); + T ScalarTransaction(string query, Action parameters); - bool Transaction(string query, Action parameters); + bool Transaction(string query, Action parameters); } } diff --git a/LaaProductionWeb/LaaProductionWeb.Data/ParameterCollection.cs b/LaaProductionWeb/LaaProductionWeb.Data/ParameterCollection.cs index 41c4e99b..38ba97ef 100644 --- a/LaaProductionWeb/LaaProductionWeb.Data/ParameterCollection.cs +++ b/LaaProductionWeb/LaaProductionWeb.Data/ParameterCollection.cs @@ -9,7 +9,7 @@ { private readonly SqlParameterCollection parameters; - public ParameterCollection(SqlParameterCollection parameters) + private ParameterCollection(SqlParameterCollection parameters) => this.parameters = parameters; public IParameterCollection Add(string name, object value) @@ -30,5 +30,8 @@ return this; } + + public static implicit operator ParameterCollection(SqlParameterCollection sqlParameterCollection) + => new ParameterCollection(sqlParameterCollection); } } diff --git a/LaaProductionWeb/LaaProductionWeb.Data/SqlReader.cs b/LaaProductionWeb/LaaProductionWeb.Data/SqlReader.cs index ba07c151..898e0fc5 100644 --- a/LaaProductionWeb/LaaProductionWeb.Data/SqlReader.cs +++ b/LaaProductionWeb/LaaProductionWeb.Data/SqlReader.cs @@ -5,13 +5,19 @@ using System; using System.Data.SqlClient; - public class SqlReader : ISqlReader + public class SqlReader : ISqlReader, IDisposable { private readonly SqlDataReader sqlDataReader; - public SqlReader(SqlDataReader sqlDataReader) + private SqlReader(SqlDataReader sqlDataReader) => this.sqlDataReader = sqlDataReader; + public void Dispose() + { + this.sqlDataReader.Close(); + this.sqlDataReader.Dispose(); + } + public byte[] GetBytes(int index) { var bytes = default(byte[]); @@ -46,5 +52,11 @@ return default(T); } + + internal bool Read() + => this.sqlDataReader.Read(); + + public static implicit operator SqlReader(SqlDataReader sqlDataReader) + => new SqlReader(sqlDataReader); } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Interfaces/IReportService.cs b/LaaProductionWeb/LaaProductionWeb.Services/Interfaces/IReportService.cs new file mode 100644 index 00000000..3c94b121 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Interfaces/IReportService.cs @@ -0,0 +1,13 @@ +namespace LaaProductionWeb.Services.Interfaces +{ + using LaaProductionWeb.Services.Models; + + using System.Collections.Generic; + + public interface IReportService : ITransient + { + HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null); + + IEnumerable LoadHeliumPressureResults(int testId); + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/LaaProductionWeb.Services.csproj b/LaaProductionWeb/LaaProductionWeb.Services/LaaProductionWeb.Services.csproj index 9fc94991..e01a42ec 100644 --- a/LaaProductionWeb/LaaProductionWeb.Services/LaaProductionWeb.Services.csproj +++ b/LaaProductionWeb/LaaProductionWeb.Services/LaaProductionWeb.Services.csproj @@ -61,8 +61,15 @@ + + + + + + + @@ -84,6 +91,7 @@ + diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumPressurePoint.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumPressurePoint.cs new file mode 100644 index 00000000..da698ce1 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumPressurePoint.cs @@ -0,0 +1,11 @@ +namespace LaaProductionWeb.Services.Models +{ + public class HeliumPressurePoint + { + public int TestId { get; set; } + + public int PointNr { get; set; } + + public decimal Result { get; set; } + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs new file mode 100644 index 00000000..c1698fc1 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilter.cs @@ -0,0 +1,109 @@ +namespace LaaProductionWeb.Services.Models +{ + using System.Collections.Generic; + using System.Linq; + + public class HeliumReportFilter : List + { + public HeliumReportFilter() + { + var model = default(HeliumReportItem); + + this.Add(model.Property(x => x.AuftragNr, this.Count)); + this.Add(model.Property(x => x.FertigungNr, this.Count)); + this.Add(model.Property(x => x.PositionNr, this.Count)); + this.Add(model.Property(x => x.SerialNr, this.Count)); + this.Add(model.Property(x => x.IdentNr, this.Count)); + this.Add(model.Property(x => x.HeId, this.Count)); + this.Add(model.Property(x => x.HeTestId, this.Count)); + this.Add(model.Property(x => x.PcbId, this.Count)); + this.Add(model.Property(x => x.Nennweite, this.Count)); + this.Add(model.Property(x => x.Baulaenge, this.Count)); + this.Add(model.Property(x => x.Typ, this.Count)); + this.Add(model.Property(x => x.Druck, this.Count)); + this.Add(model.Property(x => x.Temperatur, this.Count)); + this.Add(model.Property(x => x.HeLakeRate, this.Count)); + this.Add(model.Property(x => x.HeTestPressure, this.Count)); + this.Add(model.Property(x => x.IsValid, this.Count)); + this.Add(model.Property(x => x.Text, this.Count)); + this.Add(model.Property(x => x.TestDate, this.Count, -1)); + this.Add(model.Property(x => x.Tester, this.Count)); + } + + internal SqlExpression OrderBy() + { + var sqlExpression = new SqlExpression(); + + foreach (var property in this) + { + if (property.OrderBy == 1) + { + sqlExpression.Add($"{property.Column}"); + } + else if (property.OrderBy == -1) + { + sqlExpression.Add($"{property.Column} DESC"); + } + } + + return sqlExpression.BuildOrderBy(", "); + } + + internal SqlExpression Where() + { + var sqlExpression = new SqlExpression(); + + foreach (var property in this) + { + if (string.IsNullOrWhiteSpace(property.Like)) + { + continue; + } + + var propertyName = $"{property.Property}_{property.Index}"; + var propertyValue = $"%{property.Like}%"; + + sqlExpression.Add($"{property.Column} LIKE @{propertyName}", propertyName, propertyValue); + } + + return sqlExpression.BuildWhere(" AND "); + } + + public class SqlExpression + { + private readonly ICollection expressions + = new List(); + + public string Query { get; set; } + + public IDictionary Parameters { get; set; } + = new Dictionary(); + + internal void Add(string expression) + => this.expressions.Add(expression); + + internal void Add(string expression, string propertyName, string propertyValue) + { + this.Parameters[propertyName] = propertyValue; + + this.expressions.Add(expression); + } + + internal SqlExpression BuildOrderBy(string delimiter) + { + this.Query = string.Join(delimiter, this.expressions); + + return this; + } + + internal SqlExpression BuildWhere(string delimiter) + { + this.Query = this.expressions.Any() + ? string.Join(delimiter, this.expressions) + : "1 = 1"; + + return this; + } + } + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs new file mode 100644 index 00000000..22ce54d6 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportFilterProperty.cs @@ -0,0 +1,32 @@ +namespace LaaProductionWeb.Services.Models +{ + public class HeliumReportFilterProperty + { + public int Index { get; set; } + + public string IndexName + => $"Filter[{this.Index}].{nameof(this.Index)}"; + + public string Property { get; set; } + + public string PropertyName + => $"Filter[{this.Index}].{nameof(this.Property)}"; + + public string Column { get; set; } + public string ColumnName + => $"Filter[{this.Index}].{nameof(this.Column)}"; + + public string Like { get; set; } + + public string LikeName + => $"Filter[{this.Index}].{nameof(this.Like)}"; + + public int OrderBy { get; set; } + + public string OrderByName + => $"Filter[{this.Index}].{nameof(this.OrderBy)}"; + + public string OrderById + => $"Filter_{this.Index}_{nameof(this.OrderBy)}"; + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportItem.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportItem.cs new file mode 100644 index 00000000..541f4580 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportItem.cs @@ -0,0 +1,85 @@ +namespace LaaProductionWeb.Services.Models +{ + using System; + using System.ComponentModel.DataAnnotations; + using System.ComponentModel.DataAnnotations.Schema; + + public class HeliumReportItem + { + [Display(Name = "Auftrag Nr.")] + [Column("[POS].[AuftragNr]")] + public int AuftragNr { get; set; } + + [Display(Name = "Fertigung Nr.")] + [Column("[PT].[CordonelPressureTest_FertigungsAuftragsNr]")] + public int FertigungNr { get; set; } + + [Display(Name = "Pos.")] + [Column("[POS].[PositionNr]")] + public short PositionNr { get; set; } + + [Display(Name = "Serial Nr.")] + [Column("[PCB2SN].[MapPcbIdToSerialNumber_SerialNumber]")] + public int SerialNr { get; set; } + + [Display(Name = "Ident Nr.")] + [Column("[ID].[IdentNr]")] + public int IdentNr { get; set; } + + [Display(Name = "He Id")] + [Column("[PT_HE].[CordonelPressureTestHe_Id]")] + public int HeId { get; set; } + + [Display(Name = "He TestId")] + [Column("[PT_HE].[CordonelPressureTestHe_TestID]")] + public int HeTestId { get; set; } + + [Display(Name = "Pcb Id")] + [Column("[PT].[CordonelPressureTest_PcbId]")] + public int PcbId { get; set; } + + [Display(Name = "Nennweite")] + [Column("[ID].[Nennweite]")] + public int? Nennweite { get; set; } + + [Display(Name = "Baulänge")] + [Column("[ID].[Baulaenge]")] + public int? Baulaenge { get; set; } + + [Display(Name = "Typ")] + [Column("[ID].[Typ]")] + public string Typ { get; set; } + + [Display(Name = "Druck")] + [Column("[ID].[Druck]")] + public int? Druck { get; set; } + + [Display(Name = "°C")] + [Column("[ID].[Temperatur]")] + public int? Temperatur { get; set; } + + [Display(Name = "Lake Rate")] + [Column("[PT_HE].[CordonelPressureTestHe_LeakRate]")] + public string HeLakeRate { get; set; } + + [Display(Name = "He Druck")] + [Column("[PT_HE].[CordonelPressureTestHe_TestPressure]")] + public string HeTestPressure { get; set; } + + [Display(Name = "Valid")] + [Column("[PT].[CordonelPressureTest_Valid]")] + public bool IsValid { get; set; } + + [Display(Name = "Text")] + [Column("[PT].[CordonelPressureTest_Text]")] + public string Text { get; set; } + + [Display(Name = "Datum")] + [Column("[PT].[CordonelPressureTest_Date]")] + public DateTimeOffset TestDate { get; set; } + + [Display(Name = "Tester")] + [Column("[PT_HE].[CordonelPressureTestHe_TesterName]")] + public string Tester { get; set; } + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModel.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModel.cs new file mode 100644 index 00000000..6ee3b570 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModel.cs @@ -0,0 +1,38 @@ +namespace LaaProductionWeb.Services.Models +{ + using System; + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + using System.Linq.Expressions; + using System.Reflection; + + public class HeliumReportModel + { + public HeliumReportFilter Filter { get; set; } + = new HeliumReportFilter(); + + public IEnumerable Items { get; set; } + = Array.Empty(); + + public static implicit operator HeliumReportModel(HeliumReportFilter filter) + => new HeliumReportModel { Filter = filter }; + + public string Display(Expression> expression) + { + var memberInfo = default(MemberInfo); + + if (expression.Body is MemberExpression memberExpression) + { + memberInfo = memberExpression.Member; + } + else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression) + { + memberInfo = operandExpression.Member; + } + + return memberInfo + ?.GetCustomAttribute() + ?.Name; + } + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs new file mode 100644 index 00000000..27bb85be --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/Models/HeliumReportModelExtensions.cs @@ -0,0 +1,32 @@ +namespace LaaProductionWeb.Services.Models +{ + using System; + using System.ComponentModel.DataAnnotations.Schema; + using System.Linq.Expressions; + using System.Reflection; + + public static class HeliumReportModelExtensions + { + public static HeliumReportFilterProperty Property(this HeliumReportItem model, Expression> expression, int index, int orderBy = 0) + { + var memberInfo = default(MemberInfo); + + if (expression.Body is MemberExpression memberExpression) + { + memberInfo = memberExpression.Member; + } + else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression) + { + memberInfo = operandExpression.Member; + } + + return new HeliumReportFilterProperty + { + Column = memberInfo?.GetCustomAttribute()?.Name, + Property = memberInfo?.Name, + OrderBy = orderBy, + Index = index, + }; + } + } +} diff --git a/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs b/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs new file mode 100644 index 00000000..c6645d31 --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb.Services/ReportService.cs @@ -0,0 +1,109 @@ +namespace LaaProductionWeb.Services +{ + using LaaProductionWeb.Data.Interfaces; + using LaaProductionWeb.Services.Interfaces; + using LaaProductionWeb.Services.Models; + + using System; + using System.Collections.Generic; + + public class ReportService : IReportService + { + private readonly IDbContext dbContext; + + public ReportService(IDbContext dbContext) + => this.dbContext = dbContext; + + public HeliumReportModel LoadHeliumPressureReport(HeliumReportModel model = null) + { + if (model is null) + { + model = new HeliumReportModel(); + } + + var where = model.Filter.Where(); + var orderBy = model.Filter.OrderBy(); + + model.Items = this.dbContext.AsEnumerable($@" + SELECT [POS].[AuftragNr] AS [AuftragNr] -- 0 Filter + , [PT].[CordonelPressureTest_FertigungsAuftragsNr] AS [FertigungNr] -- 1 Filter + , [POS].[PositionNr] AS [PositionNr] -- 2 Filter + , [PCB2SN].[MapPcbIdToSerialNumber_SerialNumber] AS [SerialNr] -- 3 + , [ID].[IdentNr] AS [IdentNr] -- 4 Filter + , [PT_HE].[CordonelPressureTestHe_Id] AS [HeId] -- 5 + , [PT_HE].[CordonelPressureTestHe_TestID] AS [HeTestId] -- 6 + , [PT].[CordonelPressureTest_PcbId] AS [PcbId] -- 7 Filter + , [ID].[Nennweite] AS [Nennweite] -- 8 Filter + , [ID].[Baulaenge] AS [Baulaenge] -- 9 Filter + , [ID].[Typ] AS [Typ] -- 10 Filter + , [ID].[Druck] AS [Druck] -- 11 Filter + , [ID].[Temperatur] AS [Temperatur] -- 12 Filter + , [PT_HE].[CordonelPressureTestHe_LeakRate] AS [HeLakeRate] -- 13 + , [PT_HE].[CordonelPressureTestHe_TestPressure] AS [HeTestPressure] -- 14 + , [PT].[CordonelPressureTest_Valid] AS [IsValid] -- 15 Filter + , [PT].[CordonelPressureTest_Text] AS [Text] -- 16 Filter + , [PT].[CordonelPressureTest_Date] AS [TestDate] -- 17 Filter + , [PT_HE].[CordonelPressureTestHe_TesterName] AS [Tester] -- 18 + FROM [Cordonel_PressureTest] AS [PT] + JOIN [Cordonel_PressureTest_He] AS [PT_HE] ON [PT_HE].[CordonelPressureTestHe_TestID] = [PT].[CordonelPressureTest_Id] + LEFT JOIN [Druckpruefung] AS [DP] ON [DP].[FabNr] = [PT].[CordonelPressureTest_PcbId] + JOIN [MapPcbIdToSerialNumber] AS [PCB2SN] ON [PCB2SN].[MapPcbIdToSerialNumber_PcbId] = [PT].[CordonelPressureTest_PcbId] + JOIN [AuftragPosition_Gesamt] AS [POS] ON [POS].[FertigungsauftragNr] = [PT].[CordonelPressureTest_FertigungsAuftragsNr] + JOIN [Identnr] AS [ID] ON [ID].[IdentNr] = [POS].[Identnr] + WHERE [CordonelPressureTest_IsDeleted] = 0 + AND {where.Query} + ORDER BY {orderBy.Query}", + parameters => + { + foreach (var kvp in where.Parameters) + { + parameters.Add(kvp.Key, kvp.Value); + } + + foreach (var kvp in orderBy.Parameters) + { + parameters.Add(kvp.Key, kvp.Value); + } + }, + reader => new HeliumReportItem + { + AuftragNr = reader.GetValue(0), + FertigungNr = reader.GetValue(1), + PositionNr = reader.GetValue(2), + SerialNr = reader.GetValue(3), + IdentNr = reader.GetValue(4), + HeId = reader.GetValue(5), + HeTestId = reader.GetValue(6), + PcbId = reader.GetValue(7), + Nennweite = reader.GetValue(8), + Baulaenge = reader.GetValue(9), + Typ = reader.GetString(10), + Druck = reader.GetValue(11), + Temperatur = reader.GetValue(12), + HeLakeRate = reader.GetString(13), + HeTestPressure = reader.GetString(14), + IsValid = reader.GetValue(15), + Text = reader.GetString(16), + TestDate = reader.GetValue(17), + Tester = reader.GetString(18) + }); + + return model; + } + + public IEnumerable LoadHeliumPressureResults(int testId) + => this.dbContext.AsEnumerable($@" + SELECT [CordonelPressureTestTestPoints_Id] + , [CordonelPressureTest_TestPointNr] + , CAST([CordonelPressureTest_TestPointResult] AS NUMERIC(9, 8)) + FROM [Auftrag].[dbo].[Cordonel_PressureTest_TestPoints] + WHERE [CordonelPressureTest_Id] = @{nameof(testId)}", + parameters => parameters.Add(nameof(testId), testId), + reader => new HeliumPressurePoint + { + TestId = reader.GetValue(0), + PointNr = reader.GetValue(1), + Result = reader.GetValue(2), + }); + } +} diff --git a/LaaProductionWeb/LaaProductionWeb/App_Content/css/styles.css b/LaaProductionWeb/LaaProductionWeb/App_Content/css/styles.css index 9e9ecbf8..2a91a050 100644 --- a/LaaProductionWeb/LaaProductionWeb/App_Content/css/styles.css +++ b/LaaProductionWeb/LaaProductionWeb/App_Content/css/styles.css @@ -125,4 +125,20 @@ table.table table.table { .bg-whitesmoke { background-color: whitesmoke !important -} \ No newline at end of file +} + +.bi-bold:before { + font-weight: bolder !important; +} + +.table-responsive::-webkit-scrollbar:horizontal { + position: fixed; + bottom: 0; +} + + + +.cursor-pointer:hover { + cursor: pointer !important; + text-decoration: underline !important; +} diff --git a/LaaProductionWeb/LaaProductionWeb/App_Infrastructure/ControllersExtensions.cs b/LaaProductionWeb/LaaProductionWeb/App_Infrastructure/ControllersExtensions.cs index 417f3e13..e4c6b966 100644 --- a/LaaProductionWeb/LaaProductionWeb/App_Infrastructure/ControllersExtensions.cs +++ b/LaaProductionWeb/LaaProductionWeb/App_Infrastructure/ControllersExtensions.cs @@ -3,7 +3,10 @@ using Microsoft.Extensions.DependencyInjection; using System; + using System.ComponentModel.DataAnnotations; using System.Linq; + using System.Linq.Expressions; + using System.Reflection; using System.Security.Claims; using System.Security.Principal; using System.Web.Mvc; @@ -54,5 +57,25 @@ { return default(T); } + + public static string Display(this T model, Expression> expression) + { + if (expression.Body is MemberExpression memberExpression) + { + return memberExpression + .Member + .GetCustomAttribute() + .GetName(); + } + else if (expression.Body is UnaryExpression unaryExpression && unaryExpression.Operand is MemberExpression operandExpression) + { + return operandExpression + .Member + .GetCustomAttribute() + .GetName(); + } + + return default(string); + } } } \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs b/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs new file mode 100644 index 00000000..fe41ffed --- /dev/null +++ b/LaaProductionWeb/LaaProductionWeb/Controllers/ReportController.cs @@ -0,0 +1,38 @@ +namespace LaaProductionWeb.Controllers +{ + using LaaProductionWeb.Services.Interfaces; + using LaaProductionWeb.Services.Models; + + using System.Web.Mvc; + + public class ReportController : Controller + { + private readonly IReportService reportService; + + public ReportController(IReportService reportService) + => this.reportService = reportService; + + [HttpGet] + public ActionResult Index() + { + var model = this.reportService.LoadHeliumPressureReport(); + + return this.View(model); + } + + [HttpPost] + public ActionResult Index(HeliumReportModel model) + { + model = this.reportService.LoadHeliumPressureReport(model); + + return this.View(model); + } + + public ActionResult Results(int testId = 0) + { + var results = this.reportService.LoadHeliumPressureResults(testId); + + return this.PartialView(results); + } + } +} \ No newline at end of file diff --git a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj index 6649aecc..9d19347f 100644 --- a/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj +++ b/LaaProductionWeb/LaaProductionWeb/LaaProductionWeb.csproj @@ -145,6 +145,7 @@ + @@ -176,6 +177,9 @@ + + + diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Home/Index.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Home/Index.cshtml index 397024f4..08b28270 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Home/Index.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Home/Index.cshtml @@ -15,17 +15,17 @@ enables a clean separation of concerns and gives you full control over markup for enjoyable, agile development.

-

Learn more »

+

Learn more »

Get more libraries

NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

-

Learn more »

+

Learn more »

Web Hosting

You can easily find a web hosting company that offers the right mix of features and price for your applications.

-

Learn more »

+

Learn more »

diff --git a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Document.cshtml b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Document.cshtml index 9ed590a7..5161194d 100644 --- a/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Document.cshtml +++ b/LaaProductionWeb/LaaProductionWeb/Views/Protocol/Document.cshtml @@ -2,19 +2,21 @@ @using LaaProductionWeb.Services.Models - +
+ -
-
-
-