Fix reformatting.

This commit is contained in:
2019-11-02 23:52:33 +00:00
parent f6df95b732
commit dcaf51faef
52 changed files with 6663 additions and 5874 deletions

View File

@@ -1,16 +1,627 @@
root = true
[*] [*]
charset=utf-8 charset=utf-8
end_of_line=lf next_line=crlf
trim_trailing_whitespace=true
insert_final_newline=false insert_final_newline=false
indent_style=space indent_style=space
indent_size=4 indent_size=4
[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.uplugin,*.bowerrc,*.jsb3,*.jsb2,*.json}] # Generic non-language specific ones for Resharper and friends
indent_style=space brace_style=next_line
int_align=true
keep_existing_arrangement=false
place_simple_blocks_on_single_line=false
place_simple_declaration_blocks_on_single_line=false
place_attribute_on_same_line=false
space_after_unary_operator=false
space_after_comma=true
space_around_ternary_operator=true
space_around_binary_operator=true
space_around_member_access_operator=false
space_before_open_square_brackets=false
space_after_keywords_in_control_flow_statements=true
space_before_comma=false
space_between_method_call_name_and_opening_parenthesis=false
space_between_method_declaration_name_and_open_parenthesis=false
space_between_square_brackets=false
space_between_parentheses_of_control_flow_statements=false
accessor_owner_declaration_braces=next_line
accessor_declaration_braces=next_line
case_block_braces=next_line
initializer_braces=next_line
other_braces=next_line
allow_comment_after_lbrace=false
empty_block_style=together_same_line
braces_for_ifelse=not_required
braces_for_for=not_required
braces_for_foreach=not_required
braces_for_while=not_required
braces_for_dowhile=not_required
braces_for_using=not_required
braces_for_lock=not_required
braces_for_fixed=not_required
method_or_operator_body=expression_body
local_function_body=expression_body
constructor_or_destructor_body=expression_body
accessor_owner_body=expression_body
force_attribute_style=join
function_braces=next_line
force_control_statements_braces=always_remove
type_declaration_braces=next_line
invocable_declaration_braces=next_line
anonymous_method_declaration_braces=next_line
indent_nested_usings_stmt=true
indent_nested_fixed_stmt=true
indent_nested_lock_stmt=true
indent_nested_for_stmt=true
indent_nested_foreach_stmt=true
indent_nested_while_stmt=true
use_continuous_indent_inside_parens=true
indent_method_decl_pars=inside
indent_invocation_pars=inside
indent_statement_pars=inside
indent_typeparam_angles=inside
indent_typearg_angles=inside
indent_pars=inside
indent_preprocessor_if=outdent
indent_preprocessor_region=usual_indent
indent_preprocessor_other=usual_indent
indent_switch_labels=true
indent_type_constraints=true
stick_comment=false
alignment_tab_fill_style=use_spaces
align_multiline_parameter=true
align_multiline_extends_list=true
align_linq_query=true
align_multiline_binary_expressions_chain=true
outdent_binary_ops=true
align_multiline_calls_chain=true
outdent_dots=true
align_multiline_array_and_object_initializer=false
indent_anonymous_method_block=false
align_first_arg_by_paren=true
align_multiline_argument=true
align_tuple_components=true
align_multiline_expression=true
align_multiline_for_stmt=true
align_multiple_declaration=true
align_multline_type_parameter_list=true
align_multline_type_parameter_constrains=true
int_align_fields=true
int_align_properties=true
int_align_methods=true
int_align_parameters=false
int_align_variables=true
int_align_assignments=true
int_align_nested_ternary=true
int_align_invocations=false
int_align_binary_expressions=true
int_align_comments=true
int_align_switch_sections=true
keep_user_linebreaks=false
keep_existing_arrangement=false
keep_existing_linebreaks=false
max_line_length=120
wrap_before_comma=false
special_else_if_treatment=true
place_type_attribute_on_same_line=never
place_method_attribute_on_same_line=never
place_accessorholder_attribute_on_same_line=never
place_attribute_on_same_line=never
place_accessor_attribute_on_same_line=never
place_attribute_on_same_line=never
place_field_attribute_on_same_line=never
place_attribute_on_same_line=never
wrap_parameters_style=wrap_if_long
keep_existing_declaration_parens_arrangement=false
wrap_before_declaration_lpar=false
wrap_after_declaration_lpar=false
wrap_before_declaration_rpar=false
place_constructor_initializer_on_same_line=true
keep_existing_expr_member_arrangement=false
place_expr_method_on_single_line=true
place_expr_property_on_single_line=true
place_expr_accessor_on_single_line=true
wrap_before_arrow_with_expressions=false
place_type_constraints_on_same_line=true
wrap_before_first_type_parameter_constraint=true
wrap_multiple_type_parameter_constraints_style=wrap_if_long
wrap_before_type_parameter_langle=true
wrap_before_extends_colon=false
wrap_extends_list_style=wrap_if_long
keep_existing_declaration_block_arrangement=false
place_abstract_accessorholder_on_single_line=true
place_simple_accessorholder_on_single_line=false
place_accessor_with_attrs_holder_on_single_line=false
place_simple_accessor_on_single_line=true
place_simple_method_on_single_line=false
keep_existing_enum_arrangement=false
place_simple_enum_on_single_line=false
wrap_enum_declaration=wrap_if_long
new_line_before_else=true
new_line_before_while=false
wrap_for_stmt_header_style=wrap_if_long
wrap_multiple_declaration_style=wrap_if_long
keep_existing_embedded_arrangement=false
place_simple_embedded_statement_on_same_line=false
place_simple_case_statement_on_same_line=true
keep_existing_embedded_block_arrangement=false
place_simple_embedded_block_on_same_line=false
place_simple_anonymousmethod_on_single_line=false
keep_existing_initializer_arrangement=false
place_simple_initializer_on_single_line=false
wrap_object_and_collection_initializer_style=wrap_if_long
wrap_array_initializer_style=wrap_if_long
wrap_arguments_style=wrap_if_long
keep_existing_invocation_parens_arrangement=false
wrap_after_invocation_lpar=false
wrap_before_invocation_rpar=false
wrap_after_dot_in_method_calls=true
wrap_chained_method_calls=wrap_if_long
wrap_before_binary_opsign=false
wrap_chained_binary_expressions=wrap_if_long
force_chop_compound_if_expression=true
force_chop_compound_while_expression=true
force_chop_compound_do_expression=true
wrap_before_ternary_opsigns=true
wrap_ternary_expr_style=wrap_if_long
nested_ternary_style=expanded
wrap_linq_expressions=wrap_if_long
wrap_before_linq_expression=false
place_linq_into_on_new_line=false
wrap_verbatim_interpolated_strings=wrap_if_long
extra_spaces=remove_all
space_after_keywords_in_control_flow_statements=true
space_between_method_call_name_and_opening_parenthesis=false
space_between_method_declaration_name_and_open_parenthesis=false
space_before_typeof_parentheses=false
space_before_checked_parentheses=false
space_before_sizeof_parentheses=false
space_before_nameof_parentheses=false
space_between_keyword_and_expression=true
space_between_keyword_and_type=true
space_around_assignment_op=true
space_around_logical_op=true
space_around_binary_operator=true
space_around_equality_op=true
space_around_relational_op=true
space_around_bitwise_op=true
space_around_additive_op=true
space_around_multiplicative_op=true
space_around_shift_op=true
space_around_nullcoalescing_op=true
space_around_arrow_op=false
space_after_logical_not_op=false
space_after_unary_operator=false
space_after_cast=false
space_around_dot=false
space_around_lambda_arrow=true
space_before_pointer_asterik_declaration=false
space_before_nullable_mark=false
blank_lines_around_class_definition=1
namespace_indentation=all
space_within_template_argument=false
align_union_type_usage=true
# These are for markup languages (HTML, XML, etc)
spaces_around_eq_in_pi_attribute=false
space_after_last_pi_attribute=true
pi_attributes_indent=align_by_first_attribute
blank_line_after_pi=true
spaces_around_eq_in_attribute=false
space_after_last_attribute=false
space_before_self_closing=true
attribute_style=on_single_line
attribute_indent=align_by_first_attribute
sort_attributes=true
sort_class_selectors=true
max_blank_lines_between_tags=0
linebreak_before_all_elements=true
linebreak_before_multiline_elements=true
quote_style=doublequoted
delete_quotes_from_solid_values=false
normalize_tag_names=true
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}]
indent_size=2 indent_size=2
[{*.yml,*.yaml}] [*.js.map]
indent_style=space
indent_size=2 indent_size=2
[*.{css,scss}]
indent_size=2
declarations_style=separate_lines_for_nonsingle
media_query_style=separate_lines
selector_style=same_line
properties_style=separate_lines_for_nonsingle
brace_style=next_line
[{.analysis_options,*.yml,*.yaml}]
indent_size=2
# Xml project files
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
indent_size = 2
# Xml files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2
# Xml config files
[*.{props,targets,config,nuspec}]
indent_size = 2
# .net files
[*.{cs,vb}]
# These set the this. / Me.
dotnet_style_qualification_for_field=false:warning
dotnet_style_qualification_for_property=false:warning
dotnet_style_qualification_for_method=false:warning
dotnet_style_qualification_for_event=false:warning
# These make it suggest Int32 instead of int, etc.
dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion
dotnet_style_predefined_type_for_member_access=true:suggestion
# This controls implicit access modifiers
dotnet_style_require_accessibility_modifiers=never:suggestion
# Prefer non modified fields to be marked readonly
dotnet_style_readonly_field=true:warning
# Parenthesis settings
dotnet_style_parentheses_in_arithmetic_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_relational_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:warning
dotnet_style_parentheses_in_other_operators=always_for_clarity:warning
dotnet_style_object_initializer=true:suggestion
dotnet_style_collection_initializer=true:suggestion
dotnet_style_explicit_tuple_names=true:error
dotnet_style_prefer_inferred_tuple_names=true:warning
dotnet_style_prefer_inferred_anonymous_type_member_names=true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method=true:warning
dotnet_style_prefer_conditional_expression_over_return=true:warning
dotnet_style_coalesce_expression=true:warning
dotnet_style_null_propagation=true:error
dotnet_sort_system_directives_first=true
# Constants in C style, all-caps
dotnet_naming_rule.constant_fields_caps.symbols = constant_fields
dotnet_naming_rule.constant_fields_caps.severity = suggestion
dotnet_naming_rule.constant_fields_caps.style = caps_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.caps_style.capitalization = all_upper
# interfaces should be prefixed with I
dotnet_naming_rule.pascal_case_for_interface.severity = error
dotnet_naming_rule.pascal_case_for_interface.symbols = interfaces_fields
dotnet_naming_rule.pascal_case_for_interface.style = pascal_case_interface_style
dotnet_naming_symbols.interfaces_fields.applicable_kinds = interface
dotnet_naming_style.pascal_case_interface_style.required_prefix = I
dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case
## internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
# 2018-12-07 NP: This is not yet working in VS2017
# local variables should be camelCase
#dotnet_naming_rule.camel_case_for_locals.severity = suggestion
#dotnet_naming_rule.camel_case_for_locals.symbols = local_fields
#dotnet_naming_rule.camel_case_for_locals.style = camel_case_style
#dotnet_naming_symbols.local_fields.applicable_kinds = local
#dotnet_naming_style.camel_case_style.capitalization = camel_case
[*.cs]
# var var var
csharp_style_var_for_built_in_types=false:warning
csharp_style_var_when_type_is_apparent=true:suggestion
csharp_style_var_elsewhere=false:warning
csharp_style_expression_bodied_methods=when_on_single_line:suggestion
csharp_style_expression_bodied_constructors=when_on_single_line:suggestion
csharp_style_expression_bodied_operators=when_on_single_line:suggestion
csharp_style_expression_bodied_properties=when_on_single_line:suggestion
csharp_style_expression_bodied_indexers=when_on_single_line:suggestion
csharp_style_expression_bodied_accessors=when_on_single_line:suggestion
csharp_style_pattern_matching_over_is_with_cast_check=true:warning
csharp_style_pattern_matching_over_as_with_null_check=when_on_single_line:warning
csharp_style_inlined_variable_declaration=true:warning
csharp_prefer_simple_default_expression=true:warning
csharp_style_deconstructed_variable_declaration=false:warning
csharp_style_throw_expression=true:warning
csharp_style_conditional_delegate_call=true:warning
csharp_prefer_braces=false
csharp_new_line_before_open_brace=all
csharp_new_line_before_else=true
csharp_new_line_before_catch=true
csharp_new_line_before_finally=true
csharp_new_line_before_members_in_object_initializers=true
csharp_new_line_before_members_in_anonymous_types=true
csharp_new_line_between_query_expression_clauses=true
csharp_indent_case_contents=true
csharp_indent_switch_labels=true
csharp_indent_labels=flush_left
csharp_space_after_cast=false
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_declaration_parameter_list_parentheses=false
csharp_space_between_parentheses=none
csharp_space_before_colon_in_inheritance_clause=true
csharp_space_after_colon_in_inheritance_clause=true
csharp_space_around_binary_operators=before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses=false
csharp_space_between_method_call_name_and_opening_parenthesis=false
csharp_space_between_method_call_empty_parameter_list_parentheses=false
csharp_preserve_single_line_statements=false
csharp_preserve_single_line_blocks=true
csharp_blank_lines_around_region=0
csharp_blank_lines_inside_region=0
csharp_blank_lines_before_single_line_comment=1
csharp_keep_blank_lines_in_declarations=1
csharp_remove_blank_lines_near_braces_in_declarations=true
csharp_blank_lines_after_start_comment=false
csharp_blank_lines_between_using_groups=0
csharp_blank_lines_after_using_list=1
csharp_blank_lines_around_namespace=1
csharp_blank_lines_inside_namespace=0
csharp_blank_lines_around_type=1
csharp_blank_lines_inside_type=0
csharp_blank_lines_around_field=0
csharp_blank_lines_around_single_line_field=0
csharp_blank_lines_around_property=1
csharp_blank_lines_around_single_line_property=0
csharp_blank_lines_around_auto_property=0
csharp_blank_lines_around_single_line_auto_property=0
csharp_blank_lines_around_invocable=1
csharp_blank_lines_around_single_line_invocable=1
csharp_keep_blank_lines_in_code=1
csharp_remove_blank_lines_near_braces_in_code=true
csharp_blank_lines_around_local_method=1
csharp_blank_lines_around_single_line_local_method=1
csharp_blank_lines_before_control_transfer_statements=1
csharp_blank_lines_after_control_transfer_statements=1
csharp_blank_lines_before_block_statements=1
csharp_blank_lines_after_block_statements=1
csharp_blank_lines_before_multiline_statements=1
csharp_blank_lines_after_multiline_statements=1
csharp_type_declaration_braces=next_line
csharp_brace_style=next_line
csharp_indent_inside_namespace=true
csharp_invocable_declaration_braces=next_line
csharp_anonymous_method_declaration_braces=next_line
csharp_accessor_owner_declaration_braces=next_line
csharp_accessor_declaration_braces=next_line
csharp_case_block_braces=next_line
csharp_initializer_braces=next_line
csharp_other_braces=next_line
csharp_allow_comment_after_lbrace=false
csharp_empty_block_style=together_same_line
csharp_for_built_in_types=use_explicit_type
csharp_for_simple_types=use_var_when_evident
csharp_for_other_types=use_explicit_type
csharp_prefer_separate_deconstructed_variables_declaration=true
csharp_prefer_explicit_discard_declaration=false
csharp_instance_members_qualify_members=none
csharp_builtin_type_reference_style=use_keyword
csharp_prefer_qualified_reference=false
csharp_add_imports_to_deepest_scope=false
csharp_allow_alias=true
csharp_default_private_modifier=implicit
csharp_default_internal_modifier=explicit
csharp_arguments_literal=positional
csharp_arguments_string_literal=positional
csharp_arguments_named=positional
csharp_arguments_anonymous_function=positional
csharp_arguments_other=positional
csharp_braces_for_ifelse=not_required
csharp_braces_for_for=not_required
csharp_braces_for_foreach=not_required
csharp_braces_for_while=not_required
csharp_braces_for_dowhile=not_required
csharp_braces_for_using=not_required
csharp_braces_for_lock=not_required
csharp_braces_for_fixed=not_required
csharp_method_or_operator_body=expression_body
csharp_local_function_body=expression_body
csharp_constructor_or_destructor_body=expression_body
csharp_accessor_owner_body=expression_body
csharp_force_attribute_style=join
csharp_indent_nested_usings_stmt=true
csharp_builtin_type_reference_for_member_access_style=use_keyword
csharp_indent_nested_fixed_stmt=true
csharp_indent_nested_lock_stmt=true
csharp_indent_nested_for_stmt=true
csharp_indent_nested_foreach_stmt=true
csharp_indent_nested_while_stmt=true
csharp_use_continuous_indent_inside_parens=true
csharp_indent_method_decl_pars=inside
csharp_indent_invocation_pars=inside
csharp_indent_statement_pars=inside
csharp_indent_typeparam_angles=inside
csharp_indent_typearg_angles=inside
csharp_indent_pars=inside
csharp_indent_preprocessor_if=outdent
csharp_indent_preprocessor_region=usual_indent
csharp_indent_preprocessor_other=usual_indent
csharp_indent_switch_labels=true
csharp_indent_type_constraints=true
csharp_stick_comment=false
csharp_alignment_tab_fill_style=use_spaces
csharp_align_multiline_parameter=true
csharp_align_multiline_extends_list=true
csharp_align_linq_query=true
csharp_align_multiline_binary_expressions_chain=true
csharp_outdent_binary_ops=true
csharp_align_multiline_calls_chain=true
csharp_outdent_dots=true
csharp_align_multiline_array_and_object_initializer=false
csharp_indent_anonymous_method_block=false
csharp_align_first_arg_by_paren=true
csharp_align_multiline_argument=true
csharp_align_tuple_components=true
csharp_align_multiline_expression=true
csharp_align_multiline_for_stmt=true
csharp_align_multiple_declaration=true
csharp_align_multline_type_parameter_list=true
csharp_align_multline_type_parameter_constrains=true
csharp_int_align_fields=true
csharp_int_align_properties=true
csharp_int_align_methods=true
csharp_int_align_parameters=false
csharp_int_align_variables=true
csharp_int_align_assignments=true
csharp_int_align_nested_ternary=true
csharp_int_align_invocations=false
csharp_int_align_binary_expressions=true
csharp_int_align_comments=true
csharp_int_align_switch_sections=true
csharp_keep_user_linebreaks=false
csharp_keep_existing_arrangement=false
csharp_keep_existing_linebreaks=false
csharp_max_line_length=120
csharp_wrap_before_comma=false
csharp_special_else_if_treatment=true
csharp_insert_final_newline=false
csharp_place_type_attribute_on_same_line=never
csharp_place_method_attribute_on_same_line=never
csharp_place_accessorholder_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_place_accessor_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_place_field_attribute_on_same_line=never
csharp_place_attribute_on_same_line=never
csharp_wrap_parameters_style=wrap_if_long
csharp_keep_existing_declaration_parens_arrangement=false
csharp_wrap_before_declaration_lpar=false
csharp_wrap_after_declaration_lpar=false
csharp_wrap_before_declaration_rpar=false
csharp_place_constructor_initializer_on_same_line=true
csharp_keep_existing_expr_member_arrangement=false
csharp_place_expr_method_on_single_line=true
csharp_place_expr_property_on_single_line=true
csharp_place_expr_accessor_on_single_line=true
csharp_wrap_before_arrow_with_expressions=false
csharp_place_type_constraints_on_same_line=true
csharp_wrap_before_first_type_parameter_constraint=true
csharp_wrap_multiple_type_parameter_constraints_style=wrap_if_long
csharp_wrap_before_type_parameter_langle=true
csharp_wrap_before_extends_colon=false
csharp_wrap_extends_list_style=wrap_if_long
csharp_keep_existing_declaration_block_arrangement=false
csharp_place_abstract_accessorholder_on_single_line=true
csharp_place_simple_accessorholder_on_single_line=false
csharp_place_accessor_with_attrs_holder_on_single_line=false
csharp_place_simple_accessor_on_single_line=true
csharp_place_simple_method_on_single_line=false
csharp_keep_existing_enum_arrangement=false
csharp_place_simple_enum_on_single_line=false
csharp_wrap_enum_declaration=wrap_if_long
csharp_new_line_before_else=true
csharp_new_line_before_while=false
csharp_wrap_for_stmt_header_style=wrap_if_long
csharp_wrap_multiple_declaration_style=wrap_if_long
csharp_keep_existing_embedded_arrangement=false
csharp_place_simple_embedded_statement_on_same_line=false
csharp_place_simple_case_statement_on_same_line=true
csharp_keep_existing_embedded_block_arrangement=false
csharp_place_simple_embedded_block_on_same_line=false
csharp_place_simple_anonymousmethod_on_single_line=false
csharp_keep_existing_initializer_arrangement=false
csharp_place_simple_initializer_on_single_line=false
csharp_wrap_object_and_collection_initializer_style=wrap_if_long
csharp_wrap_array_initializer_style=wrap_if_long
csharp_wrap_arguments_style=wrap_if_long
csharp_keep_existing_invocation_parens_arrangement=false
csharp_wrap_after_invocation_lpar=false
csharp_wrap_before_invocation_rpar=false
csharp_wrap_after_dot_in_method_calls=true
csharp_wrap_chained_method_calls=wrap_if_long
csharp_wrap_before_binary_opsign=false
csharp_wrap_chained_binary_expressions=wrap_if_long
csharp_force_chop_compound_if_expression=true
csharp_force_chop_compound_while_expression=true
csharp_force_chop_compound_do_expression=true
csharp_wrap_before_ternary_opsigns=true
csharp_wrap_ternary_expr_style=wrap_if_long
csharp_nested_ternary_style=expanded
csharp_wrap_linq_expressions=wrap_if_long
csharp_wrap_before_linq_expression=false
csharp_place_linq_into_on_new_line=false
csharp_wrap_verbatim_interpolated_strings=wrap_if_long
csharp_extra_spaces=remove_all
csharp_space_after_keywords_in_control_flow_statements=false
csharp_space_between_method_call_name_and_opening_parenthesis=false
csharp_space_between_method_declaration_name_and_open_parenthesis=false
csharp_space_before_typeof_parentheses=false
csharp_space_before_checked_parentheses=false
csharp_space_before_sizeof_parentheses=false
csharp_space_before_nameof_parentheses=false
csharp_space_between_keyword_and_expression=false
csharp_space_between_keyword_and_type=false
csharp_space_around_assignment_op=true
csharp_space_around_logical_op=true
csharp_space_around_binary_operator=true
csharp_space_around_equality_op=true
csharp_space_around_relational_op=true
csharp_space_around_bitwise_op=true
csharp_space_around_additive_op=true
csharp_space_around_multiplicative_op=true
csharp_space_around_shift_op=true
csharp_space_around_nullcoalescing_op=true
csharp_space_around_arrow_op=false
csharp_space_after_logical_not_op=false
csharp_space_after_unary_operator=false
csharp_space_after_cast=false
csharp_space_around_dot=false
csharp_space_around_lambda_arrow=true
csharp_space_before_pointer_asterik_declaration=false
csharp_space_before_nullable_mark=false
[*.cshtml]
linebreaks_around_razor_statements=true
blank_lines_around_razor_functions=true
blank_lines_around_razor_helpers=true
blank_lines_around_razor_sections=true
# C++
[*.{cc,cpp,cxx,h,hpp,hxx}]
cpp_indent_access_specifiers_from_class=true
cpp_indent_wrapped_function_names=false
cpp_align_multiline_type_argument=true
# C, C++ and ObjectiveC
[*.{c,h,cc,cpp,cxx,m,hpp,hxx}]
indent_preprocessor_directives=normal
indent_type_constraints=true
# Javascript and Typescript
[*.{js,js.map,ts}]
quote_style=doublequoted
termination_style=ensure_semicolon

View File

@@ -64,26 +64,27 @@ namespace DiscImageChef.Server.Task
try try
{ {
System.Console.WriteLine("{0}: Retrieving USB IDs from Linux USB...", DateTime.UtcNow); System.Console.WriteLine("{0}: Retrieving USB IDs from Linux USB...", DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
client = new WebClient(); client = new WebClient();
var sr = new StringReader(client.DownloadString("http://www.linux-usb.org/usb.ids")); var sr = new StringReader(client.DownloadString("http://www.linux-usb.org/usb.ids"));
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
UsbVendor vendor = null; UsbVendor vendor = null;
var newVendors = 0; int newVendors = 0;
var newProducts = 0; int newProducts = 0;
var modifiedVendors = 0; int modifiedVendors = 0;
var modifiedProducts = 0; int modifiedProducts = 0;
var counter = 0; int counter = 0;
start = DateTime.UtcNow; start = DateTime.UtcNow;
System.Console.WriteLine("{0}: Adding and updating database entries...", DateTime.UtcNow); System.Console.WriteLine("{0}: Adding and updating database entries...", DateTime.UtcNow);
do do
{ {
if (counter == 1000) if(counter == 1000)
{ {
var start2 = DateTime.UtcNow; DateTime start2 = DateTime.UtcNow;
System.Console.WriteLine("{0}: Saving changes", start2); System.Console.WriteLine("{0}: Saving changes", start2);
ctx.SaveChanges(); ctx.SaveChanges();
end = DateTime.UtcNow; end = DateTime.UtcNow;
@@ -91,52 +92,59 @@ namespace DiscImageChef.Server.Task
counter = 0; counter = 0;
} }
var line = sr.ReadLine(); string line = sr.ReadLine();
if (line is null) break; if(line is null)
break;
if (line.Length == 0 || line[0] == '#') continue; if(line.Length == 0 ||
line[0] == '#')
continue;
ushort number; ushort number;
string name; string name;
if (line[0] == '\t')
if(line[0] == '\t')
{ {
try try
{ {
number = Convert.ToUInt16(line.Substring(1, 4), 16); number = Convert.ToUInt16(line.Substring(1, 4), 16);
} }
catch (FormatException) catch(FormatException)
{ {
continue; continue;
} }
if (number == 0) continue; if(number == 0)
continue;
name = line.Substring(7); name = line.Substring(7);
var product = UsbProduct product =
ctx.UsbProducts.FirstOrDefault(p => p.ProductId == number && p.Vendor != null && ctx.UsbProducts.FirstOrDefault(p => p.ProductId == number && p.Vendor != null &&
p.Vendor.VendorId == vendor.VendorId); p.Vendor.VendorId == vendor.VendorId);
if (product is null) if(product is null)
{ {
product = new UsbProduct(vendor, number, name); product = new UsbProduct(vendor, number, name);
ctx.UsbProducts.Add(product); ctx.UsbProducts.Add(product);
System.Console.WriteLine("{0}: Will add product {1} with ID {2:X4} and vendor {3} ({4:X4})", System.Console.WriteLine("{0}: Will add product {1} with ID {2:X4} and vendor {3} ({4:X4})",
DateTime.UtcNow, product.Product, product.ProductId, DateTime.UtcNow, product.Product, product.ProductId,
product.Vendor?.Vendor ?? "null", product.Vendor?.VendorId ?? 0); product.Vendor?.Vendor ?? "null", product.Vendor?.VendorId ?? 0);
newProducts++; newProducts++;
counter++; counter++;
} }
else if (name != product.Product) else if(name != product.Product)
{ {
System.Console System.Console.
.WriteLine( WriteLine("{0}: Will modify product with ID {1:X4} and vendor {2} ({3:X4}) from \"{4}\" to \"{5}\"",
"{0}: Will modify product with ID {1:X4} and vendor {2} ({3:X4}) from \"{4}\" to \"{5}\"", DateTime.UtcNow, product.ProductId, product.Vendor?.Vendor ?? "null",
DateTime.UtcNow, product.ProductId, product.Vendor?.Vendor ?? "null", product.Vendor?.VendorId ?? 0,
product.Vendor?.VendorId ?? 0, product.Product, name);
product.Product, name);
product.Product = name; product.Product = name;
product.ModifiedWhen = DateTime.UtcNow; product.ModifiedWhen = DateTime.UtcNow;
modifiedProducts++; modifiedProducts++;
counter++; counter++;
@@ -149,37 +157,40 @@ namespace DiscImageChef.Server.Task
{ {
number = Convert.ToUInt16(line.Substring(0, 4), 16); number = Convert.ToUInt16(line.Substring(0, 4), 16);
} }
catch (FormatException) catch(FormatException)
{ {
continue; continue;
} }
if (number == 0) continue; if(number == 0)
continue;
name = line.Substring(6); name = line.Substring(6);
vendor = ctx.UsbVendors.FirstOrDefault(v => v.VendorId == number); vendor = ctx.UsbVendors.FirstOrDefault(v => v.VendorId == number);
if (vendor is null) if(vendor is null)
{ {
vendor = new UsbVendor(number, name); vendor = new UsbVendor(number, name);
ctx.UsbVendors.Add(vendor); ctx.UsbVendors.Add(vendor);
System.Console.WriteLine("{0}: Will add vendor {1} with ID {2:X4}", DateTime.UtcNow, System.Console.WriteLine("{0}: Will add vendor {1} with ID {2:X4}", DateTime.UtcNow,
vendor.Vendor, vendor.Vendor, vendor.VendorId);
vendor.VendorId);
newVendors++; newVendors++;
counter++; counter++;
} }
else if (name != vendor.Vendor) else if(name != vendor.Vendor)
{ {
System.Console.WriteLine("{0}: Will modify vendor with ID {1:X4} from \"{2}\" to \"{3}\"", System.Console.WriteLine("{0}: Will modify vendor with ID {1:X4} from \"{2}\" to \"{3}\"",
DateTime.UtcNow, vendor.VendorId, vendor.Vendor, name); DateTime.UtcNow, vendor.VendorId, vendor.Vendor, name);
vendor.Vendor = name;
vendor.Vendor = name;
vendor.ModifiedWhen = DateTime.UtcNow; vendor.ModifiedWhen = DateTime.UtcNow;
modifiedVendors++; modifiedVendors++;
counter++; counter++;
} }
} while (true); } while(true);
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
@@ -196,36 +207,46 @@ namespace DiscImageChef.Server.Task
System.Console.WriteLine("{0}: {1} products modified.", DateTime.UtcNow, modifiedProducts); System.Console.WriteLine("{0}: {1} products modified.", DateTime.UtcNow, modifiedProducts);
System.Console.WriteLine("{0}: Looking up a vendor", DateTime.UtcNow); System.Console.WriteLine("{0}: Looking up a vendor", DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
vendor = ctx.UsbVendors.FirstOrDefault(v => v.VendorId == 0x8086); vendor = ctx.UsbVendors.FirstOrDefault(v => v.VendorId == 0x8086);
if (vendor is null) System.Console.WriteLine("{0}: Error, could not find vendor.", DateTime.UtcNow);
if(vendor is null)
System.Console.WriteLine("{0}: Error, could not find vendor.", DateTime.UtcNow);
else else
System.Console.WriteLine("{0}: Found {1}.", DateTime.UtcNow, System.Console.WriteLine("{0}: Found {1}.", DateTime.UtcNow, vendor.Vendor);
vendor.Vendor);
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
System.Console.WriteLine("{0}: Looking up a product", DateTime.UtcNow); System.Console.WriteLine("{0}: Looking up a product", DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
var prd =
UsbProduct prd =
ctx.UsbProducts.FirstOrDefault(p => p.ProductId == 0x0001 && p.Vendor.VendorId == 0x8086); ctx.UsbProducts.FirstOrDefault(p => p.ProductId == 0x0001 && p.Vendor.VendorId == 0x8086);
if (prd is null) System.Console.WriteLine("{0}: Error, could not find product.", DateTime.UtcNow);
else System.Console.WriteLine("{0}: Found {1}.", DateTime.UtcNow, prd.Product); if(prd is null)
System.Console.WriteLine("{0}: Error, could not find product.", DateTime.UtcNow);
else
System.Console.WriteLine("{0}: Found {1}.", DateTime.UtcNow, prd.Product);
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
} }
catch (Exception ex) catch(Exception ex)
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
System.Console.WriteLine("{0}: Exception {1} filling USB IDs...", DateTime.UtcNow, ex); System.Console.WriteLine("{0}: Exception {1} filling USB IDs...", DateTime.UtcNow, ex);
} }
System.Console.WriteLine("{0}: Fixing all devices without modification time...", DateTime.UtcNow); System.Console.WriteLine("{0}: Fixing all devices without modification time...", DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
foreach (var device in ctx.Devices.Where(d => d.ModifiedWhen == null))
foreach(Device device in ctx.Devices.Where(d => d.ModifiedWhen == null))
device.ModifiedWhen = device.AddedWhen; device.ModifiedWhen = device.AddedWhen;
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
@@ -238,11 +259,12 @@ namespace DiscImageChef.Server.Task
try try
{ {
System.Console.WriteLine("{0}: Retrieving CompactDisc read offsets from AccurateRip...", System.Console.WriteLine("{0}: Retrieving CompactDisc read offsets from AccurateRip...",
DateTime.UtcNow); DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
client = new WebClient(); client = new WebClient();
var html = client.DownloadString("http://www.accuraterip.com/driveoffsets.htm"); string html = client.DownloadString("http://www.accuraterip.com/driveoffsets.htm");
end = DateTime.UtcNow; end = DateTime.UtcNow;
System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds); System.Console.WriteLine("{0}: Took {1:F2} seconds", end, (end - start).TotalSeconds);
@@ -252,133 +274,147 @@ namespace DiscImageChef.Server.Task
var doc = new HtmlDocument(); var doc = new HtmlDocument();
doc.LoadHtml(html); doc.LoadHtml(html);
var firstTable = doc.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[1]"); HtmlNode firstTable = doc.DocumentNode.SelectSingleNode("/html[1]/body[1]/table[1]");
var firstRow = true; bool firstRow = true;
var addedOffsets = 0; int addedOffsets = 0;
var modifiedOffsets = 0; int modifiedOffsets = 0;
System.Console.WriteLine("{0}: Processing offsets...", DateTime.UtcNow); System.Console.WriteLine("{0}: Processing offsets...", DateTime.UtcNow);
start = DateTime.UtcNow; start = DateTime.UtcNow;
foreach (var row in firstTable.Descendants("tr"))
{
var columns = row.Descendants("td").ToArray();
if (columns.Length != 4) foreach(HtmlNode row in firstTable.Descendants("tr"))
{
HtmlNode[] columns = row.Descendants("td").ToArray();
if(columns.Length != 4)
{ {
System.Console.WriteLine("{0}: Row does not have correct number of columns...", System.Console.WriteLine("{0}: Row does not have correct number of columns...",
DateTime.UtcNow); DateTime.UtcNow);
continue; continue;
} }
var column0 = columns[0].InnerText; string column0 = columns[0].InnerText;
var column1 = columns[1].InnerText; string column1 = columns[1].InnerText;
var column2 = columns[2].InnerText; string column2 = columns[2].InnerText;
var column3 = columns[3].InnerText; string column3 = columns[3].InnerText;
if (firstRow) if(firstRow)
{ {
if (column0.ToLowerInvariant() != "cd drive") if(column0.ToLowerInvariant() != "cd drive")
{ {
System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow, System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow,
columns[0].InnerText); columns[0].InnerText);
break; break;
} }
if (column1.ToLowerInvariant() != "correction offset") if(column1.ToLowerInvariant() != "correction offset")
{ {
System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow, System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow,
columns[1].InnerText); columns[1].InnerText);
break; break;
} }
if (column2.ToLowerInvariant() != "submitted by") if(column2.ToLowerInvariant() != "submitted by")
{ {
System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow, System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow,
columns[2].InnerText); columns[2].InnerText);
break; break;
} }
if (column3.ToLowerInvariant() != "percentage agree") if(column3.ToLowerInvariant() != "percentage agree")
{ {
System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow, System.Console.WriteLine("{0}: Unexpected header \"{1}\" found...", DateTime.UtcNow,
columns[3].InnerText); columns[3].InnerText);
break; break;
} }
firstRow = false; firstRow = false;
continue; continue;
} }
string manufacturer; string manufacturer;
string model; string model;
if (column0[0] == '-' && column0[1] == ' ') if(column0[0] == '-' &&
column0[1] == ' ')
{ {
manufacturer = null; manufacturer = null;
model = column0.Substring(2).Trim(); model = column0.Substring(2).Trim();
} }
else else
{ {
var cutOffset = column0.IndexOf(" - ", StringComparison.Ordinal); int cutOffset = column0.IndexOf(" - ", StringComparison.Ordinal);
if (cutOffset == -1) if(cutOffset == -1)
{ {
manufacturer = null; manufacturer = null;
model = column0; model = column0;
} }
else else
{ {
manufacturer = column0.Substring(0, cutOffset).Trim(); manufacturer = column0.Substring(0, cutOffset).Trim();
model = column0.Substring(cutOffset + 3).Trim(); model = column0.Substring(cutOffset + 3).Trim();
} }
} }
switch (manufacturer) switch(manufacturer)
{ {
case "Lite-ON": case"Lite-ON":
manufacturer = "JLMS"; manufacturer = "JLMS";
break; break;
case "LG Electronics": case"LG Electronics":
manufacturer = "HL-DT-ST"; manufacturer = "HL-DT-ST";
break; break;
case "Panasonic": case"Panasonic":
manufacturer = "MATSHITA"; manufacturer = "MATSHITA";
break; break;
} }
var cdOffset = CompactDiscOffset cdOffset =
ctx.CdOffsets.FirstOrDefault(o => o.Manufacturer == manufacturer && o.Model == model); ctx.CdOffsets.FirstOrDefault(o => o.Manufacturer == manufacturer && o.Model == model);
if (column1.ToLowerInvariant() == "[purged]") if(column1.ToLowerInvariant() == "[purged]")
{ {
if (cdOffset != null) ctx.CdOffsets.Remove(cdOffset); if(cdOffset != null)
ctx.CdOffsets.Remove(cdOffset);
continue; continue;
} }
if (!short.TryParse(column1, out var offset)) continue; if(!short.TryParse(column1, out short offset))
if (!int.TryParse(column2, out var submissions)) continue; continue;
if (column3[column3.Length - 1] != '%') continue; if(!int.TryParse(column2, out int submissions))
continue;
if(column3[column3.Length - 1] != '%')
continue;
column3 = column3.Substring(0, column3.Length - 1); column3 = column3.Substring(0, column3.Length - 1);
if (!float.TryParse(column3, out var percentage)) continue; if(!float.TryParse(column3, out float percentage))
continue;
percentage /= 100; percentage /= 100;
if (cdOffset is null) if(cdOffset is null)
{ {
cdOffset = new CompactDiscOffset cdOffset = new CompactDiscOffset
{ {
AddedWhen = DateTime.UtcNow, AddedWhen = DateTime.UtcNow, ModifiedWhen = DateTime.UtcNow, Agreement = percentage,
ModifiedWhen = DateTime.UtcNow, Manufacturer = manufacturer, Model = model, Offset = offset,
Agreement = percentage, Submissions = submissions
Manufacturer = manufacturer,
Model = model,
Offset = offset,
Submissions = submissions
}; };
ctx.CdOffsets.Add(cdOffset); ctx.CdOffsets.Add(cdOffset);
@@ -386,40 +422,44 @@ namespace DiscImageChef.Server.Task
} }
else else
{ {
if (Math.Abs(cdOffset.Agreement - percentage) > 0) if(Math.Abs(cdOffset.Agreement - percentage) > 0)
{ {
cdOffset.Agreement = percentage; cdOffset.Agreement = percentage;
cdOffset.ModifiedWhen = DateTime.UtcNow; cdOffset.ModifiedWhen = DateTime.UtcNow;
} }
if (cdOffset.Offset != offset) if(cdOffset.Offset != offset)
{ {
cdOffset.Offset = offset; cdOffset.Offset = offset;
cdOffset.ModifiedWhen = DateTime.UtcNow; cdOffset.ModifiedWhen = DateTime.UtcNow;
} }
if (cdOffset.Submissions != submissions) if(cdOffset.Submissions != submissions)
{ {
cdOffset.Submissions = submissions; cdOffset.Submissions = submissions;
cdOffset.ModifiedWhen = DateTime.UtcNow; cdOffset.ModifiedWhen = DateTime.UtcNow;
} }
if (Math.Abs(cdOffset.Agreement - percentage) > 0 || cdOffset.Offset != offset || if(Math.Abs(cdOffset.Agreement - percentage) > 0 ||
cdOffset.Submissions != submissions) modifiedOffsets++; cdOffset.Offset != offset ||
cdOffset.Submissions != submissions)
modifiedOffsets++;
} }
foreach (var device in ctx foreach(Device device in ctx.
.Devices Devices.
.Where(d => d.Manufacturer == null && d.Model != null && Where(d => d.Manufacturer == null && d.Model != null &&
d.Model.Trim() == model) d.Model.Trim() == model).
.Union(ctx.Devices.Where(d => d.Manufacturer != null && Union(ctx.Devices.Where(d => d.Manufacturer != null &&
d.Manufacturer.Trim() == manufacturer && d.Manufacturer.Trim() == manufacturer &&
d.Model != null && d.Model != null &&
d.Model == model))) d.Model == model)))
{ {
if (device.CdOffset == cdOffset && device.ModifiedWhen == cdOffset.ModifiedWhen) continue; if(device.CdOffset == cdOffset &&
device.ModifiedWhen == cdOffset.ModifiedWhen)
continue;
device.CdOffset = cdOffset; device.CdOffset = cdOffset;
device.ModifiedWhen = cdOffset.ModifiedWhen; device.ModifiedWhen = cdOffset.ModifiedWhen;
} }
} }
@@ -436,11 +476,12 @@ namespace DiscImageChef.Server.Task
System.Console.WriteLine("{0}: Added {1} offsets", end, addedOffsets); System.Console.WriteLine("{0}: Added {1} offsets", end, addedOffsets);
System.Console.WriteLine("{0}: Modified {1} offsets", end, modifiedOffsets); System.Console.WriteLine("{0}: Modified {1} offsets", end, modifiedOffsets);
} }
catch (Exception ex) catch(Exception ex)
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
System.Console.WriteLine("{0}: Exception {1} filling CompactDisc read offsets...", DateTime.UtcNow, ex); System.Console.WriteLine("{0}: Exception {1} filling CompactDisc read offsets...", DateTime.UtcNow, ex);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -39,52 +39,72 @@ namespace DiscImageChef.Server
public static class ScsiEvpd public static class ScsiEvpd
{ {
/// <summary> /// <summary>
/// Takes the SCSI EVPD part of a device report and prints it as a list key=value pairs to be sequenced by ASP.NET in /// Takes the SCSI EVPD part of a device report and prints it as a list key=value pairs to be sequenced by ASP.NET
/// the rendering /// in the rendering
/// </summary> /// </summary>
/// <param name="pages">EVPD pages</param> /// <param name="pages">EVPD pages</param>
/// <param name="vendor">SCSI vendor string</param> /// <param name="vendor">SCSI vendor string</param>
/// <param name="evpdPages">List to put the key=value pairs on</param> /// <param name="evpdPages">List to put the key=value pairs on</param>
public static void Report(IEnumerable<ScsiPage> pages, string vendor, ref Dictionary<string, string> evpdPages) public static void Report(IEnumerable<ScsiPage> pages, string vendor, ref Dictionary<string, string> evpdPages)
{ {
foreach (var evpd in pages) foreach(ScsiPage evpd in pages)
{ {
string decoded; string decoded;
if (evpd.page >= 0x01 && evpd.page <= 0x7F) decoded = EVPD.DecodeASCIIPage(evpd.value);
else if (evpd.page == 0x81) decoded = EVPD.PrettifyPage_81(evpd.value);
else if (evpd.page == 0x82) decoded = EVPD.DecodePage82(evpd.value);
else if (evpd.page == 0x83) decoded = EVPD.PrettifyPage_83(evpd.value);
else if (evpd.page == 0x84) decoded = EVPD.PrettifyPage_84(evpd.value);
else if (evpd.page == 0x85) decoded = EVPD.PrettifyPage_85(evpd.value);
else if (evpd.page == 0x86) decoded = EVPD.PrettifyPage_86(evpd.value);
else if (evpd.page == 0x89) decoded = EVPD.PrettifyPage_89(evpd.value);
else if (evpd.page == 0xB0) decoded = EVPD.PrettifyPage_B0(evpd.value);
else if (evpd.page == 0xB2)
decoded =
$"TapeAlert Supported Flags Bitmap: 0x{EVPD.DecodePageB2(evpd.value):X16}<br/>";
else if (evpd.page == 0xB4) decoded = EVPD.DecodePageB4(evpd.value);
else if (evpd.page == 0xC0 && vendor.Trim() == "quantum")
decoded = EVPD.PrettifyPage_C0_Quantum(evpd.value);
else if (evpd.page == 0xC0 && vendor.Trim() == "seagate")
decoded =
EVPD.PrettifyPage_C0_Seagate(evpd.value);
else if (evpd.page == 0xC0 && vendor.Trim() == "ibm")
decoded = EVPD.PrettifyPage_C0_IBM(evpd.value);
else if (evpd.page == 0xC1 && vendor.Trim() == "ibm")
decoded = EVPD.PrettifyPage_C1_IBM(evpd.value);
else if ((evpd.page == 0xC0 || evpd.page == 0xC1) && vendor.Trim() == "certance")
decoded = EVPD.PrettifyPage_C0_C1_Certance(evpd.value);
else if ((evpd.page == 0xC2 || evpd.page == 0xC3 || evpd.page == 0xC4 || evpd.page == 0xC5 ||
evpd.page == 0xC6) &&
vendor.Trim() == "certance") decoded = EVPD.PrettifyPage_C2_C3_C4_C5_C6_Certance(evpd.value);
else if ((evpd.page == 0xC0 || evpd.page == 0xC1 || evpd.page == 0xC2 || evpd.page == 0xC3 ||
evpd.page == 0xC4 || evpd.page == 0xC5) &&
vendor.Trim() == "hp") decoded = EVPD.PrettifyPage_C0_to_C5_HP(evpd.value);
else if (evpd.page == 0xDF && vendor.Trim() == "certance")
decoded = EVPD.PrettifyPage_DF_Certance(evpd.value);
else decoded = "Undecoded";
if (!string.IsNullOrEmpty(decoded)) decoded = decoded.Replace("\n", "<br/>"); if(evpd.page >= 0x01 &&
evpd.page <= 0x7F)
decoded = EVPD.DecodeASCIIPage(evpd.value);
else if(evpd.page == 0x81)
decoded = EVPD.PrettifyPage_81(evpd.value);
else if(evpd.page == 0x82)
decoded = EVPD.DecodePage82(evpd.value);
else if(evpd.page == 0x83)
decoded = EVPD.PrettifyPage_83(evpd.value);
else if(evpd.page == 0x84)
decoded = EVPD.PrettifyPage_84(evpd.value);
else if(evpd.page == 0x85)
decoded = EVPD.PrettifyPage_85(evpd.value);
else if(evpd.page == 0x86)
decoded = EVPD.PrettifyPage_86(evpd.value);
else if(evpd.page == 0x89)
decoded = EVPD.PrettifyPage_89(evpd.value);
else if(evpd.page == 0xB0)
decoded = EVPD.PrettifyPage_B0(evpd.value);
else if(evpd.page == 0xB2)
decoded = $"TapeAlert Supported Flags Bitmap: 0x{EVPD.DecodePageB2(evpd.value):X16}<br/>";
else if(evpd.page == 0xB4)
decoded = EVPD.DecodePageB4(evpd.value);
else if(evpd.page == 0xC0 &&
vendor.Trim() == "quantum")
decoded = EVPD.PrettifyPage_C0_Quantum(evpd.value);
else if(evpd.page == 0xC0 &&
vendor.Trim() == "seagate")
decoded = EVPD.PrettifyPage_C0_Seagate(evpd.value);
else if(evpd.page == 0xC0 &&
vendor.Trim() == "ibm")
decoded = EVPD.PrettifyPage_C0_IBM(evpd.value);
else if(evpd.page == 0xC1 &&
vendor.Trim() == "ibm")
decoded = EVPD.PrettifyPage_C1_IBM(evpd.value);
else if((evpd.page == 0xC0 || evpd.page == 0xC1) &&
vendor.Trim() == "certance")
decoded = EVPD.PrettifyPage_C0_C1_Certance(evpd.value);
else if((evpd.page == 0xC2 || evpd.page == 0xC3 || evpd.page == 0xC4 || evpd.page == 0xC5 ||
evpd.page == 0xC6) &&
vendor.Trim() == "certance")
decoded = EVPD.PrettifyPage_C2_C3_C4_C5_C6_Certance(evpd.value);
else if((evpd.page == 0xC0 || evpd.page == 0xC1 || evpd.page == 0xC2 || evpd.page == 0xC3 ||
evpd.page == 0xC4 || evpd.page == 0xC5) &&
vendor.Trim() == "hp")
decoded = EVPD.PrettifyPage_C0_to_C5_HP(evpd.value);
else if(evpd.page == 0xDF &&
vendor.Trim() == "certance")
decoded = EVPD.PrettifyPage_DF_Certance(evpd.value);
else
decoded = "Undecoded";
if(!string.IsNullOrEmpty(decoded))
decoded = decoded.Replace("\n", "<br/>");
evpdPages.Add($"EVPD page {evpd.page:X2}h", decoded); evpdPages.Add($"EVPD page {evpd.page:X2}h", decoded);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -39,251 +39,480 @@ namespace DiscImageChef.Server
public static class ScsiMmcFeatures public static class ScsiMmcFeatures
{ {
/// <summary> /// <summary>
/// Takes the MMC FEATURES part of a device report and prints it as a list of values to be sequenced by ASP.NET in the /// Takes the MMC FEATURES part of a device report and prints it as a list of values to be sequenced by ASP.NET in
/// rendering /// the rendering
/// </summary> /// </summary>
/// <param name="ftr">FEATURES part of the report</param> /// <param name="ftr">FEATURES part of the report</param>
/// <param name="mmcOneValue">List to put the values on</param> /// <param name="mmcOneValue">List to put the values on</param>
public static void Report(MmcFeatures ftr, ref List<string> mmcOneValue) public static void Report(MmcFeatures ftr, ref List<string> mmcOneValue)
{ {
if (ftr.SupportsAACS && ftr.AACSVersion.HasValue) if(ftr.SupportsAACS &&
ftr.AACSVersion.HasValue)
mmcOneValue.Add($"Drive supports AACS version {ftr.AACSVersion}"); mmcOneValue.Add($"Drive supports AACS version {ftr.AACSVersion}");
else if (ftr.SupportsAACS) mmcOneValue.Add("Drive supports AACS"); else if(ftr.SupportsAACS)
if (ftr.AGIDs.HasValue) mmcOneValue.Add($"Drive supports {ftr.AGIDs} AGIDs concurrently"); mmcOneValue.Add("Drive supports AACS");
if (ftr.CanGenerateBindingNonce)
if(ftr.AGIDs.HasValue)
mmcOneValue.Add($"Drive supports {ftr.AGIDs} AGIDs concurrently");
if(ftr.CanGenerateBindingNonce)
{ {
mmcOneValue.Add("Drive supports generating the binding nonce"); mmcOneValue.Add("Drive supports generating the binding nonce");
if (ftr.BindingNonceBlocks.HasValue)
if(ftr.BindingNonceBlocks.HasValue)
mmcOneValue.Add($"{ftr.BindingNonceBlocks} media blocks are required for the binding nonce"); mmcOneValue.Add($"{ftr.BindingNonceBlocks} media blocks are required for the binding nonce");
} }
if (ftr.BlocksPerReadableUnit > 1) if(ftr.BlocksPerReadableUnit > 1)
mmcOneValue.Add($"{ftr.BlocksPerReadableUnit} logical blocks per media writable unit"); mmcOneValue.Add($"{ftr.BlocksPerReadableUnit} logical blocks per media writable unit");
if (ftr.BufferUnderrunFreeInDVD) mmcOneValue.Add("Drive supports zero loss linking writing DVDs");
if (ftr.BufferUnderrunFreeInSAO)
mmcOneValue.Add("Drive supports zero loss linking in Session at Once Mode");
if (ftr.BufferUnderrunFreeInTAO) mmcOneValue.Add("Drive supports zero loss linking in Track at Once Mode");
if (ftr.CanAudioScan) mmcOneValue.Add("Drive supports the SCAN command");
if (ftr.CanEject) mmcOneValue.Add("Drive can eject media");
if (ftr.CanEraseSector) mmcOneValue.Add("Drive supports media that require erasing before writing");
if (ftr.CanExpandBDRESpareArea)
mmcOneValue.Add("Drive can expand the spare area on a formatted BD-RE disc");
if (ftr.CanFormat) mmcOneValue.Add("Drive can format media into logical blocks");
if (ftr.CanFormatBDREWithoutSpare) mmcOneValue.Add("Drive can format BD-RE with no spares allocated");
if (ftr.CanFormatQCert) mmcOneValue.Add("Drive can format BD-RE discs with quick certification");
if (ftr.CanFormatCert) mmcOneValue.Add("Drive can format BD-RE discs with full certification");
if (ftr.CanFormatFRF) mmcOneValue.Add("Drive can fast re-format BD-RE discs");
if (ftr.CanFormatRRM) mmcOneValue.Add("Drive can format BD-R discs with RRM format");
if (ftr.CanLoad) mmcOneValue.Add("Drive can load media");
if (ftr.CanMuteSeparateChannels) mmcOneValue.Add("Drive is able to mute channels separately");
if (ftr.CanOverwriteSAOTrack) mmcOneValue.Add("Drive can overwrite a SAO track with another in CD-RWs");
if (ftr.CanOverwriteTAOTrack) mmcOneValue.Add("Drive can overwrite a TAO track with another in CD-RWs");
if (ftr.CanPlayCDAudio) mmcOneValue.Add("Drive has an analogue audio output");
if (ftr.CanPseudoOverwriteBDR) mmcOneValue.Add("Drive can write BD-R on Pseudo-OVerwrite SRM mode");
if (ftr.CanReadAllDualR) mmcOneValue.Add("Drive can read DVD-R DL from all recording modes");
if (ftr.CanReadAllDualRW) mmcOneValue.Add("Drive can read DVD-RW DL from all recording modes");
if (ftr.CanReadBD) mmcOneValue.Add("Drive can read BD-ROM");
if (ftr.CanReadBDR) mmcOneValue.Add("Drive can read BD-R Ver.1");
if (ftr.CanReadBDRE1) mmcOneValue.Add("Drive can read BD-RE Ver.1");
if (ftr.CanReadBDRE2) mmcOneValue.Add("Drive can read BD-RE Ver.2");
if (ftr.CanReadBDROM) mmcOneValue.Add("Drive can read BD-ROM Ver.1");
if (ftr.CanReadBluBCA) mmcOneValue.Add("Drive can read BD's Burst Cutting Area");
if (ftr.CanReadCD) mmcOneValue.Add("Drive can read CD-ROM");
if (ftr.CanWriteCDMRW && ftr.CanReadDVDPlusMRW && ftr.CanWriteDVDPlusMRW)
mmcOneValue.Add("Drive can read and write CD-MRW and DVD+MRW");
else if (ftr.CanReadDVDPlusMRW && ftr.CanWriteDVDPlusMRW)
mmcOneValue.Add("Drive can read and write DVD+MRW");
else if (ftr.CanWriteCDMRW && ftr.CanReadDVDPlusMRW)
mmcOneValue.Add("Drive and read DVD+MRW and read and write CD-MRW");
else if (ftr.CanWriteCDMRW) mmcOneValue.Add("Drive can read and write CD-MRW");
else if (ftr.CanReadDVDPlusMRW) mmcOneValue.Add("Drive can read CD-MRW and DVD+MRW");
else if (ftr.CanReadCDMRW) mmcOneValue.Add("Drive can read CD-MRW");
if (ftr.CanReadCPRM_MKB) mmcOneValue.Add("Drive supports reading Media Key Block of CPRM");
if (ftr.CanReadDDCD) mmcOneValue.Add("Drive can read DDCDs");
if (ftr.CanReadDVD) mmcOneValue.Add("Drive can read DVD");
if (ftr.CanWriteDVDPlusRW) mmcOneValue.Add("Drive can read and write DVD+RW");
else if (ftr.CanReadDVDPlusRW) mmcOneValue.Add("Drive can read DVD+RW");
if (ftr.CanWriteDVDPlusR) mmcOneValue.Add("Drive can read and write DVD+R");
else if (ftr.CanReadDVDPlusR) mmcOneValue.Add("Drive can read DVD+R");
if (ftr.CanWriteDVDPlusRDL) mmcOneValue.Add("Drive can read and write DVD+R DL");
else if (ftr.CanReadDVDPlusRDL) mmcOneValue.Add("Drive can read DVD+R DL");
if (ftr.CanReadDriveAACSCertificate) mmcOneValue.Add("Drive supports reading the Drive Certificate");
if (ftr.CanReadHDDVD && ftr.CanReadHDDVDR && ftr.CanReadHDDVDRAM)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW, HD DVD-R and HD DVD-RAM");
else if (ftr.CanReadHDDVD && ftr.CanReadHDDVDR)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW and HD DVD-R");
else if (ftr.CanReadHDDVD && ftr.CanReadHDDVDRAM)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW and HD DVD-RAM");
else if (ftr.CanReadHDDVD) mmcOneValue.Add("Drive can read HD DVD-ROM and HD DVD-RW");
if (ftr.CanReadLeadInCDText) mmcOneValue.Add("Drive can return CD-Text from Lead-In");
if (ftr.CanReadOldBDR) mmcOneValue.Add("Drive can read BD-R pre-1.0");
if (ftr.CanReadOldBDRE) mmcOneValue.Add("Drive can read BD-RE pre-1.0");
if (ftr.CanReadOldBDROM) mmcOneValue.Add("Drive can read BD-ROM pre-1.0");
if (ftr.CanReadSpareAreaInformation) mmcOneValue.Add("Drive can return Spare Area Information");
if (ftr.CanReportDriveSerial) mmcOneValue.Add("Drive is to report drive serial number");
if (ftr.CanReportMediaSerial) mmcOneValue.Add("Drive is to read media serial number");
if (ftr.CanTestWriteDDCDR) mmcOneValue.Add("Drive can do a test writing with DDCD-R");
if (ftr.CanTestWriteDVD) mmcOneValue.Add("Drive can do a test writing with DVDs");
if (ftr.CanTestWriteInSAO) mmcOneValue.Add("Drive can do a test writing in Session at Once Mode");
if (ftr.CanTestWriteInTAO) mmcOneValue.Add("Drive can do a test writing in Track at Once Mode");
if (ftr.CanUpgradeFirmware) mmcOneValue.Add("Drive supports Microcode Upgrade");
if (ftr.ErrorRecoveryPage) mmcOneValue.Add("Drive shall report Read/Write Error Recovery mode page");
if (ftr.Locked) mmcOneValue.Add("Drive can lock media");
if (ftr.LogicalBlockSize > 0) mmcOneValue.Add($"{ftr.LogicalBlockSize} bytes per logical block");
if (ftr.MultiRead)
mmcOneValue.Add(
"Drive claims capability to read all CD formats according to OSTA Multi-Read Specification");
if (ftr.PhysicalInterfaceStandard.HasValue) if(ftr.BufferUnderrunFreeInDVD)
switch (ftr.PhysicalInterfaceStandard) mmcOneValue.Add("Drive supports zero loss linking writing DVDs");
if(ftr.BufferUnderrunFreeInSAO)
mmcOneValue.Add("Drive supports zero loss linking in Session at Once Mode");
if(ftr.BufferUnderrunFreeInTAO)
mmcOneValue.Add("Drive supports zero loss linking in Track at Once Mode");
if(ftr.CanAudioScan)
mmcOneValue.Add("Drive supports the SCAN command");
if(ftr.CanEject)
mmcOneValue.Add("Drive can eject media");
if(ftr.CanEraseSector)
mmcOneValue.Add("Drive supports media that require erasing before writing");
if(ftr.CanExpandBDRESpareArea)
mmcOneValue.Add("Drive can expand the spare area on a formatted BD-RE disc");
if(ftr.CanFormat)
mmcOneValue.Add("Drive can format media into logical blocks");
if(ftr.CanFormatBDREWithoutSpare)
mmcOneValue.Add("Drive can format BD-RE with no spares allocated");
if(ftr.CanFormatQCert)
mmcOneValue.Add("Drive can format BD-RE discs with quick certification");
if(ftr.CanFormatCert)
mmcOneValue.Add("Drive can format BD-RE discs with full certification");
if(ftr.CanFormatFRF)
mmcOneValue.Add("Drive can fast re-format BD-RE discs");
if(ftr.CanFormatRRM)
mmcOneValue.Add("Drive can format BD-R discs with RRM format");
if(ftr.CanLoad)
mmcOneValue.Add("Drive can load media");
if(ftr.CanMuteSeparateChannels)
mmcOneValue.Add("Drive is able to mute channels separately");
if(ftr.CanOverwriteSAOTrack)
mmcOneValue.Add("Drive can overwrite a SAO track with another in CD-RWs");
if(ftr.CanOverwriteTAOTrack)
mmcOneValue.Add("Drive can overwrite a TAO track with another in CD-RWs");
if(ftr.CanPlayCDAudio)
mmcOneValue.Add("Drive has an analogue audio output");
if(ftr.CanPseudoOverwriteBDR)
mmcOneValue.Add("Drive can write BD-R on Pseudo-OVerwrite SRM mode");
if(ftr.CanReadAllDualR)
mmcOneValue.Add("Drive can read DVD-R DL from all recording modes");
if(ftr.CanReadAllDualRW)
mmcOneValue.Add("Drive can read DVD-RW DL from all recording modes");
if(ftr.CanReadBD)
mmcOneValue.Add("Drive can read BD-ROM");
if(ftr.CanReadBDR)
mmcOneValue.Add("Drive can read BD-R Ver.1");
if(ftr.CanReadBDRE1)
mmcOneValue.Add("Drive can read BD-RE Ver.1");
if(ftr.CanReadBDRE2)
mmcOneValue.Add("Drive can read BD-RE Ver.2");
if(ftr.CanReadBDROM)
mmcOneValue.Add("Drive can read BD-ROM Ver.1");
if(ftr.CanReadBluBCA)
mmcOneValue.Add("Drive can read BD's Burst Cutting Area");
if(ftr.CanReadCD)
mmcOneValue.Add("Drive can read CD-ROM");
if(ftr.CanWriteCDMRW &&
ftr.CanReadDVDPlusMRW &&
ftr.CanWriteDVDPlusMRW)
mmcOneValue.Add("Drive can read and write CD-MRW and DVD+MRW");
else if(ftr.CanReadDVDPlusMRW &&
ftr.CanWriteDVDPlusMRW)
mmcOneValue.Add("Drive can read and write DVD+MRW");
else if(ftr.CanWriteCDMRW &&
ftr.CanReadDVDPlusMRW)
mmcOneValue.Add("Drive and read DVD+MRW and read and write CD-MRW");
else if(ftr.CanWriteCDMRW)
mmcOneValue.Add("Drive can read and write CD-MRW");
else if(ftr.CanReadDVDPlusMRW)
mmcOneValue.Add("Drive can read CD-MRW and DVD+MRW");
else if(ftr.CanReadCDMRW)
mmcOneValue.Add("Drive can read CD-MRW");
if(ftr.CanReadCPRM_MKB)
mmcOneValue.Add("Drive supports reading Media Key Block of CPRM");
if(ftr.CanReadDDCD)
mmcOneValue.Add("Drive can read DDCDs");
if(ftr.CanReadDVD)
mmcOneValue.Add("Drive can read DVD");
if(ftr.CanWriteDVDPlusRW)
mmcOneValue.Add("Drive can read and write DVD+RW");
else if(ftr.CanReadDVDPlusRW)
mmcOneValue.Add("Drive can read DVD+RW");
if(ftr.CanWriteDVDPlusR)
mmcOneValue.Add("Drive can read and write DVD+R");
else if(ftr.CanReadDVDPlusR)
mmcOneValue.Add("Drive can read DVD+R");
if(ftr.CanWriteDVDPlusRDL)
mmcOneValue.Add("Drive can read and write DVD+R DL");
else if(ftr.CanReadDVDPlusRDL)
mmcOneValue.Add("Drive can read DVD+R DL");
if(ftr.CanReadDriveAACSCertificate)
mmcOneValue.Add("Drive supports reading the Drive Certificate");
if(ftr.CanReadHDDVD &&
ftr.CanReadHDDVDR &&
ftr.CanReadHDDVDRAM)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW, HD DVD-R and HD DVD-RAM");
else if(ftr.CanReadHDDVD &&
ftr.CanReadHDDVDR)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW and HD DVD-R");
else if(ftr.CanReadHDDVD &&
ftr.CanReadHDDVDRAM)
mmcOneValue.Add("Drive can read HD DVD-ROM, HD DVD-RW and HD DVD-RAM");
else if(ftr.CanReadHDDVD)
mmcOneValue.Add("Drive can read HD DVD-ROM and HD DVD-RW");
if(ftr.CanReadLeadInCDText)
mmcOneValue.Add("Drive can return CD-Text from Lead-In");
if(ftr.CanReadOldBDR)
mmcOneValue.Add("Drive can read BD-R pre-1.0");
if(ftr.CanReadOldBDRE)
mmcOneValue.Add("Drive can read BD-RE pre-1.0");
if(ftr.CanReadOldBDROM)
mmcOneValue.Add("Drive can read BD-ROM pre-1.0");
if(ftr.CanReadSpareAreaInformation)
mmcOneValue.Add("Drive can return Spare Area Information");
if(ftr.CanReportDriveSerial)
mmcOneValue.Add("Drive is to report drive serial number");
if(ftr.CanReportMediaSerial)
mmcOneValue.Add("Drive is to read media serial number");
if(ftr.CanTestWriteDDCDR)
mmcOneValue.Add("Drive can do a test writing with DDCD-R");
if(ftr.CanTestWriteDVD)
mmcOneValue.Add("Drive can do a test writing with DVDs");
if(ftr.CanTestWriteInSAO)
mmcOneValue.Add("Drive can do a test writing in Session at Once Mode");
if(ftr.CanTestWriteInTAO)
mmcOneValue.Add("Drive can do a test writing in Track at Once Mode");
if(ftr.CanUpgradeFirmware)
mmcOneValue.Add("Drive supports Microcode Upgrade");
if(ftr.ErrorRecoveryPage)
mmcOneValue.Add("Drive shall report Read/Write Error Recovery mode page");
if(ftr.Locked)
mmcOneValue.Add("Drive can lock media");
if(ftr.LogicalBlockSize > 0)
mmcOneValue.Add($"{ftr.LogicalBlockSize} bytes per logical block");
if(ftr.MultiRead)
mmcOneValue.
Add("Drive claims capability to read all CD formats according to OSTA Multi-Read Specification");
if(ftr.PhysicalInterfaceStandard.HasValue)
switch(ftr.PhysicalInterfaceStandard)
{ {
case PhysicalInterfaces.Unspecified: case PhysicalInterfaces.Unspecified:
mmcOneValue.Add("Drive uses an unspecified physical interface"); mmcOneValue.Add("Drive uses an unspecified physical interface");
break; break;
case PhysicalInterfaces.SCSI: case PhysicalInterfaces.SCSI:
mmcOneValue.Add("Drive uses SCSI interface"); mmcOneValue.Add("Drive uses SCSI interface");
break; break;
case PhysicalInterfaces.ATAPI: case PhysicalInterfaces.ATAPI:
mmcOneValue.Add("Drive uses ATAPI interface"); mmcOneValue.Add("Drive uses ATAPI interface");
break; break;
case PhysicalInterfaces.IEEE1394: case PhysicalInterfaces.IEEE1394:
mmcOneValue.Add("Drive uses IEEE-1394 interface"); mmcOneValue.Add("Drive uses IEEE-1394 interface");
break; break;
case PhysicalInterfaces.IEEE1394A: case PhysicalInterfaces.IEEE1394A:
mmcOneValue.Add("Drive uses IEEE-1394A interface"); mmcOneValue.Add("Drive uses IEEE-1394A interface");
break; break;
case PhysicalInterfaces.FC: case PhysicalInterfaces.FC:
mmcOneValue.Add("Drive uses Fibre Channel interface"); mmcOneValue.Add("Drive uses Fibre Channel interface");
break; break;
case PhysicalInterfaces.IEEE1394B: case PhysicalInterfaces.IEEE1394B:
mmcOneValue.Add("Drive uses IEEE-1394B interface"); mmcOneValue.Add("Drive uses IEEE-1394B interface");
break; break;
case PhysicalInterfaces.SerialATAPI: case PhysicalInterfaces.SerialATAPI:
mmcOneValue.Add("Drive uses Serial ATAPI interface"); mmcOneValue.Add("Drive uses Serial ATAPI interface");
break; break;
case PhysicalInterfaces.USB: case PhysicalInterfaces.USB:
mmcOneValue.Add("Drive uses USB interface"); mmcOneValue.Add("Drive uses USB interface");
break; break;
case PhysicalInterfaces.Vendor: case PhysicalInterfaces.Vendor:
mmcOneValue.Add("Drive uses a vendor unique interface"); mmcOneValue.Add("Drive uses a vendor unique interface");
break; break;
default: default:
mmcOneValue mmcOneValue.
.Add($"Drive uses an unknown interface with code {(uint) ftr.PhysicalInterfaceStandard}"); Add($"Drive uses an unknown interface with code {(uint)ftr.PhysicalInterfaceStandard}");
break; break;
} }
if (ftr.PreventJumper) mmcOneValue.Add("Drive power ups locked"); if(ftr.PreventJumper)
if (ftr.SupportsBusEncryption) mmcOneValue.Add("Drive supports bus encryption"); mmcOneValue.Add("Drive power ups locked");
if (ftr.CanWriteBD) mmcOneValue.Add("Drive can write BD-R or BD-RE");
if (ftr.CanWriteBDR) mmcOneValue.Add("Drive can write BD-R Ver.1"); if(ftr.SupportsBusEncryption)
if (ftr.CanWriteBDRE1) mmcOneValue.Add("Drive can write BD-RE Ver.1"); mmcOneValue.Add("Drive supports bus encryption");
if (ftr.CanWriteBDRE2) mmcOneValue.Add("Drive can write BD-RE Ver.2");
if (ftr.CanWriteBusEncryptedBlocks) mmcOneValue.Add("Drive supports writing with bus encryption"); if(ftr.CanWriteBD)
if (ftr.CanWriteCDRW) mmcOneValue.Add("Drive can write CD-RW"); mmcOneValue.Add("Drive can write BD-R or BD-RE");
if (ftr.CanWriteCDRWCAV) mmcOneValue.Add("Drive can write High-Speed CD-RW");
if (ftr.CanWriteCDSAO && !ftr.CanWriteRaw) if(ftr.CanWriteBDR)
mmcOneValue.Add("Drive can write BD-R Ver.1");
if(ftr.CanWriteBDRE1)
mmcOneValue.Add("Drive can write BD-RE Ver.1");
if(ftr.CanWriteBDRE2)
mmcOneValue.Add("Drive can write BD-RE Ver.2");
if(ftr.CanWriteBusEncryptedBlocks)
mmcOneValue.Add("Drive supports writing with bus encryption");
if(ftr.CanWriteCDRW)
mmcOneValue.Add("Drive can write CD-RW");
if(ftr.CanWriteCDRWCAV)
mmcOneValue.Add("Drive can write High-Speed CD-RW");
if(ftr.CanWriteCDSAO &&
!ftr.CanWriteRaw)
mmcOneValue.Add("Drive can write CDs in Session at Once Mode:"); mmcOneValue.Add("Drive can write CDs in Session at Once Mode:");
else if (!ftr.CanWriteCDSAO && ftr.CanWriteRaw) mmcOneValue.Add("Drive can write CDs in raw Mode:"); else if(!ftr.CanWriteCDSAO &&
else if (ftr.CanWriteCDSAO && ftr.CanWriteRaw) ftr.CanWriteRaw)
mmcOneValue.Add("Drive can write CDs in raw Mode:");
else if(ftr.CanWriteCDSAO &&
ftr.CanWriteRaw)
mmcOneValue.Add("Drive can write CDs in Session at Once and in Raw Modes:"); mmcOneValue.Add("Drive can write CDs in Session at Once and in Raw Modes:");
if (ftr.CanWriteCDTAO) mmcOneValue.Add("Drive can write CDs in Track at Once Mode:");
if (ftr.CanWriteCSSManagedDVD) mmcOneValue.Add("Drive can write CSS managed DVDs"); if(ftr.CanWriteCDTAO)
if (ftr.CanWriteDDCDR) mmcOneValue.Add("Drive supports writing DDCD-R"); mmcOneValue.Add("Drive can write CDs in Track at Once Mode:");
if (ftr.CanWriteDDCDRW) mmcOneValue.Add("Drive supports writing DDCD-RW");
if (ftr.CanWriteDVDPlusRWDL) mmcOneValue.Add("Drive can read and write DVD+RW DL"); if(ftr.CanWriteCSSManagedDVD)
else if (ftr.CanReadDVDPlusRWDL) mmcOneValue.Add("Drive can read DVD+RW DL"); mmcOneValue.Add("Drive can write CSS managed DVDs");
if (ftr.CanWriteDVDR && ftr.CanWriteDVDRW && ftr.CanWriteDVDRDL)
if(ftr.CanWriteDDCDR)
mmcOneValue.Add("Drive supports writing DDCD-R");
if(ftr.CanWriteDDCDRW)
mmcOneValue.Add("Drive supports writing DDCD-RW");
if(ftr.CanWriteDVDPlusRWDL)
mmcOneValue.Add("Drive can read and write DVD+RW DL");
else if(ftr.CanReadDVDPlusRWDL)
mmcOneValue.Add("Drive can read DVD+RW DL");
if(ftr.CanWriteDVDR &&
ftr.CanWriteDVDRW &&
ftr.CanWriteDVDRDL)
mmcOneValue.Add("Drive supports writing DVD-R, DVD-RW and DVD-R DL"); mmcOneValue.Add("Drive supports writing DVD-R, DVD-RW and DVD-R DL");
else if (ftr.CanWriteDVDR && ftr.CanWriteDVDRDL) else if(ftr.CanWriteDVDR &&
ftr.CanWriteDVDRDL)
mmcOneValue.Add("Drive supports writing DVD-R and DVD-R DL"); mmcOneValue.Add("Drive supports writing DVD-R and DVD-R DL");
else if (ftr.CanWriteDVDR && ftr.CanWriteDVDRW) mmcOneValue.Add("Drive supports writing DVD-R and DVD-RW"); else if(ftr.CanWriteDVDR &&
else if (ftr.CanWriteDVDR) mmcOneValue.Add("Drive supports writing DVD-R"); ftr.CanWriteDVDRW)
if (ftr.CanWriteHDDVDR && ftr.CanWriteHDDVDRAM) mmcOneValue.Add("Drive supports writing DVD-R and DVD-RW");
else if(ftr.CanWriteDVDR)
mmcOneValue.Add("Drive supports writing DVD-R");
if(ftr.CanWriteHDDVDR &&
ftr.CanWriteHDDVDRAM)
mmcOneValue.Add("Drive can write HD DVD-RW, HD DVD-R and HD DVD-RAM"); mmcOneValue.Add("Drive can write HD DVD-RW, HD DVD-R and HD DVD-RAM");
else if (ftr.CanWriteHDDVDR) mmcOneValue.Add("Drive can write HD DVD-RW and HD DVD-R"); else if(ftr.CanWriteHDDVDR)
else if (ftr.CanWriteHDDVDRAM) mmcOneValue.Add("Drive can write HD DVD-RW and HD DVD-RAM"); mmcOneValue.Add("Drive can write HD DVD-RW and HD DVD-R");
else if(ftr.CanWriteHDDVDRAM)
mmcOneValue.Add("Drive can write HD DVD-RW and HD DVD-RAM");
// TODO: Write HD DVD-RW // TODO: Write HD DVD-RW
/* /*
else else
mmcOneValue.Add("Drive can write HD DVD-RW"); mmcOneValue.Add("Drive can write HD DVD-RW");
*/ */
if (ftr.CanWriteOldBDR) mmcOneValue.Add("Drive can write BD-R pre-1.0"); if(ftr.CanWriteOldBDR)
if (ftr.CanWriteOldBDRE) mmcOneValue.Add("Drive can write BD-RE pre-1.0"); mmcOneValue.Add("Drive can write BD-R pre-1.0");
if (ftr.CanWriteRWSubchannelInTAO)
if(ftr.CanWriteOldBDRE)
mmcOneValue.Add("Drive can write BD-RE pre-1.0");
if(ftr.CanWriteRWSubchannelInTAO)
{ {
mmcOneValue.Add("Drive can write user provided data in the R-W subchannels in Track at Once Mode"); mmcOneValue.Add("Drive can write user provided data in the R-W subchannels in Track at Once Mode");
if (ftr.CanWriteRawSubchannelInTAO)
if(ftr.CanWriteRawSubchannelInTAO)
mmcOneValue.Add("Drive accepts RAW R-W subchannel data in Track at Once Mode"); mmcOneValue.Add("Drive accepts RAW R-W subchannel data in Track at Once Mode");
if (ftr.CanWritePackedSubchannelInTAO)
if(ftr.CanWritePackedSubchannelInTAO)
mmcOneValue.Add("Drive accepts Packed R-W subchannel data in Track at Once Mode"); mmcOneValue.Add("Drive accepts Packed R-W subchannel data in Track at Once Mode");
} }
if (ftr.CanWriteRWSubchannelInSAO) if(ftr.CanWriteRWSubchannelInSAO)
mmcOneValue.Add("Drive can write user provided data in the R-W subchannels in Session at Once Mode"); mmcOneValue.Add("Drive can write user provided data in the R-W subchannels in Session at Once Mode");
if (ftr.CanWriteRaw && ftr.CanWriteRawMultiSession)
if(ftr.CanWriteRaw &&
ftr.CanWriteRawMultiSession)
mmcOneValue.Add("Drive can write multi-session CDs in raw mode"); mmcOneValue.Add("Drive can write multi-session CDs in raw mode");
if (ftr.EmbeddedChanger)
if(ftr.EmbeddedChanger)
{ {
mmcOneValue.Add("Drive contains an embedded changer"); mmcOneValue.Add("Drive contains an embedded changer");
if (ftr.ChangerIsSideChangeCapable) mmcOneValue.Add("Drive can change disc side"); if(ftr.ChangerIsSideChangeCapable)
if (ftr.ChangerSupportsDiscPresent) mmcOneValue.Add("Drive can change disc side");
if(ftr.ChangerSupportsDiscPresent)
mmcOneValue.Add("Drive is able to report slots contents after a reset or change"); mmcOneValue.Add("Drive is able to report slots contents after a reset or change");
mmcOneValue.Add($"Drive has {ftr.ChangerSlots + 1} slots"); mmcOneValue.Add($"Drive has {ftr.ChangerSlots + 1} slots");
} }
if (ftr.SupportsCSS && ftr.CSSVersion.HasValue) if(ftr.SupportsCSS &&
ftr.CSSVersion.HasValue)
mmcOneValue.Add($"Drive supports DVD CSS/CPPM version {ftr.CSSVersion}"); mmcOneValue.Add($"Drive supports DVD CSS/CPPM version {ftr.CSSVersion}");
else if (ftr.SupportsCSS) mmcOneValue.Add("Drive supports DVD CSS/CPRM"); else if(ftr.SupportsCSS)
if (ftr.SupportsCPRM && ftr.CPRMVersion.HasValue) mmcOneValue.Add("Drive supports DVD CSS/CPRM");
mmcOneValue.Add($"Drive supports DVD CPPM version {ftr.CPRMVersion}");
else if (ftr.SupportsCPRM) mmcOneValue.Add("Drive supports DVD CPRM");
if (ftr.DBML) mmcOneValue.Add("Drive reports Device Busy Class events during medium loading/unloading");
if (ftr.DVDMultiRead) mmcOneValue.Add("Drive conforms to DVD Multi Drive Read-only Specifications");
if (ftr.FirmwareDate.HasValue) mmcOneValue.Add($"Drive firmware is dated {ftr.FirmwareDate}");
if (ftr.SupportsC2) mmcOneValue.Add("Drive supports C2 Error Pointers");
if (ftr.SupportsDAP) mmcOneValue.Add("Drive supports the DAP bit in the READ CD and READ CD MSF commands");
if (ftr.SupportsDeviceBusyEvent) mmcOneValue.Add("Drive supports Device Busy events");
if (ftr.LoadingMechanismType.HasValue) if(ftr.SupportsCPRM &&
switch (ftr.LoadingMechanismType) ftr.CPRMVersion.HasValue)
mmcOneValue.Add($"Drive supports DVD CPPM version {ftr.CPRMVersion}");
else if(ftr.SupportsCPRM)
mmcOneValue.Add("Drive supports DVD CPRM");
if(ftr.DBML)
mmcOneValue.Add("Drive reports Device Busy Class events during medium loading/unloading");
if(ftr.DVDMultiRead)
mmcOneValue.Add("Drive conforms to DVD Multi Drive Read-only Specifications");
if(ftr.FirmwareDate.HasValue)
mmcOneValue.Add($"Drive firmware is dated {ftr.FirmwareDate}");
if(ftr.SupportsC2)
mmcOneValue.Add("Drive supports C2 Error Pointers");
if(ftr.SupportsDAP)
mmcOneValue.Add("Drive supports the DAP bit in the READ CD and READ CD MSF commands");
if(ftr.SupportsDeviceBusyEvent)
mmcOneValue.Add("Drive supports Device Busy events");
if(ftr.LoadingMechanismType.HasValue)
switch(ftr.LoadingMechanismType)
{ {
case 0: case 0:
mmcOneValue.Add("Drive uses media caddy"); mmcOneValue.Add("Drive uses media caddy");
break; break;
case 1: case 1:
mmcOneValue.Add("Drive uses a tray"); mmcOneValue.Add("Drive uses a tray");
break; break;
case 2: case 2:
mmcOneValue.Add("Drive is pop-up"); mmcOneValue.Add("Drive is pop-up");
break; break;
case 4: case 4:
mmcOneValue.Add("Drive is a changer with individually changeable discs"); mmcOneValue.Add("Drive is a changer with individually changeable discs");
break; break;
case 5: case 5:
mmcOneValue.Add("Drive is a changer using cartridges"); mmcOneValue.Add("Drive is a changer using cartridges");
break; break;
default: default:
mmcOneValue.Add($"Drive uses unknown loading mechanism type {ftr.LoadingMechanismType}"); mmcOneValue.Add($"Drive uses unknown loading mechanism type {ftr.LoadingMechanismType}");
break; break;
} }
if (ftr.SupportsHybridDiscs) mmcOneValue.Add("Drive is able to access Hybrid discs"); if(ftr.SupportsHybridDiscs)
if (ftr.SupportsModePage1Ch) mmcOneValue.Add("Drive is able to access Hybrid discs");
if(ftr.SupportsModePage1Ch)
mmcOneValue.Add("Drive supports the Informational Exceptions Control mode page 1Ch"); mmcOneValue.Add("Drive supports the Informational Exceptions Control mode page 1Ch");
if (ftr.SupportsOSSC)
if(ftr.SupportsOSSC)
mmcOneValue.Add("Drive supports the Trusted Computing Group Optical Security Subsystem Class"); mmcOneValue.Add("Drive supports the Trusted Computing Group Optical Security Subsystem Class");
if (ftr.SupportsPWP) mmcOneValue.Add("Drive supports set/release of PWP status");
if (ftr.SupportsSWPP) mmcOneValue.Add("Drive supports the SWPP bit of the Timeout and Protect mode page"); if(ftr.SupportsPWP)
if (ftr.SupportsSecurDisc) mmcOneValue.Add("Drive supports SecurDisc"); mmcOneValue.Add("Drive supports set/release of PWP status");
if (ftr.SupportsSeparateVolume) mmcOneValue.Add("Drive supports separate volume per channel");
if (ftr.SupportsVCPS) mmcOneValue.Add("Drive supports VCPS"); if(ftr.SupportsSWPP)
if (ftr.VolumeLevels.HasValue) mmcOneValue.Add($"Drive has {ftr.VolumeLevels + 1} volume levels"); mmcOneValue.Add("Drive supports the SWPP bit of the Timeout and Protect mode page");
if (ftr.SupportsWriteProtectPAC)
if(ftr.SupportsSecurDisc)
mmcOneValue.Add("Drive supports SecurDisc");
if(ftr.SupportsSeparateVolume)
mmcOneValue.Add("Drive supports separate volume per channel");
if(ftr.SupportsVCPS)
mmcOneValue.Add("Drive supports VCPS");
if(ftr.VolumeLevels.HasValue)
mmcOneValue.Add($"Drive has {ftr.VolumeLevels + 1} volume levels");
if(ftr.SupportsWriteProtectPAC)
mmcOneValue.Add("Drive supports reading/writing the Disc Write Protect PAC on BD-R/-RE media"); mmcOneValue.Add("Drive supports reading/writing the Disc Write Protect PAC on BD-R/-RE media");
if (ftr.SupportsWriteInhibitDCB)
if(ftr.SupportsWriteInhibitDCB)
mmcOneValue.Add("Drive supports writing the Write Inhibit DCB on DVD+RW media"); mmcOneValue.Add("Drive supports writing the Write Inhibit DCB on DVD+RW media");
mmcOneValue.Sort(); mmcOneValue.Sort();

View File

@@ -39,135 +39,188 @@ namespace DiscImageChef.Server
public static class ScsiMmcMode public static class ScsiMmcMode
{ {
/// <summary> /// <summary>
/// Takes the MODE PAGE 2Ah part of a device report and prints it as a list of values to be sequenced by ASP.NET in the /// Takes the MODE PAGE 2Ah part of a device report and prints it as a list of values to be sequenced by ASP.NET
/// rendering /// in the rendering
/// </summary> /// </summary>
/// <param name="mode">MODE PAGE 2Ah part of the report</param> /// <param name="mode">MODE PAGE 2Ah part of the report</param>
/// <param name="mmcOneValue">List to put the values on</param> /// <param name="mmcOneValue">List to put the values on</param>
public static void Report(Modes.ModePage_2A mode, ref List<string> mmcOneValue) public static void Report(Modes.ModePage_2A mode, ref List<string> mmcOneValue)
{ {
if (mode.AudioPlay) mmcOneValue.Add("Drive can play audio"); if(mode.AudioPlay)
if (mode.Mode2Form1) mmcOneValue.Add("Drive can read sectors in Mode 2 Form 1 format"); mmcOneValue.Add("Drive can play audio");
if (mode.Mode2Form2) mmcOneValue.Add("Drive can read sectors in Mode 2 Form 2 format");
if (mode.MultiSession) mmcOneValue.Add("Drive supports multi-session discs and/or Photo-CD");
if (mode.CDDACommand) mmcOneValue.Add("Drive can read digital audio"); if(mode.Mode2Form1)
if (mode.AccurateCDDA) mmcOneValue.Add("Drive can continue from streaming loss"); mmcOneValue.Add("Drive can read sectors in Mode 2 Form 1 format");
if (mode.Subchannel) mmcOneValue.Add("Drive can read uncorrected and interleaved R-W subchannels");
if (mode.DeinterlaveSubchannel) mmcOneValue.Add("Drive can read, deinterleave and correct R-W subchannels");
if (mode.C2Pointer) mmcOneValue.Add("Drive supports C2 pointers");
if (mode.UPC) mmcOneValue.Add("Drive can read Media Catalogue Number");
if (mode.ISRC) mmcOneValue.Add("Drive can read ISRC");
switch (mode.LoadingMechanism) if(mode.Mode2Form2)
mmcOneValue.Add("Drive can read sectors in Mode 2 Form 2 format");
if(mode.MultiSession)
mmcOneValue.Add("Drive supports multi-session discs and/or Photo-CD");
if(mode.CDDACommand)
mmcOneValue.Add("Drive can read digital audio");
if(mode.AccurateCDDA)
mmcOneValue.Add("Drive can continue from streaming loss");
if(mode.Subchannel)
mmcOneValue.Add("Drive can read uncorrected and interleaved R-W subchannels");
if(mode.DeinterlaveSubchannel)
mmcOneValue.Add("Drive can read, deinterleave and correct R-W subchannels");
if(mode.C2Pointer)
mmcOneValue.Add("Drive supports C2 pointers");
if(mode.UPC)
mmcOneValue.Add("Drive can read Media Catalogue Number");
if(mode.ISRC)
mmcOneValue.Add("Drive can read ISRC");
switch(mode.LoadingMechanism)
{ {
case 0: case 0:
mmcOneValue.Add("Drive uses media caddy"); mmcOneValue.Add("Drive uses media caddy");
break; break;
case 1: case 1:
mmcOneValue.Add("Drive uses a tray"); mmcOneValue.Add("Drive uses a tray");
break; break;
case 2: case 2:
mmcOneValue.Add("Drive is pop-up"); mmcOneValue.Add("Drive is pop-up");
break; break;
case 4: case 4:
mmcOneValue.Add("Drive is a changer with individually changeable discs"); mmcOneValue.Add("Drive is a changer with individually changeable discs");
break; break;
case 5: case 5:
mmcOneValue.Add("Drive is a changer using cartridges"); mmcOneValue.Add("Drive is a changer using cartridges");
break; break;
default: default:
mmcOneValue.Add($"Drive uses unknown loading mechanism type {mode.LoadingMechanism}"); mmcOneValue.Add($"Drive uses unknown loading mechanism type {mode.LoadingMechanism}");
break; break;
} }
if (mode.Lock) mmcOneValue.Add("Drive can lock media"); if(mode.Lock)
if (mode.PreventJumper) mmcOneValue.Add("Drive can lock media");
if(mode.PreventJumper)
{ {
mmcOneValue.Add("Drive power ups locked"); mmcOneValue.Add("Drive power ups locked");
mmcOneValue.Add(mode.LockState
? "Drive is locked, media cannot be ejected or inserted" mmcOneValue.Add(mode.LockState ? "Drive is locked, media cannot be ejected or inserted"
: "Drive is not locked, media can be ejected and inserted"); : "Drive is not locked, media can be ejected and inserted");
} }
else else
{ {
mmcOneValue.Add(mode.LockState mmcOneValue.Add(mode.LockState
? "Drive is locked, media cannot be ejected, but if empty, can be inserted" ? "Drive is locked, media cannot be ejected, but if empty, can be inserted"
: "Drive is not locked, media can be ejected and inserted"); : "Drive is not locked, media can be ejected and inserted");
} }
if (mode.Eject) mmcOneValue.Add("Drive can eject media"); if(mode.Eject)
mmcOneValue.Add("Drive can eject media");
if (mode.SeparateChannelMute) mmcOneValue.Add("Each channel can be muted independently"); if(mode.SeparateChannelMute)
if (mode.SeparateChannelVolume) mmcOneValue.Add("Each channel's volume can be controlled independently"); mmcOneValue.Add("Each channel can be muted independently");
if (mode.SupportedVolumeLevels > 0) if(mode.SeparateChannelVolume)
mmcOneValue.Add("Each channel's volume can be controlled independently");
if(mode.SupportedVolumeLevels > 0)
mmcOneValue.Add($"Drive supports {mode.SupportedVolumeLevels} volume levels"); mmcOneValue.Add($"Drive supports {mode.SupportedVolumeLevels} volume levels");
if (mode.BufferSize > 0) mmcOneValue.Add($"Drive has {mode.BufferSize} Kbyte of buffer");
if (mode.MaximumSpeed > 0) if(mode.BufferSize > 0)
mmcOneValue.Add($"Drive has {mode.BufferSize} Kbyte of buffer");
if(mode.MaximumSpeed > 0)
mmcOneValue.Add($"Drive's maximum reading speed is {mode.MaximumSpeed} Kbyte/sec."); mmcOneValue.Add($"Drive's maximum reading speed is {mode.MaximumSpeed} Kbyte/sec.");
if (mode.CurrentSpeed > 0)
if(mode.CurrentSpeed > 0)
mmcOneValue.Add($"Drive's current reading speed is {mode.CurrentSpeed} Kbyte/sec."); mmcOneValue.Add($"Drive's current reading speed is {mode.CurrentSpeed} Kbyte/sec.");
if (mode.ReadCDR) if(mode.ReadCDR)
{ {
mmcOneValue.Add(mode.WriteCDR ? "Drive can read and write CD-R" : "Drive can read CD-R"); mmcOneValue.Add(mode.WriteCDR ? "Drive can read and write CD-R" : "Drive can read CD-R");
if (mode.Method2) mmcOneValue.Add("Drive supports reading CD-R packet media"); if(mode.Method2)
mmcOneValue.Add("Drive supports reading CD-R packet media");
} }
if (mode.ReadCDRW) if(mode.ReadCDRW)
mmcOneValue.Add(mode.WriteCDRW ? "Drive can read and write CD-RW" : "Drive can read CD-RW"); mmcOneValue.Add(mode.WriteCDRW ? "Drive can read and write CD-RW" : "Drive can read CD-RW");
if (mode.ReadDVDROM) mmcOneValue.Add("Drive can read DVD-ROM"); if(mode.ReadDVDROM)
if (mode.ReadDVDR) mmcOneValue.Add("Drive can read DVD-ROM");
if(mode.ReadDVDR)
mmcOneValue.Add(mode.WriteDVDR ? "Drive can read and write DVD-R" : "Drive can read DVD-R"); mmcOneValue.Add(mode.WriteDVDR ? "Drive can read and write DVD-R" : "Drive can read DVD-R");
if (mode.ReadDVDRAM)
if(mode.ReadDVDRAM)
mmcOneValue.Add(mode.WriteDVDRAM ? "Drive can read and write DVD-RAM" : "Drive can read DVD-RAM"); mmcOneValue.Add(mode.WriteDVDRAM ? "Drive can read and write DVD-RAM" : "Drive can read DVD-RAM");
if (mode.Composite) mmcOneValue.Add("Drive can deliver a composite audio and video data stream"); if(mode.Composite)
if (mode.DigitalPort1) mmcOneValue.Add("Drive supports IEC-958 digital output on port 1"); mmcOneValue.Add("Drive can deliver a composite audio and video data stream");
if (mode.DigitalPort2) mmcOneValue.Add("Drive supports IEC-958 digital output on port 2");
if (mode.SDP) mmcOneValue.Add("Drive contains a changer that can report the exact contents of the slots"); if(mode.DigitalPort1)
if (mode.CurrentWriteSpeedSelected > 0) mmcOneValue.Add("Drive supports IEC-958 digital output on port 1");
if(mode.DigitalPort2)
mmcOneValue.Add("Drive supports IEC-958 digital output on port 2");
if(mode.SDP)
mmcOneValue.Add("Drive contains a changer that can report the exact contents of the slots");
if(mode.CurrentWriteSpeedSelected > 0)
{ {
if (mode.RotationControlSelected == 0) if(mode.RotationControlSelected == 0)
mmcOneValue mmcOneValue.
.Add( Add($"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in CLV mode");
$"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in CLV mode"); else if(mode.RotationControlSelected == 1)
else if (mode.RotationControlSelected == 1) mmcOneValue.
mmcOneValue Add($"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in pure CAV mode");
.Add(
$"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in pure CAV mode");
} }
else else
{ {
if (mode.MaxWriteSpeed > 0) if(mode.MaxWriteSpeed > 0)
mmcOneValue.Add($"Drive's maximum writing speed is {mode.MaxWriteSpeed} Kbyte/sec."); mmcOneValue.Add($"Drive's maximum writing speed is {mode.MaxWriteSpeed} Kbyte/sec.");
if (mode.CurrentWriteSpeed > 0)
if(mode.CurrentWriteSpeed > 0)
mmcOneValue.Add($"Drive's current writing speed is {mode.CurrentWriteSpeed} Kbyte/sec."); mmcOneValue.Add($"Drive's current writing speed is {mode.CurrentWriteSpeed} Kbyte/sec.");
} }
if (mode.WriteSpeedPerformanceDescriptors != null) if(mode.WriteSpeedPerformanceDescriptors != null)
foreach (var descriptor in foreach(Modes.ModePage_2A_WriteDescriptor descriptor in
mode.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0)) mode.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0))
if (descriptor.RotationControl == 0) if(descriptor.RotationControl == 0)
mmcOneValue.Add($"Drive supports writing at {descriptor.WriteSpeed} Kbyte/sec. in CLV mode"); mmcOneValue.Add($"Drive supports writing at {descriptor.WriteSpeed} Kbyte/sec. in CLV mode");
else if (descriptor.RotationControl == 1) else if(descriptor.RotationControl == 1)
mmcOneValue mmcOneValue.
.Add($"Drive supports writing at is {descriptor.WriteSpeed} Kbyte/sec. in pure CAV mode"); Add($"Drive supports writing at is {descriptor.WriteSpeed} Kbyte/sec. in pure CAV mode");
if (mode.TestWrite) mmcOneValue.Add("Drive supports test writing"); if(mode.TestWrite)
mmcOneValue.Add("Drive supports test writing");
if (mode.ReadBarcode) mmcOneValue.Add("Drive can read barcode"); if(mode.ReadBarcode)
mmcOneValue.Add("Drive can read barcode");
if (mode.SCC) mmcOneValue.Add("Drive can read both sides of a disc"); if(mode.SCC)
if (mode.LeadInPW) mmcOneValue.Add("Drive an read raw R-W subchannel from the Lead-In"); mmcOneValue.Add("Drive can read both sides of a disc");
if (mode.CMRSupported == 1) mmcOneValue.Add("Drive supports DVD CSS and/or DVD CPPM"); if(mode.LeadInPW)
mmcOneValue.Add("Drive an read raw R-W subchannel from the Lead-In");
if (mode.BUF) mmcOneValue.Add("Drive supports buffer under-run free recording"); if(mode.CMRSupported == 1)
mmcOneValue.Add("Drive supports DVD CSS and/or DVD CPPM");
if(mode.BUF)
mmcOneValue.Add("Drive supports buffer under-run free recording");
mmcOneValue.Sort(); mmcOneValue.Sort();
mmcOneValue.Add(""); mmcOneValue.Add("");

View File

@@ -39,195 +39,221 @@ namespace DiscImageChef.Server
public static class ScsiModeSense public static class ScsiModeSense
{ {
/// <summary> /// <summary>
/// Takes the MODE PAGEs part of a device report and prints it as a list of values and another list of key=value pairs /// Takes the MODE PAGEs part of a device report and prints it as a list of values and another list of key=value
/// to be sequenced by ASP.NET in the rendering /// pairs to be sequenced by ASP.NET in the rendering
/// </summary> /// </summary>
/// <param name="modeSense">MODE PAGEs part of a device report</param> /// <param name="modeSense">MODE PAGEs part of a device report</param>
/// <param name="vendor">SCSI vendor string</param> /// <param name="vendor">SCSI vendor string</param>
/// <param name="deviceType">SCSI peripheral device type</param> /// <param name="deviceType">SCSI peripheral device type</param>
/// <param name="scsiOneValue">List to put values on</param> /// <param name="scsiOneValue">List to put values on</param>
/// <param name="modePages">List to put key=value pairs on</param> /// <param name="modePages">List to put key=value pairs on</param>
public static void Report(ScsiMode modeSense, string vendor, public static void Report(ScsiMode modeSense, string vendor, PeripheralDeviceTypes deviceType,
PeripheralDeviceTypes deviceType, ref List<string> scsiOneValue, ref Dictionary<string, string> modePages)
ref List<string> scsiOneValue, ref Dictionary<string, string> modePages)
{ {
if (modeSense.MediumType.HasValue) scsiOneValue.Add($"Medium type is {modeSense.MediumType:X2}h"); if(modeSense.MediumType.HasValue)
if (modeSense.WriteProtected) scsiOneValue.Add("Device is write protected."); scsiOneValue.Add($"Medium type is {modeSense.MediumType:X2}h");
if (modeSense.BlockDescriptors != null)
foreach (var descriptor in modeSense.BlockDescriptors) if(modeSense.WriteProtected)
if (descriptor.Blocks.HasValue && descriptor.BlockLength.HasValue) scsiOneValue.Add("Device is write protected.");
scsiOneValue
.Add( if(modeSense.BlockDescriptors != null)
$"Density code {descriptor.Density:X2}h has {descriptor.Blocks} blocks of {descriptor.BlockLength} bytes each"); foreach(BlockDescriptor descriptor in modeSense.BlockDescriptors)
if(descriptor.Blocks.HasValue &&
descriptor.BlockLength.HasValue)
scsiOneValue.
Add($"Density code {descriptor.Density:X2}h has {descriptor.Blocks} blocks of {descriptor.BlockLength} bytes each");
else else
scsiOneValue.Add($"Density code {descriptor.Density:X2}h"); scsiOneValue.Add($"Density code {descriptor.Density:X2}h");
if (modeSense.DPOandFUA) scsiOneValue.Add("Drive supports DPO and FUA bits"); if(modeSense.DPOandFUA)
if (modeSense.BlankCheckEnabled) scsiOneValue.Add("Blank checking during write is enabled"); scsiOneValue.Add("Drive supports DPO and FUA bits");
if (modeSense.BufferedMode.HasValue)
switch (modeSense.BufferedMode) if(modeSense.BlankCheckEnabled)
scsiOneValue.Add("Blank checking during write is enabled");
if(modeSense.BufferedMode.HasValue)
switch(modeSense.BufferedMode)
{ {
case 0: case 0:
scsiOneValue.Add("Device writes directly to media"); scsiOneValue.Add("Device writes directly to media");
break; break;
case 1: case 1:
scsiOneValue.Add("Device uses a write cache"); scsiOneValue.Add("Device uses a write cache");
break; break;
case 2: case 2:
scsiOneValue.Add("Device uses a write cache but doesn't return until cache is flushed"); scsiOneValue.Add("Device uses a write cache but doesn't return until cache is flushed");
break; break;
default: default:
scsiOneValue.Add($"Unknown buffered mode code 0x{modeSense.BufferedMode:X2}"); scsiOneValue.Add($"Unknown buffered mode code 0x{modeSense.BufferedMode:X2}");
break; break;
} }
if (modeSense.ModePages == null) return; if(modeSense.ModePages == null)
return;
foreach (var page in modeSense.ModePages) foreach(ScsiPage page in modeSense.ModePages)
switch (page.page) switch(page.page)
{ {
case 0x00: case 0x00:
{ {
if (deviceType == PeripheralDeviceTypes.MultiMediaDevice && page.subpage == 0) if(deviceType == PeripheralDeviceTypes.MultiMediaDevice &&
page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value));
else else
modePages modePages.
.Add( Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h",
page.subpage != 0
? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h"
: $"MODE page {page.page:X2}h",
"Unknown vendor mode page"); "Unknown vendor mode page");
break; break;
} }
case 0x01: case 0x01:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", modePages.Add($"MODE page {page.page:X2}h",
deviceType == PeripheralDeviceTypes.MultiMediaDevice deviceType == PeripheralDeviceTypes.MultiMediaDevice
? Modes.PrettifyModePage_01_MMC(page.value) ? Modes.PrettifyModePage_01_MMC(page.value)
: Modes.PrettifyModePage_01(page.value)); : Modes.PrettifyModePage_01(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x02: case 0x02:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_02(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_02(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x03: case 0x03:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_03(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_03(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x04: case 0x04:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_04(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_04(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x05: case 0x05:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_05(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_05(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x06: case 0x06:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_06(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_06(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x07: case 0x07:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", modePages.Add($"MODE page {page.page:X2}h",
deviceType == PeripheralDeviceTypes.MultiMediaDevice deviceType == PeripheralDeviceTypes.MultiMediaDevice
? Modes.PrettifyModePage_07_MMC(page.value) ? Modes.PrettifyModePage_07_MMC(page.value)
: Modes.PrettifyModePage_07(page.value)); : Modes.PrettifyModePage_07(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x08: case 0x08:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_08(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_08(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x0A: case 0x0A:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0A(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0A(page.value));
else if (page.subpage == 1) else if(page.subpage == 1)
modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h", modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h",
Modes.PrettifyModePage_0A_S01(page.value)); Modes.PrettifyModePage_0A_S01(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x0B: case 0x0B:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0B(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0B(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x0D: case 0x0D:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0D(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0D(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x0E: case 0x0E:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0E(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0E(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x0F: case 0x0F:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0F(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0F(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x10: case 0x10:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", modePages.Add($"MODE page {page.page:X2}h",
deviceType == PeripheralDeviceTypes.SequentialAccess deviceType == PeripheralDeviceTypes.SequentialAccess
? Modes.PrettifyModePage_10_SSC(page.value) ? Modes.PrettifyModePage_10_SSC(page.value)
: Modes.PrettifyModePage_10(page.value)); : Modes.PrettifyModePage_10(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x11: case 0x11:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_11(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_11(page.value));
else goto default; else
goto default;
break; break;
} }
@@ -235,152 +261,167 @@ namespace DiscImageChef.Server
case 0x13: case 0x13:
case 0x14: case 0x14:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_12_13_14(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_12_13_14(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x1A: case 0x1A:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1A(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1A(page.value));
else if (page.subpage == 1) else if(page.subpage == 1)
modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h", modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h",
Modes.PrettifyModePage_1A_S01(page.value)); Modes.PrettifyModePage_1A_S01(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x1B: case 0x1B:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1B(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1B(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x1C: case 0x1C:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", modePages.Add($"MODE page {page.page:X2}h",
deviceType == PeripheralDeviceTypes.MultiMediaDevice deviceType == PeripheralDeviceTypes.MultiMediaDevice
? Modes.PrettifyModePage_1C_SFF(page.value) ? Modes.PrettifyModePage_1C_SFF(page.value)
: Modes.PrettifyModePage_1C(page.value)); : Modes.PrettifyModePage_1C(page.value));
else if (page.subpage == 1) else if(page.subpage == 1)
modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h", modePages.Add($"MODE page {page.page:X2}h subpage {page.subpage:X2}h",
Modes.PrettifyModePage_1C_S01(page.value)); Modes.PrettifyModePage_1C_S01(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x1D: case 0x1D:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1D(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1D(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x21: case 0x21:
{ {
if (vendor == "CERTANCE") if(vendor == "CERTANCE")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_21(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_21(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x22: case 0x22:
{ {
if (vendor == "CERTANCE") if(vendor == "CERTANCE")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_22(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_22(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x24: case 0x24:
{ {
if (vendor == "IBM") if(vendor == "IBM")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_24(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_24(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x2A: case 0x2A:
{ {
if (page.subpage == 0) if(page.subpage == 0)
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_2A(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_2A(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x2F: case 0x2F:
{ {
if (vendor == "IBM") if(vendor == "IBM")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_2F(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_2F(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x30: case 0x30:
{ {
if (Modes.IsAppleModePage_30(page.value)) if(Modes.IsAppleModePage_30(page.value))
modePages.Add("MODE page 30h", "Drive identifies as an Apple OEM drive"); modePages.Add("MODE page 30h", "Drive identifies as an Apple OEM drive");
else goto default; else
goto default;
break; break;
} }
case 0x3B: case 0x3B:
{ {
if (vendor == "HP") if(vendor == "HP")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3B(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3B(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x3C: case 0x3C:
{ {
if (vendor == "HP") if(vendor == "HP")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3C(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3C(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x3D: case 0x3D:
{ {
if (vendor == "IBM") if(vendor == "IBM")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_3D(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_3D(page.value));
else if (vendor == "HP") else if(vendor == "HP")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3D(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3D(page.value));
else goto default; else
goto default;
break; break;
} }
case 0x3E: case 0x3E:
{ {
if (vendor == "FUJITSU") if(vendor == "FUJITSU")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyFujitsuModePage_3E(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyFujitsuModePage_3E(page.value));
else if (vendor == "HP") else if(vendor == "HP")
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3E(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3E(page.value));
else goto default; else
goto default;
break; break;
} }
default: default:
{ {
modePages.Add( modePages.
page.subpage != 0 Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h",
? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" "Unknown mode page");
: $"MODE page {page.page:X2}h",
"Unknown mode page");
} }
break; break;
} }
var newModePages = new Dictionary<string, string>(); Dictionary<string, string> newModePages = new Dictionary<string, string>();
foreach (var kvp in modePages)
foreach(KeyValuePair<string, string> kvp in modePages)
newModePages.Add(kvp.Key, newModePages.Add(kvp.Key,
string.IsNullOrWhiteSpace(kvp.Value) ? "Undecoded" : kvp.Value.Replace("\n", "<br/>")); string.IsNullOrWhiteSpace(kvp.Value) ? "Undecoded" : kvp.Value.Replace("\n", "<br/>"));
modePages = newModePages; modePages = newModePages;
} }

View File

@@ -37,21 +37,21 @@ namespace DiscImageChef.Server
{ {
public static class SscTestedMedia public static class SscTestedMedia
{ {
/// <summary> /// <summary>Takes the tested media from SCSI Streaming devices of a device report and prints it as a list of values</summary>
/// Takes the tested media from SCSI Streaming devices of a device report and prints it as a list of values
/// </summary>
/// <param name="mediaOneValue">List to put values on</param> /// <param name="mediaOneValue">List to put values on</param>
/// <param name="testedMedia">List of tested media</param> /// <param name="testedMedia">List of tested media</param>
public static void Report(IEnumerable<TestedSequentialMedia> testedMedia, ref List<string> mediaOneValue) public static void Report(IEnumerable<TestedSequentialMedia> testedMedia, ref List<string> mediaOneValue)
{ {
foreach (var media in testedMedia) foreach(TestedSequentialMedia media in testedMedia)
{ {
if (!string.IsNullOrWhiteSpace(media.MediumTypeName)) if(!string.IsNullOrWhiteSpace(media.MediumTypeName))
{ {
mediaOneValue.Add($"<i>Information for medium named \"{media.MediumTypeName}\"</i>"); mediaOneValue.Add($"<i>Information for medium named \"{media.MediumTypeName}\"</i>");
if (media.MediumType.HasValue) mediaOneValue.Add($"Medium type code: {media.MediumType:X2}h");
if(media.MediumType.HasValue)
mediaOneValue.Add($"Medium type code: {media.MediumType:X2}h");
} }
else if (media.MediumType.HasValue) else if(media.MediumType.HasValue)
{ {
mediaOneValue.Add($"<i>Information for medium type {media.MediumType:X2}h</i>"); mediaOneValue.Add($"<i>Information for medium type {media.MediumType:X2}h</i>");
} }
@@ -60,13 +60,20 @@ namespace DiscImageChef.Server
mediaOneValue.Add("<i>Information for unknown medium type</i>"); mediaOneValue.Add("<i>Information for unknown medium type</i>");
} }
if (!string.IsNullOrWhiteSpace(media.Manufacturer)) if(!string.IsNullOrWhiteSpace(media.Manufacturer))
mediaOneValue.Add($"Medium manufactured by: {media.Manufacturer}"); mediaOneValue.Add($"Medium manufactured by: {media.Manufacturer}");
if (!string.IsNullOrWhiteSpace(media.Model)) mediaOneValue.Add($"Medium model: {media.Model}");
if (media.Density.HasValue) mediaOneValue.Add($"Medium has density code {media.Density:X2}h"); if(!string.IsNullOrWhiteSpace(media.Model))
if (media.CanReadMediaSerial == true) mediaOneValue.Add("Drive can read medium serial number."); mediaOneValue.Add($"Medium model: {media.Model}");
if (media.MediaIsRecognized) mediaOneValue.Add("Drive recognizes this medium.");
if(media.Density.HasValue)
mediaOneValue.Add($"Medium has density code {media.Density:X2}h");
if(media.CanReadMediaSerial == true)
mediaOneValue.Add("Drive can read medium serial number.");
if(media.MediaIsRecognized)
mediaOneValue.Add("Drive recognizes this medium.");
mediaOneValue.Add(""); mediaOneValue.Add("");
} }

View File

@@ -43,323 +43,447 @@ namespace DiscImageChef.Server
{ {
var ctx = new DicServerContext(); var ctx = new DicServerContext();
if (newStats.Commands != null) if(newStats.Commands != null)
{ {
if (newStats.Commands.Analyze > 0) if(newStats.Commands.Analyze > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Analyze, Name = "analyze"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Analyze; {
Count = newStats.Commands.Analyze, Name = "analyze"
});
else
existing.Count += newStats.Commands.Analyze;
} }
if (newStats.Commands.Benchmark > 0) if(newStats.Commands.Benchmark > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Benchmark, Name = "benchmark"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Benchmark; {
Count = newStats.Commands.Benchmark, Name = "benchmark"
});
else
existing.Count += newStats.Commands.Benchmark;
} }
if (newStats.Commands.Checksum > 0) if(newStats.Commands.Checksum > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Checksum, Name = "checksum"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Checksum; {
Count = newStats.Commands.Checksum, Name = "checksum"
});
else
existing.Count += newStats.Commands.Checksum;
} }
if (newStats.Commands.Compare > 0) if(newStats.Commands.Compare > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Compare, Name = "compare"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Compare; {
Count = newStats.Commands.Compare, Name = "compare"
});
else
existing.Count += newStats.Commands.Compare;
} }
if (newStats.Commands.CreateSidecar > 0) if(newStats.Commands.CreateSidecar > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command ctx.Commands.Add(new Command
{ {
Count = newStats.Commands.CreateSidecar, Name = "create-sidecar" Count = newStats.Commands.CreateSidecar, Name = "create-sidecar"
}); });
else existing.Count += newStats.Commands.CreateSidecar; else
existing.Count += newStats.Commands.CreateSidecar;
} }
if (newStats.Commands.Decode > 0) if(newStats.Commands.Decode > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Decode, Name = "decode"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Decode; {
Count = newStats.Commands.Decode, Name = "decode"
});
else
existing.Count += newStats.Commands.Decode;
} }
if (newStats.Commands.DeviceInfo > 0) if(newStats.Commands.DeviceInfo > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceInfo, Name = "device-info"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.DeviceInfo; {
Count = newStats.Commands.DeviceInfo, Name = "device-info"
});
else
existing.Count += newStats.Commands.DeviceInfo;
} }
if (newStats.Commands.DeviceReport > 0) if(newStats.Commands.DeviceReport > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceReport, Name = "device-report"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.DeviceReport; {
Count = newStats.Commands.DeviceReport, Name = "device-report"
});
else
existing.Count += newStats.Commands.DeviceReport;
} }
if (newStats.Commands.DumpMedia > 0) if(newStats.Commands.DumpMedia > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DumpMedia, Name = "dump-media"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.DumpMedia; {
Count = newStats.Commands.DumpMedia, Name = "dump-media"
});
else
existing.Count += newStats.Commands.DumpMedia;
} }
if (newStats.Commands.Entropy > 0) if(newStats.Commands.Entropy > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Entropy, Name = "entropy"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Entropy; {
Count = newStats.Commands.Entropy, Name = "entropy"
});
else
existing.Count += newStats.Commands.Entropy;
} }
if (newStats.Commands.Formats > 0) if(newStats.Commands.Formats > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Formats, Name = "formats"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Formats; {
Count = newStats.Commands.Formats, Name = "formats"
});
else
existing.Count += newStats.Commands.Formats;
} }
if (newStats.Commands.MediaInfo > 0) if(newStats.Commands.MediaInfo > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaInfo, Name = "media-info"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.MediaInfo; {
Count = newStats.Commands.MediaInfo, Name = "media-info"
});
else
existing.Count += newStats.Commands.MediaInfo;
} }
if (newStats.Commands.MediaScan > 0) if(newStats.Commands.MediaScan > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaScan, Name = "media-scan"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.MediaScan; {
Count = newStats.Commands.MediaScan, Name = "media-scan"
});
else
existing.Count += newStats.Commands.MediaScan;
} }
if (newStats.Commands.PrintHex > 0) if(newStats.Commands.PrintHex > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.PrintHex, Name = "printhex"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.PrintHex; {
Count = newStats.Commands.PrintHex, Name = "printhex"
});
else
existing.Count += newStats.Commands.PrintHex;
} }
if (newStats.Commands.Verify > 0) if(newStats.Commands.Verify > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Verify, Name = "verify"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.Verify; {
Count = newStats.Commands.Verify, Name = "verify"
});
else
existing.Count += newStats.Commands.Verify;
} }
if (newStats.Commands.Ls > 0) if(newStats.Commands.Ls > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "ls"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "ls");
if (existing == null) ctx.Commands.Add(new Command {Count = newStats.Commands.Ls, Name = "ls"}); if(existing == null)
else existing.Count += newStats.Commands.Ls; ctx.Commands.Add(new Command
{
Count = newStats.Commands.Ls, Name = "ls"
});
else
existing.Count += newStats.Commands.Ls;
} }
if (newStats.Commands.ExtractFiles > 0) if(newStats.Commands.ExtractFiles > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ExtractFiles, Name = "extract-files"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.ExtractFiles; {
Count = newStats.Commands.ExtractFiles, Name = "extract-files"
});
else
existing.Count += newStats.Commands.ExtractFiles;
} }
if (newStats.Commands.ListDevices > 0) if(newStats.Commands.ListDevices > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ListDevices, Name = "list-devices"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.ListDevices; {
Count = newStats.Commands.ListDevices, Name = "list-devices"
});
else
existing.Count += newStats.Commands.ListDevices;
} }
if (newStats.Commands.ListEncodings > 0) if(newStats.Commands.ListEncodings > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command ctx.Commands.Add(new Command
{ {
Count = newStats.Commands.ListEncodings, Name = "list-encodings" Count = newStats.Commands.ListEncodings, Name = "list-encodings"
}); });
else existing.Count += newStats.Commands.ListEncodings; else
existing.Count += newStats.Commands.ListEncodings;
} }
if (newStats.Commands.ConvertImage > 0) if(newStats.Commands.ConvertImage > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ConvertImage, Name = "convert-image"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.ConvertImage; {
Count = newStats.Commands.ConvertImage, Name = "convert-image"
});
else
existing.Count += newStats.Commands.ConvertImage;
} }
if (newStats.Commands.ImageInfo > 0) if(newStats.Commands.ImageInfo > 0)
{ {
var existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info"); Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info");
if (existing == null) if(existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ImageInfo, Name = "image-info"}); ctx.Commands.Add(new Command
else existing.Count += newStats.Commands.ImageInfo; {
Count = newStats.Commands.ImageInfo, Name = "image-info"
});
else
existing.Count += newStats.Commands.ImageInfo;
} }
} }
if (newStats.OperatingSystems != null) if(newStats.OperatingSystems != null)
{ {
foreach (var operatingSystem in newStats.OperatingSystems) foreach(OsStats operatingSystem in newStats.OperatingSystems)
{ {
if (string.IsNullOrWhiteSpace(operatingSystem.name) || if(string.IsNullOrWhiteSpace(operatingSystem.name) ||
string.IsNullOrWhiteSpace(operatingSystem.version)) continue; string.IsNullOrWhiteSpace(operatingSystem.version))
continue;
var existing = OperatingSystem existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name && ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
c.Version == operatingSystem.version); c.Version == operatingSystem.version);
if (existing == null) if(existing == null)
ctx.OperatingSystems.Add(new OperatingSystem ctx.OperatingSystems.Add(new OperatingSystem
{ {
Count = operatingSystem.Value, Count = operatingSystem.Value, Name = operatingSystem.name,
Name = operatingSystem.name,
Version = operatingSystem.version Version = operatingSystem.version
}); });
else existing.Count += operatingSystem.Value; else
existing.Count += operatingSystem.Value;
} }
} }
else else
{ {
var existing = OperatingSystem existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == "Linux" && c.Version == null); ctx.OperatingSystems.FirstOrDefault(c => c.Name == "Linux" && c.Version == null);
if (existing == null) ctx.OperatingSystems.Add(new OperatingSystem {Count = 1, Name = "Linux"}); if(existing == null)
else existing.Count++; ctx.OperatingSystems.Add(new OperatingSystem
{
Count = 1, Name = "Linux"
});
else
existing.Count++;
} }
if (newStats.Versions != null) if(newStats.Versions != null)
{ {
foreach (var nvs in newStats.Versions) foreach(NameValueStats nvs in newStats.Versions)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if(string.IsNullOrWhiteSpace(nvs.name))
continue;
var existing = ctx.Versions.FirstOrDefault(c => c.Value == nvs.name); Version existing = ctx.Versions.FirstOrDefault(c => c.Value == nvs.name);
if (existing == null) ctx.Versions.Add(new Version {Count = nvs.Value, Value = nvs.name}); if(existing == null)
else existing.Count += nvs.Value; ctx.Versions.Add(new Version
{
Count = nvs.Value, Value = nvs.name
});
else
existing.Count += nvs.Value;
} }
} }
else else
{ {
var existing = ctx.Versions.FirstOrDefault(c => c.Value == "previous"); Version existing = ctx.Versions.FirstOrDefault(c => c.Value == "previous");
if (existing == null) ctx.Versions.Add(new Version {Count = 1, Value = "previous"}); if(existing == null)
else existing.Count++; ctx.Versions.Add(new Version
{
Count = 1, Value = "previous"
});
else
existing.Count++;
} }
if (newStats.Filesystems != null) if(newStats.Filesystems != null)
foreach (var nvs in newStats.Filesystems) foreach(NameValueStats nvs in newStats.Filesystems)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if(string.IsNullOrWhiteSpace(nvs.name))
continue;
var existing = ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name); Filesystem existing = ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Filesystems.Add(new Filesystem {Count = nvs.Value, Name = nvs.name}); if(existing == null)
else existing.Count += nvs.Value; ctx.Filesystems.Add(new Filesystem
{
Count = nvs.Value, Name = nvs.name
});
else
existing.Count += nvs.Value;
} }
if (newStats.Partitions != null) if(newStats.Partitions != null)
foreach (var nvs in newStats.Partitions) foreach(NameValueStats nvs in newStats.Partitions)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if(string.IsNullOrWhiteSpace(nvs.name))
continue;
var existing = ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name); Partition existing = ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Partitions.Add(new Partition {Count = nvs.Value, Name = nvs.name}); if(existing == null)
else existing.Count += nvs.Value; ctx.Partitions.Add(new Partition
{
Count = nvs.Value, Name = nvs.name
});
else
existing.Count += nvs.Value;
} }
if (newStats.MediaImages != null) if(newStats.MediaImages != null)
foreach (var nvs in newStats.MediaImages) foreach(NameValueStats nvs in newStats.MediaImages)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if(string.IsNullOrWhiteSpace(nvs.name))
continue;
var existing = ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name); MediaFormat existing = ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.MediaFormats.Add(new MediaFormat {Count = nvs.Value, Name = nvs.name}); if(existing == null)
else existing.Count += nvs.Value; ctx.MediaFormats.Add(new MediaFormat
{
Count = nvs.Value, Name = nvs.name
});
else
existing.Count += nvs.Value;
} }
if (newStats.Filters != null) if(newStats.Filters != null)
foreach (var nvs in newStats.Filters) foreach(NameValueStats nvs in newStats.Filters)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if(string.IsNullOrWhiteSpace(nvs.name))
continue;
var existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name); Filter existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Filters.Add(new Filter {Count = nvs.Value, Name = nvs.name}); if(existing == null)
else existing.Count += nvs.Value; ctx.Filters.Add(new Filter
{
Count = nvs.Value, Name = nvs.name
});
else
existing.Count += nvs.Value;
} }
if (newStats.Devices != null) if(newStats.Devices != null)
foreach (var device in newStats.Devices) foreach(DeviceStats device in newStats.Devices)
{ {
if (string.IsNullOrWhiteSpace(device.Model)) continue; if(string.IsNullOrWhiteSpace(device.Model))
continue;
if (!ctx.DeviceStats.Any(c => c.Bus == device.Bus && c.Manufacturer == device.Manufacturer && if(!ctx.DeviceStats.Any(c => c.Bus == device.Bus && c.Manufacturer == device.Manufacturer &&
c.Model == device.Model && c.Revision == device.Revision)) c.Model == device.Model && c.Revision == device.Revision))
ctx.DeviceStats.Add(new DeviceStat ctx.DeviceStats.Add(new DeviceStat
{ {
Bus = device.Bus, Bus = device.Bus, Manufacturer = device.Manufacturer, Model = device.Model,
Manufacturer = device.Manufacturer,
Model = device.Model,
Revision = device.Revision Revision = device.Revision
}); });
} }
if (newStats.Medias != null) if(newStats.Medias != null)
foreach (var media in newStats.Medias) foreach(MediaStats media in newStats.Medias)
{ {
if (string.IsNullOrWhiteSpace(media.type)) continue; if(string.IsNullOrWhiteSpace(media.type))
continue;
var existing = ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real); Media existing = ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real);
if (existing == null) if(existing == null)
ctx.Medias.Add(new Media {Count = media.Value, Real = media.real, Type = media.type}); ctx.Medias.Add(new Media
else existing.Count += media.Value; {
Count = media.Value, Real = media.real, Type = media.type
});
else
existing.Count += media.Value;
} }
ctx.SaveChanges(); ctx.SaveChanges();

View File

@@ -36,23 +36,22 @@ namespace DiscImageChef.Server.App_Start
{ {
public static class TestedMedia public static class TestedMedia
{ {
/// <summary> /// <summary>Takes the tested media from a device report and prints it as a list of values</summary>
/// Takes the tested media from a device report and prints it as a list of values
/// </summary>
/// <param name="ata"><c>true</c> if device report is from an ATA device</param> /// <param name="ata"><c>true</c> if device report is from an ATA device</param>
/// <param name="mediaOneValue">List to put values on</param> /// <param name="mediaOneValue">List to put values on</param>
/// <param name="testedMedias">List of tested media</param> /// <param name="testedMedias">List of tested media</param>
public static void Report(List<CommonTypes.Metadata.TestedMedia> testedMedias, ref List<string> mediaOneValue) public static void Report(List<CommonTypes.Metadata.TestedMedia> testedMedias, ref List<string> mediaOneValue)
{ {
foreach (var testedMedia in testedMedias) foreach(CommonTypes.Metadata.TestedMedia testedMedia in testedMedias)
{ {
if (!string.IsNullOrWhiteSpace(testedMedia.MediumTypeName)) if(!string.IsNullOrWhiteSpace(testedMedia.MediumTypeName))
{ {
mediaOneValue.Add($"<i>Information for medium named \"{testedMedia.MediumTypeName}\"</i>"); mediaOneValue.Add($"<i>Information for medium named \"{testedMedia.MediumTypeName}\"</i>");
if (testedMedia.MediumType != null)
if(testedMedia.MediumType != null)
mediaOneValue.Add($"Medium type code: {testedMedia.MediumType:X2}h"); mediaOneValue.Add($"Medium type code: {testedMedia.MediumType:X2}h");
} }
else if (testedMedia.MediumType != null) else if(testedMedia.MediumType != null)
{ {
mediaOneValue.Add($"<i>Information for medium type {testedMedia.MediumType:X2}h</i>"); mediaOneValue.Add($"<i>Information for medium type {testedMedia.MediumType:X2}h</i>");
} }
@@ -61,265 +60,318 @@ namespace DiscImageChef.Server.App_Start
mediaOneValue.Add("<i>Information for unknown medium type</i>"); mediaOneValue.Add("<i>Information for unknown medium type</i>");
} }
mediaOneValue.Add(testedMedia.MediaIsRecognized mediaOneValue.Add(testedMedia.MediaIsRecognized ? "Drive recognizes this medium."
? "Drive recognizes this medium." : "Drive does not recognize this medium.");
: "Drive does not recognize this medium.");
if (!string.IsNullOrWhiteSpace(testedMedia.Manufacturer)) if(!string.IsNullOrWhiteSpace(testedMedia.Manufacturer))
mediaOneValue.Add($"Medium manufactured by: {testedMedia.Manufacturer}"); mediaOneValue.Add($"Medium manufactured by: {testedMedia.Manufacturer}");
if (!string.IsNullOrWhiteSpace(testedMedia.Model))
mediaOneValue.Add($"Medium model: {testedMedia.Model}");
if (testedMedia.Density != null) mediaOneValue.Add($"Density code: {testedMedia.Density:X2}h");
if (testedMedia.BlockSize != null) if(!string.IsNullOrWhiteSpace(testedMedia.Model))
mediaOneValue.Add($"Medium model: {testedMedia.Model}");
if(testedMedia.Density != null)
mediaOneValue.Add($"Density code: {testedMedia.Density:X2}h");
if(testedMedia.BlockSize != null)
mediaOneValue.Add($"Logical sector size: {testedMedia.BlockSize} bytes"); mediaOneValue.Add($"Logical sector size: {testedMedia.BlockSize} bytes");
if (testedMedia.PhysicalBlockSize != null)
if(testedMedia.PhysicalBlockSize != null)
mediaOneValue.Add($"Physical sector size: {testedMedia.PhysicalBlockSize} bytes"); mediaOneValue.Add($"Physical sector size: {testedMedia.PhysicalBlockSize} bytes");
if (testedMedia.LongBlockSize != null)
if(testedMedia.LongBlockSize != null)
mediaOneValue.Add($"READ LONG sector size: {testedMedia.LongBlockSize} bytes"); mediaOneValue.Add($"READ LONG sector size: {testedMedia.LongBlockSize} bytes");
if (testedMedia.Blocks != null && testedMedia.BlockSize != null) if(testedMedia.Blocks != null &&
testedMedia.BlockSize != null)
{ {
mediaOneValue.Add($"Medium has {testedMedia.Blocks} blocks of {testedMedia.BlockSize} bytes each"); mediaOneValue.Add($"Medium has {testedMedia.Blocks} blocks of {testedMedia.BlockSize} bytes each");
if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000) if(testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue.
.Add( Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); else if(testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000)
else if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000) mediaOneValue.
mediaOneValue Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
.Add(
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue.
.Add( Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.CHS != null && testedMedia.CurrentCHS != null) if(testedMedia.CHS != null &&
testedMedia.CurrentCHS != null)
{ {
var currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads * int currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads *
testedMedia.CurrentCHS.Sectors; testedMedia.CurrentCHS.Sectors;
mediaOneValue
.Add( mediaOneValue.
$"Cylinders: {testedMedia.CHS.Cylinders} max., {testedMedia.CurrentCHS.Cylinders} current"); Add($"Cylinders: {testedMedia.CHS.Cylinders} max., {testedMedia.CurrentCHS.Cylinders} current");
mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads} max., {testedMedia.CurrentCHS.Heads} current"); mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads} max., {testedMedia.CurrentCHS.Heads} current");
mediaOneValue
.Add( mediaOneValue.
$"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current"); Add($"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current");
mediaOneValue
.Add( mediaOneValue.
$"Sectors addressable in CHS mode: {testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors} max., {currentSectors} current"); Add($"Sectors addressable in CHS mode: {testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors} max., {currentSectors} current");
mediaOneValue
.Add( mediaOneValue.
$"Medium size in CHS mode: {(ulong) currentSectors * testedMedia.BlockSize} bytes, {(ulong) currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); Add($"Medium size in CHS mode: {(ulong)currentSectors * testedMedia.BlockSize} bytes, {(ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
else if (testedMedia.CHS != null) else if(testedMedia.CHS != null)
{ {
var currentSectors = testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors; int currentSectors = testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors;
mediaOneValue.Add($"Cylinders: {testedMedia.CHS.Cylinders}"); mediaOneValue.Add($"Cylinders: {testedMedia.CHS.Cylinders}");
mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads}"); mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads}");
mediaOneValue.Add($"Sectors per track: {testedMedia.CHS.Sectors}"); mediaOneValue.Add($"Sectors per track: {testedMedia.CHS.Sectors}");
mediaOneValue.Add($"Sectors addressable in CHS mode: {currentSectors}"); mediaOneValue.Add($"Sectors addressable in CHS mode: {currentSectors}");
mediaOneValue
.Add( mediaOneValue.
$"Medium size in CHS mode: {(ulong) currentSectors * testedMedia.BlockSize} bytes, {(ulong) currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); Add($"Medium size in CHS mode: {(ulong)currentSectors * testedMedia.BlockSize} bytes, {(ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.LBASectors != null) if(testedMedia.LBASectors != null)
{ {
mediaOneValue.Add($"Sectors addressable in sectors in 28-bit LBA mode: {testedMedia.LBASectors}"); mediaOneValue.Add($"Sectors addressable in sectors in 28-bit LBA mode: {testedMedia.LBASectors}");
if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) if((ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue.
.Add( Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); else if((ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000)
else if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000) mediaOneValue.
mediaOneValue Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
.Add(
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue.
.Add( Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.LBA48Sectors != null) if(testedMedia.LBA48Sectors != null)
{ {
mediaOneValue.Add($"Sectors addressable in sectors in 48-bit LBA mode: {testedMedia.LBA48Sectors}"); mediaOneValue.Add($"Sectors addressable in sectors in 48-bit LBA mode: {testedMedia.LBA48Sectors}");
if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) if(testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue.
.Add( Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); else if(testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000)
else if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000) mediaOneValue.
mediaOneValue Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
.Add(
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue.
.Add( Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.NominalRotationRate != null && testedMedia.NominalRotationRate != 0x0000 && if(testedMedia.NominalRotationRate != null &&
testedMedia.NominalRotationRate != 0xFFFF) testedMedia.NominalRotationRate != 0x0000 &&
mediaOneValue.Add(testedMedia.NominalRotationRate == 0x0001 testedMedia.NominalRotationRate != 0xFFFF)
? "Medium does not rotate." mediaOneValue.Add(testedMedia.NominalRotationRate == 0x0001 ? "Medium does not rotate."
: $"Medium rotates at {testedMedia.NominalRotationRate} rpm"); : $"Medium rotates at {testedMedia.NominalRotationRate} rpm");
if (testedMedia.BlockSize != null && if(testedMedia.BlockSize != null &&
testedMedia.PhysicalBlockSize != null && testedMedia.PhysicalBlockSize != null &&
testedMedia.BlockSize.Value != testedMedia.PhysicalBlockSize.Value && testedMedia.BlockSize.Value != testedMedia.PhysicalBlockSize.Value &&
(testedMedia.LogicalAlignment & 0x8000) == 0x0000 && (testedMedia.LogicalAlignment & 0x8000) == 0x0000 &&
(testedMedia.LogicalAlignment & 0x4000) == 0x4000) (testedMedia.LogicalAlignment & 0x4000) == 0x4000)
mediaOneValue mediaOneValue.
.Add( Add($"Logical sector starts at offset {testedMedia.LogicalAlignment & 0x3FFF} from physical sector");
$"Logical sector starts at offset {testedMedia.LogicalAlignment & 0x3FFF} from physical sector");
if (testedMedia.SupportsReadSectors == true) if(testedMedia.SupportsReadSectors == true)
mediaOneValue.Add("Device can use the READ SECTOR(S) command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ SECTOR(S) command in CHS mode with this medium");
if (testedMedia.SupportsReadRetry == true)
if(testedMedia.SupportsReadRetry == true)
mediaOneValue.Add("Device can use the READ SECTOR(S) RETRY command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ SECTOR(S) RETRY command in CHS mode with this medium");
if (testedMedia.SupportsReadDma == true)
if(testedMedia.SupportsReadDma == true)
mediaOneValue.Add("Device can use the READ DMA command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ DMA command in CHS mode with this medium");
if (testedMedia.SupportsReadDmaRetry == true)
if(testedMedia.SupportsReadDmaRetry == true)
mediaOneValue.Add("Device can use the READ DMA RETRY command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ DMA RETRY command in CHS mode with this medium");
if (testedMedia.SupportsReadLong == true)
if(testedMedia.SupportsReadLong == true)
mediaOneValue.Add("Device can use the READ LONG command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ LONG command in CHS mode with this medium");
if (testedMedia.SupportsReadLongRetry == true)
if(testedMedia.SupportsReadLongRetry == true)
mediaOneValue.Add("Device can use the READ LONG RETRY command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ LONG RETRY command in CHS mode with this medium");
if (testedMedia.SupportsReadLba == true) if(testedMedia.SupportsReadLba == true)
mediaOneValue.Add("Device can use the READ SECTOR(S) command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ SECTOR(S) command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadRetryLba == true)
mediaOneValue if(testedMedia.SupportsReadRetryLba == true)
.Add("Device can use the READ SECTOR(S) RETRY command in 28-bit LBA mode with this medium"); mediaOneValue.
if (testedMedia.SupportsReadDmaLba == true) Add("Device can use the READ SECTOR(S) RETRY command in 28-bit LBA mode with this medium");
if(testedMedia.SupportsReadDmaLba == true)
mediaOneValue.Add("Device can use the READ DMA command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ DMA command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadDmaRetryLba == true)
if(testedMedia.SupportsReadDmaRetryLba == true)
mediaOneValue.Add("Device can use the READ DMA RETRY command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ DMA RETRY command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadLongLba == true)
if(testedMedia.SupportsReadLongLba == true)
mediaOneValue.Add("Device can use the READ LONG command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ LONG command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadLongRetryLba == true)
if(testedMedia.SupportsReadLongRetryLba == true)
mediaOneValue.Add("Device can use the READ LONG RETRY command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ LONG RETRY command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadLba48 == true) if(testedMedia.SupportsReadLba48 == true)
mediaOneValue.Add("Device can use the READ SECTOR(S) command in 48-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ SECTOR(S) command in 48-bit LBA mode with this medium");
if (testedMedia.SupportsReadDmaLba48 == true)
if(testedMedia.SupportsReadDmaLba48 == true)
mediaOneValue.Add("Device can use the READ DMA command in 48-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the READ DMA command in 48-bit LBA mode with this medium");
if (testedMedia.SupportsSeek == true) if(testedMedia.SupportsSeek == true)
mediaOneValue.Add("Device can use the SEEK command in CHS mode with this medium"); mediaOneValue.Add("Device can use the SEEK command in CHS mode with this medium");
if (testedMedia.SupportsSeekLba == true)
if(testedMedia.SupportsSeekLba == true)
mediaOneValue.Add("Device can use the SEEK command in 28-bit LBA mode with this medium"); mediaOneValue.Add("Device can use the SEEK command in 28-bit LBA mode with this medium");
if (testedMedia.SupportsReadCapacity == true) if(testedMedia.SupportsReadCapacity == true)
mediaOneValue.Add("Device can use the READ CAPACITY (10) command with this medium"); mediaOneValue.Add("Device can use the READ CAPACITY (10) command with this medium");
if (testedMedia.SupportsReadCapacity16 == true)
if(testedMedia.SupportsReadCapacity16 == true)
mediaOneValue.Add("Device can use the READ CAPACITY (16) command with this medium"); mediaOneValue.Add("Device can use the READ CAPACITY (16) command with this medium");
if (testedMedia.SupportsRead6 == true)
if(testedMedia.SupportsRead6 == true)
mediaOneValue.Add("Device can use the READ (6) command with this medium"); mediaOneValue.Add("Device can use the READ (6) command with this medium");
if (testedMedia.SupportsRead10 == true)
if(testedMedia.SupportsRead10 == true)
mediaOneValue.Add("Device can use the READ (10) command with this medium"); mediaOneValue.Add("Device can use the READ (10) command with this medium");
if (testedMedia.SupportsRead12 == true)
if(testedMedia.SupportsRead12 == true)
mediaOneValue.Add("Device can use the READ (12) command with this medium"); mediaOneValue.Add("Device can use the READ (12) command with this medium");
if (testedMedia.SupportsRead16 == true)
if(testedMedia.SupportsRead16 == true)
mediaOneValue.Add("Device can use the READ (16) command with this medium"); mediaOneValue.Add("Device can use the READ (16) command with this medium");
if (testedMedia.SupportsReadLong == true)
if(testedMedia.SupportsReadLong == true)
mediaOneValue.Add("Device can use the READ LONG (10) command with this medium"); mediaOneValue.Add("Device can use the READ LONG (10) command with this medium");
if (testedMedia.SupportsReadLong16 == true)
if(testedMedia.SupportsReadLong16 == true)
mediaOneValue.Add("Device can use the READ LONG (16) command with this medium"); mediaOneValue.Add("Device can use the READ LONG (16) command with this medium");
if (testedMedia.SupportsReadCd == true) if(testedMedia.SupportsReadCd == true)
mediaOneValue.Add("Device can use the READ CD command with LBA addressing with this medium"); mediaOneValue.Add("Device can use the READ CD command with LBA addressing with this medium");
if (testedMedia.SupportsReadCdMsf == true)
mediaOneValue.Add("Device can use the READ CD command with MM:SS:FF addressing with this medium");
if (testedMedia.SupportsReadCdRaw == true)
mediaOneValue
.Add(
"Device can use the READ CD command with LBA addressing with this medium to read raw sector");
if (testedMedia.SupportsReadCdMsfRaw == true)
mediaOneValue
.Add(
"Device can use the READ CD command with MM:SS:FF addressing with this medium read raw sector");
if (testedMedia.SupportsHLDTSTReadRawDVD == true) if(testedMedia.SupportsReadCdMsf == true)
mediaOneValue.Add("Device can use the READ CD command with MM:SS:FF addressing with this medium");
if(testedMedia.SupportsReadCdRaw == true)
mediaOneValue.
Add("Device can use the READ CD command with LBA addressing with this medium to read raw sector");
if(testedMedia.SupportsReadCdMsfRaw == true)
mediaOneValue.
Add("Device can use the READ CD command with MM:SS:FF addressing with this medium read raw sector");
if(testedMedia.SupportsHLDTSTReadRawDVD == true)
mediaOneValue.Add("Device can use the HL-DT-ST vendor READ DVD (RAW) command with this medium"); mediaOneValue.Add("Device can use the HL-DT-ST vendor READ DVD (RAW) command with this medium");
if (testedMedia.SupportsNECReadCDDA == true)
if(testedMedia.SupportsNECReadCDDA == true)
mediaOneValue.Add("Device can use the NEC vendor READ CD-DA command with this medium"); mediaOneValue.Add("Device can use the NEC vendor READ CD-DA command with this medium");
if (testedMedia.SupportsPioneerReadCDDA == true)
if(testedMedia.SupportsPioneerReadCDDA == true)
mediaOneValue.Add("Device can use the PIONEER vendor READ CD-DA command with this medium"); mediaOneValue.Add("Device can use the PIONEER vendor READ CD-DA command with this medium");
if (testedMedia.SupportsPioneerReadCDDAMSF == true)
if(testedMedia.SupportsPioneerReadCDDAMSF == true)
mediaOneValue.Add("Device can use the PIONEER vendor READ CD-DA MSF command with this medium"); mediaOneValue.Add("Device can use the PIONEER vendor READ CD-DA MSF command with this medium");
if (testedMedia.SupportsPlextorReadCDDA == true)
if(testedMedia.SupportsPlextorReadCDDA == true)
mediaOneValue.Add("Device can use the PLEXTOR vendor READ CD-DA command with this medium"); mediaOneValue.Add("Device can use the PLEXTOR vendor READ CD-DA command with this medium");
if (testedMedia.SupportsPlextorReadRawDVD == true)
if(testedMedia.SupportsPlextorReadRawDVD == true)
mediaOneValue.Add("Device can use the PLEXOR vendor READ DVD (RAW) command with this medium"); mediaOneValue.Add("Device can use the PLEXOR vendor READ DVD (RAW) command with this medium");
if (testedMedia.CanReadAACS == true) if(testedMedia.CanReadAACS == true)
mediaOneValue.Add("Device can read the Advanced Access Content System from this medium"); mediaOneValue.Add("Device can read the Advanced Access Content System from this medium");
if (testedMedia.CanReadADIP == true)
if(testedMedia.CanReadADIP == true)
mediaOneValue.Add("Device can read the DVD ADress-In-Pregroove from this medium"); mediaOneValue.Add("Device can read the DVD ADress-In-Pregroove from this medium");
if (testedMedia.CanReadATIP == true)
if(testedMedia.CanReadATIP == true)
mediaOneValue.Add("Device can read the CD Absolute-Time-In-Pregroove from this medium"); mediaOneValue.Add("Device can read the CD Absolute-Time-In-Pregroove from this medium");
if (testedMedia.CanReadBCA == true)
if(testedMedia.CanReadBCA == true)
mediaOneValue.Add("Device can read the Burst Cutting Area from this medium"); mediaOneValue.Add("Device can read the Burst Cutting Area from this medium");
if (testedMedia.CanReadC2Pointers == true)
if(testedMedia.CanReadC2Pointers == true)
mediaOneValue.Add("Device can report the C2 pointers when reading from this medium"); mediaOneValue.Add("Device can report the C2 pointers when reading from this medium");
if (testedMedia.CanReadCMI == true)
if(testedMedia.CanReadCMI == true)
mediaOneValue.Add("Device can read the Copyright Management Information from this medium"); mediaOneValue.Add("Device can read the Copyright Management Information from this medium");
if (testedMedia.CanReadCorrectedSubchannel == true)
if(testedMedia.CanReadCorrectedSubchannel == true)
mediaOneValue.Add("Device can correct subchannels when reading from this medium"); mediaOneValue.Add("Device can correct subchannels when reading from this medium");
if (testedMedia.CanReadCorrectedSubchannelWithC2 == true)
mediaOneValue if(testedMedia.CanReadCorrectedSubchannelWithC2 == true)
.Add("Device can correct subchannels and report the C2 pointers when reading from this medium"); mediaOneValue.
if (testedMedia.CanReadDCB == true) Add("Device can correct subchannels and report the C2 pointers when reading from this medium");
if(testedMedia.CanReadDCB == true)
mediaOneValue.Add("Device can read the Disc Control Blocks from this medium"); mediaOneValue.Add("Device can read the Disc Control Blocks from this medium");
if (testedMedia.CanReadDDS == true)
if(testedMedia.CanReadDDS == true)
mediaOneValue.Add("Device can read the Disc Definition Structure from this medium"); mediaOneValue.Add("Device can read the Disc Definition Structure from this medium");
if (testedMedia.CanReadDMI == true)
if(testedMedia.CanReadDMI == true)
mediaOneValue.Add("Device can read the Disc Manufacurer Information from this medium"); mediaOneValue.Add("Device can read the Disc Manufacurer Information from this medium");
if (testedMedia.CanReadDiscInformation == true)
if(testedMedia.CanReadDiscInformation == true)
mediaOneValue.Add("Device can read the Disc Information from this medium"); mediaOneValue.Add("Device can read the Disc Information from this medium");
if (testedMedia.CanReadFullTOC == true)
if(testedMedia.CanReadFullTOC == true)
mediaOneValue.Add("Device can read the Table of Contents from this medium, without processing it"); mediaOneValue.Add("Device can read the Table of Contents from this medium, without processing it");
if (testedMedia.CanReadHDCMI == true)
if(testedMedia.CanReadHDCMI == true)
mediaOneValue.Add("Device can read the HD DVD Copyright Management Information from this medium"); mediaOneValue.Add("Device can read the HD DVD Copyright Management Information from this medium");
if (testedMedia.CanReadLayerCapacity == true)
if(testedMedia.CanReadLayerCapacity == true)
mediaOneValue.Add("Device can read the layer capacity from this medium"); mediaOneValue.Add("Device can read the layer capacity from this medium");
if (testedMedia.CanReadFirstTrackPreGap == true)
if(testedMedia.CanReadFirstTrackPreGap == true)
mediaOneValue.Add("Device can read the first track's pregap data"); mediaOneValue.Add("Device can read the first track's pregap data");
if (testedMedia.CanReadLeadIn == true)
if(testedMedia.CanReadLeadIn == true)
mediaOneValue.Add("Device can read the Lead-In from this medium"); mediaOneValue.Add("Device can read the Lead-In from this medium");
if (testedMedia.CanReadLeadOut == true)
if(testedMedia.CanReadLeadOut == true)
mediaOneValue.Add("Device can read the Lead-Out from this medium"); mediaOneValue.Add("Device can read the Lead-Out from this medium");
if (testedMedia.CanReadMediaID == true)
if(testedMedia.CanReadMediaID == true)
mediaOneValue.Add("Device can read the Media ID from this medium"); mediaOneValue.Add("Device can read the Media ID from this medium");
if (testedMedia.CanReadMediaSerial == true)
if(testedMedia.CanReadMediaSerial == true)
mediaOneValue.Add("Device can read the Media Serial Number from this medium"); mediaOneValue.Add("Device can read the Media Serial Number from this medium");
if (testedMedia.CanReadPAC == true) mediaOneValue.Add("Device can read the PAC from this medium");
if (testedMedia.CanReadPFI == true) if(testedMedia.CanReadPAC == true)
mediaOneValue.Add("Device can read the PAC from this medium");
if(testedMedia.CanReadPFI == true)
mediaOneValue.Add("Device can read the Physical Format Information from this medium"); mediaOneValue.Add("Device can read the Physical Format Information from this medium");
if (testedMedia.CanReadPMA == true)
if(testedMedia.CanReadPMA == true)
mediaOneValue.Add("Device can read the Power Management Area from this medium"); mediaOneValue.Add("Device can read the Power Management Area from this medium");
if (testedMedia.CanReadPQSubchannel == true)
if(testedMedia.CanReadPQSubchannel == true)
mediaOneValue.Add("Device can read the P to Q subchannels from this medium"); mediaOneValue.Add("Device can read the P to Q subchannels from this medium");
if (testedMedia.CanReadPQSubchannelWithC2 == true)
mediaOneValue if(testedMedia.CanReadPQSubchannelWithC2 == true)
.Add("Device can read the P to Q subchannels from this medium reporting the C2 pointers"); mediaOneValue.
if (testedMedia.CanReadPRI == true) Add("Device can read the P to Q subchannels from this medium reporting the C2 pointers");
if(testedMedia.CanReadPRI == true)
mediaOneValue.Add("Device can read the Pre-Recorded Information from this medium"); mediaOneValue.Add("Device can read the Pre-Recorded Information from this medium");
if (testedMedia.CanReadRWSubchannel == true)
if(testedMedia.CanReadRWSubchannel == true)
mediaOneValue.Add("Device can read the R to W subchannels from this medium"); mediaOneValue.Add("Device can read the R to W subchannels from this medium");
if (testedMedia.CanReadRWSubchannelWithC2 == true)
mediaOneValue if(testedMedia.CanReadRWSubchannelWithC2 == true)
.Add("Device can read the R to W subchannels from this medium reporting the C2 pointers"); mediaOneValue.
if (testedMedia.CanReadRecordablePFI == true) Add("Device can read the R to W subchannels from this medium reporting the C2 pointers");
if(testedMedia.CanReadRecordablePFI == true)
mediaOneValue.Add("Device can read the Physical Format Information from Lead-In from this medium"); mediaOneValue.Add("Device can read the Physical Format Information from Lead-In from this medium");
if (testedMedia.CanReadSpareAreaInformation == true)
if(testedMedia.CanReadSpareAreaInformation == true)
mediaOneValue.Add("Device can read the Spare Area Information from this medium"); mediaOneValue.Add("Device can read the Spare Area Information from this medium");
if (testedMedia.CanReadTOC == true)
if(testedMedia.CanReadTOC == true)
mediaOneValue.Add("Device can read the Table of Contents from this medium"); mediaOneValue.Add("Device can read the Table of Contents from this medium");
mediaOneValue.Add(""); mediaOneValue.Add("");

View File

@@ -41,21 +41,18 @@ namespace DiscImageChef.Server.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly IWebHostEnvironment _environment; readonly IWebHostEnvironment _environment;
public HomeController(IWebHostEnvironment environment) public HomeController(IWebHostEnvironment environment) => _environment = environment;
{
_environment = environment;
}
[Route("")] [Route(""), Route("README")]
[Route("README")]
public ActionResult Index() public ActionResult Index()
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "README.md")); "docs", "README.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -72,8 +69,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "Changelog.md")); "docs", "Changelog.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -90,8 +88,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CODE_OF_CONDUCT.md")); "docs", "CODE_OF_CONDUCT.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -108,8 +107,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "PULL_REQUEST_TEMPLATE.md")); "docs", "PULL_REQUEST_TEMPLATE.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -126,8 +126,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "ISSUE_TEMPLATE.md")); "docs", "ISSUE_TEMPLATE.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -144,8 +145,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CONTRIBUTING.md")); "docs", "CONTRIBUTING.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -162,8 +164,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "DONATING.md")); "docs", "DONATING.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -180,8 +183,9 @@ namespace DiscImageChef.Server.Controllers
{ {
var sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "TODO.md")); "docs", "TODO.md"));
var mdcontent = sr.ReadToEnd();
string mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");

View File

@@ -39,99 +39,100 @@ using DiscImageChef.Decoders.SCSI;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using Tuple = DiscImageChef.Decoders.PCMCIA.Tuple;
namespace DiscImageChef.Server.Controllers namespace DiscImageChef.Server.Controllers
{ {
public class ReportController : Controller public class ReportController : Controller
{ {
private readonly DicServerContext _ctx; readonly DicServerContext _ctx;
public ReportController(DicServerContext context) public ReportController(DicServerContext context) => _ctx = context;
{
_ctx = context;
}
public ActionResult Index() public ActionResult Index() => RedirectToAction("View", "Report", new RouteValueDictionary
{ {
return RedirectToAction("View", "Report", new RouteValueDictionary {{"id", 1}}); {
} "id", 1
}
});
public ActionResult View(int? id) public ActionResult View(int? id)
{ {
if (id == null || id <= 0) return Content("Incorrect device report request"); if(id == null ||
id <= 0)
return Content("Incorrect device report request");
try try
{ {
var report = _ctx.Devices.FirstOrDefault(d => d.Id == id); Device report = _ctx.Devices.FirstOrDefault(d => d.Id == id);
if (report is null) return Content("Cannot find requested report"); if(report is null)
return Content("Cannot find requested report");
ViewBag.lblManufacturer = report.Manufacturer; ViewBag.lblManufacturer = report.Manufacturer;
ViewBag.lblModel = report.Model; ViewBag.lblModel = report.Model;
ViewBag.lblRevision = report.Revision; ViewBag.lblRevision = report.Revision;
if (report.USB != null) if(report.USB != null)
{ {
string usbVendorDescription = null; string usbVendorDescription = null;
string usbProductDescription = null; string usbProductDescription = null;
var dbProduct = UsbProduct dbProduct =
_ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID && _ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID &&
p.Vendor != null && p.Vendor != null &&
p.Vendor.VendorId == report.USB.VendorID); p.Vendor.VendorId == report.USB.VendorID);
if (dbProduct is null) if(dbProduct is null)
{ {
var dbVendor = _ctx.UsbVendors.FirstOrDefault(v => v.VendorId == report.USB.VendorID); UsbVendor dbVendor = _ctx.UsbVendors.FirstOrDefault(v => v.VendorId == report.USB.VendorID);
if (!(dbVendor is null)) usbVendorDescription = dbVendor.Vendor; if(!(dbVendor is null))
usbVendorDescription = dbVendor.Vendor;
} }
else else
{ {
usbProductDescription = dbProduct.Product; usbProductDescription = dbProduct.Product;
usbVendorDescription = dbProduct.Vendor.Vendor; usbVendorDescription = dbProduct.Vendor.Vendor;
} }
ViewBag.UsbItem = new Item ViewBag.UsbItem = new Item
{ {
Manufacturer = report.USB.Manufacturer, Manufacturer = report.USB.Manufacturer, Product = report.USB.Product,
Product = report.USB.Product, VendorDescription = usbVendorDescription != null
VendorDescription = ? $"0x{report.USB.VendorID:x4} ({usbVendorDescription})"
usbVendorDescription != null : $"0x{report.USB.VendorID:x4}",
? $"0x{report.USB.VendorID:x4} ({usbVendorDescription})"
: $"0x{report.USB.VendorID:x4}",
ProductDescription = usbProductDescription != null ProductDescription = usbProductDescription != null
? $"0x{report.USB.ProductID:x4} ({usbProductDescription})" ? $"0x{report.USB.ProductID:x4} ({usbProductDescription})"
: $"0x{report.USB.ProductID:x4}" : $"0x{report.USB.ProductID:x4}"
}; };
} }
if (report.FireWire != null) if(report.FireWire != null)
ViewBag.FireWireItem = new Item ViewBag.FireWireItem = new Item
{ {
Manufacturer = report.FireWire.Manufacturer, Manufacturer = report.FireWire.Manufacturer, Product = report.FireWire.Product,
Product = report.FireWire.Product, VendorDescription = $"0x{report.FireWire.VendorID:x8}",
VendorDescription = $"0x{report.FireWire.VendorID:x8}",
ProductDescription = $"0x{report.FireWire.ProductID:x8}" ProductDescription = $"0x{report.FireWire.ProductID:x8}"
}; };
if (report.PCMCIA != null) if(report.PCMCIA != null)
{ {
ViewBag.PcmciaItem = new PcmciaItem ViewBag.PcmciaItem = new PcmciaItem
{ {
Manufacturer = report.PCMCIA.Manufacturer, Manufacturer = report.PCMCIA.Manufacturer, Product = report.PCMCIA.ProductName,
Product = report.PCMCIA.ProductName, VendorDescription = $"0x{report.PCMCIA.ManufacturerCode:x4}",
VendorDescription = $"0x{report.PCMCIA.ManufacturerCode:x4}", ProductDescription = $"0x{report.PCMCIA.CardCode:x4}", Compliance = report.PCMCIA.Compliance
ProductDescription = $"0x{report.PCMCIA.CardCode:x4}",
Compliance = report.PCMCIA.Compliance
}; };
var tuples = CIS.GetTuples(report.PCMCIA.CIS); Tuple[] tuples = CIS.GetTuples(report.PCMCIA.CIS);
if (tuples != null)
if(tuples != null)
{ {
var decodedTuples = new Dictionary<string, string>(); Dictionary<string, string> decodedTuples = new Dictionary<string, string>();
foreach (var tuple in tuples)
switch (tuple.Code) foreach(Tuple tuple in tuples)
switch(tuple.Code)
{ {
case TupleCodes.CISTPL_NULL: case TupleCodes.CISTPL_NULL:
case TupleCodes.CISTPL_END: case TupleCodes.CISTPL_END:
@@ -139,20 +140,25 @@ namespace DiscImageChef.Server.Controllers
case TupleCodes.CISTPL_VERS_1: break; case TupleCodes.CISTPL_VERS_1: break;
case TupleCodes.CISTPL_DEVICEGEO: case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A: case TupleCodes.CISTPL_DEVICEGEO_A:
var geom = CIS.DecodeDeviceGeometryTuple(tuple.Data); DeviceGeometryTuple geom = CIS.DecodeDeviceGeometryTuple(tuple.Data);
if (geom?.Geometries != null)
foreach (var geometry in geom.Geometries) if(geom?.Geometries != null)
foreach(DeviceGeometry geometry in geom.Geometries)
{ {
decodedTuples.Add("Device width", decodedTuples.Add("Device width",
$"{(1 << (geometry.CardInterface - 1)) * 8} bits"); $"{(1 << (geometry.CardInterface - 1)) * 8} bits");
decodedTuples.Add("Erase block", decodedTuples.Add("Erase block",
$"{(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes"); $"{(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes");
decodedTuples.Add("Read block", decodedTuples.Add("Read block",
$"{(1 << (geometry.ReadBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes"); $"{(1 << (geometry.ReadBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes");
decodedTuples.Add("Write block", decodedTuples.Add("Write block",
$"{(1 << (geometry.WriteBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes"); $"{(1 << (geometry.WriteBlockSize - 1)) * (1 << (geometry.Interleaving - 1))} bytes");
decodedTuples.Add("Partition alignment", decodedTuples.Add("Partition alignment",
$"{(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1)) * (1 << (geometry.Partitions - 1))} bytes"); $"{(1 << (geometry.EraseBlockSize - 1)) * (1 << (geometry.Interleaving - 1)) * (1 << (geometry.Partitions - 1))} bytes");
} }
break; break;
@@ -191,46 +197,53 @@ namespace DiscImageChef.Server.Controllers
case TupleCodes.CISTPL_SWIL: case TupleCodes.CISTPL_SWIL:
case TupleCodes.CISTPL_VERS_2: case TupleCodes.CISTPL_VERS_2:
decodedTuples.Add("Undecoded tuple ID", tuple.Code.ToString()); decodedTuples.Add("Undecoded tuple ID", tuple.Code.ToString());
break; break;
default: default:
decodedTuples.Add("Unknown tuple ID", $"0x{(byte) tuple.Code:X2}"); decodedTuples.Add("Unknown tuple ID", $"0x{(byte)tuple.Code:X2}");
break; break;
} }
if (decodedTuples.Count > 0) ViewBag.repPcmciaTuples = decodedTuples; if(decodedTuples.Count > 0)
ViewBag.repPcmciaTuples = decodedTuples;
} }
} }
var removable = true; bool removable = true;
List<TestedMedia> testedMedia = null; List<TestedMedia> testedMedia = null;
var ata = false; bool ata = false;
var atapi = false; bool atapi = false;
var sscMedia = false; bool sscMedia = false;
if (report.ATA != null || report.ATAPI != null) if(report.ATA != null ||
report.ATAPI != null)
{ {
ata = true; ata = true;
var ataOneValue = new List<string>(); List<string> ataOneValue = new List<string>();
var ataTwoValue = new Dictionary<string, string>(); Dictionary<string, string> ataTwoValue = new Dictionary<string, string>();
CommonTypes.Metadata.Ata ataReport; CommonTypes.Metadata.Ata ataReport;
if (report.ATAPI != null) if(report.ATAPI != null)
{ {
ViewBag.AtaItem = "ATAPI"; ViewBag.AtaItem = "ATAPI";
ataReport = report.ATAPI; ataReport = report.ATAPI;
atapi = true; atapi = true;
} }
else else
{ {
ViewBag.AtaItem = "ATA"; ViewBag.AtaItem = "ATA";
ataReport = report.ATA; ataReport = report.ATA;
} }
var cfa = report.CompactFlash; bool cfa = report.CompactFlash;
if (atapi && !cfa) ViewBag.lblAtaDeviceType = "ATAPI device"; if(atapi && !cfa)
else if (!atapi && cfa) ViewBag.lblAtaDeviceType = "CompactFlash device"; ViewBag.lblAtaDeviceType = "ATAPI device";
else ViewBag.lblAtaDeviceType = "ATA device"; else if(!atapi && cfa)
ViewBag.lblAtaDeviceType = "CompactFlash device";
else
ViewBag.lblAtaDeviceType = "ATA device";
Ata.Report(ataReport, cfa, atapi, ref removable, ref ataOneValue, ref ataTwoValue, ref testedMedia); Ata.Report(ataReport, cfa, atapi, ref removable, ref ataOneValue, ref ataTwoValue, ref testedMedia);
@@ -238,62 +251,78 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repAtaTwo = ataTwoValue; ViewBag.repAtaTwo = ataTwoValue;
} }
if (report.SCSI != null) if(report.SCSI != null)
{ {
var scsiOneValue = new List<string>(); List<string> scsiOneValue = new List<string>();
var modePages = new Dictionary<string, string>(); Dictionary<string, string> modePages = new Dictionary<string, string>();
var evpdPages = new Dictionary<string, string>(); Dictionary<string, string> evpdPages = new Dictionary<string, string>();
var vendorId = StringHandlers.CToString(report.SCSI.Inquiry?.VendorIdentification); string vendorId = StringHandlers.CToString(report.SCSI.Inquiry?.VendorIdentification);
if (report.SCSI.Inquiry != null)
if(report.SCSI.Inquiry != null)
{ {
var inq = report.SCSI.Inquiry.Value; Inquiry.SCSIInquiry inq = report.SCSI.Inquiry.Value;
ViewBag.lblScsiVendor = VendorString.Prettify(vendorId) != vendorId ViewBag.lblScsiVendor = VendorString.Prettify(vendorId) != vendorId
? $"{vendorId} ({VendorString.Prettify(vendorId)})" ? $"{vendorId} ({VendorString.Prettify(vendorId)})" : vendorId;
: vendorId;
ViewBag.lblScsiProduct = StringHandlers.CToString(inq.ProductIdentification); ViewBag.lblScsiProduct = StringHandlers.CToString(inq.ProductIdentification);
ViewBag.lblScsiRevision = StringHandlers.CToString(inq.ProductRevisionLevel); ViewBag.lblScsiRevision = StringHandlers.CToString(inq.ProductRevisionLevel);
} }
scsiOneValue.AddRange(ScsiInquiry.Report(report.SCSI.Inquiry)); scsiOneValue.AddRange(ScsiInquiry.Report(report.SCSI.Inquiry));
if (report.SCSI.SupportsModeSense6) scsiOneValue.Add("Device supports MODE SENSE (6)"); if(report.SCSI.SupportsModeSense6)
if (report.SCSI.SupportsModeSense10) scsiOneValue.Add("Device supports MODE SENSE (10)"); scsiOneValue.Add("Device supports MODE SENSE (6)");
if (report.SCSI.SupportsModeSubpages) scsiOneValue.Add("Device supports MODE SENSE subpages");
if (report.SCSI.ModeSense != null) if(report.SCSI.SupportsModeSense10)
scsiOneValue.Add("Device supports MODE SENSE (10)");
if(report.SCSI.SupportsModeSubpages)
scsiOneValue.Add("Device supports MODE SENSE subpages");
if(report.SCSI.ModeSense != null)
{ {
var devType = PeripheralDeviceTypes.DirectAccess; var devType = PeripheralDeviceTypes.DirectAccess;
if (report.SCSI.Inquiry != null)
devType = (PeripheralDeviceTypes) report.SCSI.Inquiry.Value.PeripheralDeviceType; if(report.SCSI.Inquiry != null)
devType = (PeripheralDeviceTypes)report.SCSI.Inquiry.Value.PeripheralDeviceType;
ScsiModeSense.Report(report.SCSI.ModeSense, vendorId, devType, ref scsiOneValue, ref modePages); ScsiModeSense.Report(report.SCSI.ModeSense, vendorId, devType, ref scsiOneValue, ref modePages);
} }
if (modePages.Count > 0) ViewBag.repModeSense = modePages; if(modePages.Count > 0)
ViewBag.repModeSense = modePages;
if (report.SCSI.EVPDPages != null) ScsiEvpd.Report(report.SCSI.EVPDPages, vendorId, ref evpdPages); if(report.SCSI.EVPDPages != null)
ScsiEvpd.Report(report.SCSI.EVPDPages, vendorId, ref evpdPages);
if (evpdPages.Count > 0) ViewBag.repEvpd = evpdPages; if(evpdPages.Count > 0)
ViewBag.repEvpd = evpdPages;
if (report.SCSI.MultiMediaDevice != null) if(report.SCSI.MultiMediaDevice != null)
{ {
testedMedia = report.SCSI.MultiMediaDevice.TestedMedia; testedMedia = report.SCSI.MultiMediaDevice.TestedMedia;
if (report.SCSI.MultiMediaDevice.ModeSense2A != null) if(report.SCSI.MultiMediaDevice.ModeSense2A != null)
{ {
var mmcModeOneValue = new List<string>(); List<string> mmcModeOneValue = new List<string>();
ScsiMmcMode.Report(report.SCSI.MultiMediaDevice.ModeSense2A, ref mmcModeOneValue); ScsiMmcMode.Report(report.SCSI.MultiMediaDevice.ModeSense2A, ref mmcModeOneValue);
if (mmcModeOneValue.Count > 0) ViewBag.repScsiMmcMode = mmcModeOneValue;
if(mmcModeOneValue.Count > 0)
ViewBag.repScsiMmcMode = mmcModeOneValue;
} }
if (report.SCSI.MultiMediaDevice.Features != null) if(report.SCSI.MultiMediaDevice.Features != null)
{ {
var mmcFeaturesOneValue = new List<string>(); List<string> mmcFeaturesOneValue = new List<string>();
ScsiMmcFeatures.Report(report.SCSI.MultiMediaDevice.Features, ref mmcFeaturesOneValue); ScsiMmcFeatures.Report(report.SCSI.MultiMediaDevice.Features, ref mmcFeaturesOneValue);
if (mmcFeaturesOneValue.Count > 0) ViewBag.repScsiMmcFeatures = mmcFeaturesOneValue;
if(mmcFeaturesOneValue.Count > 0)
ViewBag.repScsiMmcFeatures = mmcFeaturesOneValue;
} }
} }
else if (report.SCSI.SequentialDevice != null) else if(report.SCSI.SequentialDevice != null)
{ {
ViewBag.divScsiSscVisible = true; ViewBag.divScsiSscVisible = true;
@@ -306,75 +335,82 @@ namespace DiscImageChef.Server.Controllers
ViewBag.lblScsiSscMinBlock = ViewBag.lblScsiSscMinBlock =
report.SCSI.SequentialDevice.MinBlockLength?.ToString() ?? "Unspecified"; report.SCSI.SequentialDevice.MinBlockLength?.ToString() ?? "Unspecified";
if (report.SCSI.SequentialDevice.SupportedDensities != null) if(report.SCSI.SequentialDevice.SupportedDensities != null)
ViewBag.repScsiSscDensities = report.SCSI.SequentialDevice.SupportedDensities; ViewBag.repScsiSscDensities = report.SCSI.SequentialDevice.SupportedDensities;
if (report.SCSI.SequentialDevice.SupportedMediaTypes != null) if(report.SCSI.SequentialDevice.SupportedMediaTypes != null)
ViewBag.repScsiSscMedias = report.SCSI.SequentialDevice.SupportedMediaTypes; ViewBag.repScsiSscMedias = report.SCSI.SequentialDevice.SupportedMediaTypes;
if (report.SCSI.SequentialDevice.TestedMedia != null) if(report.SCSI.SequentialDevice.TestedMedia != null)
{ {
var mediaOneValue = new List<string>(); List<string> mediaOneValue = new List<string>();
SscTestedMedia.Report(report.SCSI.SequentialDevice.TestedMedia, ref mediaOneValue); SscTestedMedia.Report(report.SCSI.SequentialDevice.TestedMedia, ref mediaOneValue);
if (mediaOneValue.Count > 0)
if(mediaOneValue.Count > 0)
{ {
sscMedia = true; sscMedia = true;
ViewBag.repTestedMedia = mediaOneValue; ViewBag.repTestedMedia = mediaOneValue;
} }
} }
} }
else if (report.SCSI.ReadCapabilities != null) else if(report.SCSI.ReadCapabilities != null)
{ {
removable = false; removable = false;
scsiOneValue.Add(""); scsiOneValue.Add("");
if (report.SCSI.ReadCapabilities.Blocks.HasValue && if(report.SCSI.ReadCapabilities.Blocks.HasValue &&
report.SCSI.ReadCapabilities.BlockSize.HasValue) report.SCSI.ReadCapabilities.BlockSize.HasValue)
{ {
scsiOneValue scsiOneValue.
.Add( Add($"Device has {report.SCSI.ReadCapabilities.Blocks} blocks of {report.SCSI.ReadCapabilities.BlockSize} bytes each");
$"Device has {report.SCSI.ReadCapabilities.Blocks} blocks of {report.SCSI.ReadCapabilities.BlockSize} bytes each");
if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 / if(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 /
1024 > 1000000) 1024 > 1000000)
scsiOneValue scsiOneValue.
.Add( Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); else if(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize /
else if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 /
1024 / 1024 > 1000)
1024 > 1000) scsiOneValue.
scsiOneValue Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
.Add(
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
scsiOneValue scsiOneValue.
.Add( Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000} Mb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024:F2} MiB");
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000} Mb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (report.SCSI.ReadCapabilities.MediumType.HasValue) if(report.SCSI.ReadCapabilities.MediumType.HasValue)
scsiOneValue.Add($"Medium type code: {report.SCSI.ReadCapabilities.MediumType:X2}h"); scsiOneValue.Add($"Medium type code: {report.SCSI.ReadCapabilities.MediumType:X2}h");
if (report.SCSI.ReadCapabilities.Density.HasValue)
if(report.SCSI.ReadCapabilities.Density.HasValue)
scsiOneValue.Add($"Density code: {report.SCSI.ReadCapabilities.Density:X2}h"); scsiOneValue.Add($"Density code: {report.SCSI.ReadCapabilities.Density:X2}h");
if ((report.SCSI.ReadCapabilities.SupportsReadLong == true ||
report.SCSI.ReadCapabilities.SupportsReadLong16 == true) && if((report.SCSI.ReadCapabilities.SupportsReadLong == true ||
report.SCSI.ReadCapabilities.LongBlockSize.HasValue) report.SCSI.ReadCapabilities.SupportsReadLong16 == true) &&
report.SCSI.ReadCapabilities.LongBlockSize.HasValue)
scsiOneValue.Add($"Long block size: {report.SCSI.ReadCapabilities.LongBlockSize} bytes"); scsiOneValue.Add($"Long block size: {report.SCSI.ReadCapabilities.LongBlockSize} bytes");
if (report.SCSI.ReadCapabilities.SupportsReadCapacity == true)
if(report.SCSI.ReadCapabilities.SupportsReadCapacity == true)
scsiOneValue.Add("Device supports READ CAPACITY (10) command."); scsiOneValue.Add("Device supports READ CAPACITY (10) command.");
if (report.SCSI.ReadCapabilities.SupportsReadCapacity16 == true)
if(report.SCSI.ReadCapabilities.SupportsReadCapacity16 == true)
scsiOneValue.Add("Device supports READ CAPACITY (16) command."); scsiOneValue.Add("Device supports READ CAPACITY (16) command.");
if (report.SCSI.ReadCapabilities.SupportsRead6 == true)
if(report.SCSI.ReadCapabilities.SupportsRead6 == true)
scsiOneValue.Add("Device supports READ (6) command."); scsiOneValue.Add("Device supports READ (6) command.");
if (report.SCSI.ReadCapabilities.SupportsRead10 == true)
if(report.SCSI.ReadCapabilities.SupportsRead10 == true)
scsiOneValue.Add("Device supports READ (10) command."); scsiOneValue.Add("Device supports READ (10) command.");
if (report.SCSI.ReadCapabilities.SupportsRead12 == true)
if(report.SCSI.ReadCapabilities.SupportsRead12 == true)
scsiOneValue.Add("Device supports READ (12) command."); scsiOneValue.Add("Device supports READ (12) command.");
if (report.SCSI.ReadCapabilities.SupportsRead16 == true)
if(report.SCSI.ReadCapabilities.SupportsRead16 == true)
scsiOneValue.Add("Device supports READ (16) command."); scsiOneValue.Add("Device supports READ (16) command.");
if (report.SCSI.ReadCapabilities.SupportsReadLong == true)
if(report.SCSI.ReadCapabilities.SupportsReadLong == true)
scsiOneValue.Add("Device supports READ LONG (10) command."); scsiOneValue.Add("Device supports READ LONG (10) command.");
if (report.SCSI.ReadCapabilities.SupportsReadLong16 == true)
if(report.SCSI.ReadCapabilities.SupportsReadLong16 == true)
scsiOneValue.Add("Device supports READ LONG (16) command."); scsiOneValue.Add("Device supports READ LONG (16) command.");
} }
else else
@@ -385,88 +421,100 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repScsi = scsiOneValue; ViewBag.repScsi = scsiOneValue;
} }
if (report.MultiMediaCard != null) if(report.MultiMediaCard != null)
{ {
var mmcOneValue = new List<string>(); List<string> mmcOneValue = new List<string>();
if (report.MultiMediaCard.CID != null) if(report.MultiMediaCard.CID != null)
{ {
mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCID(report.MultiMediaCard.CID) mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCID(report.MultiMediaCard.CID).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
mmcOneValue.Add(""); mmcOneValue.Add("");
} }
if (report.MultiMediaCard.CSD != null) if(report.MultiMediaCard.CSD != null)
{ {
mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCSD(report.MultiMediaCard.CSD) mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCSD(report.MultiMediaCard.CSD).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
mmcOneValue.Add(""); mmcOneValue.Add("");
} }
if (report.MultiMediaCard.ExtendedCSD != null) if(report.MultiMediaCard.ExtendedCSD != null)
{ {
mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyExtendedCSD(report.MultiMediaCard.ExtendedCSD) mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyExtendedCSD(report.MultiMediaCard.ExtendedCSD).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
mmcOneValue.Add(""); mmcOneValue.Add("");
} }
if (report.MultiMediaCard.OCR != null) if(report.MultiMediaCard.OCR != null)
{ {
mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCSD(report.MultiMediaCard.OCR) mmcOneValue.Add(Decoders.MMC.Decoders.PrettifyCSD(report.MultiMediaCard.OCR).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
mmcOneValue.Add(""); mmcOneValue.Add("");
} }
ViewBag.repMMC = mmcOneValue; ViewBag.repMMC = mmcOneValue;
} }
if (report.SecureDigital != null) if(report.SecureDigital != null)
{ {
var sdOneValue = new List<string>(); List<string> sdOneValue = new List<string>();
if (report.SecureDigital.CID != null) if(report.SecureDigital.CID != null)
{ {
sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCID(report.SecureDigital.CID) sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCID(report.SecureDigital.CID).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
sdOneValue.Add(""); sdOneValue.Add("");
} }
if (report.SecureDigital.CSD != null) if(report.SecureDigital.CSD != null)
{ {
sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCSD(report.SecureDigital.CSD) sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCSD(report.SecureDigital.CSD).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
sdOneValue.Add(""); sdOneValue.Add("");
} }
if (report.SecureDigital.SCR != null) if(report.SecureDigital.SCR != null)
{ {
sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifySCR(report.SecureDigital.SCR) sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifySCR(report.SecureDigital.SCR).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
sdOneValue.Add(""); sdOneValue.Add("");
} }
if (report.SecureDigital.OCR != null) if(report.SecureDigital.OCR != null)
{ {
sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCSD(report.SecureDigital.OCR) sdOneValue.Add(Decoders.SecureDigital.Decoders.PrettifyCSD(report.SecureDigital.OCR).
.Replace("\n", "<br/>")); Replace("\n", "<br/>"));
sdOneValue.Add(""); sdOneValue.Add("");
} }
ViewBag.repSD = sdOneValue; ViewBag.repSD = sdOneValue;
} }
if (removable && !sscMedia && testedMedia != null) if(removable &&
!sscMedia &&
testedMedia != null)
{ {
var mediaOneValue = new List<string>(); List<string> mediaOneValue = new List<string>();
App_Start.TestedMedia.Report(testedMedia, ref mediaOneValue); App_Start.TestedMedia.Report(testedMedia, ref mediaOneValue);
if (mediaOneValue.Count > 0) ViewBag.repTestedMedia = mediaOneValue;
if(mediaOneValue.Count > 0)
ViewBag.repTestedMedia = mediaOneValue;
} }
} }
catch (Exception) catch(Exception)
{ {
#if DEBUG #if DEBUG
throw; throw;
#endif #endif
return Content("Could not load device report"); return Content("Could not load device report");
} }

View File

@@ -44,27 +44,27 @@ using DiscImageChef.Server.Models;
using Highsoft.Web.Mvc.Charts; using Highsoft.Web.Mvc.Charts;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID; using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
using Version = DiscImageChef.Server.Models.Version;
namespace DiscImageChef.Server.Controllers namespace DiscImageChef.Server.Controllers
{ {
/// <summary> /// <summary>Renders a page with statistics, list of media type, devices, etc</summary>
/// Renders a page with statistics, list of media type, devices, etc
/// </summary>
public class StatsController : Controller public class StatsController : Controller
{ {
private readonly IWebHostEnvironment _environment; readonly IWebHostEnvironment _environment;
private readonly DicServerContext ctx; readonly DicServerContext ctx;
private List<DeviceItem> devices; List<DeviceItem> devices;
private List<NameValueStats> operatingSystems; List<NameValueStats> operatingSystems;
private List<MediaItem> realMedia; List<MediaItem> realMedia;
private List<NameValueStats> versions; List<NameValueStats> versions;
private List<MediaItem> virtualMedia; List<MediaItem> virtualMedia;
public StatsController(IWebHostEnvironment environment, DicServerContext context) public StatsController(IWebHostEnvironment environment, DicServerContext context)
{ {
_environment = environment; _environment = environment;
ctx = context; ctx = context;
} }
public ActionResult Index() public ActionResult Index()
@@ -73,121 +73,122 @@ namespace DiscImageChef.Server.Controllers
try try
{ {
if ( if(
System.IO.File System.IO.File.
.Exists(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Exists(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Statistics", "Statistics.xml"))) "Statistics", "Statistics.xml")))
try try
{ {
var statistics = new Stats(); var statistics = new Stats();
var xs = new XmlSerializer(statistics.GetType()); var xs = new XmlSerializer(statistics.GetType());
var fs =
WaitForFile( FileStream fs =
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
"Statistics", "Statistics.xml"), FileMode.Open, FileAccess.Read, FileShare.Read);
FileMode.Open, FileAccess.Read, FileShare.Read);
statistics = (Stats) xs.Deserialize(fs); statistics = (Stats)xs.Deserialize(fs);
fs.Close(); fs.Close();
StatsConverter.Convert(statistics); StatsConverter.Convert(statistics);
System.IO.File System.IO.File.
.Delete(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Delete(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Statistics", "Statistics.xml")); "Statistics", "Statistics.xml"));
} }
catch (XmlException) catch(XmlException)
{ {
// Do nothing // Do nothing
} }
if (ctx.OperatingSystems.Any()) if(ctx.OperatingSystems.Any())
{ {
operatingSystems = new List<NameValueStats>(); operatingSystems = new List<NameValueStats>();
foreach (var nvs in ctx.OperatingSystems)
foreach(OperatingSystem nvs in ctx.OperatingSystems)
operatingSystems.Add(new NameValueStats operatingSystems.Add(new NameValueStats
{ {
name = name =
$"{DetectOS.GetPlatformName((PlatformID) Enum.Parse(typeof(PlatformID), nvs.Name), nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}", $"{DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), nvs.Name), nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}",
Value = nvs.Count Value = nvs.Count
}); });
ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList(); ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();
var osPieData = new List<PieSeriesData>(); List<PieSeriesData> osPieData = new List<PieSeriesData>();
decimal totalOsCount = ctx.OperatingSystems.Sum(o => o.Count); decimal totalOsCount = ctx.OperatingSystems.Sum(o => o.Count);
foreach (var os in ctx.OperatingSystems.Select(o => o.Name).Distinct().ToList())
foreach(string os in ctx.OperatingSystems.Select(o => o.Name).Distinct().ToList())
{ {
decimal osCount = ctx.OperatingSystems.Where(o => o.Name == os).Sum(o => o.Count); decimal osCount = ctx.OperatingSystems.Where(o => o.Name == os).Sum(o => o.Count);
osPieData.Add(new PieSeriesData osPieData.Add(new PieSeriesData
{ {
Name = Name = DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), os)),
DetectOS.GetPlatformName((PlatformID) Enum.Parse(typeof(PlatformID), Y = (double?)(osCount / totalOsCount), Sliced = os == "Linux", Selected = os == "Linux"
os)),
Y = (double?) (osCount / totalOsCount),
Sliced = os == "Linux",
Selected = os == "Linux"
}); });
} }
ViewData["osPieData"] = osPieData; ViewData["osPieData"] = osPieData;
var linuxPieData = new List<PieSeriesData>(); List<PieSeriesData> linuxPieData = new List<PieSeriesData>();
decimal linuxCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()) decimal linuxCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).
.Sum(o => o.Count); Sum(o => o.Count);
foreach (var version in
foreach(OperatingSystem version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()))
linuxPieData.Add(new PieSeriesData linuxPieData.Add(new PieSeriesData
{ {
Name = Name =
$"{DetectOS.GetPlatformName(PlatformID.Linux, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}", $"{DetectOS.GetPlatformName(PlatformID.Linux, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
Y = (double?) (version.Count / linuxCount) Y = (double?)(version.Count / linuxCount)
}); });
ViewData["linuxPieData"] = linuxPieData; ViewData["linuxPieData"] = linuxPieData;
var macosPieData = new List<PieSeriesData>(); List<PieSeriesData> macosPieData = new List<PieSeriesData>();
decimal macosCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()) decimal macosCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).
.Sum(o => o.Count); Sum(o => o.Count);
foreach (var version in
foreach(OperatingSystem version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()))
macosPieData.Add(new PieSeriesData macosPieData.Add(new PieSeriesData
{ {
Name = Name =
$"{DetectOS.GetPlatformName(PlatformID.MacOSX, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}", $"{DetectOS.GetPlatformName(PlatformID.MacOSX, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
Y = (double?) (version.Count / macosCount) Y = (double?)(version.Count / macosCount)
}); });
ViewData["macosPieData"] = macosPieData; ViewData["macosPieData"] = macosPieData;
var windowsPieData = new List<PieSeriesData>(); List<PieSeriesData> windowsPieData = new List<PieSeriesData>();
decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()) decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).
.Sum(o => o.Count); Sum(o => o.Count);
foreach (var version in
foreach(OperatingSystem version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()))
windowsPieData.Add(new PieSeriesData windowsPieData.Add(new PieSeriesData
{ {
Name = Name =
$"{DetectOS.GetPlatformName(PlatformID.Win32NT, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}", $"{DetectOS.GetPlatformName(PlatformID.Win32NT, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
Y = (double?) (version.Count / windowsCount) Y = (double?)(version.Count / windowsCount)
}); });
ViewData["windowsPieData"] = windowsPieData; ViewData["windowsPieData"] = windowsPieData;
} }
if (ctx.Versions.Any()) if(ctx.Versions.Any())
{ {
versions = new List<NameValueStats>(); versions = new List<NameValueStats>();
foreach (var nvs in ctx.Versions)
foreach(Version nvs in ctx.Versions)
versions.Add(new NameValueStats versions.Add(new NameValueStats
{ {
name = nvs.Value == "previous" ? "Previous than 3.4.99.0" : nvs.Value, name = nvs.Value == "previous" ? "Previous than 3.4.99.0" : nvs.Value, Value = nvs.Count
Value = nvs.Count
}); });
ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList(); ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList();
@@ -196,272 +197,264 @@ namespace DiscImageChef.Server.Controllers
ViewData["versionsPieData"] = ctx.Versions.Select(version => new PieSeriesData ViewData["versionsPieData"] = ctx.Versions.Select(version => new PieSeriesData
{ {
Name = Name = version.Value == "previous" ? "Previous than 3.4.99.0" : version.Value,
version.Value == "previous" Y = (double?)(version.Count / totalVersionCount), Sliced = version.Value == "previous",
? "Previous than 3.4.99.0" Selected = version.Value == "previous"
: version.Value,
Y = (double?) (version.Count /
totalVersionCount),
Sliced = version.Value == "previous",
Selected = version.Value == "previous"
}).ToList(); }).ToList();
} }
if (ctx.Commands.Any()) if(ctx.Commands.Any())
{ {
ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList(); ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList();
decimal totalCommandCount = ctx.Commands.Sum(o => o.Count); decimal totalCommandCount = ctx.Commands.Sum(o => o.Count);
ViewData["commandsPieData"] = ctx ViewData["commandsPieData"] = ctx.Commands.Select(command => new PieSeriesData
.Commands.Select(command => new PieSeriesData {
{ Name = command.Name, Y = (double?)(command.Count / totalCommandCount),
Name = command.Name, Sliced = command.Name == "analyze", Selected = command.Name == "analyze"
Y = (double?) (command.Count / }).ToList();
totalCommandCount),
Sliced = command.Name == "analyze",
Selected = command.Name == "analyze"
}).ToList();
} }
if (ctx.Filters.Any()) if(ctx.Filters.Any())
{ {
ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList(); ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();
var filtersPieData = new List<PieSeriesData>(); List<PieSeriesData> filtersPieData = new List<PieSeriesData>();
decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count); decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count);
foreach (var filter in ctx.Filters.ToList())
foreach(Filter filter in ctx.Filters.ToList())
filtersPieData.Add(new PieSeriesData filtersPieData.Add(new PieSeriesData
{ {
Name = filter.Name, Name = filter.Name, Y = (double?)(filter.Count / totalFiltersCount),
Y = (double?) (filter.Count / totalFiltersCount), Sliced = filter.Name == "No filter", Selected = filter.Name == "No filter"
Sliced = filter.Name == "No filter",
Selected = filter.Name == "No filter"
}); });
ViewData["filtersPieData"] = filtersPieData; ViewData["filtersPieData"] = filtersPieData;
} }
if (ctx.MediaFormats.Any()) if(ctx.MediaFormats.Any())
{ {
ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList(); ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();
var formatsPieData = new List<PieSeriesData>(); List<PieSeriesData> formatsPieData = new List<PieSeriesData>();
decimal totalFormatsCount = ctx.MediaFormats.Sum(o => o.Count); decimal totalFormatsCount = ctx.MediaFormats.Sum(o => o.Count);
decimal top10FormatCount = 0; decimal top10FormatCount = 0;
foreach (var format in ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10)) foreach(MediaFormat format in ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10))
{ {
top10FormatCount += format.Count; top10FormatCount += format.Count;
formatsPieData.Add(new PieSeriesData formatsPieData.Add(new PieSeriesData
{ {
Name = format.Name, Y = (double?) (format.Count / totalFormatsCount) Name = format.Name, Y = (double?)(format.Count / totalFormatsCount)
}); });
} }
formatsPieData.Add(new PieSeriesData formatsPieData.Add(new PieSeriesData
{ {
Name = "Other", Name = "Other", Y = (double?)((totalFormatsCount - top10FormatCount) / totalFormatsCount),
Y = (double?) ((totalFormatsCount - top10FormatCount) / Sliced = true, Selected = true
totalFormatsCount),
Sliced = true,
Selected = true
}); });
ViewData["formatsPieData"] = formatsPieData; ViewData["formatsPieData"] = formatsPieData;
} }
if (ctx.Partitions.Any()) if(ctx.Partitions.Any())
{ {
ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList(); ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList();
var partitionsPieData = new List<PieSeriesData>(); List<PieSeriesData> partitionsPieData = new List<PieSeriesData>();
decimal totalPartitionsCount = ctx.Partitions.Sum(o => o.Count); decimal totalPartitionsCount = ctx.Partitions.Sum(o => o.Count);
decimal top10PartitionCount = 0; decimal top10PartitionCount = 0;
foreach (var partition in ctx.Partitions.OrderByDescending(o => o.Count).Take(10)) foreach(Partition partition in ctx.Partitions.OrderByDescending(o => o.Count).Take(10))
{ {
top10PartitionCount += partition.Count; top10PartitionCount += partition.Count;
partitionsPieData.Add(new PieSeriesData partitionsPieData.Add(new PieSeriesData
{ {
Name = partition.Name, Name = partition.Name, Y = (double?)(partition.Count / totalPartitionsCount)
Y = (double?) (partition.Count / totalPartitionsCount)
}); });
} }
partitionsPieData.Add(new PieSeriesData partitionsPieData.Add(new PieSeriesData
{ {
Name = "Other", Name = "Other",
Y = (double?) ((totalPartitionsCount - top10PartitionCount) / Y = (double?)((totalPartitionsCount - top10PartitionCount) / totalPartitionsCount),
totalPartitionsCount), Sliced = true, Selected = true
Sliced = true,
Selected = true
}); });
ViewData["partitionsPieData"] = partitionsPieData; ViewData["partitionsPieData"] = partitionsPieData;
} }
if (ctx.Filesystems.Any()) if(ctx.Filesystems.Any())
{ {
ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList(); ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList();
var filesystemsPieData = new List<PieSeriesData>(); List<PieSeriesData> filesystemsPieData = new List<PieSeriesData>();
decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count); decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count);
decimal top10FilesystemCount = 0; decimal top10FilesystemCount = 0;
foreach (var filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10)) foreach(Filesystem filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10))
{ {
top10FilesystemCount += filesystem.Count; top10FilesystemCount += filesystem.Count;
filesystemsPieData.Add(new PieSeriesData filesystemsPieData.Add(new PieSeriesData
{ {
Name = filesystem.Name, Name = filesystem.Name, Y = (double?)(filesystem.Count / totalFilesystemsCount)
Y = (double?) (filesystem.Count / totalFilesystemsCount)
}); });
} }
filesystemsPieData.Add(new PieSeriesData filesystemsPieData.Add(new PieSeriesData
{ {
Name = "Other", Name = "Other",
Y = (double?) ((totalFilesystemsCount - top10FilesystemCount) / Y = (double?)((totalFilesystemsCount - top10FilesystemCount) / totalFilesystemsCount),
totalFilesystemsCount), Sliced = true, Selected = true
Sliced = true,
Selected = true
}); });
ViewData["filesystemsPieData"] = filesystemsPieData; ViewData["filesystemsPieData"] = filesystemsPieData;
} }
if (ctx.Medias.Any()) if(ctx.Medias.Any())
{ {
realMedia = new List<MediaItem>(); realMedia = new List<MediaItem>();
virtualMedia = new List<MediaItem>(); virtualMedia = new List<MediaItem>();
foreach (var nvs in ctx.Medias)
foreach(Media nvs in ctx.Medias)
try try
{ {
MediaType MediaType.
.MediaTypeToString( MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type),
(CommonTypes.MediaType) Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type), out string type, out string subtype);
out var type, out var subtype);
if (nvs.Real) if(nvs.Real)
realMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Count}); realMedia.Add(new MediaItem
else virtualMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Count}); {
Type = type, SubType = subtype, Count = nvs.Count
});
else
virtualMedia.Add(new MediaItem
{
Type = type, SubType = subtype, Count = nvs.Count
});
} }
catch catch
{ {
if (nvs.Real) if(nvs.Real)
realMedia.Add(new MediaItem {Type = nvs.Type, SubType = null, Count = nvs.Count}); realMedia.Add(new MediaItem
else virtualMedia.Add(new MediaItem {Type = nvs.Type, SubType = null, Count = nvs.Count}); {
Type = nvs.Type, SubType = null, Count = nvs.Count
});
else
virtualMedia.Add(new MediaItem
{
Type = nvs.Type, SubType = null, Count = nvs.Count
});
} }
if (realMedia.Count > 0) if(realMedia.Count > 0)
{ {
ViewBag.repRealMedia = ViewBag.repRealMedia =
realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList(); realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
var realMediaPieData = new List<PieSeriesData>(); List<PieSeriesData> realMediaPieData = new List<PieSeriesData>();
decimal totalRealMediaCount = realMedia.Sum(o => o.Count); decimal totalRealMediaCount = realMedia.Sum(o => o.Count);
decimal top10RealMediaCount = 0; decimal top10RealMediaCount = 0;
foreach (var realMediaItem in realMedia.OrderByDescending(o => o.Count).Take(10)) foreach(MediaItem realMediaItem in realMedia.OrderByDescending(o => o.Count).Take(10))
{ {
top10RealMediaCount += realMediaItem.Count; top10RealMediaCount += realMediaItem.Count;
realMediaPieData.Add(new PieSeriesData realMediaPieData.Add(new PieSeriesData
{ {
Name = $"{realMediaItem.Type} ({realMediaItem.SubType})", Name = $"{realMediaItem.Type} ({realMediaItem.SubType})",
Y = (double?) (realMediaItem.Count / totalRealMediaCount) Y = (double?)(realMediaItem.Count / totalRealMediaCount)
}); });
} }
realMediaPieData.Add(new PieSeriesData realMediaPieData.Add(new PieSeriesData
{ {
Name = "Other", Name = "Other",
Y = (double?) ((totalRealMediaCount - top10RealMediaCount) / Y = (double?)((totalRealMediaCount - top10RealMediaCount) / totalRealMediaCount),
totalRealMediaCount), Sliced = true, Selected = true
Sliced = true,
Selected = true
}); });
ViewData["realMediaPieData"] = realMediaPieData; ViewData["realMediaPieData"] = realMediaPieData;
} }
if (virtualMedia.Count > 0) if(virtualMedia.Count > 0)
{ {
ViewBag.repVirtualMedia = ViewBag.repVirtualMedia =
virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList(); virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
var virtualMediaPieData = new List<PieSeriesData>(); List<PieSeriesData> virtualMediaPieData = new List<PieSeriesData>();
decimal totalVirtualMediaCount = virtualMedia.Sum(o => o.Count); decimal totalVirtualMediaCount = virtualMedia.Sum(o => o.Count);
decimal top10VirtualMediaCount = 0; decimal top10VirtualMediaCount = 0;
foreach (var virtualMediaItem in virtualMedia.OrderByDescending(o => o.Count).Take(10)) foreach(MediaItem virtualMediaItem in virtualMedia.OrderByDescending(o => o.Count).Take(10))
{ {
top10VirtualMediaCount += virtualMediaItem.Count; top10VirtualMediaCount += virtualMediaItem.Count;
virtualMediaPieData.Add(new PieSeriesData virtualMediaPieData.Add(new PieSeriesData
{ {
Name = Name = $"{virtualMediaItem.Type} ({virtualMediaItem.SubType})",
$"{virtualMediaItem.Type} ({virtualMediaItem.SubType})", Y = (double?)(virtualMediaItem.Count / totalVirtualMediaCount)
Y = (double?) (virtualMediaItem.Count /
totalVirtualMediaCount)
}); });
} }
virtualMediaPieData.Add(new PieSeriesData virtualMediaPieData.Add(new PieSeriesData
{ {
Name = "Other", Name = "Other",
Y = (double?) Y = (double?)((totalVirtualMediaCount - top10VirtualMediaCount) /
((totalVirtualMediaCount - top10VirtualMediaCount) / totalVirtualMediaCount),
totalVirtualMediaCount), Sliced = true, Selected = true
Sliced = true,
Selected = true
}); });
ViewData["virtualMediaPieData"] = virtualMediaPieData; ViewData["virtualMediaPieData"] = virtualMediaPieData;
} }
} }
if (ctx.DeviceStats.Any()) if(ctx.DeviceStats.Any())
{ {
devices = new List<DeviceItem>(); devices = new List<DeviceItem>();
foreach (var device in ctx.DeviceStats.ToList())
foreach(DeviceStat device in ctx.DeviceStats.ToList())
{ {
string xmlFile; string xmlFile;
if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
!string.IsNullOrWhiteSpace(device.Model) && if(!string.IsNullOrWhiteSpace(device.Manufacturer) &&
!string.IsNullOrWhiteSpace(device.Revision)) !string.IsNullOrWhiteSpace(device.Model) &&
!string.IsNullOrWhiteSpace(device.Revision))
xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml"; xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml";
else if (!string.IsNullOrWhiteSpace(device.Manufacturer) && else if(!string.IsNullOrWhiteSpace(device.Manufacturer) &&
!string.IsNullOrWhiteSpace(device.Model)) !string.IsNullOrWhiteSpace(device.Model))
xmlFile = device.Manufacturer + "_" + device.Model + ".xml"; xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
else if (!string.IsNullOrWhiteSpace(device.Model) && else if(!string.IsNullOrWhiteSpace(device.Model) &&
!string.IsNullOrWhiteSpace(device.Revision)) !string.IsNullOrWhiteSpace(device.Revision))
xmlFile = device.Model + "_" + device.Revision + ".xml"; xmlFile = device.Model + "_" + device.Revision + ".xml";
else xmlFile = device.Model + ".xml"; else
xmlFile = device.Model + ".xml";
xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_'); xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_');
if (System.IO.File.Exists(Path.Combine(_environment.ContentRootPath, "Reports", xmlFile))) if(System.IO.File.Exists(Path.Combine(_environment.ContentRootPath, "Reports", xmlFile)))
{ {
var deviceReport = new DeviceReport(); var deviceReport = new DeviceReport();
var xs = new XmlSerializer(deviceReport.GetType()); var xs = new XmlSerializer(deviceReport.GetType());
var fs =
WaitForFile( FileStream fs =
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile),
"Reports", xmlFile), FileMode.Open, FileAccess.Read, FileShare.Read);
FileMode.Open, FileAccess.Read, FileShare.Read);
deviceReport = (DeviceReport) xs.Deserialize(fs); deviceReport = (DeviceReport)xs.Deserialize(fs);
fs.Close(); fs.Close();
var deviceReportV2 = new DeviceReportV2(deviceReport); var deviceReportV2 = new DeviceReportV2(deviceReport);
@@ -469,70 +462,64 @@ namespace DiscImageChef.Server.Controllers
device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity; device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity;
ctx.SaveChanges(); ctx.SaveChanges();
System.IO.File System.IO.File.
.Delete(Path.Combine( Delete(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
_environment.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile));
"Reports", xmlFile));
} }
devices.Add(new DeviceItem devices.Add(new DeviceItem
{ {
Manufacturer = device.Manufacturer, Manufacturer = device.Manufacturer, Model = device.Model, Revision = device.Revision,
Model = device.Model, Bus = device.Bus,
Revision = device.Revision, ReportId = device.Report != null && device.Report.Id != 0 ? device.Report.Id : 0
Bus = device.Bus,
ReportId = device.Report != null && device.Report.Id != 0
? device.Report.Id
: 0
}); });
} }
ViewBag.repDevices = devices.OrderBy(device => device.Manufacturer).ThenBy(device => device.Model) ViewBag.repDevices = devices.OrderBy(device => device.Manufacturer).ThenBy(device => device.Model).
.ThenBy(device => device.Revision).ThenBy(device => device.Bus) ThenBy(device => device.Revision).ThenBy(device => device.Bus).
.ToList(); ToList();
ViewData["devicesBusPieData"] = (from deviceBus in devices.Select(d => d.Bus).Distinct() ViewData["devicesBusPieData"] = (from deviceBus in devices.Select(d => d.Bus).Distinct()
let deviceBusCount = devices.Count(d => d.Bus == deviceBus) let deviceBusCount = devices.Count(d => d.Bus == deviceBus)
select new PieSeriesData select new PieSeriesData
{ {
Name = deviceBus, Name = deviceBus, Y = deviceBusCount / (double)devices.Count
Y = deviceBusCount / (double) devices.Count }).ToList();
}).ToList();
ViewData["devicesManufacturerPieData"] = ViewData["devicesManufacturerPieData"] =
(from manufacturer in (from manufacturer in devices.Where(d => d.Manufacturer != null).
devices.Where(d => d.Manufacturer != null) Select(d => d.Manufacturer.ToLowerInvariant()).Distinct()
.Select(d => d.Manufacturer.ToLowerInvariant()) let manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer)
.Distinct() select new PieSeriesData
let manufacturerCount = {
devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer) Name = manufacturer, Y = manufacturerCount / (double)devices.Count
select new PieSeriesData }).ToList();
{Name = manufacturer, Y = manufacturerCount / (double) devices.Count})
.ToList();
} }
} }
catch (Exception) catch(Exception)
{ {
#if DEBUG #if DEBUG
throw; throw;
#endif #endif
return Content("Could not read statistics"); return Content("Could not read statistics");
} }
return View(); return View();
} }
private static FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share) static FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
{ {
for (var numTries = 0; numTries < 100; numTries++) for(int numTries = 0; numTries < 100; numTries++)
{ {
FileStream fs = null; FileStream fs = null;
try try
{ {
fs = new FileStream(fullPath, mode, access, share); fs = new FileStream(fullPath, mode, access, share);
return fs; return fs;
} }
catch (IOException) catch(IOException)
{ {
fs?.Dispose(); fs?.Dispose();
Thread.Sleep(50); Thread.Sleep(50);

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2019 Natalia Portillo // Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -45,60 +46,63 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UpdateController : Controller public class UpdateController : Controller
{ {
private readonly DicServerContext _ctx; readonly DicServerContext _ctx;
public UpdateController(DicServerContext ctx) public UpdateController(DicServerContext ctx) => _ctx = ctx;
{
_ctx = ctx;
}
/// <summary> /// <summary>Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server</summary>
/// Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server
/// </summary>
/// <returns>HTTP response</returns> /// <returns>HTTP response</returns>
[Route("api/update")] [Route("api/update"), HttpGet]
[HttpGet]
public ActionResult Update(long timestamp) public ActionResult Update(long timestamp)
{ {
var sync = new SyncDto(); var sync = new SyncDto();
var lastSync = DateHandlers.UnixToDateTime(timestamp); DateTime lastSync = DateHandlers.UnixToDateTime(timestamp);
sync.UsbVendors = new List<UsbVendorDto>(); sync.UsbVendors = new List<UsbVendorDto>();
foreach (var vendor in _ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync))
sync.UsbVendors.Add(new UsbVendorDto {VendorId = vendor.VendorId, Vendor = vendor.Vendor}); foreach(UsbVendor vendor in _ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync))
sync.UsbVendors.Add(new UsbVendorDto
{
VendorId = vendor.VendorId, Vendor = vendor.Vendor
});
sync.UsbProducts = new List<UsbProductDto>(); sync.UsbProducts = new List<UsbProductDto>();
foreach (var product in _ctx.UsbProducts.Include(p => p.Vendor).Where(p => p.ModifiedWhen > lastSync))
foreach(UsbProduct product in _ctx.UsbProducts.Include(p => p.Vendor).Where(p => p.ModifiedWhen > lastSync))
sync.UsbProducts.Add(new UsbProductDto sync.UsbProducts.Add(new UsbProductDto
{ {
Id = product.Id, Id = product.Id, Product = product.Product, ProductId = product.ProductId,
Product = product.Product,
ProductId = product.ProductId,
VendorId = product.Vendor.VendorId VendorId = product.Vendor.VendorId
}); });
sync.Offsets = new List<CdOffsetDto>(); sync.Offsets = new List<CdOffsetDto>();
foreach (var offset in _ctx.CdOffsets.Where(o => o.ModifiedWhen > lastSync))
foreach(CompactDiscOffset offset in _ctx.CdOffsets.Where(o => o.ModifiedWhen > lastSync))
sync.Offsets.Add(new CdOffsetDto(offset, offset.Id)); sync.Offsets.Add(new CdOffsetDto(offset, offset.Id));
sync.Devices = new List<DeviceDto>(); sync.Devices = new List<DeviceDto>();
foreach (var device in _ctx.Devices.Where(d => d.ModifiedWhen > lastSync).ToList())
sync.Devices.Add(new
DeviceDto(
JsonConvert.DeserializeObject<DeviceReportV2>(JsonConvert.SerializeObject(device,
Formatting.None,
new JsonSerializerSettings {ReferenceLoopHandling = ReferenceLoopHandling.Ignore})),
device.Id, device.OptimalMultipleSectorsRead));
var js = JsonSerializer.Create(); foreach(Device device in _ctx.Devices.Where(d => d.ModifiedWhen > lastSync).ToList())
var sw = new StringWriter(); sync.Devices.Add(new DeviceDto(JsonConvert.
DeserializeObject<DeviceReportV2>(JsonConvert.SerializeObject(device,
Formatting.
None,
new
JsonSerializerSettings
{
ReferenceLoopHandling
= ReferenceLoopHandling.
Ignore
})),
device.Id, device.OptimalMultipleSectorsRead));
JsonSerializer js = JsonSerializer.Create();
var sw = new StringWriter();
js.Serialize(sw, sync); js.Serialize(sw, sync);
return new ContentResult return new ContentResult
{ {
StatusCode = (int) HttpStatusCode.OK, StatusCode = (int)HttpStatusCode.OK, Content = sw.ToString(), ContentType = "application/json"
Content = sw.ToString(),
ContentType = "application/json"
}; };
} }
} }

View File

@@ -42,6 +42,7 @@ using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using MailKit.Net.Smtp; using MailKit.Net.Smtp;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MimeKit; using MimeKit;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -50,71 +51,80 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UploadReportController : Controller public class UploadReportController : Controller
{ {
private readonly IWebHostEnvironment _environment; readonly IWebHostEnvironment _environment;
private readonly DicServerContext ctx; readonly DicServerContext ctx;
public UploadReportController(IWebHostEnvironment environment, DicServerContext _ctx) public UploadReportController(IWebHostEnvironment environment, DicServerContext _ctx)
{ {
_environment = environment; _environment = environment;
ctx = _ctx; ctx = _ctx;
} }
/// <summary> /// <summary>Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server</summary>
/// Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server
/// </summary>
/// <returns>HTTP response</returns> /// <returns>HTTP response</returns>
[Route("api/uploadreport")] [Route("api/uploadreport"), HttpPost]
[HttpPost]
public async Task<IActionResult> UploadReport() public async Task<IActionResult> UploadReport()
{ {
var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
};
try try
{ {
var newReport = new DeviceReport(); var newReport = new DeviceReport();
var request = HttpContext.Request; HttpRequest request = HttpContext.Request;
var xs = new XmlSerializer(newReport.GetType()); var xs = new XmlSerializer(newReport.GetType());
newReport = (DeviceReport) xs.Deserialize(
new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if (newReport == null) newReport =
(DeviceReport)
xs.Deserialize(new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if(newReport == null)
{ {
response.Content = "notstats"; response.Content = "notstats";
return response; return response;
} }
var reportV2 = new DeviceReportV2(newReport); var reportV2 = new DeviceReportV2(newReport);
var jsonSw = new StringWriter(); var jsonSw = new StringWriter();
jsonSw.Write(JsonConvert.SerializeObject(reportV2, Formatting.Indented,
new JsonSerializerSettings jsonSw.Write(JsonConvert.SerializeObject(reportV2, Formatting.Indented, new JsonSerializerSettings
{ {
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
})); }));
var reportV2String = jsonSw.ToString();
string reportV2String = jsonSw.ToString();
jsonSw.Close(); jsonSw.Close();
ctx.Reports.Add(new UploadedReport(reportV2)); ctx.Reports.Add(new UploadedReport(reportV2));
ctx.SaveChanges(); ctx.SaveChanges();
var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportV2String)); var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportV2String));
var pgpOut = new MemoryStream(); var pgpOut = new MemoryStream();
var pgp = new ChoPGPEncryptDecrypt(); var pgp = new ChoPGPEncryptDecrypt();
pgp.Encrypt(pgpIn, pgpOut, pgp.Encrypt(pgpIn, pgpOut,
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"public.asc")); "public.asc"));
pgpOut.Position = 0; pgpOut.Position = 0;
reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray()); reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray());
var message = new MimeMessage var message = new MimeMessage
{ {
Subject = "New device report (old version)", Subject = "New device report (old version)", Body = new TextPart("plain")
Body = new TextPart("plain") {Text = reportV2String} {
Text = reportV2String
}
}; };
message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com")); message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com"));
message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com")); message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com"));
using (var client = new SmtpClient()) using(var client = new SmtpClient())
{ {
client.Connect("mail.claunia.com", 25, false); client.Connect("mail.claunia.com", 25, false);
client.Send(message); client.Send(message);
@@ -122,63 +132,74 @@ namespace DiscImageChef.Server.Controllers
} }
response.Content = "ok"; response.Content = "ok";
return response; return response;
} }
// ReSharper disable once RedundantCatchClause // ReSharper disable once RedundantCatchClause
catch catch
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
response.Content = "error"; response.Content = "error";
return response; return response;
} }
} }
/// <summary> /// <summary>Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server</summary>
/// Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server
/// </summary>
/// <returns>HTTP response</returns> /// <returns>HTTP response</returns>
[Route("api/uploadreportv2")] [Route("api/uploadreportv2"), HttpPost]
[HttpPost]
public async Task<IActionResult> UploadReportV2() public async Task<IActionResult> UploadReportV2()
{ {
var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
};
try try
{ {
var request = HttpContext.Request; HttpRequest request = HttpContext.Request;
var sr = new StreamReader(request.Body); var sr = new StreamReader(request.Body);
var reportJson = await sr.ReadToEndAsync(); string reportJson = await sr.ReadToEndAsync();
var newReport = JsonConvert.DeserializeObject<DeviceReportV2>(reportJson); var newReport = JsonConvert.DeserializeObject<DeviceReportV2>(reportJson);
if (newReport == null) if(newReport == null)
{ {
response.Content = "notstats"; response.Content = "notstats";
return response; return response;
} }
ctx.Reports.Add(new UploadedReport(newReport)); ctx.Reports.Add(new UploadedReport(newReport));
ctx.SaveChanges(); ctx.SaveChanges();
var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportJson)); var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportJson));
var pgpOut = new MemoryStream(); var pgpOut = new MemoryStream();
var pgp = new ChoPGPEncryptDecrypt(); var pgp = new ChoPGPEncryptDecrypt();
pgp.Encrypt(pgpIn, pgpOut, pgp.Encrypt(pgpIn, pgpOut,
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"public.asc")); "public.asc"));
pgpOut.Position = 0; pgpOut.Position = 0;
reportJson = Encoding.UTF8.GetString(pgpOut.ToArray()); reportJson = Encoding.UTF8.GetString(pgpOut.ToArray());
var message = new MimeMessage var message = new MimeMessage
{ {
Subject = "New device report", Body = new TextPart("plain") {Text = reportJson} Subject = "New device report", Body = new TextPart("plain")
{
Text = reportJson
}
}; };
message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com")); message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com"));
message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com")); message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com"));
using (var client = new SmtpClient()) using(var client = new SmtpClient())
{ {
client.Connect("mail.claunia.com", 25, false); client.Connect("mail.claunia.com", 25, false);
client.Send(message); client.Send(message);
@@ -186,15 +207,19 @@ namespace DiscImageChef.Server.Controllers
} }
response.Content = "ok"; response.Content = "ok";
return response; return response;
} }
// ReSharper disable once RedundantCatchClause // ReSharper disable once RedundantCatchClause
catch catch
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
response.Content = "error"; response.Content = "error";
return response; return response;
} }
} }

View File

@@ -41,6 +41,7 @@ using System.Xml.Serialization;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem; using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
@@ -50,176 +51,216 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UploadStatsController : Controller public class UploadStatsController : Controller
{ {
private readonly DicServerContext _ctx; readonly DicServerContext _ctx;
private IWebHostEnvironment _environment; IWebHostEnvironment _environment;
public UploadStatsController(IWebHostEnvironment environment, DicServerContext ctx) public UploadStatsController(IWebHostEnvironment environment, DicServerContext ctx)
{ {
_environment = environment; _environment = environment;
_ctx = ctx; _ctx = ctx;
} }
/// <summary> /// <summary>
/// Receives statistics from DiscImageChef.Core, processes them and adds them to a server-side global statistics XML /// Receives statistics from DiscImageChef.Core, processes them and adds them to a server-side global statistics
/// XML
/// </summary> /// </summary>
/// <returns>HTTP response</returns> /// <returns>HTTP response</returns>
[Route("api/uploadstats")] [Route("api/uploadstats"), HttpPost]
[HttpPost]
public async Task<IActionResult> UploadStats() public async Task<IActionResult> UploadStats()
{ {
var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
};
try try
{ {
var newStats = new Stats(); var newStats = new Stats();
var request = HttpContext.Request; HttpRequest request = HttpContext.Request;
var xs = new XmlSerializer(newStats.GetType()); var xs = new XmlSerializer(newStats.GetType());
newStats = (Stats) xs.Deserialize(
new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if (newStats == null) newStats =
(Stats)xs.Deserialize(new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if(newStats == null)
{ {
response.Content = "notstats"; response.Content = "notstats";
return response; return response;
} }
StatsConverter.Convert(newStats); StatsConverter.Convert(newStats);
response.Content = "ok"; response.Content = "ok";
return response; return response;
} }
catch (Exception ex) catch(Exception ex)
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
response.Content = "error"; response.Content = "error";
return response; return response;
} }
} }
/// <summary> /// <summary>Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server</summary>
/// Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server
/// </summary>
/// <returns>HTTP response</returns> /// <returns>HTTP response</returns>
[Route("api/uploadstatsv2")] [Route("api/uploadstatsv2"), HttpPost]
[HttpPost]
public async Task<IActionResult> UploadStatsV2() public async Task<IActionResult> UploadStatsV2()
{ {
var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
};
try try
{ {
var request = HttpContext.Request; HttpRequest request = HttpContext.Request;
var sr = new StreamReader(request.Body); var sr = new StreamReader(request.Body);
var statsString = await sr.ReadToEndAsync(); string statsString = await sr.ReadToEndAsync();
var newstats = JsonConvert.DeserializeObject<StatsDto>(statsString); var newstats = JsonConvert.DeserializeObject<StatsDto>(statsString);
if (newstats == null) if(newstats == null)
{ {
response.Content = "notstats"; response.Content = "notstats";
return response; return response;
} }
if (newstats.Commands != null) if(newstats.Commands != null)
foreach (var nvs in newstats.Commands) foreach(NameValueStats nvs in newstats.Commands)
{ {
var existing = _ctx.Commands.FirstOrDefault(c => c.Name == nvs.name); Command existing = _ctx.Commands.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Commands.Add(new Command {Name = nvs.name, Count = nvs.Value}); if(existing == null)
else existing.Count += nvs.Value; _ctx.Commands.Add(new Command
{
Name = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.Versions != null) if(newstats.Versions != null)
foreach (var nvs in newstats.Versions) foreach(NameValueStats nvs in newstats.Versions)
{ {
var existing = _ctx.Versions.FirstOrDefault(c => c.Value == nvs.name); Version existing = _ctx.Versions.FirstOrDefault(c => c.Value == nvs.name);
if (existing == null) _ctx.Versions.Add(new Version {Value = nvs.name, Count = nvs.Value}); if(existing == null)
else existing.Count += nvs.Value; _ctx.Versions.Add(new Version
{
Value = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.Filesystems != null) if(newstats.Filesystems != null)
foreach (var nvs in newstats.Filesystems) foreach(NameValueStats nvs in newstats.Filesystems)
{ {
var existing = _ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name); Filesystem existing = _ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Filesystems.Add(new Filesystem {Name = nvs.name, Count = nvs.Value}); if(existing == null)
else existing.Count += nvs.Value; _ctx.Filesystems.Add(new Filesystem
{
Name = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.Partitions != null) if(newstats.Partitions != null)
foreach (var nvs in newstats.Partitions) foreach(NameValueStats nvs in newstats.Partitions)
{ {
var existing = _ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name); Partition existing = _ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Partitions.Add(new Partition {Name = nvs.name, Count = nvs.Value}); if(existing == null)
else existing.Count += nvs.Value; _ctx.Partitions.Add(new Partition
{
Name = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.MediaFormats != null) if(newstats.MediaFormats != null)
foreach (var nvs in newstats.MediaFormats) foreach(NameValueStats nvs in newstats.MediaFormats)
{ {
var existing = _ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name); MediaFormat existing = _ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) if(existing == null)
_ctx.MediaFormats.Add(new MediaFormat {Name = nvs.name, Count = nvs.Value}); _ctx.MediaFormats.Add(new MediaFormat
else existing.Count += nvs.Value; {
Name = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.Filters != null) if(newstats.Filters != null)
foreach (var nvs in newstats.Filters) foreach(NameValueStats nvs in newstats.Filters)
{ {
var existing = _ctx.Filters.FirstOrDefault(c => c.Name == nvs.name); Filter existing = _ctx.Filters.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Filters.Add(new Filter {Name = nvs.name, Count = nvs.Value}); if(existing == null)
else existing.Count += nvs.Value; _ctx.Filters.Add(new Filter
{
Name = nvs.name, Count = nvs.Value
});
else
existing.Count += nvs.Value;
} }
if (newstats.OperatingSystems != null) if(newstats.OperatingSystems != null)
foreach (var operatingSystem in newstats.OperatingSystems) foreach(OsStats operatingSystem in newstats.OperatingSystems)
{ {
var existing = OperatingSystem existing =
_ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name && _ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
c.Version == operatingSystem.version); c.Version == operatingSystem.version);
if (existing == null) if(existing == null)
_ctx.OperatingSystems.Add(new OperatingSystem _ctx.OperatingSystems.Add(new OperatingSystem
{ {
Name = operatingSystem.name, Name = operatingSystem.name, Version = operatingSystem.version,
Version = operatingSystem.version,
Count = operatingSystem.Value Count = operatingSystem.Value
}); });
else existing.Count += operatingSystem.Value; else
existing.Count += operatingSystem.Value;
} }
if (newstats.Medias != null) if(newstats.Medias != null)
foreach (var media in newstats.Medias) foreach(MediaStats media in newstats.Medias)
{ {
var existing = _ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real); Media existing = _ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real);
if (existing == null) if(existing == null)
_ctx.Medias.Add(new Media {Type = media.type, Real = media.real, Count = media.Value}); _ctx.Medias.Add(new Media
else existing.Count += media.Value; {
Type = media.type, Real = media.real, Count = media.Value
});
else
existing.Count += media.Value;
} }
if (newstats.Devices != null) if(newstats.Devices != null)
foreach (var device in newstats.Devices) foreach(DeviceStats device in newstats.Devices)
{ {
var existing = DeviceStat existing =
_ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus && _ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus &&
c.Manufacturer == device.Manufacturer && c.Manufacturer == device.Manufacturer &&
c.Model == device.Model && c.Model == device.Model &&
c.Revision == device.Revision); c.Revision == device.Revision);
if (existing == null) if(existing == null)
_ctx.DeviceStats.Add(new DeviceStat _ctx.DeviceStats.Add(new DeviceStat
{ {
Bus = device.Bus, Bus = device.Bus, Manufacturer = device.Manufacturer, Model = device.Model,
Manufacturer = device.Manufacturer,
Model = device.Model,
Revision = device.Revision Revision = device.Revision
}); });
} }
@@ -227,32 +268,40 @@ namespace DiscImageChef.Server.Controllers
_ctx.SaveChanges(); _ctx.SaveChanges();
response.Content = "ok"; response.Content = "ok";
return response; return response;
} }
// ReSharper disable once RedundantCatchClause // ReSharper disable once RedundantCatchClause
catch catch
{ {
#if DEBUG #if DEBUG
if (Debugger.IsAttached) throw; if(Debugger.IsAttached)
#endif throw;
#endif
response.Content = "error"; response.Content = "error";
return response; return response;
} }
} }
private FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share) FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
{ {
for (var numTries = 0; numTries < 100; numTries++) for(int numTries = 0; numTries < 100; numTries++)
{ {
FileStream fs = null; FileStream fs = null;
try try
{ {
fs = new FileStream(fullPath, mode, access, share); fs = new FileStream(fullPath, mode, access, share);
return fs; return fs;
} }
catch (IOException) catch(IOException)
{ {
if (fs != null) fs.Dispose(); if(fs != null)
fs.Dispose();
Thread.Sleep(50); Thread.Sleep(50);
} }
} }

View File

@@ -6,379 +6,160 @@ namespace DiscImageChef.Server.Migrations
{ {
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn("ProductIDSql", "Usb");
name: "ProductIDSql",
table: "Usb");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("VendorIDSql", "Usb");
name: "VendorIDSql",
table: "Usb");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BlockSizeSql", "TestedMedia");
name: "BlockSizeSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BlocksSql", "TestedMedia");
name: "BlocksSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LBA48SectorsSql", "TestedMedia");
name: "LBA48SectorsSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LBASectorsSql", "TestedMedia");
name: "LBASectorsSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LogicalAlignmentSql", "TestedMedia");
name: "LogicalAlignmentSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LongBlockSizeSql", "TestedMedia");
name: "LongBlockSizeSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("NominalRotationRateSql", "TestedMedia");
name: "NominalRotationRateSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("PhysicalBlockSizeSql", "TestedMedia");
name: "PhysicalBlockSizeSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("UnformattedBPSSql", "TestedMedia");
name: "UnformattedBPSSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("UnformattedBPTSql", "TestedMedia");
name: "UnformattedBPTSql",
table: "TestedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BitsPerMmSql", "SupportedDensity");
name: "BitsPerMmSql",
table: "SupportedDensity");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("CapacitySql", "SupportedDensity");
name: "CapacitySql",
table: "SupportedDensity");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("TracksSql", "SupportedDensity");
name: "TracksSql",
table: "SupportedDensity");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("WidthSql", "SupportedDensity");
name: "WidthSql",
table: "SupportedDensity");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LengthSql", "SscSupportedMedia");
name: "LengthSql",
table: "SscSupportedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("WidthSql", "SscSupportedMedia");
name: "WidthSql",
table: "SscSupportedMedia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("MaxBlockLengthSql", "Ssc");
name: "MaxBlockLengthSql",
table: "Ssc");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("MinBlockLengthSql", "Ssc");
name: "MinBlockLengthSql",
table: "Ssc");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("CardCodeSql", "Pcmcia");
name: "CardCodeSql",
table: "Pcmcia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("ManufacturerCodeSql", "Pcmcia");
name: "ManufacturerCodeSql",
table: "Pcmcia");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BlocksPerReadableUnitSql", "MmcFeatures");
name: "BlocksPerReadableUnitSql",
table: "MmcFeatures");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("LogicalBlockSizeSql", "MmcFeatures");
name: "LogicalBlockSizeSql",
table: "MmcFeatures");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("PhysicalInterfaceStandardNumberSql", "MmcFeatures");
name: "PhysicalInterfaceStandardNumberSql",
table: "MmcFeatures");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("VolumeLevelsSql", "MmcFeatures");
name: "VolumeLevelsSql",
table: "MmcFeatures");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("ProductIDSql", "FireWire");
name: "ProductIDSql",
table: "FireWire");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("VendorIDSql", "FireWire");
name: "VendorIDSql",
table: "FireWire");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("CylindersSql", "Chs");
name: "CylindersSql",
table: "Chs");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("HeadsSql", "Chs");
name: "HeadsSql",
table: "Chs");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("SectorsSql", "Chs");
name: "SectorsSql",
table: "Chs");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BlockLengthSql", "BlockDescriptor");
name: "BlockLengthSql",
table: "BlockDescriptor");
migrationBuilder.DropColumn( migrationBuilder.DropColumn("BlocksSql", "BlockDescriptor");
name: "BlocksSql",
table: "BlockDescriptor");
migrationBuilder.AlterColumn<ushort>( migrationBuilder.AlterColumn<ushort>("VendorId", "UsbVendors", nullable: false, oldClrType: typeof(int),
name: "VendorId", oldType: "int");
table: "UsbVendors",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<ushort>( migrationBuilder.AlterColumn<ushort>("ProductId", "UsbProducts", nullable: false, oldClrType: typeof(int),
name: "ProductId", oldType: "int");
table: "UsbProducts",
nullable: false,
oldClrType: typeof(int),
oldType: "int");
} }
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>("VendorId", "UsbVendors", "int", nullable: false,
name: "VendorId", oldClrType: typeof(ushort));
table: "UsbVendors",
type: "int",
nullable: false,
oldClrType: typeof(ushort));
migrationBuilder.AlterColumn<int>( migrationBuilder.AlterColumn<int>("ProductId", "UsbProducts", "int", nullable: false,
name: "ProductId", oldClrType: typeof(ushort));
table: "UsbProducts",
type: "int",
nullable: false,
oldClrType: typeof(ushort));
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("ProductIDSql", "Usb", "smallint", nullable: false,
name: "ProductIDSql", defaultValue: (short)0);
table: "Usb",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("VendorIDSql", "Usb", "smallint", nullable: false,
name: "VendorIDSql", defaultValue: (short)0);
table: "Usb",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("BlockSizeSql", "TestedMedia", "int", nullable: true);
name: "BlockSizeSql",
table: "TestedMedia",
type: "int",
nullable: true);
migrationBuilder.AddColumn<long>( migrationBuilder.AddColumn<long>("BlocksSql", "TestedMedia", "bigint", nullable: true);
name: "BlocksSql",
table: "TestedMedia",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<long>( migrationBuilder.AddColumn<long>("LBA48SectorsSql", "TestedMedia", "bigint", nullable: true);
name: "LBA48SectorsSql",
table: "TestedMedia",
type: "bigint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("LBASectorsSql", "TestedMedia", "int", nullable: true);
name: "LBASectorsSql",
table: "TestedMedia",
type: "int",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("LogicalAlignmentSql", "TestedMedia", "smallint", nullable: true);
name: "LogicalAlignmentSql",
table: "TestedMedia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("LongBlockSizeSql", "TestedMedia", "int", nullable: true);
name: "LongBlockSizeSql",
table: "TestedMedia",
type: "int",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("NominalRotationRateSql", "TestedMedia", "smallint", nullable: true);
name: "NominalRotationRateSql",
table: "TestedMedia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("PhysicalBlockSizeSql", "TestedMedia", "int", nullable: true);
name: "PhysicalBlockSizeSql",
table: "TestedMedia",
type: "int",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("UnformattedBPSSql", "TestedMedia", "smallint", nullable: true);
name: "UnformattedBPSSql",
table: "TestedMedia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("UnformattedBPTSql", "TestedMedia", "smallint", nullable: true);
name: "UnformattedBPTSql",
table: "TestedMedia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("BitsPerMmSql", "SupportedDensity", "int", nullable: false,
name: "BitsPerMmSql", defaultValue: 0);
table: "SupportedDensity",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("CapacitySql", "SupportedDensity", "int", nullable: false, defaultValue: 0);
name: "CapacitySql",
table: "SupportedDensity",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("TracksSql", "SupportedDensity", "smallint", nullable: false,
name: "TracksSql", defaultValue: (short)0);
table: "SupportedDensity",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("WidthSql", "SupportedDensity", "smallint", nullable: false,
name: "WidthSql", defaultValue: (short)0);
table: "SupportedDensity",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("LengthSql", "SscSupportedMedia", "smallint", nullable: false,
name: "LengthSql", defaultValue: (short)0);
table: "SscSupportedMedia",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("WidthSql", "SscSupportedMedia", "smallint", nullable: false,
name: "WidthSql", defaultValue: (short)0);
table: "SscSupportedMedia",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("MaxBlockLengthSql", "Ssc", "int", nullable: true);
name: "MaxBlockLengthSql",
table: "Ssc",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("MinBlockLengthSql", "Ssc", "int", nullable: true);
name: "MinBlockLengthSql",
table: "Ssc",
type: "int",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("CardCodeSql", "Pcmcia", "smallint", nullable: true);
name: "CardCodeSql",
table: "Pcmcia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("ManufacturerCodeSql", "Pcmcia", "smallint", nullable: true);
name: "ManufacturerCodeSql",
table: "Pcmcia",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("BlocksPerReadableUnitSql", "MmcFeatures", "smallint", nullable: true);
name: "BlocksPerReadableUnitSql",
table: "MmcFeatures",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("LogicalBlockSizeSql", "MmcFeatures", "int", nullable: true);
name: "LogicalBlockSizeSql",
table: "MmcFeatures",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("PhysicalInterfaceStandardNumberSql", "MmcFeatures", "int", nullable: true);
name: "PhysicalInterfaceStandardNumberSql",
table: "MmcFeatures",
type: "int",
nullable: true);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("VolumeLevelsSql", "MmcFeatures", "smallint", nullable: true);
name: "VolumeLevelsSql",
table: "MmcFeatures",
type: "smallint",
nullable: true);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("ProductIDSql", "FireWire", "int", nullable: false, defaultValue: 0);
name: "ProductIDSql",
table: "FireWire",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("VendorIDSql", "FireWire", "int", nullable: false, defaultValue: 0);
name: "VendorIDSql",
table: "FireWire",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("CylindersSql", "Chs", "smallint", nullable: false,
name: "CylindersSql", defaultValue: (short)0);
table: "Chs",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("HeadsSql", "Chs", "smallint", nullable: false, defaultValue: (short)0);
name: "HeadsSql",
table: "Chs",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<short>( migrationBuilder.AddColumn<short>("SectorsSql", "Chs", "smallint", nullable: false, defaultValue: (short)0);
name: "SectorsSql",
table: "Chs",
type: "smallint",
nullable: false,
defaultValue: (short)0);
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>("BlockLengthSql", "BlockDescriptor", "int", nullable: true);
name: "BlockLengthSql",
table: "BlockDescriptor",
type: "int",
nullable: true);
migrationBuilder.AddColumn<long>( migrationBuilder.AddColumn<long>("BlocksSql", "BlockDescriptor", "bigint", nullable: true);
name: "BlocksSql",
table: "BlockDescriptor",
type: "bigint",
nullable: true);
} }
} }
} }

View File

@@ -38,33 +38,31 @@ namespace DiscImageChef.Server.Models
{ {
public class CompactDiscOffset : CdOffset public class CompactDiscOffset : CdOffset
{ {
public CompactDiscOffset() public CompactDiscOffset() { }
{
}
public CompactDiscOffset(string manufacturer, string model, short offset, int submissions, float agreement) public CompactDiscOffset(string manufacturer, string model, short offset, int submissions, float agreement)
{ {
Manufacturer = manufacturer; Manufacturer = manufacturer;
Model = model; Model = model;
Offset = offset; Offset = offset;
Submissions = submissions; Submissions = submissions;
Agreement = agreement; Agreement = agreement;
AddedWhen = ModifiedWhen = DateTime.UtcNow; AddedWhen = ModifiedWhen = DateTime.UtcNow;
} }
public CompactDiscOffset(CdOffset offset) public CompactDiscOffset(CdOffset offset)
{ {
Manufacturer = offset.Manufacturer; Manufacturer = offset.Manufacturer;
Model = offset.Model; Model = offset.Model;
Offset = offset.Offset; Offset = offset.Offset;
Submissions = offset.Submissions; Submissions = offset.Submissions;
Agreement = offset.Agreement; Agreement = offset.Agreement;
AddedWhen = ModifiedWhen = DateTime.UtcNow; AddedWhen = ModifiedWhen = DateTime.UtcNow;
} }
public int Id { get; set; } public int Id { get; set; }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; } public DateTime ModifiedWhen { get; set; }
public virtual ICollection<Device> Devices { get; set; } public virtual ICollection<Device> Devices { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class Command public class Command
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2019 Natalia Portillo // Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System.Data.Common;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@@ -37,36 +38,32 @@ namespace DiscImageChef.Server.Models
{ {
public sealed class DicServerContext : DbContext public sealed class DicServerContext : DbContext
{ {
public DicServerContext() public DicServerContext() { }
{
}
public DicServerContext(DbContextOptions<DicServerContext> options) : base(options) public DicServerContext(DbContextOptions<DicServerContext> options) : base(options) { }
{
}
public DbSet<Device> Devices { get; set; } public DbSet<Device> Devices { get; set; }
public DbSet<UploadedReport> Reports { get; set; } public DbSet<UploadedReport> Reports { get; set; }
public DbSet<Command> Commands { get; set; } public DbSet<Command> Commands { get; set; }
public DbSet<DeviceStat> DeviceStats { get; set; } public DbSet<DeviceStat> DeviceStats { get; set; }
public DbSet<Filesystem> Filesystems { get; set; } public DbSet<Filesystem> Filesystems { get; set; }
public DbSet<Filter> Filters { get; set; } public DbSet<Filter> Filters { get; set; }
public DbSet<Media> Medias { get; set; } public DbSet<Media> Medias { get; set; }
public DbSet<MediaFormat> MediaFormats { get; set; } public DbSet<MediaFormat> MediaFormats { get; set; }
public DbSet<OperatingSystem> OperatingSystems { get; set; } public DbSet<OperatingSystem> OperatingSystems { get; set; }
public DbSet<Partition> Partitions { get; set; } public DbSet<Partition> Partitions { get; set; }
public DbSet<Version> Versions { get; set; } public DbSet<Version> Versions { get; set; }
public DbSet<UsbVendor> UsbVendors { get; set; } public DbSet<UsbVendor> UsbVendors { get; set; }
public DbSet<UsbProduct> UsbProducts { get; set; } public DbSet<UsbProduct> UsbProducts { get; set; }
public DbSet<CompactDiscOffset> CdOffsets { get; set; } public DbSet<CompactDiscOffset> CdOffsets { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
if (optionsBuilder.IsConfigured) return; if(optionsBuilder.IsConfigured)
return;
IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); IConfigurationRoot configuration = builder.Build();
var configuration = builder.Build();
optionsBuilder.UseMySql(configuration.GetConnectionString("DefaultConnection")); optionsBuilder.UseMySql(configuration.GetConnectionString("DefaultConnection"));
} }
@@ -86,16 +83,17 @@ namespace DiscImageChef.Server.Models
internal static bool TableExists(string tableName) internal static bool TableExists(string tableName)
{ {
using (var db = new DicServerContext()) using(var db = new DicServerContext())
{ {
var connection = db.Database.GetDbConnection(); DbConnection connection = db.Database.GetDbConnection();
connection.Open(); connection.Open();
var command = connection.CreateCommand(); DbCommand command = connection.CreateCommand();
command.CommandText = command.CommandText =
$"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=\"{tableName}\""; $"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=\"{tableName}\"";
var result = (long) command.ExecuteScalar(); long result = (long)command.ExecuteScalar();
return result != 0; return result != 0;
} }

View File

@@ -38,34 +38,32 @@ namespace DiscImageChef.Server.Models
{ {
public class Device : DeviceReportV2 public class Device : DeviceReportV2
{ {
public Device() public Device() => AddedWhen = DateTime.UtcNow;
{
AddedWhen = DateTime.UtcNow;
}
public Device(DeviceReportV2 report) public Device(DeviceReportV2 report)
{ {
ATA = report.ATA; ATA = report.ATA;
ATAPI = report.ATAPI; ATAPI = report.ATAPI;
CompactFlash = report.CompactFlash; CompactFlash = report.CompactFlash;
FireWire = report.FireWire; FireWire = report.FireWire;
AddedWhen = DateTime.UtcNow; AddedWhen = DateTime.UtcNow;
ModifiedWhen = DateTime.UtcNow; ModifiedWhen = DateTime.UtcNow;
MultiMediaCard = report.MultiMediaCard; MultiMediaCard = report.MultiMediaCard;
PCMCIA = report.PCMCIA; PCMCIA = report.PCMCIA;
SCSI = report.SCSI; SCSI = report.SCSI;
SecureDigital = report.SecureDigital; SecureDigital = report.SecureDigital;
USB = report.USB; USB = report.USB;
Manufacturer = report.Manufacturer; Manufacturer = report.Manufacturer;
Model = report.Model; Model = report.Model;
Revision = report.Revision; Revision = report.Revision;
Type = report.Type; Type = report.Type;
} }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime? ModifiedWhen { get; set; } public DateTime? ModifiedWhen { get; set; }
public virtual CompactDiscOffset CdOffset { get; set; } public virtual CompactDiscOffset CdOffset { get; set; }
[DefaultValue(0)] public int OptimalMultipleSectorsRead { get; set; } [DefaultValue(0)]
public int OptimalMultipleSectorsRead { get; set; }
} }
} }

View File

@@ -35,9 +35,9 @@ namespace DiscImageChef.Server.Models
public class DeviceItem public class DeviceItem
{ {
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
public string Model { get; set; } public string Model { get; set; }
public string Revision { get; set; } public string Revision { get; set; }
public string Bus { get; set; } public string Bus { get; set; }
public int ReportId { get; set; } public int ReportId { get; set; }
} }
} }

View File

@@ -36,12 +36,13 @@ namespace DiscImageChef.Server.Models
{ {
public class DeviceStat public class DeviceStat
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
public string Model { get; set; } public string Model { get; set; }
public string Revision { get; set; } public string Revision { get; set; }
public string Bus { get; set; } public string Bus { get; set; }
public virtual Device Report { get; set; } public virtual Device Report { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class Filesystem public class Filesystem
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class Filter public class Filter
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -36,10 +36,11 @@ namespace DiscImageChef.Server.Models
{ {
public class Media public class Media
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Type { get; set; } public string Type { get; set; }
public bool Real { get; set; } public bool Real { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class MediaFormat public class MediaFormat
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -34,8 +34,8 @@ namespace DiscImageChef.Server.Models
{ {
public class MediaItem public class MediaItem
{ {
public string Type { get; set; } public string Type { get; set; }
public string SubType { get; set; } public string SubType { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -36,10 +36,11 @@ namespace DiscImageChef.Server.Models
{ {
public class OperatingSystem public class OperatingSystem
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Version { get; set; } public string Version { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class Partition public class Partition
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -37,27 +37,24 @@ namespace DiscImageChef.Server.Models
{ {
public class UploadedReport : DeviceReportV2 public class UploadedReport : DeviceReportV2
{ {
public UploadedReport() public UploadedReport() => UploadedWhen = DateTime.UtcNow;
{
UploadedWhen = DateTime.UtcNow;
}
public UploadedReport(DeviceReportV2 report) public UploadedReport(DeviceReportV2 report)
{ {
ATA = report.ATA; ATA = report.ATA;
ATAPI = report.ATAPI; ATAPI = report.ATAPI;
CompactFlash = report.CompactFlash; CompactFlash = report.CompactFlash;
FireWire = report.FireWire; FireWire = report.FireWire;
UploadedWhen = DateTime.UtcNow; UploadedWhen = DateTime.UtcNow;
MultiMediaCard = report.MultiMediaCard; MultiMediaCard = report.MultiMediaCard;
PCMCIA = report.PCMCIA; PCMCIA = report.PCMCIA;
SCSI = report.SCSI; SCSI = report.SCSI;
SecureDigital = report.SecureDigital; SecureDigital = report.SecureDigital;
USB = report.USB; USB = report.USB;
Manufacturer = report.Manufacturer; Manufacturer = report.Manufacturer;
Model = report.Model; Model = report.Model;
Revision = report.Revision; Revision = report.Revision;
Type = report.Type; Type = report.Type;
} }
public DateTime UploadedWhen { get; set; } public DateTime UploadedWhen { get; set; }

View File

@@ -38,26 +38,26 @@ namespace DiscImageChef.Server.Models
{ {
public class UsbProduct public class UsbProduct
{ {
public UsbProduct() public UsbProduct() { }
{
}
public UsbProduct(UsbVendor vendor, ushort id, string product) public UsbProduct(UsbVendor vendor, ushort id, string product)
{ {
ProductId = id; ProductId = id;
Product = product; Product = product;
AddedWhen = ModifiedWhen = DateTime.UtcNow; AddedWhen = ModifiedWhen = DateTime.UtcNow;
Vendor = vendor; Vendor = vendor;
} }
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public ushort ProductId { get; set; } public ushort ProductId { get; set; }
public string Product { get; set; } public string Product { get; set; }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; } public DateTime ModifiedWhen { get; set; }
public int VendorId { get; set; } public int VendorId { get; set; }
[JsonIgnore] public virtual UsbVendor Vendor { get; set; } [JsonIgnore]
public virtual UsbVendor Vendor { get; set; }
} }
} }

View File

@@ -39,24 +39,24 @@ namespace DiscImageChef.Server.Models
{ {
public class UsbVendor public class UsbVendor
{ {
public UsbVendor() public UsbVendor() { }
{
}
public UsbVendor(ushort id, string vendor) public UsbVendor(ushort id, string vendor)
{ {
VendorId = id; VendorId = id;
Vendor = vendor; Vendor = vendor;
AddedWhen = ModifiedWhen = DateTime.UtcNow; AddedWhen = ModifiedWhen = DateTime.UtcNow;
} }
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public ushort VendorId { get; set; } public ushort VendorId { get; set; }
public string Vendor { get; set; } public string Vendor { get; set; }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; } public DateTime ModifiedWhen { get; set; }
[JsonIgnore] public virtual ICollection<UsbProduct> Products { get; set; } [JsonIgnore]
public virtual ICollection<UsbProduct> Products { get; set; }
} }
} }

View File

@@ -36,9 +36,10 @@ namespace DiscImageChef.Server.Models
{ {
public class Version public class Version
{ {
[Key] public int Id { get; set; } [Key]
public int Id { get; set; }
public string Value { get; set; } public string Value { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }
} }

View File

@@ -19,72 +19,71 @@ namespace DiscImageChef.Server
System.Console.Clear(); System.Console.Clear();
System.Console.Write( System.Console.Write(
"\u001b[32m . ,,\n" + "\u001b[32m . ,,\n" +
"\u001b[32m ;,. '0d.\n" + "\u001b[32m ;,. '0d.\n" +
"\u001b[32m oc oWd \u001b[31m" + "\u001b[32m oc oWd \u001b[31m" +
@"__/\\\\\\\\\\\\_____/\\\\\\\\\\\________/\\\\\\\\\_ " + @"__/\\\\\\\\\\\\_____/\\\\\\\\\\\________/\\\\\\\\\_ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m ;X. 'WN' \u001b[31m" + "\u001b[32m ;X. 'WN' \u001b[31m" +
@" _\/\\\////////\\\__\/////\\\///______/\\\////////__ " + @" _\/\\\////////\\\__\/////\\\///______/\\\////////__ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m oMo cMM: \u001b[31m" + "\u001b[32m oMo cMM: \u001b[31m" +
@" _\/\\\______\//\\\_____\/\\\_______/\\\/___________ " + @" _\/\\\______\//\\\_____\/\\\_______/\\\/___________ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m ;MM. .MMM; \u001b[31m" + "\u001b[32m ;MM. .MMM; \u001b[31m" +
@" _\/\\\_______\/\\\_____\/\\\______/\\\_____________ " + @" _\/\\\_______\/\\\_____\/\\\______/\\\_____________ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m NMM WMMW \u001b[31m" + "\u001b[32m NMM WMMW \u001b[31m" +
@" _\/\\\_______\/\\\_____\/\\\_____\/\\\_____________ " + @" _\/\\\_______\/\\\_____\/\\\_____\/\\\_____________ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m 'MMM MMMM; \u001b[31m" + "\u001b[32m 'MMM MMMM; \u001b[31m" +
@" _\/\\\_______\/\\\_____\/\\\_____\//\\\____________ " + @" _\/\\\_______\/\\\_____\/\\\_____\//\\\____________ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m ,MMM: dMMMM: \u001b[31m" + "\u001b[32m ,MMM: dMMMM: \u001b[31m" +
@" _\/\\\_______/\\\______\/\\\______\///\\\__________ " + @" _\/\\\_______/\\\______\/\\\______\///\\\__________ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m .MMMW. :MMMMM. \u001b[31m" + "\u001b[32m .MMMW. :MMMMM. \u001b[31m" +
@" _\/\\\\\\\\\\\\/____/\\\\\\\\\\\____\////\\\\\\\\\_ " + @" _\/\\\\\\\\\\\\/____/\\\\\\\\\\\____\////\\\\\\\\\_ " +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m XMMMW: .:xKNMMMMMMN0d, lMMMMMd \u001b[31m" + "\u001b[32m XMMMW: .:xKNMMMMMMN0d, lMMMMMd \u001b[31m" +
@" _\////////////_____\///////////________\/////////__" + @" _\////////////_____\///////////________\/////////__" +
"\n\u001b[0m" + "\n\u001b[0m" +
"\u001b[32m :MMMMMK; cWMNkl:;;;:lxKMXc .0MMMMMO\u001b[0m\n" + "\u001b[32m :MMMMMK; cWMNkl:;;;:lxKMXc .0MMMMMO\u001b[0m\n" +
"\u001b[32m ..KMMMMMMNo,. ,OMMMMMMW:,. \u001b[37;1m DiscImageChef Website\u001b[0m\n" + "\u001b[32m ..KMMMMMMNo,. ,OMMMMMMW:,. \u001b[37;1m DiscImageChef Website\u001b[0m\n" +
"\u001b[32m .;d0NMMMMMMMMMMMMMMW0d:' .;lOWMMMMMMMMMMMMMXkl. \u001b[37;1m Version \u001b[0m\u001b[33m{0}\u001b[37;1m-\u001b[0m\u001b[31m{1}\u001b[0m\n" + "\u001b[32m .;d0NMMMMMMMMMMMMMMW0d:' .;lOWMMMMMMMMMMMMMXkl. \u001b[37;1m Version \u001b[0m\u001b[33m{0}\u001b[37;1m-\u001b[0m\u001b[31m{1}\u001b[0m\n" +
"\u001b[32m :KMMMMMMMMMMMMMMMMMMMMMMMMc WMMMMMMMMMMMMMMMMMMMMMMWk'\u001b[0m\n" + "\u001b[32m :KMMMMMMMMMMMMMMMMMMMMMMMMc WMMMMMMMMMMMMMMMMMMMMMMWk'\u001b[0m\n" +
"\u001b[32m ;NMMMMWX0kkkkO0XMMMMMMMMMMM0' dNMMMMMMMMMMW0xl:;,;:oOWMMX; \u001b[37;1m Running under \u001b[35;1m{2}\u001b[37;1m, \u001b[35m{3}-bit\u001b[37;1m in \u001b[35m{4}-bit\u001b[37;1m mode.\u001b[0m\n" + "\u001b[32m ;NMMMMWX0kkkkO0XMMMMMMMMMMM0' dNMMMMMMMMMMW0xl:;,;:oOWMMX; \u001b[37;1m Running under \u001b[35;1m{2}\u001b[37;1m, \u001b[35m{3}-bit\u001b[37;1m in \u001b[35m{4}-bit\u001b[37;1m mode.\u001b[0m\n" +
"\u001b[32m xMMWk:. .c0MMMMMW' OMMMMMM0c'.. .oNMO \u001b[37;1m Using \u001b[33;1m{5}\u001b[37;1m version \u001b[31;1m{6}\u001b[0m\n" + "\u001b[32m xMMWk:. .c0MMMMMW' OMMMMMM0c'.. .oNMO \u001b[37;1m Using \u001b[33;1m{5}\u001b[37;1m version \u001b[31;1m{6}\u001b[0m\n" +
"\u001b[32m OMNc .MNc oWMMk 'WMMNl. .MMK ;KX.\u001b[0m\n" + "\u001b[32m OMNc .MNc oWMMk 'WMMNl. .MMK ;KX.\u001b[0m\n" +
"\u001b[32m xMO WMN ; ., , ': ,MMx lK\u001b[0m\n" + "\u001b[32m xMO WMN ; ., , ': ,MMx lK\u001b[0m\n" +
"\u001b[32m ,Md cMMl .XMMMWWMMMO XMW. :\u001b[0m\n" + "\u001b[32m ,Md cMMl .XMMMWWMMMO XMW. :\u001b[0m\n" +
"\u001b[32m Ok xMMl XMMMMMMMMc 0MW,\u001b[0m\n" + "\u001b[32m Ok xMMl XMMMMMMMMc 0MW,\u001b[0m\n" +
"\u001b[32m 0 oMM0' lMMMMMMMM. :NMN'\u001b[0m\n" + "\u001b[32m 0 oMM0' lMMMMMMMM. :NMN'\u001b[0m\n" +
"\u001b[32m . .0MMKl ;MMMMMMMM oNMWd\u001b[0m\n" + "\u001b[32m . .0MMKl ;MMMMMMMM oNMWd\u001b[0m\n" +
"\u001b[32m .dNW cMMMMMMMM, XKl\u001b[0m\n" + "\u001b[32m .dNW cMMMMMMMM, XKl\u001b[0m\n" +
"\u001b[32m 0MMMMMMMMK\u001b[0m\n" + "\u001b[32m 0MMMMMMMMK\u001b[0m\n" +
"\u001b[32m ;MMMMMMMMMMO \u001b[37;1m Proudly presented to you by:\u001b[0m\n" + "\u001b[32m ;MMMMMMMMMMO \u001b[37;1m Proudly presented to you by:\u001b[0m\n" +
"\u001b[32m 'WMMMMKxMMMMM0 \u001b[34;1m Natalia Portillo\u001b[0m\n" + "\u001b[32m 'WMMMMKxMMMMM0 \u001b[34;1m Natalia Portillo\u001b[0m\n" +
"\u001b[32m oMMMMNc :WMMMMN:\u001b[0m\n" + "\u001b[32m oMMMMNc :WMMMMN:\u001b[0m\n" +
"\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" + "\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" +
"\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" + "\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" +
"\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" + "\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" +
"\u001b[0m\n", Version.GetVersion(), "\u001b[0m\n", Version.GetVersion(),
#if DEBUG #if DEBUG
"DEBUG" "DEBUG"
#else #else
"RELEASE" "RELEASE"
#endif #endif
, DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()), , DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32, Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
DetectOS.IsMono ? "Mono" : ".NET Core", DetectOS.IsMono ? "Mono" : ".NET Core",
DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion()); DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());
var host = CreateHostBuilder(args).Build(); IHost host = CreateHostBuilder(args).Build();
using(IServiceScope scope = host.Services.CreateScope())
using (var scope = host.Services.CreateScope())
{ {
var services = scope.ServiceProvider; IServiceProvider services = scope.ServiceProvider;
try try
{ {
@@ -93,15 +92,16 @@ namespace DiscImageChef.Server
var context = services.GetRequiredService<DicServerContext>(); var context = services.GetRequiredService<DicServerContext>();
context.Database.Migrate(); context.Database.Migrate();
end = DateTime.Now; end = DateTime.Now;
System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
(end - start).TotalSeconds); (end - start).TotalSeconds);
} }
catch (Exception ex) catch(Exception ex)
{ {
System.Console.WriteLine("\u001b[31;1mCould not open database...\u001b[0m"); System.Console.WriteLine("\u001b[31;1mCould not open database...\u001b[0m");
#if DEBUG #if DEBUG
System.Console.WriteLine("\u001b[31;1mException: {0}\u001b[0m", ex.Message); System.Console.WriteLine("\u001b[31;1mException: {0}\u001b[0m", ex.Message);
#endif #endif
return; return;
} }
} }
@@ -110,10 +110,11 @@ namespace DiscImageChef.Server
host.Run(); host.Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) public static IHostBuilder CreateHostBuilder(string[] args) => Host.
{ CreateDefaultBuilder(args).
return Host.CreateDefaultBuilder(args) ConfigureWebHostDefaults(webBuilder =>
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); {
} webBuilder.UseStartup<Startup>();
});
} }
} }

View File

@@ -12,10 +12,7 @@ namespace DiscImageChef.Server
{ {
public class Startup public class Startup
{ {
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration) => Configuration = configuration;
{
Configuration = configuration;
}
public IConfiguration Configuration { get; } public IConfiguration Configuration { get; }
@@ -23,7 +20,8 @@ namespace DiscImageChef.Server
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddDbContext<DicServerContext>(options => services.AddDbContext<DicServerContext>(options =>
options.UseMySql(Configuration.GetConnectionString("DefaultConnection"))); options.UseMySql(Configuration.
GetConnectionString("DefaultConnection")));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
} }
@@ -36,13 +34,14 @@ namespace DiscImageChef.Server
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
}); });
if (env.IsDevelopment()) if(env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
else else
{ {
app.UseExceptionHandler("/Home/Error"); 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. // 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.UseHsts();
} }
@@ -55,9 +54,7 @@ namespace DiscImageChef.Server
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllerRoute( endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
"default",
"{controller=Home}/{action=Index}/{id?}");
}); });
} }
} }

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef's code of conduct: DiscImageChef's code of conduct:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
How to contribute to DiscImageChef: How to contribute to DiscImageChef:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef list of changes: DiscImageChef list of changes:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef list of things to be donated: DiscImageChef list of things to be donated:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef's template for issue reports: DiscImageChef's template for issue reports:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -38,8 +38,7 @@
<header> <header>
Welcome to Welcome to
<i> <i>
<a href="http://github.com/claunia/discimagechef" <a href="http://github.com/claunia/discimagechef" target="_blank">
target="_blank">
DiscImageChef DiscImageChef
</a> </a>
</i> Server version @ViewBag.lblVersion </i> Server version @ViewBag.lblVersion

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef's template for pull requests: DiscImageChef's template for pull requests:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -36,7 +36,7 @@
// ****************************************************************************/ // ****************************************************************************/
} }
<p> <p>
@Html.ActionLink("Return to main page.", "Index")<br/> @Html.ActionLink("Return to main page.", "Index")<br />
DiscImageChef list of things to do: DiscImageChef list of things to do:
</p> </p>
<div class="container">@Html.Raw(ViewBag.Markdown)</div> <div class="container">@Html.Raw(ViewBag.Markdown)</div>

View File

@@ -45,11 +45,12 @@ DiscImageChef Report for
@if (ViewBag.UsbItem != null) @if (ViewBag.UsbItem != null)
{ {
<div id="divUsb"> <div id="divUsb">
<br/> <br />
<b>USB characteristics:</b><br/> <b>USB characteristics:</b>
<i>Manufacturer:</i> @ViewBag.UsbItem.Manufacturer<br/> <br />
<i>Product:</i> @ViewBag.UsbItem.Product<br/> <i>Manufacturer:</i> @ViewBag.UsbItem.Manufacturer<br />
<i>Vendor ID:</i> @ViewBag.UsbItem.VendorDescription<br/> <i>Product:</i> @ViewBag.UsbItem.Product<br />
<i>Vendor ID:</i> @ViewBag.UsbItem.VendorDescription<br />
<i>Product ID:</i> @ViewBag.UsbItem.ProductDescription <i>Product ID:</i> @ViewBag.UsbItem.ProductDescription
</div> </div>
} }
@@ -57,11 +58,12 @@ DiscImageChef Report for
@if (ViewBag.FireWireItem != null) @if (ViewBag.FireWireItem != null)
{ {
<div id="divFireWire"> <div id="divFireWire">
<br/> <br />
<b>FireWire characteristics:</b><br/> <b>FireWire characteristics:</b>
<i>Manufacturer:</i> @ViewBag.FireWire.Manufacturer<br/> <br />
<i>Product:</i> @ViewBag.FireWire.Product<br/> <i>Manufacturer:</i> @ViewBag.FireWire.Manufacturer<br />
<i>Vendor ID:</i> @ViewBag.FireWire.VendorDescription<br/> <i>Product:</i> @ViewBag.FireWire.Product<br />
<i>Vendor ID:</i> @ViewBag.FireWire.VendorDescription<br />
<i>Product ID:</i> @ViewBag.FireWire.ProductDescription <i>Product ID:</i> @ViewBag.FireWire.ProductDescription
</div> </div>
} }
@@ -69,18 +71,20 @@ DiscImageChef Report for
@if (ViewBag.PcmciaItem != null) @if (ViewBag.PcmciaItem != null)
{ {
<div id="divPcmcia"> <div id="divPcmcia">
<br/> <br />
<b>PCMCIA characteristics:</b><br/> <b>PCMCIA characteristics:</b>
<i>Manufacturer:</i> @ViewBag.PcmciaItem.Manufacturer<br/> <br />
<i>Product:</i> @ViewBag.PcmciaItem.ProductName<br/> <i>Manufacturer:</i> @ViewBag.PcmciaItem.Manufacturer<br />
<i>Manufacturer code:</i> @ViewBag.PcmciaItem.VendorDescription<br/> <i>Product:</i> @ViewBag.PcmciaItem.ProductName<br />
<i>Card code:</i> @ViewBag.PcmciaItem.CardCode<br/> <i>Manufacturer code:</i> @ViewBag.PcmciaItem.VendorDescription<br />
<i>Compliance:</i> @ViewBag.PcmciaItem.Compliance<br/> <i>Card code:</i> @ViewBag.PcmciaItem.CardCode<br />
<i>Compliance:</i> @ViewBag.PcmciaItem.Compliance<br />
@if (ViewBag.repPcmciaTuples != null) @if (ViewBag.repPcmciaTuples != null)
{ {
foreach (KeyValuePair<string, string> kvp in ViewBag.repPcmciaTuples) foreach (KeyValuePair<string, string> kvp in ViewBag.repPcmciaTuples)
{ {
<text><i>@kvp.Key</i>: @kvp.Value<br/></text> <text>
<i>@kvp.Key</i>: @kvp.Value<br /></text>
} }
} }
</div> </div>
@@ -89,38 +93,42 @@ DiscImageChef Report for
@if (ViewBag.AtaItem != null) @if (ViewBag.AtaItem != null)
{ {
<div id="divAta"> <div id="divAta">
<br/> <br />
<b> <b>
@ViewBag.AtaItem characteristics: @ViewBag.AtaItem characteristics:
</b><br/> </b>
@ViewBag.lblAtaDeviceType<br/> <br />
@ViewBag.lblAtaDeviceType<br />
@foreach (KeyValuePair<string, string> kvp in ViewBag.repAtaTwo) @foreach (KeyValuePair<string, string> kvp in ViewBag.repAtaTwo)
{ {
<text><i>@kvp.Key</i>: @kvp.Value<br/></text> <text>
<i>@kvp.Key</i>: @kvp.Value<br /></text>
} }
<br/> <br />
@foreach (string item in ViewBag.repAtaOne) @foreach (string item in ViewBag.repAtaOne)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }
@if (ViewBag.repScsi != null) @if (ViewBag.repScsi != null)
{ {
<div id="divScsi"> <div id="divScsi">
<br/> <br />
<b>SCSI characteristics:</b><br/> <b>SCSI characteristics:</b>
<i>Vendor: </i>@ViewBag.lblScsiVendor<br/> <br />
<i>Product: </i>@ViewBag.lblScsiProduct<br/> <i>Vendor: </i>@ViewBag.lblScsiVendor<br />
<i>Revision: </i>@ViewBag.lblScsiRevision<br/> <i>Product: </i>@ViewBag.lblScsiProduct<br />
<i>Revision: </i>@ViewBag.lblScsiRevision<br />
@foreach (string item in ViewBag.repScsi) @foreach (string item in ViewBag.repScsi)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
@if (ViewBag.repModeSense != null) @if (ViewBag.repModeSense != null)
{ {
<div id="divScsiModeSense"> <div id="divScsiModeSense">
<br/><i>SCSI mode sense pages:</i> <br />
<i>SCSI mode sense pages:</i>
<table border="1"> <table border="1">
<tr> <tr>
<th>Mode</th> <th>Mode</th>
@@ -143,7 +151,8 @@ DiscImageChef Report for
@if (ViewBag.repEvpd != null) @if (ViewBag.repEvpd != null)
{ {
<div id="divScsiEvpd"> <div id="divScsiEvpd">
<br/><i>SCSI extended vital product data pages:</i> <br />
<i>SCSI extended vital product data pages:</i>
<table border="1"> <table border="1">
<tr> <tr>
<th>EVPD</th> <th>EVPD</th>
@@ -166,47 +175,57 @@ DiscImageChef Report for
@if (ViewBag.repScsiMmcMode != null) @if (ViewBag.repScsiMmcMode != null)
{ {
<div id="divScsiMmcMode"> <div id="divScsiMmcMode">
<br/><b>SCSI CD-ROM capabilities:</b><br/> <br />
<b>SCSI CD-ROM capabilities:</b>
<br />
@foreach (string item in ViewBag.repScsiMmcMode) @foreach (string item in ViewBag.repScsiMmcMode)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }
@if (ViewBag.repScsiMmcFeatures != null) @if (ViewBag.repScsiMmcFeatures != null)
{ {
<div id="divScsiMmcFeatures"> <div id="divScsiMmcFeatures">
<br/><b>SCSI MMC features:</b><br/> <br />
<b>SCSI MMC features:</b>
<br />
@foreach (string item in ViewBag.repScsiMmcFeatures) @foreach (string item in ViewBag.repScsiMmcFeatures)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }
@if (ViewBag.divScsiSscVisible == true) @if (ViewBag.divScsiSscVisible == true)
{ {
<div id="divScsiSsc"> <div id="divScsiSsc">
<br/><b>SCSI Streaming device capabilities:</b><br/> <br />
Block size granularity: @ViewBag.lblScsiSscGranularity<br/> <b>SCSI Streaming device capabilities:</b>
Maximum block length: @ViewBag.lblScsiSscMaxBlock bytes<br/> <br />
Minimum block length: @ViewBag.lblScsiSscMinBlock bytes<br/> Block size granularity: @ViewBag.lblScsiSscGranularity<br />
Maximum block length: @ViewBag.lblScsiSscMaxBlock bytes
<br />
Minimum block length: @ViewBag.lblScsiSscMinBlock bytes
<br />
@if (ViewBag.repScsiSscDensities != null) @if (ViewBag.repScsiSscDensities != null)
{ {
foreach (SupportedDensity density in ViewBag.repScsiSscDensities) foreach (SupportedDensity density in ViewBag.repScsiSscDensities)
{ {
<text> <text>
<br/> <br />
<b> <b>
Information for supported density with primary code @($"{density.PrimaryCode:X2h}") and secondary code @($"{density.SecondaryCode:X2h}") Information for supported density with primary code @($"{density.PrimaryCode:X2h}") and secondary code @($"{density.SecondaryCode:X2h}")
</b><br/> </b>
Drive can write this density: @density.Writable<br/> <br />
Duplicate density: @density.Duplicate<br/> Drive can write this density: @density.Writable<br />
Default density: @density.DefaultDensity<br/> Duplicate density: @density.Duplicate<br />
Default density: @density.DefaultDensity<br />
Density has @density.BitsPerMm bits per mm, with @density.Tracks tracks in a @density.Width mm width tape Density has @density.BitsPerMm bits per mm, with @density.Tracks tracks in a @density.Width mm width tape
Name: @density.Name<br/> Name: @density.Name<br />
Organization: @density.Organization<br/> Organization: @density.Organization<br />
Description: @density.Description<br/> Description: @density.Description<br />
Maximum capacity: @density.Capacity megabytes<br/> Maximum capacity: @density.Capacity megabytes
<br />
</text> </text>
} }
} }
@@ -215,14 +234,15 @@ DiscImageChef Report for
foreach (SscSupportedMedia media in ViewBag.repScsiSscMedias) foreach (SscSupportedMedia media in ViewBag.repScsiSscMedias)
{ {
<text> <text>
<br/> <br />
<b> <b>
Information for supported media with type code @($"{media.MediumType:X2h}") Information for supported media with type code @($"{media.MediumType:X2h}")
</b><br/> </b>
<br />
Media is @media.Length m long in a @media.Width mm width tape Media is @media.Length m long in a @media.Width mm width tape
Name: @media.Name<br/> Name: @media.Name<br />
Organization: @media.Organization<br/> Organization: @media.Organization<br />
Description: @media.Description<br/> Description: @media.Description<br />
</text> </text>
} }
} }
@@ -233,32 +253,36 @@ DiscImageChef Report for
@if (ViewBag.repTestedMedia != null) @if (ViewBag.repTestedMedia != null)
{ {
<div id="divTestedMedia"> <div id="divTestedMedia">
<br/><b>Tested media:</b><br/> <br />
<b>Tested media:</b>
<br />
@foreach (string item in ViewBag.repTestedMedia) @foreach (string item in ViewBag.repTestedMedia)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }
@if (ViewBag.repMMC != null) @if (ViewBag.repMMC != null)
{ {
<div id="divMMC"> <div id="divMMC">
<br/> <br />
<b>MultiMediaCard device:</b><br/> <b>MultiMediaCard device:</b>
<br />
@foreach (string item in ViewBag.repMMC) @foreach (string item in ViewBag.repMMC)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }
@if (ViewBag.repSD != null) @if (ViewBag.repSD != null)
{ {
<div id="divSD"> <div id="divSD">
<br/> <br />
<b>SecureDigital device:</b><br/> <b>SecureDigital device:</b>
<br />
@foreach (string item in ViewBag.repSD) @foreach (string item in ViewBag.repSD)
{ {
@Html.Raw(item)<br/> @Html.Raw(item)<br />
} }
</div> </div>
} }

View File

@@ -2,24 +2,26 @@
@{ @{
ViewData["Title"] = "Error"; ViewData["Title"] = "Error";
} }
<h1 class="text-danger">Error.</h1> <h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2> <h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId) @if (Model.ShowRequestId)
{ {
<p> <p>
<strong>Request ID:</strong> <code>@Model.RequestId</code> <strong>Request ID:</strong>
<code>@Model.RequestId</code>
</p> </p>
} }
<h3>Development Mode</h3> <h3>Development Mode</h3>
<p> <p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred. Swapping to
<strong>Development</strong> environment will display more detailed information about the error that occurred.
</p> </p>
<p> <p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> <strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users. It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> For local debugging, enable the
<strong>Development</strong> environment by setting the
<strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to
<strong>Development</strong>
and restarting the app. and restarting the app.
</p> </p>

View File

@@ -39,23 +39,18 @@
{ {
// 24th January, Macintosh launch // 24th January, Macintosh launch
case 24: case 24:
<link href="~/css/mac/dicserver.css" <link href="~/css/mac/dicserver.css" rel="stylesheet" type="text/css" />
rel="stylesheet" type="text/css"/> <link href="~/css/mac/dicserver_highcharts.css" rel="stylesheet" type="text/css" />
<link href="~/css/mac/dicserver_highcharts.css"
rel="stylesheet" type="text/css"/>
break; break;
default: default:
<link href="~/css/dos/dicserver.css" <link href="~/css/dos/dicserver.css" rel="stylesheet" type="text/css" />
rel="stylesheet" type="text/css"/> <link href="~/css/dos/dicserver_highcharts.css" rel="stylesheet" type="text/css" />
<link href="~/css/dos/dicserver_highcharts.css"
rel="stylesheet" type="text/css"/>
break; break;
} }
<meta charset="utf-8"/> <meta charset="utf-8" />
<title>@ViewBag.Title</title> <title>@ViewBag.Title</title>
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<script async <script async src="https://www.googletagmanager.com/gtag/js?id=UA-111466173-1"></script>
src="https://www.googletagmanager.com/gtag/js?id=UA-111466173-1"></script>
<script> <script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
@@ -70,10 +65,10 @@
@RenderBody() @RenderBody()
<footer class="container-fluid"> <footer class="container-fluid">
© 2011-2019 © 2011-2019
<a href="http://www.claunia.com" <a href="http://www.claunia.com" target="_blank">
target="_blank">
Claunia.com Claunia.com
</a><br/> </a>
<br />
@switch (DateTime.UtcNow.DayOfYear) @switch (DateTime.UtcNow.DayOfYear)
{ {
// 24th January, Macintosh launch // 24th January, Macintosh launch
@@ -86,25 +81,17 @@
; ;
break; break;
} }
<br/> <br />
CSS © 2018-2019 CSS © 2018-2019
<a href="https://getbootstrap.com/" <a href="https://getbootstrap.com/" target="_blank">
target="_blank">
Bootstrap Bootstrap
</a> and </a> and
<a href="http://www.claunia.com" <a href="http://www.claunia.com" target="_blank">
target="_blank">
Claunia.com Claunia.com
</a> </a>
</footer> </footer>
<script crossorigin="anonymous" <script crossorigin="anonymous" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" <script crossorigin="anonymous" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> <script crossorigin="anonymous" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut"
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
</body> </body>
</html> </html>

View File

@@ -39,8 +39,7 @@
<header> <header>
Welcome to Welcome to
<i> <i>
<a href="http://github.com/claunia/discimagechef" <a href="http://github.com/claunia/discimagechef" target="_blank">
target="_blank">
DiscImageChef DiscImageChef
</a> </a>
</i> Server version @ViewBag.Version </i> Server version @ViewBag.Version
@@ -48,87 +47,57 @@
<div class="container-fluid mt-3"> <div class="container-fluid mt-3">
@if (ViewBag.repOperatingSystems != null) @if (ViewBag.repOperatingSystems != null)
{ {
<div class="container" <div class="container" id="divOperatingSystems">
id="divOperatingSystems"> <div class="carousel slide" data-ride="carousel" id="carouselOses">
<div class="carousel slide"
data-ride="carousel"
id="carouselOses">
<ol class="carousel-indicators"> <ol class="carousel-indicators">
<li class="active" <li class="active" data-slide-to="0" data-target="#carouselOses">
data-slide-to="0"
data-target="#carouselOses">
</li> </li>
<li data-slide-to="1" <li data-slide-to="1" data-target="#carouselOses">
data-target="#carouselOses">
</li> </li>
<li data-slide-to="2" <li data-slide-to="2" data-target="#carouselOses">
data-target="#carouselOses">
</li> </li>
<li data-slide-to="3" <li data-slide-to="3" data-target="#carouselOses">
data-target="#carouselOses">
</li> </li>
</ol> </ol>
<div class="carousel-inner"> <div class="carousel-inner">
<div class="active carousel-item" <div class="active carousel-item" id="osChart">
id="osChart">
</div> </div>
<div class="carousel-item" <div class="carousel-item" id="linuxChart">
id="linuxChart">
</div> </div>
<div class="carousel-item" <div class="carousel-item" id="macosChart">
id="macosChart">
</div> </div>
<div class="carousel-item" <div class="carousel-item" id="windowsChart">
id="windowsChart">
</div> </div>
</div> </div>
<a class="carousel-control-prev" <a class="carousel-control-prev" data-slide="prev" href="#carouselOses" role="button">
data-slide="prev" <span aria-hidden="true" class="carousel-control-prev-icon">
href="#carouselOses"
role="button">
<span aria-hidden="true"
class="carousel-control-prev-icon">
</span> </span>
<span class="sr-only">Previous</span> <span class="sr-only">Previous</span>
</a> </a>
<a class="carousel-control-next" <a class="carousel-control-next" data-slide="next" href="#carouselOses" role="button">
data-slide="next" <span aria-hidden="true" class="carousel-control-next-icon">
href="#carouselOses"
role="button">
<span aria-hidden="true"
class="carousel-control-next-icon">
</span> </span>
<span class="sr-only">Next</span> <span class="sr-only">Next</span>
</a> </a>
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="osAccordion">
id="osAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="osHeading">
id="osHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="osCollapse" <button aria-controls="osCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#osCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#osCollapse"
data-toggle="collapse"
type="button">
All operating systems DiscImageChef has run on... All operating systems DiscImageChef has run on...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="osHeading" class="collapse" data-parent="#osAccordion" id="osCollapse">
<div aria-labelledby="osHeading"
class="collapse"
data-parent="#osAccordion"
id="osCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-dark"> <table class="table-dark">
@foreach (NameValueStats os in ViewBag.repOperatingSystems) @foreach (NameValueStats os in ViewBag.repOperatingSystems)
{ {
<tr> <tr>
<td class="text-left"> <td class="text-left">
DiscImageChef has run on <i class="table-dark-em">@os.name</i> @os.Value times. DiscImageChef has run on
<i class="table-dark-em">@os.name</i> @os.Value times.
</td> </td>
</tr> </tr>
} }
@@ -137,44 +106,32 @@
</div> </div>
</div> </div>
</div> </div>
<br/> <br />
</div> </div>
} }
@if (ViewBag.repVersions != null) @if (ViewBag.repVersions != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divVersions">
id="divVersions"> <div class="container" id="versionsChart">
<div class="container"
id="versionsChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="versionsAccordion">
id="versionsAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="versionsHeading">
id="versionsHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="versionsCollapse" <button aria-controls="versionsCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#versionsCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#versionsCollapse"
data-toggle="collapse"
type="button">
All DiscImageChef versions... All DiscImageChef versions...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="versionsHeading" class="collapse" data-parent="#versionsAccordion" id="versionsCollapse">
<div aria-labelledby="versionsHeading"
class="collapse"
data-parent="#versionsAccordion"
id="versionsCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-dark"> <table class="table-dark">
@foreach (NameValueStats version in ViewBag.repVersions) @foreach (NameValueStats version in ViewBag.repVersions)
{ {
<tr> <tr>
<td class="text-left"> <td class="text-left">
DiscImageChef version <i class="table-dark-em">@version.name</i> has been used @version.Value times. DiscImageChef version
<i class="table-dark-em">@version.name</i> has been used @version.Value times.
</td> </td>
</tr> </tr>
} }
@@ -183,37 +140,24 @@
</div> </div>
</div> </div>
</div> </div>
<br/> <br />
</div> </div>
} }
@if (ViewBag.repCommands != null) @if (ViewBag.repCommands != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divCommands">
id="divCommands"> <div class="container" id="commandsChart">
<div class="container"
id="commandsChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="commandsAccordion">
id="commandsAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="commandsHeading">
id="commandsHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="commandsCollapse" <button aria-controls="commandsCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#commandsCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#commandsCollapse"
data-toggle="collapse"
type="button">
All DiscImageChef commands... All DiscImageChef commands...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="commandsHeading" class="collapse" data-parent="#commandsAccordion" id="commandsCollapse">
<div aria-labelledby="commandsHeading"
class="collapse"
data-parent="#commandsAccordion"
id="commandsCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-dark"> <table class="table-dark">
@foreach (Command command in ViewBag.repCommands) @foreach (Command command in ViewBag.repCommands)
@@ -229,37 +173,24 @@
</div> </div>
</div> </div>
</div> </div>
<br/> <br />
</div> </div>
} }
@if (ViewBag.repFilters != null) @if (ViewBag.repFilters != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divFilters">
id="divFilters"> <div class="container" id="filtersChart">
<div class="container"
id="filtersChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="filtersAccordion">
id="filtersAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="filtersHeading">
id="filtersHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="filtersCollapse" <button aria-controls="filtersCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#filtersCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#filtersCollapse"
data-toggle="collapse"
type="button">
All filters found... All filters found...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="filtersHeading" class="collapse" data-parent="#filtersAccordion" id="filtersCollapse">
<div aria-labelledby="filtersHeading"
class="collapse"
data-parent="#filtersAccordion"
id="filtersCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -286,32 +217,19 @@
} }
@if (ViewBag.repMediaImages != null) @if (ViewBag.repMediaImages != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divMediaImages">
id="divMediaImages"> <div class="container" id="formatsChart">
<div class="container"
id="formatsChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="formatsAccordion">
id="formatsAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="formatsHeading">
id="formatsHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="formatsCollapse" <button aria-controls="formatsCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#formatsCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#formatsCollapse"
data-toggle="collapse"
type="button">
All media image formats found... All media image formats found...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="formatsHeading" class="collapse" data-parent="#formatsAccordion" id="formatsCollapse">
<div aria-labelledby="formatsHeading"
class="collapse"
data-parent="#formatsAccordion"
id="formatsCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -338,32 +256,19 @@
} }
@if (ViewBag.repPartitions != null) @if (ViewBag.repPartitions != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divPartitions">
id="divPartitions"> <div class="container" id="partitionsChart">
<div class="container"
id="partitionsChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="partitionsAccordion">
id="partitionsAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="partitionsHeading">
id="partitionsHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="partitionsCollapse" <button aria-controls="partitionsCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#partitionsCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#partitionsCollapse"
data-toggle="collapse"
type="button">
All partitioning schemes found... All partitioning schemes found...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="partitionsHeading" class="collapse" data-parent="#partitionsAccordion" id="partitionsCollapse">
<div aria-labelledby="partitionsHeading"
class="collapse"
data-parent="#partitionsAccordion"
id="partitionsCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -390,32 +295,19 @@
} }
@if (ViewBag.repFilesystems != null) @if (ViewBag.repFilesystems != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divFilesystems">
id="divFilesystems"> <div class="container" id="filesystemsChart">
<div class="container"
id="filesystemsChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="filesystemsAccordion">
id="filesystemsAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="filesystemsHeading">
id="filesystemsHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="filesystemsCollapse" <button aria-controls="filesystemsCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#filesystemsCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#filesystemsCollapse"
data-toggle="collapse"
type="button">
All filesystems found... All filesystems found...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="filesystemsHeading" class="collapse" data-parent="#filesystemsAccordion" id="filesystemsCollapse">
<div aria-labelledby="filesystemsHeading"
class="collapse"
data-parent="#filesystemsAccordion"
id="filesystemsCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -442,32 +334,19 @@
} }
@if (ViewBag.repVirtualMedia != null) @if (ViewBag.repVirtualMedia != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divVirtualMedia">
id="divVirtualMedia"> <div class="container" id="virtualMediaChart">
<div class="container"
id="virtualMediaChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="virtualMediaAccordion">
id="virtualMediaAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="virtualMediaHeading">
id="virtualMediaHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="virtualMediaCollapse" <button aria-controls="virtualMediaCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#virtualMediaCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#virtualMediaCollapse"
data-toggle="collapse"
type="button">
All media types found in images... All media types found in images...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="virtualMediaHeading" class="collapse" data-parent="#virtualMediaAccordion" id="virtualMediaCollapse">
<div aria-labelledby="virtualMediaHeading"
class="collapse"
data-parent="#virtualMediaAccordion"
id="virtualMediaCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -498,32 +377,19 @@
} }
@if (ViewBag.repRealMedia != null) @if (ViewBag.repRealMedia != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divRealMedia">
id="divRealMedia"> <div class="container" id="realMediaChart">
<div class="container"
id="realMediaChart">
</div> </div>
<div class="accordion mt-3" <div class="accordion mt-3" id="realMediaAccordion">
id="realMediaAccordion">
<div class="card"> <div class="card">
<div class="card-header" <div class="card-header" id="realMediaHeading">
id="realMediaHeading">
<h2 class="mb-0"> <h2 class="mb-0">
<button aria-controls="realMediaCollapse" <button aria-controls="realMediaCollapse" aria-expanded="true" class="btn btn-link card-button collapsed" data-target="#realMediaCollapse" data-toggle="collapse" type="button">
aria-expanded="true"
class="btn btn-link card-button collapsed"
data-target="#realMediaCollapse"
data-toggle="collapse"
type="button">
All media types found in devices... All media types found in devices...
</button> </button>
</h2> </h2>
</div> </div>
<div aria-labelledby="realMediaHeading" class="collapse" data-parent="#realMediaAccordion" id="realMediaCollapse">
<div aria-labelledby="realMediaHeading"
class="collapse"
data-parent="#realMediaAccordion"
id="realMediaCollapse">
<div class="card-body"> <div class="card-body">
<table class="table-bordered table-centered table-dark table-striped"> <table class="table-bordered table-centered table-dark table-striped">
<tr> <tr>
@@ -554,49 +420,31 @@
} }
@if (ViewBag.repDevices != null) @if (ViewBag.repDevices != null)
{ {
<div class="container mt-3" <div class="container mt-3" id="divDevices">
id="divDevices"> <div class="carousel slide" data-ride="carousel" id="carouselDevices">
<div class="carousel slide"
data-ride="carousel"
id="carouselDevices">
<ol class="carousel-indicators"> <ol class="carousel-indicators">
<li class="active" <li class="active" data-slide-to="0" data-target="#carouselDevices">
data-slide-to="0"
data-target="#carouselDevices">
</li> </li>
<li data-slide-to="1" <li data-slide-to="1" data-target="#carouselDevices">
data-target="#carouselDevices">
</li> </li>
<li data-slide-to="2" <li data-slide-to="2" data-target="#carouselDevices">
data-target="#carouselDevices">
</li> </li>
<li data-slide-to="3" <li data-slide-to="3" data-target="#carouselDevices">
data-target="#carouselDevices">
</li> </li>
</ol> </ol>
<div class="carousel-inner"> <div class="carousel-inner">
<div class="active carousel-item" <div class="active carousel-item" id="devicesBusChart">
id="devicesBusChart">
</div> </div>
<div class="carousel-item" <div class="carousel-item" id="devicesManufacturerChart">
id="devicesManufacturerChart">
</div> </div>
</div> </div>
<a class="carousel-control-prev" <a class="carousel-control-prev" data-slide="prev" href="#carouselDevices" role="button">
data-slide="prev" <span aria-hidden="true" class="carousel-control-prev-icon">
href="#carouselDevices"
role="button">
<span aria-hidden="true"
class="carousel-control-prev-icon">
</span> </span>
<span class="sr-only">Previous</span> <span class="sr-only">Previous</span>
</a> </a>
<a class="carousel-control-next" <a class="carousel-control-next" data-slide="next" href="#carouselDevices" role="button">
data-slide="next" <span aria-hidden="true" class="carousel-control-next-icon">
href="#carouselDevices"
role="button">
<span aria-hidden="true"
class="carousel-control-next-icon">
</span> </span>
<span class="sr-only">Next</span> <span class="sr-only">Next</span>
</a> </a>
@@ -636,7 +484,13 @@
<td> <td>
@if (device.ReportId != 0) @if (device.ReportId != 0)
{ {
<text>@Html.ActionLink("Yes", "View", "Report", new {id = device.ReportId}, new {target = "_blank"})</text> <text>@Html.ActionLink("Yes", "View", "Report", new
{
id = device.ReportId
}, new
{
target = "_blank"
})</text>
} }
else else
{ {