diff --git a/.editorconfig b/.editorconfig index e69de29..d5ad560 100644 --- a/.editorconfig +++ b/.editorconfig @@ -0,0 +1,268 @@ +[*.cs] +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true +csharp_prefer_braces = false:silent +csharp_prefer_qualified_reference = true:error +csharp_prefer_simple_default_expression = true:warning +csharp_prefer_simple_using_statement = true:warning +csharp_prefer_static_local_function = true:warning +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true +csharp_style_allow_embedded_statements_on_same_line_experimental = true +csharp_style_conditional_delegate_call = true +csharp_style_deconstructed_variable_declaration = false +csharp_style_expression_bodied_accessors = when_on_single_line:warning +csharp_style_expression_bodied_constructors = when_on_single_line:warning +csharp_style_expression_bodied_indexers = when_on_single_line:warning +csharp_style_expression_bodied_lambdas = when_on_single_line:warning +csharp_style_expression_bodied_local_functions = when_on_single_line:warning +csharp_style_expression_bodied_methods = when_on_single_line:warning +csharp_style_expression_bodied_operators = when_on_single_line:warning +csharp_style_expression_bodied_properties = when_on_single_line:warning +csharp_style_implicit_object_creation_when_type_is_apparent = true:warning +csharp_style_inlined_variable_declaration = false +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_pattern_local_over_anonymous_function = true:warning +csharp_style_pattern_matching_over_as_with_null_check = true:warning +csharp_style_pattern_matching_over_is_with_cast_check = true:warning +csharp_style_prefer_index_operator = true:warning +csharp_style_prefer_not_pattern = true:warning +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_pattern_matching = true:warning +csharp_style_prefer_range_operator = true:warning +csharp_style_prefer_switch_expression = true:warning +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:warning +csharp_style_unused_value_expression_statement_preference = discard_variable:warning +csharp_style_var_elsewhere = false:warning +csharp_style_var_for_built_in_types = false:warning +csharp_style_var_when_type_is_apparent = false:warning +csharp_using_directive_placement = outside_namespace:silent +dotnet_code_quality_unused_parameters = all +dotnet_code_quality_unused_parameters = non_public # IDE0060: Remove unused parameter +dotnet_code_quality.CAXXXX.api_surface = private, internal +dotnet_diagnostic.CA1825.severity = warning # CA1823: Avoid zero-length array allocations +dotnet_diagnostic.CA1829.severity = warning # CA1829: Use Length/Count property instead of Count() when available +dotnet_diagnostic.CA1834.severity = warning # CA1834: Consider using 'StringBuilder.Append(char)' when applicable +dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name +dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. +dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); +dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary +dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) +dotnet_diagnostic.IDE0047.severity = warning # IDE0047: Parentheses can be removed +dotnet_diagnostic.IDE0049.severity = warning # Use language keywords instead of framework type names for type references (IDE0049) +dotnet_diagnostic.IDE0060.severity = warning # IDE0060: Remove unused parameter +dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning +dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method +dotnet_naming_rule.class_should_be_pascal_case.severity = warning +dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.class_should_be_pascal_case.symbols = class +dotnet_naming_rule.delegate_should_be_pascal_case.severity = warning +dotnet_naming_rule.delegate_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.delegate_should_be_pascal_case.symbols = delegate +dotnet_naming_rule.enum_should_be_pascal_case.severity = warning +dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum +dotnet_naming_rule.event_should_be_pascal_case.severity = warning +dotnet_naming_rule.event_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.event_should_be_pascal_case.symbols = event +dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.method_should_be_pascal_case.severity = warning +dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.method_should_be_pascal_case.symbols = method +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.private_method_should_be_pascal_case.severity = warning +dotnet_naming_rule.private_method_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.private_method_should_be_pascal_case.symbols = private_method +dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.severity = warning +dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.style = private_of_internal_field +dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.symbols = private_or_internal_field +dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.severity = warning +dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.style = private_of_internal_field +dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.symbols = private_or_internal_static_field +dotnet_naming_rule.property_should_be_pascal_case.severity = warning +dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.property_should_be_pascal_case.symbols = property +dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.severity = warning +dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.style = private_of_internal_field +dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.symbols = public_or_protected_field +dotnet_naming_rule.static_field_should_be_pascal_case.severity = warning +dotnet_naming_rule.static_field_should_be_pascal_case.symbols = static_field +dotnet_naming_rule.static_method_should_be_pascal_case.severity = warning +dotnet_naming_rule.static_method_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.static_method_should_be_pascal_case.symbols = static_method +dotnet_naming_rule.struct_should_be_pascal_case.severity = warning +dotnet_naming_rule.struct_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct +dotnet_naming_rule.types_should_be_pascal_case.severity = warning +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_style.begins_with_i.capitalization = pascal_case +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.private_of_internal_field.required_prefix = _ +dotnet_naming_style.private_of_internal_field.required_suffix = +dotnet_naming_style.private_of_internal_field.word_separator = +dotnet_naming_symbols.abstract_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.abstract_method.applicable_kinds = method +dotnet_naming_symbols.abstract_method.required_modifiers = abstract +dotnet_naming_symbols.class.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.class.applicable_kinds = class +dotnet_naming_symbols.class.required_modifiers = +dotnet_naming_symbols.delegate.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.delegate.applicable_kinds = delegate +dotnet_naming_symbols.delegate.required_modifiers = +dotnet_naming_symbols.enum.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.enum.applicable_kinds = enum +dotnet_naming_symbols.enum.required_modifiers = +dotnet_naming_symbols.event.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.event.applicable_kinds = event +dotnet_naming_symbols.event.required_modifiers = +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.required_modifiers = +dotnet_naming_symbols.method.applicable_accessibilities = public +dotnet_naming_symbols.method.applicable_kinds = method +dotnet_naming_symbols.method.required_modifiers = +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.required_modifiers = +dotnet_naming_symbols.private_method.applicable_accessibilities = private +dotnet_naming_symbols.private_method.applicable_kinds = method +dotnet_naming_symbols.private_method.required_modifiers = +dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_field.required_modifiers = +dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected +dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field +dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static +dotnet_naming_symbols.property.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.property.applicable_kinds = property +dotnet_naming_symbols.property.required_modifiers = +dotnet_naming_symbols.public_or_protected_field.applicable_accessibilities = public, protected +dotnet_naming_symbols.public_or_protected_field.applicable_kinds = field +dotnet_naming_symbols.public_or_protected_field.required_modifiers = +dotnet_naming_symbols.static_field.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.static_field.applicable_kinds = field +dotnet_naming_symbols.static_field.required_modifiers = static +dotnet_naming_symbols.static_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.static_method.applicable_kinds = method +dotnet_naming_symbols.static_method.required_modifiers = static +dotnet_naming_symbols.struct.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.struct.applicable_kinds = struct +dotnet_naming_symbols.struct.required_modifiers = +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.required_modifiers = +dotnet_remove_unnecessary_suppression_exclusions = 0 +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +dotnet_style_allow_multiple_blank_lines_experimental = false:warning +dotnet_style_allow_statement_immediately_after_block_experimental = true +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true:warning +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = false +dotnet_style_prefer_conditional_expression_over_return = false +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_simplified_boolean_expressions = true:warning +dotnet_style_prefer_simplified_interpolation = true +dotnet_style_qualification_for_event = false:error +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false:error +dotnet_style_qualification_for_property = false:error +dotnet_style_readonly_field = true:warning +dotnet_style_require_accessibility_modifiers = for_non_interface_members +end_of_line = crlf +file_header_template = unset +indent_size = 4 +indent_style = space +insert_final_newline = false +root = true +tab_width = 4 +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_prefer_local_over_anonymous_function = true:suggestion +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1822 +# https://github.com/dotnet/aspnetcore/blob/main/.editorconfig +# https://github.com/dotnet/project-system/blob/main/.editorconfig +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +dotnet_style_prefer_auto_properties = true:warning +dotnet_style_object_initializer = true:warning +dotnet_style_collection_initializer = true:warning +dotnet_style_prefer_simplified_boolean_expressions = true:warning +dotnet_style_prefer_conditional_expression_over_assignment = false:silent +dotnet_style_prefer_conditional_expression_over_return = false:silent +dotnet_style_explicit_tuple_names = true:warning +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:suggestion \ No newline at end of file diff --git a/ReportingServices.API/Controllers/ScrapeDBController.cs b/ReportingServices.API/Controllers/ScrapeDBController.cs index 6a5f989..edadc78 100644 --- a/ReportingServices.API/Controllers/ScrapeDBController.cs +++ b/ReportingServices.API/Controllers/ScrapeDBController.cs @@ -2,92 +2,57 @@ using ReportingServices.Shared.Models.PlanningReport; using ReportingServices.Shared.Models.ProductionReport; using ReportingServices.Shared.Repositories; -using ReportingServices.Shared.ViewModels.ProductionReport; -namespace ReportingServices.API.Controllers +namespace ReportingServices.API.Controllers; + +[Route("api/[controller]")] +[ApiController] +public class ScrapeDBController : ControllerBase { - [Route("api/[controller]")] - [ApiController] - public class ScrapeDBController : ControllerBase + private readonly IScrapeDatabaseRepository _scrapeDBRepository; + + public ScrapeDBController(IScrapeDatabaseRepository scrapeDBRepository) => _scrapeDBRepository = scrapeDBRepository; + + [HttpGet("ReactorOuts")] + public YieldInformation GetReactorOuts(string startDate, string endDate) { - private readonly IScrapeDatabaseRepository _scrapeDBRepository; - - public ScrapeDBController(IScrapeDatabaseRepository scrapeDBRepository) + List outs = _scrapeDBRepository.GetRDSRunBetweenDates(startDate, endDate); + YieldInformation yieldInformation = new() { - _scrapeDBRepository = scrapeDBRepository; - } + Outs = outs, + Scrap = _scrapeDBRepository.GetScrapByDay(outs) + }; - [HttpGet("ReactorOuts")] - public YieldInformation GetReactorOuts(string startDate, string endDate) - { - List outs = _scrapeDBRepository.GetRDSRunBetweenDates(startDate, endDate); - YieldInformation yieldInformation = new() - { - Outs = outs, - Scrap = _scrapeDBRepository.GetScrapByDay(outs) - }; - - return yieldInformation; - } - - [HttpGet("PSNWO")] - public List GetReactorPSNWORuns(string startDate, string endDate) - { - return _scrapeDBRepository.GetReactorPSNWORuns(startDate, endDate); - } - - [HttpGet("PartChanges")] - public int GetNumberOfPartChanges(string startDate, string endDate) - { - return _scrapeDBRepository.GetNumberOfPartChanges(startDate, endDate); - } - - [HttpGet("Targets")] - public QuarterlyTargets GetQuarterlyTargets() - { - return _scrapeDBRepository.GetQuarterlyTargets(); - } - - [HttpGet("Reactors")] - public List GetReactors() - { - return _scrapeDBRepository.GetReactors(); - } - - [HttpGet("RDS")] - public List GetRDSForLastDay(string date) - { - return _scrapeDBRepository.GetRDSForLastDay(date); - } - - [HttpGet("ReactorEvents")] - public List GetReactorEvents(string startDate, string endDate, string reactorNumber) - { - return _scrapeDBRepository.GetReactorEvents(startDate, endDate, reactorNumber); - } - - [HttpGet("GetLastUpTransaction")] - public int GetLastUpTransaction(string reactorNumber) - { - return _scrapeDBRepository.GetLastUpTransaction(reactorNumber); - } - - [HttpGet("ToolEvents")] - public ToolEvent GetLatestToolEvent(string toolID) - { - return _scrapeDBRepository.GetLatestToolEvent(toolID); - } - - [HttpGet("GetOutsAndScrapTotals")] - public OutsAndScrapTotal GetOutsAndScrapTotal(string startDate, string endDate) - { - return _scrapeDBRepository.GetOutsAndScrapTotals(startDate, endDate); - } - - [HttpGet("GetQuarterStartDate")] - public DateTime GetQuarterStartDate() - { - return _scrapeDBRepository.GetQuarterStartDate(); - } + return yieldInformation; } -} + + [HttpGet("PSNWO")] + public List GetReactorPSNWORuns(string startDate, string endDate) => _scrapeDBRepository.GetReactorPSNWORuns(startDate, endDate); + + [HttpGet("PartChanges")] + public int GetNumberOfPartChanges(string startDate, string endDate) => _scrapeDBRepository.GetNumberOfPartChanges(startDate, endDate); + + [HttpGet("Targets")] + public QuarterlyTargets GetQuarterlyTargets() => _scrapeDBRepository.GetQuarterlyTargets(); + + [HttpGet("Reactors")] + public List GetReactors() => _scrapeDBRepository.GetReactors(); + + [HttpGet("RDS")] + public List GetRDSForLastDay(string date) => _scrapeDBRepository.GetRDSForLastDay(date); + + [HttpGet("ReactorEvents")] + public List GetReactorEvents(string startDate, string endDate, string reactorNumber) => _scrapeDBRepository.GetReactorEvents(startDate, endDate, reactorNumber); + + [HttpGet("GetLastUpTransaction")] + public int GetLastUpTransaction(string reactorNumber) => _scrapeDBRepository.GetLastUpTransaction(reactorNumber); + + [HttpGet("ToolEvents")] + public ToolEvent GetLatestToolEvent(string toolID) => _scrapeDBRepository.GetLatestToolEvent(toolID); + + [HttpGet("GetOutsAndScrapTotals")] + public OutsAndScrapTotal GetOutsAndScrapTotal(string startDate, string endDate) => _scrapeDBRepository.GetOutsAndScrapTotals(startDate, endDate); + + [HttpGet("GetQuarterStartDate")] + public DateTime GetQuarterStartDate() => _scrapeDBRepository.GetQuarterStartDate(); +} \ No newline at end of file diff --git a/ReportingServices.API/Program.cs b/ReportingServices.API/Program.cs index 2d51169..c790913 100644 --- a/ReportingServices.API/Program.cs +++ b/ReportingServices.API/Program.cs @@ -1,47 +1,53 @@ using ReportingServices.Shared.Repositories; using Serilog; -LoggerConfiguration loggerConfiguration = new(); - -var builder = WebApplication.CreateBuilder(args); -Environment.SetEnvironmentVariable("workingDirectory", "D:\\tmp\\logging\\MesaReportingServices\\API"); -_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, builder.Configuration); -_ = SerilogHostBuilderExtensions.UseSerilog(builder.Host); -Log.Logger = loggerConfiguration.CreateLogger(); -Serilog.ILogger log = Log.ForContext(); -// Add services to the container. -builder.Services.AddControllers(); -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); -builder.Services.AddScoped(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) +internal class Program { - app.UseSwagger(); - app.UseSwaggerUI(); -} + private static void Main(string[] args) + { + LoggerConfiguration loggerConfiguration = new(); -app.UseHttpsRedirection(); + WebApplicationBuilder builder = WebApplication.CreateBuilder(args); + Environment.SetEnvironmentVariable("workingDirectory", "D:\\tmp\\logging\\MesaReportingServices\\API"); + _ = loggerConfiguration.ReadFrom.Configuration(builder.Configuration); + _ = builder.Host.UseSerilog(); + Log.Logger = loggerConfiguration.CreateLogger(); + Serilog.ILogger log = Log.ForContext(); + // Add services to the container. + _ = builder.Services.AddControllers(); + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + _ = builder.Services.AddEndpointsApiExplorer(); + _ = builder.Services.AddSwaggerGen(); + _ = builder.Services.AddScoped(); -app.UseAuthorization(); + WebApplication app = builder.Build(); -app.MapControllers(); -_ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); -log.Information("Starting Web APIs"); + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + _ = app.UseSwagger(); + _ = app.UseSwaggerUI(); + } -try -{ - app.Run(); -} -catch (Exception ex) -{ - log.Fatal(ex, "Host terminated unexpectedly"); -} -finally -{ - Log.CloseAndFlush(); -} + _ = app.UseHttpsRedirection(); + + _ = app.UseAuthorization(); + + _ = app.MapControllers(); + _ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); + log.Information("Starting Web APIs"); + + try + { + app.Run(); + } + catch (Exception ex) + { + log.Fatal(ex, "Host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/HelperClasses/APIHelperFunctions.cs b/ReportingServices.Shared/HelperClasses/APIHelperFunctions.cs index 6398639..0ca641b 100644 --- a/ReportingServices.Shared/HelperClasses/APIHelperFunctions.cs +++ b/ReportingServices.Shared/HelperClasses/APIHelperFunctions.cs @@ -1,56 +1,53 @@ -using System.Web; +namespace ReportingServices.Shared.HelperClasses; -namespace ReportingServices.Shared.HelperClasses +public static class APIHelperFunctions { - public static class APIHelperFunctions + public static string GetBeginningOfWeekAsAPIString() { - public static string GetBeginningOfWeekAsAPIString() + DateTime date = DateTime.Now; + + int dayOfWeek = (int)date.DayOfWeek; + + date = dayOfWeek switch { - DateTime date = DateTime.Now; + 0 => date.AddDays(-6), + 1 => date, + _ => date.AddDays(1 - dayOfWeek) + }; - int dayOfWeek = (int)date.DayOfWeek; - - date = dayOfWeek switch - { - 0 => date.AddDays(-6), - 1 => date, - _ => date.AddDays(1 - dayOfWeek) - }; - - return GetDateTimeAsAPIString(date.ToString(), false); - } - - public static string GetDateWithOffsetAsAPIString(string dateString, float offset) - { - DateTime date = DateTime.Parse(dateString); - - date = date.AddHours(offset); - - return GetDateTimeAsAPIString(date.ToString(), true); - } - - public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime) - { - DateTime date = DateTime.Parse(dateString); - - if (fullDateTime) - dateString = date.ToString("yyyy-M-d HH:mm:ss"); - else - dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0"; - - return dateString; - } - - public static List ReverseList(List inputList) - { - List temp = new(); - - for (int i = inputList.Count - 1; i >= 0; i--) - { - temp.Add(inputList[i]); - } - - return temp; - } + return GetDateTimeAsAPIString(date.ToString(), false); } -} + + public static string GetDateWithOffsetAsAPIString(string dateString, float offset) + { + DateTime date = DateTime.Parse(dateString); + + date = date.AddHours(offset); + + return GetDateTimeAsAPIString(date.ToString(), true); + } + + public static string GetDateTimeAsAPIString(string dateString, bool fullDateTime) + { + DateTime date = DateTime.Parse(dateString); + + if (fullDateTime) + dateString = date.ToString("yyyy-M-d HH:mm:ss"); + else + dateString = date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0"; + + return dateString; + } + + public static List ReverseList(List inputList) + { + List temp = new(); + + for (int i = inputList.Count - 1; i >= 0; i--) + { + temp.Add(inputList[i]); + } + + return temp; + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/HelperClasses/ApiCaller.cs b/ReportingServices.Shared/HelperClasses/ApiCaller.cs index 8cee208..ce4391b 100644 --- a/ReportingServices.Shared/HelperClasses/ApiCaller.cs +++ b/ReportingServices.Shared/HelperClasses/ApiCaller.cs @@ -1,22 +1,19 @@ -using ReportingServices.Shared.Models.ProductionReport; -using System.Net.Http.Json; -using System.Text.Json; +using System.Text.Json; -namespace ReportingServices.Shared.HelperClasses +namespace ReportingServices.Shared.HelperClasses; + +public static class ApiCaller { - public static class ApiCaller + public static async Task GetApi(string url) { - public static async Task GetApi(string url) + T deserializedJson = default; + + using (HttpClient client = new()) { - T deserializedJson = default(T); - - using (HttpClient client = new()) - { - string apiResponse = await client.GetStringAsync(url); - deserializedJson = JsonSerializer.Deserialize(apiResponse); - } - - return deserializedJson; + string apiResponse = await client.GetStringAsync(url); + deserializedJson = JsonSerializer.Deserialize(apiResponse); } + + return deserializedJson; } -} +} \ No newline at end of file diff --git a/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs b/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs index a199b71..6461371 100644 --- a/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs +++ b/ReportingServices.Shared/HelperClasses/DailyReportHelper.cs @@ -2,181 +2,180 @@ using ReportingServices.Shared.Models.ProductionReport; using ReportingServices.Shared.ViewModels.ProductionReport; -namespace ReportingServices.Shared.HelperClasses +namespace ReportingServices.Shared.HelperClasses; + +public static class DailyReportHelper { - public static class DailyReportHelper + private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json"; + private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json"; + + public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb) { - private static readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json"; - private static readonly string _SLLFilePath = "wwwroot/Assets/SLLTools.json"; + DailyReport report = new(); - public static DailyReport SetUpDailyReport(ILogger logger, string baseUrlScrapeDb) + try { - DailyReport report = new(); + report.SLLTools = JsonFileHandler.LoadJSONFile>(_SLLFilePath); + report.ManualReportEntries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); - try - { - report.SLLTools = JsonFileHandler.LoadJSONFile>(_SLLFilePath); - report.ManualReportEntries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); - - } - catch (Exception ex) - { - logger.LogError(ex, "Failed to load JsonFiles."); - logger.LogInformation("SLL File Path: {path}", _SLLFilePath); - logger.LogInformation("Manual Report Entries File Path: {path}", _dailyRptFilePath); - } - - List cleanTools = new() - { - "AHPS", - "AKRION1", - "CB3", - "MES", - "SRD 1", - "SRD 2" - }; - - List metrologyTools = new() - { - "ASET", - "BIORAD2", - "BIORAD3", - "BIORAD4", - "BIORAD5", - "CDE2", - "CDE3", - "CDE5", - "FLEXUS", - "HGCV1", - "HGCV2", - "HGCV3", - "SRP" - }; - - List reactors = new(); - Dictionary> lastUpTransactions = new(); - List>> toolEvents = new(); - List> cleanEvents = new(); - List> metrologyEvents = new(); - - Task task1 = null; - Task task2 = null; - Task targets = null; - Task> rds = null; - Task task3 = null; - Task task4 = null; - - try - { - reactors = ApiCaller.GetApi>(baseUrlScrapeDb + "Reactors").Result; - - foreach (Reactor reactor in reactors) - { - toolEvents.Add(ApiCaller.GetApi>(baseUrlScrapeDb + "ReactorEvents?startDate=" + report.StartDate.ToString() + - "&endDate=" + DateTime.Now.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type)); - - lastUpTransactions.Add(reactor.ReactorNumber.ToString(), - ApiCaller.GetApi(baseUrlScrapeDb + "GetLastUpTransaction?reactorNumber=" + reactor.ReactorNumber)); - } - - foreach (string tool in cleanTools) - { - cleanEvents.Add(ApiCaller.GetApi(baseUrlScrapeDb + "ToolEvents?toolID=" + tool)); - } - - foreach (string tool in metrologyTools) - { - metrologyEvents.Add(ApiCaller.GetApi(baseUrlScrapeDb + "ToolEvents?toolID=" + tool)); - } - - task1 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString()); - task2 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString()); - task3 = ApiCaller.GetApi(baseUrlScrapeDb + "GetQuarterStartDate"); - targets = ApiCaller.GetApi(baseUrlScrapeDb + "Targets"); - - rds = ApiCaller.GetApi>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString()); - task4 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + DateTime.Now.ToString()); - } - catch (Exception ex) - { - logger.LogCritical(ex, "Failed to send get requests to scrapedb endpoints."); - } - - try - { - report.QuarterlyTargets = targets.Result; - report.SetRDSInfo(rds.Result); - report.SetReactorInfo(reactors, GetUnscheduledReactors(report)); - - foreach (var task in toolEvents) - { - ToolEventView toolEvent = new(task.Result, - report.StartDate.ToString(), DateTime.Now.ToString(), task.Result[0].REACT_NO, - reactors.FirstOrDefault(x => x.ReactorNumber == int.Parse(task.Result[0].REACT_NO)).Type); - - toolEvent.SetDowntime(lastUpTransactions[toolEvent.Reactor].Result); - - report.ToolEvents.Add(toolEvent); - } - - report.ToolEvents = report.ToolEvents - .Where(x => x.Reactor != "100" && x.Reactor != "101" && x.Reactor != "47") - .OrderBy(x => x.Reactor) - .ToList(); - - foreach (Task task in cleanEvents) - report.CleanEvents.Add(task.Result); - - foreach (Task task in metrologyEvents) - report.MetrologyEvents.Add(task.Result); - - report.CleanEvents = report.CleanEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList(); - report.MetrologyEvents = report.MetrologyEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList(); - - report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets); - report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets); - - report.QuarterStartDate = task3.Result; - - report.CurrentWeek.QTDOutsAndScrap = task4.Result; - report.PreviousWeek.QTDOutsAndScrap = task4.Result; - } - catch (Exception ex) - { - logger.LogCritical(ex, "Failed to retrieve data back from Scrape DB endpoints."); - } - - report.ReverseLists(); - - ManualReportEntries entries = report.ManualReportEntries; - List sll = report.SLLTools; - - try - { - JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath); - JsonFileHandler.SaveJSONFile(sll, _SLLFilePath); - } - catch (Exception ex) - { - logger.LogCritical(ex, "Failed to save data back to JSON files."); - } - - return report; + } + catch (Exception ex) + { + logger.LogError(ex, "Failed to load JsonFiles."); + logger.LogInformation("SLL File Path: {path}", _SLLFilePath); + logger.LogInformation("Manual Report Entries File Path: {path}", _dailyRptFilePath); } - public static List GetUnscheduledReactors(DailyReport report) + List cleanTools = new() { - List reactors = new(); + "AHPS", + "AKRION1", + "CB3", + "MES", + "SRD 1", + "SRD 2" + }; - foreach (ToolEventView tool in report.ToolEvents) + List metrologyTools = new() + { + "ASET", + "BIORAD2", + "BIORAD3", + "BIORAD4", + "BIORAD5", + "CDE2", + "CDE3", + "CDE5", + "FLEXUS", + "HGCV1", + "HGCV2", + "HGCV3", + "SRP" + }; + + List reactors = new(); + Dictionary> lastUpTransactions = new(); + List>> toolEvents = new(); + List> cleanEvents = new(); + List> metrologyEvents = new(); + + Task task1 = null; + Task task2 = null; + Task targets = null; + Task> rds = null; + Task task3 = null; + Task task4 = null; + + try + { + reactors = ApiCaller.GetApi>(baseUrlScrapeDb + "Reactors").Result; + + foreach (Reactor reactor in reactors) { - if (!tool.IsInProduction) - { - reactors.Add(int.Parse(tool.Reactor)); - } + toolEvents.Add(ApiCaller.GetApi>(baseUrlScrapeDb + "ReactorEvents?startDate=" + report.StartDate.ToString() + + "&endDate=" + DateTime.Now.ToString() + "&reactorNumber=" + reactor.ReactorNumber + "&reactorType=" + reactor.Type)); + + lastUpTransactions.Add(reactor.ReactorNumber.ToString(), + ApiCaller.GetApi(baseUrlScrapeDb + "GetLastUpTransaction?reactorNumber=" + reactor.ReactorNumber)); } - return reactors; + foreach (string tool in cleanTools) + { + cleanEvents.Add(ApiCaller.GetApi(baseUrlScrapeDb + "ToolEvents?toolID=" + tool)); + } + + foreach (string tool in metrologyTools) + { + metrologyEvents.Add(ApiCaller.GetApi(baseUrlScrapeDb + "ToolEvents?toolID=" + tool)); + } + + task1 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.ToString() + "&endDate=" + DateTime.Now.ToString()); + task2 = ApiCaller.GetApi(baseUrlScrapeDb + "ReactorOuts?startDate=" + report.StartDate.AddDays(-7).ToString() + "&endDate=" + report.StartDate.ToString()); + task3 = ApiCaller.GetApi(baseUrlScrapeDb + "GetQuarterStartDate"); + targets = ApiCaller.GetApi(baseUrlScrapeDb + "Targets"); + + rds = ApiCaller.GetApi>(baseUrlScrapeDb + "RDS?date=" + report.StartDate.ToString()); + task4 = ApiCaller.GetApi(baseUrlScrapeDb + "GetOutsAndScrapTotals?startDate=" + task3.Result + "&endDate=" + DateTime.Now.ToString()); } + catch (Exception ex) + { + logger.LogCritical(ex, "Failed to send get requests to scrapedb endpoints."); + } + + try + { + report.QuarterlyTargets = targets.Result; + report.SetRDSInfo(rds.Result); + report.SetReactorInfo(reactors, GetUnscheduledReactors(report)); + + foreach (Task> task in toolEvents) + { + ToolEventView toolEvent = new(task.Result, + report.StartDate.ToString(), DateTime.Now.ToString(), task.Result[0].REACT_NO, + reactors.FirstOrDefault(x => x.ReactorNumber == int.Parse(task.Result[0].REACT_NO)).Type); + + toolEvent.SetDowntime(lastUpTransactions[toolEvent.Reactor].Result); + + report.ToolEvents.Add(toolEvent); + } + + report.ToolEvents = report.ToolEvents + .Where(x => x.Reactor is not "100" and not "101" and not "47") + .OrderBy(x => x.Reactor) + .ToList(); + + foreach (Task task in cleanEvents) + report.CleanEvents.Add(task.Result); + + foreach (Task task in metrologyEvents) + report.MetrologyEvents.Add(task.Result); + + report.CleanEvents = report.CleanEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList(); + report.MetrologyEvents = report.MetrologyEvents.Where(x => (x.TOOL_MODE != "PROD" || x.TOOL_MODE_DESC != "Production") && x.TOOL_MODE != "OUT").ToList(); + + report.CurrentWeek.SetYieldInformation(task1.Result, report.QuarterlyTargets); + report.PreviousWeek.SetYieldInformation(task2.Result, report.QuarterlyTargets); + + report.QuarterStartDate = task3.Result; + + report.CurrentWeek.QTDOutsAndScrap = task4.Result; + report.PreviousWeek.QTDOutsAndScrap = task4.Result; + } + catch (Exception ex) + { + logger.LogCritical(ex, "Failed to retrieve data back from Scrape DB endpoints."); + } + + report.ReverseLists(); + + ManualReportEntries entries = report.ManualReportEntries; + List sll = report.SLLTools; + + try + { + JsonFileHandler.SaveJSONFile(entries, _dailyRptFilePath); + JsonFileHandler.SaveJSONFile(sll, _SLLFilePath); + } + catch (Exception ex) + { + logger.LogCritical(ex, "Failed to save data back to JSON files."); + } + + return report; } -} + + public static List GetUnscheduledReactors(DailyReport report) + { + List reactors = new(); + + foreach (ToolEventView tool in report.ToolEvents) + { + if (!tool.IsInProduction) + { + reactors.Add(int.Parse(tool.Reactor)); + } + } + + return reactors; + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/HelperClasses/JsonFileHandler.cs b/ReportingServices.Shared/HelperClasses/JsonFileHandler.cs index 7e3d2f0..e514faa 100644 --- a/ReportingServices.Shared/HelperClasses/JsonFileHandler.cs +++ b/ReportingServices.Shared/HelperClasses/JsonFileHandler.cs @@ -1,19 +1,18 @@ using System.Text.Json; -namespace ReportingServices.Shared.HelperClasses -{ - public static class JsonFileHandler - { - public static T LoadJSONFile(string file) - { - string json = File.ReadAllText(file); - return JsonSerializer.Deserialize(json); - } +namespace ReportingServices.Shared.HelperClasses; - public static void SaveJSONFile(T obj, string file) - { - string json = JsonSerializer.Serialize(obj); - File.WriteAllText(file, json); - } +public static class JsonFileHandler +{ + public static T LoadJSONFile(string file) + { + string json = File.ReadAllText(file); + return JsonSerializer.Deserialize(json); } -} + + public static void SaveJSONFile(T obj, string file) + { + string json = JsonSerializer.Serialize(obj); + File.WriteAllText(file, json); + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/PlanningReport/ReactorPSNWORuns.cs b/ReportingServices.Shared/Models/PlanningReport/ReactorPSNWORuns.cs index 0752e0a..1c2102b 100644 --- a/ReportingServices.Shared/Models/PlanningReport/ReactorPSNWORuns.cs +++ b/ReportingServices.Shared/Models/PlanningReport/ReactorPSNWORuns.cs @@ -1,14 +1,13 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.PlanningReport +namespace ReportingServices.Shared.Models.PlanningReport; + +public class ReactorPSNWORuns { - public class ReactorPSNWORuns - { - [JsonPropertyName("REACTOR")] - public string REACTOR { get; set; } - [JsonPropertyName("PSN")] - public string PSN { get; set; } - [JsonPropertyName("WO_COUNT")] - public int WO_COUNT { get; set; } - } -} + [JsonPropertyName("REACTOR")] + public string REACTOR { get; set; } + [JsonPropertyName("PSN")] + public string PSN { get; set; } + [JsonPropertyName("WO_COUNT")] + public int WO_COUNT { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/PlanningReport/WeeklyPartChanges.cs b/ReportingServices.Shared/Models/PlanningReport/WeeklyPartChanges.cs index 9c78c44..6a682b8 100644 --- a/ReportingServices.Shared/Models/PlanningReport/WeeklyPartChanges.cs +++ b/ReportingServices.Shared/Models/PlanningReport/WeeklyPartChanges.cs @@ -1,10 +1,9 @@ -namespace ReportingServices.Shared.Models.PlanningReport +namespace ReportingServices.Shared.Models.PlanningReport; + +public class WeeklyPartChanges { - public class WeeklyPartChanges - { - public int TotalPartChanges { get; set; } - public string StartDate { get; set; } - public string EndDate { get; set; } - public List ReactorPSNWORuns { get; set; } - } -} + public int TotalPartChanges { get; set; } + public string StartDate { get; set; } + public string EndDate { get; set; } + public List ReactorPSNWORuns { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs b/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs index b5c2595..a6eaa89 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ManualReportEntries.cs @@ -1,21 +1,20 @@ -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ManualReportEntries { - public class ManualReportEntries - { - public int OperatorHeadcountDays { get; set; } - public int OperatorHeadcountNights { get; set; } - public int OperatorCallOutsDays { get; set; } - public int OperatorCallOutsNights { get; set; } - public int EngineeringHeadcountDays { get; set; } - public int EngineeringHeadcountNights { get; set; } - public int EngineeringCallOutsDays { get; set; } - public int EngineeringCallOutsNights { get; set; } - public int MaintenanceHeadcountDays { get; set; } - public int MaintenanceHeadcountNights { get; set; } - public int MaintenanceCallOutsDays { get; set; } - public int MaintenanceCallOutsNights { get; set; } - public string BottleChanges { get; set; } - public string DailyPartChanges { get; set; } - public string WeeklyPartChanges { get; set; } - } -} + public int OperatorHeadcountDays { get; set; } + public int OperatorHeadcountNights { get; set; } + public int OperatorCallOutsDays { get; set; } + public int OperatorCallOutsNights { get; set; } + public int EngineeringHeadcountDays { get; set; } + public int EngineeringHeadcountNights { get; set; } + public int EngineeringCallOutsDays { get; set; } + public int EngineeringCallOutsNights { get; set; } + public int MaintenanceHeadcountDays { get; set; } + public int MaintenanceHeadcountNights { get; set; } + public int MaintenanceCallOutsDays { get; set; } + public int MaintenanceCallOutsNights { get; set; } + public string BottleChanges { get; set; } + public string DailyPartChanges { get; set; } + public string WeeklyPartChanges { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/OutsAndScrapTotal.cs b/ReportingServices.Shared/Models/ProductionReport/OutsAndScrapTotal.cs index 0b0d4f4..2c46b32 100644 --- a/ReportingServices.Shared/Models/ProductionReport/OutsAndScrapTotal.cs +++ b/ReportingServices.Shared/Models/ProductionReport/OutsAndScrapTotal.cs @@ -1,16 +1,15 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class OutsAndScrapTotal { - public class OutsAndScrapTotal - { - [JsonPropertyName("Outs")] - public int Outs { get; set; } - [JsonPropertyName("CustomerScrap")] - public int CustomerScrap { get; set; } - [JsonPropertyName("ManufacturingScrap")] - public int ManufacturingScrap { get; set; } - [JsonPropertyName("ProductionScrap")] - public int ProductionScrap { get; set; } - } -} + [JsonPropertyName("Outs")] + public int Outs { get; set; } + [JsonPropertyName("CustomerScrap")] + public int CustomerScrap { get; set; } + [JsonPropertyName("ManufacturingScrap")] + public int ManufacturingScrap { get; set; } + [JsonPropertyName("ProductionScrap")] + public int ProductionScrap { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/QuarterlyTargets.cs b/ReportingServices.Shared/Models/ProductionReport/QuarterlyTargets.cs index b694c6e..d32da9e 100644 --- a/ReportingServices.Shared/Models/ProductionReport/QuarterlyTargets.cs +++ b/ReportingServices.Shared/Models/ProductionReport/QuarterlyTargets.cs @@ -1,18 +1,17 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class QuarterlyTargets { - public class QuarterlyTargets - { - [JsonPropertyName("Reactor_Outs")] - public int Reactor_Outs { get; set; } - [JsonPropertyName("Yield_Outs")] - public int Yield_Outs { get; set; } - [JsonPropertyName("IFX_Scrap")] - public int IFX_Scrap { get; set; } - [JsonPropertyName("Yield")] - public float Yield { get; set; } - [JsonPropertyName("PlanWorkingDays")] - public int PlanWorkingDays { get; set; } - } -} + [JsonPropertyName("Reactor_Outs")] + public int Reactor_Outs { get; set; } + [JsonPropertyName("Yield_Outs")] + public int Yield_Outs { get; set; } + [JsonPropertyName("IFX_Scrap")] + public int IFX_Scrap { get; set; } + [JsonPropertyName("Yield")] + public float Yield { get; set; } + [JsonPropertyName("PlanWorkingDays")] + public int PlanWorkingDays { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/RDS.cs b/ReportingServices.Shared/Models/ProductionReport/RDS.cs index 603cb01..bf5d71a 100644 --- a/ReportingServices.Shared/Models/ProductionReport/RDS.cs +++ b/ReportingServices.Shared/Models/ProductionReport/RDS.cs @@ -1,18 +1,17 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class RDS { - public class RDS - { - [JsonPropertyName("Reactor")] - public int Reactor { get; set; } - [JsonPropertyName("ReactorType")] - public string ReactorType { get; set; } - [JsonPropertyName("DateOut")] - public DateTime DateOut { get; set; } - [JsonPropertyName("UnloadTemp")] - public int UnloadTemp { get; set; } - [JsonPropertyName("LayerType")] - public string LayerType { get; set; } - } -} + [JsonPropertyName("Reactor")] + public int Reactor { get; set; } + [JsonPropertyName("ReactorType")] + public string ReactorType { get; set; } + [JsonPropertyName("DateOut")] + public DateTime DateOut { get; set; } + [JsonPropertyName("UnloadTemp")] + public int UnloadTemp { get; set; } + [JsonPropertyName("LayerType")] + public string LayerType { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/Reactor.cs b/ReportingServices.Shared/Models/ProductionReport/Reactor.cs index 389ef4d..91b71e8 100644 --- a/ReportingServices.Shared/Models/ProductionReport/Reactor.cs +++ b/ReportingServices.Shared/Models/ProductionReport/Reactor.cs @@ -1,16 +1,15 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class Reactor { - public class Reactor - { - [JsonPropertyName("ReactorNumber")] - public int ReactorNumber { get; set; } - [JsonPropertyName("Type")] - public string Type { get; set; } - [JsonPropertyName("PocketSize")] - public string PocketSize { get; set; } - [JsonPropertyName("HasDisabledLoadLock")] - public bool HasDisabledLoadlock { get; set; } - } -} + [JsonPropertyName("ReactorNumber")] + public int ReactorNumber { get; set; } + [JsonPropertyName("Type")] + public string Type { get; set; } + [JsonPropertyName("PocketSize")] + public string PocketSize { get; set; } + [JsonPropertyName("HasDisabledLoadLock")] + public bool HasDisabledLoadlock { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ReactorEvent.cs b/ReportingServices.Shared/Models/ProductionReport/ReactorEvent.cs index 9e1b948..9add017 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ReactorEvent.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ReactorEvent.cs @@ -1,16 +1,15 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ReactorEvent { - public class ReactorEvent - { - [JsonPropertyName("REACT_NO")] - public string REACT_NO { get; set; } - [JsonPropertyName("EVENT_DTM")] - public string EVENT_DTM { get; set; } - [JsonPropertyName("COMMENT")] - public string COMMENT { get; set; } - [JsonPropertyName("REACT_MODE")] - public string REACT_MODE { get; set; } - } -} + [JsonPropertyName("REACT_NO")] + public string REACT_NO { get; set; } + [JsonPropertyName("EVENT_DTM")] + public string EVENT_DTM { get; set; } + [JsonPropertyName("COMMENT")] + public string COMMENT { get; set; } + [JsonPropertyName("REACT_MODE")] + public string REACT_MODE { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByDay.cs b/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByDay.cs index fbdbe4d..05081ac 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByDay.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByDay.cs @@ -1,8 +1,7 @@ -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ReactorOutsByDay { - public class ReactorOutsByDay - { - public string StartDate { get; set; } - public int TotalWafers { get; set; } - } -} + public string StartDate { get; set; } + public int TotalWafers { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByRDS.cs b/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByRDS.cs index 98a8b4d..9bb5dea 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByRDS.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ReactorOutsByRDS.cs @@ -1,14 +1,13 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ReactorOutsByRDS { - public class ReactorOutsByRDS - { - [JsonPropertyName("RDS_NO")] - public string RDS_NO { get; set; } - [JsonPropertyName("Units")] - public string Units { get; set; } - [JsonPropertyName("EndProcessTime")] - public string EndProcessTime { get; set; } - } -} + [JsonPropertyName("RDS_NO")] + public string RDS_NO { get; set; } + [JsonPropertyName("Units")] + public string Units { get; set; } + [JsonPropertyName("EndProcessTime")] + public string EndProcessTime { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ScrapByDay.cs b/ReportingServices.Shared/Models/ProductionReport/ScrapByDay.cs index 5aca4aa..d9dd9b6 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ScrapByDay.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ScrapByDay.cs @@ -1,18 +1,17 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ScrapByDay { - public class ScrapByDay - { - [JsonPropertyName("StartDate")] - public string StartDate { get; set; } - [JsonPropertyName("TW_PROD")] - public int TW_PROD { get; set; } - [JsonPropertyName("TOT_REJ_CUST")] - public int TOT_REJ_CUST { get; set; } - [JsonPropertyName("TOT_REJ_MANU")] - public int TOT_REJ_MANU { get; set; } - [JsonPropertyName("TOT_REJ_WFRS")] - public int TOT_REJ_WFRS { get; set; } - } -} + [JsonPropertyName("StartDate")] + public string StartDate { get; set; } + [JsonPropertyName("TW_PROD")] + public int TW_PROD { get; set; } + [JsonPropertyName("TOT_REJ_CUST")] + public int TOT_REJ_CUST { get; set; } + [JsonPropertyName("TOT_REJ_MANU")] + public int TOT_REJ_MANU { get; set; } + [JsonPropertyName("TOT_REJ_WFRS")] + public int TOT_REJ_WFRS { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ToolEvent.cs b/ReportingServices.Shared/Models/ProductionReport/ToolEvent.cs index 632a404..8355527 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ToolEvent.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ToolEvent.cs @@ -1,16 +1,15 @@ using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ToolEvent { - public class ToolEvent - { - [JsonPropertyName("TOOL_ID")] - public string TOOL_ID { get; set; } - [JsonPropertyName("START_DTM")] - public string START_DTM { get; set; } - [JsonPropertyName("TOOL_MODE")] - public string TOOL_MODE { get; set; } - [JsonPropertyName("TOOL_MODE_DESC")] - public string TOOL_MODE_DESC { get; set; } - } -} + [JsonPropertyName("TOOL_ID")] + public string TOOL_ID { get; set; } + [JsonPropertyName("START_DTM")] + public string START_DTM { get; set; } + [JsonPropertyName("TOOL_MODE")] + public string TOOL_MODE { get; set; } + [JsonPropertyName("TOOL_MODE_DESC")] + public string TOOL_MODE_DESC { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/ToolUptimeData.cs b/ReportingServices.Shared/Models/ProductionReport/ToolUptimeData.cs index 6e0d726..31056c6 100644 --- a/ReportingServices.Shared/Models/ProductionReport/ToolUptimeData.cs +++ b/ReportingServices.Shared/Models/ProductionReport/ToolUptimeData.cs @@ -1,8 +1,7 @@ -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class ToolUptimeData { - public class ToolUptimeData - { - public string Date { get; set; } - public double UptimePercentage { get; set; } - } -} + public string Date { get; set; } + public double UptimePercentage { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Models/ProductionReport/YieldInformation.cs b/ReportingServices.Shared/Models/ProductionReport/YieldInformation.cs index 8a5b500..4343cac 100644 --- a/ReportingServices.Shared/Models/ProductionReport/YieldInformation.cs +++ b/ReportingServices.Shared/Models/ProductionReport/YieldInformation.cs @@ -1,17 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; -namespace ReportingServices.Shared.Models.ProductionReport +namespace ReportingServices.Shared.Models.ProductionReport; + +public class YieldInformation { - public class YieldInformation - { - [JsonPropertyName("Outs")] - public List Outs { get; set; } - [JsonPropertyName("Scrap")] - public List Scrap { get; set; } - } -} + [JsonPropertyName("Outs")] + public List Outs { get; set; } + [JsonPropertyName("Scrap")] + public List Scrap { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs index 72f4ae4..8823fbd 100644 --- a/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs +++ b/ReportingServices.Shared/Repositories/Implementations/ScrapeDatabaseRepository.cs @@ -1,499 +1,493 @@ using Microsoft.Data.SqlClient; using ReportingServices.Shared.Models.PlanningReport; using ReportingServices.Shared.Models.ProductionReport; -using System.Collections.Generic; using System.Data; -namespace ReportingServices.Shared.Repositories +namespace ReportingServices.Shared.Repositories; + +public class ScrapeDatabaseRepository : IScrapeDatabaseRepository { - public class ScrapeDatabaseRepository : IScrapeDatabaseRepository + private SqlConnection _connection; + private readonly string _connectionString; + + public ScrapeDatabaseRepository() => _connectionString = "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true"; + + public void OpenConnection() { - private SqlConnection _connection; - private readonly string _connectionString; + _connection ??= new SqlConnection(_connectionString); - public ScrapeDatabaseRepository() - { - _connectionString = "Server=MESSV01EC.EC.LOCAL\\PROD1,53959;Database=LSL2SQL;User Id=srpadmin;Password=0okm9ijn;TrustServerCertificate=true"; - } - - public void OpenConnection() - { - if (_connection == null) - _connection = new SqlConnection(_connectionString); - - if (_connection.State != ConnectionState.Open) - _connection.Open(); - } - - public void CloseConnection() - { - if (_connection.State != ConnectionState.Closed) - _connection.Close(); - } - - public int GetNumberOfPartChanges(string startDate, string endDate) - { - int result = 0; - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT COUNT(*) FROM " + - "(SELECT REACTOR, COUNT(PROD_SPEC_ID) - 1 AS PCHANGE FROM " + - "(SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) AS PSN_COUNT FROM RDS WHERE DATE_OUT BETWEEN @startDate AND @endDate GROUP BY REACTOR, PROD_SPEC_ID) AS t " + - "GROUP BY REACTOR) AS l WHERE PCHANGE > 0"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@startDate", startDate); - cmd.Parameters.AddWithValue("@endDate", endDate); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - reader.Read(); - - result = int.Parse(reader[0].ToString()); - } - - cmd.Dispose(); - - CloseConnection(); - - return result; - } - - public List GetScrapByDay(List outs) - { - List scrap = new(); - string rdsNumbers = ""; - - foreach (ReactorOutsByRDS rout in outs) - rdsNumbers = rdsNumbers + "'" + rout.RDS_NO + "', "; - - rdsNumbers = rdsNumbers.Substring(0, rdsNumbers.Length - 2); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT " + - " DATE_OUT," + - " SUM(CUST_TOT_REJ) AS TOT_REJ_CUST," + - " SUM(LSL_TOT_REJ) AS TOT_REJ_MANU," + - " SUM(TW_PROD) AS TW_PROD " + - "FROM RDS " + - "WHERE SEQ IN (" + rdsNumbers + ") " + - "GROUP BY DATE_OUT " + - "ORDER BY 1 DESC"; - - cmd.CommandText = query; - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read() && reader[0].ToString() != "1/1/1900 12:00:00 AM") - scrap.Add(new ScrapByDay - { - StartDate = reader[0].ToString(), - TW_PROD = int.Parse(reader[3].ToString()), - TOT_REJ_CUST = int.Parse(reader[1].ToString()), - TOT_REJ_MANU = int.Parse(reader[2].ToString()), - TOT_REJ_WFRS = - int.Parse(reader[1].ToString()) + int.Parse(reader[2].ToString()) - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return scrap; - } - - public List GetReactorPSNWORuns(string startDate, string endDate) - { - List weeklyPartChanges = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) FROM RDS " + - "WHERE DATE_OUT BETWEEN @startDate AND @endDate " + - "GROUP BY REACTOR, PROD_SPEC_ID " + - "ORDER BY 1"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@startDate", startDate); - cmd.Parameters.AddWithValue("@endDate", endDate); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - weeklyPartChanges.Add(new ReactorPSNWORuns - { - REACTOR = reader[0].ToString(), - PSN = reader[1].ToString(), - WO_COUNT = int.Parse(reader[2].ToString()) - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return weeklyPartChanges; - } - - public QuarterlyTargets GetQuarterlyTargets() - { - Dictionary targets = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT THRU_TARGET, THRU_QTY, THRU_PCNT FROM FISCAL_QTR_TARGETS " + - " WHERE THRU_GROUP = 'TOT' " + - " AND FISCAL_YR = " + - " (SELECT FISCAL_YR FROM FISCAL_QTR " + - " WHERE START_DT < SYSDATETIME() " + - " AND END_DT > SYSDATETIME()) " + - " AND FISCAL_QTR = " + - " (SELECT FISCAL_QTR FROM FISCAL_QTR " + - " WHERE START_DT < SYSDATETIME() " + - " AND END_DT > SYSDATETIME()) " + - "UNION " + - "SELECT 'PlanWorkingDays' As THRU_TARGET," + - " PLAN_WORKING_DAYS AS THRU_QTY," + - " NULL AS THRU_PCNT" + - " FROM FISCAL_QTR " + - " WHERE SYSDATETIME() BETWEEN START_DT AND END_DT"; - - cmd.CommandText = query; - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while(reader.Read()) - { - if (reader[0].ToString().ToUpper() == "YIELD") - targets.Add(reader[0].ToString(), float.Parse(reader[2].ToString())); - else if (!string.IsNullOrEmpty(reader[1].ToString())) - targets.Add(reader[0].ToString(), int.Parse(reader[1].ToString())); - } - } - - cmd.Dispose(); - - CloseConnection(); - - QuarterlyTargets quarterlyTargets = new() - { - Reactor_Outs = (int)targets["Reactor_Outs"], - Yield_Outs = (int)targets["Yield_Outs"], - IFX_Scrap = (int)targets["IFX_Scrap"], - Yield = targets["Yield"], - PlanWorkingDays = (int)targets["PlanWorkingDays"] - }; - - return quarterlyTargets; - } - - public List GetReactors() - { - List reactors = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT " + - " REACT_NO, REACT_TYPE, SUSC_POCKET_SIZE, CASE WHEN ACTIVE_LL_DISABLED <> '' THEN 'TRUE' ELSE 'FALSE' END AS \"LL_DISABLED\" " + - " FROM REACTOR " + - " WHERE REACT_ASSIGNMENT IS NOT NULL " + - " AND REACT_ASSIGNMENT <> 'Out of Service' " + - " AND REACT_ASSIGNMENT<> ''"; - - cmd.CommandText = query; - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - reactors.Add(new Reactor - { - ReactorNumber = int.Parse(reader[0].ToString()), - Type = reader[1].ToString(), - PocketSize = reader[2].ToString(), - HasDisabledLoadlock = bool.Parse(reader[3].ToString()) - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return reactors; - } - - public List GetRDSForLastDay(string date) - { - List rdsList = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT rds.REACTOR, rds.REACTOR_TYPE, rds.DATE_OUT, " + - "CASE WHEN lay.UL_TEMP IS NULL THEN '1000' ELSE lay.UL_TEMP END, psn.LAYER_TYPE FROM RDS " + - "INNER JOIN RDS_LAYER lay ON lay.RDS_NO = SEQ " + - "INNER JOIN PROD_SPEC psn ON rds.PROD_SPEC_ID = psn.SEQ " + - "WHERE DATE_OUT >= @date"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@date", date); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - rdsList.Add(new RDS - { - Reactor = int.Parse(reader[0].ToString()), - ReactorType = reader[1].ToString(), - DateOut = DateTime.Parse(reader[2].ToString()), - UnloadTemp = int.Parse(reader[3].ToString()), - LayerType = reader[4].ToString() - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return rdsList; - } - - public List GetRDSRunBetweenDates(string startDate, string endDate) - { - List outs = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT SEQ, WFRS_OUT, DATE_OUT " + - " FROM RDS " + - " WHERE DATE_OUT >= @startDate " + - " AND DATE_OUT < @endDate " + - "ORDER BY DATE_OUT ASC"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@startDate", startDate); - cmd.Parameters.AddWithValue("@endDate", endDate); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - outs.Add(new ReactorOutsByRDS - { - RDS_NO = reader[0].ToString(), - Units = reader[1].ToString(), - EndProcessTime = reader[2].ToString() - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return outs; - } - - public List GetReactorEvents(string startDate, string endDate, string reactorNumber) - { - List events = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT " + - " REACT_NO, " + - " EVENT_DTM, " + - " COMMENT, " + - " REACT_MODE " + - " FROM REACT_EVENT " + - " WHERE EVENT_DTM > @startDate " + - " AND EVENT_DTM < @endDate " + - " AND REACT_NO = @reactorNumber " + - "UNION ALL " + - "SELECT " + - " REACT_NO, " + - " EVENT_DTM, " + - " COMMENT, " + - " REACT_MODE " + - " FROM " + - " (SELECT TOP 1 * FROM REACT_EVENT " + - " WHERE EVENT_DTM < @startDate " + - " AND REACT_NO = @reactorNumber ORDER BY EVENT_DTM DESC) AS tbl1 " + - "ORDER BY EVENT_DTM ASC"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@startDate", startDate); - cmd.Parameters.AddWithValue("@endDate", endDate); - cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - events.Add(new ReactorEvent - { - REACT_NO = reader[0].ToString(), - EVENT_DTM = reader[1].ToString(), - COMMENT = reader[2].ToString(), - REACT_MODE = reader[3].ToString() - }); - } - - cmd.Dispose(); - - CloseConnection(); - - return events; - } - - public ToolEvent GetLatestToolEvent(string toolID) - { - ToolEvent evnt = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT TOP 1 " + - " TOOL_ID, " + - " START_DTM, " + - " TOOL_MODE, " + - " TOOL_MODE_DESC " + - " FROM TOOL_LOG " + - " WHERE TOOL_ID = @toolID " + - "ORDER BY START_DTM DESC"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@toolID", toolID); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - evnt = new ToolEvent - { - TOOL_ID = reader[0].ToString(), - START_DTM = reader[1].ToString(), - TOOL_MODE = reader[2].ToString(), - TOOL_MODE_DESC = reader[3].ToString() - }; - } - - cmd.Dispose(); - - CloseConnection(); - - return evnt; - } - - public int GetLastUpTransaction(string reactorNumber) - { - int lastTransaction = 0; - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT TOP 1 DATEDIFF(MINUTE,START_DTM,SYSDATETIME()) " + - " FROM REACT_MODE " + - " WHERE REACT_NO = @reactorNumber " + - " AND (MODE = 'UP' OR MODE = 'UP_WITH_INCREASED_SAMPLING') " + - "ORDER BY START_DTM DESC"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - lastTransaction = int.Parse(reader[0].ToString()); - } - - cmd.Dispose(); - - CloseConnection(); - - return lastTransaction; - } - - public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate) - { - OutsAndScrapTotal totals = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT SUM(WFRS_OUT) AS OUTS, " + - " SUM(CUST_TOT_REJ) AS CUST, " + - " SUM(LSL_TOT_REJ) AS MANU, " + - " SUM(TW_PROD) AS PROD " + - " FROM RDS " + - " WHERE DATE_OUT >= @startDate " + - " AND DATE_OUT <= @endDate"; - - cmd.CommandText = query; - cmd.Parameters.AddWithValue("@startDate", startDate); - cmd.Parameters.AddWithValue("@endDate", endDate); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - totals = new() - { - Outs = int.Parse(reader[0].ToString()), - CustomerScrap = int.Parse(reader[1].ToString()), - ManufacturingScrap = int.Parse(reader[2].ToString()), - ProductionScrap = int.Parse(reader[3].ToString()), - }; - } - - cmd.Dispose(); - - CloseConnection(); - - return totals; - } - - public DateTime GetQuarterStartDate() - { - DateTime date = new(); - - OpenConnection(); - - SqlCommand cmd = _connection.CreateCommand(); - - string query = "SELECT START_DT " + - " FROM FISCAL_QTR " + - " WHERE START_DT < SYSDATETIME() " + - " AND END_DT > SYSDATETIME()"; - - cmd.CommandText = query; - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - while (reader.Read()) - date = DateTime.Parse(reader[0].ToString()); - } - - cmd.Dispose(); - - CloseConnection(); - - return date; - } + if (_connection.State != ConnectionState.Open) + _connection.Open(); } -} + + public void CloseConnection() + { + if (_connection.State != ConnectionState.Closed) + _connection.Close(); + } + + public int GetNumberOfPartChanges(string startDate, string endDate) + { + int result = 0; + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT COUNT(*) FROM " + + "(SELECT REACTOR, COUNT(PROD_SPEC_ID) - 1 AS PCHANGE FROM " + + "(SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) AS PSN_COUNT FROM RDS WHERE DATE_OUT BETWEEN @startDate AND @endDate GROUP BY REACTOR, PROD_SPEC_ID) AS t " + + "GROUP BY REACTOR) AS l WHERE PCHANGE > 0"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@startDate", startDate); + _ = cmd.Parameters.AddWithValue("@endDate", endDate); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + _ = reader.Read(); + + result = int.Parse(reader[0].ToString()); + } + + cmd.Dispose(); + + CloseConnection(); + + return result; + } + + public List GetScrapByDay(List outs) + { + List scrap = new(); + string rdsNumbers = ""; + + foreach (ReactorOutsByRDS rout in outs) + rdsNumbers = rdsNumbers + "'" + rout.RDS_NO + "', "; + + rdsNumbers = rdsNumbers[..^2]; + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT " + + " DATE_OUT," + + " SUM(CUST_TOT_REJ) AS TOT_REJ_CUST," + + " SUM(LSL_TOT_REJ) AS TOT_REJ_MANU," + + " SUM(TW_PROD) AS TW_PROD " + + "FROM RDS " + + "WHERE SEQ IN (" + rdsNumbers + ") " + + "GROUP BY DATE_OUT " + + "ORDER BY 1 DESC"; + + cmd.CommandText = query; + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read() && reader[0].ToString() != "1/1/1900 12:00:00 AM") + scrap.Add(new ScrapByDay + { + StartDate = reader[0].ToString(), + TW_PROD = int.Parse(reader[3].ToString()), + TOT_REJ_CUST = int.Parse(reader[1].ToString()), + TOT_REJ_MANU = int.Parse(reader[2].ToString()), + TOT_REJ_WFRS = + int.Parse(reader[1].ToString()) + int.Parse(reader[2].ToString()) + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return scrap; + } + + public List GetReactorPSNWORuns(string startDate, string endDate) + { + List weeklyPartChanges = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT REACTOR, PROD_SPEC_ID, COUNT(WO) FROM RDS " + + "WHERE DATE_OUT BETWEEN @startDate AND @endDate " + + "GROUP BY REACTOR, PROD_SPEC_ID " + + "ORDER BY 1"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@startDate", startDate); + _ = cmd.Parameters.AddWithValue("@endDate", endDate); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + weeklyPartChanges.Add(new ReactorPSNWORuns + { + REACTOR = reader[0].ToString(), + PSN = reader[1].ToString(), + WO_COUNT = int.Parse(reader[2].ToString()) + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return weeklyPartChanges; + } + + public QuarterlyTargets GetQuarterlyTargets() + { + Dictionary targets = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT THRU_TARGET, THRU_QTY, THRU_PCNT FROM FISCAL_QTR_TARGETS " + + " WHERE THRU_GROUP = 'TOT' " + + " AND FISCAL_YR = " + + " (SELECT FISCAL_YR FROM FISCAL_QTR " + + " WHERE START_DT < SYSDATETIME() " + + " AND END_DT > SYSDATETIME()) " + + " AND FISCAL_QTR = " + + " (SELECT FISCAL_QTR FROM FISCAL_QTR " + + " WHERE START_DT < SYSDATETIME() " + + " AND END_DT > SYSDATETIME()) " + + "UNION " + + "SELECT 'PlanWorkingDays' As THRU_TARGET," + + " PLAN_WORKING_DAYS AS THRU_QTY," + + " NULL AS THRU_PCNT" + + " FROM FISCAL_QTR " + + " WHERE SYSDATETIME() BETWEEN START_DT AND END_DT"; + + cmd.CommandText = query; + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + { + if (reader[0].ToString().ToUpper() == "YIELD") + targets.Add(reader[0].ToString(), float.Parse(reader[2].ToString())); + else if (!string.IsNullOrEmpty(reader[1].ToString())) + targets.Add(reader[0].ToString(), int.Parse(reader[1].ToString())); + } + } + + cmd.Dispose(); + + CloseConnection(); + + QuarterlyTargets quarterlyTargets = new() + { + Reactor_Outs = (int)targets["Reactor_Outs"], + Yield_Outs = (int)targets["Yield_Outs"], + IFX_Scrap = (int)targets["IFX_Scrap"], + Yield = targets["Yield"], + PlanWorkingDays = (int)targets["PlanWorkingDays"] + }; + + return quarterlyTargets; + } + + public List GetReactors() + { + List reactors = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT " + + " REACT_NO, REACT_TYPE, SUSC_POCKET_SIZE, CASE WHEN ACTIVE_LL_DISABLED <> '' THEN 'TRUE' ELSE 'FALSE' END AS \"LL_DISABLED\" " + + " FROM REACTOR " + + " WHERE REACT_ASSIGNMENT IS NOT NULL " + + " AND REACT_ASSIGNMENT <> 'Out of Service' " + + " AND REACT_ASSIGNMENT<> ''"; + + cmd.CommandText = query; + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + reactors.Add(new Reactor + { + ReactorNumber = int.Parse(reader[0].ToString()), + Type = reader[1].ToString(), + PocketSize = reader[2].ToString(), + HasDisabledLoadlock = bool.Parse(reader[3].ToString()) + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return reactors; + } + + public List GetRDSForLastDay(string date) + { + List rdsList = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT rds.REACTOR, rds.REACTOR_TYPE, rds.DATE_OUT, " + + "CASE WHEN lay.UL_TEMP IS NULL THEN '1000' ELSE lay.UL_TEMP END, psn.LAYER_TYPE FROM RDS " + + "INNER JOIN RDS_LAYER lay ON lay.RDS_NO = SEQ " + + "INNER JOIN PROD_SPEC psn ON rds.PROD_SPEC_ID = psn.SEQ " + + "WHERE DATE_OUT >= @date"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@date", date); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + rdsList.Add(new RDS + { + Reactor = int.Parse(reader[0].ToString()), + ReactorType = reader[1].ToString(), + DateOut = DateTime.Parse(reader[2].ToString()), + UnloadTemp = int.Parse(reader[3].ToString()), + LayerType = reader[4].ToString() + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return rdsList; + } + + public List GetRDSRunBetweenDates(string startDate, string endDate) + { + List outs = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT SEQ, WFRS_OUT, DATE_OUT " + + " FROM RDS " + + " WHERE DATE_OUT >= @startDate " + + " AND DATE_OUT < @endDate " + + "ORDER BY DATE_OUT ASC"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@startDate", startDate); + _ = cmd.Parameters.AddWithValue("@endDate", endDate); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + outs.Add(new ReactorOutsByRDS + { + RDS_NO = reader[0].ToString(), + Units = reader[1].ToString(), + EndProcessTime = reader[2].ToString() + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return outs; + } + + public List GetReactorEvents(string startDate, string endDate, string reactorNumber) + { + List events = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT " + + " REACT_NO, " + + " EVENT_DTM, " + + " COMMENT, " + + " REACT_MODE " + + " FROM REACT_EVENT " + + " WHERE EVENT_DTM > @startDate " + + " AND EVENT_DTM < @endDate " + + " AND REACT_NO = @reactorNumber " + + "UNION ALL " + + "SELECT " + + " REACT_NO, " + + " EVENT_DTM, " + + " COMMENT, " + + " REACT_MODE " + + " FROM " + + " (SELECT TOP 1 * FROM REACT_EVENT " + + " WHERE EVENT_DTM < @startDate " + + " AND REACT_NO = @reactorNumber ORDER BY EVENT_DTM DESC) AS tbl1 " + + "ORDER BY EVENT_DTM ASC"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@startDate", startDate); + _ = cmd.Parameters.AddWithValue("@endDate", endDate); + _ = cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + events.Add(new ReactorEvent + { + REACT_NO = reader[0].ToString(), + EVENT_DTM = reader[1].ToString(), + COMMENT = reader[2].ToString(), + REACT_MODE = reader[3].ToString() + }); + } + + cmd.Dispose(); + + CloseConnection(); + + return events; + } + + public ToolEvent GetLatestToolEvent(string toolID) + { + ToolEvent evnt = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT TOP 1 " + + " TOOL_ID, " + + " START_DTM, " + + " TOOL_MODE, " + + " TOOL_MODE_DESC " + + " FROM TOOL_LOG " + + " WHERE TOOL_ID = @toolID " + + "ORDER BY START_DTM DESC"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@toolID", toolID); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + evnt = new ToolEvent + { + TOOL_ID = reader[0].ToString(), + START_DTM = reader[1].ToString(), + TOOL_MODE = reader[2].ToString(), + TOOL_MODE_DESC = reader[3].ToString() + }; + } + + cmd.Dispose(); + + CloseConnection(); + + return evnt; + } + + public int GetLastUpTransaction(string reactorNumber) + { + int lastTransaction = 0; + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT TOP 1 DATEDIFF(MINUTE,START_DTM,SYSDATETIME()) " + + " FROM REACT_MODE " + + " WHERE REACT_NO = @reactorNumber " + + " AND (MODE = 'UP' OR MODE = 'UP_WITH_INCREASED_SAMPLING') " + + "ORDER BY START_DTM DESC"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@reactorNumber", reactorNumber); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + lastTransaction = int.Parse(reader[0].ToString()); + } + + cmd.Dispose(); + + CloseConnection(); + + return lastTransaction; + } + + public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate) + { + OutsAndScrapTotal totals = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT SUM(WFRS_OUT) AS OUTS, " + + " SUM(CUST_TOT_REJ) AS CUST, " + + " SUM(LSL_TOT_REJ) AS MANU, " + + " SUM(TW_PROD) AS PROD " + + " FROM RDS " + + " WHERE DATE_OUT >= @startDate " + + " AND DATE_OUT <= @endDate"; + + cmd.CommandText = query; + _ = cmd.Parameters.AddWithValue("@startDate", startDate); + _ = cmd.Parameters.AddWithValue("@endDate", endDate); + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + totals = new() + { + Outs = int.Parse(reader[0].ToString()), + CustomerScrap = int.Parse(reader[1].ToString()), + ManufacturingScrap = int.Parse(reader[2].ToString()), + ProductionScrap = int.Parse(reader[3].ToString()), + }; + } + + cmd.Dispose(); + + CloseConnection(); + + return totals; + } + + public DateTime GetQuarterStartDate() + { + DateTime date = new(); + + OpenConnection(); + + SqlCommand cmd = _connection.CreateCommand(); + + string query = "SELECT START_DT " + + " FROM FISCAL_QTR " + + " WHERE START_DT < SYSDATETIME() " + + " AND END_DT > SYSDATETIME()"; + + cmd.CommandText = query; + + using (SqlDataReader reader = cmd.ExecuteReader()) + { + while (reader.Read()) + date = DateTime.Parse(reader[0].ToString()); + } + + cmd.Dispose(); + + CloseConnection(); + + return date; + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/Repositories/Interfaces/IScrapeDatabaseRepository.cs b/ReportingServices.Shared/Repositories/Interfaces/IScrapeDatabaseRepository.cs index bd7b13b..d47720f 100644 --- a/ReportingServices.Shared/Repositories/Interfaces/IScrapeDatabaseRepository.cs +++ b/ReportingServices.Shared/Repositories/Interfaces/IScrapeDatabaseRepository.cs @@ -1,23 +1,22 @@ using ReportingServices.Shared.Models.PlanningReport; using ReportingServices.Shared.Models.ProductionReport; -namespace ReportingServices.Shared.Repositories +namespace ReportingServices.Shared.Repositories; + +public interface IScrapeDatabaseRepository { - public interface IScrapeDatabaseRepository - { - public void OpenConnection(); - public void CloseConnection(); - public List GetScrapByDay(List outs); - public List GetReactorPSNWORuns(string startDate, string endDate); - public int GetNumberOfPartChanges(string startDate, string endDate); - public QuarterlyTargets GetQuarterlyTargets(); - public List GetReactors(); - public List GetRDSForLastDay(string date); - public List GetRDSRunBetweenDates(string startDate, string endDate); - public List GetReactorEvents(string startDate, string endDate, string reactorNumber); - public ToolEvent GetLatestToolEvent(string toolID); - public int GetLastUpTransaction(string reactorNumber); - public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate); - public DateTime GetQuarterStartDate(); - } -} + public void OpenConnection(); + public void CloseConnection(); + public List GetScrapByDay(List outs); + public List GetReactorPSNWORuns(string startDate, string endDate); + public int GetNumberOfPartChanges(string startDate, string endDate); + public QuarterlyTargets GetQuarterlyTargets(); + public List GetReactors(); + public List GetRDSForLastDay(string date); + public List GetRDSRunBetweenDates(string startDate, string endDate); + public List GetReactorEvents(string startDate, string endDate, string reactorNumber); + public ToolEvent GetLatestToolEvent(string toolID); + public int GetLastUpTransaction(string reactorNumber); + public OutsAndScrapTotal GetOutsAndScrapTotals(string startDate, string endDate); + public DateTime GetQuarterStartDate(); +} \ No newline at end of file diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/DailyReport.cs b/ReportingServices.Shared/ViewModels/ProductionReport/DailyReport.cs index d16aed4..46f268f 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/DailyReport.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/DailyReport.cs @@ -1,131 +1,130 @@ using ReportingServices.Shared.HelperClasses; using ReportingServices.Shared.Models.ProductionReport; -namespace ReportingServices.Shared.ViewModels.ProductionReport +namespace ReportingServices.Shared.ViewModels.ProductionReport; + +public class DailyReport { - public class DailyReport + public DateTime StartDate { get; set; } + public DateTime QuarterStartDate { get; set; } + public YieldStatistics CurrentWeek { get; set; } + public YieldStatistics PreviousWeek { get; set; } + public List ToolEvents { get; set; } + public List CleanEvents { get; set; } + public List MetrologyEvents { get; set; } + public Dictionary> ToolStatesByOwner { get; set; } + public Dictionary> DualLayerReactors { get; set; } + public ManualReportEntries ManualReportEntries { get; set; } + public List UnloadTempsByDay { get; set; } + public List SLLTools { get; set; } + public int NumberOfToolsWaferSize6IN { get; set; } + public int NumberOfToolsWaferSize8IN { get; set; } + public int NumberOfToolsWaferSize6INScheduled { get; set; } + public int NumberOfToolsWaferSize8INScheduled { get; set; } + public QuarterlyTargets QuarterlyTargets { get; set; } + + public DailyReport() { - public DateTime StartDate { get; set; } - public DateTime QuarterStartDate { get; set; } - public YieldStatistics CurrentWeek { get; set; } - public YieldStatistics PreviousWeek { get; set; } - public List ToolEvents { get; set; } - public List CleanEvents { get; set; } - public List MetrologyEvents { get; set; } - public Dictionary> ToolStatesByOwner { get; set; } - public Dictionary> DualLayerReactors { get; set; } - public ManualReportEntries ManualReportEntries { get; set; } - public List UnloadTempsByDay { get; set; } - public List SLLTools { get; set; } - public int NumberOfToolsWaferSize6IN { get; set; } - public int NumberOfToolsWaferSize8IN { get; set; } - public int NumberOfToolsWaferSize6INScheduled { get; set; } - public int NumberOfToolsWaferSize8INScheduled { get; set; } - public QuarterlyTargets QuarterlyTargets { get; set; } + CleanEvents = new(); + MetrologyEvents = new(); + DualLayerReactors = new(); + UnloadTempsByDay = new(); + ToolEvents = new(); + StartDate = DateTime.Parse(APIHelperFunctions.GetBeginningOfWeekAsAPIString()); + CurrentWeek = new(StartDate, true); + PreviousWeek = new(StartDate.AddDays(-7), false); + } - public DailyReport() + public void SetReactorInfo(List reactors, List unscheduledReactors) + { + SetToolsByPocketSize(reactors, unscheduledReactors); + SetDisabledLoadlocks(reactors); + } + + public void SetRDSInfo(List rdsList) + { + SetDualLayerReactors(rdsList); + SetUnloadTempsLessThan700(rdsList); + } + + private void SetToolsByPocketSize(List reactors, List unscheduledReactors) + { + NumberOfToolsWaferSize6IN = reactors.Where(react => react.PocketSize.Contains("150")).Count(); + NumberOfToolsWaferSize8IN = reactors.Where(react => react.PocketSize.Contains("200")).Count(); + + NumberOfToolsWaferSize6INScheduled = + reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber) + && react.PocketSize.Contains("150")).Count(); + NumberOfToolsWaferSize8INScheduled = + reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber) + && react.PocketSize.Contains("200")).Count(); + } + + private void SetDisabledLoadlocks(List reactors) + { + List reactorsWithDisabledLoadlocks = reactors.Where(react => react.HasDisabledLoadlock).ToList(); + + int singleLoadlockASM = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("ASM")).Count(); + int singleLoadlockHTR = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("HTR")).Count(); + + foreach (SLLTool sll in SLLTools) { - CleanEvents = new(); - MetrologyEvents = new(); - DualLayerReactors = new(); - UnloadTempsByDay = new(); - ToolEvents = new(); - StartDate = DateTime.Parse(APIHelperFunctions.GetBeginningOfWeekAsAPIString()); - CurrentWeek = new(StartDate, true); - PreviousWeek = new(StartDate.AddDays(-7), false); - } - - public void SetReactorInfo(List reactors, List unscheduledReactors) - { - SetToolsByPocketSize(reactors, unscheduledReactors); - SetDisabledLoadlocks(reactors); - } - - public void SetRDSInfo(List rdsList) - { - SetDualLayerReactors(rdsList); - SetUnloadTempsLessThan700(rdsList); - } - - private void SetToolsByPocketSize(List reactors, List unscheduledReactors) - { - NumberOfToolsWaferSize6IN = reactors.Where(react => react.PocketSize.Contains("150")).Count(); - NumberOfToolsWaferSize8IN = reactors.Where(react => react.PocketSize.Contains("200")).Count(); - - NumberOfToolsWaferSize6INScheduled = - reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber) - && react.PocketSize.Contains("150")).Count(); - NumberOfToolsWaferSize8INScheduled = - reactors.Where(react => !unscheduledReactors.Contains(react.ReactorNumber) - && react.PocketSize.Contains("200")).Count(); - } - - private void SetDisabledLoadlocks(List reactors) - { - List reactorsWithDisabledLoadlocks = reactors.Where(react => react.HasDisabledLoadlock).ToList(); - - int singleLoadlockASM = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("ASM")).Count(); - int singleLoadlockHTR = reactorsWithDisabledLoadlocks.Where(react => react.Type.Contains("HTR")).Count(); - - foreach (SLLTool sll in SLLTools) + if (sll.Date.Date == DateTime.Now.Date) { - if (sll.Date.Date == DateTime.Now.Date) - { - sll.ASM = singleLoadlockASM; - sll.HTR = singleLoadlockHTR; - return; - } + sll.ASM = singleLoadlockASM; + sll.HTR = singleLoadlockHTR; + return; } + } - SLLTools.Add(new SLLTool + SLLTools.Add(new SLLTool + { + Date = DateTime.Now.Date, + ASM = singleLoadlockASM, + HTR = singleLoadlockHTR + }); + } + + private void SetDualLayerReactors(List rdsList) + { + DateTime compareDate = DateTime.Now.Date; + List rdsWithDualLayerPSN = rdsList.Where(rds => rds.LayerType.Contains("2 Layer") && rds.DateOut == compareDate).ToList(); + + DualLayerReactors.Add("ASM", rdsWithDualLayerPSN. + Where(rds => rds.ReactorType.Contains("ASM")). + OrderBy(rds => rds.Reactor). + Select(rds => rds.Reactor). + Distinct().ToList()); + DualLayerReactors.Add("HTR", rdsWithDualLayerPSN. + Where(rds => rds.ReactorType.Contains("HTR")). + OrderBy(rds => rds.Reactor). + Select(rds => rds.Reactor). + Distinct().ToList()); + DualLayerReactors.Add("EPP", rdsWithDualLayerPSN. + Where(rds => rds.ReactorType.Contains("EPP")). + OrderBy(rds => rds.Reactor). + Select(rds => rds.Reactor). + Distinct().ToList()); + } + + private void SetUnloadTempsLessThan700(List rdsList) + { + IEnumerable> rdsWithTempsLessThan700 = rdsList.Where(rds => rds.UnloadTemp < 700).GroupBy(rds => rds.DateOut); + + foreach (IGrouping group in rdsWithTempsLessThan700) + { + UnloadTempsByDay.Add(new UnloadTempsByDay { - Date = DateTime.Now.Date, - ASM = singleLoadlockASM, - HTR = singleLoadlockHTR + Date = group.Key, + ASMUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("ASM")).Select(rds => rds.Reactor).Distinct().Count(), + HTRUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("HTR")).Select(rds => rds.Reactor).Distinct().Count() }); } - - private void SetDualLayerReactors(List rdsList) - { - DateTime compareDate = DateTime.Now.Date; - List rdsWithDualLayerPSN = rdsList.Where(rds => rds.LayerType.Contains("2 Layer") && rds.DateOut == compareDate).ToList(); - - DualLayerReactors.Add("ASM", rdsWithDualLayerPSN. - Where(rds => rds.ReactorType.Contains("ASM")). - OrderBy(rds => rds.Reactor). - Select(rds => rds.Reactor). - Distinct().ToList()); - DualLayerReactors.Add("HTR", rdsWithDualLayerPSN. - Where(rds => rds.ReactorType.Contains("HTR")). - OrderBy(rds => rds.Reactor). - Select(rds => rds.Reactor). - Distinct().ToList()); - DualLayerReactors.Add("EPP", rdsWithDualLayerPSN. - Where(rds => rds.ReactorType.Contains("EPP")). - OrderBy(rds => rds.Reactor). - Select(rds => rds.Reactor). - Distinct().ToList()); - } - - private void SetUnloadTempsLessThan700(List rdsList) - { - var rdsWithTempsLessThan700 = rdsList.Where(rds => rds.UnloadTemp < 700).GroupBy(rds => rds.DateOut); - - foreach (var group in rdsWithTempsLessThan700) - { - UnloadTempsByDay.Add(new UnloadTempsByDay - { - Date = group.Key, - ASMUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("ASM")).Select(rds => rds.Reactor).Distinct().Count(), - HTRUnloadsBelow700 = group.Where(rds => rds.ReactorType.Contains("HTR")).Select(rds => rds.Reactor).Distinct().Count() - }); - } - } - - public void ReverseLists() - { - CurrentWeek.ScrapByDay = APIHelperFunctions.ReverseList(CurrentWeek.ScrapByDay); - PreviousWeek.ScrapByDay = APIHelperFunctions.ReverseList(PreviousWeek.ScrapByDay); - } } -} + + public void ReverseLists() + { + CurrentWeek.ScrapByDay = APIHelperFunctions.ReverseList(CurrentWeek.ScrapByDay); + PreviousWeek.ScrapByDay = APIHelperFunctions.ReverseList(PreviousWeek.ScrapByDay); + } +} \ No newline at end of file diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/SLLTool.cs b/ReportingServices.Shared/ViewModels/ProductionReport/SLLTool.cs index b325abb..2f5afcd 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/SLLTool.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/SLLTool.cs @@ -1,9 +1,8 @@ -namespace ReportingServices.Shared.ViewModels.ProductionReport +namespace ReportingServices.Shared.ViewModels.ProductionReport; + +public class SLLTool { - public class SLLTool - { - public DateTime Date { get; set; } - public int ASM { get; set; } - public int HTR { get; set; } - } -} + public DateTime Date { get; set; } + public int ASM { get; set; } + public int HTR { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/ToolEventView.cs b/ReportingServices.Shared/ViewModels/ProductionReport/ToolEventView.cs index fecfa74..a8ac6df 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/ToolEventView.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/ToolEventView.cs @@ -1,71 +1,93 @@ using ReportingServices.Shared.Models.ProductionReport; -using System.Data; -namespace ReportingServices.Shared.ViewModels.ProductionReport +namespace ReportingServices.Shared.ViewModels.ProductionReport; + +public class ToolEventView { - public class ToolEventView + public string Reactor { get; set; } + public string Type { get; set; } + public string StartDate { get; set; } + public string EndDate { get; set; } + public double Downtime { get; set; } + public bool IsInProduction { get; set; } + public List Events { get; set; } + public ReactorEvent MostRecentEvent { get; set; } + public List Uptime { get; set; } + + public ToolEventView(List events, string startDate, string endDate, string reactor, string type) { - public string Reactor { get; set; } - public string Type { get; set; } - public string StartDate { get; set; } - public string EndDate { get; set; } - public double Downtime { get; set; } - public bool IsInProduction { get; set; } - public List Events { get; set; } - public ReactorEvent MostRecentEvent { get; set; } - public List Uptime { get; set; } + Events = events; + StartDate = startDate; + EndDate = endDate; + Reactor = reactor; + Type = type; + MostRecentEvent = events[^1]; + IsInProduction = EventIsProduction(MostRecentEvent.REACT_MODE); + Uptime = DetermineToolUptimeData(); + } - public ToolEventView(List events, string startDate, string endDate, string reactor, string type) + public void SetDowntime(int timeSinceLastUpTransaction) + { + if (IsInProduction) + Downtime = 0; + else + Downtime = (double)timeSinceLastUpTransaction / 60; + } + + public List DetermineToolUptimeData() + { + List data = new(); + + bool currentModeIsUp; + double uptime = 0; + DateTime compareDate = DateTime.Parse(StartDate).Date; + DateTime previousTransaction = DateTime.Parse(StartDate).Date; + + currentModeIsUp = EventIsProduction(Events[0].REACT_MODE); + + if (Events.Count == 1) + data = LoadUptimeData(currentModeIsUp); + + for (int i = 1; i < Events.Count; i++) { - Events = events; - StartDate = startDate; - EndDate = endDate; - Reactor = reactor; - Type = type; - MostRecentEvent = events[events.Count - 1]; - IsInProduction = EventIsProduction(MostRecentEvent.REACT_MODE); - Uptime = DetermineToolUptimeData(); - } + DateTime currentTransaction = DateTime.Parse(Events[i].EVENT_DTM); - public void SetDowntime(int timeSinceLastUpTransaction) - { - if (IsInProduction) - Downtime = 0; - else - Downtime = (double)timeSinceLastUpTransaction / 60; - } - - public List DetermineToolUptimeData() - { - List data = new(); - - bool currentModeIsUp; - double uptime = 0; - DateTime compareDate = DateTime.Parse(StartDate).Date; - DateTime previousTransaction = DateTime.Parse(StartDate).Date; - - currentModeIsUp = EventIsProduction(Events[0].REACT_MODE); - - if (Events.Count == 1) - data = LoadUptimeData(currentModeIsUp); - - for (int i = 1; i < Events.Count; i++) + if (currentTransaction.Date == compareDate) { - DateTime currentTransaction = DateTime.Parse(Events[i].EVENT_DTM); + if (currentModeIsUp) + uptime += (DateTime.Parse(Events[i].EVENT_DTM) - previousTransaction).TotalMinutes; - if (currentTransaction.Date == compareDate) + currentModeIsUp = EventIsProduction(Events[i].REACT_MODE); + previousTransaction = DateTime.Parse(Events[i].EVENT_DTM); + } + + if ((currentTransaction.Date - compareDate).TotalHours == 24) + { + if (currentModeIsUp) + uptime += (currentTransaction.Date - previousTransaction).TotalMinutes; + + data.Add(new ToolUptimeData + { + Date = compareDate.ToString(), + UptimePercentage = uptime / 1440 + }); + + if (currentModeIsUp) + uptime = (currentTransaction - currentTransaction.Date).TotalMinutes; + else + uptime = 0; + + compareDate = compareDate.AddDays(1); + currentModeIsUp = EventIsProduction(Events[i].REACT_MODE); + previousTransaction = DateTime.Parse(Events[i].EVENT_DTM); + } + + if ((currentTransaction.Date - compareDate).TotalHours > 24) + { + while (currentTransaction.Date != compareDate) { if (currentModeIsUp) - uptime += (DateTime.Parse(Events[i].EVENT_DTM) - previousTransaction).TotalMinutes; - - currentModeIsUp = EventIsProduction(Events[i].REACT_MODE); - previousTransaction = DateTime.Parse(Events[i].EVENT_DTM); - } - - if ((currentTransaction.Date - compareDate).TotalHours == 24) - { - if (currentModeIsUp) - uptime += (currentTransaction.Date - previousTransaction).TotalMinutes; + uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes; data.Add(new ToolUptimeData { @@ -73,19 +95,18 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport UptimePercentage = uptime / 1440 }); - if (currentModeIsUp) - uptime = (currentTransaction - currentTransaction.Date).TotalMinutes; - else - uptime = 0; + uptime = 0; compareDate = compareDate.AddDays(1); - currentModeIsUp = EventIsProduction(Events[i].REACT_MODE); - previousTransaction = DateTime.Parse(Events[i].EVENT_DTM); + previousTransaction = compareDate; } - - if ((currentTransaction.Date - compareDate).TotalHours > 24) + } + + if (i == Events.Count - 1) + { + if (DateTime.Parse(EndDate).Date != compareDate) { - while (currentTransaction.Date != compareDate) + while (DateTime.Parse(EndDate).Date != compareDate) { if (currentModeIsUp) uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes; @@ -103,71 +124,48 @@ namespace ReportingServices.Shared.ViewModels.ProductionReport } } - if (i == Events.Count - 1) - { - if ((DateTime.Parse(EndDate).Date != compareDate)) - { - while (DateTime.Parse(EndDate).Date != compareDate) - { - if (currentModeIsUp) - uptime += (compareDate.AddDays(1) - previousTransaction).TotalMinutes; + if (currentModeIsUp) + uptime += (DateTime.Parse(EndDate) - previousTransaction).TotalMinutes; - data.Add(new ToolUptimeData - { - Date = compareDate.ToString(), - UptimePercentage = uptime / 1440 - }); - - uptime = 0; - - compareDate = compareDate.AddDays(1); - previousTransaction = compareDate; - } - } - - if (currentModeIsUp) - uptime += (DateTime.Parse(EndDate) - previousTransaction).TotalMinutes; - - data.Add(new ToolUptimeData - { - Date = DateTime.Now.Date.ToString(), - UptimePercentage = uptime / (DateTime.Parse(EndDate) - DateTime.Parse(EndDate).Date).TotalMinutes - }); - - } - } - - return data; - } - - private List LoadUptimeData(bool currentModeIsUp) - { - List data = new(); - - double days = (DateTime.Parse(EndDate) - DateTime.Parse(StartDate)).TotalDays; - - for (int i = 0; i < days; i++) - { data.Add(new ToolUptimeData { - Date = DateTime.Parse(StartDate).Date.AddDays(i).ToString(), - UptimePercentage = currentModeIsUp ? 1 : 0 + Date = DateTime.Now.Date.ToString(), + UptimePercentage = uptime / (DateTime.Parse(EndDate) - DateTime.Parse(EndDate).Date).TotalMinutes }); + } - - return data; - } - - private bool EventIsProduction(string evnt) - { - if (evnt.ToUpper() == "UP") - return true; - - if (evnt.ToUpper() == "UP_WITH_INCREASED_SAMPLING") - return true; - - return false; } + return data; } -} + + private List LoadUptimeData(bool currentModeIsUp) + { + List data = new(); + + double days = (DateTime.Parse(EndDate) - DateTime.Parse(StartDate)).TotalDays; + + for (int i = 0; i < days; i++) + { + data.Add(new ToolUptimeData + { + Date = DateTime.Parse(StartDate).Date.AddDays(i).ToString(), + UptimePercentage = currentModeIsUp ? 1 : 0 + }); + } + + return data; + } + + private bool EventIsProduction(string evnt) + { + if (evnt.ToUpper() == "UP") + return true; + + if (evnt.ToUpper() == "UP_WITH_INCREASED_SAMPLING") + return true; + + return false; + } + +} \ No newline at end of file diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/UnloadTempsByDay.cs b/ReportingServices.Shared/ViewModels/ProductionReport/UnloadTempsByDay.cs index 0bb91ac..e415373 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/UnloadTempsByDay.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/UnloadTempsByDay.cs @@ -1,9 +1,8 @@ -namespace ReportingServices.Shared.ViewModels.ProductionReport +namespace ReportingServices.Shared.ViewModels.ProductionReport; + +public class UnloadTempsByDay { - public class UnloadTempsByDay - { - public DateTime Date { get; set; } - public int ASMUnloadsBelow700 { get; set; } - public int HTRUnloadsBelow700 { get; set; } - } -} + public DateTime Date { get; set; } + public int ASMUnloadsBelow700 { get; set; } + public int HTRUnloadsBelow700 { get; set; } +} \ No newline at end of file diff --git a/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs b/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs index f4c16f5..ec26f07 100644 --- a/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs +++ b/ReportingServices.Shared/ViewModels/ProductionReport/YieldStatistics.cs @@ -1,62 +1,61 @@ using ReportingServices.Shared.Models.ProductionReport; -namespace ReportingServices.Shared.ViewModels.ProductionReport +namespace ReportingServices.Shared.ViewModels.ProductionReport; + +public class YieldStatistics { - public class YieldStatistics + public DateTime StartDate { get; set; } + public List OutsByDay { get; set; } + public List ScrapByDay { get; set; } + public OutsAndScrapTotal QTDOutsAndScrap { get; set; } + public int DailyPlanWafers { get; set; } + public bool IsCurrentWeek { get; set; } + + public YieldStatistics(DateTime startDate, bool isCurrentWeek) { - public DateTime StartDate { get; set; } - public List OutsByDay { get; set; } - public List ScrapByDay { get; set; } - public OutsAndScrapTotal QTDOutsAndScrap { get; set; } - public int DailyPlanWafers { get; set; } - public bool IsCurrentWeek { get; set; } + StartDate = startDate; + IsCurrentWeek = isCurrentWeek; + } - public YieldStatistics(DateTime startDate, bool isCurrentWeek) + public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets) + { + OutsByDay = GetReactorOutsByDay(yieldInformation.Outs); + ScrapByDay = yieldInformation.Scrap; + DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays; + } + + public static List GetDistinctDatesFromReactorOuts(List outs) + { + List dates = new(); + + foreach (ReactorOutsByRDS rout in outs) { - StartDate = startDate; - IsCurrentWeek = isCurrentWeek; + if (!dates.Contains(DateTime.Parse(rout.EndProcessTime).Date.ToString())) + dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString()); } - public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets) - { - OutsByDay = GetReactorOutsByDay(yieldInformation.Outs); - ScrapByDay = yieldInformation.Scrap; - DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays; - } + return dates; + } - public static List GetDistinctDatesFromReactorOuts(List outs) + public static List GetReactorOutsByDay(List outs) + { + List outsByDay = new(); + + List dates = GetDistinctDatesFromReactorOuts(outs); + + foreach (string date in dates) { - List dates = new(); + int waferCount = 0; foreach (ReactorOutsByRDS rout in outs) { - if (!dates.Contains(DateTime.Parse(rout.EndProcessTime).Date.ToString())) - dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString()); + if (DateTime.Parse(rout.EndProcessTime).Date.ToString() == date) + waferCount += (int)float.Parse(rout.Units); } - return dates; + outsByDay.Add(new ReactorOutsByDay { StartDate = date, TotalWafers = waferCount }); } - public static List GetReactorOutsByDay(List outs) - { - List outsByDay = new(); - - List dates = GetDistinctDatesFromReactorOuts(outs); - - foreach (string date in dates) - { - int waferCount = 0; - - foreach (ReactorOutsByRDS rout in outs) - { - if (DateTime.Parse(rout.EndProcessTime).Date.ToString() == date) - waferCount += (int)float.Parse(rout.Units); - } - - outsByDay.Add(new ReactorOutsByDay { StartDate = date, TotalWafers = waferCount }); - } - - return outsByDay; - } + return outsByDay; } -} +} \ No newline at end of file diff --git a/ReportingServices.Test/APIHelperTester.cs b/ReportingServices.Test/APIHelperTester.cs index 231b249..323daaa 100644 --- a/ReportingServices.Test/APIHelperTester.cs +++ b/ReportingServices.Test/APIHelperTester.cs @@ -1,88 +1,88 @@ using ReportingServices.Shared.HelperClasses; -namespace ReportingServices.Test +namespace ReportingServices.Test; + +[TestClass] +public class APIHelperTester { - [TestClass] - public class APIHelperTester + [TestMethod] + public void CheckShortDateWithPassedInDate() { - [TestMethod] - public void CheckShortDateWithPassedInDate() - { - // Arrange - string date = DateTime.Now.ToString("yyyy-M-d") + " 0:0:0"; + // Arrange + string date = DateTime.Now.ToString("yyyy-M-d") + " 0:0:0"; - // Act - string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), false); + // Act + string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), false); - // Assert - Assert.AreEqual(date, callerDate); - } + // Assert + Assert.AreEqual(date, callerDate); + } - [TestMethod] - public void CheckFullDateWithPassedInDate() - { - // Arrange - string date = DateTime.Now.ToString("yyyy-M-d HH:mm:ss"); + [TestMethod] + public void CheckFullDateWithPassedInDate() + { + // Arrange + string date = DateTime.Now.ToString("yyyy-M-d HH:mm:ss"); - // Act - string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), true); + // Act + string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), true); - // Assert - Assert.AreEqual(date, callerDate); - } + // Assert + Assert.AreEqual(date, callerDate); + } - [TestMethod] - public void CheckStartDateForWeekNow() - { - // Arrange - string date = DetermineDate(); + [TestMethod] + public void CheckStartDateForWeekNow() + { + // Arrange + string date = DetermineDate(); - // Act - string callerDate = APIHelperFunctions.GetBeginningOfWeekAsAPIString(); + // Act + string callerDate = APIHelperFunctions.GetBeginningOfWeekAsAPIString(); - // Assert - Assert.AreEqual(date, callerDate); - } + // Assert + Assert.AreEqual(date, callerDate); + } - [TestMethod] - public void CheckStartDateForDayPassedInAndHoursAdded() - { - // Arrange - string date = "2022-11-23 00:00:00"; + [TestMethod] + public void CheckStartDateForDayPassedInAndHoursAdded() + { + // Arrange + string date = "2022-11-23 00:00:00"; - // Act - string callerDate = APIHelperFunctions.GetDateWithOffsetAsAPIString("11/23/2022 12:30 PM", -12.5f); + // Act + string callerDate = APIHelperFunctions.GetDateWithOffsetAsAPIString("11/23/2022 12:30 PM", -12.5f); - // Assert - Assert.AreEqual(date, callerDate); - } + // Assert + Assert.AreEqual(date, callerDate); + } - private string DetermineDate() - { - DateTime date = DateTime.Now; + private string DetermineDate() + { + DateTime date = DateTime.Now; - if (date.DayOfWeek == DayOfWeek.Monday) - date = date.AddDays(-7); + if (date.DayOfWeek == DayOfWeek.Monday) + date = date.AddDays(-7); - if (date.DayOfWeek == DayOfWeek.Tuesday) - date = date.AddDays(-1); + if (date.DayOfWeek == DayOfWeek.Tuesday) + date = date.AddDays(-1); - if (date.DayOfWeek == DayOfWeek.Wednesday) - date = date.AddDays(-2); + if (date.DayOfWeek == DayOfWeek.Wednesday) + date = date.AddDays(-2); - if (date.DayOfWeek == DayOfWeek.Thursday) - date = date.AddDays(-3); + if (date.DayOfWeek == DayOfWeek.Thursday) + date = date.AddDays(-3); - if (date.DayOfWeek == DayOfWeek.Friday) - date = date.AddDays(-4); + if (date.DayOfWeek == DayOfWeek.Friday) + date = date.AddDays(-4); - if (date.DayOfWeek == DayOfWeek.Saturday) - date = date.AddDays(-5); + if (date.DayOfWeek == DayOfWeek.Saturday) + date = date.AddDays(-5); - if (date.DayOfWeek == DayOfWeek.Sunday) - date = date.AddDays(-6); + if (date.DayOfWeek == DayOfWeek.Sunday) + date = date.AddDays(-6); - return date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0"; ; - } + return date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0"; + ; } } \ No newline at end of file diff --git a/ReportingServices.Test/DailyReportTester.cs b/ReportingServices.Test/DailyReportTester.cs index aea18ab..7056f92 100644 --- a/ReportingServices.Test/DailyReportTester.cs +++ b/ReportingServices.Test/DailyReportTester.cs @@ -1,67 +1,64 @@ -using ReportingServices.Shared.ViewModels.ProductionReport; +namespace ReportingServices.Test; -namespace ReportingServices.Test +[TestClass] +public class DailyReportTester { - [TestClass] - public class DailyReportTester + [TestMethod] + public void SetRDSInfo_InputData_CalculatedAndStoresCorrectly() { - [TestMethod] - public void SetRDSInfo_InputData_CalculatedAndStoresCorrectly() + /* + // Arrange + DailyReport rpt = new() { - /* - // Arrange - DailyReport rpt = new() - { - CurrentEntries = TestingClass.ManualReportEntries - }; - Dictionary> dualLayerReactors = new() - { - { "ASM", new List() { 24, 62 } }, - { "HTR", new List() { } }, - { "EPP", new List() { 40, 42, 44, 46 } }, - }; - int asmUnloadTempsLessThan700 = 3; - int htrUnloadTempsLessThan700 = 3; - - // Act - rpt.SetRDSInfo(TestingClass.RDSList); - - // Assert - CollectionAssert.AreEqual(dualLayerReactors["ASM"].ToList(), rpt.DualLayerReactors["ASM"].ToList()); - CollectionAssert.AreEqual(dualLayerReactors["HTR"].ToList(), rpt.DualLayerReactors["HTR"].ToList()); - CollectionAssert.AreEqual(dualLayerReactors["EPP"].ToList(), rpt.DualLayerReactors["EPP"].ToList()); - Assert.AreEqual(asmUnloadTempsLessThan700, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].ASMUnloadTempsLessThan700); - Assert.AreEqual(htrUnloadTempsLessThan700, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].HTRUnloadTempsLessThan700); - */ - } - - [TestMethod] - public void SetReactorInfo_InputData_CalculatedAndStoresCorrectly() + CurrentEntries = TestingClass.ManualReportEntries + }; + Dictionary> dualLayerReactors = new() { - /* - // Arrange - DailyReport rpt = new() - { - CurrentEntries = TestingClass.ManualReportEntries - }; - int numberOfToolsWaferSize6IN = 11; - int numberOfToolsWaferSize8IN = 46; - int numberOfToolsWaferSize6INScheduled = 9; - int numberOfToolsWaferSize8INScheduled = 39; - int singleLoadLockASM = 5; - int singleLoadLockHTR = 14; + { "ASM", new List() { 24, 62 } }, + { "HTR", new List() { } }, + { "EPP", new List() { 40, 42, 44, 46 } }, + }; + int asmUnloadTempsLessThan700 = 3; + int htrUnloadTempsLessThan700 = 3; - // Act - rpt.SetReactorInfo(TestingClass.Reactors, TestingClass.UnscheduledReactors); + // Act + rpt.SetRDSInfo(TestingClass.RDSList); - // Assert - Assert.AreEqual(numberOfToolsWaferSize6IN, rpt.NumberOfToolsWaferSize6IN); - Assert.AreEqual(numberOfToolsWaferSize8IN, rpt.NumberOfToolsWaferSize8IN); - Assert.AreEqual(numberOfToolsWaferSize6INScheduled, rpt.NumberOfToolsWaferSize6INScheduled); - Assert.AreEqual(numberOfToolsWaferSize8INScheduled, rpt.NumberOfToolsWaferSize8INScheduled); - Assert.AreEqual(singleLoadLockASM, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].ASMSingleLoadLock); - Assert.AreEqual(singleLoadLockHTR, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].HTRSingleLoadLock); - */ - } + // Assert + CollectionAssert.AreEqual(dualLayerReactors["ASM"].ToList(), rpt.DualLayerReactors["ASM"].ToList()); + CollectionAssert.AreEqual(dualLayerReactors["HTR"].ToList(), rpt.DualLayerReactors["HTR"].ToList()); + CollectionAssert.AreEqual(dualLayerReactors["EPP"].ToList(), rpt.DualLayerReactors["EPP"].ToList()); + Assert.AreEqual(asmUnloadTempsLessThan700, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].ASMUnloadTempsLessThan700); + Assert.AreEqual(htrUnloadTempsLessThan700, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].HTRUnloadTempsLessThan700); + */ } -} + + [TestMethod] + public void SetReactorInfo_InputData_CalculatedAndStoresCorrectly() + { + /* + // Arrange + DailyReport rpt = new() + { + CurrentEntries = TestingClass.ManualReportEntries + }; + int numberOfToolsWaferSize6IN = 11; + int numberOfToolsWaferSize8IN = 46; + int numberOfToolsWaferSize6INScheduled = 9; + int numberOfToolsWaferSize8INScheduled = 39; + int singleLoadLockASM = 5; + int singleLoadLockHTR = 14; + + // Act + rpt.SetReactorInfo(TestingClass.Reactors, TestingClass.UnscheduledReactors); + + // Assert + Assert.AreEqual(numberOfToolsWaferSize6IN, rpt.NumberOfToolsWaferSize6IN); + Assert.AreEqual(numberOfToolsWaferSize8IN, rpt.NumberOfToolsWaferSize8IN); + Assert.AreEqual(numberOfToolsWaferSize6INScheduled, rpt.NumberOfToolsWaferSize6INScheduled); + Assert.AreEqual(numberOfToolsWaferSize8INScheduled, rpt.NumberOfToolsWaferSize8INScheduled); + Assert.AreEqual(singleLoadLockASM, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].ASMSingleLoadLock); + Assert.AreEqual(singleLoadLockHTR, rpt.CurrentEntries[(int)DateTime.Now.DayOfWeek].HTRSingleLoadLock); + */ + } +} \ No newline at end of file diff --git a/ReportingServices.Test/TestingClass.cs b/ReportingServices.Test/TestingClass.cs index 4b50502..424cdc4 100644 --- a/ReportingServices.Test/TestingClass.cs +++ b/ReportingServices.Test/TestingClass.cs @@ -1,186 +1,185 @@ using ReportingServices.Shared.Models.ProductionReport; -namespace ReportingServices.Test +namespace ReportingServices.Test; + +internal static class TestingClass { - internal static class TestingClass + public static readonly List RDSList = new() { - public static readonly List RDSList = new() - { - new RDS { Reactor = 79, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 600, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 45, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 66, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 28, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 28, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 63, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 63, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 23, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 23, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 32, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 58, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 650, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 77, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 77, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 57, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 57, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 20, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 20, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 43, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 43, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 29, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 25, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 38, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 38, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 64, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 64, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 32, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 37, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 37, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 30, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 31, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 36, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 21, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 21, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 73, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 75, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 75, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 53, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 53, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 36, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 61, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 61, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 49, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 54, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 50, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 40, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 40, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 44, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 44, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, - new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 50, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 54, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, - new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" } - }; + new RDS { Reactor = 79, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 600, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 45, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 62, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 24, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 66, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 28, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 28, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 63, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 63, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 23, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 23, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 32, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 58, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 650, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 77, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 77, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 57, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 57, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 20, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 20, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 43, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 43, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 29, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 25, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 38, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 38, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 64, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 64, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 32, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 37, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 37, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 30, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 31, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 33, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 55, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 36, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 21, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 21, ReactorType = "ASM", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 73, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 75, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 75, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 750, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 51, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 53, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 53, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 35, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 36, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 68, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 41, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 70, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 74, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 700, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 61, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 61, ReactorType = "ASM+", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 800, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 49, ReactorType = "HTR", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 550, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 54, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 50, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 40, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 40, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 42, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 44, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 44, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 46, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 2 Layer" }, + new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 50, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 54, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 48, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" }, + new RDS { Reactor = 52, ReactorType = "EPP", DateOut = new DateTime(2022, 12, 13), UnloadTemp = 1000, LayerType = "Standard 1 Layer" } + }; - public static readonly List Reactors = new() - { - new Reactor { ReactorNumber = 20, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 21, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 22, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 23, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 24, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 25, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 26, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 27, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 28, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 29, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 30, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 31, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 32, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 33, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 34, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 35, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 36, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 37, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 38, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 39, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 40, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 41, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 42, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 43, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 44, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 45, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 46, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 47, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 48, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 49, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 50, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 51, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 52, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 53, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 54, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 55, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 56, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 57, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 58, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 59, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 60, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 61, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 62, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 63, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 64, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 65, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 66, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 68, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 70, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 72, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, - new Reactor { ReactorNumber = 73, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 74, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 75, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 77, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 79, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 100, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, - new Reactor { ReactorNumber = 101, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false } - }; + public static readonly List Reactors = new() + { + new Reactor { ReactorNumber = 20, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 21, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 22, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 23, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 24, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 25, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 26, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 27, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 28, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 29, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 30, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 31, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 32, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 33, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 34, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 35, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 36, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 37, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 38, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 39, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 40, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 41, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 42, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 43, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 44, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 45, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 46, Type = "EPP", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 47, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 48, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 49, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 50, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 51, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 52, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 53, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 54, Type = "EPP", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 55, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 56, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 57, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 58, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 59, Type = "ASM", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 60, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 61, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 62, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 63, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 64, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 65, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 66, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 68, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 70, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 72, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = true }, + new Reactor { ReactorNumber = 73, Type = "HTR", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 74, Type = "HTR", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 75, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 77, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 79, Type = "ASM+", PocketSize = "200 mm 8 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 100, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false }, + new Reactor { ReactorNumber = 101, Type = "ASM", PocketSize = "150 mm 6 in", HasDisabledLoadlock = false } + }; - public static readonly List UnscheduledReactors = new() - { - 20, 25, 30, 32, 49, 55, 59, 67, 69, 70, 74 - }; + public static readonly List UnscheduledReactors = new() + { + 20, 25, 30, 32, 49, 55, 59, 67, 69, 70, 74 + }; - public static readonly List ManualReportEntries = new() - { - new ManualReportEntries(), - new ManualReportEntries(), - new ManualReportEntries(), - new ManualReportEntries(), - new ManualReportEntries(), - new ManualReportEntries(), - new ManualReportEntries(), - }; - } -} + public static readonly List ManualReportEntries = new() + { + new ManualReportEntries(), + new ManualReportEntries(), + new ManualReportEntries(), + new ManualReportEntries(), + new ManualReportEntries(), + new ManualReportEntries(), + new ManualReportEntries(), + }; +} \ No newline at end of file diff --git a/ReportingServices.UI/Controllers/HomeController.cs b/ReportingServices.UI/Controllers/HomeController.cs index 271549d..0fc1f06 100644 --- a/ReportingServices.UI/Controllers/HomeController.cs +++ b/ReportingServices.UI/Controllers/HomeController.cs @@ -2,27 +2,20 @@ using ReportingServices.UI.Models; using System.Diagnostics; -namespace ReportingServices.UI.Controllers +namespace ReportingServices.UI.Controllers; + +public class HomeController : Controller { - public class HomeController : Controller + private readonly ILogger _logger; + + public HomeController(ILogger logger) => _logger = logger; + + public IActionResult Index() { - private readonly ILogger _logger; - - public HomeController(ILogger logger) - { - _logger = logger; - } - - public IActionResult Index() - { - _logger.LogInformation("Starting Index Page"); - return View(); - } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } + _logger.LogInformation("Starting Index Page"); + return View(); } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() => View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } \ No newline at end of file diff --git a/ReportingServices.UI/Controllers/PlanningReportController.cs b/ReportingServices.UI/Controllers/PlanningReportController.cs index 943656f..b5822a0 100644 --- a/ReportingServices.UI/Controllers/PlanningReportController.cs +++ b/ReportingServices.UI/Controllers/PlanningReportController.cs @@ -1,55 +1,50 @@ using Microsoft.AspNetCore.Mvc; -using ReportingServices.Shared.Models.PlanningReport; using ReportingServices.Shared.HelperClasses; +using ReportingServices.Shared.Models.PlanningReport; -namespace ReportingServices.UI.Controllers +namespace ReportingServices.UI.Controllers; + +public class PlanningReportController : Controller { - public class PlanningReportController : Controller + private readonly ILogger _logger; + private readonly string _baseUrl; + + public PlanningReportController(ILogger logger) { - private readonly ILogger _logger; - private readonly string _baseUrl; + _logger = logger; + _baseUrl = "http://localhost:50201/api/" + "ScrapeDB/"; - public PlanningReportController(ILogger logger) - { - _logger = logger; - _baseUrl = "http://localhost:50201/api/" + "ScrapeDB/"; - - _logger.LogInformation("Base API Address: {baseUrl}", _baseUrl); - } - - public IActionResult Index() - { - return View(); - } - - public async Task WeeklyPartChangesReport(DateTime startDate, DateTime endDate) - { - string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString(); - string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString(); - - _logger.LogInformation("Part Change URL: {url}", partChangeUrl); - _logger.LogInformation("PSN WO Runs URL: {url}", psnwoRunsUrl); - - WeeklyPartChanges weeklyPartChanges = new(); - - try - { - int numberOfPartChanges = await ApiCaller.GetApi(partChangeUrl); - List reactorPSNWORuns = await ApiCaller.GetApi>(psnwoRunsUrl); - - weeklyPartChanges.TotalPartChanges = numberOfPartChanges; - weeklyPartChanges.StartDate = startDate.ToShortDateString(); - weeklyPartChanges.EndDate = endDate.ToShortDateString(); - weeklyPartChanges.ReactorPSNWORuns = reactorPSNWORuns; - } - catch (Exception ex) - { - _logger.LogCritical(ex, "Failed to get a response from API calls."); - RedirectToAction("Error"); - } - - - return View(weeklyPartChanges); - } + _logger.LogInformation("Base API Address: {baseUrl}", _baseUrl); } -} + + public IActionResult Index() => View(); + + public async Task WeeklyPartChangesReport(DateTime startDate, DateTime endDate) + { + string partChangeUrl = _baseUrl + "PartChanges?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString(); + string psnwoRunsUrl = _baseUrl + "PSNWO?startDate=" + startDate.ToString() + "&endDate=" + endDate.ToString(); + + _logger.LogInformation("Part Change URL: {url}", partChangeUrl); + _logger.LogInformation("PSN WO Runs URL: {url}", psnwoRunsUrl); + + WeeklyPartChanges weeklyPartChanges = new(); + + try + { + int numberOfPartChanges = await ApiCaller.GetApi(partChangeUrl); + List reactorPSNWORuns = await ApiCaller.GetApi>(psnwoRunsUrl); + + weeklyPartChanges.TotalPartChanges = numberOfPartChanges; + weeklyPartChanges.StartDate = startDate.ToShortDateString(); + weeklyPartChanges.EndDate = endDate.ToShortDateString(); + weeklyPartChanges.ReactorPSNWORuns = reactorPSNWORuns; + } + catch (Exception ex) + { + _logger.LogCritical(ex, "Failed to get a response from API calls."); + _ = RedirectToAction("Error"); + } + + return View(weeklyPartChanges); + } +} \ No newline at end of file diff --git a/ReportingServices.UI/Controllers/ProductionReportController.cs b/ReportingServices.UI/Controllers/ProductionReportController.cs index fa3a908..a661875 100644 --- a/ReportingServices.UI/Controllers/ProductionReportController.cs +++ b/ReportingServices.UI/Controllers/ProductionReportController.cs @@ -3,62 +3,57 @@ using ReportingServices.Shared.HelperClasses; using ReportingServices.Shared.Models.ProductionReport; using ReportingServices.Shared.ViewModels.ProductionReport; -namespace ReportingServices.UI.Controllers +namespace ReportingServices.UI.Controllers; + +public class ProductionReportController : Controller { - public class ProductionReportController : Controller + private readonly ILogger _logger; + private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json"; + private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json"; + private readonly string _baseDBUrl; + + public ProductionReportController(ILogger logger) { - private readonly ILogger _logger; - private readonly string _dailyRptFilePath = "wwwroot/Assets/DailyReportInfo.json"; - private readonly string _toolStateOwnerFilePath = "wwwroot/Assets/ToolStates.json"; - private readonly string _baseDBUrl; + _logger = logger; + _baseDBUrl = "http://localhost:50201/api/"; - public ProductionReportController(ILogger logger) + _logger.LogInformation("Base Database Address: {baseUrl}", _baseDBUrl); + } + + public IActionResult Index() => View(); + + public IActionResult DailyReport() + { + string baseScrapeDbUrl = _baseDBUrl + "ScrapeDB/"; + + try { - _logger = logger; - _baseDBUrl = "http://localhost:50201/api/"; + DailyReport dailyReport = DailyReportHelper.SetUpDailyReport(_logger, baseScrapeDbUrl); + Dictionary> toolStateOwners = JsonFileHandler.LoadJSONFile>>(_toolStateOwnerFilePath); - _logger.LogInformation("Base Database Address: {baseUrl}", _baseDBUrl); + dailyReport.ToolStatesByOwner = toolStateOwners; + + return View(dailyReport); } - - - public IActionResult Index() + catch (Exception ex) { + _logger.LogCritical(ex, "Failed to load report"); return View(); } - - public IActionResult DailyReport() - { - string baseScrapeDbUrl = _baseDBUrl + "ScrapeDB/"; - - try - { - DailyReport dailyReport = DailyReportHelper.SetUpDailyReport(_logger, baseScrapeDbUrl); - Dictionary> toolStateOwners = JsonFileHandler.LoadJSONFile>>(_toolStateOwnerFilePath); - - dailyReport.ToolStatesByOwner = toolStateOwners; - - return View(dailyReport); - } - catch (Exception ex) - { - _logger.LogCritical(ex, "Failed to load report"); - return View(); - } - } - - public IActionResult EditDailyReport() - { - ManualReportEntries entries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); - - return View(entries); - } - - [HttpPost] - public IActionResult EditDailyReport(ManualReportEntries rpt) - { - JsonFileHandler.SaveJSONFile(rpt, _dailyRptFilePath); - - return RedirectToAction("DailyReport"); - } } -} + + public IActionResult EditDailyReport() + { + ManualReportEntries entries = JsonFileHandler.LoadJSONFile(_dailyRptFilePath); + + return View(entries); + } + + [HttpPost] + public IActionResult EditDailyReport(ManualReportEntries rpt) + { + JsonFileHandler.SaveJSONFile(rpt, _dailyRptFilePath); + + return RedirectToAction("DailyReport"); + } +} \ No newline at end of file diff --git a/ReportingServices.UI/Models/ErrorViewModel.cs b/ReportingServices.UI/Models/ErrorViewModel.cs index c2598b2..57936d3 100644 --- a/ReportingServices.UI/Models/ErrorViewModel.cs +++ b/ReportingServices.UI/Models/ErrorViewModel.cs @@ -1,9 +1,8 @@ -namespace ReportingServices.UI.Models -{ - public class ErrorViewModel - { - public string RequestId { get; set; } +namespace ReportingServices.UI.Models; - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - } +public class ErrorViewModel +{ + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); } \ No newline at end of file diff --git a/ReportingServices.UI/Program.cs b/ReportingServices.UI/Program.cs index 768e45e..16473d3 100644 --- a/ReportingServices.UI/Program.cs +++ b/ReportingServices.UI/Program.cs @@ -1,50 +1,54 @@ -using ReportingServices.Shared.Repositories; using Serilog; -LoggerConfiguration loggerConfiguration = new(); - -var builder = WebApplication.CreateBuilder(args); -Environment.SetEnvironmentVariable("workingDirectory", "D:\\tmp\\logging\\MesaReportingServices\\UI"); -_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, builder.Configuration); -_ = SerilogHostBuilderExtensions.UseSerilog(builder.Host); -Log.Logger = loggerConfiguration.CreateLogger(); -Serilog.ILogger log = Log.ForContext(); - - -// Add services to the container. -builder.Services.AddControllersWithViews(); - -var app = builder.Build(); - -// Configure the HTTP request pipeline. -if (!app.Environment.IsDevelopment()) +internal class Program { - app.UseExceptionHandler("/Home/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); -} + private static void Main(string[] args) + { + LoggerConfiguration loggerConfiguration = new(); -app.UseHttpsRedirection(); -app.UseStaticFiles(); + WebApplicationBuilder builder = WebApplication.CreateBuilder(args); + Environment.SetEnvironmentVariable("workingDirectory", "D:\\tmp\\logging\\MesaReportingServices\\UI"); + _ = loggerConfiguration.ReadFrom.Configuration(builder.Configuration); + _ = builder.Host.UseSerilog(); + Log.Logger = loggerConfiguration.CreateLogger(); + Serilog.ILogger log = Log.ForContext(); -app.UseRouting(); + // Add services to the container. + _ = builder.Services.AddControllersWithViews(); -app.UseAuthorization(); + WebApplication app = builder.Build(); -app.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); -_ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); -log.Information("Starting Web Application"); -try -{ - app.Run(); -} -catch (Exception ex) -{ - log.Fatal(ex, "Host terminated unexpectedly"); -} -finally -{ - Log.CloseAndFlush(); -} + // Configure the HTTP request pipeline. + if (!app.Environment.IsDevelopment()) + { + _ = app.UseExceptionHandler("/Home/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + _ = app.UseHsts(); + } + + _ = app.UseHttpsRedirection(); + _ = app.UseStaticFiles(); + + _ = app.UseRouting(); + + _ = app.UseAuthorization(); + + _ = app.MapControllerRoute( + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); + _ = app.Lifetime.ApplicationStopped.Register(Log.CloseAndFlush); + log.Information("Starting Web Application"); + try + { + app.Run(); + } + catch (Exception ex) + { + log.Fatal(ex, "Host terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } +} \ No newline at end of file diff --git a/ReportingServices.sln b/ReportingServices.sln index 3fbe636..d7466df 100644 --- a/ReportingServices.sln +++ b/ReportingServices.sln @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReportingServices.Shared", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E5DEBD84-0237-49D3-B6D7-6F5736174EF6}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitignore = .gitignore .config\dotnet-tools.json = .config\dotnet-tools.json EndProjectSection EndProject