Match TFS Changeset 303361

This commit is contained in:
Mike Phares 2022-02-01 19:49:09 -07:00
parent 6b4180dd68
commit a6abe8fdbd
115 changed files with 8097 additions and 13 deletions

336
.editorconfig Normal file
View File

@ -0,0 +1,336 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4
# New line preferences
end_of_line = crlf
insert_final_newline = false
#### .NET Coding Conventions ####
# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = false
file_header_template = unset
# this. and Me. preferences
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
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
# Parentheses preferences
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
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members
# Expression-level preferences
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_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
# Field preferences
dotnet_style_readonly_field = true:warning
# Parameter preferences
dotnet_code_quality_unused_parameters = all
# Suppression preferences
dotnet_remove_unnecessary_suppression_exclusions = 0
# New line preferences
dotnet_style_allow_multiple_blank_lines_experimental = false:warning
dotnet_style_allow_statement_immediately_after_block_experimental = true
#### C# Coding Conventions ####
# var preferences
csharp_style_var_elsewhere = false:warning
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning
# Expression-bodied members
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
# Pattern matching preferences
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_not_pattern = true:warning
csharp_style_prefer_pattern_matching = true:warning
csharp_style_prefer_switch_expression = true:warning
# Null-checking preferences
csharp_style_conditional_delegate_call = true
# Modifier preferences
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
# Code-block preferences
csharp_prefer_braces = false
csharp_prefer_simple_using_statement = true:warning
csharp_style_namespace_declarations = file_scoped:warning
# Expression-level preferences
csharp_prefer_simple_default_expression = true:warning
csharp_style_deconstructed_variable_declaration = false
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_inlined_variable_declaration = false
csharp_style_pattern_local_over_anonymous_function = true:warning
csharp_style_prefer_index_operator = false:warning
csharp_style_prefer_null_check_over_type_check = true
csharp_style_prefer_range_operator = false:warning
csharp_style_throw_expression = true
csharp_style_unused_value_assignment_preference = discard_variable:warning
csharp_style_unused_value_expression_statement_preference = discard_variable:warning
# 'using' directive preferences
csharp_using_directive_placement = outside_namespace
# New line preferences
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
#### C# Formatting Rules ####
# New line preferences
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
# Indentation preferences
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
# Space preferences
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
# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
#### Naming styles ####
# Naming rules
dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
dotnet_naming_rule.types_should_be_pascal_case.severity = warning
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
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.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_should_be_private_of_internal_field.style = private_of_internal_field
dotnet_naming_rule.enum_should_be_pascal_case.severity = warning
dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum
dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case
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.symbols = public_or_protected_field
dotnet_naming_rule.public_or_protected_field_should_be_private_of_internal_field.style = private_of_internal_field
dotnet_naming_rule.class_should_be_pascal_case.severity = warning
dotnet_naming_rule.class_should_be_pascal_case.symbols = class
dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.method_should_be_pascal_case.severity = warning
dotnet_naming_rule.method_should_be_pascal_case.symbols = method
dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case
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.symbols = private_or_internal_static_field
dotnet_naming_rule.private_or_internal_static_field_should_be_private_of_internal_field.style = private_of_internal_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_field_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.property_should_be_pascal_case.severity = warning
dotnet_naming_rule.property_should_be_pascal_case.symbols = property
dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.static_method_should_be_pascal_case.severity = warning
dotnet_naming_rule.static_method_should_be_pascal_case.symbols = static_method
dotnet_naming_rule.static_method_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.abstract_method_should_be_pascal_case.severity = warning
dotnet_naming_rule.abstract_method_should_be_pascal_case.symbols = abstract_method
dotnet_naming_rule.abstract_method_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.private_method_should_be_pascal_case.severity = warning
dotnet_naming_rule.private_method_should_be_pascal_case.symbols = private_method
dotnet_naming_rule.private_method_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.event_should_be_pascal_case.severity = warning
dotnet_naming_rule.event_should_be_pascal_case.symbols = event
dotnet_naming_rule.event_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.delegate_should_be_pascal_case.severity = warning
dotnet_naming_rule.delegate_should_be_pascal_case.symbols = delegate
dotnet_naming_rule.delegate_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.struct_should_be_pascal_case.severity = warning
dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct
dotnet_naming_rule.struct_should_be_pascal_case.style = pascal_case
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
# Symbol specifications
dotnet_naming_symbols.class.applicable_kinds = class
dotnet_naming_symbols.class.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.class.required_modifiers =
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =
dotnet_naming_symbols.struct.applicable_kinds = struct
dotnet_naming_symbols.struct.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.struct.required_modifiers =
dotnet_naming_symbols.enum.applicable_kinds = enum
dotnet_naming_symbols.enum.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.enum.required_modifiers =
dotnet_naming_symbols.delegate.applicable_kinds = delegate
dotnet_naming_symbols.delegate.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.delegate.required_modifiers =
dotnet_naming_symbols.event.applicable_kinds = event
dotnet_naming_symbols.event.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.event.required_modifiers =
dotnet_naming_symbols.method.applicable_kinds = method
dotnet_naming_symbols.method.applicable_accessibilities = public
dotnet_naming_symbols.method.required_modifiers =
dotnet_naming_symbols.private_method.applicable_kinds = method
dotnet_naming_symbols.private_method.applicable_accessibilities = private
dotnet_naming_symbols.private_method.required_modifiers =
dotnet_naming_symbols.abstract_method.applicable_kinds = method
dotnet_naming_symbols.abstract_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.abstract_method.required_modifiers = abstract
dotnet_naming_symbols.static_method.applicable_kinds = method
dotnet_naming_symbols.static_method.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.static_method.required_modifiers = static
dotnet_naming_symbols.property.applicable_kinds = property
dotnet_naming_symbols.property.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.property.required_modifiers =
dotnet_naming_symbols.public_or_protected_field.applicable_kinds = field
dotnet_naming_symbols.public_or_protected_field.applicable_accessibilities = public, protected
dotnet_naming_symbols.public_or_protected_field.required_modifiers =
dotnet_naming_symbols.static_field.applicable_kinds = field
dotnet_naming_symbols.static_field.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.static_field.required_modifiers = static
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_field.required_modifiers =
dotnet_naming_symbols.private_or_internal_static_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_static_field.applicable_accessibilities = internal, private, private_protected
dotnet_naming_symbols.private_or_internal_static_field.required_modifiers = static
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =
# Naming styles
dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.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.begins_with_i.capitalization = pascal_case
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_style.private_of_internal_field.capitalization = pascal_case

9
.gitignore vendored
View File

@ -328,3 +328,12 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
##
## Visual Studio Code
##
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

View File

@ -0,0 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>APCViewer.Tests</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<VSTestLogger>trx</VSTestLogger>
<VSTestResultsDirectory>../../../Trunk/APC Viewer/05_TestResults/TestResults</VSTestResultsDirectory>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<DefineConstants>OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../APC Viewer/APC Viewer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,173 @@
using APCViewer.Models;
using Helper.Log;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shared;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text.Json;
using System.Threading;
namespace APCViewer.Tests
{
[TestClass]
public class BackgroundTests : LoggingUnitTesting, IBackground
{
private static WebClient _WebClient;
private static string _WorkingDirectory;
private static Singleton.IBackground _Background;
private static BackgroundTests _LoggingUnitTesting;
internal static BackgroundTests LoggingUnitTesting => _LoggingUnitTesting;
public BackgroundTests() : base(testContext: null, declaringType: null)
{
if (_LoggingUnitTesting is null)
throw new Exception();
}
public BackgroundTests(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
{
}
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
if (_LoggingUnitTesting is null)
_LoggingUnitTesting = new BackgroundTests(testContext);
_LoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
_WebClient = new WebClient();
Assembly assembly = Assembly.GetExecutingAssembly();
_WorkingDirectory = Log.GetWorkingDirectory(assembly.GetName().Name, "IFXApps");
Type type = new StackFrame().GetMethod().DeclaringType;
_Background = new Singleton.Background(_LoggingUnitTesting.IsEnvironment, _LoggingUnitTesting.ConfigurationRoot, _WorkingDirectory);
_Background.Update(_LoggingUnitTesting.Logger, _WebClient);
Assert.IsNotNull(_Background);
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.URLs));
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.Server));
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.MonARessource));
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_LoggingUnitTesting.Logger is null))
_LoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_LoggingUnitTesting is null))
_LoggingUnitTesting.Dispose();
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
public void APCDataCallback_WindowsDevelopment()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
public void APCDataCallback_WindowsStaging()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
public void APCDataCallback_WindowsProduction()
{
_Background.APCDataCallback();
Assert.IsTrue(true);
}
void IBackground.APCDataCallback()
{
APCDataCallback_WindowsDevelopment();
APCDataCallback_WindowsStaging();
APCDataCallback_WindowsProduction();
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
public void EAFLogDataCallback_WindowsDevelopment()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
public void EAFLogDataCallback_WindowsStaging()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
public void EAFLogDataCallback_WindowsProduction()
{
_Background.EAFLogDataCallback();
Assert.IsTrue(true);
}
void IBackground.EAFLogDataCallback()
{
EAFLogDataCallback_WindowsDevelopment();
EAFLogDataCallback_WindowsStaging();
EAFLogDataCallback_WindowsProduction();
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
public void EDADataCallback_WindowsDevelopment()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
public void EDADataCallback_WindowsStaging()
{
MethodBase methodBase = new StackFrame().GetMethod();
_Logger.LogInformation($"Skipped - {methodBase.Name}");
Assert.IsTrue(true);
}
[TestMethod]
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
public void EDADataCallback_WindowsProduction()
{
_Background.EDADataCallback();
Assert.IsTrue(true);
}
void IBackground.EDADataCallback()
{
EDADataCallback_WindowsDevelopment();
EDADataCallback_WindowsStaging();
EDADataCallback_WindowsProduction();
}
}
}
// dotnet build --runtime win-x64
// dotnet test --runtime win-x64 --no-build --filter EDADataCallback_WindowsProduction --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.BackgroundTests & TestCategory=WindowsDevelopment" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.BackgroundTests & TestCategory=WindowsStaging" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.BackgroundTests & TestCategory=WindowsProduction" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")

View File

@ -0,0 +1,282 @@
using APCViewer.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shared;
using System;
using System.Diagnostics;
using System.Net;
using System.Reflection;
namespace APCViewer.Tests
{
[TestClass]
public class HomeControllerTests : LoggingUnitTesting, IHomeController
{
private static long _Sequence;
private static WebClient _WebClient;
private static string _WorkingDirectory;
private static Singleton.IBackground _Background;
private static Controllers.HomeController _HomeController;
private static HomeControllerTests _LoggingUnitTesting;
internal static HomeControllerTests LoggingUnitTesting => _LoggingUnitTesting;
public HomeControllerTests() : base(testContext: null, declaringType: null)
{
if (_LoggingUnitTesting is null)
throw new Exception();
}
public HomeControllerTests(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
{
}
[ClassInitialize]
public static void ClassInitialize(TestContext testContext)
{
if (_LoggingUnitTesting is null)
_LoggingUnitTesting = new HomeControllerTests(testContext);
_LoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
_WebClient = new WebClient();
_Sequence = 637642624355251927;
Assembly assembly = Assembly.GetExecutingAssembly();
_WorkingDirectory = Log.GetWorkingDirectory(assembly.GetName().Name, "IFXApps");
Type type = new StackFrame().GetMethod().DeclaringType;
_Background = new Singleton.Background(_LoggingUnitTesting.IsEnvironment, _LoggingUnitTesting.ConfigurationRoot, _WorkingDirectory);
_HomeController = new Controllers.HomeController(new NullLogger<Controllers.HomeController>(), _Background, httpContextAccessor: null);
_Background.Update(_LoggingUnitTesting.Logger, _WebClient);
Assert.IsNotNull(_Background);
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.URLs));
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.Server));
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.MonARessource));
}
[ClassCleanup()]
public static void ClassCleanup()
{
if (!(_LoggingUnitTesting.Logger is null))
_LoggingUnitTesting.Logger.LogInformation("Cleanup");
if (!(_LoggingUnitTesting is null))
_LoggingUnitTesting.Dispose();
}
[TestMethod]
public void Background()
{
IActionResult IActionResult = _HomeController.Background();
Assert.IsTrue(true);
}
IActionResult IHomeController.Background(bool? message_clear, bool? exceptions_clear, bool? set_is_primary_instance, bool? logistics_clear)
{
Background();
return null;
}
[Ignore]
[TestMethod]
public void DownloadCustomIPDSF()
{
IActionResult IActionResult = _HomeController.DownloadCustomIPDSF(ipdsf_file: "");
Assert.IsTrue(true);
}
IActionResult IHomeController.DownloadCustomIPDSF(string ipdsf_file)
{
DownloadCustomIPDSF();
return null;
}
[Ignore]
[TestMethod]
public void DownloadCustomPDSF()
{
IActionResult IActionResult = _HomeController.DownloadCustomPDSF(pdsf_file: "");
Assert.IsTrue(true);
}
IActionResult IHomeController.DownloadCustomPDSF(string pdsf_file)
{
DownloadCustomPDSF();
return null;
}
[Ignore]
[TestMethod]
public void DownloadIPDSF()
{
IActionResult IActionResult = _HomeController.DownloadIPDSF(_Sequence.ToString());
Assert.IsTrue(true);
}
IActionResult IHomeController.DownloadIPDSF(string id)
{
DownloadIPDSF();
return null;
}
[Ignore]
[TestMethod]
public void DownloadPDSF()
{
IActionResult IActionResult = _HomeController.DownloadPDSF(_Sequence.ToString());
Assert.IsTrue(true);
}
IActionResult IHomeController.DownloadPDSF(string id)
{
DownloadPDSF();
return null;
}
[TestMethod]
public void Encode()
{
IActionResult IActionResult = _HomeController.Encode();
Assert.IsTrue(true);
}
IActionResult IHomeController.Encode(string value)
{
Encode();
return null;
}
IActionResult IHomeController.Error()
{
throw new System.NotImplementedException();
}
[TestMethod]
public void Index()
{
IActionResult IActionResult = _HomeController.Index();
Assert.IsTrue(true);
}
IActionResult IHomeController.Index()
{
Index();
return null;
}
[Ignore]
[TestMethod]
public void IPDSF()
{
IActionResult IActionResult = _HomeController.IPDSF();
Assert.IsTrue(true);
}
IActionResult IHomeController.IPDSF(string directory, string filter, bool is_gaN, bool is_Si)
{
IPDSF();
return null;
}
[Ignore]
[TestMethod]
public void PDSF()
{
IActionResult IActionResult = _HomeController.PDSF();
Assert.IsTrue(true);
}
IActionResult IHomeController.PDSF(string directory, string filter, bool is_gaN, bool is_Si)
{
PDSF();
return null;
}
[TestMethod]
public void Privacy()
{
IActionResult IActionResult = _HomeController.Privacy();
Assert.IsTrue(true);
}
IActionResult IHomeController.Privacy()
{
Privacy();
return null;
}
[TestMethod]
public void TimePivot()
{
IActionResult IActionResult = _HomeController.TimePivot();
Assert.IsTrue(true);
}
IActionResult IHomeController.TimePivot(bool is_gaN, bool is_Si)
{
TimePivot();
return null;
}
[Ignore]
[TestMethod]
public void ViewCustomIPDSF()
{
IActionResult IActionResult = _HomeController.ViewCustomIPDSF(ipdsf_file: "");
Assert.IsTrue(true);
}
ContentResult IHomeController.ViewCustomIPDSF(string ipdsf_file)
{
ViewCustomIPDSF();
return null;
}
[Ignore]
[TestMethod]
public void ViewCustomPDSF()
{
IActionResult IActionResult = _HomeController.ViewCustomPDSF(pdsf_file: "");
Assert.IsTrue(true);
}
ContentResult IHomeController.ViewCustomPDSF(string pdsf_file)
{
ViewCustomPDSF();
return null;
}
[TestMethod]
public void ViewIPDSF()
{
IActionResult IActionResult = _HomeController.ViewIPDSF(_Sequence.ToString());
Assert.IsTrue(true);
}
ContentResult IHomeController.ViewIPDSF(string id)
{
ViewIPDSF();
return null;
}
[TestMethod]
public void ViewPDSF()
{
IActionResult IActionResult = _HomeController.ViewPDSF(_Sequence.ToString());
Assert.IsTrue(true);
}
ContentResult IHomeController.ViewPDSF(string id)
{
ViewPDSF();
return null;
}
}
}
// dotnet build --runtime win-x64
// dotnet test --no-build --filter ViewPDSF
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsDevelopment" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsStaging" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsProduction" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")

View File

@ -0,0 +1,71 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
namespace Shared
{
public class LoggingUnitTesting : UnitTesting, IDisposable
{
protected ILogger<object> _Logger;
protected ILoggerFactory _LoggerFactory;
protected readonly LogLevel? _DefaultLogLevel;
protected readonly LogLevel? _Log4netProviderLogLevel;
protected readonly IConfigurationRoot _ConfigurationRoot;
public ILogger<object> Logger => _Logger;
public LogLevel? DefaultLogLevel => _DefaultLogLevel;
public ILoggerFactory LoggerFactory => _LoggerFactory;
public IConfigurationRoot ConfigurationRoot => _ConfigurationRoot;
public LogLevel? Log4netProviderLogLevel => _Log4netProviderLogLevel;
public LoggingUnitTesting(TestContext testContext, Type declaringType) : base(testContext, declaringType)
{
_LoggerFactory = new LoggerFactory();
if (testContext is null || declaringType is null)
{
_ConfigurationRoot = null;
_DefaultLogLevel = null;
_Log4netProviderLogLevel = null;
}
else
{
LogLevel logLevel;
IConfigurationSection configurationSection;
List<LogLevel> logLevels = new List<LogLevel>();
string defaultLogLevelSection = "Logging:LogLevel:Default";
string log4netProviderLogLevelSection = "Logging:LogLevel:Log4netProvider";
string[] sections = new string[] { defaultLogLevelSection, log4netProviderLogLevelSection };
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(_IsEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
_ConfigurationRoot = configurationBuilder.Build();
foreach (string section in sections)
{
configurationSection = _ConfigurationRoot.GetSection(section);
if (configurationSection is null)
logLevel = LogLevel.Debug;
else if (!Enum.TryParse<LogLevel>(configurationSection.Value, out logLevel))
logLevel = LogLevel.Debug;
logLevels.Add(logLevel);
}
_DefaultLogLevel = logLevels[0];
_Log4netProviderLogLevel = logLevels[1];
}
if (DefaultLogLevel.HasValue)
_LoggerFactory.AddProvider(new DebugProvider(DefaultLogLevel.Value));
if (DefaultLogLevel.HasValue)
_LoggerFactory.AddProvider(new ConsoleProvider(DefaultLogLevel.Value));
_Logger = _LoggerFactory.CreateLogger<object>();
}
public void Dispose()
{
_LoggerFactory.Dispose();
}
}
}

View File

@ -0,0 +1,93 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading;
namespace Shared
{
public class UnitTesting
{
protected readonly IsEnvironment _IsEnvironment;
public IsEnvironment IsEnvironment => _IsEnvironment;
public UnitTesting(TestContext testContext, Type declaringType)
{
if (testContext is null || declaringType is null)
_IsEnvironment = null;
else
{
string projectDirectory = GetProjectDirectory(testContext);
string json = JsonSerializer.Serialize(testContext.Properties);
string vsCodeDirectory = Path.Combine(projectDirectory, ".vscode");
if (!Directory.Exists(vsCodeDirectory))
Directory.CreateDirectory(vsCodeDirectory);
string launchText = GetLaunchText();
File.WriteAllText(Path.Combine(vsCodeDirectory, "launch.json"), launchText);
for (int i = 0; i < int.MaxValue; i++)
{
if (!json.Contains("Debugger.IsAttached") || Debugger.IsAttached)
break;
Thread.Sleep(500);
}
MethodBase methodBase = declaringType.GetMethod(testContext.TestName);
if (!(methodBase is null))
{
TestCategoryAttribute testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>();
if (!(testCategoryAttribute is null))
{
foreach (string testCategory in testCategoryAttribute.TestCategories)
_IsEnvironment = new IsEnvironment(testCategory);
}
}
if (_IsEnvironment is null)
_IsEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached);
}
}
internal static string GetProjectDirectory(TestContext testContext)
{
string result;
string[] checkFiles = null;
result = Path.GetDirectoryName(testContext.DeploymentDirectory);
for (int i = 0; i < int.MaxValue; i++)
{
if (string.IsNullOrEmpty(result))
break;
checkFiles = Directory.GetFiles(result, "*.Tests.*proj", SearchOption.TopDirectoryOnly);
if (checkFiles.Any())
break;
result = Path.GetDirectoryName(result);
}
if (string.IsNullOrEmpty(result) || checkFiles is null || !checkFiles.Any())
throw new Exception(result);
return result;
}
internal static string GetLaunchText()
{
StringBuilder result = new StringBuilder();
result.
AppendLine("{").
AppendLine(" \"configurations\": [").
AppendLine(" {").
AppendLine(" \"name\": \".NET Core Attach\",").
AppendLine(" \"type\": \"coreclr\",").
AppendLine(" \"request\": \"attach\",").
AppendLine($" \"processId\": {System.Diagnostics.Process.GetCurrentProcess().Id}").
AppendLine(" }").
AppendLine(" ]").
AppendLine("}");
return result.ToString();
}
}
}

View File

@ -0,0 +1,49 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<LangVersion>9.0</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>APCViewer</RootNamespace>
<RuntimeFrameworkVersion>5.0.2</RuntimeFrameworkVersion>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<UserSecretsId>d71a673c-be39-45b5-ae5f-4c22639be045</UserSecretsId>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<DefineConstants>OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Infineon.Monitoring.MonA" Version="2.0.0" />
<PackageReference Include="Log4net" Version="2.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.5" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.1.4" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\images\" />
<Folder Include="wwwroot\js\html5shiv\3.7.2\" />
<Folder Include="wwwroot\js\respond\1.4.2\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,352 @@
using APCViewer.Models;
using APCViewer.Singleton;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Shared;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Web;
namespace APCViewer.Controllers
{
public class HomeController : Controller, IHomeController
{
private readonly Log _Log;
private readonly Singleton.IBackground _Background;
private readonly IHttpContextAccessor _HttpContextAccessor;
public HomeController(ILogger<HomeController> logger, Singleton.IBackground background, IHttpContextAccessor httpContextAccessor)
{
_Log = new Log(logger);
_Background = background;
_HttpContextAccessor = httpContextAccessor;
}
public ActionResult Index()
{
return View();
}
public ActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public ActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public ActionResult Encode(string value = null)
{
string result = string.Empty;
if (!string.IsNullOrEmpty(value))
result = HttpUtility.UrlEncode(value);
return Content(result, "text/plain");
}
public ActionResult Background(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null, bool? logistics_clear = null)
{
_Background.SendStatusOk();
if (message_clear.HasValue && message_clear.Value)
_Background.ClearMessage();
if (exceptions_clear.HasValue && exceptions_clear.Value)
_Background.Exceptions.Clear();
if (set_is_primary_instance.HasValue)
{
if (set_is_primary_instance.Value)
_Background.SetIsPrimaryInstance();
else
_Background.ClearIsPrimaryInstance();
}
if (logistics_clear.HasValue && logistics_clear.Value)
_Background.LogisticsClear();
string message;
if (string.IsNullOrWhiteSpace(_Background.Message))
message = "N/A";
else
message = _Background.Message;
//Response.AppendToLog(_Background.Message);
List<Exception> exceptions = new();
foreach (Exception exception in _Background.Exceptions)
exceptions.Add(exception);
ViewBag.Message = message;
ViewBag.Exceptions = exceptions;
ViewBag.URLs = _Background.AppSettings.URLs;
ViewBag.Profile = _Background.IsEnvironment.Profile;
ViewBag.WorkingDirectory = _Background.WorkingDirectory;
ViewBag.IsPrimaryInstance = _Background.IsPrimaryInstance();
ViewBag.ExceptionsCount = string.Concat("Exception(s) - ", exceptions.Count);
return View();
}
public ActionResult PDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false)
{
Tuple<int, object, object, string> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forPDSF: true);
ViewBag.Files = tuple.Item1;
ViewBag.Grouped = tuple.Item2;
ViewBag.Sorted = tuple.Item3;
ViewBag.Directory = tuple.Item4;
return View();
}
private StringBuilder GetPDSFHtml(string pdsfFile)
{
StringBuilder result = new();
result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(pdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(pdsfFile))
result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
else
{
bool header = true;
bool body = false;
bool footer = false;
string logisticsSegment;
List<string> logistics = new();
string[] pdsfLines = System.IO.File.ReadAllLines(pdsfFile);
foreach (string pdsfLine in pdsfLines)
{
if (pdsfLine.StartsWith("LOGISTICS_"))
{
logisticsSegment = pdsfLine.Split('\t')[0];
if (!logistics.Contains(logisticsSegment))
{
logistics.Add(logisticsSegment);
result.AppendLine("</table><hr /><table border = '1'>");
}
}
if (pdsfLine.StartsWith("NUM_DATA_ROWS") || pdsfLine.StartsWith("END_HEADER"))
{
body = false;
footer = true;
result.AppendLine("</table><hr /><table border = '1'>");
}
if (header)
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body)
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer)
{
if (pdsfLine.StartsWith("DELIMITER"))
result.Append("<tr><td>").Append(pdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else
result.Append("<tr><td>").Append(pdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
}
else
throw new Exception();
if (pdsfLine.StartsWith("END_OFFSET"))
{
header = false;
body = true;
result.AppendLine("</table><hr /><table border = '1'>");
}
}
}
result.AppendLine("</table></body>");
return result;
}
public ContentResult ViewPDSF(string id = null)
{
string pdsfFile;
StringBuilder result = new();
if (!id.Contains('_'))
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
else
{
pdsfFile = _Background.GetPDSF(sequence);
result = GetPDSFHtml(pdsfFile);
}
}
return Content(result.ToString(), "text/html");
}
public ActionResult DownloadPDSF(string id = null)
{
string pdsfFile;
if (!id.Contains('_'))
throw new Exception("A) Error: Invalid input");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
throw new Exception("B) Error: Invalid input");
else
pdsfFile = _Background.GetPDSF(sequence);
}
return File(pdsfFile, "text/plain", Path.GetFileName(pdsfFile));
}
public ContentResult ViewCustomPDSF(string pdsf_file = null)
{
StringBuilder result = GetPDSFHtml(pdsf_file);
return Content(result.ToString(), "text/html");
}
public ActionResult DownloadCustomPDSF(string pdsf_file = null)
{
if (string.IsNullOrEmpty(pdsf_file))
throw new Exception("Error: Invalid input");
else if (!System.IO.File.Exists(pdsf_file))
throw new Exception("Error: file does not exist");
return File(pdsf_file, "text/plain", Path.GetFileName(pdsf_file));
}
public ActionResult IPDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false)
{
Tuple<int, object, object, string> tuple = _Background.SetViewBag(directory, filter, isGaN: is_gaN, isSi: is_Si, forIPDSF: true);
ViewBag.Files = tuple.Item1;
ViewBag.Grouped = tuple.Item2;
ViewBag.Sorted = tuple.Item3;
ViewBag.Directory = tuple.Item4;
return View();
}
private StringBuilder GetIPDSFHtml(string ipdsfFile)
{
StringBuilder result = new();
result.AppendLine("<html><body><table border = '1'>");
if (string.IsNullOrEmpty(ipdsfFile))
throw new Exception("<tr><td>Invalid input</td></tr>");
else if (!System.IO.File.Exists(ipdsfFile))
result.AppendLine("<tr><td>File doesn't exist!</td></tr>");
else
{
bool header = true;
bool body = false;
bool footer = false;
string logisticsSegment;
List<string> logistics = new();
string[] ipdsfLines = System.IO.File.ReadAllLines(ipdsfFile);
foreach (string ipdsfLine in ipdsfLines)
{
if (ipdsfLine.StartsWith("LOGISTICS_"))
{
logisticsSegment = ipdsfLine.Split('\t')[0];
if (!logistics.Contains(logisticsSegment))
{
logistics.Add(logisticsSegment);
result.AppendLine("</table><hr /><table border = '1'>");
}
}
if (ipdsfLine.StartsWith("NUM_DATA_ROWS") || ipdsfLine.StartsWith("END_HEADER"))
{
body = false;
footer = true;
result.AppendLine("</table><hr /><table border = '1'>");
}
if (header)
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (body)
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else if (footer)
{
if (ipdsfLine.StartsWith("DELIMITER"))
result.Append("<tr><td>").Append(ipdsfLine.Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
else
result.Append("<tr><td>").Append(ipdsfLine.Replace("\t", "</td><td>").Replace("=", "</td><td>").Replace(";", "</td><td>")).AppendLine("&nbsp;</td></tr>");
}
else
throw new Exception();
if (ipdsfLine.StartsWith("END_OFFSET"))
{
header = false;
body = true;
result.AppendLine("</table><hr /><table border = '1'>");
}
}
}
result.AppendLine("</table></body>");
return result;
}
public ContentResult ViewIPDSF(string id = null)
{
string ipdsfFile;
StringBuilder result = new();
if (!id.Contains('_'))
result.AppendLine("<html><body><table border = '1'><tr><td>A) Error: Invalid input</td></tr></table></body>");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
result.AppendLine("<html><body><table border = '1'><tr><td>B) Error: Invalid input</td></tr></table></body>");
else
{
ipdsfFile = _Background.GetIPDSF(sequence);
result = GetIPDSFHtml(ipdsfFile);
}
}
return Content(result.ToString(), "text/html");
}
public ActionResult DownloadIPDSF(string id = null)
{
string ipdsfFile;
if (!id.Contains('_'))
throw new Exception("A) Error: Invalid input");
else
{
if (!long.TryParse(id.Split('_')[1], out long sequence))
throw new Exception("B) Error: Invalid input");
else
ipdsfFile = _Background.GetIPDSF(sequence);
}
return File(ipdsfFile, "text/plain", Path.GetFileName(ipdsfFile));
}
public ContentResult ViewCustomIPDSF(string ipdsf_file = null)
{
StringBuilder result = GetIPDSFHtml(ipdsf_file);
return Content(result.ToString(), "text/html");
}
public ActionResult DownloadCustomIPDSF(string ipdsf_file = null)
{
if (string.IsNullOrEmpty(ipdsf_file))
throw new Exception("Error: Invalid input");
else if (!System.IO.File.Exists(ipdsf_file))
throw new Exception("Error: file does not exist");
return File(ipdsf_file, "text/plain", Path.GetFileName(ipdsf_file));
}
public ActionResult TimePivot(bool is_gaN = false, bool is_Si = false)
{
Tuple<List<string[]>, List<string[]>> tuple = _Background.GetTimePivot(isGaN: is_gaN, isSi: is_Si);
ViewBag.forIPDSF = tuple.Item1;
ViewBag.forPDSF = tuple.Item2;
return View();
}
IActionResult IHomeController.Background(bool? message_clear, bool? exceptions_clear, bool? set_is_primary_instance, bool? logistics_clear) => throw new NotImplementedException();
IActionResult IHomeController.DownloadCustomIPDSF(string ipdsf_file) => throw new NotImplementedException();
IActionResult IHomeController.DownloadCustomPDSF(string pdsf_file) => throw new NotImplementedException();
IActionResult IHomeController.DownloadIPDSF(string id) => throw new NotImplementedException();
IActionResult IHomeController.DownloadPDSF(string id) => throw new NotImplementedException();
IActionResult IHomeController.Encode(string value) => throw new NotImplementedException();
IActionResult IHomeController.Error() => throw new NotImplementedException();
IActionResult IHomeController.Index() => throw new NotImplementedException();
IActionResult IHomeController.IPDSF(string directory, string filter, bool is_gaN, bool is_Si) => throw new NotImplementedException();
IActionResult IHomeController.PDSF(string directory, string filter, bool is_gaN, bool is_Si) => throw new NotImplementedException();
IActionResult IHomeController.Privacy() => throw new NotImplementedException();
IActionResult IHomeController.TimePivot(bool is_gaN, bool is_Si) => throw new NotImplementedException();
}
}
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "L:\net5.0\APCViewer"
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "D:\net5.0\APCViewer"
// dotnet publish --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o "D:\.jenkins\publish\manual-Mesa-0\APCViewer"
//http://mestsa005.infineon.com:8080/job/Mesa/buildWithParameters?token=DotnetRules&projectName=APC%20Viewer
// http://mestsa02ec.ec.local:8080/job/Mesa/buildWithParameters?token=DotnetRules&projectName=APC%20Viewer
//sc create APCViewer_5003 binPath="D:\.jenkins\publish\manual-Mesa-0\APCViewer\APC Viewer.exe"

View File

@ -0,0 +1,9 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~M:APCViewer.Controllers.HomeController.GetPDSFHtml(System.String)~System.Text.StringBuilder")]
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "<Pending>", Scope = "member", Target = "~M:APCViewer.Controllers.HomeController.GetIPDSFHtml(System.String)~System.Text.StringBuilder")]

View File

@ -0,0 +1,168 @@
using APCViewer.Singleton;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
namespace APCViewer.HostedService
{
public class TimedHostedService : IHostedService, IDisposable
{
private readonly int _ExecutionCount;
private readonly WebClient _WebClient;
private readonly Background _Background;
private readonly IConfiguration _Configuration;
private readonly ILogger<TimedHostedService> _Log;
private Timer _APCDataTimer;
private Timer _EDADataTimer;
private Timer _EAFLogDataTimer;
public TimedHostedService(Background background, IConfiguration configuration, IServiceProvider serviceProvider)
{
_ExecutionCount = 0;
_Background = background;
_Configuration = configuration;
_WebClient = serviceProvider.GetRequiredService<WebClient>();
_Log = serviceProvider.GetRequiredService<ILogger<TimedHostedService>>();
//_HttpContextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
_WebClient = serviceProvider.GetRequiredService<WebClient>();
}
public Task StartAsync(CancellationToken stoppingToken)
{
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " running."));
_Background.Update(_Log, _WebClient);
if (_Background.IsEnvironment.Development)
{
int milliSeconds = 3000;
if (milliSeconds == 0)
{ }
}
else if (_Background.IsEnvironment.Staging)
{
int milliSeconds = 3000;
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_APCDataTimer);
milliSeconds += 2000;
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EAFLogDataTimer);
milliSeconds += 2000;
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EDADataTimer);
milliSeconds += 2000;
}
else if (_Background.IsEnvironment.Production)
{
int milliSeconds = 3000;
_APCDataTimer = new Timer(APCDataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_APCDataTimer);
milliSeconds += 2000;
_EAFLogDataTimer = new Timer(EAFLogDataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EAFLogDataTimer);
milliSeconds += 2000;
_EDADataTimer = new Timer(EDADataCallback, null, milliSeconds, Timeout.Infinite);
_Background.Timers.Add(_EDADataTimer);
milliSeconds += 2000;
}
else
throw new Exception();
if (_Background.IsEnvironment.Staging || _Background.IsEnvironment.Production)
{
string countDirectory = _Background.GetCountDirectory("Start");
string checkDirectory = Path.GetPathRoot(countDirectory);
if (Directory.Exists(checkDirectory))
Directory.CreateDirectory(countDirectory);
}
return Task.CompletedTask;
}
public Task StopAsync(CancellationToken stoppingToken)
{
_Log.LogInformation(string.Concat("Timed Hosted Service: ", nameof(Background), ":", _Background.IsEnvironment.Profile, ":", Environment.ProcessId, " is stopping."));
_Background.Stop(immediate: true);
for (short i = 0; i < short.MaxValue; i++)
{
Thread.Sleep(500);
if (_ExecutionCount == 0)
break;
}
return Task.CompletedTask;
}
public void Dispose()
{
_Background.Dispose();
}
private void APCDataCallback(object state)
{
try
{
if (_Background.IsPrimaryInstance())
_Background.APCDataCallback();
}
catch (Exception e) { _Background.Catch(e); }
try
{
TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
_APCDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
catch (Exception e) { _Background.Catch(e); }
}
private void EDADataCallback(object state)
{
try
{
if (_Background.IsPrimaryInstance())
_Background.EDADataCallback();
}
catch (Exception e) { _Background.Catch(e); }
try
{
TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
_EDADataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
catch (Exception e) { _Background.Catch(e); }
}
private void EAFLogDataCallback(object state)
{
try
{
if (_Background.IsPrimaryInstance())
_Background.EAFLogDataCallback();
}
catch (Exception e) { _Background.Catch(e); }
try
{
TimeSpan timeSpan;
if (!_Background.IsPrimaryInstance())
timeSpan = new TimeSpan(DateTime.Now.AddSeconds(15).Ticks - DateTime.Now.Ticks);
else
timeSpan = new TimeSpan(DateTime.Now.AddMinutes(1).Ticks - DateTime.Now.Ticks);
_EAFLogDataTimer.Change((int)timeSpan.TotalMilliseconds, Timeout.Infinite);
}
catch (Exception e) { _Background.Catch(e); }
}
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.Core
{
public class BackboneComponent
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.Core
{
public class BackboneStatusCache
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.Core
{
public interface ILoggingSetupManager
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.Core
{
public class StatusItem
{
}
}

View File

@ -0,0 +1,48 @@
using Library.PeerGroup.GCL.Annotations;
using System;
using System.Collections.Generic;
namespace Library.Eaf.Core
{
public class Backbone
{
public const string STATE_ERROR = "Error";
public const string STATE_OFFLINE = "Offline";
public const string STATE_RUNNING = "Running";
public const string STATE_SHUTDOWN = "Shutting Down";
public const string STATE_STARTING = "Starting";
protected Backbone() { }
[NotNull]
public static Backbone Instance { get; }
[NotNull]
public ILoggingSetupManager LoggingConfigurationManager { get; set; }
public BackboneStatusCache Status { get; }
public bool IsAutomatedRestartActive { get; }
public bool IsReadyForRestart { get; }
public string StartTime { get; }
public string State { get; }
public string Name { get; }
public string ConfigurationServiceAddress { get; }
public string CellName { get; }
protected bool IsInitialized { get; set; }
protected Dictionary<string, BackboneComponent> BackboneComponents { get; }
public void AddBackboneComponent(BackboneComponent backboneComponent) { }
public bool ContainsBackboneComponent(string id) { throw new NotImplementedException(); }
[Obsolete("Use the capabilities exposed via the Status property -> GetAll. Will be removed with next major release.")]
public List<StatusItem> GetAllStatuses() { throw new NotImplementedException(); }
public BackboneComponent GetBackboneComponentById(string id) { throw new NotImplementedException(); }
public List<T> GetBackboneComponentsOfType<T>() { throw new NotImplementedException(); }
public List<BackboneComponent> GetBackboneComponentsOfType(Type type) { throw new NotImplementedException(); }
public void RegisterSubprocess(int pid) { }
[Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")]
public void SetStatus(string statusName, string statusValue) { }
[Obsolete("Use the capabilities exposed via the Status property -> SetValue. Will be removed with next major release.")]
public void SetStatus(BackboneComponent source, string statusName, string statusValue) { }
protected void CloseConnectionOfComponents(List<BackboneComponent> components) { }
protected virtual void StopAllComponents() { }
protected void StopComponents(List<BackboneComponent> components) { }
}
}

View File

@ -0,0 +1,24 @@
using System;
namespace Library.Eaf.Core.Smtp
{
public class EmailMessage
{
public EmailMessage() { }
public EmailMessage(string subject, string body, MailPriority priority = MailPriority.Normal) { }
public string Body { get; }
public MailPriority Priority { get; }
public string Subject { get; }
public EmailMessage PriorityHigh() { throw new NotImplementedException(); }
public EmailMessage PriorityLow() { throw new NotImplementedException(); }
public EmailMessage PriorityNormal() { throw new NotImplementedException(); }
public EmailMessage SetBody(string body) { throw new NotImplementedException(); }
public EmailMessage SetPriority(MailPriority priority) { throw new NotImplementedException(); }
public EmailMessage SetSubject(string subject) { throw new NotImplementedException(); }
}
}

View File

@ -0,0 +1,9 @@
namespace Library.Eaf.Core.Smtp
{
public interface ISmtp
{
void Send(EmailMessage message);
}
}

View File

@ -0,0 +1,11 @@
namespace Library.Eaf.Core.Smtp
{
public enum MailPriority
{
Low = 0,
Normal = 1,
High = 2
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class ChangeDataCollectionHandler
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class DataCollectionRequest
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class EquipmentEvent
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class EquipmentException
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class EquipmentSelfDescription
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class GetParameterValuesHandler
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IConnectionControl
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IDataTracingHandler
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IEquipmentCommandService
{
}
}

View File

@ -0,0 +1,16 @@
using Library.PeerGroup.GCL.Annotations;
namespace Library.Eaf.EquipmentCore.Control
{
public interface IEquipmentControl : IPackageSource
{
[NotNull]
IEquipmentSelfDescriptionBuilder SelfDescriptionBuilder { get; }
[NotNull]
IEquipmentDataCollection DataCollection { get; }
[NotNull]
IEquipmentCommandService Commands { get; }
[NotNull]
IConnectionControl Connection { get; }
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IEquipmentSelfDescriptionBuilder
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IPackage
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface ISelfDescriptionLookup
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IVirtualParameterValuesHandler
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class SetParameterValuesHandler
{
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public class TraceRequest
{
}
}

View File

@ -0,0 +1,39 @@
using Library.Eaf.EquipmentCore.DataCollection.Reporting;
using Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
using System;
using System.Collections.Generic;
namespace Library.Eaf.EquipmentCore.Control
{
public interface IEquipmentDataCollection
{
IVirtualParameterValuesHandler VirtualParameterValuesHandler { get; }
ISelfDescriptionLookup SelfDescriptionLookup { get; }
EquipmentSelfDescription SelfDescription { get; }
IEnumerable<DataCollectionRequest> ActiveRequests { get; }
IDataTracingHandler DataTracingHandler { get; }
ParameterValue CreateParameterValue(EquipmentParameter parameter, object value);
void NotifyDataTracingAvailable(bool isAvailable);
void RegisterChangeDataCollectionHandler(ChangeDataCollectionHandler handler);
void RegisterDataTracingHandler(IDataTracingHandler handler);
void RegisterGetParameterValuesHandler(GetParameterValuesHandler handler);
void RegisterSetParameterValuesHandler(SetParameterValuesHandler handler);
void TriggerDeactivate(DataCollectionRequest deactivateRequest);
void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters);
void TriggerEvent(EquipmentEvent equipmentEvent, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride);
void TriggerExceptionClear(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride, IPackage sourcePackage);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, string severityOverride, string descriptionOverride);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerExceptionSet(EquipmentException equipmentException, IEnumerable<ParameterValue> parameters);
void TriggerPerformanceRestored();
void TriggerPerformanceWarning();
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, IPackage sourcePackage);
void TriggerTraceSample(TraceRequest traceRequest, long sampleId, IEnumerable<ParameterValue> parameters, DateTime equipmentTimeStamp);
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.EquipmentCore.Control
{
public interface IPackageSource
{
}
}

View File

@ -0,0 +1,20 @@
using Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
using Library.PeerGroup.GCL.Annotations;
using System;
namespace Library.Eaf.EquipmentCore.DataCollection.Reporting
{
public class ParameterValue
{
public ParameterValue(EquipmentParameter definition, object value) { }
public ParameterValue(EquipmentParameter definition, object value, DateTime timestamp) { }
public virtual object Value { get; protected internal set; }
[NotNull]
public EquipmentParameter Definition { get; }
public DateTime Timestamp { get; protected set; }
public virtual ParameterValue Clone(EquipmentParameter newDefinition) { throw new NotImplementedException(); }
public override string ToString() { return base.ToString(); }
}
}

View File

@ -0,0 +1,24 @@
using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
namespace Library.Eaf.EquipmentCore.SelfDescription.ElementDescription
{
public class EquipmentParameter
{
public EquipmentParameter(EquipmentParameter source, ParameterTypeDefinition typeDefinition) { }
public EquipmentParameter(string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
public EquipmentParameter(string id, string name, ParameterTypeDefinition typeDefinition, string description, bool isTransient = false, bool isReadOnly = true) { }
public string Name { get; }
public string Id { get; }
public string Description { get; }
public string SourcePath { get; }
public string SourceEquipment { get; }
public ParameterTypeDefinition TypeDefinition { get; }
public bool IsTransient { get; }
public bool IsReadOnly { get; }
public override string ToString() { return base.ToString(); }
public string ToStringWithDetails() { return base.ToString(); }
}
}

View File

@ -0,0 +1,12 @@
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
{
public class Field
{
public Field(string name, string description, bool canBeNull, ParameterTypeDefinition typeDefinition) { }
public string Name { get; }
public string Description { get; }
public ParameterTypeDefinition TypeDefinition { get; }
public bool CanBeNull { get; }
}
}

View File

@ -0,0 +1,12 @@
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
{
public abstract class ParameterTypeDefinition
{
public ParameterTypeDefinition(string name, string description) { }
public string Name { get; }
public string Description { get; }
public override string ToString() { return base.ToString(); }
}
}

View File

@ -0,0 +1,12 @@
using System.Collections.Generic;
namespace Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes
{
public class StructuredType : ParameterTypeDefinition
{
public StructuredType(string name, string description, IList<Field> fields) : base(name, description) { }
public IList<Field> Fields { get; }
}
}

View File

@ -0,0 +1,6 @@
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
{
public interface IConfigurationObject
{
}
}

View File

@ -0,0 +1,26 @@
using System;
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
{
[System.Runtime.Serialization.DataContractAttribute(IsReference = true)]
public class ModelObjectParameterDefinition : IConfigurationObject
{
public ModelObjectParameterDefinition() { }
public ModelObjectParameterDefinition(string name, ModelObjectParameterType valueType, object defaultValue) { }
public ModelObjectParameterDefinition(string name, Type enumType, object defaultValue) { }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long Id { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual string Value { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual ModelObjectParameterType ValueType { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual string EnumType { get; set; }
public virtual ModelObjectParameterDefinition Clone() { return null; }
public virtual bool IsValidValue(string value) { return false; }
}
}

View File

@ -0,0 +1,17 @@
namespace Library.Eaf.Management.ConfigurationData.CellAutomation
{
public enum ModelObjectParameterType
{
String = 0,
Bool = 1,
Byte = 2,
SignedByte = 3,
Integer = 4,
UnsignedInteger = 5,
LongInteger = 6,
UnsignedLongInteger = 7,
Double = 8,
Float = 9,
Enum = 10
}
}

View File

@ -0,0 +1,44 @@
using Library.PeerGroup.GCL.SecsDriver;
using System;
namespace Library.Eaf.Management.ConfigurationData.Semiconductor.CellInstances
{
[System.Runtime.Serialization.DataContractAttribute]
public class SecsConnectionConfiguration
{
public SecsConnectionConfiguration() { }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T6HsmsControlMessage { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T5ConnectionSeperation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T4InterBlock { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T3MessageReply { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T2Protocol { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T1InterCharacter { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual SerialBaudRate? BaudRate { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual SecsTransportType? PortType { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? Port { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan LinkTestTimer { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual string Host { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? DeviceId { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual HsmsSessionMode? SessionMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual HsmsConnectionMode? ConnectionMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T7ConnectionIdle { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TimeSpan T8NetworkIntercharacter { get; set; }
}
}

View File

@ -0,0 +1,13 @@
namespace Library.Ifx.Eaf.Common.Configuration
{
[System.Runtime.Serialization.DataContractAttribute]
public class ConnectionSetting
{
public ConnectionSetting(string name, string value) { }
[System.Runtime.Serialization.DataMemberAttribute]
public string Name { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string Value { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
{
public class File
{
public File(string filePath) { throw new NotImplementedException(); }
public File(string filePath, DateTime timeFileFound) { throw new NotImplementedException(); }
public string Path { get; }
public DateTime TimeFound { get; }
public bool IsErrorFile { get; }
public Dictionary<string, string> ContentParameters { get; }
public File UpdateContentParameters(Dictionary<string, string> contentParameters) { throw new NotImplementedException(); }
public File UpdateParsingStatus(bool isErrorFile) { throw new NotImplementedException(); }
}
}

View File

@ -0,0 +1,35 @@
using Library.Ifx.Eaf.EquipmentConnector.File.Configuration;
using System;
using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.Component
{
public class FilePathGenerator
{
public const char PLACEHOLDER_IDENTIFIER = '%';
public const char PLACEHOLDER_SEPARATOR = ':';
public const string PLACEHOLDER_NOT_AVAILABLE = "NA";
public const string PLACEHOLDER_ORIGINAL_FILE_NAME = "OriginalFileName";
public const string PLACEHOLDER_ORIGINAL_FILE_EXTENSION = "OriginalFileExtension";
public const string PLACEHOLDER_DATE_TIME = "DateTime";
public const string PLACEHOLDER_SUB_FOLDER = "SubFolder";
public const string PLACEHOLDER_CELL_NAME = "CellName";
public FilePathGenerator(FileConnectorConfiguration config, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
public FilePathGenerator(FileConnectorConfiguration config, File file, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
public FilePathGenerator(FileConnectorConfiguration config, string sourceFilePath, bool isErrorFile = false, Dictionary<string, string> customPattern = null) { throw new NotImplementedException(); }
protected string SubFolderPath { get; }
protected FileConnectorConfiguration Configuration { get; }
protected File File { get; }
protected bool IsErrorFile { get; }
protected string DefaultPlaceHolderValue { get; }
public string GetFullTargetPath() { throw new NotImplementedException(); }
public virtual string GetTargetFileName() { throw new NotImplementedException(); }
public string GetTargetFolder(bool throwExceptionIfNotExist = true) { throw new NotImplementedException(); }
protected virtual string GetSubFolder(string folderPattern, string subFolderPath) { throw new NotImplementedException(); }
protected virtual string PrepareFolderPath(string targetFolderPath, string subFolderPath) { throw new NotImplementedException(); }
protected string ReplacePlaceholder(string inputPath) { throw new NotImplementedException(); }
}
}

View File

@ -0,0 +1,135 @@
using Library.Ifx.Eaf.Common.Configuration;
using System;
using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.Configuration
{
[System.Runtime.Serialization.DataContractAttribute]
public class FileConnectorConfiguration
{
public const ulong IDLE_EVENT_WAIT_TIME_DEFAULT = 360;
public const ulong FILE_HANDLE_TIMEOUT_DEFAULT = 15;
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? TriggerOnChanged { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? PostProcessingRetries { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? CopySourceFolderStructure { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public IfPostProcessingFailsEnum? IfPostProcessingFailsAction { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string AlternateTargetFolder { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? FileHandleTimeout { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public bool? DeleteEmptySourceSubFolders { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? IdleEventWaitTimeInSeconds { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string FileAgeThreshold { get; set; }
public bool? FolderAgeCheckIndividualSubFolders { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual ZipModeEnum? ZipMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public FileAgeFilterEnum? FileAgeFilterMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ZipTargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ZipErrorTargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? ZipFileSubFolderLevel { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string DefaultPlaceHolderValue { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public bool? UseZip64Mode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public List<ConnectionSetting> ConnectionSettings { get; set; }
public string SourceDirectoryCloaking { get; set; }
public string FolderAgeThreshold { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? FileScanningIntervalInSeconds { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? TriggerOnCreated { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string SourceFileFilter { get; set; }
public List<string> SourceFileFilters { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual bool? IncludeSubDirectories { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual FileScanningOptionEnum? FileScanningOption { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileLocation { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string TargetFileName { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? FileHandleWaitTime { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public IfFileExistEnum? IfFileExistAction { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public long? ConnectionRetryInterval { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PreProcessingModeEnum? PreProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? PostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public PostProcessingModeEnum? ErrorPostProcessingMode { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual long? ZipFileAmount { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public string ErrorTargetFileName { get; set; }
public void Initialize() { throw new NotImplementedException(); }
public enum PostProcessingModeEnum
{
None = 0,
Move = 1,
Copy = 2,
Rename = 3,
Zip = 4,
Delete = 5,
MoveFolder = 6,
CopyFolder = 7,
DeleteFolder = 8
}
public enum PreProcessingModeEnum
{
None = 0,
Process = 1
}
public enum IfFileExistEnum
{
Overwrite = 0,
LeaveFiles = 1,
Delete = 2
}
public enum IfPostProcessingFailsEnum
{
LeaveFiles = 0,
Delete = 1
}
public enum FileScanningOptionEnum
{
FileWatcher = 0,
TimeBased = 1
}
public enum ZipModeEnum
{
ZipByAmountOrTime = 0,
ZipByFileName = 1,
ZipBySubFolderName = 2
}
public enum FileAgeFilterEnum
{
IgnoreNewer = 0,
IgnoreOlder = 1
}
}
}

View File

@ -0,0 +1,14 @@
using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
using System;
using System.Collections.Generic;
namespace Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription
{
public class FileConnectorParameterTypeDefinitionProvider
{
public FileConnectorParameterTypeDefinitionProvider() { }
public IEnumerable<ParameterTypeDefinition> GetAllParameterTypeDefinition() { return null; }
public ParameterTypeDefinition GetParameterTypeDefinition(string name) { return null; }
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace Library.PeerGroup.GCL.Annotations
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = false, Inherited = true)]
public sealed class NotNullAttribute : Attribute
{
public NotNullAttribute() { }
}
}

View File

@ -0,0 +1,8 @@
namespace Library.PeerGroup.GCL.SecsDriver
{
public enum HsmsConnectionMode
{
Active = 0,
Passive = 1
}
}

View File

@ -0,0 +1,8 @@
namespace Library.PeerGroup.GCL.SecsDriver
{
public enum HsmsSessionMode
{
MultiSession = 0,
SingleSession = 1
}
}

View File

@ -0,0 +1,8 @@
namespace Library.PeerGroup.GCL.SecsDriver
{
public enum SecsTransportType
{
HSMS = 0,
Serial = 1
}
}

View File

@ -0,0 +1,16 @@
namespace Library.PeerGroup.GCL.SecsDriver
{
public enum SerialBaudRate
{
Baud9600 = 0,
Baud19200 = 1,
Baud4800 = 2,
Baud2400 = 3,
Baud1200 = 4,
Baud300 = 5,
Baud150 = 6,
Baud38400 = 7,
Baud57600 = 8,
Baud115200 = 9
}
}

View File

@ -0,0 +1,12 @@
namespace APCViewer.Models
{
public class AppSettings
{
public string Company { get; set; }
public string EncryptedPassword { get; set; }
public string MonARessource { get; set; }
public string Server { get; set; }
public string ServiceUser { get; set; }
public string URLs { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace APCViewer.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@ -0,0 +1,91 @@
namespace APCViewer.Models
{
public interface IBackground
{
void APCDataCallback();
// public void DataForApc(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: false);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, apcLogistics, pdsfFiles, isAPC: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: true, forIPDSF: false);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: true, forIPDSF: false);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
void EAFLogDataCallback();
// public void DataForEafLog(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: false);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, eafLogLogistics, pdsfFiles, isEAFLog: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: false, forIPDSF: true);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: false, forIPDSF: true);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
void EDADataCallback();
// public void DataForEda(string workingDirectory, bool isGaN = false, bool isSi = false)
// {
// long ticks = DateTime.Now.Ticks;
// string server = GetServer(debugIsNotEC: true);
// Logic2019Q2 logic2019Q2 = new Logic2019Q2(_Log);
// Logic2020Q3 logic2020Q3 = new Logic2020Q3(_Log);
// string[] equipmentTypes = GetEquipmentTypes(isGaN, isSi);
// Dictionary<string, string> pdsfFiles = new Dictionary<string, string>();
// Dictionary<string, object> apcLogistics = new Dictionary<string, object>();
// Dictionary<string, object> edaLogistics = new Dictionary<string, object>();
// Dictionary<string, object> eafLogLogistics = new Dictionary<string, object>();
// logic2019Q2.Data(server, equipmentTypes, edaLogistics, pdsfFiles, isEDA: true);
// Tuple<int, object, object, string> tuple = logic2020Q3.SetViewBag(apcLogistics, edaLogistics, eafLogLogistics, directory: null, filter: null, forPDSF: true, forIPDSF: false);
// if (tuple is null) { }
// List<string[]> timePivot = logic2020Q3.GetTimePivot(equipmentTypes, apcLogistics, edaLogistics, eafLogLogistics, forPDSF: true, forIPDSF: false);
// _Log.Debug(string.Concat("Took ", new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds, " second(s)"));
// List<string> list = new List<string>();
// StringBuilder stringBuilder = new StringBuilder();
// foreach (string[] segments in timePivot)
// {
// foreach (string segment in segments)
// stringBuilder.Append(segment).Append('\t');
// list.Add(stringBuilder.ToString());
// stringBuilder.Clear();
// }
// ShowWindow(workingDirectory, ShowWindowCommand.ShowMaximized, list);
// }
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
namespace APCViewer.Models
{
public interface IHomeController
{
IActionResult Background(bool? message_clear = null, bool? exceptions_clear = null, bool? set_is_primary_instance = null, bool? logistics_clear = null);
IActionResult DownloadCustomIPDSF(string ipdsf_file = null);
IActionResult DownloadCustomPDSF(string pdsf_file = null);
IActionResult DownloadIPDSF(string id = null);
IActionResult DownloadPDSF(string id = null);
IActionResult Encode(string value = null);
IActionResult Error();
IActionResult Index();
IActionResult IPDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false);
IActionResult PDSF(string directory = null, string filter = null, bool is_gaN = false, bool is_Si = false);
IActionResult Privacy();
IActionResult TimePivot(bool is_gaN = false, bool is_Si = false);
ContentResult ViewCustomIPDSF(string ipdsf_file = null);
ContentResult ViewCustomPDSF(string pdsf_file = null);
ContentResult ViewIPDSF(string id = null);
ContentResult ViewPDSF(string id = null);
}
}

40
APC Viewer/Program.cs Normal file
View File

@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Shared;
using System.Diagnostics;
namespace APCViewer
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
IHostBuilder result;
IsEnvironment isEnvironment = new IsEnvironment(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: Debugger.IsAttached, nullASPNetCoreEnvironmentIsProduction: !Debugger.IsAttached);
result = Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureAppConfiguration((context, configuration) =>
{
configuration
.AddEnvironmentVariables()
.AddCommandLine(args)
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
return result;
}
}
}

View File

@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("APC Viewer.Tests")]

View File

@ -0,0 +1,192 @@
using Library.Eaf.Core;
using Library.Eaf.EquipmentCore.Control;
using Library.Eaf.EquipmentCore.DataCollection.Reporting;
using Library.Eaf.EquipmentCore.SelfDescription.ElementDescription;
using Library.Eaf.EquipmentCore.SelfDescription.ParameterTypes;
using Library.Ifx.Eaf.EquipmentConnector.File.SelfDescription;
using Shared.Metrology;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
namespace Shared
{
public class Description
{
public enum RowColumn
{
Test = 1000,
Count,
Index
}
public enum LogisticsColumn
{
EventName = 2000,
NullData,
JobID,
Sequence,
MesEntity,
ReportFullPath,
ProcessJobID,
MID
}
public enum Param
{
String = 0,
Integer = 2,
Double = 3,
Boolean = 4,
StructuredType = 5
}
internal const string FileFound = "FileFound";
public List<EquipmentParameter> EquipmentParameters { get; private set; }
public List<ParameterTypeDefinition> ParameterTypeDefinitions { get; private set; }
private readonly bool _UseCyclical;
private readonly List<string> _HeaderNames;
private readonly Dictionary<string, int> _KeyIndexPairs;
private readonly ParameterTypeDefinition _StructuredType;
private readonly FileConnectorParameterTypeDefinitionProvider _FileConnectorParameterTypeDefinitionProvider;
public Description(ILogic logic, ConfigDataBase configDataBase, IEquipmentControl equipmentControl)
{
_KeyIndexPairs = new Dictionary<string, int>();
_HeaderNames = configDataBase.GetHeaderNames(logic);
_UseCyclical = configDataBase.UseCyclicalForDescription;
_StructuredType = new StructuredType(nameof(StructuredType), string.Empty, new List<Field>());
_FileConnectorParameterTypeDefinitionProvider = new FileConnectorParameterTypeDefinitionProvider();
EquipmentParameters = new List<EquipmentParameter>();
ParameterTypeDefinitions = new List<ParameterTypeDefinition> { _StructuredType };
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection = configDataBase.GetParameterInfo(logic, allowNull: false);
List<ParameterValue> results = GetParameterValues(equipmentControl, keyValuePairsCollection);
}
private List<ParameterValue> GetParameterValues(IEquipmentControl equipmentControl, Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection)
{
List<ParameterValue> results = new List<ParameterValue>();
Enum param;
object value;
Enum[] @params;
string description;
List<object[]> list;
EquipmentParameter equipmentParameter;
ParameterTypeDefinition parameterTypeDefinition;
bool addToEquipmentParameters = !EquipmentParameters.Any();
foreach (KeyValuePair<string, List<Tuple<Enum, string, string, object>>> keyValuePair in keyValuePairsCollection)
{
if (!addToEquipmentParameters && !_KeyIndexPairs.ContainsKey(keyValuePair.Key))
continue;
@params = (from l in keyValuePair.Value select l.Item1).Distinct().ToArray();
if (@params.Length != 1)
throw new Exception();
if (keyValuePair.Value[0].Item2 != keyValuePair.Key)
throw new Exception();
param = @params[0];
if (!addToEquipmentParameters)
equipmentParameter = EquipmentParameters[_KeyIndexPairs[keyValuePair.Key]];
else
{
description = keyValuePair.Value[0].Item3;
_KeyIndexPairs.Add(keyValuePair.Key, EquipmentParameters.Count());
if (param is Param.StructuredType || (_UseCyclical && !_HeaderNames.Contains(keyValuePair.Key)))
parameterTypeDefinition = _StructuredType;
else
parameterTypeDefinition = _FileConnectorParameterTypeDefinitionProvider.GetParameterTypeDefinition(param.ToString());
equipmentParameter = new EquipmentParameter(keyValuePair.Key, parameterTypeDefinition, description);
EquipmentParameters.Add(equipmentParameter);
}
if (!_UseCyclical || _HeaderNames.Contains(keyValuePair.Key))
value = keyValuePair.Value[0].Item4;
else
{
list = new List<object[]>();
for (int i = 0; i < keyValuePair.Value.Count; i++)
list.Add(new object[] { i, keyValuePair.Value[i].Item4 });
value = list;
}
if (equipmentControl is null || !(param is Param.StructuredType))
results.Add(new ParameterValue(equipmentParameter, value, DateTime.Now));
else
results.Add(equipmentControl.DataCollection.CreateParameterValue(equipmentParameter, value));
}
return results;
}
public List<ParameterValue> GetParameterValues(ILogic logic, IEquipmentControl equipmentControl, JsonElement jsonElement, int? i = null, Dictionary<string, object> keyValuePairs = null)
{
List<ParameterValue> results = new List<ParameterValue>();
if (_UseCyclical && (i is null || i.Value > 0))
throw new Exception();
if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception();
Enum param;
Tuple<Enum, string, string, object> tuple;
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairsCollection = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
for (int r = i.Value; r < jsonElements.Length; r++)
{
foreach (JsonProperty jsonProperty in jsonElement[r].EnumerateObject())
{
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
{
param = Param.StructuredType;
//jValue = jObject.Value<JValue>("Item1");
throw new NotImplementedException("Item1");
}
else
{
switch (jsonProperty.Value.ValueKind)
{
case JsonValueKind.String:
param = Param.String;
break;
case JsonValueKind.Number:
param = Param.Double;
break;
case JsonValueKind.True:
case JsonValueKind.False:
param = Param.Boolean;
break;
case JsonValueKind.Null:
param = Param.String;
break;
default:
param = Param.StructuredType;
break;
}
}
tuple = new Tuple<Enum, string, string, object>(param, jsonProperty.Name, string.Empty, jsonProperty.Value.ToString());
if (!keyValuePairsCollection.ContainsKey(jsonProperty.Name))
keyValuePairsCollection.Add(jsonProperty.Name, new List<Tuple<Enum, string, string, object>>());
keyValuePairsCollection[jsonProperty.Name].Add(tuple);
}
if (!_UseCyclical)
break;
}
results = GetParameterValues(equipmentControl, keyValuePairsCollection);
return results;
}
public static string GetCellName()
{
string result;
if (Backbone.Instance?.CellName is null)
result = string.Empty;
else
result = Backbone.Instance.CellName;
if (result.Contains("-IO"))
result = result.Replace("-IO", string.Empty);
return result;
}
}
}

View File

@ -0,0 +1,53 @@
namespace Shared
{
public enum EquipmentType
{
FileEquipment,
SemiEquipment,
//
DEP08EGANAIXG5,
//
MET08ANLYSDIFAAST230_Semi,
MET08DDUPSFS6420,
MET08DDUPSP1TBI,
MET08RESIHGCV,
MET08RESIMAPCDE,
MET08THFTIRQS408M,
MET08THFTIRSTRATUS,
//
MET08AFMD3100,
MET08BVHGPROBE,
MET08CVHGPROBE802B150,
MET08CVHGPROBE802B150_Monthly,
MET08CVHGPROBE802B150_Weekly,
MET08DDINCAN8620,
MET08DDINCAN8620_Daily,
MET08EBEAMINTEGRITY26,
MET08HALLHL5580,
MET08HALLHL5580_Monthly,
MET08HALLHL5580_Weekly,
MET08MESMICROSCOPE,
MET08NDFRESIMAP151C,
MET08NDFRESIMAP151C_Verification,
MET08PLMAPRPM,
MET08PLMAPRPM_Daily,
MET08PLMAPRPM_Verification,
MET08PLMPPLATO,
MET08PRFUSB4000,
MET08PRFUSB4000_Daily,
MET08PRFUSB4000_Monthly,
MET08PRFUSB4000_Weekly,
MET08PRFUSB4000_Verification,
MET08PRFUSB4000_Villach,
MET08UVH44GS100M,
MET08VPDSUBCON,
MET08WGEOMX203641Q,
MET08WGEOMX203641Q_Verification,
MET08XRDXPERTPROMRDXL,
MET08XRDXPERTPROMRDXL_Monthly,
MET08XRDXPERTPROMRDXL_Weekly,
METBRXRAYJV7300L
}
}

View File

@ -0,0 +1,16 @@
using Shared.Metrology;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace Shared
{
public interface IProcessData
{
Tuple<string, JsonElement?, List<FileInfo>> GetResults(ILogic logic, ConfigDataBase configData, List<FileInfo> fileInfoCollection);
}
}

View File

@ -0,0 +1,26 @@
using Shared.Metrology;
using System.Collections.Generic;
namespace Shared
{
public interface IProcessDataDescription
{
int Test { get; set; }
int Count { get; set; }
int Index { get; set; }
IProcessDataDescription GetDefault(ILogic logic, ConfigDataBase configDataBase);
IProcessDataDescription GetDisplayNames(ILogic logic, ConfigDataBase configDataBase);
List<IProcessDataDescription> GetDescription(ILogic logic, ConfigDataBase configDataBase, List<Test> tests, IProcessData iProcessData);
List<string> GetDetailNames(ILogic logic, ConfigDataBase configDataBase);
List<string> GetHeaderNames(ILogic logic, ConfigDataBase configDataBase);
List<string> GetIgnoreParameterNames(ILogic logic, ConfigDataBase configDataBase, Test test);
List<string> GetNames(ILogic logic, ConfigDataBase configDataBase);
List<string> GetPairedParameterNames(ILogic logic, ConfigDataBase configDataBase);
List<string> GetParameterNames(ILogic logic, ConfigDataBase configDataBase);
string GetEventDescription();
}
}

View File

@ -0,0 +1,21 @@
using System;
namespace Shared
{
public interface IScopeInfo
{
Enum Enum { get; }
string HTML { get; }
string Title { get; }
string FileName { get; }
int TestValue { get; }
string Header { get; }
string QueryFilter { get; }
string FileNameWithoutExtension { get; }
EquipmentType EquipmentType { get; }
}
}

View File

@ -0,0 +1,171 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Shared
{
public class IsEnvironment
{
public enum Name
{
LinuxDevelopment,
LinuxProduction,
LinuxStaging,
OSXDevelopment,
OSXProduction,
OSXStaging,
WindowsDevelopment,
WindowsProduction,
WindowsStaging
}
public bool DebuggerWasAttachedDuringConstructor { get; private set; }
public bool Development { get; private set; }
public bool Linux { get; private set; }
public bool OSX { get; private set; }
public bool Production { get; private set; }
public bool Staging { get; private set; }
public bool Windows { get; private set; }
public string Profile { get; private set; }
public string AppSettingsFileName { get; private set; }
public string ASPNetCoreEnvironment { get; private set; }
public IsEnvironment(string testCategory)
{
if (testCategory.EndsWith(".json"))
{
Production = testCategory == "appsettings.json";
Staging = testCategory.EndsWith(nameof(Staging));
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Development = testCategory.EndsWith(nameof(Development));
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
}
else
{
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
OSX = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(OSX));
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Linux = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Linux));
Staging = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Staging));
Windows = !string.IsNullOrEmpty(testCategory) && testCategory.StartsWith(nameof(Windows));
Production = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Production));
Development = !string.IsNullOrEmpty(testCategory) && testCategory.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(bool isDevelopment, bool isStaging, bool isProduction)
{
Staging = isStaging;
Production = isProduction;
Development = isDevelopment;
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount: null);
}
public IsEnvironment(int? processesCount, bool nullASPNetCoreEnvironmentIsDevelopment, bool nullASPNetCoreEnvironmentIsProduction)
{
OSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
Linux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
DebuggerWasAttachedDuringConstructor = Debugger.IsAttached;
Windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
ASPNetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (nullASPNetCoreEnvironmentIsDevelopment && nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsProduction)
Production = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && nullASPNetCoreEnvironmentIsDevelopment)
Development = true;
else if (string.IsNullOrEmpty(ASPNetCoreEnvironment) && !nullASPNetCoreEnvironmentIsDevelopment && !nullASPNetCoreEnvironmentIsProduction)
throw new Exception();
else
{
Staging = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Staging));
Production = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Production));
Development = ASPNetCoreEnvironment is not null && ASPNetCoreEnvironment.EndsWith(nameof(Development));
}
Profile = GetProfile();
AppSettingsFileName = GetAppSettingsFileName(processesCount);
}
private string GetProfile()
{
string result;
if (Windows && Production)
result = nameof(Production);
else if (Windows && Staging)
result = nameof(Staging);
else if (Windows && Development)
result = nameof(Development);
else if (Linux && Production)
result = nameof(Name.LinuxProduction);
else if (Linux && Staging)
result = nameof(Name.LinuxStaging);
else if (Linux && Development)
result = nameof(Name.LinuxDevelopment);
else if (OSX && Production)
result = nameof(Name.OSXProduction);
else if (OSX && Staging)
result = nameof(Name.OSXStaging);
else if (OSX && Development)
result = nameof(Name.OSXDevelopment);
else
throw new Exception();
return result;
}
private string GetAppSettingsFileName(int? processesCount)
{
string result;
if (Production)
{
if (processesCount is null)
result = "appsettings.json";
else
result = $"appsettings.{processesCount}.json";
}
else
{
string environment;
if (Staging)
environment = nameof(Staging);
else if (Development)
environment = nameof(Development);
else
throw new Exception();
if (processesCount is null)
result = $"appsettings.{environment}.json";
else
result = $"appsettings.{environment}.{processesCount}.json";
}
return result;
}
public static string GetEnvironmentName(IsEnvironment isEnvironment)
{
string result;
if (isEnvironment.Windows)
result = nameof(IsEnvironment.Windows);
else if (isEnvironment.Linux)
result = nameof(IsEnvironment.Linux);
else if (isEnvironment.OSX)
result = nameof(IsEnvironment.OSX);
else
throw new Exception();
return result;
}
}
}

View File

@ -0,0 +1,245 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Shared
{
public class Logistics
{
public object NullData { get; private set; }
public string JobID { get; private set; } //CellName
public long Sequence { get; private set; } //Ticks
public DateTime DateTimeFromSequence { get; private set; }
public double TotalSecondsSinceLastWriteTimeFromSequence { get; private set; }
public string MesEntity { get; private set; } //SPC
public string ReportFullPath { get; private set; } //Extract file
public string ProcessJobID { get; internal set; } //Reactor (duplicate but I want it in the logistics)
public string MID { get; internal set; } //Lot & Pocket || Lot
public List<string> Tags { get; internal set; }
public List<string> Logistics1 { get; internal set; }
public List<Logistics2> Logistics2 { get; internal set; }
public Logistics()
{
DateTime dateTime = DateTime.Now;
NullData = null;
JobID = Description.GetCellName();
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = string.Empty;
ProcessJobID = nameof(ProcessJobID);
MID = nameof(MID);
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
public Logistics(object nullData, Dictionary<string, string> cellNames, Dictionary<string, string> mesEntities, FileInfo fileInfo, bool useSplitForMID, int? fileInfoLength = null)
{
NullData = nullData;
string mesEntity = string.Empty;
string jobID = Description.GetCellName();
DateTime dateTime = fileInfo.LastWriteTime;
if (fileInfoLength.HasValue && fileInfo.Length < fileInfoLength.Value)
dateTime = dateTime.AddTicks(-1);
if (string.IsNullOrEmpty(jobID))
{
if (cellNames.Count == 1)
jobID = cellNames.ElementAt(0).Key;
else
{
string reportFullPathLower = fileInfo.FullName.ToLower();
foreach (var element in cellNames)
{
if (reportFullPathLower.Contains(element.Key) || reportFullPathLower.Contains(element.Value))
{
jobID = element.Key;
break;
}
}
}
}
if (string.IsNullOrEmpty(jobID))
throw new Exception();
if (mesEntities.ContainsKey(jobID))
mesEntity = mesEntities[jobID];
else if (mesEntities.Count == 1)
mesEntity = mesEntities.ElementAt(0).Value;
//
if (string.IsNullOrEmpty(mesEntity))
throw new Exception();
JobID = jobID;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = mesEntity;
ReportFullPath = fileInfo.FullName;
ProcessJobID = nameof(ProcessJobID);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
if (useSplitForMID)
{
if (fileNameWithoutExtension.IndexOf(".") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('.')[0].Trim();
if (fileNameWithoutExtension.IndexOf("_") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('_')[0].Trim();
if (fileNameWithoutExtension.IndexOf("-") > -1)
fileNameWithoutExtension = fileNameWithoutExtension.Split('-')[0].Trim();
}
MID = string.Concat(fileNameWithoutExtension.Substring(0, 1).ToUpper(), fileNameWithoutExtension.Substring(1).ToLower());
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
public Logistics(string reportFullPath, string logistics)
{
string key;
DateTime dateTime;
string[] segments;
Logistics1 = logistics.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (!Logistics1.Any() || !Logistics1[0].StartsWith("LOGISTICS_1"))
{
NullData = null;
JobID = "null";
dateTime = new FileInfo(reportFullPath).LastWriteTime;
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
MesEntity = DefaultMesEntity(dateTime);
ReportFullPath = reportFullPath;
ProcessJobID = "R##";
MID = "null";
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
else
{
string logistics1Line1 = Logistics1[0];
key = "NULL_DATA=";
if (!logistics1Line1.Contains(key))
NullData = null;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
NullData = segments[1].Split(';')[0];
}
key = "JOBID=";
if (!logistics1Line1.Contains(key))
JobID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
JobID = segments[1].Split(';')[0];
}
key = "SEQUENCE=";
if (!logistics1Line1.Contains(key))
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
if (!long.TryParse(segments[1].Split(';')[0].Split('.')[0], out long sequence) || sequence < new DateTime(1999, 1, 1).Ticks)
dateTime = new FileInfo(reportFullPath).LastWriteTime;
else
dateTime = new DateTime(sequence);
}
Sequence = dateTime.Ticks;
DateTimeFromSequence = dateTime;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTime).TotalSeconds;
DateTime lastWriteTime = new FileInfo(reportFullPath).LastWriteTime;
if (TotalSecondsSinceLastWriteTimeFromSequence > 600)
{
if (lastWriteTime != dateTime)
try
{ File.SetLastWriteTime(reportFullPath, dateTime); }
catch (Exception) { }
}
key = "MES_ENTITY=";
if (!logistics1Line1.Contains(key))
MesEntity = DefaultMesEntity(dateTime);
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MesEntity = segments[1].Split(';')[0];
}
ReportFullPath = reportFullPath;
key = "PROCESS_JOBID=";
if (!logistics1Line1.Contains(key))
ProcessJobID = "R##";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
ProcessJobID = segments[1].Split(';')[0];
}
key = "MID=";
if (!logistics1Line1.Contains(key))
MID = "null";
else
{
segments = logistics1Line1.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0];
}
}
Logistics2 logistics2;
Tags = new List<string>();
Logistics2 = new List<Logistics2>();
for (int i = 1; i < Logistics1.Count(); i++)
{
if (Logistics1[i].StartsWith("LOGISTICS_2"))
{
logistics2 = new Logistics2(Logistics1[i]);
Logistics2.Add(logistics2);
}
}
for (int i = Logistics1.Count() - 1; i > -1; i--)
{
if (Logistics1[i].StartsWith("LOGISTICS_2"))
Logistics1.RemoveAt(i);
}
}
public Logistics ShallowCopy()
{
return (Logistics)MemberwiseClone();
}
private string DefaultMesEntity(DateTime dateTime)
{
return string.Concat(dateTime.Ticks, "_MES_ENTITY");
}
internal string GetLotViaMostCommonMethod()
{
return MID.Substring(0, MID.Length - 2);
}
internal string GetPocketNumberViaMostCommonMethod()
{
return MID.Substring(MID.Length - 2);
}
internal void Update(string dateTime, string processJobID, string mid)
{
if (!DateTime.TryParse(dateTime, out DateTime dateTimeCasted))
dateTimeCasted = DateTime.Now;
NullData = null;
//JobID = Description.GetCellName();
Sequence = dateTimeCasted.Ticks;
DateTimeFromSequence = dateTimeCasted;
TotalSecondsSinceLastWriteTimeFromSequence = (DateTime.Now - dateTimeCasted).TotalSeconds;
//MesEntity = DefaultMesEntity(dateTime);
//ReportFullPath = string.Empty;
ProcessJobID = processJobID;
MID = mid;
Tags = new List<string>();
Logistics1 = new string[] { string.Concat("LOGISTICS_1", '\t', "A_JOBID=", JobID, ";A_MES_ENTITY=", MesEntity, ";") }.ToList();
Logistics2 = new List<Logistics2>();
}
}
}

View File

@ -0,0 +1,80 @@
using System;
namespace Shared
{
public class Logistics2
{
public string MID { get; private set; }
public string RunNumber { get; private set; }
public string SatelliteGroup { get; private set; }
public string PartNumber { get; private set; }
public string PocketNumber { get; private set; }
public string WaferLot { get; private set; }
public string Recipe { get; private set; }
public Logistics2(string logistics2)
{
string key;
string[] segments;
key = "JOBID=";
if (!logistics2.Contains(key))
MID = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
MID = segments[1].Split(';')[0];
}
key = "MID=";
if (!logistics2.Contains(key))
RunNumber = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
RunNumber = segments[1].Split(';')[0];
}
key = "INFO=";
if (!logistics2.Contains(key))
SatelliteGroup = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
SatelliteGroup = segments[1].Split(';')[0];
}
key = "PRODUCT=";
if (!logistics2.Contains(key))
PartNumber = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
PartNumber = segments[1].Split(';')[0];
}
key = "CHAMBER=";
if (!logistics2.Contains(key))
PocketNumber = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
PocketNumber = segments[1].Split(';')[0];
}
key = "WAFER_ID=";
if (!logistics2.Contains(key))
WaferLot = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
WaferLot = segments[1].Split(';')[0];
}
key = "PPID=";
if (!logistics2.Contains(key))
Recipe = "null";
else
{
segments = logistics2.Split(new string[] { key }, StringSplitOptions.RemoveEmptyEntries);
Recipe = segments[1].Split(';')[0];
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,410 @@
using Library.Ifx.Eaf.EquipmentConnector.File.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Shared.Metrology
{
public class ConfigDataBase
{
public bool UseCyclicalForDescription { get; protected set; }
public Dictionary<string, string> CellNames { get; protected set; }
public Dictionary<string, string> MesEntities { get; protected set; }
public IProcessDataDescription ProcessDataDescription { get; protected set; }
public bool IsEvent { get; private set; }
public EventName EventName => _EventName;
public bool EafHosted { get; private set; }
public string CellName { get; private set; }
public bool IsSourceTimer { get; private set; }
public EquipmentType EquipmentType => _EquipmentType;
public string EquipmentElementName { get; private set; }
public bool IsDatabaseExportToIPDSF { get; private set; }
public EquipmentType? EquipmentConnection => _EquipmentConnection;
public FileConnectorConfiguration FileConnectorConfiguration { get; private set; }
protected readonly EventName _EventName;
protected readonly EquipmentType _EquipmentType;
protected readonly EquipmentType? _EquipmentConnection;
protected readonly Dictionary<string, string> _Reactors;
public ConfigDataBase(string cellName, string cellInstanceConnectionName, FileConnectorConfiguration fileConnectorConfiguration, string equipmentTypeName, string parameterizedModelObjectDefinitionType, bool isEAFHosted)
{
CellName = cellName;
EafHosted = isEAFHosted;
EquipmentType equipmentTypeValue;
_Reactors = new Dictionary<string, string>();
CellNames = new Dictionary<string, string>();
MesEntities = new Dictionary<string, string>();
EquipmentElementName = cellInstanceConnectionName;
FileConnectorConfiguration = fileConnectorConfiguration;
string[] segments = parameterizedModelObjectDefinitionType.Split('.');
IsSourceTimer = (fileConnectorConfiguration.SourceFileFilter.StartsWith("*Timer.txt"));
string cellInstanceConnectionNameBase = cellInstanceConnectionName.Replace("-", string.Empty);
IsDatabaseExportToIPDSF = (fileConnectorConfiguration.SourceFileLocation.Contains("DatabaseExport"));
if (!Enum.TryParse(segments[segments.Length - 1], out EventName eventNameValue))
throw new Exception(cellInstanceConnectionName);
if (!Enum.TryParse(cellInstanceConnectionNameBase, out equipmentTypeValue))
_EquipmentConnection = null;
else
_EquipmentConnection = equipmentTypeValue;
string suffix;
switch (eventNameValue)
{
case EventName.FileRead:
suffix = string.Empty;
break;
case EventName.FileReadDaily:
suffix = "_Daily";
break;
case EventName.FileReadWeekly:
suffix = "_Weekly";
break;
case EventName.FileReadMonthly:
suffix = "_Monthly";
break;
case EventName.FileReadVerification:
suffix = "_Verification";
break;
default:
throw new Exception(cellInstanceConnectionName);
}
string parameterizedModelObjectDefinitionTypeAppended = string.Concat(segments[0], suffix);
IsEvent = cellInstanceConnectionNameBase != parameterizedModelObjectDefinitionTypeAppended;
_EventName = eventNameValue;
if (!Enum.TryParse(parameterizedModelObjectDefinitionTypeAppended, out equipmentTypeValue))
throw new Exception(cellInstanceConnectionName);
_EquipmentType = equipmentTypeValue;
if (!isEAFHosted && equipmentTypeName != parameterizedModelObjectDefinitionTypeAppended)
throw new Exception(cellInstanceConnectionName);
}
public string GetEventName()
{
string result = EventName.ToString();
return result;
}
public string GetEquipmentType()
{
string result = EquipmentConnection.ToString();
return result;
}
public string GetEventDescription()
{
string result = ProcessDataDescription.GetEventDescription();
return result;
}
public IProcessDataDescription GetDefault(ILogic logic)
{
IProcessDataDescription result = ProcessDataDescription.GetDefault(logic, this);
return result;
}
public IProcessDataDescription GetDisplayNames(ILogic logic)
{
IProcessDataDescription result = ProcessDataDescription.GetDisplayNames(logic, this);
return result;
}
public List<string> GetDetailNames(ILogic logic)
{
List<string> results = ProcessDataDescription.GetDetailNames(logic, this);
return results;
}
public List<string> GetHeaderNames(ILogic logic)
{
List<string> results = ProcessDataDescription.GetHeaderNames(logic, this);
return results;
}
public List<string> GetNames(ILogic logic)
{
List<string> results = ProcessDataDescription.GetNames(logic, this);
return results;
}
public List<string> GetPairedParameterNames(ILogic logic)
{
List<string> results = ProcessDataDescription.GetPairedParameterNames(logic, this);
return results;
}
public List<string> GetParameterNames(ILogic logic)
{
List<string> results = ProcessDataDescription.GetParameterNames(logic, this);
return results;
}
public List<IProcessDataDescription> GetDescription(ILogic logic, List<Test> tests, IProcessData iProcessData)
{
List<IProcessDataDescription> results = ProcessDataDescription.GetDescription(logic, this, tests, iProcessData);
return results;
}
public string GetCurrentReactor(ILogic logic)
{
string result = string.Empty;
foreach (KeyValuePair<string, string> keyValuePair in _Reactors)
{
foreach (string filePrefix in keyValuePair.Value.Split('|'))
{
if (logic.Logistics.MID.StartsWith(filePrefix) || (EventName != EventName.FileRead && MesEntities.ContainsKey(logic.Logistics.JobID) && keyValuePair.Value == MesEntities[logic.Logistics.JobID]))
{
result = keyValuePair.Key;
break;
}
}
}
if (string.IsNullOrEmpty(result) && _Reactors.Count == 1)
result = _Reactors.ElementAt(0).Key;
return result;
}
protected JsonElement GetDefaultJsonElement(ILogic logic)
{
JsonElement result;
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDefault(logic, this);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
result = (JsonElement)@object;
return result;
}
public Dictionary<string, List<Tuple<Enum, string, string, object>>> GetParameterInfo(ILogic logic, bool allowNull)
{
Dictionary<string, List<Tuple<Enum, string, string, object>>> results = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
string description;
Enum param;
Tuple<Enum, string, string, object> tuple;
JsonElement defaultJsonElement = GetDefaultJsonElement(logic);
Dictionary<string, string> keyValuePairs = GetDisplayNamesJsonElement(logic);
foreach (JsonProperty jsonProperty in defaultJsonElement.EnumerateObject())
{
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
throw new Exception();
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
{
description = string.Empty;
param = Description.Param.StructuredType;
//jValue = jObject.Value<JValue>("Item1");
throw new NotImplementedException("Item1");
}
else
{
switch (jsonProperty.Value.ValueKind)
{
case JsonValueKind.String:
param = Description.Param.String;
break;
case JsonValueKind.Number:
param = Description.Param.Double;
break;
case JsonValueKind.True:
case JsonValueKind.False:
param = Description.Param.Boolean;
break;
case JsonValueKind.Null:
param = Description.Param.String;
break;
default:
param = Description.Param.StructuredType;
break;
}
}
if (!keyValuePairs.ContainsKey(jsonProperty.Name))
description = string.Empty;
else
description = keyValuePairs[jsonProperty.Name];
tuple = new Tuple<Enum, string, string, object>(param, jsonProperty.Name, description, jsonProperty.Value.ToString());
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, new List<Tuple<Enum, string, string, object>>());
results[jsonProperty.Name].Add(tuple);
}
return results;
}
protected void WriteExportAliases(ILogic logic, string cellName, string equipmentElementName)
{
int i = 0;
Enum param;
object value;
Enum[] @params;
string description;
StringBuilder stringBuilder = new StringBuilder();
string shareRoot = @"\\messv02ecc1.ec.local\EC_EDA";
string shareDirectory = string.Concat(shareRoot, @"\Staging\Pdsf\", cellName, @"\ExportAliases\", equipmentElementName);
Dictionary<string, List<Tuple<Enum, string, string, object>>> keyValuePairs;
if (!(logic is null))
keyValuePairs = GetParameterInfo(logic, allowNull: false);
else
keyValuePairs = new Dictionary<string, List<Tuple<Enum, string, string, object>>>();
stringBuilder.AppendLine("\"AliasName\";\"Condition\";\"EventId\";\"ExceptionId\";\"Formula\";\"HardwareId\";\"OrderId\";\"ParameterName\";\"Remark\";\"ReportName\";\"SourceId\";\"Use\"");
if (!Directory.Exists(shareRoot))
return;
if (!Directory.Exists(shareDirectory))
Directory.CreateDirectory(shareDirectory);
string shareFile = string.Concat(shareDirectory, @"\", DateTime.Now.Ticks, ".csv");
foreach (KeyValuePair<string, List<Tuple<Enum, string, string, object>>> keyValuePair in keyValuePairs)
{
i += 1;
@params = (from l in keyValuePair.Value select l.Item1).Distinct().ToArray();
if (@params.Length != 1)
throw new Exception();
if (keyValuePair.Value[0].Item2 != keyValuePair.Key)
throw new Exception();
param = @params[0];
if (!(param is Description.Param.String))
stringBuilder.AppendLine($"\"{keyValuePair.Key}\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{keyValuePair.Key}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
else
{
description = keyValuePair.Value[0].Item3.Split('|')[0];
if (string.IsNullOrEmpty(description))
continue;
value = keyValuePair.Value[0].Item4;
stringBuilder.AppendLine($"\"'{description}'\";\"\";\"\";\"\";\"\";\"\";\"{i}\";\"{cellName}/{EquipmentElementName}/{value}\";\"\";\"{cellName}/{EquipmentElementName}/{EventName}\";\"\";\"True\"");
}
}
if (keyValuePairs.Any())
File.WriteAllText(shareFile, stringBuilder.ToString());
}
public Dictionary<string, string> GetDisplayNamesJsonElement(ILogic logic)
{
Dictionary<string, string> results = new Dictionary<string, string>();
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
JsonElement jsonElement = JsonSerializer.Deserialize<JsonElement>(json);
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, string.Empty);
if (jsonProperty.Value is JsonElement jsonPropertyValue)
results[jsonProperty.Name] = jsonPropertyValue.ToString();
}
return results;
}
public List<string> GetIgnoreParameterNames(ILogic logic, Test test, bool includePairedParameterNames)
{
List<string> results = ProcessDataDescription.GetIgnoreParameterNames(logic, this, test);
if (includePairedParameterNames)
{
string value;
List<string> pairedParameterNames = ProcessDataDescription.GetPairedParameterNames(logic, this);
IProcessDataDescription processDataDescription = ProcessDataDescription.GetDisplayNames(logic, this);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (!(@object is JsonElement jsonElement))
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
{
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
throw new Exception();
value = jsonProperty.Value.ToString();
if (!results.Contains(jsonProperty.Name) && pairedParameterNames.Contains(jsonProperty.Name) && (string.IsNullOrEmpty(value) || value[0] == '|'))
results.Add(jsonProperty.Name);
}
}
return results;
}
public List<Duplicator.Description> GetProcessDataDescriptions(JsonElement jsonElement)
{
List<Duplicator.Description> results;
if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception();
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
results = JsonSerializer.Deserialize<List<Duplicator.Description>>(jsonElement.ToString(), jsonSerializerOptions);
return results;
}
public Dictionary<Test, List<Duplicator.Description>> GetKeyValuePairs(List<Duplicator.Description> processDataDescriptions)
{
Dictionary<Test, List<Duplicator.Description>> results = new Dictionary<Test, List<Duplicator.Description>>();
Test testKey;
for (int i = 0; i < processDataDescriptions.Count; i++)
{
testKey = (Test)processDataDescriptions[i].Test;
if (!results.ContainsKey(testKey))
results.Add(testKey, new List<Duplicator.Description>());
results[testKey].Add(processDataDescriptions[i]);
}
return results;
}
public Dictionary<string, List<string>> GetKeyValuePairs(JsonElement jsonElement, List<Duplicator.Description> processDataDescriptions, Test test)
{
Dictionary<string, List<string>> results = new Dictionary<string, List<string>>();
Test testKey;
if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception();
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
if (processDataDescriptions.Count != jsonElements.Length)
throw new Exception();
for (int i = 0; i < processDataDescriptions.Count; i++)
{
testKey = (Test)processDataDescriptions[i].Test;
if (testKey != test)
continue;
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
{
if (jsonProperty.Value.ValueKind == JsonValueKind.Object || jsonProperty.Value.ValueKind == JsonValueKind.Array)
throw new Exception();
if (!results.ContainsKey(jsonProperty.Name))
results.Add(jsonProperty.Name, new List<string>());
results[jsonProperty.Name].Add(jsonProperty.Value.ToString());
}
}
return results;
}
protected void VerifyProcessDataDescription(ILogic logic)
{
string description;
bool allowNull = false;
JsonElement defaultJsonElement = GetDefaultJsonElement(logic);
Dictionary<string, string> keyValuePairs = GetDisplayNamesJsonElement(logic);
JsonProperty[] jsonProperties = defaultJsonElement.EnumerateObject().ToArray();
foreach (JsonProperty jsonProperty in jsonProperties)
{
if (jsonProperty.Value.ValueKind == JsonValueKind.Null && !allowNull)
throw new Exception();
if (!(jsonProperty.Value.ValueKind is JsonValueKind.String) || !keyValuePairs.ContainsKey(jsonProperty.Name))
description = string.Empty;
else
description = keyValuePairs[jsonProperty.Name].Split('|')[0];
}
}
public List<IProcessDataDescription> GetIProcessDataDescriptions(JsonElement jsonElement)
{
List<IProcessDataDescription> results = new List<IProcessDataDescription>();
if (jsonElement.ValueKind != JsonValueKind.Array)
throw new Exception();
object @object;
Type type = ProcessDataDescription.GetType();
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions { NumberHandling = JsonNumberHandling.AllowReadingFromString | JsonNumberHandling.WriteAsString };
for (int i = 0; i < jsonElements.Length; i++)
{
@object = JsonSerializer.Deserialize(jsonElements[i].ToString(), type, jsonSerializerOptions);
if (!(@object is IProcessDataDescription processDataDescription))
continue;
results.Add(processDataDescription);
}
return results;
}
}
}

View File

@ -0,0 +1,13 @@
namespace Shared.Metrology
{
public enum EventName
{
FileRead,
FileReadDaily,
FileReadMonthly,
FileReadVerification,
FileReadWeekly
}
}

View File

@ -0,0 +1,48 @@
using Library.Eaf.EquipmentCore.Control;
using Library.Eaf.Management.ConfigurationData.CellAutomation;
using Library.Ifx.Eaf.EquipmentConnector.File.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
namespace Shared.Metrology
{
public interface ILogic
{
ILogic ShallowCopy();
Logistics Logistics { get; }
void ConfigurationRestore();
void CreateSelfDescription();
void CreateSelfDescription(IEquipmentControl equipment, string cellInstanceName, string cellInstanceConnectionName, FileConnectorConfiguration configuration, IList<ModelObjectParameterDefinition> modelObjectParameterDefinitions, EquipmentType? equipmentType, EventName? eventName);
bool Extract(string reportFullPath, string eventName);
string GetConfigurationErrorTargetFileLocation();
string GetConfigurationSourceFileLocation();
string GetConfigurationTarget2FileLocation();
string GetConfigurationTargetFileLocation();
string GetConfigurationTargetFileName();
Tuple<string, JsonElement?, List<FileInfo>> GetExtractResult(string reportFullPath, string eventName);
object GetFilePathGeneratorInfo(string reportFullPath, bool isErrorFile);
string GetReportFullPath(Dictionary<string, object> keyValuePairs);
string GetTarget2FileLocation();
void Move(string reportFullPath, Tuple<string, JsonElement?, List<FileInfo>> extractResults, Exception exception = null);
string ReExtract(string searchDirectory, string sourceFileFilter);
void ReflectionCreateSelfDescription(string equipmentElementName, int? input, string cellName, string debugConfig, string[] strings, bool[] booleans, long[] numbers, string[] enums);
ConfigDataBase ReflectionCreateSelfDescriptionV2(string json);
string ResolveErrorTargetPlaceHolders(string reportFullPath, bool createDirectory = true, string fileFoundPath = "");
string ResolveSourcePlaceHolders(string reportFullPath, bool createDirectory = true);
string ResolveTarget2PlaceHolders(string reportFullPath, bool createDirectory = true, string fileFoundPath = "");
string ResolveTargetPlaceHolders(string reportFullPath, bool createDirectory = true, string fileFoundPath = "");
void SetFileParameter(string key, string value);
void SetFileParameterLotID(string value, bool includeLogisticsSequence = false);
void SetFileParameterLotIDToLogisticsMID(bool includeLogisticsSequence = true);
void SetFileParameterSystemDateTimeToLogisticsSequence();
void SetPlaceHolder(string reportFullPath, string key, string value);
void SetTarget2FileLocation(string value);
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08AFMD3100
{
public enum Test
{
AFMRoughness = Metrology.Test.AFMRoughness
}
}
}

View File

@ -0,0 +1,16 @@
namespace Shared.Metrology
{
public class MET08BVHGPROBE
{
public enum Test
{
BreakdownVoltageCenter = Metrology.Test.BreakdownVoltageCenter,
BreakdownVoltageEdge = Metrology.Test.BreakdownVoltageEdge,
BreakdownVoltageMiddle8in = Metrology.Test.BreakdownVoltageMiddle8in
}
}
}

View File

@ -0,0 +1,16 @@
namespace Shared.Metrology
{
public class MET08CVHGPROBE802B150
{
public enum Test
{
CV = Metrology.Test.CV,
MonthlyCV = Metrology.Test.MonthlyCV,
WeeklyCV = Metrology.Test.WeeklyCV
}
}
}

View File

@ -0,0 +1,18 @@
namespace Shared.Metrology
{
public class MET08DDINCAN8620
{
public enum Test
{
CandelaKlarfDC = Metrology.Test.CandelaKlarfDC,
CandelaLaser = Metrology.Test.CandelaLaser,
CandelaVerify = Metrology.Test.CandelaVerify,
CandelaPSL = Metrology.Test.CandelaPSL,
CandelaProdU = Metrology.Test.CandelaProdU
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08DDUPSFS6420
{
public enum Test
{
Tencor = Metrology.Test.Tencor
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08DDUPSP1TBI
{
public enum Test
{
SP1 = Metrology.Test.SP1
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08EBEAMINTEGRITY26
{
public enum Test
{
Denton = Metrology.Test.Denton
}
}
}

View File

@ -0,0 +1,16 @@
namespace Shared.Metrology
{
public class MET08HALLHL5580
{
public enum Test
{
Hall = Metrology.Test.Hall,
MonthlyHall = Metrology.Test.MonthlyHall,
WeeklyHall = Metrology.Test.WeeklyHall
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08MESMICROSCOPE
{
public enum Test
{
Microscope = Metrology.Test.Microscope
}
}
}

View File

@ -0,0 +1,15 @@
namespace Shared.Metrology
{
public class MET08NDFRESIMAP151C
{
public enum Test
{
Lehighton = Metrology.Test.Lehighton,
VerificationLehighton = Metrology.Test.VerificationLehighton
}
}
}

View File

@ -0,0 +1,20 @@
namespace Shared.Metrology
{
public class MET08PLMAPRPM
{
public enum Test
{
RPMXY = Metrology.Test.RPMXY,
RPMAverage = Metrology.Test.RPMAverage,
RPMPLRatio = Metrology.Test.RPMPLRatio,
DailyRPMXY = Metrology.Test.DailyRPMXY,
DailyRPMAverage = Metrology.Test.DailyRPMAverage,
DailyRPMPLRatio = Metrology.Test.DailyRPMPLRatio,
VerificationRPM = Metrology.Test.VerificationRPM
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08PRFUSB4000
{
public enum Test
{
Photoreflectance = Metrology.Test.Photoreflectance
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08RESIHGCV
{
public enum Test
{
HgCV = Metrology.Test.HgCV
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08RESIMAPCDE
{
public enum Test
{
CDE = Metrology.Test.CDE
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08THFTIRQS408M
{
public enum Test
{
BioRadQS408M = Metrology.Test.BioRadQS408M
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08THFTIRSTRATUS
{
public enum Test
{
BioRadStratus = Metrology.Test.BioRadStratus
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08UVH44GS100M
{
public enum Test
{
UV = Metrology.Test.UV
}
}
}

View File

@ -0,0 +1,14 @@
namespace Shared.Metrology
{
public class MET08VPDSUBCON
{
public enum Test
{
VpdIcpmsAnalyte = Metrology.Test.VpdIcpmsAnalyte
}
}
}

View File

@ -0,0 +1,15 @@
namespace Shared.Metrology
{
public class MET08WGEOMX203641Q
{
public enum Test
{
WarpAndBow = Metrology.Test.WarpAndBow,
VerificationWarpAndBow = Metrology.Test.VerificationWarpAndBow
}
}
}

View File

@ -0,0 +1,23 @@
namespace Shared.Metrology
{
public class MET08XRDXPERTPROMRDXL
{
public enum Test
{
XRDXY = Metrology.Test.XRDXY,
XRDWeightedAverage = Metrology.Test.XRDWeightedAverage,
MonthlyXRD = Metrology.Test.MonthlyXRD,
WeeklyXRD = Metrology.Test.WeeklyXRD,
WeeklyXRDAIcomp = Metrology.Test.WeeklyXRDAIcomp,
WeeklyXRDFWHM002 = Metrology.Test.WeeklyXRDFWHM002,
WeeklyXRDFWHM105 = Metrology.Test.WeeklyXRDFWHM105,
WeeklyXRDSLStks = Metrology.Test.WeeklyXRDSLStks,
WeeklyXRDXRR = Metrology.Test.WeeklyXRDXRR,
JVXRD = Metrology.Test.JVXRD
}
}
}

View File

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
namespace Shared.Metrology
{
public class Duplicator
{
public class Description : IProcessDataDescription
{
public int Test { get; set; }
public int Count { get; set; }
public int Index { get; set; }
//
public string EventName { get; set; }
public string NullData { get; set; }
public string JobID { get; set; }
public string Sequence { get; set; }
public string MesEntity { get; set; }
public string ReportFullPath { get; set; }
public string ProcessJobID { get; set; }
public string MID { get; set; }
public string Date { get; set; } //2021-02-22
public string GetEventDescription() { return "File Has been read and parsed"; }
public List<string> GetHeaderNames(ILogic logic, ConfigDataBase configDataBase)
{
List<string> results = new List<string>();
return results;
}
public List<string> GetDetailNames(ILogic logic, ConfigDataBase configDataBase)
{
List<string> results = new List<string>();
return results;
}
public List<string> GetParameterNames(ILogic logic, ConfigDataBase configDataBase)
{
List<string> results = new List<string>();
return results;
}
public List<string> GetPairedParameterNames(ILogic logic, ConfigDataBase configDataBase)
{
List<string> results = new List<string>();
return results;
}
public List<string> GetIgnoreParameterNames(ILogic logic, ConfigDataBase configDataBase, Test test)
{
List<string> results = new List<string>();
return results;
}
public List<string> GetNames(ILogic logic, ConfigDataBase configDataBase)
{
List<string> results = new List<string>();
IProcessDataDescription processDataDescription = GetDefault(logic, configDataBase);
string json = JsonSerializer.Serialize(processDataDescription, processDataDescription.GetType());
object @object = JsonSerializer.Deserialize<object>(json);
if (!(@object is JsonElement jsonElement))
throw new Exception();
foreach (JsonProperty jsonProperty in jsonElement.EnumerateObject())
results.Add(jsonProperty.Name);
return results;
}
public IProcessDataDescription GetDisplayNames(ILogic logic, ConfigDataBase configDataBase)
{
Description result = new Description();
return result;
}
public IProcessDataDescription GetDefault(ILogic logic, ConfigDataBase configDataBase)
{
Description result = new Description
{
Test = -1,
Count = 0,
Index = -1,
//
EventName = configDataBase.GetEventName(),
NullData = string.Empty,
JobID = logic.Logistics.JobID,
Sequence = logic.Logistics.Sequence.ToString(),
MesEntity = logic.Logistics.MesEntity,
ReportFullPath = logic.Logistics.ReportFullPath,
ProcessJobID = logic.Logistics.ProcessJobID,
MID = logic.Logistics.MID,
Date = logic.Logistics.DateTimeFromSequence.ToUniversalTime().ToString("MM/dd/yyyy HH:mm:ss"),
};
return result;
}
public List<IProcessDataDescription> GetDescription(ILogic logic, ConfigDataBase configDataBase, List<Test> tests, IProcessData iProcessData)
{
List<IProcessDataDescription> results = new List<IProcessDataDescription>();
return results;
}
}
}
}

View File

@ -0,0 +1,527 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
namespace Shared.Metrology
{
public class ProcessDataStandardFormat
{
public const string RecordStart = "RECORD_START";
public enum SearchFor
{
EquipmentIntegration = 1,
BusinessIntegration = 2,
SystemExport = 3,
Archive = 4
}
public static string GetPDSFText(ILogic logic, string eventName, string equipmentType, JsonElement jsonElement, string logisticsText)
{
string result;
if (jsonElement.ValueKind != JsonValueKind.Array)
result = string.Empty;
else
{
int columns = 0;
List<string> lines;
string endOffset = "E#######T";
string dataOffset = "D#######T";
string headerOffset = "H#######T";
string format = "MM/dd/yyyy HH:mm:ss";
StringBuilder stringBuilder = new StringBuilder();
lines = new string[] { "HEADER_TAG\tHEADER_VALUE", "FORMAT\t2.00", "NUMBER_PASSES\t0001", string.Concat("HEADER_OFFSET\t", headerOffset), string.Concat("DATA_OFFSET\t", dataOffset), string.Concat("END_OFFSET\t", endOffset) }.ToList();
stringBuilder.Append("\"Time\"").Append('\t');
stringBuilder.Append("\"A_LOGISTICS\"").Append('\t');
stringBuilder.Append("\"B_LOGISTICS\"").Append('\t');
JsonElement[] jsonElements = jsonElement.EnumerateArray().ToArray();
for (int i = 0; i < jsonElements.Length;)
{
foreach (JsonProperty jsonProperty in jsonElements[0].EnumerateObject())
{
columns += 1;
stringBuilder.Append("\"").Append(jsonProperty.Name).Append("\"").Append('\t');
}
break;
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString());
for (int i = 0; i < jsonElements.Length; i++)
{
stringBuilder.Clear();
stringBuilder.Append("0.1").Append('\t');
stringBuilder.Append("1").Append('\t');
stringBuilder.Append("2").Append('\t');
foreach (JsonProperty jsonProperty in jsonElements[i].EnumerateObject())
stringBuilder.Append(jsonProperty.Value).Append('\t');
stringBuilder.Remove(stringBuilder.Length - 1, 1);
lines.Add(stringBuilder.ToString());
}
lines.Add(string.Concat("NUM_DATA_ROWS ", jsonElements.Length.ToString().PadLeft(9, '0')));
lines.Add(string.Concat("NUM_DATA_COLUMNS ", (columns + 3).ToString().PadLeft(9, '0')));
lines.Add("DELIMITER ;");
lines.Add(string.Concat("START_TIME_FORMAT ", format));
lines.Add(string.Concat("START_TIME ", logic.Logistics.DateTimeFromSequence.ToString(format))); //12/26/2019 15:22:44
lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "A_LOGISTICS"));
lines.Add(string.Concat("LOGISTICS_COLUMN", '\t', "B_LOGISTICS"));
if (!string.IsNullOrEmpty(logisticsText))
lines.Add(logisticsText);
else
{
lines.Add(string.Concat("LOGISTICS_1", '\t', "A_CHAMBER=;A_INFO=", eventName, ";A_INFO2=", equipmentType, ";A_JOBID=", logic.Logistics.JobID, ";A_MES_ENTITY=", logic.Logistics.MesEntity, ";A_MID=", logic.Logistics.MID, ";A_NULL_DATA=", logic.Logistics.NullData, ";A_PPID=NO_PPID;A_PROCESS_JOBID=", logic.Logistics.ProcessJobID, ";A_PRODUCT=;A_SEQUENCE=", logic.Logistics.Sequence, ";A_WAFER_ID=;"));
lines.Add(string.Concat("LOGISTICS_2", '\t', "B_CHAMBER=;B_INFO=", eventName, ";B_INFO2=", equipmentType, ";B_JOBID=", logic.Logistics.JobID, ";B_MES_ENTITY=", logic.Logistics.MesEntity, ";B_MID=", logic.Logistics.MID, ";B_NULL_DATA=", logic.Logistics.NullData, ";B_PPID=NO_PPID;B_PROCESS_JOBID=", logic.Logistics.ProcessJobID, ";B_PRODUCT=;B_SEQUENCE=", logic.Logistics.Sequence, ";B_WAFER_ID=;"));
lines.Add("END_HEADER");
}
stringBuilder.Clear();
foreach (string line in lines)
stringBuilder.AppendLine(line);
result = stringBuilder.ToString();
result = result.Replace(headerOffset, result.IndexOf("NUM_DATA_ROWS").ToString().PadLeft(9, '0')).
Replace(dataOffset, result.IndexOf('"').ToString().PadLeft(9, '0')).
Replace(endOffset, result.Length.ToString().PadLeft(9, '0'));
}
return result;
}
public static Tuple<string, string[], string[]> GetLogisticsColumnsAndBody(string reportFullPath, string[] lines = null)
{
string segment;
List<string> body = new List<string>();
StringBuilder logistics = new StringBuilder();
if (lines is null)
lines = File.ReadAllLines(reportFullPath);
string[] segments;
if (lines.Length < 7)
segments = new string[] { };
else
segments = lines[6].Trim().Split('\t');
List<string> columns = new List<string>();
for (int c = 0; c < segments.Length; c++)
{
segment = segments[c].Substring(1, segments[c].Length - 2);
if (!columns.Contains(segment))
columns.Add(segment);
else
{
for (short i = 1; i < short.MaxValue; i++)
{
segment = string.Concat(segment, "_", i);
if (!columns.Contains(segment))
{
columns.Add(segment);
break;
}
}
}
}
bool lookForLogistics = false;
for (int r = 7; r < lines.Count(); r++)
{
if (lines[r].StartsWith("NUM_DATA_ROWS"))
lookForLogistics = true;
if (!lookForLogistics)
{
body.Add(lines[r]);
continue;
}
if (lines[r].StartsWith("LOGISTICS_1"))
{
for (int i = r; i < lines.Count(); i++)
{
if (lines[r].StartsWith("END_HEADER"))
break;
logistics.AppendLine(lines[i]);
}
break;
}
}
return new Tuple<string, string[], string[]>(logistics.ToString(), columns.ToArray(), body.ToArray());
}
public static JsonElement GetArray(Tuple<string, string[], string[]> pdsf, bool lookForNumbers = false)
{
JsonElement result;
string logistics = pdsf.Item1;
string[] columns = pdsf.Item2;
string[] bodyLines = pdsf.Item3;
if (!bodyLines.Any() || !bodyLines[0].Contains('\t'))
result = JsonSerializer.Deserialize<JsonElement>("[]");
else
{
string value;
string[] segments;
StringBuilder stringBuilder = new StringBuilder();
foreach (string bodyLine in bodyLines)
{
stringBuilder.Append('{');
segments = bodyLine.Trim().Split('\t');
if (!lookForNumbers)
{
for (int c = 1; c < segments.Length; c++)
{
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
}
}
else
{
for (int c = 1; c < segments.Length; c++)
{
value = segments[c].Replace("\"", "\\\"").Replace("\\", "\\\\");
if (string.IsNullOrEmpty(value))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append("null,");
else if (value.All(char.IsDigit))
stringBuilder.Append('"').Append(columns[c]).Append("\":").Append(value).Append(",");
else
stringBuilder.Append('"').Append(columns[c]).Append("\":\"").Append(value).Append("\",");
}
}
stringBuilder.Remove(stringBuilder.Length - 1, 1);
stringBuilder.AppendLine("},");
}
stringBuilder.Remove(stringBuilder.Length - 3, 3);
result = JsonSerializer.Deserialize<JsonElement>(string.Concat("[", stringBuilder, "]"));
}
return result;
}
public static Dictionary<string, List<string>> GetDictionary(Tuple<string, string[], string[]> pdsf)
{
Dictionary<string, List<string>> results = new Dictionary<string, List<string>>();
string[] segments;
string[] columns = pdsf.Item2;
string[] bodyLines = pdsf.Item3;
foreach (string column in columns)
results.Add(column, new List<string>());
foreach (string bodyLine in bodyLines)
{
segments = bodyLine.Split('\t');
for (int c = 1; c < segments.Length; c++)
{
if (c >= columns.Length)
continue;
results[columns[c]].Add(segments[c]);
}
}
return results;
}
public static Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>> GetTestDictionary(Tuple<string, string[], string[]> pdsf)
{
Dictionary<Test, Dictionary<string, List<string>>> results = new Dictionary<Test, Dictionary<string, List<string>>>();
string testColumn = Description.RowColumn.Test.ToString();
Dictionary<string, List<string>> keyValuePairs = GetDictionary(pdsf);
if (!keyValuePairs.ContainsKey(testColumn))
throw new Exception();
int min;
int max;
Test testKey;
List<string> vs;
string columnKey;
Dictionary<Test, List<int>> tests = new Dictionary<Test, List<int>>();
for (int i = 0; i < keyValuePairs[testColumn].Count; i++)
{
if (Enum.TryParse(keyValuePairs[testColumn][i], out Test test))
{
if (!results.ContainsKey(test))
{
tests.Add(test, new List<int>());
results.Add(test, new Dictionary<string, List<string>>());
}
tests[test].Add(i);
}
}
foreach (KeyValuePair<Test, List<int>> testKeyValuePair in tests)
{
testKey = testKeyValuePair.Key;
min = testKeyValuePair.Value.Min();
max = testKeyValuePair.Value.Max() + 1;
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
results[testKey].Add(keyValuePair.Key, new List<string>());
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{
vs = keyValuePair.Value;
columnKey = keyValuePair.Key;
for (int i = min; i < max; i++)
{
if (vs.Count > i)
results[testKey][columnKey].Add(vs[i]);
else
results[testKey][columnKey].Add(string.Empty);
}
}
}
return new Tuple<string, Dictionary<Test, Dictionary<string, List<string>>>>(pdsf.Item1, results);
}
private static string GetString(SearchFor searchFor, bool addSpaces, char separator = ' ')
{
if (!addSpaces)
return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), searchFor);
else
return string.Concat(((int)searchFor).ToString().PadLeft(2, '0'), separator, searchFor.ToString().Replace("In", string.Concat(separator, "In")).Replace("Ex", string.Concat(separator, "Ex")));
}
public static string EquipmentIntegration(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.EquipmentIntegration, addSpaces, separator);
}
public static string BusinessIntegration(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.BusinessIntegration, addSpaces, separator);
}
public static string SystemExport(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.SystemExport, addSpaces, separator);
}
public static string Archive(bool addSpaces = true, char separator = ' ')
{
return GetString(SearchFor.Archive, addSpaces, separator);
}
public static string GetLines(Logistics logistics, IScopeInfo scopeInfo, Dictionary<string, List<string>> keyValuePairs, Enum[] enumColumns, string dateFormat, string timeFormat, Column[] pairedColumns, bool useDateTimeFromSequence = true, string format = "", Dictionary<Column, string> alternateDisplayName = null, Enum[] ignoreColumns = null)
{
StringBuilder result = new StringBuilder();
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
throw new Exception();
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
throw new Exception();
int start;
string ckey;
string pKey;
int pairedColumnsCount;
string firstDuplicate = "_1";
if (ignoreColumns is null)
ignoreColumns = new Enum[] { };
if (alternateDisplayName is null)
alternateDisplayName = new Dictionary<Column, string>();
string columnDate = Column.Date.ToString();
string columnTime = Column.Time.ToString();
List<string> columnKeys = new List<string>();
foreach (Enum item in enumColumns)
{
if (ignoreColumns.Contains(item))
continue;
columnKeys.Add(item.ToString());
}
result.AppendLine(scopeInfo.Header);
StringBuilder line = new StringBuilder();
int count = keyValuePairs[Description.RowColumn.Count.ToString()].Count();
string nullData;
if (logistics.NullData is null)
nullData = string.Empty;
else
nullData = logistics.NullData.ToString();
if (pairedColumns is null)
{
start = -1;
pairedColumnsCount = 0;
}
else
{
start = 0;
pairedColumnsCount = pairedColumns.Length;
}
for (int r = 0; r < count; r++)
{
for (int p = start; p < pairedColumnsCount; p++)
{
if (pairedColumnsCount == 0)
pKey = string.Empty;
else if (!(ignoreColumns is null) && ignoreColumns.Contains(pairedColumns[p]))
continue;
else
{
pKey = pairedColumns[p].ToString();
if (!keyValuePairs.ContainsKey(pKey))
continue;
else if (keyValuePairs[pKey][r] == nullData)
continue;
}
if (pairedColumnsCount == 0 || !string.IsNullOrEmpty(pKey))
{
line.Clear();
line.Append("!");
for (int i = 0; i < columnKeys.Count; i++)
{
ckey = columnKeys[i];
if (!keyValuePairs.ContainsKey(ckey))
line.Append(string.Empty);
else
{
if (useDateTimeFromSequence && ckey == columnDate)
line.Append(logistics.DateTimeFromSequence.ToString(dateFormat));
else if (useDateTimeFromSequence && ckey == columnTime)
line.Append(logistics.DateTimeFromSequence.ToString(timeFormat));
else if (!useDateTimeFromSequence && ckey == columnDate && keyValuePairs[ckey][r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePairs[ckey][r], format, CultureInfo.InvariantCulture).ToString(dateFormat));
else if (!useDateTimeFromSequence && ckey == columnTime && keyValuePairs.ContainsKey(string.Concat(ckey, firstDuplicate)) && keyValuePairs[string.Concat(ckey, firstDuplicate)][r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePairs[string.Concat(ckey, firstDuplicate)][r], format, CultureInfo.InvariantCulture).ToString(timeFormat));
else
line.Append(keyValuePairs[ckey][r]);
}
line.Append(';');
}
if (pairedColumnsCount > 0)
{
if (!alternateDisplayName.ContainsKey(pairedColumns[p]))
line.Append(pairedColumns[p].GetDiplayName());
else
line.Append(alternateDisplayName[pairedColumns[p]]);
line.Append(';');
line.Append(keyValuePairs[pKey][r]);
line.Append(';');
}
line.Remove(line.Length - 1, 1);
result.AppendLine(line.ToString());
}
}
}
return result.ToString();
}
public static string GetLines(Logistics logistics, IScopeInfo scopeInfo, List<string> names, Dictionary<string, List<string>> keyValuePairs, string dateFormat, string timeFormat, List<string> pairedParameterNames, bool useDateTimeFromSequence = true, string format = "", List<string> ignoreParameterNames = null)
{
StringBuilder result = new StringBuilder();
if (ignoreParameterNames is null)
ignoreParameterNames = new List<string>();
if (useDateTimeFromSequence && !string.IsNullOrEmpty(format))
throw new Exception();
else if (!useDateTimeFromSequence && string.IsNullOrEmpty(format))
throw new Exception();
string nullData;
const string columnDate = "Date";
const string columnTime = "Time";
const string firstDuplicate = "_1";
result.AppendLine(scopeInfo.Header);
StringBuilder line = new StringBuilder();
if (logistics.NullData is null)
nullData = string.Empty;
else
nullData = logistics.NullData.ToString();
int count = (from l in keyValuePairs select l.Value.Count).Min();
for (int r = 0; r < count; r++)
{
line.Clear();
line.Append("!");
foreach (KeyValuePair<string, List<string>> keyValuePair in keyValuePairs)
{
if (!names.Contains(keyValuePair.Key))
continue;
if (ignoreParameterNames.Contains(keyValuePair.Key))
continue;
if (pairedParameterNames.Contains(keyValuePair.Key))
{
if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
continue;
else
result.Append(line).Append(keyValuePair.Key).Append(';').AppendLine(keyValuePair.Value[r]);
}
else
{
if (useDateTimeFromSequence && keyValuePair.Key == columnDate)
line.Append(logistics.DateTimeFromSequence.ToString(dateFormat));
else if (useDateTimeFromSequence && keyValuePair.Key == columnTime)
line.Append(logistics.DateTimeFromSequence.ToString(timeFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnDate && keyValuePair.Value[r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePair.Value[r], format, CultureInfo.InvariantCulture).ToString(dateFormat));
else if (!useDateTimeFromSequence && keyValuePair.Key == columnTime && keyValuePairs.ContainsKey(string.Concat(keyValuePair.Key, firstDuplicate)) && keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r].Length == format.Length)
line.Append(DateTime.ParseExact(keyValuePairs[string.Concat(keyValuePair.Key, firstDuplicate)][r], format, CultureInfo.InvariantCulture).ToString(timeFormat));
else if (string.IsNullOrEmpty(keyValuePair.Value[r]) || keyValuePair.Value[r] == nullData)
line.Append(nullData);
else
line.Append(keyValuePair.Value[r]);
line.Append(';');
}
}
if (!pairedParameterNames.Any())
{
line.Remove(line.Length - 1, 1);
result.AppendLine(line.ToString());
}
}
return result.ToString();
}
public static List<string> PDSFToFixedWidth(string reportFullPath)
{
List<string> results = new List<string>();
if (!File.Exists(reportFullPath))
throw new Exception();
int[] group;
string line;
int startsAt = 0;
string[] segments;
int? currentGroup = null;
char inputSeperator = '\t';
char outputSeperator = '\t';
List<int> vs = new List<int>();
List<int[]> groups = new List<int[]>();
string[] lines = File.ReadAllLines(reportFullPath);
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < lines.Length; i++)
{
if (string.IsNullOrEmpty(lines[i]))
continue;
segments = lines[i].Split(inputSeperator);
if (currentGroup is null)
currentGroup = segments.Length;
if (segments.Length != currentGroup)
{
currentGroup = segments.Length;
groups.Add(new int[] { startsAt, i - 1 });
startsAt = i;
}
}
if (startsAt == lines.Length - 1 && lines[0].Split(inputSeperator).Length != currentGroup)
groups.Add(new int[] { lines.Length - 1, lines.Length - 1 });
for (int g = 0; g < groups.Count; g++)
{
vs.Clear();
group = groups[g];
line = lines[group[0]];
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
vs.Add(segments[s].Length);
for (int i = group[0]; i <= group[1]; i++)
{
line = lines[i];
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
{
if (vs[s] < segments[s].Length)
vs[s] = segments[s].Length;
}
}
stringBuilder.Clear();
for (int s = 0; s < segments.Length; s++)
stringBuilder.Append((s + 1).ToString().PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
for (int i = group[0]; i <= group[1]; i++)
{
line = lines[i];
stringBuilder.Clear();
segments = line.Split(inputSeperator);
for (int s = 0; s < segments.Length; s++)
stringBuilder.Append(segments[s].PadLeft(vs[s], ' ')).Append(outputSeperator);
stringBuilder.Remove(stringBuilder.Length - 1, 1);
results.Add(stringBuilder.ToString());
}
results.Add(string.Empty);
}
return results;
}
}
}

View File

@ -0,0 +1,57 @@
namespace Shared.Metrology
{
public enum Test
{
AFMRoughness = 34,
BioRadQS408M = 25,
BioRadStratus = 26,
BreakdownVoltageCenter = 0,
BreakdownVoltageEdge = 1,
BreakdownVoltageMiddle8in = 2,
CandelaKlarfDC = 6,
CandelaLaser = 36,
CandelaProdU = 39,
CandelaPSL = 38,
CandelaVerify = 37,
CDE = 24,
CV = 3,
DailyRPMAverage = 19,
DailyRPMPLRatio = 20,
DailyRPMXY = 18,
Denton = 9,
DiffusionLength = 45,
Hall = 10,
HgCV = 23,
Lehighton = 13,
Microscope = 46,
MonthlyCV = 4,
MonthlyHall = 11,
MonthlyXRD = 32,
Photoreflectance = 22,
PlatoA = 48, //Largest
RPMAverage = 16,
RPMPLRatio = 17,
RPMXY = 15,
SP1 = 8,
Tencor = 7,
UV = 35,
VerificationLehighton = 14,
VerificationRPM = 21,
VerificationWarpAndBow = 29,
VpdIcpmsAnalyte = 27,
WarpAndBow = 28,
WeeklyCV = 5,
WeeklyHall = 12,
WeeklyXRD = 33,
WeeklyXRDAIcomp = 40,
WeeklyXRDFWHM002 = 41,
WeeklyXRDFWHM105 = 42,
WeeklyXRDSLStks = 43,
WeeklyXRDXRR = 44,
XRDWeightedAverage = 31,
JVXRD = 47,
XRDXY = 30
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using APCViewer.Models;
using Microsoft.Extensions.Logging;
using Shared;
using System;
using System.Collections.Generic;
using System.Net;
namespace APCViewer.Singleton
{
public interface IBackground : Models.IBackground, IDisposable
{
void ClearMessage();
void SendStatusOk();
void LogisticsClear();
string Message { get; }
IsEnvironment IsEnvironment { get; }
bool IsPrimaryInstance();
void SetIsPrimaryInstance();
WebClient WebClient { get; }
void ClearIsPrimaryInstance();
AppSettings AppSettings { get; }
string GetPDSF(long Sequence);
string GetIPDSF(long Sequence);
string WorkingDirectory { get; }
List<Exception> Exceptions { get; }
string GetCountDirectory(string verb);
void Update(ILogger<object> logger, WebClient webClient);
Tuple<List<string[]>, List<string[]>> GetTimePivot(bool isGaN = false, bool isSi = false);
Tuple<int, object, object, string> SetViewBag(string directory, string filter, bool isGaN = false, bool isSi = false, bool forPDSF = false, bool forIPDSF = false);
}
}

166
APC Viewer/Startup.cs Normal file
View File

@ -0,0 +1,166 @@
using APCViewer.HostedService;
using APCViewer.Models;
using APCViewer.Singleton;
using Helper.Log;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Shared;
using System;
using System.IO;
using System.Net;
using System.Reflection;
namespace APCViewer
{
public class Startup
{
private Background _Background;
private readonly IsEnvironment _IsEnvironment;
private readonly IConfiguration _Configuration;
private readonly IWebHostEnvironment _WebHostEnvironment;
public Startup(IConfiguration configuration, IWebHostEnvironment webHostEnvironment)
{
_Configuration = configuration;
_WebHostEnvironment = webHostEnvironment;
if (!(configuration is ConfigurationRoot configurationRoot))
_IsEnvironment = new IsEnvironment(webHostEnvironment.IsDevelopment(), webHostEnvironment.IsStaging(), webHostEnvironment.IsProduction());
else
{
foreach (IConfigurationProvider provider in configurationRoot.Providers)
{
if (!(provider is JsonConfigurationProvider jsonConfigurationProvider))
continue;
if (jsonConfigurationProvider.Source.Optional)
continue;
_IsEnvironment = new IsEnvironment(jsonConfigurationProvider.Source.Path);
}
}
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
LogLevel defaultLogLevel;
LogLevel log4netLogLevel;
IConfigurationSection configurationSection;
configurationSection = _Configuration.GetSection("Logging:LogLevel:Default");
if (configurationSection is null || configurationSection.Value is null)
defaultLogLevel = LogLevel.Debug;
else if (!Enum.TryParse<LogLevel>(configurationSection.Value, out defaultLogLevel))
defaultLogLevel = LogLevel.Debug;
configurationSection = _Configuration.GetSection("Logging:LogLevel:Log4netProvider");
if (configurationSection is null || configurationSection.Value is null)
log4netLogLevel = defaultLogLevel;
else if (!Enum.TryParse<LogLevel>(configurationSection.Value, out log4netLogLevel))
log4netLogLevel = defaultLogLevel;
Assembly assembly = Assembly.GetExecutingAssembly();
string workingDirectory = Log.GetWorkingDirectory(assembly.GetName().Name, "IFXApps");
services.AddLogging(logging =>
{
logging.AddProvider(new DebugProvider(defaultLogLevel));
logging.AddProvider(new ConsoleProvider(defaultLogLevel));
logging.AddProvider(new Log4netProvider(typeof(Startup), log4netLogLevel, workingDirectory));
});
services.AddDirectoryBrowser();
services.AddControllersWithViews().AddRazorRuntimeCompilation();
services.AddServerSideBlazor();
services.AddSingleton<WebClient, WebClient>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
_Background = new Background(_IsEnvironment, _Configuration, workingDirectory);
services.AddSingleton<Singleton.IBackground, Background>(b => _Background);
services.AddHostedService(t => new TimedHostedService(_Background, _Configuration, t.GetRequiredService<IServiceProvider>()));
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "APCViewer", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime)
{
if (env.IsDevelopment())
{
if (string.IsNullOrEmpty(_Background.Storage.UrlRoot))
{
Environment.ExitCode = -1;
lifetime.StopApplication();
}
app.UseDeveloperExceptionPage();
app.UseSwagger(c =>
{
c.SerializeAsV2 = true;
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "APC Viewer API V1");
c.RoutePrefix = string.Empty;
});
}
else
{
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.UseSwagger(c =>
{
c.SerializeAsV2 = true;
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/APCViewer/swagger/v1/swagger.json", "APC Viewer API V1");
c.RoutePrefix = string.Empty;
});
}
// app.UseDirectoryBrowser(new DirectoryBrowserOptions
// {
// FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, "images")),
// RequestPath = "/MyImages"
// });
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
//endpoints.MapBlazorHub();
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(env.WebRootPath, "images")),
RequestPath = "/MyImages"
});
}
}
}

Some files were not shown because too many files have changed in this diff Show More