From bd1a9ad35778d5e9b407c168d539f5b9d829d170 Mon Sep 17 00:00:00 2001 From: Marcel Vielhaus Date: Fri, 6 Nov 2026 19:38:11 +0100 Subject: [PATCH 1/2] Run `dotnet format` for `MORYX-Framework.slnx` To prevent repeated changes in PRs and align the whole solution to the current formatting settings. --- .../Models/PartConnector.cs | 2 +- .../Models/PartModel.cs | 2 +- .../Models/ProductCustomization.cs | 2 +- .../Models/ProductDefinitionModel.cs | 2 +- .../Models/ProductImporter.cs | 2 +- .../Models/ProductInstanceModel.cs | 2 +- .../Models/ProductModel.cs | 2 +- .../Models/RecipeClassificationModel.cs | 2 +- .../Models/RecipeDefinitionModel.cs | 2 +- .../Models/RecipeModel.cs | 2 +- .../Models/WorkplanModel.cs | 2 +- .../PartialSerialization.cs | 6 +- .../ProductConverter.cs | 38 +- .../ProductManagementController.cs | 106 +++- .../ProductPermissions.cs | 2 +- .../WorkplanController.cs | 27 +- .../WorkplanPermissions.cs | 2 +- .../Converter/ResourceQueryConverter.cs | 8 +- .../Converter/ResourceToModelConverter.cs | 20 +- .../DataMemberAttributeValueProviderFilter.cs | 7 +- .../Models/ReferenceFilter.cs | 2 +- .../Models/ReferenceTypeModel.cs | 2 +- .../Models/ResourceModel.cs | 6 +- .../Models/ResourceQuery.cs | 2 +- .../Models/ResourceReferenceModel.cs | 2 +- .../Models/ResourceTypeModel.cs | 2 +- .../ResourceSerialization.cs | 2 +- .../MqttBuilderExtensions.cs | 1 - .../ResourceEventHandler.cs | 3 +- .../ResourceEventService.cs | 4 +- .../ResourceSynchronizationService.cs | 2 +- .../Serializations/ResourceToJsonConverter.cs | 2 +- .../WriteOnlyHashStore.cs | 2 +- .../DummyProductInstance.cs | 2 +- .../DummyProductPartLink.cs | 9 +- .../DummyProductRecipe.cs | 16 +- .../DummyWorkplan.cs | 9 +- .../InMemoryUnitOfWorkFactoryBuilder.cs | 2 +- .../ReferenceCollectionMock.cs | 2 +- .../Resources/ResourceGraphMock.cs | 6 +- .../Activities/Activity.cs | 2 +- .../ActivityBindingResolverFactory.cs | 2 +- .../Activities/ActivityExtensions.cs | 2 +- .../Activities/ActivityResult.cs | 2 +- .../Activities/ActivityResultsAttribute.cs | 2 +- .../Activities/DefaultActivityResult.cs | 2 +- .../Activities/IActivity.cs | 2 +- .../Activities/IParameters.cs | 2 +- .../Activities/NullActivityParameters.cs | 2 +- .../Activities/OutputTypeAttribute.cs | 2 +- .../Activities/Parameters.cs | 6 +- .../Activities/ProcessRequirement.cs | 2 +- .../Activities/Tracing.cs | 6 +- .../Activities/TracingExtension.cs | 2 +- .../Capabilities/CapabilitiesBase.cs | 2 +- .../Capabilities/CombinedCapabilities.cs | 2 +- .../Capabilities/ICapabilities.cs | 2 +- .../Constraints/ExpressionConstraint.cs | 7 +- .../Constraints/IConstraint.cs | 2 +- .../Constraints/IConstraintContext.cs | 2 +- .../Constraints/NullConstraint.cs | 2 +- .../Drivers/Axis/Axes.cs | 2 +- .../Drivers/Axis/AxisMovementResponse.cs | 2 +- .../Drivers/Axis/AxisPosition.cs | 2 +- .../Drivers/Axis/NumberedAxis.cs | 5 +- src/Moryx.AbstractionLayer/Drivers/Driver.cs | 2 +- src/Moryx.AbstractionLayer/Drivers/IDriver.cs | 2 +- .../Drivers/IDriverState.cs | 2 +- .../Drivers/InOut/IInOutDriver.cs | 2 +- .../Drivers/InOut/IInput.cs | 2 +- .../Drivers/InOut/IOutput.cs | 2 +- .../Drivers/InOut/InputChangedEventArgs.cs | 2 +- .../Drivers/InOut/SupportedAccess.cs | 2 +- .../Drivers/Marking/MarkingConfiguration.cs | 2 +- .../Drivers/Marking/MarkingFIleResponse.cs | 2 +- .../Drivers/Marking/MarkingFile.cs | 2 +- .../Drivers/Marking/MarkingResponse.cs | 2 +- .../Marking/SegmentsNotSupportedException.cs | 2 +- .../Drivers/Message/IIdentifierMessage.cs | 2 +- .../Drivers/Message/IMessageDriver.cs | 2 +- .../Drivers/Rfid/RfidDirection.cs | 2 +- .../Drivers/Rfid/RfidTag.cs | 2 +- .../Drivers/Scanner/ReadCodeOptions.cs | 4 - .../Drivers/StateClassification.cs | 2 +- .../Drivers/SyncDriverState.cs | 2 +- .../Identity/BatchIdentity.cs | 2 +- .../Identity/IIdentifiableObject.cs | 2 +- .../Identity/IIdentity.cs | 2 +- .../Identity/IdentityEntryEncoder.cs | 1 - .../Identity/NumberIdentity.cs | 6 +- .../Processes/IProcess.cs | 3 +- .../Processes/Process.cs | 6 +- .../ProcessBindingResolverFactory.cs | 20 +- .../Processes/ProcessRecipeLink.cs | 2 +- .../Processes/ProcessWorkplanContext.cs | 2 +- .../Processes/ProductionProcess.cs | 2 +- .../Products/IProductInstance.cs | 2 +- .../Products/IProductManagement.cs | 2 +- .../Products/IProductPartLink.cs | 2 +- .../Products/IProductType.cs | 2 +- .../Products/IProductionDate.cs | 2 +- .../Products/IdentityConflictException.cs | 2 +- .../Products/Import/FileImportParameters.cs | 2 +- .../Products/Import/IProductImporter.cs | 2 +- .../Products/Import/ProductImportContext.cs | 2 +- .../Products/Import/ProductImporterBase.cs | 2 +- .../Products/Import/ProductImporterConfig.cs | 2 +- .../Products/Import/ProductImporterResult.cs | 2 +- .../Products/ProductIdentity.cs | 6 + .../Products/ProductImportResult.cs | 2 +- .../Products/ProductInstance.cs | 2 +- .../Products/ProductPartLink.cs | 2 +- .../Products/ProductType.cs | 2 +- .../Products/ProductTypeWrapper.cs | 2 +- .../Recipes/IProductRecipe.cs | 2 +- src/Moryx.AbstractionLayer/Recipes/IRecipe.cs | 2 +- .../Recipes/IRecipeProvider.cs | 2 +- .../Recipes/IWorkplanRecipe.cs | 2 +- .../Recipes/ProductRecipe.cs | 2 +- .../Recipes/ProductRecipeReference.cs | 2 +- .../Recipes/ProductionRecipe.cs | 2 +- src/Moryx.AbstractionLayer/Recipes/Recipe.cs | 2 +- .../Recipes/RecipeBindingResolverFactory.cs | 10 +- .../Recipes/RecipeClassification.cs | 2 +- .../Recipes/RecipeState.cs | 2 +- .../Recipes/WorkplanRecipe.cs | 2 +- .../AvailableCapabilitiesAttribute.cs | 10 +- .../Attributes/ReferenceOverrideAttribute.cs | 2 +- .../ResourceAvailableAsAttribute.cs | 2 +- .../ResourceConstructorAttribute.cs | 2 +- .../Attributes/ResourceReferenceAttribute.cs | 2 +- .../ResourceRegistrationAttribute.cs | 2 +- .../ResourceSynchronizationAttribute.cs | 8 +- .../Attributes/ResourceTypesAttribute.cs | 5 +- .../SynchronizableMemberAttribute.cs | 6 +- .../ResourceInitializerExtensions.cs | 2 +- .../Resources/IReferences.cs | 2 +- .../Resources/IResource.cs | 2 +- .../Resources/IResourceGraph.cs | 2 +- .../Resources/IResourceManagement.cs | 2 +- .../Resources/IResourceTypeNode.cs | 2 +- .../Resources/IResourceTypeTree.cs | 2 +- .../Initializer/IResourceInitializer.cs | 2 +- .../ResourceInitializerAttribute.cs | 2 +- .../Initializer/ResourceInitializerBase.cs | 1 - .../Initializer/ResourceInitializerConfig.cs | 2 +- .../Resources/ProxyDetachedException.cs | 2 +- .../Resources/Resource.cs | 4 +- .../ResourceBindingResolverFactory.cs | 2 +- .../Resources/ResourceFacadeExtensions.cs | 2 +- .../Resources/ResourceNotFoundException.cs | 2 +- .../Resources/ResourceReferenceRole.cs | 2 +- .../Resources/ResourceRelationType.cs | 2 +- src/Moryx.AbstractionLayer/Workplans/ITask.cs | 2 +- .../Workplans/ITaskStep.cs | 2 +- .../Workplans/TaskStep.cs | 20 +- .../Workplans/TaskTransition.cs | 5 + .../Workplans/WorkplanExtensions.cs | 4 + .../Components/MqttClientUserOptions.cs | 1 - .../Endpoints/MqttEndpointContext.cs | 2 +- src/Moryx.AspNetCore/MoryxExceptionFilter.cs | 2 +- .../MoryxExceptionResponse.cs | 2 +- src/Moryx.Benchmarking/BenchmarkActivity.cs | 2 +- .../BenchmarkCapabilities.cs | 2 +- src/Moryx.Benchmarking/BenchmarkInstance.cs | 2 +- src/Moryx.Benchmarking/BenchmarkProduct.cs | 2 +- src/Moryx.Benchmarking/BenchmarkResult.cs | 2 +- src/Moryx.Benchmarking/BenchmarkStep.cs | 2 +- src/Moryx.Benchmarking/BenchmarkTracing.cs | 2 +- src/Moryx.Benchmarking/BenchmarkTrigger.cs | 2 +- .../Pages/CommandCenter.cshtml.cs | 2 +- .../DataBitTypes.cs | 2 +- .../SerialBinaryConfig.cs | 2 +- .../SerialBinaryConnection.cs | 6 +- .../SerialPortFactory.cs | 2 +- src/Moryx.Container/CastleContainer.cs | 10 + .../ChildContainerSubResolver.cs | 4 +- .../ConfigBasedComponentSelector.cs | 6 +- .../NameBasedComponentSelector.cs | 4 +- src/Moryx.Container/MoryxFacility.cs | 6 +- .../NamedDependencyResolver.cs | 8 +- .../ServiceProviderSubResolver.cs | 2 +- src/Moryx.Container/StrategySubResolver.cs | 6 +- .../JobManagementController.cs | 10 +- .../JobPermissions.cs | 2 +- .../Models/Converter.cs | 4 + .../Models/JobModel.cs | 2 +- .../Models/ProductionJobModel.cs | 2 +- .../Models/SetupJobModel.cs | 2 +- .../Models/StateChangeModel.cs | 2 +- .../Components/IMaterialManager.cs | 2 +- .../Implementation/MaterialManager.cs | 6 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 6 +- .../Facades/JobManagementFacade.cs | 7 +- .../IdShiftGenerator.cs | 2 +- .../Jobs/Components/BrokenJobData.cs | 2 +- .../Jobs/Components/IJobDataList.cs | 2 +- .../Jobs/Components/IJobDispatcher.cs | 2 +- .../Jobs/Components/IJobHandler.cs | 2 +- .../Jobs/Components/IJobHistory.cs | 2 +- .../Jobs/Components/IJobManager.cs | 2 +- .../Jobs/Components/ModifiedJobsFragment.cs | 2 +- .../Jobs/EngineJob.cs | 3 +- .../Jobs/IJobData.cs | 2 +- .../Jobs/IJobDataFactory.cs | 10 + .../Jobs/IJobState.cs | 2 +- .../Jobs/IProductionJobData.cs | 2 +- .../Jobs/ISetupJobData.cs | 2 +- .../Jobs/Implementation/IJobStorage.cs | 2 +- .../Jobs/Implementation/JobDispatcher.cs | 4 +- .../Jobs/Implementation/JobList.cs | 38 +- .../Jobs/Implementation/JobManager.cs | 21 +- .../Jobs/Implementation/JobStorage.cs | 62 ++- .../Jobs/Implementation/ParallelScheduler.cs | 6 +- .../Implementation/ParallelSchedulerConfig.cs | 2 +- .../Implementation/SchedulerExtensions.cs | 4 + .../Jobs/Implementation/SeamlessScheduler.cs | 5 + .../Implementation/SeamlessSchedulerConfig.cs | 2 +- .../Jobs/JobDataBase.cs | 6 +- .../Jobs/JobStateBase.cs | 4 +- .../Jobs/JobStateEventArgs.cs | 2 +- .../Jobs/ProcessDataIterator.cs | 2 +- .../Jobs/ProcessList.cs | 2 +- .../Jobs/Production/ProductionJobData.cs | 15 + .../Jobs/Production/ProductionJobStateBase.cs | 6 +- .../Jobs/Production/States/AbortingState.cs | 2 +- .../Jobs/Production/States/CleanUpState.cs | 4 +- .../Production/States/CleanUpWaitingState.cs | 2 +- .../Jobs/Production/States/CleaningUpState.cs | 2 +- .../Jobs/Production/States/CompletedState.cs | 2 +- .../States/CompletingInterruptedState.cs | 2 +- .../CompletingInterruptedWaitingState.cs | 2 +- .../States/CompletingInterruptingState.cs | 12 +- .../Jobs/Production/States/CompletingState.cs | 2 +- .../Jobs/Production/States/DiscardingState.cs | 2 +- .../Jobs/Production/States/DispatchedState.cs | 2 +- .../Jobs/Production/States/InitialState.cs | 4 +- .../Production/States/InterruptedState.cs | 2 +- .../States/InterruptedWaitingState.cs | 2 +- .../Production/States/InterruptingState.cs | 2 +- .../Jobs/Production/States/RunningState.cs | 2 +- .../Jobs/Production/States/SuspendedState.cs | 2 +- .../Jobs/Production/States/WaitingState.cs | 2 +- .../Jobs/Setup/ISetupJobHandler.cs | 2 +- .../Jobs/Setup/SetupJobData.cs | 6 + .../Jobs/Setup/SetupJobHandler.cs | 19 +- .../Jobs/Setup/SetupJobStateBase.cs | 2 +- .../Jobs/Setup/States/AbortingSetupState.cs | 6 +- .../Jobs/Setup/States/CompletedState.cs | 2 +- .../Jobs/Setup/States/InitialState.cs | 2 +- .../Jobs/Setup/States/InterruptingState.cs | 4 +- .../Jobs/Setup/States/RequestRecipeState.cs | 2 +- .../Setup/States/RetrySetupBlockedState.cs | 2 +- .../Jobs/Setup/States/RunningState.cs | 8 +- .../Jobs/Setup/States/WaitingState.cs | 6 +- .../Jobs/Setup/TemporarySetupProvider.cs | 2 +- .../Jobs/WorkplanValidation.cs | 6 +- .../Model/API/IActivityEntityRepository.cs | 2 +- .../Model/API/IJobEntityRepository.cs | 2 +- .../Model/API/IProcessEntityRepository.cs | 2 +- .../Model/API/ITokenHolderEntityRepository.cs | 2 +- .../Model/API/ITracingTypeRepository.cs | 2 +- .../Model/Entities/ActivityEntity.cs | 4 +- .../Model/Entities/JobEntity.cs | 2 +- .../Model/Entities/ProcessEntity.cs | 2 +- .../Model/Entities/TokenHolderEntity.cs | 2 +- .../Model/Entities/TracingType.cs | 2 +- .../Npgsql/20220831123023_InitialCreate.cs | 2 +- .../Npgsql/20251030111419_TableNames.cs | 4 +- ...1202141815_RemovedTypeNameProcessEntity.cs | 4 +- .../Sqlite/20230216064711_InitialCreate.cs | 2 +- .../Sqlite/20251030111412_TableNames.cs | 4 +- ...1202141833_RemovedTypeNameProcessEntity.cs | 4 +- .../Model/NpgsqlProcessContext.cs | 2 +- .../Model/ProcessContext.cs | 2 +- .../Model/SqliteProcessContext.cs | 2 +- .../ComponentOrchestration.cs | 8 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 1 - .../ModuleController/ModuleController.cs | 2 + .../Processes/ActivityState.cs | 2 +- .../Processes/CellReference.cs | 2 +- .../Processes/Components/ActivityEventArgs.cs | 2 +- .../Components/IActivityDispatcher.cs | 2 +- .../Components/IActivityPoolListener.cs | 2 +- .../Components/ICellSelectorFactory.cs | 2 +- .../Processes/Components/IFailurePredictor.cs | 2 +- .../Components/IProcessController.cs | 2 +- .../Processes/Components/IProcessStorage.cs | 2 +- .../Components/IResourceAssignment.cs | 2 +- .../Processes/Components/ProcessEventArgs.cs | 2 +- .../Implementation/ActivityDispatcher.cs | 56 ++- .../Processes/Implementation/ActivityPool.cs | 15 + .../Implementation/ActivityProvider.cs | 28 +- .../Implementation/ActivityTimeoutObserver.cs | 8 + .../Implementation/FailurePredictor.cs | 7 + .../Implementation/ProcessArchive.cs | 31 +- .../Implementation/ProcessController.cs | 2 +- .../Implementation/ProcessInterruption.cs | 26 +- .../Implementation/ProcessRemoval.cs | 14 +- .../Implementation/ResourceAssignment.cs | 14 + .../Implementation/StorageTrigger.cs | 26 + .../Processes/ProcessData.cs | 21 +- .../Processes/ProcessState.cs | 2 +- .../Processes/ProcessStorage.cs | 53 +- .../Processes/ResourceAndSession.cs | 19 +- .../ProcessHolderEventHandlers.cs | 2 +- .../Models/ActivityResourceModel.cs | 2 +- .../Models/Converter.cs | 25 +- .../Models/JobProcessModel.cs | 2 +- .../Models/ProcessActivityModel.cs | 4 +- .../Models/TracingModel.cs | 2 +- .../Models/TracingSerialization.cs | 2 +- .../ProcessPermissions.cs | 2 +- .../ProcessHolderGroupStream.cs | 2 +- .../Components/ISetupManager.cs | 2 +- .../Components/ISetupTriggerFactory.cs | 2 +- .../Facades/SetupProviderFacade.cs | 6 +- .../Implementation/SetupManager.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 4 +- .../Components/IProcessSimulator.cs | 2 +- .../ConcurrentDictionaryExtensions.cs | 6 +- .../Implementation/ProcessMovement.cs | 2 +- .../Implementation/ProcessSimulator.cs | 20 +- .../ModuleController/ModuleConsole.cs | 4 +- .../ModuleController/ModuleController.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../AssembleActivity.cs | 2 +- .../AssembleActivityResult.cs | 2 +- .../AssembleParameters.cs | 2 +- .../AssembleSetupActivity.cs | 2 +- .../AssembleSetupParameters.cs | 2 +- .../AssembleSetupTask.cs | 2 +- .../AssembleSetupTrigger.cs | 14 +- .../AssembleSetupTriggerConfig.cs | 2 +- .../IAssembleActivity.cs | 2 +- .../IAssembleSetupActivity.cs | 2 +- .../Identity/AssignIdentityActivity.cs | 2 +- .../Identity/AssignIdentityParameters.cs | 4 +- .../Identity/AssignIdentityResults.cs | 2 +- .../Identity/IAssignIdentityParameters.cs | 2 +- .../Activities/Mounting/MountActivity.cs | 2 +- .../Activities/Mounting/MountingParameters.cs | 2 +- .../Activities/Mounting/MountingResult.cs | 4 +- .../Activities/Mounting/UnmountActivity.cs | 2 +- .../Activities/Mounting/UnmountingResult.cs | 2 +- .../SubWorkplan/SubWorkplanActivity.cs | 2 +- .../SubWorkplan/SubWorkplanParameters.cs | 2 +- .../Capabilities/AssembleCapabilities.cs | 2 +- .../AssignIdentityCapabilities.cs | 2 +- .../Capabilities/IdentitySource.cs | 2 +- .../Capabilities/MountCapabilities.cs | 4 +- .../DummyActivity.cs | 2 +- .../DummyRecipe.cs | 6 +- .../Identity/NumberingSchemeIdentity.cs | 2 +- .../Identity/TestNumberIdentity.cs | 2 +- .../Tasks/AssignIdentityTask.cs | 2 +- .../Tasks/MountTask.cs | 2 +- .../Tasks/SubWorkplanTask.cs | 4 +- .../Tasks/UnmountTask.cs | 2 +- .../Activities/ActivityClassification.cs | 2 +- .../Activities/IActivityTimeoutParameters.cs | 2 +- .../Activities/IControlSystemActivity.cs | 2 +- .../IInstanceModificationActivity.cs | 2 +- .../Activities/IMountingActivity.cs | 2 +- .../Activities/InstanceModificationType.cs | 2 +- .../Activities/ProcessFixupActivity.cs | 2 +- .../ProcessFixupCapapabilities.cs | 2 +- .../Cells/ActivityCompleted.cs | 2 +- .../Cells/ActivityStart.cs | 4 + src/Moryx.ControlSystem/Cells/Cell.cs | 2 +- .../Cells/CellSelectorBase.cs | 2 +- .../Cells/CellSelectorConfig.cs | 2 +- src/Moryx.ControlSystem/Cells/ICell.cs | 2 +- .../Cells/ICellSelector.cs | 2 +- .../Cells/ICompletableSession.cs | 2 +- .../Cells/NotReadyToWork.cs | 2 +- .../Cells/ProcessReference.cs | 11 +- src/Moryx.ControlSystem/Cells/ReadyToWork.cs | 2 +- .../Cells/ReadyToWorkType.cs | 2 +- .../Cells/SequenceCompleted.cs | 2 +- src/Moryx.ControlSystem/Cells/Session.cs | 2 +- .../Cells/SessionExtensions.cs | 2 +- .../Cells/UnknownActivityAborted.cs | 2 +- src/Moryx.ControlSystem/Jobs/IJobList.cs | 2 +- .../Jobs/IJobManagement.cs | 3 +- src/Moryx.ControlSystem/Jobs/IJobScheduler.cs | 2 +- .../Jobs/IPredictiveJob.cs | 2 +- .../Jobs/JobClassification.cs | 2 +- .../Jobs/JobCreationContext.cs | 2 +- src/Moryx.ControlSystem/Jobs/JobEvaluation.cs | 2 +- src/Moryx.ControlSystem/Jobs/JobExtensions.cs | 4 +- src/Moryx.ControlSystem/Jobs/JobPosition.cs | 2 +- .../Jobs/JobPositionType.cs | 2 +- .../Jobs/JobSchedulerBase.cs | 2 + .../Jobs/JobSchedulerConfig.cs | 2 +- src/Moryx.ControlSystem/Jobs/JobSlots.cs | 20 +- .../Jobs/JobStateChangedEventArgs.cs | 2 +- .../Materials/IMaterialContainer.cs | 2 +- .../Materials/MaterialCapabilities.cs | 2 +- .../Processes/ActivityUpdatedEventArgs.cs | 2 +- .../Processes/EmptyProcess.cs | 2 +- .../Processes/IActivityPool.cs | 2 +- .../Processes/IProcessControl.cs | 2 +- .../Processes/IProcessHolderGroup.cs | 2 +- .../Processes/IProcessHolderPosition.cs | 2 +- .../Processes/IProcessReporter.cs | 2 +- .../Processes/MountInformation.cs | 2 +- .../Processes/ProcessHolderExtensions.cs | 11 + .../Processes/ProcessHolderGroup.cs | 2 +- .../Processes/ProcessHolderTracing.cs | 2 +- .../Processes/ProcessMovement.cs | 10 + .../Processes/ProcessReplacement.cs | 1 - .../Processes/ProcessUpdatedEventArgs.cs | 2 +- .../Processes/ReportAction.cs | 2 +- .../Processes/UnknownProcess.cs | 2 +- .../Recipes/IOrderBasedRecipe.cs | 2 +- .../Recipes/IRecipeExtensions.cs | 2 +- .../Recipes/OrderBasedRecipe.cs | 2 +- .../Recipes/SetupRecipe.cs | 2 +- .../Setups/CurrentResourceTarget.cs | 2 +- .../Setups/ISetupProvider.cs | 2 +- src/Moryx.ControlSystem/Setups/ISetupStep.cs | 2 +- .../Setups/ISetupTarget.cs | 2 +- .../Setups/ISetupTrigger.cs | 2 +- .../Setups/SetupClassification.cs | 2 +- .../Setups/SetupEvaluation.cs | 2 +- .../Setups/SetupExecution.cs | 2 +- .../Setups/SetupTriggerBase.cs | 2 +- .../Setups/SetupTriggerConfig.cs | 2 +- .../Simulation/ISimulationDriver.cs | 2 +- .../Simulation/ISimulationParameters.cs | 2 +- .../Simulation/SimulationState.cs | 2 +- .../Transport/ITransportSystem.cs | 2 +- .../Transport/TransportCapabilities.cs | 8 +- .../Transport/TransportMode.cs | 2 +- .../Facades/DependentTestModuleFacade.cs | 2 +- .../Facades/IDependentTestModule.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 2 +- .../ModuleController/ModuleController.cs | 2 +- src/Moryx.Drivers.Mqtt/MqttDriver.cs | 25 +- src/Moryx.Drivers.Mqtt/MqttTopic.cs | 12 +- .../States/ConnectedToBrokerState.cs | 2 +- .../States/ConnectingToBrokerState.cs | 2 +- .../States/DisconnectedState.cs | 2 +- .../Topics/JsonOptionsExtension.cs | 3 +- .../Topics/MqttTopicJson.cs | 1 - src/Moryx.Drivers.OpcUa/DataValueResult.cs | 2 +- .../Exceptions/InvalidCertificateException.cs | 2 +- src/Moryx.Drivers.OpcUa/NodeIdAlias.cs | 2 +- src/Moryx.Drivers.OpcUa/OpcUaInput.cs | 2 + .../InOutDriver/SimulatedInOutDriver.cs | 4 +- .../InOutDriver/SimulatedInput.cs | 2 +- .../EntryVisualizationAttribute.cs | 2 +- src/Moryx.Factory/ILocation.cs | 2 +- src/Moryx.Factory/IMachineGroup.cs | 2 +- src/Moryx.Factory/IMachineLocation.cs | 2 +- src/Moryx.Factory/IManufacturingFactory.cs | 2 +- src/Moryx.Factory/ITransportPath.cs | 2 +- src/Moryx.Factory/MachineGroup.cs | 4 +- src/Moryx.Factory/MachineLocation.cs | 6 +- src/Moryx.Factory/ManufacturingFactory.cs | 2 +- src/Moryx.Factory/Position.cs | 2 +- src/Moryx.Factory/SwitchPoint.cs | 6 +- src/Moryx.Factory/TransportPath.cs | 6 +- .../Converter/CellSerialization.cs | 2 +- .../Converter/Converter.cs | 1 - .../Exceptions/NoRootFactoryException.cs | 2 +- .../Extensions/CellExtensions.cs | 11 +- .../Extensions/FactoryMonitorHelper.cs | 1 - .../Extensions/ResourceExtensions.cs | 1 - .../Extensions/SimpleGraphExtensions.cs | 2 +- .../FactoryMonitorController.cs | 22 +- .../FactoryMonitorPermissions.cs | 2 +- .../Models/ActivityChangedModel.cs | 4 +- .../Models/CellLocationModel.cs | 2 +- .../Models/CellSettingsModel.cs | 2 +- .../Models/CellState.cs | 2 +- .../Models/CellStateChangedModel.cs | 2 +- .../Models/FactoryModel.cs | 2 +- .../Models/FactoryStateModel.cs | 2 +- .../Models/MachineGroupModel.cs | 2 +- .../Models/OrderChangedModel.cs | 2 +- .../Models/OrderModel.cs | 2 +- .../Models/OrderReferenceModel.cs | 2 +- .../Models/SimpleFactoryGraph.cs | 2 +- .../Models/SimpleGraph.cs | 1 - .../Models/TransportPathModel.cs | 2 +- .../Models/TransportRouteModel.cs | 2 +- .../Models/VisualizableItemModel.cs | 2 +- .../Pages/FactoryMonitor.cshtml.cs | 6 +- .../Constants/Roles.cs | 2 +- .../Controllers/API/AuthController.cs | 20 +- .../Controllers/MVC/HomeController.cs | 4 +- .../Controllers/MVC/LoginController.cs | 17 +- .../Controllers/MVC/PermissionsController.cs | 6 +- .../MVC/RolePermissionsController.cs | 4 +- .../Controllers/MVC/RolesController.cs | 2 +- .../Controllers/MVC/UserRolesController.cs | 2 +- .../Controllers/MVC/UsersController.cs | 15 +- .../Data/MoryxIdentitiesDbContext.cs | 2 +- .../Data/MoryxRole.cs | 2 +- .../Data/MoryxUser.cs | 2 +- .../Data/PasswordReset.cs | 2 +- .../Data/Permission.cs | 2 +- .../Data/PermissionRole.cs | 2 +- .../Data/RefreshToken.cs | 2 +- .../Extensions/ClaimsPrincipalExtension.cs | 6 +- .../Extensions/CookiesExtensions.cs | 4 +- .../Extensions/HostExtensions.cs | 8 +- .../Extensions/HtmlHelperExtensions.cs | 8 +- .../Extensions/ServiceCollectionExtensions.cs | 2 +- .../Identity/AppClaimsPrincipalFactory.cs | 8 +- .../Identity/IPasswordResetService.cs | 2 +- .../Identity/IPermissionManager.cs | 2 +- .../Identity/ITokenService.cs | 2 +- .../Identity/MoryxUserManager.cs | 2 +- .../Identity/PasswordResetService.cs | 4 +- .../Identity/PermissionManager.cs | 18 +- .../Identity/TokenService.cs | 31 +- .../20210902100252_CreateIdentity.cs | 469 +++++++++--------- .../20210903081444_AddedRefreshTokensTable.cs | 75 ++- .../20230309102819_UpdateTimestampType.cs | 99 ++-- .../20230403163720_AddedPasswordResets.cs | 69 ++- ...40920134143_ChangeRefreshTokensOnDelete.cs | 65 ++- .../Migrations/20260108201039_MORYX10.cs | 147 +++--- .../Models/ErrorViewModel.cs | 2 +- .../Models/MoryxUserModel.cs | 4 +- .../Models/MoryxUserRegisterModel.cs | 4 +- .../Models/MoryxUserResetPasswordModel.cs | 4 +- .../Models/MoryxUserUpdateModel.cs | 2 +- .../Models/PermissionModel.cs | 2 +- .../Models/PermissionsViewModel.cs | 2 +- .../Models/RolePermissionsViewModel.cs | 2 +- .../Models/TokenRequest.cs | 2 +- .../Models/UserLoginModel.cs | 2 +- .../Models/UserRolesViewModel.cs | 2 +- .../Settings/JwtSettings.cs | 2 +- src/Moryx.Identity/Models/AuthResult.cs | 2 +- .../MoryxAccessManagementClient.cs | 2 +- .../MoryxAuthorizationPolicyProvider.cs | 2 +- src/Moryx.Identity/MoryxIdentityDefaults.cs | 2 +- src/Moryx.Identity/MoryxIdentityExtensions.cs | 2 +- src/Moryx.Identity/MoryxIdentityHandler.cs | 20 +- src/Moryx.Identity/MoryxIdentityOptions.cs | 2 +- .../MoryxIdentityResultHandler.cs | 2 +- src/Moryx.Launcher/IShellNavigator.cs | 2 +- src/Moryx.Launcher/LauncherRegionAttribute.cs | 1 - src/Moryx.Launcher/Models/CultureModel.cs | 2 +- src/Moryx.Launcher/Models/RegionItem.cs | 2 +- src/Moryx.Launcher/ShellNavigator.cs | 12 +- .../MediaModelConverter.cs | 4 +- src/Moryx.Media.Endpoints/MediaPermissions.cs | 2 +- .../MediaServerController.cs | 47 +- .../Models/ContentDescriptorModel.cs | 2 +- .../Models/FileDescriptorModel.cs | 2 +- .../Models/PreviewDescriptorModel.cs | 4 +- src/Moryx.Media.Endpoints/UploadValidation.cs | 22 +- .../ContentManager/ContentManager.cs | 34 ++ .../ContentManager/HashPath.cs | 14 +- .../ContentManager/IContentManager.cs | 2 +- .../Facades/MediaServerFacade.cs | 2 +- src/Moryx.Media.Server/InternalConstants.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 4 +- .../ModuleController/ModuleController.cs | 2 +- .../Previews/FFmpeg/FFmpegPreviewCreator.cs | 4 +- .../FFmpeg/FFmpegPreviewCreatorConfig.cs | 2 +- .../Previews/IPreviewCreatorFactory.cs | 2 +- .../Previews/IPreviewService.cs | 2 +- .../Previews/Image/ImagePreviewCreator.cs | 6 +- .../Image/ImagePreviewCreatorConfig.cs | 2 +- .../Previews/PreviewService.cs | 10 +- src/Moryx.Media/ContentAddingInfo.cs | 2 +- src/Moryx.Media/ContentDescriptor.cs | 2 +- src/Moryx.Media/FileDescriptor.cs | 2 +- src/Moryx.Media/IMediaServer.cs | 2 +- src/Moryx.Media/MediaConstants.cs | 2 +- src/Moryx.Media/PreviewDescriptor.cs | 2 +- src/Moryx.Media/PreviewState.cs | 2 +- src/Moryx.Media/Previews/IPreviewCreator.cs | 2 +- .../Previews/PreviewCreatorBase.cs | 2 +- .../Previews/PreviewCreatorConfig.cs | 2 +- src/Moryx.Media/Previews/PreviewJob.cs | 2 +- src/Moryx.Media/Previews/PreviewJobResult.cs | 2 +- src/Moryx.Media/VariantDescriptor.cs | 2 +- .../InMemoryDbContextManager.cs | 3 +- .../InMemoryUnitOfWorkFactory.cs | 3 +- .../NpgsqlDatabaseConfig.cs | 2 +- .../SqlServerDatabaseConfig.cs | 2 +- .../SqlServerDbContextAttribute.cs | 2 +- .../SqlServerModelConfigurator.cs | 4 +- .../SqliteDatabaseConfig.cs | 4 +- .../SqliteDbContextAttribute.cs | 2 +- .../SqliteDbContextManager.cs | 3 +- .../SqliteModelConfigurator.cs | 2 + .../Annotations/DateTimeKindAnnotation.cs | 6 + .../Attributes/DateTimeKindAttribute.cs | 2 +- .../Attributes/DefaultSchemaAttribute.cs | 2 +- .../Attributes/ModelSetupAttribute.cs | 2 +- .../Configuration/ModelConfiguratorBase.cs | 14 +- src/Moryx.Model/ContextFactory.cs | 3 +- src/Moryx.Model/DataModification.cs | 8 +- src/Moryx.Model/DatabaseConfig.cs | 4 + src/Moryx.Model/DbContextManager.cs | 17 +- src/Moryx.Model/EntityBase.cs | 2 +- .../Extensions/DbContextExtensions.cs | 2 +- src/Moryx.Model/Extensions/DbSetExtensions.cs | 4 +- .../Extensions/QueryableExtensions.cs | 2 +- .../Extensions/UnitOfWorkExtensions.cs | 2 +- src/Moryx.Model/IContextFactory.cs | 3 +- src/Moryx.Model/IDbContextManager.cs | 2 +- src/Moryx.Model/IEntity.cs | 2 +- src/Moryx.Model/IModelSetup.cs | 2 +- src/Moryx.Model/IModelSetupExecutor.cs | 4 +- .../ModelServiceCollectionExtension.cs | 2 +- src/Moryx.Model/ModelSetupExecutor.cs | 3 +- .../ModificationTrackedEntityBase.cs | 2 +- src/Moryx.Model/MoryxDbContext.cs | 6 +- src/Moryx.Model/Repositories/IRepository.cs | 2 +- src/Moryx.Model/Repositories/IUnitOfWork.cs | 2 +- .../Repositories/IUnitOfWorkFactory.cs | 3 +- .../Proxy/IMethodProxyStrategy.cs | 2 +- .../Proxy/MethodProxyStrategyBase.cs | 12 +- .../Proxy/ParameterPropertyMap.cs | 4 +- .../Proxy/RepositoryProxyBuilder.cs | 28 +- .../Proxy/Strategies/CreateMethodStrategy.cs | 6 +- .../Proxy/Strategies/FilterMethodStrategy.cs | 6 +- .../Proxy/Strategies/RemoveMethodStrategy.cs | 4 +- src/Moryx.Model/Repositories/Repository.cs | 10 +- .../Repositories/UnitOfWorkFactory.cs | 9 +- .../Models/Converter.cs | 5 +- .../Models/NotificationModel.cs | 2 +- .../NotificationPermissions.cs | 2 +- .../INotificationManager.cs | 2 +- .../API/INotificationEntityRepository.cs | 2 +- .../API/INotificationTypeEntityRepository.cs | 2 +- .../Model/Entities/NotificationEntity.cs | 2 +- .../Model/Entities/NotificationTypeEntity.cs | 2 +- .../Npgsql/20220825085020_InitialCreate.cs | 2 +- .../Npgsql/20251030111139_TableNames.cs | 4 +- .../Sqlite/20230215155009_InitialCreate.cs | 2 +- .../Sqlite/20251030111147_TableNames.cs | 4 +- .../Model/NotificationsContext.cs | 2 +- .../Model/NpgsqlNotificationsContext.cs | 2 +- .../Model/SqliteNotificationsContext.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleController.cs | 4 +- .../NotificationManager.cs | 48 +- .../Processors/INotificationProcessor.cs | 2 +- .../Processors/INotificationType.cs | 2 +- .../Processors/NotificationProcessor.cs | 2 +- .../Processors/NotificationProcessorBase.cs | 30 +- .../Processors/NotificationProcessorResult.cs | 2 +- .../Processors/NotificationType.cs | 2 +- .../Processors/NotificationTypeList.cs | 2 +- .../Adapter/INotificationSender.cs | 2 +- .../Adapter/INotificationSourceAdapter.cs | 2 +- .../Adapter/NotificationAdapter.cs | 23 +- .../Facade/INotificationSource.cs | 2 +- .../Facade/NotificationSourceFacade.cs | 2 +- .../INotificationPublisher.cs | 2 +- .../Notification/Notification.cs | 14 +- .../NotificationExtensions.cs | 2 +- .../Models/Converter.cs | 12 +- .../Models/OperatorModel.cs | 2 +- .../Models/SignInStatusChangedModel.cs | 18 +- .../Models/SkillCreationContextModel.cs | 2 +- .../Models/SkillModel.cs | 2 +- .../Models/SkillTypeCreationContextModel.cs | 2 +- .../Models/SkillTypeModel.cs | 2 +- .../OperatorPermissions.cs | 2 +- .../SkillPermissions.cs | 2 +- .../Components/IOperatorManager.cs | 2 +- .../Components/ISkillManager.cs | 2 +- .../Facade/UserResource.cs | 2 +- .../Implementation/OperatorManager.cs | 6 +- .../Implementation/OperatorStorage.cs | 4 +- .../Implementation/SkillManager.cs | 6 +- .../Implementation/SkillStorage.cs | 4 + .../Model/API/IOperatorEntityRepository.cs | 2 +- .../Model/API/ISkillEntityRepository.cs | 2 +- .../Model/API/ISkillTypeRepository.cs | 2 +- .../Model/Entities/OperatorEntity.cs | 6 +- .../Model/Entities/ResourceLinkEntity.cs | 2 +- .../Model/Entities/SkillTypeEntity.cs | 2 +- .../Npgsql/20240808094933_InitialCreate.cs | 2 +- .../Npgsql/20251030110809_TableNames.cs | 4 +- .../Sqlite/20240808095012_InitialCreate.cs | 2 +- .../Sqlite/20251030110844_TableNames.cs | 4 +- .../Model/NpgsqlOperatorsContext.cs | 2 +- .../Model/OperatorsContext.cs | 2 +- .../Model/SqliteOperatorsContext.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 4 +- .../Pages/Operators.cshtml.cs | 2 +- .../Attendances/AssignableOperator.cs | 2 +- src/Moryx.Operators/IOperatorManagement.cs | 2 +- src/Moryx.Operators/Operator.cs | 2 +- .../Skills/AttendableResource.cs | 9 +- .../Skills/Extensions/SkillExtensions.cs | 4 +- .../Skills/FaultyCapabilities.cs | 2 +- .../Skills/ISkillManagement.cs | 2 +- src/Moryx.Operators/Skills/SimpleSkill.cs | 6 +- src/Moryx.Operators/Skills/Skill.cs | 2 +- src/Moryx.Operators/Skills/SkillChange.cs | 2 +- .../Skills/SkillChangedEventArgs.cs | 2 +- .../Skills/SkillCreationContext.cs | 2 +- src/Moryx.Operators/Skills/SkillType.cs | 4 +- src/Moryx.Operators/Skills/SkillTypeChange.cs | 2 +- .../Skills/SkillTypeChangedEventArgs.cs | 2 +- .../Skills/SkillTypeCreationContext.cs | 2 +- .../ClientOperationSource.cs | 4 +- .../Models/AdviceModel.cs | 2 +- .../Models/BeginModel.cs | 2 +- .../Models/DocumentModel.cs | 2 +- .../Models/OperationChangedModel.cs | 2 +- .../Models/OperationCreationContextModel.cs | 7 +- .../Models/OperationLogMessageModel.cs | 2 +- .../Models/OperationModel.cs | 2 +- .../Models/OperationRecipeModel.cs | 2 +- .../Models/ProductPartModel.cs | 2 +- .../Models/ReportModel.cs | 2 +- .../OrderManagementController.cs | 54 +- .../OrderPermissions.cs | 2 +- .../Components/AdviceEventArgs.cs | 2 +- .../Components/IOperationData.cs | 2 +- .../Components/IOperationFactory.cs | 2 +- .../Components/IOrderData.cs | 2 +- .../Components/OperationAssignState.cs | 2 +- .../Components/OperationEventArgs.cs | 2 +- .../Components/ReportEventArgs.cs | 2 +- .../Components/StartedEventArgs.cs | 2 +- .../Facade/OrderManagementFacade.cs | 10 + .../Implementation/Advice/AdviceManager.cs | 4 +- .../Implementation/Advice/IAdviceManager.cs | 2 +- .../Advice/NullAdviceExecutor.cs | 2 +- .../Assignment/DefaultPartsAssignment.cs | 2 +- .../Assignment/DefaultProductAssignment.cs | 2 +- .../Assignment/DefaultRecipeAssignment.cs | 2 +- .../Assignment/DocumentAssignStep.cs | 6 +- .../Assignment/IAssignStepFactory.cs | 2 +- .../Assignment/IOperationAssignStep.cs | 2 +- .../Assignment/IOperationAssignment.cs | 2 +- .../Assignment/NullDocumentLoader.cs | 2 +- .../Assignment/NullOperationValidation.cs | 2 +- .../Assignment/NullPartsAssignment.cs | 2 +- .../Assignment/OperationAssignment.cs | 4 + .../Assignment/PartsAssignStep.cs | 2 +- .../Assignment/ProductAssignStep.cs | 6 +- .../Assignment/RecipeAssignStep.cs | 2 +- .../Assignment/RegexOperationValidation.cs | 12 +- .../RegexOperationValidationConfig.cs | 2 +- .../Assignment/UserAssignStep.cs | 2 +- .../Assignment/ValidateAssignStep.cs | 2 +- .../DoNotReplaceScrapStrategy.cs | 2 +- .../CountStrategy/ReplaceScrapStrategy.cs | 9 +- .../Implementation/JobHandler/IJobHandler.cs | 2 +- .../Implementation/JobHandler/JobHandler.cs | 10 +- .../SingleJobOperationDispatcher.cs | 6 +- .../Logging/IOperationLoggerProvider.cs | 2 +- .../Logging/OperationLoggerProvider.cs | 4 + .../Implementation/NullUserManagement.cs | 2 +- .../OperationData/InternalOperation.cs | 2 +- .../InternalOperationProgress.cs | 2 +- .../OperationData/OperationData.cs | 4 +- .../OperationData/States/AbortedState.cs | 4 +- .../States/AmountReachedAssignFailedState.cs | 2 +- .../States/AmountReachedAssignState.cs | 4 +- .../States/AmountReachedState.cs | 4 +- .../OperationData/States/CompletedState.cs | 2 +- .../OperationData/States/IOperationState.cs | 2 +- .../States/InitialAssignFailedState.cs | 4 +- .../States/InitialAssignState.cs | 4 +- .../OperationData/States/InitialState.cs | 4 +- .../States/InterruptedAssignFailedState.cs | 2 +- .../States/InterruptedAssignState.cs | 4 +- .../OperationData/States/InterruptedState.cs | 2 +- .../OperationData/States/InterruptingState.cs | 4 +- .../States/OperationDataStateBase.cs | 23 +- .../States/ReadyAssignFailedState.cs | 2 +- .../OperationData/States/ReadyAssignState.cs | 4 +- .../OperationData/States/ReadyState.cs | 2 +- .../OperationData/States/RunningState.cs | 2 +- .../OperationManager/IOperationManager.cs | 2 +- .../OperationManager/OperationManager.cs | 6 + .../Implementation/OperationStorage.cs | 10 +- .../Implementation/OrderData/InternalOrder.cs | 2 +- .../Implementation/OrderData/OrderData.cs | 2 +- .../Implementation/Pool/IOperationDataPool.cs | 2 +- .../Implementation/Pool/OperationDataPool.cs | 10 + .../API/IOperationAdviceEntityRepository.cs | 2 +- .../Model/API/IOperationEntityRepository.cs | 2 +- .../IOperationJobReferenceEntityRepository.cs | 2 +- ...perationRecipeReferenceEntityRepository.cs | 2 +- .../API/IOperationReportEntityRepository.cs | 2 +- .../Model/API/IOrderEntityRepository.cs | 2 +- .../Model/API/IProductPartEntityRepository.cs | 2 +- .../Model/Entities/OperationAdviceEntity.cs | 2 +- .../Model/Entities/OperationEntity.cs | 2 +- .../Entities/OperationJobReferenceEntity.cs | 2 +- .../OperationRecipeReferenceEntity.cs | 2 +- .../Model/Entities/OperationReportEntity.cs | 2 +- .../Model/Entities/OrderEntity.cs | 2 +- .../Model/Entities/ProductPartEntity.cs | 2 +- .../Npgsql/20220825105205_InitialCreate.cs | 2 +- .../Npgsql/20251030110554_TableNames.cs | 4 +- .../Sqlite/20230215153734_InitialCreate.cs | 2 +- .../Sqlite/20251030110420_TableNames.cs | 4 +- .../Model/NpgsqlOrdersContext.cs | 2 +- .../Model/OrdersContext.cs | 2 +- .../Model/SqliteOrdersContext.cs | 2 +- .../ComponentOrchestration.cs | 2 +- .../ModuleController/Config/AdviceConfig.cs | 2 +- .../ModuleController/Config/UsersConfig.cs | 2 +- .../ModuleController/ModuleConfig.cs | 3 +- .../ModuleController/ModuleConsole.cs | 2 +- .../ModuleController/ModuleController.cs | 14 +- .../Advice/AdviceExecutorConfig.cs | 2 +- src/Moryx.Orders/Advice/AdviceResult.cs | 2 +- src/Moryx.Orders/Advice/IAdviceExecutor.cs | 2 +- .../Documents/DocumentLoaderConfig.cs | 2 +- .../Assignment/Documents/IDocumentLoader.cs | 2 +- .../Assignment/Parts/IPartsAssignment.cs | 2 +- .../Parts/ProductAssignmentConfig.cs | 2 +- .../Assignment/Products/IProductAssignment.cs | 2 +- .../Products/ProductAssignmentBase.cs | 2 +- .../Products/ProductAssignmentConfig.cs | 2 +- .../Assignment/Recipes/IRecipeAssignment.cs | 2 +- .../Recipes/RecipeAssignmentBase.cs | 4 +- .../Recipes/RecipeAssignmentConfig.cs | 2 +- .../Validation/IOperationValidation.cs | 2 +- .../Validation/OperationValidationConfig.cs | 2 +- src/Moryx.Orders/DispatchContext.cs | 2 +- .../Dispatcher/IOperationDispatcher.cs | 2 +- .../Dispatcher/JobDispatchedEventArgs.cs | 2 +- .../Dispatcher/OperationDispatcherBase.cs | 3 +- .../Dispatcher/OperationDispatcherConfig.cs | 2 +- src/Moryx.Orders/Documents/Document.cs | 2 +- .../Documents/FileSystemDocument.cs | 2 +- src/Moryx.Orders/Documents/WebDocument.cs | 2 +- src/Moryx.Orders/Facade/IOrderManagement.cs | 2 +- .../Facade/OperationActionRequestEventArgs.cs | 2 +- .../Facade/OperationAdviceEventArgs.cs | 2 +- .../Facade/OperationBeginRequestEventArgs.cs | 2 +- .../Facade/OperationChangedEventArgs.cs | 2 +- .../Facade/OperationReportEventArgs.cs | 2 +- .../Facade/OperationReportRequestEventArgs.cs | 2 +- .../Facade/OperationStartedEventArgs.cs | 2 +- src/Moryx.Orders/OperationAdvice.cs | 2 +- src/Moryx.Orders/OperationCreationContext.cs | 2 +- src/Moryx.Orders/OperationExtensions.cs | 2 +- src/Moryx.Orders/OperationInfo.cs | 2 +- src/Moryx.Orders/PartClassification.cs | 2 +- src/Moryx.Orders/PartCreationContext.cs | 2 +- src/Moryx.Orders/ProductPart.cs | 2 +- src/Moryx.Orders/ReportContext.cs | 2 +- src/Moryx.Orders/ReportType.cs | 2 +- .../Restrictions/BeginRestriction.cs | 2 +- .../Restrictions/IOperationRestriction.cs | 2 +- .../Restrictions/ReportRestriction.cs | 2 +- .../Restrictions/RestrictionDescription.cs | 2 +- .../Restrictions/RestrictionSeverity.cs | 2 +- src/Moryx.Orders/StagingIndicator.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 6 +- .../ModuleController/ModuleController.cs | 2 +- .../NotificationBindingResolverFactory.cs | 4 +- .../NotificationPublisherAdapter.cs | 4 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 6 +- .../ModuleController/ModuleController.cs | 2 +- .../OrderManagementAdapter.cs | 6 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 6 +- .../ModuleController/ModuleController.cs | 2 +- .../ProcessEngineAdapter.cs | 4 +- .../ResourceActivityBindingResolverFactory.cs | 7 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 6 +- .../ModuleController/ModuleController.cs | 2 +- .../ResourceManagementAdapter.cs | 12 +- .../Controllers/ProcessDataController.cs | 6 +- .../Models/ConfiguredBindings.cs | 2 +- .../Models/ListenersResponse.cs | 2 +- .../Models/MeasurandBindingsResponse.cs | 2 +- .../Models/MeasurandResponse.cs | 2 +- .../Models/NameIdentifierResponse.cs | 2 +- .../Services/ConfigurationService.cs | 23 +- .../Services/IConfigurationService.cs | 2 +- .../Services/IListenerService.cs | 2 +- .../Services/ListenerService.cs | 6 +- .../InfluxDbListener.cs | 12 +- .../InfluxDbListenerV2.cs | 28 +- .../Facade/ProcessDataMonitorFacade.cs | 2 +- .../IProcessDataCollector.cs | 2 +- .../Listener/IProcessDataListenerFactory.cs | 2 +- .../Listener/LogListener.cs | 8 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 4 +- .../ModuleController/ModuleController.cs | 2 +- .../ProcessDataCollector.cs | 8 +- .../Properties/AssemblyInfo.cs | 2 +- .../CsvRow.cs | 2 +- .../CsvStructure.cs | 38 +- .../SpreadsheetsListener.cs | 11 +- .../SpreadsheetsListenerConfig.cs | 2 +- .../Bindings/MeasurementBindingProcessor.cs | 10 +- .../Configuration/MeasurementBinding.cs | 2 +- .../Configuration/ValueTarget.cs | 2 +- src/Moryx.ProcessData/DataField.cs | 2 +- src/Moryx.ProcessData/DataTag.cs | 2 +- src/Moryx.ProcessData/IProcessDataMonitor.cs | 2 +- .../IProcessDataPublisher.cs | 2 +- .../Listener/IProcessDataListener.cs | 2 +- .../Listener/ProcessDataListenerBase.cs | 6 +- .../Listener/ProcessDataListenerConfig.cs | 2 +- src/Moryx.ProcessData/Measurand.cs | 2 +- src/Moryx.ProcessData/Measurement.cs | 2 +- .../Components/IConfiguredTypesProvider.cs | 2 +- .../Components/IProductImporterFactory.cs | 2 +- .../Components/IProductInstanceStrategy.cs | 2 +- .../Components/IProductLinkStrategy.cs | 2 +- .../Components/IProductManager.cs | 2 +- .../Components/IProductRecipeStrategy.cs | 2 +- .../Components/IProductStorage.cs | 2 +- .../Components/IProductTypeStrategy.cs | 2 +- .../IPropertyMappedConfiguration.cs | 2 +- .../Components/IRecipeManagement.cs | 2 +- .../Components/IStorageStrategyFactory.cs | 2 +- .../Facades/ProductManagementFacade.cs | 10 + .../Implementation/ImportState.cs | 6 +- .../Implementation/ProductManager.cs | 18 +- .../Implementation/RecipeManagement.cs | 61 ++- .../Implementation/RecipeStorage.cs | 20 + .../Storage/ConstructorStrategyInformation.cs | 10 +- .../FloatStrategyConfigurationAttribute.cs | 2 +- .../Storage/InstanceStrategyBase.cs | 2 +- .../IntegerStrategyConfigurationAttribute.cs | 2 + .../Storage/LinkStrategyBase.cs | 2 +- .../Storage/PartSourceStrategy.cs | 2 +- .../Storage/ProductExpressionHelpers.cs | 10 + .../Implementation/Storage/ProductStorage.cs | 99 +++- .../Storage/ProductTypeConfiguration.cs | 2 +- .../PropertyStrategyConfigurationAttribute.cs | 2 +- .../Storage/RecipeStrategyBase.cs | 2 +- .../Implementation/Storage/StrategyBase.cs | 2 +- .../Storage/StrategyConfigurationAttribute.cs | 6 +- .../TextStrategyConfigurationAttribute.cs | 6 +- .../Storage/TypeStrategyBase.cs | 2 +- .../Implementation/WorkplanReferenceType.cs | 2 +- .../Model/API/IPartLinkRepository.cs | 2 +- .../Model/API/IProductInstanceRepository.cs | 2 +- .../Model/API/IProductTypeRepository.cs | 2 +- .../IWorkplanConnectorReferenceRepository.cs | 2 +- .../Model/API/IWorkplanReferenceRepository.cs | 2 +- .../Model/API/IWorkplanRepository.cs | 2 +- .../Model/Entities/IGenericColumns.cs | 2 +- .../Model/Entities/PartLinkEntity.cs | 2 +- .../Model/Entities/ProductTypeEntity.cs | 4 + .../Entities/ProductTypePropertiesEntity.cs | 2 +- .../Model/Entities/WorkplanConnectorEntity.cs | 2 +- .../WorkplanConnectorReferenceEntity.cs | 2 +- .../Model/Entities/WorkplanEntity.cs | 2 +- .../WorkplanOutputDescriptionEntity.cs | 2 +- .../Model/Entities/WorkplanReferenceEntity.cs | 2 +- .../Npgsql/20251202131135_StepTypeName.cs | 2 +- .../Npgsql/20251203182754_RecipeTypeName.cs | 4 +- .../Npgsql/20251210085949_ProductState.cs | 2 +- .../Sqlite/20251202123359_StepTypeName.cs | 2 +- .../Sqlite/20251203182818_RecipeTypeName.cs | 4 +- .../Sqlite/20251210093915_ProductState.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 2 +- .../AvailableColumnsAttribute.cs | 2 +- .../GenericStrategies/ConversionAccessor.cs | 2 +- .../DifferentialContractResolver.cs | 8 +- .../GenericStrategies/GenericEntityMapper.cs | 1 - .../GenericInstanceConfiguration.cs | 2 +- .../GenericInstanceStrategy.cs | 2 +- .../GenericLinkConfiguration.cs | 2 +- .../GenericStrategies/GenericLinkStrategy.cs | 2 +- .../GenericRecipeConfiguration.cs | 2 +- .../GenericRecipeStrategy.cs | 2 +- .../GenericTypeConfiguration.cs | 2 +- .../GenericStrategies/GenericTypeStrategy.cs | 2 +- .../GenericStrategies/IGenericMapper.cs | 2 +- .../IGenericMapperConfiguration.cs | 2 +- .../GenericStrategies/IPropertyMapper.cs | 2 +- .../IPropertyMapperFactory.cs | 2 +- .../GenericStrategies/IntegerColumnMapper.cs | 18 + .../GenericStrategies/NullPropertyMapper.cs | 2 +- .../GenericStrategies/PropertyMapper.cs | 6 + .../GenericStrategies/PropertyMapperConfig.cs | 2 +- .../Plugins/Importers/DefaultImporter.cs | 2 +- ...pertylessStrategyConfigurationAttribute.cs | 2 +- .../NullStrategies/SimpleLinkStrategy.cs | 2 +- .../NullStrategies/SkipInstancesStrategy.cs | 2 +- src/Moryx.Products.Management/TypeTool.cs | 5 +- .../Importer/FileImporterConfig.cs | 2 +- .../Importer/JsonProductTypeImporter.cs | 3 +- .../Importer/WatchImporter.cs | 4 +- .../Importer/WatchImporterConfig.cs | 2 +- .../ProductInstances/NeedleInstance.cs | 2 +- .../ProductInstances/WatchInstance.cs | 2 +- .../ProductInstances/WatchPackageInstance.cs | 2 +- .../ProductInstances/WatchfaceInstance.cs | 2 +- .../ProductTypes/NeedlePartLink.cs | 2 +- .../ProductTypes/NeedleRole.cs | 2 +- .../ProductTypes/NeedleType.cs | 2 +- .../ProductTypes/WatchPackageType.cs | 2 +- .../ProductTypes/WatchType.cs | 2 +- .../ProductTypes/WatchfaceType.cs | 2 +- .../Recipe/SampleRecipe.cs | 4 +- .../Recipe/WatchProductRecipe.cs | 2 +- .../Strategies/WatchStrategy.cs | 2 +- .../Pages/Products.cshtml.cs | 2 +- .../AssemblyCell.cs | 2 +- .../BenchmarkInitializer.cs | 2 +- .../BenchmarkReporter.cs | 6 +- .../BenchmarkReporterConfig.cs | 2 +- .../BenchmarkResource.cs | 2 + .../IBenchmarkResource.cs | 2 +- .../Messages/AssembleProductMessage.cs | 2 +- .../Messages/AssemblyCompletedMessage.cs | 2 +- .../Messages/ReleaseWorkpiece.cs | 2 +- .../Messages/WorkpieceArrivedMessage.cs | 2 +- .../SimulatedFakeDriver.cs | 14 +- .../Extensions/ResourceExtensions.cs | 2 +- .../Facades/ResourceManagementFacade.cs | 12 +- .../Facades/ResourceTypeTreeFacade.cs | 4 +- .../Model/API/IResourceRelationRepository.cs | 2 +- .../Model/API/IResourceRepository.cs | 2 +- .../Model/Entities/ResourceEntity.cs | 2 +- .../Model/Entities/ResourceRelationEntity.cs | 2 +- .../Npgsql/20211104134830_InitialCreate.cs | 2 +- .../Npgsql/20251124065017_UpdateEf10.cs | 5 +- .../Sqlite/20230215071938_InitialCreate.cs | 2 +- .../Model/NpgsqlResourcesContext.cs | 2 +- .../Model/ResourcesContext.cs | 2 +- .../Model/SqliteResourcesContext.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 2 +- .../Properties/AssemblyInfo.cs | 1 - .../Resources/IManagedResourceGraph.cs | 2 +- .../Resources/IResourceFactory.cs | 2 +- .../Resources/IResourceInitializerFactory.cs | 2 +- .../Resources/IResourceLinker.cs | 2 +- .../Resources/IResourceManager.cs | 2 +- .../Resources/IResourceTypeController.cs | 2 +- .../Resources/ResourceEntityAccessor.cs | 58 ++- .../Resources/ResourceGraph.cs | 8 +- .../Resources/ResourceLinker.cs | 2 +- .../Resources/ResourceManager.cs | 25 + .../Resources/ResourceReferenceTools.cs | 32 +- .../Resources/ResourceTypeController.cs | 39 +- .../Resources/ResourceTypeNode.cs | 24 +- .../AssembleResource.cs | 2 +- src/Moryx.Resources.Samples/BufferResource.cs | 3 + src/Moryx.Resources.Samples/Cell.cs | 2 +- src/Moryx.Resources.Samples/GateResource.cs | 2 +- .../IVisualInstructor.cs | 2 +- .../Initializer/SampleMachineInitializer.cs | 2 +- .../SampleMachineInitializerConfig.cs | 2 +- src/Moryx.Resources.Samples/Machine.cs | 1 - .../RefreshResource.cs | 2 +- .../RoutingResource.cs | 2 +- src/Moryx.Resources.Samples/SolderingCell.cs | 2 +- .../TcpDriverSample.cs | 7 +- .../VisualInstructor.cs | 14 + .../Pages/Resources.cshtml.cs | 2 +- .../Common/CommonController.cs | 2 + .../Response/HostInformationResponse.cs | 2 +- .../Common/Response/ServerTimeResponse.cs | 2 +- .../Databases/DatabaseController.cs | 30 +- .../Exceptions/BadRequestException.cs | 2 +- .../Databases/Models/DataModel.cs | 2 +- .../Databases/Models/DatabaseConfigModel.cs | 2 +- .../Databases/Models/DbMigrationsModel.cs | 2 +- .../Models/ModelConfiguratorModel.cs | 2 +- .../Databases/Models/SetupModel.cs | 2 +- .../Databases/Request/ExecuteSetupRequest.cs | 2 +- .../Databases/Response/DatabasesResponse.cs | 2 +- .../Response/TestConnectionResponse.cs | 2 +- .../Services/DatabaseConfigUpdateService.cs | 2 +- .../Services/IDatabaseConfigUpdateService.cs | 2 +- .../InvocationResponse.cs | 2 +- .../Modules/Models/AssemblyModel.cs | 2 +- .../Modules/Models/Config.cs | 2 +- .../Modules/Models/ConfigUpdateMode.cs | 2 +- .../Modules/Models/DependencyEvaluation.cs | 2 +- .../Modules/Models/ModuleNotificationModel.cs | 5 +- .../Modules/Models/SerializableException.cs | 2 +- .../Modules/Models/ServerModuleModel.cs | 2 +- .../Modules/ModulesController.cs | 41 +- .../Modules/Request/SaveConfigRequest.cs | 2 +- .../AdvancedEntrySerializeSerialization.cs | 4 +- .../RuntimePermissions.cs | 2 +- .../Configuration/ConfigLiveUpdater.cs | 17 +- .../ValueProvider/SharedConfigProvider.cs | 8 +- .../Modules/BehaviourAccess.cs | 4 + .../Components/IModuleDependencyManager.cs | 2 +- .../Components/MissingFacadeException.cs | 2 +- .../Components/ModuleDependencyManager.cs | 23 +- .../Modules/MissingModuleDependency.cs | 2 +- .../Modules/MissingServerModule.cs | 9 +- .../Modules/ModuleManagerConfig.cs | 2 +- src/Moryx.Runtime.Kernel/MoryxHost.cs | 2 +- .../Configuration/ModuleStrategyAttribute.cs | 2 +- .../Configuration/SharedConfigAttribute.cs | 2 +- src/Moryx.Runtime/Modules/ConfigParser.cs | 6 +- src/Moryx.Runtime/Modules/FacadeBase.cs | 5 +- src/Moryx.Runtime/Modules/IFacadeContainer.cs | 2 +- src/Moryx.Runtime/Modules/IFacadeControl.cs | 2 +- .../Modules/ILifeCycleBoundFacade.cs | 2 +- src/Moryx.Runtime/Modules/IServerModule.cs | 2 +- .../Modules/IServerModuleConsole.cs | 2 +- .../Management/HealthStateException.cs | 2 +- .../Management/IModuleDependencyTree.cs | 2 +- .../Modules/Management/IModuleManager.cs | 2 +- .../Management/RequiredModuleApiAttribute.cs | 2 +- .../Modules/ModuleNotification.cs | 2 +- .../Modules/ModuleStartBehaviour.cs | 2 +- src/Moryx.Runtime/Modules/ServerModuleBase.cs | 17 +- .../Modules/ServerModuleConsoleAttribute.cs | 2 +- .../Modules/ServerModuleState.cs | 2 +- .../Modules/States/FailureState.cs | 2 +- .../States/IServerModuleStateContext.cs | 2 +- .../Modules/States/InitializingState.cs | 2 +- .../Modules/States/MissingState.cs | 2 +- .../Modules/States/ReadyState.cs | 2 +- .../Modules/States/RunningState.cs | 2 +- .../Modules/States/ServerModuleStateBase.cs | 2 +- .../Modules/States/StartingState.cs | 2 +- .../Modules/States/StoppedState.cs | 2 +- .../Modules/States/StoppingState.cs | 2 +- src/Moryx.Runtime/Properties/AssemblyInfo.cs | 5 +- .../Models/Extensions.cs | 2 +- .../ShiftAssignementCreationContextModel.cs | 4 +- .../Models/ShiftAssignementModel.cs | 4 +- .../Models/ShiftCreationContextModel.cs | 2 +- .../Models/ShiftCriteria.cs | 4 +- .../Models/ShiftModel.cs | 2 +- .../Models/ShiftTypeCreationContextModel.cs | 2 +- .../Models/ShiftTypeModel.cs | 2 +- .../ShiftManagementController.cs | 22 + .../Implementation/IShiftManager.cs | 4 +- .../Implementation/IShiftStorage.cs | 4 +- .../Implementation/ShiftManager.cs | 6 +- .../Implementation/ShiftStorage.cs | 2 +- .../Model/API/IShiftAssignementRepository.cs | 4 +- .../Model/API/IShiftRepository.cs | 4 +- .../Model/API/IShiftTypeRepository.cs | 2 +- .../Model/Entities/EntityExtensions.cs | 2 +- .../Model/Entities/ShiftAssignementEntity.cs | 2 +- .../Model/Entities/ShiftEntity.cs | 4 +- .../Model/Entities/ShiftTypeEntity.cs | 4 +- .../Npgsql/20240613104936_InitialCreate.cs | 4 +- .../Npgsql/20251030111003_TableNames.cs | 4 +- .../Sqlite/20240613105036_InitialCreate.cs | 4 +- .../Sqlite/20251030111012_TableNames.cs | 4 +- .../Model/NpgsqlShiftsContext.cs | 4 +- .../Model/ShiftsContext.cs | 4 +- .../Model/SqliteShiftsContext.cs | 4 +- .../ModuleController/ModuleConfig.cs | 4 +- .../ModuleController/ModuleConsole.cs | 4 +- src/Moryx.Shifts/AssignedDays.cs | 2 +- src/Moryx.Shifts/IShiftManagement.cs | 2 +- src/Moryx.Shifts/Shift.cs | 2 +- src/Moryx.Shifts/ShiftAssignement.cs | 2 +- src/Moryx.Shifts/ShiftAssignementChange.cs | 2 +- .../ShiftAssignementCreationContext.cs | 2 +- .../ShiftAssignementsChangedEventArgs.cs | 2 +- src/Moryx.Shifts/ShiftChange.cs | 2 +- src/Moryx.Shifts/ShiftCreationContext.cs | 2 +- src/Moryx.Shifts/ShiftManagementExtensions.cs | 12 +- src/Moryx.Shifts/ShiftType.cs | 2 +- src/Moryx.Shifts/ShiftTypeChange.cs | 2 +- src/Moryx.Shifts/ShiftTypeCreationContext.cs | 2 +- .../ShiftTypesChangedEventArgs.cs | 2 +- src/Moryx.Shifts/ShiftsChangedEventArgs.cs | 2 +- .../Controllers/TestController.cs | 2 +- src/Moryx.TestModule/Facades/ITestModule.cs | 2 +- .../Facades/TestModuleFacade.cs | 2 +- src/Moryx.TestModule/JsonTest.cs | 8 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 14 +- .../ModuleController/ModuleController.cs | 2 +- src/Moryx.TestModule/Plugin/AnotherPlugin.cs | 2 +- .../Plugin/AnotherPluginConfig.cs | 2 +- src/Moryx.TestModule/Plugin/IAnotherPlugin.cs | 2 +- src/Moryx.TestModule/Plugin/ITestPlugin.cs | 2 +- src/Moryx.TestModule/Plugin/ITestSubPlugin.cs | 2 +- src/Moryx.TestModule/Plugin/TestPlugin.cs | 2 +- src/Moryx.TestModule/Plugin/TestPlugin1.cs | 2 +- src/Moryx.TestModule/Plugin/TestPlugin2.cs | 2 +- .../Plugin/TestPluginConfig.cs | 2 +- .../Plugin/TestPluginConfig1.cs | 2 +- .../Plugin/TestPluginConfig2.cs | 2 +- src/Moryx.TestModule/Plugin/TestSubPlugin.cs | 2 +- src/Moryx.TestModule/Plugin/TestSubPlugin1.cs | 2 +- src/Moryx.TestModule/Plugin/TestSubPlugin2.cs | 2 +- .../Plugin/TestSubPluginConfig.cs | 2 +- .../Plugin/TestSubPluginConfig1.cs | 2 +- .../Plugin/TestSubPluginConfig2.cs | 2 +- .../MoryxTestEnvironment.cs | 8 +- .../API/IAnotherEntityRepository.cs | 2 +- .../API/ICarEntityRepository.cs | 2 +- .../API/IHouseEntityRepository.cs | 2 +- .../API/IHugePocoRepository.cs | 2 +- .../API/IJsonEntityRepository.cs | 2 +- .../API/ISportCarRepository.cs | 2 +- .../API/IWheelEntityRepository.cs | 2 +- .../Entities/AnotherEntity.cs | 2 +- .../Entities/CarEntity.cs | 2 +- .../Entities/HouseEntity.cs | 2 +- .../Entities/HugePocoEntity.cs | 2 +- .../Entities/JsonEntity.cs | 2 +- .../Entities/SportCarEntity.cs | 2 +- .../Entities/WheelEntity.cs | 2 +- .../Npgsql/20251030141744_InitialCreate.cs | 4 +- .../SqlServer/20251030141638_InitialCreate.cs | 4 +- .../Sqlite/20251030141720_InitialCreate.cs | 4 +- .../Setups/AnySetup.cs | 2 +- .../Setups/DisposedObjectSetup.cs | 2 +- .../BasicInterceptorInstaller.cs | 2 +- .../EmptyInterceptor.cs | 2 +- .../NotSoParallelOps.cs | 4 +- .../IVisualInstructionsController.cs | 2 +- .../Components/InstructionProcessor.cs | 14 +- .../VisualInstructionsController.cs | 17 +- .../Facades/VisualInstructionsFacade.cs | 2 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleConsole.cs | 4 +- .../ModuleController/ModuleController.cs | 2 +- .../Models/Converter.cs | 6 +- .../Models/InstructionItemModel.cs | 3 +- .../Models/InstructionModel.cs | 2 +- .../Models/InstructionResponseModel.cs | 2 +- .../Models/InstructionResultModel.cs | 2 +- .../Models/InstructionType.cs | 2 +- .../VisualInstructionsPermissions.cs | 2 +- .../ActiveInstruction.cs | 4 +- .../ActiveInstructionResponse.cs | 2 +- .../EnumInstructionAttribute.cs | 2 +- .../EnumInstructionResult.cs | 4 + .../IVisualInstructionSource.cs | 2 +- .../IVisualInstructions.cs | 2 +- .../IVisualInstructor.cs | 2 +- .../InstructionEventArgs.cs | 2 +- .../InstructionResult.cs | 2 +- .../VisualInstruction.cs | 2 +- .../VisualInstructionBinder.cs | 8 +- .../VisualInstructionParameters.cs | 6 +- .../VisualInstructorExtensions.cs | 2 +- .../Components/IWorkplanEditingSession.cs | 2 +- .../Components/IWorkplanEditor.cs | 2 +- .../Facade/WorkplanFacade.cs | 2 +- .../Implementation/Extensions.cs | 2 +- .../Implementation/InvolvedSteps.cs | 2 +- .../Implementation/WorkplanEditingSession.cs | 40 ++ .../Implementation/WorkplanEditor.cs | 6 +- .../ModuleController/ModuleConfig.cs | 2 +- .../ModuleController/ModuleController.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../Activities/TestActivity.cs | 2 +- .../Activities/TestParameters.cs | 2 +- .../Activities/TestTask.cs | 2 +- .../Models/ModelConverter.cs | 13 +- .../Models/WorkplanNodeModel.cs | 2 +- .../Models/WorkplanSessionModel.cs | 2 +- .../Models/WorkplanStepRecipe.cs | 6 +- .../Models/WorkplanStepSerialization.cs | 4 +- .../WorkplanEditingController.cs | 2 - src/Moryx.Workplans/IWorkplanEditing.cs | 2 +- src/Moryx.Workplans/WorkplanSession.cs | 2 +- .../ForceAssemblyReferenceAttribute.cs | 2 +- src/Moryx/Bindings/BindingResolverBase.cs | 8 +- .../Bindings/BindingResolverExtension.cs | 2 + src/Moryx/Bindings/BindingResolverFactory.cs | 4 +- src/Moryx/Bindings/DelegateResolver.cs | 4 +- src/Moryx/Bindings/FormatBindingResolver.cs | 2 +- src/Moryx/Bindings/IBindingResolver.cs | 2 +- src/Moryx/Bindings/IBindingResolverChain.cs | 2 +- src/Moryx/Bindings/IBindingResolverFactory.cs | 2 +- src/Moryx/Bindings/ITextBindingResolver.cs | 2 +- src/Moryx/Bindings/IndexResolver.cs | 4 +- src/Moryx/Bindings/NullResolver.cs | 2 +- .../Bindings/TextBindingResolverFactory.cs | 8 +- .../Collections/DelayQueue/DelayQueue.cs | 6 +- .../Collections/DelayQueue/IDelayQueue.cs | 2 +- .../DelayQueue/States/IDelayQueueContext.cs | 2 +- .../DelayQueue/States/QueueIdleState.cs | 2 +- .../DelayQueue/States/QueuePendingState.cs | 2 +- .../DelayQueue/States/QueueStateBase.cs | 2 +- .../DelayQueue/States/QueueStoppedState.cs | 2 +- src/Moryx/Collections/MergedCollection.cs | 2 +- src/Moryx/Collections/MonitorEnumerator.cs | 2 +- .../Collections/ProducerConsumerEnumerator.cs | 2 +- src/Moryx/Collections/SortableCollection.cs | 7 + .../Collections/StringNumericComparer.cs | 26 +- src/Moryx/Collections/WeakCollection.cs | 8 +- .../Attributes/PayloadPositionAttribute.cs | 2 +- .../Connection/BinaryConnectionConfig.cs | 2 +- .../Connection/BinaryConnectionState.cs | 2 +- .../Connection/ConnectionAttempt.cs | 8 +- .../Connection/IBinaryConnection.cs | 2 +- .../Connection/IBinaryConnectionFactory.cs | 2 +- .../Connection/IDeviceCommunication.cs | 2 +- .../Communication/Connection/StatusCheck.cs | 4 +- .../Interpreter/DelimitedMessageContext.cs | 2 +- .../DelimitedMessageInterpreter.cs | 33 +- .../Interpreter/HeaderMessageContext.cs | 2 +- .../Interpreter/HeaderMessageInterpreter.cs | 31 +- .../Communication/Interpreter/ReadContext.cs | 2 +- .../Client/States/ClientConnectedState.cs | 2 +- .../Client/States/ClientConnectingState.cs | 2 +- .../Client/States/ClientDisconnectedState.cs | 2 +- .../Client/States/ClientDisconnectingState.cs | 2 +- .../Client/States/ClientReconnectingState.cs | 2 +- .../Client/States/ClientRetryConnectState.cs | 2 +- .../Sockets/Client/States/ClientStateBase.cs | 2 +- .../Sockets/Client/TcpClientConfig.cs | 2 +- .../Sockets/Client/TcpClientConnection.cs | 18 + .../Sockets/InvalidHeaderException.cs | 2 +- .../Communication/Sockets/Server/PortMap.cs | 6 + .../Server/States/ServerConnectedState.cs | 2 +- .../Server/States/ServerListeningState.cs | 4 +- .../Server/States/ServerNotListeningState.cs | 2 +- .../Server/States/ServerReconnectingState.cs | 2 +- .../Sockets/Server/States/ServerStateBase.cs | 2 +- .../Sockets/Server/TcpListenerConfig.cs | 2 +- .../Sockets/Server/TcpListenerConnection.cs | 18 + .../Sockets/Server/TcpPortListener.cs | 6 +- .../Communication/Sockets/TcpTransmission.cs | 23 + .../Transmission/BinaryMessage.cs | 2 +- .../Transmission/IBinaryHeader.cs | 2 +- .../Transmission/IBinaryMessageHook.cs | 2 +- .../Transmission/IBinaryPayload.cs | 2 +- .../Communication/Transmission/IBinaryRoot.cs | 2 +- .../Transmission/IBinaryTransmission.cs | 2 +- .../Transmission/IByteSerializable.cs | 2 +- .../Transmission/IByteSerializer.cs | 2 +- .../Transmission/IMessageInterpreter.cs | 2 +- .../Transmission/IReadContext.cs | 2 +- .../Validation/IMessageValidator.cs | 2 +- src/Moryx/Configuration/ConfigBase.cs | 3 +- src/Moryx/Configuration/ConfigState.cs | 4 +- .../Defaults/CpuCountAttribute.cs | 2 +- .../Defaults/CurrentHostNameAttribute.cs | 2 +- .../Configuration/FileSystemPathAttribute.cs | 2 +- src/Moryx/Configuration/IConfigManager.cs | 2 +- .../Configuration/IEmptyPropertyProvider.cs | 2 +- src/Moryx/Configuration/IUpdatableConfig.cs | 2 +- .../Configuration/InvalidConfigException.cs | 2 +- .../PossibleValuesSerialization.cs | 10 + src/Moryx/Configuration/UpdatableEntry.cs | 2 +- .../DefaultCanWriteValueProviderFilter.cs | 2 +- .../ValueProvider/IValueProviderFilter.cs | 2 +- .../PropertyValidationException.cs | 6 +- .../Providers/ActivatorValueProvider.cs | 2 +- .../DefaultValueAttributeProvider.cs | 6 +- .../ValueProviderExecutorSettings.cs | 2 +- .../Attributes/ComponentAttribute.cs | 2 +- .../ComponentLoaderIgnoreAttribute.cs | 2 +- .../DependencyRegistrationAttribute.cs | 2 +- .../Container/Attributes/NamedAttribute.cs | 2 +- .../Container/Attributes/PluginAttribute.cs | 2 +- .../Attributes/PluginFactoryAttribute.cs | 2 +- .../IConfigBasedComponentSelector.cs | 2 +- .../INameBasedComponentSelector.cs | 2 +- .../ContainerLoadComponentsExtension.cs | 20 +- .../ContainerRegistrationExtensions.cs | 2 + .../Container/ContainerResolveExtensions.cs | 2 +- src/Moryx/Container/IContainer.cs | 2 +- .../Container/IModuleContainerFactory.cs | 2 +- src/Moryx/Container/INamedChildContainer.cs | 2 +- src/Moryx/Container/UseChildAttribute.cs | 2 +- src/Moryx/Logging/ILoggingComponent.cs | 2 +- src/Moryx/Logging/IModuleLogger.cs | 2 +- src/Moryx/Modules/ExpectedConfigAttribute.cs | 2 +- src/Moryx/Modules/IAsyncConfiguredPlugin.cs | 2 +- src/Moryx/Modules/IAsyncInitializable.cs | 2 +- src/Moryx/Modules/IAsyncPlugin.cs | 2 +- src/Moryx/Modules/IConfiguredInitializable.cs | 2 +- src/Moryx/Modules/IConfiguredPlugin.cs | 2 +- src/Moryx/Modules/IInitializable.cs | 2 +- src/Moryx/Modules/IInitializablePlugin.cs | 2 +- src/Moryx/Modules/IModule.cs | 2 +- src/Moryx/Modules/IModuleNotification.cs | 2 +- src/Moryx/Modules/IPlugin.cs | 2 +- src/Moryx/Modules/IPluginConfig.cs | 2 +- src/Moryx/Modules/IPriorizedInitializable.cs | 8 +- .../Modules/ModuleEventStreamAttribute.cs | 2 +- src/Moryx/Modules/ModuleMenuCategory.cs | 2 +- src/Moryx/Modules/WebModuleAttribute.cs | 2 +- src/Moryx/Notifications/Severity.cs | 2 +- src/Moryx/Platform.cs | 2 +- src/Moryx/Serialization/ByteSerializer.cs | 2 +- .../Serialization/DefaultSerialization.cs | 47 +- src/Moryx/Serialization/EntryConvert/Entry.cs | 20 +- .../EntryConvert/EntryConvert.cs | 28 ++ .../EntryConvert/EntryUnitType.cs | 2 +- .../EntryConvert/EntryValidation.cs | 2 +- .../Serialization/EntryConvert/EntryValue.cs | 2 +- .../Serialization/EntryConvert/MethodEntry.cs | 4 +- .../EntrySerializeSerialization.cs | 38 +- src/Moryx/Serialization/InlineConverter.cs | 28 +- src/Moryx/Serialization/MergedSerializer.cs | 2 +- .../PossibleValues/IntegerStepsAttribute.cs | 2 +- .../PossibleValues/PluginConfigsAttribute.cs | 6 +- .../PluginNameSelectorAttribute.cs | 2 +- .../PossibleValues/PossibleValuesContext.cs | 2 +- .../RelativeDirectoriesAttribute.cs | 2 +- .../StateMachineKeysAttribute.cs | 2 +- src/Moryx/StateMachines/AsyncStateBase.cs | 8 + src/Moryx/StateMachines/IStateContext.cs | 2 +- .../StateMachines/StateDefinitionAttribute.cs | 2 +- src/Moryx/StateMachines/SyncStateBase.cs | 8 + src/Moryx/Threading/IParallelOperations.cs | 2 +- .../Threading/NonStackingTimerCallback.cs | 5 +- src/Moryx/Threading/ParallelOperations.cs | 9 + .../Threading/ParallelOperationsQueue.cs | 4 +- src/Moryx/Tools/AppDomainBuilder.cs | 4 +- .../Tools/Extensions/CollectionExtensions.cs | 14 +- .../CustomAttributeProviderExtensions.cs | 6 +- .../Tools/Extensions/DateTimeExtensions.cs | 2 +- .../Tools/Extensions/DictionaryExtensions.cs | 2 +- .../Extensions/EditableObjectExtensions.cs | 8 +- .../Tools/Extensions/EnumerableExtensions.cs | 3 +- .../Tools/Extensions/StringExtensions.cs | 12 +- src/Moryx/Tools/IPropertyAccessor.cs | 2 +- src/Moryx/Tools/ReferenceGroup.cs | 2 +- src/Moryx/Tools/ReflectionTool.cs | 38 +- src/Moryx/Workplans/API/IAttemptInvocation.cs | 2 +- src/Moryx/Workplans/API/IIndexResolver.cs | 2 +- src/Moryx/Workplans/API/IPathPredictor.cs | 2 +- src/Moryx/Workplans/API/ITransitionMapper.cs | 2 +- src/Moryx/Workplans/API/IWorkplanEngine.cs | 2 +- src/Moryx/Workplans/API/IWorkplans.cs | 2 +- src/Moryx/Workplans/API/Instance/IPlace.cs | 2 +- src/Moryx/Workplans/API/Instance/IToken.cs | 2 +- .../Workplans/API/Instance/ITokenHolder.cs | 2 +- .../Workplans/API/Instance/ITransition.cs | 2 +- .../API/Instance/IWorkplanInstance.cs | 2 +- src/Moryx/Workplans/API/NodeClassification.cs | 2 +- src/Moryx/Workplans/API/Type/IConnector.cs | 2 +- .../Workplans/API/Type/ISubworkplanStep.cs | 2 +- src/Moryx/Workplans/API/Type/IWorkplan.cs | 2 +- .../Workplans/API/Type/IWorkplanContext.cs | 2 +- src/Moryx/Workplans/API/Type/IWorkplanNode.cs | 2 +- src/Moryx/Workplans/API/Type/IWorkplanStep.cs | 2 +- src/Moryx/Workplans/API/Type/WorkplanState.cs | 2 +- src/Moryx/Workplans/API/WorkplanSnapshot.cs | 2 +- .../Workplans/Implementation/Connector.cs | 2 +- .../Implementation/Engine/EngineState.cs | 2 +- .../Implementation/Engine/IdleState.cs | 2 +- .../Implementation/Engine/PausedState.cs | 2 + .../Implementation/Engine/ReadyState.cs | 2 +- .../Implementation/Engine/RestoredState.cs | 2 +- .../Implementation/Engine/RunningState.cs | 2 +- .../Implementation/Engine/WorkplanEngine.cs | 20 +- .../Workplans/Implementation/MainToken.cs | 2 +- .../Workplans/Implementation/NullContext.cs | 2 +- .../Workplans/Implementation/PathPredictor.cs | 10 +- src/Moryx/Workplans/Implementation/Place.cs | 6 +- .../Implementation/SimpleWorkplanInstance.cs | 2 +- .../Workplans/Implementation/SplitToken.cs | 2 +- .../Implementation/TransitionMapper.cs | 12 +- .../Workplans/Implementation/Workplan.cs | 6 +- .../Implementation/WorkplanExtensions.cs | 10 + .../Implementation/WorkplanInstanceFactory.cs | 2 + .../Workplans/Transitions/JoinTransition.cs | 8 +- .../Workplans/Transitions/NullTransition.cs | 2 +- .../Workplans/Transitions/SplitTransition.cs | 2 +- .../Workplans/Transitions/TransitionBase.cs | 4 +- .../Workplans/Validation/DeadEndValidator.cs | 6 + .../Validation/IWorkplanValidator.cs | 2 +- .../Workplans/Validation/LoneWolfValidator.cs | 4 + .../Workplans/Validation/ValidationAspect.cs | 2 +- .../Workplans/Validation/ValidationResult.cs | 2 +- .../Validation/WorkplanValidation.cs | 4 +- src/Moryx/Workplans/WorkplanInstance.cs | 2 +- .../WorkplanSteps/JoinWorkplanStep.cs | 6 +- .../WorkplanSteps/SplitWorkplanStep.cs | 2 + .../WorkplanSteps/SubWorkplanStep.cs | 6 +- .../WorkplanSteps/SubWorkplanStepBase.cs | 16 +- .../WorkplanSteps/WorkplanStepBase.cs | 2 +- .../ProductConverterTests.cs | 79 ++- .../Mocks/IReferencedResource.cs | 4 +- .../Mocks/ReferencingResource.cs | 4 +- .../ResourceModificationControllerTests.cs | 2 +- .../ActivityResultLocalizationTests.cs | 3 +- .../CapabilitiesTests.cs | 1 - .../ExpressionConstraintTests.cs | 4 +- .../ParameterBindingTests.cs | 14 +- .../ProcessExtensionsTests.cs | 12 - .../ProductConstraintTests.cs | 4 +- .../ProductIdentityTests.cs | 1 - .../ProductTests.cs | 3 +- ...eExtensionsGetFirstRelatedResourceTests.cs | 2 - .../ResourceConstructorTestResources.cs | 2 +- .../TestData/TestActivity.cs | 2 +- .../TestData/TestResults.cs | 2 +- .../TestData/TestTask.cs | 2 +- .../TracingActivityTests.cs | 5 +- .../ManagedMqttClientTests.cs | 6 +- .../BinaryConnectionFactoryMock.cs | 6 +- .../CommunicationSocketsTests.cs | 4 +- .../CommunicationSocketsTestsBase.cs | 12 +- .../ConnectionBuffer.cs | 4 +- .../DelimiterCommunicationSocketTests.cs | 4 +- .../DelimiterInterpreterTests.cs | 7 +- .../EndDelimiterOnlyInterpreter.cs | 2 +- .../DelimiterProtocol/HtmlInterpreter.cs | 2 +- .../TestDelimiterInterpreter.cs | 2 +- .../TestDelimiterValidator.cs | 2 +- .../HeaderedCommunicationSocketTests.cs | 12 +- .../HeaderProtocol/SystemTestHeader.cs | 4 +- .../SystemTestHeaderInterpreter.cs | 2 +- .../HeaderProtocol/SystemTestValidator.cs | 2 +- .../ForeignComponent.cs | 2 +- .../ForeignDefaultComponent.cs | 2 +- .../ForeignRootClass.cs | 2 +- .../ComponentConfig.cs | 2 +- .../IConfiguredComponent.cs | 2 +- .../Moryx.Container.TestTools/IRootClass.cs | 2 +- .../IRootClassFactory.cs | 2 +- .../RootClassFactoryConfig.cs | 2 +- .../Local/ConfiguredComponent.cs | 2 +- .../Local/LocalComponent.cs | 2 +- .../Local/NamedComponents.cs | 2 +- .../Local/ServiceProviderBridgeTests.cs | 4 +- .../Local/StrategySelectionTest.cs | 4 +- .../Moryx.Container.Tests/Named/Component.cs | 2 +- .../Named/NamedComponentTest.cs | 2 +- .../Registrator/NamedDummy.cs | 2 +- .../Registrator/RegistratorTest.cs | 2 +- .../UseChild/Components.cs | 12 +- .../UseChild/ParentAndChild.cs | 8 +- .../UseChild/UseChildTest.cs | 2 +- .../Activities/AssembleParametersTests.cs | 8 +- .../Jobs/JobDataTestBase.cs | 4 +- .../Jobs/JobDispatcherTests.cs | 4 +- .../Jobs/JobListTests.cs | 12 +- .../Jobs/JobManagerTests.cs | 7 +- .../Jobs/JobStorageTests.cs | 5 +- .../Jobs/ParallelSchedulerTests.cs | 3 +- .../Jobs/ProductionJobDataTests.cs | 8 +- .../Jobs/SchedulerTestBase.cs | 7 +- .../Jobs/SeamlessSchedulerTests.cs | 5 - .../Jobs/SetupJobDataTests.cs | 5 +- .../Jobs/WorkplanValidationTests.cs | 3 +- .../Processes/ActivityDispatcherTests.cs | 11 +- .../Processes/ActivityPoolTests.cs | 11 +- .../Processes/ActivityProviderTests.cs | 8 +- .../Processes/ActivityTimeoutObserverTests.cs | 3 +- .../Processes/ProcessArchiveTests.cs | 14 +- .../Processes/ProcessControllerTests.cs | 3 +- .../Processes/ProcessInterruptionTests.cs | 5 +- .../Processes/ProcessRemovalTests.cs | 7 +- .../Processes/ProcessStorageTests.cs | 10 +- .../Processes/ProcessTestsBase.cs | 4 +- .../Processes/ProcessesIntegrationTests.cs | 5 +- .../Processes/ResourceAssignmentTests.cs | 8 +- .../Processes/StorageTriggerTest.cs | 10 +- .../Setup/SetupHandlerTests.cs | 20 +- .../Setup/TestTriggerBase.cs | 2 +- .../TestRecipe.cs | 2 +- .../MultiStepTrigger.cs | 3 +- .../SetupManagerTests.cs | 1 - .../TestRecipe.cs | 2 +- .../TestTriggerBase.cs | 9 +- .../TestTriggerCleanUp.cs | 2 +- .../TestTriggerPrepare.cs | 2 +- .../EnumInstructionResultTests.cs | 4 +- .../Mocks/DummyActivity.cs | 2 +- .../Mocks/DummyActivityParameters.cs | 2 +- .../Mocks/DummyCapabilities.cs | 2 +- .../Mocks/DummyRecipe.cs | 5 +- .../Mocks/DummyResult.cs | 2 +- .../ProcessExtensionsTest.cs | 7 +- .../ProductionSessionTests.cs | 3 +- .../VisualInstructorExtensionsTests.cs | 2 +- .../TestDriverMqttChannelFunctions.cs | 6 +- .../TestDriverMqttIByteSerializable.cs | 11 +- .../TestDriverMqttJsonTopic.cs | 3 - .../TestDriverMqttPrimitiveDatatypeTopic.cs | 9 +- .../TestDriverStateMachine.cs | 5 +- .../BoolByteSerializableMessage.cs | 3 +- .../TestMessages/BoolMqttMessage.cs | 3 +- .../MessageForPlaceholderMessages.cs | 2 +- .../Moryx.Drivers.Mqtt.Tests/TestMqttTopic.cs | 4 - .../HandleContinuationPoint.cs | 4 +- .../HandlingCyclicNodesTests.cs | 1 - .../Mocks/FakeSubscriptionFactory.cs | 2 +- .../NodeHandlingTests.cs | 1 - .../BaseTest.cs | 5 - ...FactoryMonitorController_BackgroundTest.cs | 4 +- ...oryMonitorController_CellOperationsTest.cs | 3 - .../FactoryMonitorController_RouteTest.cs | 5 +- .../FactoryMonitorController_StateTest.cs | 30 +- .../Resources/DummyCell.cs | 6 +- .../TestActivities/ActivityParameters.cs | 3 +- .../TestActivities/AssemblyActivity.cs | 2 +- .../TestActivities/MyRecipe.cs | 2 +- .../TestActivities/SolderingActivity.cs | 2 +- .../TestCapabilities/DummyCapabilities1.cs | 3 +- .../TestCapabilities/DummyCapabilities2.cs | 3 +- .../MediaServerControllerTests.cs | 11 +- .../UploadValidationTests.cs | 6 +- .../ContentManagerTests.cs | 19 +- .../Properties/AssemblyInfo.cs | 2 +- src/Tests/Moryx.Model.Tests/InMemoryTests.cs | 4 +- .../RepositoryProxies/Entities/SomeEntity.cs | 2 +- .../Entities/SomeModificationTrackedEntity.cs | 2 +- .../RepositoryProxies/InterfaceProxyTests.cs | 3 +- .../Interfaces/ICreateAllParamsRepository.cs | 2 +- .../ICreateStringParamRepository.cs | 2 +- .../ICreateUnknownPropertyRepository.cs | 2 +- .../Interfaces/ICreateValueParamRepository.cs | 3 +- .../ICreateWrongReturnTypeRepository.cs | 3 +- .../Interfaces/IEmptyRepository.cs | 2 +- .../IModificationTrackedRepository.cs | 2 +- .../IWithoutIRepositoryRepository.cs | 2 +- .../Interfaces/IWrongParamTypeRepository.cs | 2 +- src/Tests/Moryx.Model.Tests/SqliteTests.cs | 8 +- .../NotificationAdapterTests.cs | 1 - .../NotificationProcessorTests.cs | 4 +- .../NotificationPublisherTests.cs | 15 +- .../GlobalUsings.cs | 2 +- .../IAttendanceManagementTests.cs | 4 +- .../IOperatorManagementTests.cs | 2 +- .../ISkillManagementTests.cs | 2 +- .../ModuleTests.cs | 2 +- .../TestsBase.cs | 6 + .../ConvertOperationCreationModel.cs | 5 +- .../Advice/AdviceManagerTests.cs | 4 +- .../DoNotReplaceScrapStrategyTests.cs | 4 +- .../Integration/OperationFactoryMock.cs | 5 +- .../Integration/ProductionTests.cs | 20 +- .../NullOperationSavingContext.cs | 4 +- .../DocumentAssignStepTests.cs | 13 +- .../OperationAssignmentTests.cs | 11 +- .../ProductRecipeAssignStepTests.cs | 15 +- .../OperationData/OperationDataAdviceTests.cs | 4 +- .../OperationData/OperationDataCreateTests.cs | 3 +- .../OperationDataProductionTests.cs | 29 +- .../OperationData/OperationDataReportTests.cs | 5 +- .../OperationDataRestoreTests.cs | 14 +- .../OperationData/OperationDataTestBase.cs | 17 +- .../SingleJobOperationDispatcherTests.cs | 6 +- .../OperationNotificationsTests.cs | 5 +- .../OperationPool/OperationPoolTests.cs | 8 +- .../NullOperationValidationTests.cs | 4 +- .../RegexOperationValidationTests.cs | 7 +- .../InfluxDbListenerV2Test.cs | 1 - .../Usings.cs | 2 +- .../CsvStructureTest.cs | 91 +++- .../SpreadsheetsListenerTest.cs | 16 +- .../TestDirectory.cs | 5 +- .../MeasurementBindingProcessorTests.cs | 5 +- .../ProcessDataListenerTests.cs | 6 +- .../FloatColumnMapperTests.cs | 2 +- .../ProductStorageTests.cs | 7 +- .../RecipeStorage/RecipeStorageTests.cs | 4 +- .../RecipeStorage/TaskA.cs | 2 +- .../RecipeStorage/TaskB.cs | 2 +- .../StrategyConfigurationAttributeTests.cs | 5 +- .../Mocks/DerivedResource.cs | 2 +- .../Mocks/DerivedResourceWithNewProxy.cs | 2 +- .../Mocks/ExplicitEventResource.cs | 1 - .../Mocks/InterferenceResource.cs | 2 +- .../Mocks/NonPublicResource.cs | 2 +- .../Mocks/OtherResource.cs | 2 +- .../Mocks/ReferenceResource.cs | 7 +- .../Mocks/ResourceWithGenericMethod.cs | 4 +- .../Mocks/ResourceWithImplicitApi.cs | 2 +- .../Mocks/SharedEventNameResource.cs | 1 - .../Mocks/SimpleResource.cs | 1 - .../ResourceEntityAccessorTests.cs | 25 +- .../ResourceLinkerTests.cs | 21 +- .../ResourceManagerSqliteTests.cs | 6 +- .../ResourceManagerTests.cs | 18 +- .../TypeControllerTests.cs | 9 +- .../VisualInstructorTests.cs | 3 +- .../Databases/Controller/ModelSetupTests.cs | 13 +- .../Databases/UpdateConfigTests.cs | 11 +- .../Configuration/CachedConfigManagerTests.cs | 3 +- .../Configuration/ConfigManagerTests.cs | 2 - .../ConfigManagerWithConfigProviderTests.cs | 3 - .../MicrosoftExtensionConfigProviderTests.cs | 3 - .../RuntimeConfigManagerTests.cs | 7 +- .../Configuration/TestConfig.cs | 1 - .../RuntimeConfigManagerTestConfig1.cs | 5 +- .../RuntimeConfigManagerTestConfig2.cs | 2 +- .../KernelServiceCollectionExtensionsTests.cs | 3 - .../ModuleMocks/IFacadeA.cs | 2 +- .../ModuleMocks/IFacadeB.cs | 4 +- .../ModuleMocks/IFacadeC.cs | 4 +- .../LifeCycleBoundFacadeTestModule.cs | 8 +- .../ModuleMocks/ModuleA.cs | 6 +- .../ModuleMocks/ModuleADependent.cs | 6 +- .../ModuleMocks/ModuleB1.cs | 6 +- .../ModuleMocks/ModuleB2.cs | 4 +- .../ModuleMocks/ModuleB3.cs | 4 +- .../ModuleMocks/ModuleBUsingA.cs | 4 +- .../ModuleMocks/ModuleBase.cs | 5 +- .../ModuleMocks/ModuleC.cs | 6 +- .../ModuleMocks/ServerModuleADependent.cs | 3 +- .../ModuleMocks/TestFacade.cs | 2 +- src/Tests/Moryx.Runtime.Tests/Helper.cs | 3 +- .../Mocks/TestLoggerMgmt.cs | 5 +- .../Moryx.Runtime.Tests/ModuleBaseTest.cs | 7 +- .../Modules/DelayedExceptionModule.cs | 5 +- .../Moryx.Runtime.Tests/Modules/TestModule.cs | 2 +- .../ServerNotificationCollectionTests.cs | 115 +++-- .../StateTransitionTest.cs | 7 +- src/Tests/Moryx.Runtime.Tests/Strategy.cs | 2 +- .../FacadeTests.cs | 4 +- .../ModuleTests.cs | 4 +- .../TestBase.cs | 2 +- .../AssemblyActivity.cs | 2 +- .../AssemblyCapabilities.cs | 2 +- .../AssemblyTestCell.cs | 2 +- src/Tests/Moryx.Simulation.Tests/BaseTest.cs | 12 +- src/Tests/Moryx.Simulation.Tests/Builder.cs | 2 +- .../SimulatedDummyTestDriver.cs | 14 +- .../SimulationActivitiesTests.cs | 2 +- .../SimulationDriverTests.cs | 4 +- .../SimulationStatesTests.cs | 4 +- .../Bindings/BindingResolverExtensionTests.cs | 3 +- .../Bindings/DelegateResolverTest.cs | 2 +- .../Moryx.Tests/Bindings/Dummies/Branch.cs | 4 +- src/Tests/Moryx.Tests/Bindings/Dummies/Foo.cs | 2 +- .../Bindings/Dummies/ISomeInterface.cs | 2 +- .../Moryx.Tests/Bindings/Dummies/SomeClass.cs | 2 +- .../Bindings/Dummies/SomeComplexClass.cs | 4 +- .../Dummies/SomeHiddenPropertyClass.cs | 2 +- .../Bindings/Dummies/SomeImplementation.cs | 2 +- .../Bindings/ReflectionResolverTests.cs | 1 - .../Moryx.Tests/Bindings/UpdateValueTest.cs | 2 +- .../Collections/DelayQueueTests.cs | 13 +- src/Tests/Moryx.Tests/Collections/SortObj.cs | 4 +- .../Collections/SortableCollectionTests.cs | 3 +- .../Collections/StringNumericComparerTests.cs | 3 +- .../Moryx.Tests/Communication/PortMapTests.cs | 13 +- .../Transformer/ModelTransformerTest.cs | 12 +- .../Transformer/TransformerTestConfig.cs | 7 +- ...DefaultCanWriteValueProviderFilterTests.cs | 2 +- .../NoStringValueProviderFilter.cs | 2 +- .../ValueProvider/TestConfig1.cs | 2 +- .../ValueProvider/TestConfig2.cs | 2 +- .../ValueProvider/TestConfig3.cs | 3 +- .../ValueProvider/TestConfig4.cs | 3 +- .../ValueProvider/TestConfig5.cs | 7 +- .../ValueProvider/TestConfig6.cs | 4 +- .../ValueProvider/ThreeProvider.cs | 4 +- .../ValueProvider/ValueProviderTests.cs | 2 +- .../Extensions/AppDomain/AbstractBaseClass.cs | 2 +- .../Extensions/AppDomain/BaseClass.cs | 2 +- .../Extensions/AppDomain/ChildClass1.cs | 2 +- .../Extensions/AppDomain/ChildClass2.cs | 2 +- .../Extensions/AppDomain/GranChildClass1.cs | 2 +- .../Extensions/AppDomain/GranChildClass2.cs | 2 +- .../Extensions/AppDomain/IBaseInterface.cs | 2 +- .../Extensions/AppDomain/ITestInterface.cs | 2 +- .../Extensions/AppDomain/ReferenceClass.cs | 6 +- .../CustomAttributeProviderExtensionTests.cs | 13 +- .../Extensions/DateTimeExtensionTests.cs | 3 +- .../Extensions/EnumerableExtensionTests.cs | 8 +- .../Extensions/ReflectionToolTests.cs | 7 +- .../Moryx.Tests/Modules/PriorityTests.cs | 2 +- .../Dummies/DictionaryClassDummy.cs | 2 +- .../EntryConvert/EntryConvertTests.cs | 31 ++ .../EntryConvert/EntryEncoderTests.cs | 2 +- .../EntryConvert/PossibleValuesTests.cs | 2 + .../StateMachines/AsyncStateMachineTests.cs | 3 - .../AsyncTestMachine/AAsyncState.cs | 5 +- .../AsyncTestMachine/BAsyncState.cs | 5 +- .../AsyncTestMachine/CAsyncState.cs | 4 +- .../AsyncTestMachine/MyAsyncContext.cs | 4 +- .../AsyncTestMachine/MyAsyncStateBase.cs | 1 - .../StateMachines/StateMachineTests.cs | 12 +- .../StateMachines/TestMachine/AState.cs | 2 +- .../StateMachines/TestMachine/BState.cs | 2 +- .../StateMachines/TestMachine/CState.cs | 2 +- .../StateMachines/TestMachine/MyContext.cs | 2 +- .../StateMachines/TestMachine/MyStateBase.cs | 2 +- .../Threading/EventDecouplerTests.cs | 11 +- .../NonStackingTimerCallbackTests.cs | 2 +- .../Threading/ParallelOperationTests.cs | 10 +- .../Tools/FunctionResultTestsBase.cs | 2 +- .../Tools/FunctionResultWithNothingTests.cs | 1 - .../Tools/FunctionResultWithTypeTests.cs | 1 - .../Workplans/Dummies/DummyStep.cs | 8 +- .../Workplans/Dummies/DummyToken.cs | 2 +- .../Workplans/Dummies/EmptyParametersStep.cs | 2 +- .../Workplans/Dummies/InvalidStep.cs | 2 +- .../Workplans/Dummies/MoveTransition.cs | 2 +- .../Workplans/Dummies/ParameterStep.cs | 8 +- .../Workplans/Dummies/PausableStep.cs | 7 +- .../Workplans/Dummies/WorkplanDummy.cs | 4 +- .../Moryx.Tests/Workplans/EngineTests.cs | 5 +- .../Workplans/PathPredictionTests.cs | 17 +- .../Moryx.Tests/Workplans/PlacesTests.cs | 14 +- .../Workplans/SerializationTest.cs | 3 +- src/Tests/Moryx.Tests/Workplans/StepTests.cs | 4 +- .../Moryx.Tests/Workplans/TransitionTests.cs | 3 - .../InstructionProcessorTests.cs | 19 +- .../ParameterBindingTests.cs | 14 +- .../VisualInstructionsControllerTests.cs | 2 +- .../VisualInstructionsControllerTests.cs | 3 - .../VisualInstructionsFacadeMock.cs | 6 +- .../VisualInstructorExtensionsTests.cs | 2 +- .../DummyStep.cs | 2 +- .../DummyTransition.cs | 6 +- .../DummyWorkplan.cs | 4 +- .../WorkplanEditingSessionTests.cs | 9 +- 1822 files changed, 5887 insertions(+), 3439 deletions(-) diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartConnector.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartConnector.cs index 1a320b8314..bbe7ee8a65 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartConnector.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartConnector.cs @@ -26,4 +26,4 @@ public class PartConnector [DataMember] public Entry PropertyTemplates { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartModel.cs index d21effdbc9..1a082d0b9e 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/PartModel.cs @@ -17,4 +17,4 @@ public class PartModel [DataMember] public ProductModel Product { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductCustomization.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductCustomization.cs index 02e50a48a4..7ae0c5bb60 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductCustomization.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductCustomization.cs @@ -16,4 +16,4 @@ public class ProductCustomization [DataMember] public ProductImporter[] Importers { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductDefinitionModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductDefinitionModel.cs index 78f3a222dd..ff87ce07d1 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductDefinitionModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductDefinitionModel.cs @@ -20,4 +20,4 @@ public class ProductDefinitionModel [DataMember] public Entry Properties { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductImporter.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductImporter.cs index a0bf8b97fb..06905e7d8a 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductImporter.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductImporter.cs @@ -14,4 +14,4 @@ public class ProductImporter [DataMember] public Entry Parameters { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductInstanceModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductInstanceModel.cs index a60e3ce20e..36e1b537e1 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductInstanceModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductInstanceModel.cs @@ -26,4 +26,4 @@ public class ProductInstanceModel [DataMember] public Entry Properties { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductModel.cs index 055b992f7d..f43a7bcde8 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/ProductModel.cs @@ -35,4 +35,4 @@ public class ProductModel [DataMember] public RecipeModel[] Recipes { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeClassificationModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeClassificationModel.cs index 186538ce3b..ea65bc4872 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeClassificationModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeClassificationModel.cs @@ -17,4 +17,4 @@ public enum RecipeClassificationModel Intermediate, Part -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeDefinitionModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeDefinitionModel.cs index 4e27821502..a47074f30f 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeDefinitionModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeDefinitionModel.cs @@ -16,4 +16,4 @@ public class RecipeDefinitionModel [DataMember] public bool HasWorkplans { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeModel.cs index 9c31877d0e..ac77028154 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/RecipeModel.cs @@ -66,4 +66,4 @@ public class RecipeModel /// [DataMember] public bool IsClone { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/WorkplanModel.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/WorkplanModel.cs index eb413c6006..8c68c3fb36 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/Models/WorkplanModel.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/Models/WorkplanModel.cs @@ -20,4 +20,4 @@ public class WorkplanModel [DataMember] public WorkplanState State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/PartialSerialization.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/PartialSerialization.cs index 80d9c8162b..4e9cad4ddb 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/PartialSerialization.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/PartialSerialization.cs @@ -50,11 +50,15 @@ protected bool SimpleProp(PropertyInfo prop) if (typeof(ProductType).IsAssignableFrom(type) || typeof(ProductPartLink).IsAssignableFrom(type) || typeof(IEnumerable).IsAssignableFrom(type)) + { return false; + } // Filter default properties if (FilteredProperties.Contains(prop.Name)) + { return false; + } return true; } @@ -73,4 +77,4 @@ public void FillEmpty(object obj) ValueProviderExecutor.Execute(obj, new ValueProviderExecutorSettings().AddDefaultValueProvider()); } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductConverter.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductConverter.cs index 1ffe6505b3..e28f62c026 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductConverter.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductConverter.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Collections; +using System.Reflection; +using Moryx.AbstractionLayer.Products.Endpoints.Models; using Moryx.AbstractionLayer.Recipes; using Moryx.Container; using Moryx.Serialization; using Moryx.Tools; using Moryx.Workplans; -using System.Collections; -using System.Reflection; -using Moryx.AbstractionLayer.Products.Endpoints.Models; namespace Moryx.AbstractionLayer.Products.Endpoints; @@ -74,7 +74,9 @@ public async Task ConvertProduct(ProductType productType, bool fla }; if (flat) + { return converted; + } // Properties var typeWrapper = _productManagement.GetTypeWrapper(productType.GetType().FullName); @@ -155,7 +157,9 @@ private static Type FindGenericBaseDefinition(Type type, Type genericDefinition) while (current != null && current != typeof(object)) { if (current.IsGenericType && current.GetGenericTypeDefinition() == genericDefinition) + { return current; + } current = current.BaseType; } @@ -167,7 +171,9 @@ private async Task ConvertPart(ProductPartLink link) { // No link, no DTO! if (link is null || link.Product is null) + { return null; + } var part = new PartModel { @@ -196,26 +202,38 @@ public async Task ConvertProductBack(ProductModel source, ProductTy productRecipe = (IProductRecipe)Activator.CreateInstance(type); } else + { productRecipe = (IProductRecipe)await _productManagement.LoadRecipeAsync(recipeModel.Id); + } ConvertRecipeBack(recipeModel, productRecipe, converted); recipes.Add(productRecipe); } if (recipes.Any()) + { foreach (var recipe in recipes) + { await _productManagement.SaveRecipeAsync(recipe); + } + } // Product is flat if (source.Properties is null) + { return converted; + } // Delete recipes if (converted.Id != 0) { var recipesOfProduct = await _productManagement.LoadRecipesAsync(converted, RecipeClassification.CloneFilter); foreach (var recipe in recipesOfProduct) + { if (recipes.FirstOrDefault(r => r.Id == recipe.Id) == null) + { await _productManagement.DeleteRecipeAsync(recipe.Id); + } + } } // Copy extended properties @@ -227,7 +245,9 @@ public async Task ConvertProductBack(ProductModel source, ProductTy foreach (var partConnector in source.Parts ?? Enumerable.Empty()) { if (partConnector.Parts is null) + { continue; + } var prop = properties.First(p => p.Name == partConnector.Name); var value = prop.GetValue(converted); @@ -271,7 +291,9 @@ private async Task UpdateCollection(IList value, IEnumerable parts) foreach (var partModel in parts) { if (partModel is null) + { continue; + } var oldPartMatch = oldParts.Find(r => r.Id == partModel.Id); // new partlink @@ -283,17 +305,23 @@ private async Task UpdateCollection(IList value, IEnumerable parts) } //modified reference else if (oldPartMatch.Product.Id != partModel.Product.Id) + { oldPartMatch.Product = await _productManagement.LoadTypeAsync(partModel.Product.Id); + } else + { // existing unchanged partlink: do not delete at the end oldParts.Remove(oldPartMatch); + } EntryConvert.UpdateInstance(oldPartMatch, partModel.Properties); } // Clear all values no longer present in the model foreach (var part in oldParts) + { value.Remove(part); + } } private async Task UpdateReference(ProductPartLink value, PartModel part) @@ -355,7 +383,9 @@ public async Task ConvertRecipeBack(RecipeModel recipe, IProduct // Only load workplan if it changed var workplanRecipe = productRecipe as IWorkplanRecipe; if (workplanRecipe != null && workplanRecipe.Workplan?.Id != recipe.WorkplanModel.Id) + { workplanRecipe.Workplan = await _productManagement.LoadWorkplanAsync(recipe.WorkplanModel.Id); + } if (productRecipe.Product == null) { @@ -366,7 +396,9 @@ public async Task ConvertRecipeBack(RecipeModel recipe, IProduct // Do not update a clones classification if (productRecipe.Classification.HasFlag(RecipeClassification.Clone)) + { return productRecipe; + } switch (recipe.Classification) { diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductManagementController.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductManagementController.cs index a384ebd2f3..27b62100b8 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductManagementController.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductManagementController.cs @@ -6,14 +6,14 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Moryx.AbstractionLayer.Recipes; -using Moryx.Tools; -using Moryx.Serialization; using Moryx.AbstractionLayer.Products.Endpoints.Models; using Moryx.AbstractionLayer.Products.Endpoints.Properties; +using Moryx.AbstractionLayer.Recipes; using Moryx.AspNetCore; using Moryx.Configuration; using Moryx.Runtime.Modules; +using Moryx.Serialization; +using Moryx.Tools; namespace Moryx.AbstractionLayer.Products.Endpoints; @@ -65,7 +65,10 @@ private ProductDefinitionModel[] GetProductTypes() var types = _productManagement.ProductTypes; var typeModels = new List(); foreach (var type in types) + { typeModels.Add(_productConverter.ConvertProductType(type)); + } + return typeModels.ToArray(); } @@ -74,7 +77,10 @@ private RecipeDefinitionModel[] GetRecipeTypes() var recipeTypes = _productManagement.RecipeTypes; var typeModels = new List(); foreach (var recipeType in recipeTypes) + { typeModels.Add(ProductConverter.ConvertRecipeType(recipeType)); + } + return typeModels.ToArray(); } @@ -86,7 +92,10 @@ private RecipeDefinitionModel[] GetRecipeTypes() public async Task> Import(string importerName, Entry importParameters) { if (importParameters == null) + { return BadRequest($"Import parameters were null"); + } + var parameters = ConvertParametersBack(importerName, importParameters); if (parameters == null) { @@ -95,7 +104,10 @@ public async Task> Import(string importerName, Entr var importedTypes = (await _productManagement.ImportAsync(importerName, parameters)).ImportedTypes; var modelList = new List(); foreach (var t in importedTypes) + { modelList.Add(await _productConverter.ConvertProduct(t, false)); + } + return modelList.ToArray(); } @@ -103,7 +115,9 @@ private object ConvertParametersBack(string importerName, Entry currentParameter { var oldParameters = _productManagement.Importers.FirstOrDefault(i => i.Key == importerName).Value; if (oldParameters == null) + { return null; + } var parameters = EntryConvert.UpdateInstance(oldParameters, currentParameters); return parameters; @@ -119,11 +133,17 @@ private object ConvertParametersBack(string importerName, Entry currentParameter public async Task> SaveType(ProductModel newTypeModel) { if (newTypeModel == null) + { return BadRequest($"Modified type was null"); + } + var type = ReflectionTool.GetPublicClasses(t => t.Name == newTypeModel.Type) .FirstOrDefault(); if (type == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.ProductManagementController_TypeNotFound }); + } + var productType = (ProductType)Activator.CreateInstance(type); var newType = await _productConverter.ConvertProductBack(newTypeModel, productType); return await _productManagement.SaveTypeAsync(newType); @@ -143,17 +163,26 @@ public async Task> GetTypeByIdentity(string identit .ToList(); var productModels = new List(); foreach (var p in products) + { productModels.Add(await _productConverter.ConvertProduct(p, false)); + } + return productModels.ToArray(); } var identityArray = WebUtility.HtmlEncode(identity).Split('-'); if (identityArray.Length != 2) + { return BadRequest($"Identity has wrong format. Must be identifier-revision"); + } + var productIdentity = new ProductIdentity(identityArray[0], Convert.ToInt16(identityArray[1], CultureInfo.InvariantCulture)); var productType = await _productManagement.LoadTypeAsync(productIdentity); if (productType == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.ProductManagementController_TypeNotFound }); + } + return new ProductModel[] { await _productConverter.ConvertProduct(productType, false) @@ -183,7 +212,10 @@ public async Task> GetTypes(ProductQuery query) public async Task> GetTypeById(long id) { if (id == 0) + { return BadRequest($"Id was 0"); + } + ProductType productType = null; try { @@ -193,7 +225,10 @@ public async Task> GetTypeById(long id) { } if (productType == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.ProductManagementController_TypeNotFound }); + } + return await _productConverter.ConvertProduct(productType, false); } @@ -206,7 +241,10 @@ public async Task> DeleteType(long id) { var result = await _productManagement.DeleteTypeAsync(id); if (!result) + { return NotFound(new MoryxExceptionResponse { Title = Strings.ProductManagementController_TypeNotFound }); + } + return result; } @@ -218,10 +256,16 @@ public async Task> DeleteType(long id) public async Task> UpdateType(long id, ProductModel modifiedType) { if (modifiedType == null) + { return BadRequest($"Modified product type was null"); + } + var type = await _productManagement.LoadTypeAsync(id); if (type == null) + { return BadRequest($"No product type with id {modifiedType.Id} was found"); + } + type = await _productConverter.ConvertProductBack(modifiedType, (ProductType)type); return await _productManagement.SaveTypeAsync(type); } @@ -237,10 +281,16 @@ public async Task> Duplicate(long id, [FromBody] stri { var template = await _productManagement.LoadTypeAsync(id); if (template == null) + { return BadRequest($"Producttype with id {id} not found"); + } + var identityArray = WebUtility.HtmlEncode(newIdentity).Split('-'); if (identityArray.Length != 2) + { return BadRequest($"Identity has wrong format. Must be identifier-revision"); + } + var identity = new ProductIdentity(identityArray[0], Convert.ToInt16(identityArray[1], CultureInfo.InvariantCulture)); ProductType newProductType; try @@ -252,7 +302,10 @@ public async Task> Duplicate(long id, [FromBody] stri return Conflict(ex.Message); } if (newProductType == null) + { return BadRequest($"Error while duplicating"); + } + return await _productConverter.ConvertProduct(newProductType, false); } @@ -265,11 +318,17 @@ public async Task> GetRecipes(long id, int classific { var productType = await _productManagement.LoadTypeAsync(id); if (productType == null) + { return BadRequest($"ProductType is null"); + } + var recipes = await _productManagement.LoadRecipesAsync(productType, (RecipeClassification)classification); var recipeModels = new List(); foreach (var recipe in recipes) + { recipeModels.Add(_productConverter.ConvertRecipe(recipe)); + } + return recipeModels.ToArray(); } #endregion @@ -284,10 +343,16 @@ public async Task> GetRecipes(long id, int classific public async Task> GetInstance(long id) { if (id == 0) + { return BadRequest($"Id was 0"); + } + var productInstance = await _productManagement.LoadInstanceAsync(id); if (productInstance == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.ProductManagementController_InstanceNotFound, id) }); + } + return ProductConverter.ConvertProductInstance(productInstance); } @@ -299,7 +364,10 @@ public async Task> GetInstances([FromQuery] var instances = await _productManagement.LoadInstancesAsync(ids); var modelList = new List(); foreach (var instance in instances) + { modelList.Add(ProductConverter.ConvertProductInstance(instance)); + } + return modelList.ToArray(); } @@ -313,7 +381,10 @@ public async Task> CreateInstance(string iden var identity = new ProductIdentity(WebUtility.HtmlEncode(identifier), revision); var productType = await _productManagement.LoadTypeAsync(identity); if (productType == null) + { return BadRequest($"Product type not found"); + } + var instance = await _productManagement.CreateInstanceAsync(productType, save); return ProductConverter.ConvertProductInstance(instance); } @@ -326,11 +397,17 @@ public async Task> CreateInstance(string iden public async Task SaveInstance(ProductInstanceModel instanceModel) { if (instanceModel == null) + { return BadRequest($"Instance model was empty"); + } + var type = ReflectionTool.GetPublicClasses(t => t.Name == instanceModel.Type) .FirstOrDefault(); if (type == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.ProductManagementController_InstanceNotFound, "null") }); + } + var productType = (ProductType)Activator.CreateInstance(type); var productInstance = ProductConverter.ConvertProductInstanceBack(instanceModel, productType); await _productManagement.SaveInstanceAsync(productInstance); @@ -348,10 +425,16 @@ public async Task SaveInstance(ProductInstanceModel instanceModel) public async Task> GetRecipe(long id) { if (id == 0) + { return BadRequest($"Id was 0"); + } + var recipe = await _productManagement.LoadRecipeAsync(id); if (recipe == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.ProductManagementController_RecipeNotFound, id) }); + } + return _productConverter.ConvertRecipe(recipe); } @@ -364,11 +447,17 @@ public async Task> GetRecipe(long id) public async Task> SaveRecipe(RecipeModel recipe) { if (recipe == null) + { return BadRequest($"Recipe was null"); + } + var type = ReflectionTool.GetPublicClasses(t => t.Name == recipe.Type) .FirstOrDefault(); if (type == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.ProductManagementController_RecipeNotFound, "null") }); + } + var productRecipe = (IProductRecipe)Activator.CreateInstance(type); return await _productManagement.SaveRecipeAsync(await _productConverter.ConvertRecipeBack(recipe, productRecipe, null)); } @@ -382,13 +471,22 @@ public async Task> SaveRecipe(RecipeModel recipe) public async Task> UpdateRecipe(long id, RecipeModel recipeModel) { if (recipeModel == null) + { return BadRequest($"Recipe was null"); + } + var recipe = await _productManagement.LoadRecipeAsync(id); if (recipe == null) + { return BadRequest($"Recipe with id {id} not found"); + } + var productRecipe = recipe as IProductRecipe; if (productRecipe == null) + { return BadRequest($"Recipe with id {id} wasn't a IProductRecipe but a {nameof(recipe.GetType)}"); + } + var productionRecipe = await _productConverter.ConvertRecipeBack(recipeModel, productRecipe, null); return await _productManagement.SaveRecipeAsync(productionRecipe); } @@ -401,7 +499,9 @@ public ActionResult CreateRecipe(string recipeType) { var recipe = _productManagement.CreateRecipe(recipeType); if (recipe == null) + { return BadRequest($"Recipe of type {recipeType} could not created"); + } return _productConverter.ConvertRecipe(recipe); } diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductPermissions.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductPermissions.cs index 673af2482e..114ffbf2f4 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/ProductPermissions.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/ProductPermissions.cs @@ -52,4 +52,4 @@ public static class ProductPermissions /// Permission for all actions related to creating one or multiple product instances /// public const string CanCreateInstances = _prefix + "CanCreateInstances"; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanController.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanController.cs index c0e648682b..6c25e809ef 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanController.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanController.cs @@ -32,7 +32,10 @@ public async Task> GetAllWorkplans() { var workplans = new List(); foreach (var w in await _workplans.LoadAllWorkplansAsync()) + { workplans.Add(ProductConverter.ConvertWorkplan(w)); + } + return workplans.ToArray(); } @@ -42,7 +45,10 @@ public async Task> GetAllWorkplans() public async Task> SaveWorkplan(WorkplanModel model) { if (model == null) + { return BadRequest($"Model was null"); + } + var workplan = ProductConverter.ConvertWorkplanBack(model); return await _workplans.SaveWorkplanAsync(workplan); } @@ -56,10 +62,16 @@ public async Task> SaveWorkplan(WorkplanModel model) public async Task> GetVersions(long id) { if (id == 0) + { return BadRequest($"Workplan id was 0"); + } + var versions = await _workplans.LoadVersionsAsync(id); if (versions == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.WorkplanController_WorkplanNotFound, id) }); + } + var model = new List(); foreach (var v in versions) { @@ -77,10 +89,16 @@ public async Task> GetVersions(long id) public async Task> GetWorkplan(long id) { if (id == 0) + { return BadRequest($"Workplan id was 0"); + } + var workplan = await _workplans.LoadWorkplanAsync(id); if (workplan == null) + { return NotFound(new MoryxExceptionResponse { Title = string.Format(CultureInfo.CurrentCulture, Strings.WorkplanController_WorkplanNotFound, id) }); + } + return ProductConverter.ConvertWorkplan(workplan); } @@ -93,7 +111,10 @@ public async Task DeleteWorkplan(long id) { var workplan = await _workplans.LoadWorkplanAsync(id); if (workplan == null) + { return NotFound(); + } + await _workplans.DeleteWorkplanAsync(id); return Ok(); } @@ -105,12 +126,16 @@ public async Task DeleteWorkplan(long id) public async Task> UpdateWorkplan(WorkplanModel model) { if (model == null) + { return BadRequest($"Workplan id was 0"); + } var workplan = await _workplans.LoadWorkplanAsync(model.Id); - if (workplan== null) + if (workplan == null) + { return BadRequest($"Workplan with id {model.Id} does not exist"); + } return await _workplans.SaveWorkplanAsync(ProductConverter.ConvertWorkplanBack(model)); } diff --git a/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanPermissions.cs b/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanPermissions.cs index aee8b42e5b..dcfc55b60b 100644 --- a/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanPermissions.cs +++ b/src/Moryx.AbstractionLayer.Products.Endpoints/WorkplanPermissions.cs @@ -27,4 +27,4 @@ public static class WorkplanPermissions /// Permission for all actions related to deleting one or multiple workplans /// public const string CanDelete = _prefix + "CanDelete"; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceQueryConverter.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceQueryConverter.cs index 8a4924c655..51230b2630 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceQueryConverter.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceQueryConverter.cs @@ -7,7 +7,7 @@ namespace Moryx.AbstractionLayer.Resources.Endpoints; -internal class ResourceQueryConverter : ResourceToModelConverter +internal sealed class ResourceQueryConverter : ResourceToModelConverter { protected ResourceQuery Query { get; } @@ -72,7 +72,9 @@ private ResourceReferenceModel[] FilteredReferences(Resource current) } if (!filterMatched) + { continue; + } // Convert reference and apply recursion var includedReference = ConvertReference(current, reference); @@ -85,6 +87,8 @@ private ResourceReferenceModel[] FilteredReferences(Resource current) protected override void ConvertReferenceRecursion(Resource resource, ResourceModel model) { if (Query.ReferenceRecursion) + { model.References = FilteredReferences(resource); + } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceToModelConverter.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceToModelConverter.cs index 7f7571ef5c..fed70d6fbe 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceToModelConverter.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Converter/ResourceToModelConverter.cs @@ -51,7 +51,11 @@ public ResourceToModelConverter(IResourceTypeTree typeController, ICustomSeriali /// public ResourceModel GetDetails(Resource current) { - if (current == null) return null; + if (current == null) + { + return null; + } + return ToModel(current, false); } @@ -63,7 +67,10 @@ public ResourceModel GetDetails(Resource current) /// protected ResourceModel ToModel(Resource current, bool partially) { - if (current == null) return null; + if (current == null) + { + return null; + } // Extract model var model = new ResourceModel { @@ -131,7 +138,9 @@ protected ResourceReferenceModel ConvertReference(Resource current, PropertyInfo // We can not set current targets if we do not have any var value = property.GetValue(current); if (value == null) + { return referenceModel; + } // Convert referenced resource objects and possible instance types var referenceTargets = (value as IEnumerable) ?? [(IResource)value]; @@ -161,7 +170,9 @@ private static ICollection MergeTypeConstraints(PropertyInfo property, Typ { // If there are no overrides the only limitation is the target type if (!referenceOverrides.TryGetValue(property.Name, out var myOverrides)) + { return [targetType]; + } // Otherwise find all types that limit the reference type without redundancies. This means eliminating all types // represented by another type @@ -185,7 +196,9 @@ internal ResourceTypeModel ConvertType(IResourceTypeNode node, ResourceTypeModel var resType = node.ResourceType; if (TypeCache.TryGetValue(node.Name, out var cachedType)) + { return cachedType; + } // Remove generic arguments from type name var typeModel = new ResourceTypeModel @@ -231,7 +244,10 @@ private ReferenceTypeModel ConvertReferenceProperty(PropertyInfo property, IDict // Get type constraints Type targetType = property.PropertyType; if (referenceModel.IsCollection) + { targetType = EntryConvert.ElementType(targetType); + } + var typeConstraints = MergeTypeConstraints(property, targetType, overrides); referenceModel.SupportedTypes = TypeController.SupportedTypes(typeConstraints).Select(t => t.Name).ToArray(); diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/DataMemberAttributeValueProviderFilter.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/DataMemberAttributeValueProviderFilter.cs index 14f997b22e..4708c47454 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/DataMemberAttributeValueProviderFilter.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/DataMemberAttributeValueProviderFilter.cs @@ -7,7 +7,7 @@ namespace Moryx.AbstractionLayer.Resources.Endpoints; -internal class DataMemberAttributeValueProviderFilter : IValueProviderFilter +internal sealed class DataMemberAttributeValueProviderFilter : IValueProviderFilter { private readonly bool _filterDataMembers; @@ -19,7 +19,10 @@ public DataMemberAttributeValueProviderFilter(bool filterDataMembers) public bool CheckProperty(PropertyInfo propertyInfo) { if (_filterDataMembers) + { return propertyInfo.GetCustomAttribute() == null; + } + return propertyInfo.GetCustomAttribute() != null; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceFilter.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceFilter.cs index 20e6d2ca93..240a050846 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceFilter.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceFilter.cs @@ -55,4 +55,4 @@ public class ReferenceFilter /// [DataMember] public ReferenceValue ValueConstraint { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceTypeModel.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceTypeModel.cs index 6ced707100..4f644abfce 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceTypeModel.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ReferenceTypeModel.cs @@ -58,4 +58,4 @@ public class ReferenceTypeModel /// [DataMember] public ResourceRelationType RelationType { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceModel.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceModel.cs index d356c51e06..3ac255e669 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceModel.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceModel.cs @@ -77,14 +77,18 @@ internal bool DifferentFrom(Resource resource, ICustomSerialization serializatio { // Do not compare values that were not transmitted if (resource.Descriptor == null || PartiallyLoaded) + { return false; + } // Compare obvious base properties var different = resource.Name != Name || resource.Description != Description; if (different) + { return true; + } var resourceProperties = EntryConvert.EncodeObject(resource.Descriptor, serialization); return !Entry.ValuesEqual(Properties, resourceProperties); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceQuery.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceQuery.cs index 5ec9934459..28bc7dcfb4 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceQuery.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceQuery.cs @@ -34,4 +34,4 @@ public class ResourceQuery /// [DataMember] public ReferenceFilter[] IncludedReferences { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceReferenceModel.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceReferenceModel.cs index 90bfb3e576..8738fce4c9 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceReferenceModel.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceReferenceModel.cs @@ -22,4 +22,4 @@ public class ResourceReferenceModel /// [DataMember] public List Targets { get; set; } = []; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceTypeModel.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceTypeModel.cs index 9980cb2af4..12bf8a59bb 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceTypeModel.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/Models/ResourceTypeModel.cs @@ -59,4 +59,4 @@ public class ResourceTypeModel /// [DataMember] public ResourceTypeModel[] DerivedTypes { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.Resources.Endpoints/ResourceSerialization.cs b/src/Moryx.AbstractionLayer.Resources.Endpoints/ResourceSerialization.cs index 5ae24bd748..3c8804aed2 100644 --- a/src/Moryx.AbstractionLayer.Resources.Endpoints/ResourceSerialization.cs +++ b/src/Moryx.AbstractionLayer.Resources.Endpoints/ResourceSerialization.cs @@ -8,7 +8,7 @@ namespace Moryx.AbstractionLayer.Resources.Endpoints; -internal class ResourceSerialization : PossibleValuesSerialization +internal sealed class ResourceSerialization : PossibleValuesSerialization { /// /// Instance for we use to filter properties and methods diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/MqttBuilderExtensions.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/MqttBuilderExtensions.cs index c6d37d2c52..34a4b18ab4 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/MqttBuilderExtensions.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/MqttBuilderExtensions.cs @@ -3,7 +3,6 @@ using Moryx.AspNetCore.Mqtt.Builders; - namespace Moryx.AbstractionLayer.Resources.Mqtt.Endpoints; /// diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventHandler.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventHandler.cs index 41df827869..93bf45500a 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventHandler.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventHandler.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.Text.Json; using Moryx.AbstractionLayer.Identity; -using Moryx.AspNetCore.Mqtt; using Moryx.AspNetCore.Mqtt.Components; using Moryx.AspNetCore.Mqtt.Converters; using MQTTnet; @@ -46,7 +45,7 @@ public async void InvokeMethod(object sender, T eventArg) messageBuilder.WithContentType("application/json"); await client.EnqueueAsync(messageBuilder.Build(), CancellationToken.None); } - catch (Exception e) + catch (Exception) { throw; // TODO handle exception } diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventService.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventService.cs index 1b70c37ea7..2a77a8215d 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventService.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceEventService.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Identity; -using Moryx.AbstractionLayer.Resources; -using Moryx.AspNetCore.Mqtt; using Moryx.AspNetCore.Mqtt.Builders; using Moryx.AspNetCore.Mqtt.Components; using Moryx.Runtime.Modules; @@ -194,7 +192,7 @@ private void RemoveEventHandlers(IResource resource) _eventHandlers.Remove(resource.Id); } - private class ResourceEventSubscription + private sealed class ResourceEventSubscription { public object Resource { get; } public string EventName { get; } diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceSynchronizationService.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceSynchronizationService.cs index caa659c9d4..0fe93105a3 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceSynchronizationService.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/ResourceSynchronizationService.cs @@ -420,7 +420,7 @@ private enum ExistingResourceChangeType /// /// Message for deleted resource synchronization /// - private class DeletedResourceMessage + private sealed class DeletedResourceMessage { public string? SynchronizationTypeId { get; set; } diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/Serializations/ResourceToJsonConverter.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/Serializations/ResourceToJsonConverter.cs index 34aa4ce1f6..56696cf3a5 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/Serializations/ResourceToJsonConverter.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/Serializations/ResourceToJsonConverter.cs @@ -14,7 +14,7 @@ namespace Moryx.AbstractionLayer.Resources.Mqtt.Endpoints; /// Converts any that has the to JSON /// /// Resource Management facade -internal class ResourceToJsonConverter(IResourceManagement resourceManagement) : JsonConverter +internal sealed class ResourceToJsonConverter(IResourceManagement resourceManagement) : JsonConverter { // public override IResource? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) diff --git a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/WriteOnlyHashStore.cs b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/WriteOnlyHashStore.cs index b7a5a3da35..f196867fe0 100644 --- a/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/WriteOnlyHashStore.cs +++ b/src/Moryx.AbstractionLayer.Resources.Mqtt.Endpoints/WriteOnlyHashStore.cs @@ -10,7 +10,7 @@ namespace Moryx.AbstractionLayer.Resources.Mqtt.Endpoints; /// /// /// -internal class WriteOnlyHashStore(IParallelOperations parallelOperations) : IDisposable +internal sealed class WriteOnlyHashStore(IParallelOperations parallelOperations) : IDisposable { private readonly List _cache = []; private readonly Lock _lock = new(); diff --git a/src/Moryx.AbstractionLayer.TestTools/DummyProductInstance.cs b/src/Moryx.AbstractionLayer.TestTools/DummyProductInstance.cs index 014f1ef774..99a4f4fc8d 100644 --- a/src/Moryx.AbstractionLayer.TestTools/DummyProductInstance.cs +++ b/src/Moryx.AbstractionLayer.TestTools/DummyProductInstance.cs @@ -14,4 +14,4 @@ public class DummyProductInstance : ProductInstance /// Example information on an instance /// public string SerialNumber { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer.TestTools/DummyProductPartLink.cs b/src/Moryx.AbstractionLayer.TestTools/DummyProductPartLink.cs index eda71f601f..b331de1c36 100644 --- a/src/Moryx.AbstractionLayer.TestTools/DummyProductPartLink.cs +++ b/src/Moryx.AbstractionLayer.TestTools/DummyProductPartLink.cs @@ -15,10 +15,17 @@ public override bool Equals(object obj) { var toCompareWith = obj as DummyProductPartLink; if (toCompareWith == null) + { return false; + } return GetType().GetProperties() .All(prop => (prop.GetValue(toCompareWith) is null && prop.GetValue(this) is null) || prop.GetValue(toCompareWith).Equals(prop.GetValue(this))); } -} \ No newline at end of file + + public override int GetHashCode() + { + throw new NotImplementedException(); + } +} diff --git a/src/Moryx.AbstractionLayer.TestTools/DummyProductRecipe.cs b/src/Moryx.AbstractionLayer.TestTools/DummyProductRecipe.cs index 94d3b03eac..6a0419bc46 100644 --- a/src/Moryx.AbstractionLayer.TestTools/DummyProductRecipe.cs +++ b/src/Moryx.AbstractionLayer.TestTools/DummyProductRecipe.cs @@ -16,7 +16,9 @@ public override bool Equals(object obj) { var toCompareWith = obj as DummyProductRecipe; if (toCompareWith == null) + { return false; + } return toCompareWith.Name == Name && toCompareWith.Revision == Revision && toCompareWith.State == State && toCompareWith.Classification == Classification @@ -24,6 +26,11 @@ public override bool Equals(object obj) && ((toCompareWith.Product is null && Product is null) || Product.Equals(toCompareWith.Product)) && ((toCompareWith.Target is null && Target is null) || Target.Equals(toCompareWith.Target)); } + + public override int GetHashCode() + { + throw new NotImplementedException(); + } } /// @@ -42,10 +49,17 @@ public override bool Equals(object obj) { var toCompareWith = obj as DummyProductWorkplanRecipe; if (toCompareWith == null) + { return false; + } return base.Equals(toCompareWith) && ((toCompareWith.Workplan is null && Workplan is null) || Workplan.Equals(toCompareWith.Workplan)) && ((toCompareWith.DisabledSteps is null && DisabledSteps is null) || Enumerable.SequenceEqual(DisabledSteps, toCompareWith.DisabledSteps)); } -} \ No newline at end of file + + public override int GetHashCode() + { + throw new NotImplementedException(); + } +} diff --git a/src/Moryx.AbstractionLayer.TestTools/DummyWorkplan.cs b/src/Moryx.AbstractionLayer.TestTools/DummyWorkplan.cs index bb1eb6b0b9..ef3861e69a 100644 --- a/src/Moryx.AbstractionLayer.TestTools/DummyWorkplan.cs +++ b/src/Moryx.AbstractionLayer.TestTools/DummyWorkplan.cs @@ -15,11 +15,18 @@ public override bool Equals(object obj) { var toCompareWith = obj as DummyWorkplan; if (toCompareWith == null) + { return false; + } return toCompareWith.Id == Id && toCompareWith.Name == Name && toCompareWith.Version == toCompareWith.Version && toCompareWith.State == State && ((toCompareWith.Connectors is null && Connectors is null) || Enumerable.SequenceEqual(toCompareWith.Connectors, Connectors)) && ((toCompareWith.Steps is null && Steps is null) || Enumerable.SequenceEqual(toCompareWith.Steps, Steps)); } -} \ No newline at end of file + + public override int GetHashCode() + { + throw new NotImplementedException(); + } +} diff --git a/src/Moryx.AbstractionLayer.TestTools/InMemoryUnitOfWorkFactoryBuilder.cs b/src/Moryx.AbstractionLayer.TestTools/InMemoryUnitOfWorkFactoryBuilder.cs index bb9c9459c1..a5abcd5d0e 100644 --- a/src/Moryx.AbstractionLayer.TestTools/InMemoryUnitOfWorkFactoryBuilder.cs +++ b/src/Moryx.AbstractionLayer.TestTools/InMemoryUnitOfWorkFactoryBuilder.cs @@ -63,4 +63,4 @@ public static UnitOfWorkFactory EnsureDbIsCreated(this UnitOfWorkFactory) - select prop).ToList(); + let propType = prop.PropertyType + where propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof(IReferences<>) + select prop).ToList(); foreach (var property in properties) { var listType = typeof(ReferenceCollectionMock<>).MakeGenericType(property.PropertyType.GetGenericArguments()[0]); diff --git a/src/Moryx.AbstractionLayer/Activities/Activity.cs b/src/Moryx.AbstractionLayer/Activities/Activity.cs index 1faa646a9b..1b17e98e19 100644 --- a/src/Moryx.AbstractionLayer/Activities/Activity.cs +++ b/src/Moryx.AbstractionLayer/Activities/Activity.cs @@ -145,4 +145,4 @@ protected Activity() public abstract class Activity : Activity where TParam : IParameters { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/ActivityBindingResolverFactory.cs b/src/Moryx.AbstractionLayer/Activities/ActivityBindingResolverFactory.cs index e80955042c..b0211b067e 100644 --- a/src/Moryx.AbstractionLayer/Activities/ActivityBindingResolverFactory.cs +++ b/src/Moryx.AbstractionLayer/Activities/ActivityBindingResolverFactory.cs @@ -38,4 +38,4 @@ protected override IBindingResolverChain CreateBaseResolver(string baseKey) return null; } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/ActivityExtensions.cs b/src/Moryx.AbstractionLayer/Activities/ActivityExtensions.cs index 2c41d75cb5..53c59ef017 100644 --- a/src/Moryx.AbstractionLayer/Activities/ActivityExtensions.cs +++ b/src/Moryx.AbstractionLayer/Activities/ActivityExtensions.cs @@ -25,4 +25,4 @@ public static IWorkplanStep GetTask(this Activity activity) } return null; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/ActivityResult.cs b/src/Moryx.AbstractionLayer/Activities/ActivityResult.cs index a270c97a49..bb18c64cf8 100644 --- a/src/Moryx.AbstractionLayer/Activities/ActivityResult.cs +++ b/src/Moryx.AbstractionLayer/Activities/ActivityResult.cs @@ -40,4 +40,4 @@ public static ActivityResult Create(bool success, long value) /// Result number used to determine next steps /// public long Numeric { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/ActivityResultsAttribute.cs b/src/Moryx.AbstractionLayer/Activities/ActivityResultsAttribute.cs index 5b1acc671d..4afe307fa3 100644 --- a/src/Moryx.AbstractionLayer/Activities/ActivityResultsAttribute.cs +++ b/src/Moryx.AbstractionLayer/Activities/ActivityResultsAttribute.cs @@ -21,4 +21,4 @@ public ActivityResultsAttribute(Type resultEnum) /// Type of the enum containing the results /// public Type ResultEnum { get; private set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/DefaultActivityResult.cs b/src/Moryx.AbstractionLayer/Activities/DefaultActivityResult.cs index 23adccc1b0..dabe296558 100644 --- a/src/Moryx.AbstractionLayer/Activities/DefaultActivityResult.cs +++ b/src/Moryx.AbstractionLayer/Activities/DefaultActivityResult.cs @@ -27,4 +27,4 @@ public enum DefaultActivityResult /// [OutputType(OutputType.Failure)] TechnicalError = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/IActivity.cs b/src/Moryx.AbstractionLayer/Activities/IActivity.cs index 50acb319a4..8c3ea183ca 100644 --- a/src/Moryx.AbstractionLayer/Activities/IActivity.cs +++ b/src/Moryx.AbstractionLayer/Activities/IActivity.cs @@ -73,4 +73,4 @@ public interface IActivity : IActivity /// Typed parameters object for this activity /// new TParam Parameters { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/IParameters.cs b/src/Moryx.AbstractionLayer/Activities/IParameters.cs index ff4050e2e0..7b2a7e0dbd 100644 --- a/src/Moryx.AbstractionLayer/Activities/IParameters.cs +++ b/src/Moryx.AbstractionLayer/Activities/IParameters.cs @@ -14,4 +14,4 @@ public interface IParameters /// Create new parameters object with resolved binding values from process /// IParameters Bind(Process process); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/NullActivityParameters.cs b/src/Moryx.AbstractionLayer/Activities/NullActivityParameters.cs index a6726d88a6..3213f10d34 100644 --- a/src/Moryx.AbstractionLayer/Activities/NullActivityParameters.cs +++ b/src/Moryx.AbstractionLayer/Activities/NullActivityParameters.cs @@ -17,4 +17,4 @@ public IParameters Bind(Process process) { return this; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/OutputTypeAttribute.cs b/src/Moryx.AbstractionLayer/Activities/OutputTypeAttribute.cs index 4608dd07af..507f1e3d00 100644 --- a/src/Moryx.AbstractionLayer/Activities/OutputTypeAttribute.cs +++ b/src/Moryx.AbstractionLayer/Activities/OutputTypeAttribute.cs @@ -24,4 +24,4 @@ public OutputTypeAttribute(OutputType outputType) /// Set output type /// public OutputType OutputType { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/Parameters.cs b/src/Moryx.AbstractionLayer/Activities/Parameters.cs index 85eb30877b..80d8024188 100644 --- a/src/Moryx.AbstractionLayer/Activities/Parameters.cs +++ b/src/Moryx.AbstractionLayer/Activities/Parameters.cs @@ -29,10 +29,14 @@ public IParameters Bind(Process process) { // We are already bound to this process if (_process == process) + { return this; + } if (_instanceDelegate == null) + { _instanceDelegate = ReflectionTool.ConstructorDelegate(GetType()); + } // Create new instance of this type var instance = _instanceDelegate(); @@ -50,4 +54,4 @@ public IParameters Bind(Process process) /// New instance of this type /// Process to bind to protected abstract void Populate(Process process, Parameters instance); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/ProcessRequirement.cs b/src/Moryx.AbstractionLayer/Activities/ProcessRequirement.cs index e809020fee..ff72adf7f3 100644 --- a/src/Moryx.AbstractionLayer/Activities/ProcessRequirement.cs +++ b/src/Moryx.AbstractionLayer/Activities/ProcessRequirement.cs @@ -24,4 +24,4 @@ public enum ProcessRequirement /// a process by inserting a part into the machine or confirming the execution of a process. /// Empty -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/Tracing.cs b/src/Moryx.AbstractionLayer/Activities/Tracing.cs index a1da54b22a..179c2f354b 100644 --- a/src/Moryx.AbstractionLayer/Activities/Tracing.cs +++ b/src/Moryx.AbstractionLayer/Activities/Tracing.cs @@ -47,7 +47,9 @@ public Sparta Transform() where Sparta : Tracing, new() { if (this is Sparta) + { return this as Sparta; + } var replacement = new Sparta(); var replacementType = typeof(Sparta); @@ -59,9 +61,11 @@ public Sparta Transform() where Sparta { var value = property.GetValue(this); if (property.CanWrite) + { property.SetValue(replacement, value); + } } return replacement; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Activities/TracingExtension.cs b/src/Moryx.AbstractionLayer/Activities/TracingExtension.cs index c38cbaf941..e7245e713c 100644 --- a/src/Moryx.AbstractionLayer/Activities/TracingExtension.cs +++ b/src/Moryx.AbstractionLayer/Activities/TracingExtension.cs @@ -29,4 +29,4 @@ public static class TracingExtension setter(activityTracing); return activityTracing; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Capabilities/CapabilitiesBase.cs b/src/Moryx.AbstractionLayer/Capabilities/CapabilitiesBase.cs index 0acf34a183..68e836a13d 100644 --- a/src/Moryx.AbstractionLayer/Capabilities/CapabilitiesBase.cs +++ b/src/Moryx.AbstractionLayer/Capabilities/CapabilitiesBase.cs @@ -24,4 +24,4 @@ public IEnumerable GetAll() => /// Check if our required capabilities are provided by the given object /// protected abstract bool ProvidedBy(ICapabilities provided); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Capabilities/CombinedCapabilities.cs b/src/Moryx.AbstractionLayer/Capabilities/CombinedCapabilities.cs index 42edcb31d1..e5b14ef559 100644 --- a/src/Moryx.AbstractionLayer/Capabilities/CombinedCapabilities.cs +++ b/src/Moryx.AbstractionLayer/Capabilities/CombinedCapabilities.cs @@ -42,4 +42,4 @@ IEnumerable ICapabilities.GetAll() { return _capabilities; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Capabilities/ICapabilities.cs b/src/Moryx.AbstractionLayer/Capabilities/ICapabilities.cs index f01c141bfa..4fd2e6e966 100644 --- a/src/Moryx.AbstractionLayer/Capabilities/ICapabilities.cs +++ b/src/Moryx.AbstractionLayer/Capabilities/ICapabilities.cs @@ -32,4 +32,4 @@ public interface ICapabilities /// /// IEnumerable GetAll(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Constraints/ExpressionConstraint.cs b/src/Moryx.AbstractionLayer/Constraints/ExpressionConstraint.cs index 37f4c9acb2..45ff7f5be1 100644 --- a/src/Moryx.AbstractionLayer/Constraints/ExpressionConstraint.cs +++ b/src/Moryx.AbstractionLayer/Constraints/ExpressionConstraint.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Runtime.CompilerServices; -using Moryx.Serialization; namespace Moryx.AbstractionLayer.Constraints; @@ -95,7 +94,7 @@ public override string ToString() /// /// Check if the expressions return value equals the /// - private class ExpressionEqualsConstraint : ExpressionConstraintBase + private sealed class ExpressionEqualsConstraint : ExpressionConstraintBase where TContext : class, IConstraintContext { @@ -114,7 +113,7 @@ protected override bool CheckConstraint(TContext context) /// /// Check if the expression return value is less or equal to /// - private class ExpressionLessConstraint : ExpressionConstraintBase + private sealed class ExpressionLessConstraint : ExpressionConstraintBase where TContext : class, IConstraintContext { public ExpressionLessConstraint(Func expression, object value, string expressionString) : base(expression, value, expressionString) @@ -134,7 +133,7 @@ protected override bool CheckConstraint(TContext context) /// /// Check if the expression return value is greater or equal to /// - private class ExpressionGreaterConstraint : ExpressionConstraintBase + private sealed class ExpressionGreaterConstraint : ExpressionConstraintBase where TContext : class, IConstraintContext { public ExpressionGreaterConstraint(Func expression, object value, string expressionString) : base(expression, value, expressionString) diff --git a/src/Moryx.AbstractionLayer/Constraints/IConstraint.cs b/src/Moryx.AbstractionLayer/Constraints/IConstraint.cs index 3364c2562a..f6a81ba7e4 100644 --- a/src/Moryx.AbstractionLayer/Constraints/IConstraint.cs +++ b/src/Moryx.AbstractionLayer/Constraints/IConstraint.cs @@ -13,4 +13,4 @@ public interface IConstraint /// /// True: all is ok and valid, False: nothing is ok and not valid. bool Check(IConstraintContext context); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Constraints/IConstraintContext.cs b/src/Moryx.AbstractionLayer/Constraints/IConstraintContext.cs index d25990f38e..e8e22e9658 100644 --- a/src/Moryx.AbstractionLayer/Constraints/IConstraintContext.cs +++ b/src/Moryx.AbstractionLayer/Constraints/IConstraintContext.cs @@ -8,4 +8,4 @@ namespace Moryx.AbstractionLayer.Constraints; /// public interface IConstraintContext { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Constraints/NullConstraint.cs b/src/Moryx.AbstractionLayer/Constraints/NullConstraint.cs index abe86ab3bf..72d8e1f594 100644 --- a/src/Moryx.AbstractionLayer/Constraints/NullConstraint.cs +++ b/src/Moryx.AbstractionLayer/Constraints/NullConstraint.cs @@ -15,4 +15,4 @@ public bool Check(IConstraintContext context) { return true; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Axis/Axes.cs b/src/Moryx.AbstractionLayer/Drivers/Axis/Axes.cs index 34957a4960..01ef1701e6 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Axis/Axes.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Axis/Axes.cs @@ -125,4 +125,4 @@ public enum Axes : uint /// All axes of system /// All = uint.MaxValue, -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Axis/AxisMovementResponse.cs b/src/Moryx.AbstractionLayer/Drivers/Axis/AxisMovementResponse.cs index 6d25d851e4..561b06b354 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Axis/AxisMovementResponse.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Axis/AxisMovementResponse.cs @@ -9,4 +9,4 @@ namespace Moryx.AbstractionLayer.Drivers.Axis; public class AxisMovementResponse { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Axis/AxisPosition.cs b/src/Moryx.AbstractionLayer/Drivers/Axis/AxisPosition.cs index d1735670e1..adea665b08 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Axis/AxisPosition.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Axis/AxisPosition.cs @@ -60,4 +60,4 @@ public enum AxisPosition /// Move axes to reference position /// Reference, -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Axis/NumberedAxis.cs b/src/Moryx.AbstractionLayer/Drivers/Axis/NumberedAxis.cs index c0542afc98..8f44c7a9fb 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Axis/NumberedAxis.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Axis/NumberedAxis.cs @@ -48,7 +48,10 @@ public bool Equals(NumberedAxis other) public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) + { return false; + } + return obj is NumberedAxis && Equals((NumberedAxis)obj); } @@ -60,4 +63,4 @@ public override int GetHashCode() return ((int)Axis * 397) ^ Number; } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Driver.cs b/src/Moryx.AbstractionLayer/Drivers/Driver.cs index 538998f4bf..669e1f15d3 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Driver.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Driver.cs @@ -48,4 +48,4 @@ protected virtual Task OnStateChangedAsync(CancellationToken cancellationToken) /// public event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/IDriver.cs b/src/Moryx.AbstractionLayer/Drivers/IDriver.cs index 81f7757862..c93de8ba30 100644 --- a/src/Moryx.AbstractionLayer/Drivers/IDriver.cs +++ b/src/Moryx.AbstractionLayer/Drivers/IDriver.cs @@ -19,4 +19,4 @@ public interface IDriver : IResource /// Event raised when the device state changed /// event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/IDriverState.cs b/src/Moryx.AbstractionLayer/Drivers/IDriverState.cs index d7cf364701..bc5f4ceaf3 100644 --- a/src/Moryx.AbstractionLayer/Drivers/IDriverState.cs +++ b/src/Moryx.AbstractionLayer/Drivers/IDriverState.cs @@ -12,4 +12,4 @@ public interface IDriverState /// Gets the classification of the state. /// StateClassification Classification { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/InOut/IInOutDriver.cs b/src/Moryx.AbstractionLayer/Drivers/InOut/IInOutDriver.cs index 30684b23ec..2499040082 100644 --- a/src/Moryx.AbstractionLayer/Drivers/InOut/IInOutDriver.cs +++ b/src/Moryx.AbstractionLayer/Drivers/InOut/IInOutDriver.cs @@ -31,4 +31,4 @@ public interface IOutputDriver : IDriver /// public interface IInOutDriver : IInputDriver, IOutputDriver { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/InOut/IInput.cs b/src/Moryx.AbstractionLayer/Drivers/InOut/IInput.cs index 9a3922e8fb..167f9e17b0 100644 --- a/src/Moryx.AbstractionLayer/Drivers/InOut/IInput.cs +++ b/src/Moryx.AbstractionLayer/Drivers/InOut/IInput.cs @@ -38,4 +38,4 @@ public interface IInput /// Event raised when any input value changed /// event EventHandler InputChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/InOut/IOutput.cs b/src/Moryx.AbstractionLayer/Drivers/InOut/IOutput.cs index 604efaeb78..f797237994 100644 --- a/src/Moryx.AbstractionLayer/Drivers/InOut/IOutput.cs +++ b/src/Moryx.AbstractionLayer/Drivers/InOut/IOutput.cs @@ -33,4 +33,4 @@ public interface IOutput /// /// Thrown if the driver is in an invalid state for this operation. object this[string key] { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/InOut/InputChangedEventArgs.cs b/src/Moryx.AbstractionLayer/Drivers/InOut/InputChangedEventArgs.cs index 704242e441..c11c3b745d 100644 --- a/src/Moryx.AbstractionLayer/Drivers/InOut/InputChangedEventArgs.cs +++ b/src/Moryx.AbstractionLayer/Drivers/InOut/InputChangedEventArgs.cs @@ -66,4 +66,4 @@ public InputChangedEventArgs(int index, string key, object value) Value = value; InputAccess = SupportedAccess.Index | SupportedAccess.Key; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/InOut/SupportedAccess.cs b/src/Moryx.AbstractionLayer/Drivers/InOut/SupportedAccess.cs index 42cbed5c6e..aa23ad1d0e 100644 --- a/src/Moryx.AbstractionLayer/Drivers/InOut/SupportedAccess.cs +++ b/src/Moryx.AbstractionLayer/Drivers/InOut/SupportedAccess.cs @@ -33,4 +33,4 @@ public enum SupportedAccess /// Driver supports changed events for inputs /// Event = 1 << 16 -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingConfiguration.cs b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingConfiguration.cs index 1c80edd375..380d95679f 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingConfiguration.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingConfiguration.cs @@ -63,4 +63,4 @@ public MarkingConfiguration SetTransformation(double resizingFactor, double angl YAxis = yAxis; return this; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFIleResponse.cs b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFIleResponse.cs index 7b171d83b3..162cc2b233 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFIleResponse.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFIleResponse.cs @@ -9,4 +9,4 @@ namespace Moryx.AbstractionLayer.Drivers.Marking; public class MarkingFileResponse { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFile.cs b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFile.cs index 1a631c462a..502ba28121 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFile.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingFile.cs @@ -26,4 +26,4 @@ public MarkingFile(string fileName, byte[] fileBytes) /// File to mark with the laser /// public byte[] FileBytes { get; private set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingResponse.cs b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingResponse.cs index 180969f09b..7afe7984e3 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingResponse.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Marking/MarkingResponse.cs @@ -9,4 +9,4 @@ namespace Moryx.AbstractionLayer.Drivers.Marking; public class MarkingResponse { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Marking/SegmentsNotSupportedException.cs b/src/Moryx.AbstractionLayer/Drivers/Marking/SegmentsNotSupportedException.cs index c6dfe80144..1879869dfa 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Marking/SegmentsNotSupportedException.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Marking/SegmentsNotSupportedException.cs @@ -17,4 +17,4 @@ public SegmentsNotSupportedException() : base(Strings.SegmentsNotSupportedExcept { } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Message/IIdentifierMessage.cs b/src/Moryx.AbstractionLayer/Drivers/Message/IIdentifierMessage.cs index 4d397f0bad..9a3982b5e8 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Message/IIdentifierMessage.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Message/IIdentifierMessage.cs @@ -12,4 +12,4 @@ public interface IIdentifierMessage /// Source or target identifier of the message /// string Identifier { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Message/IMessageDriver.cs b/src/Moryx.AbstractionLayer/Drivers/Message/IMessageDriver.cs index bce7212eb5..4753c0120d 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Message/IMessageDriver.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Message/IMessageDriver.cs @@ -17,4 +17,4 @@ public interface IMessageDriver : IDriver, IMessageChannel /// Get channel using specialized API /// IMessageChannel Channel(string identifier); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidDirection.cs b/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidDirection.cs index 24505a5a66..25f2f6db8e 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidDirection.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidDirection.cs @@ -22,4 +22,4 @@ public enum RfidDirection /// Direction detection from right ro left /// FromRightToLeft = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidTag.cs b/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidTag.cs index 108d4e2da0..7760a6a52e 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidTag.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Rfid/RfidTag.cs @@ -37,4 +37,4 @@ public class RfidTag /// Movement direction of the rfid tag /// public RfidDirection Direction { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/Scanner/ReadCodeOptions.cs b/src/Moryx.AbstractionLayer/Drivers/Scanner/ReadCodeOptions.cs index 7857fcafad..7c1145a6f7 100644 --- a/src/Moryx.AbstractionLayer/Drivers/Scanner/ReadCodeOptions.cs +++ b/src/Moryx.AbstractionLayer/Drivers/Scanner/ReadCodeOptions.cs @@ -8,8 +8,4 @@ namespace Moryx.AbstractionLayer.Drivers.Scanner; /// public class ReadCodeOptions { - /// - /// Determines whether the button of the scanner can be used to initiate a scan or whether it is triggered by the system - /// - bool UseButton { get; set; } } diff --git a/src/Moryx.AbstractionLayer/Drivers/StateClassification.cs b/src/Moryx.AbstractionLayer/Drivers/StateClassification.cs index 976985b9ca..8cc603dac2 100644 --- a/src/Moryx.AbstractionLayer/Drivers/StateClassification.cs +++ b/src/Moryx.AbstractionLayer/Drivers/StateClassification.cs @@ -40,4 +40,4 @@ public enum StateClassification : int /// Error means that is not running because there is an error /// Error = 1 << 8, -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Drivers/SyncDriverState.cs b/src/Moryx.AbstractionLayer/Drivers/SyncDriverState.cs index c501ffc743..47fdf25f96 100644 --- a/src/Moryx.AbstractionLayer/Drivers/SyncDriverState.cs +++ b/src/Moryx.AbstractionLayer/Drivers/SyncDriverState.cs @@ -41,4 +41,4 @@ public virtual void Disconnect() { InvalidState(); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Identity/BatchIdentity.cs b/src/Moryx.AbstractionLayer/Identity/BatchIdentity.cs index d59cffcf4c..0e3f81addd 100644 --- a/src/Moryx.AbstractionLayer/Identity/BatchIdentity.cs +++ b/src/Moryx.AbstractionLayer/Identity/BatchIdentity.cs @@ -36,4 +36,4 @@ public bool Equals(IIdentity other) { return other is BatchIdentity batchIdentity && batchIdentity.Identifier == Identifier; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Identity/IIdentifiableObject.cs b/src/Moryx.AbstractionLayer/Identity/IIdentifiableObject.cs index 8a853000f9..303f4f7a71 100644 --- a/src/Moryx.AbstractionLayer/Identity/IIdentifiableObject.cs +++ b/src/Moryx.AbstractionLayer/Identity/IIdentifiableObject.cs @@ -12,4 +12,4 @@ public interface IIdentifiableObject /// Identity of this product /// IIdentity Identity { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Identity/IIdentity.cs b/src/Moryx.AbstractionLayer/Identity/IIdentity.cs index b377640faf..ae0b6a1650 100644 --- a/src/Moryx.AbstractionLayer/Identity/IIdentity.cs +++ b/src/Moryx.AbstractionLayer/Identity/IIdentity.cs @@ -19,4 +19,4 @@ public interface IIdentity : IEquatable /// /// Identifiers of some identities must not be overriden void SetIdentifier(string identifier); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Identity/IdentityEntryEncoder.cs b/src/Moryx.AbstractionLayer/Identity/IdentityEntryEncoder.cs index 84d5ca64e5..35e5721d54 100644 --- a/src/Moryx.AbstractionLayer/Identity/IdentityEntryEncoder.cs +++ b/src/Moryx.AbstractionLayer/Identity/IdentityEntryEncoder.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Globalization; using System.Reflection; -using Moryx.Configuration; using Moryx.Serialization; using Moryx.Tools; diff --git a/src/Moryx.AbstractionLayer/Identity/NumberIdentity.cs b/src/Moryx.AbstractionLayer/Identity/NumberIdentity.cs index f3011aeb36..9058aa5449 100644 --- a/src/Moryx.AbstractionLayer/Identity/NumberIdentity.cs +++ b/src/Moryx.AbstractionLayer/Identity/NumberIdentity.cs @@ -80,7 +80,9 @@ public override bool Equals(object obj) public static bool operator ==(NumberIdentity id1, NumberIdentity id2) { if (((object)id1) == null || ((object)id2) == null) + { return Equals(id1, id2); + } return id1.Equals(id2); } @@ -94,7 +96,9 @@ public override bool Equals(object obj) public static bool operator !=(NumberIdentity id1, NumberIdentity id2) { if (((object)id1) == null || ((object)id2) == null) + { return !Equals(id1, id2); + } return !(id1.Equals(id2)); } @@ -107,4 +111,4 @@ public override int GetHashCode() return NumberType * (Identifier?.GetHashCode() ?? 42); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Processes/IProcess.cs b/src/Moryx.AbstractionLayer/Processes/IProcess.cs index a3ca8ec7b5..b8e1f225de 100644 --- a/src/Moryx.AbstractionLayer/Processes/IProcess.cs +++ b/src/Moryx.AbstractionLayer/Processes/IProcess.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Constraints; using Moryx.AbstractionLayer.Recipes; namespace Moryx.AbstractionLayer.Processes; @@ -74,4 +73,4 @@ public interface IProcess : IPersistentObject /// Remove an activity from the list /// void RemoveActivity(Activity toRemove); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Processes/Process.cs b/src/Moryx.AbstractionLayer/Processes/Process.cs index 2a036aa4c6..a59333c010 100644 --- a/src/Moryx.AbstractionLayer/Processes/Process.cs +++ b/src/Moryx.AbstractionLayer/Processes/Process.cs @@ -40,9 +40,13 @@ public virtual IEnumerable GetActivities(Func predicat Activity[] result; if (predicate == null) + { result = _activities.ToArray(); + } else + { result = _activities.Where(predicate).ToArray(); + } _activitiesLock.ExitReadLock(); @@ -110,4 +114,4 @@ public virtual void RemoveActivity(Activity toRemove) _activitiesLock.ExitWriteLock(); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Processes/ProcessBindingResolverFactory.cs b/src/Moryx.AbstractionLayer/Processes/ProcessBindingResolverFactory.cs index 1f07f18634..392396a77e 100644 --- a/src/Moryx.AbstractionLayer/Processes/ProcessBindingResolverFactory.cs +++ b/src/Moryx.AbstractionLayer/Processes/ProcessBindingResolverFactory.cs @@ -53,10 +53,14 @@ protected override IBindingResolverChain AddToChain(IBindingResolverChain resolv resolver = resolver.Extend(new PartLinkShortCut()); if (property == nameof(IIdentity.Identifier)) + { return resolver.Extend(new IdentifierShortCut()); + } if (property == nameof(ProductType) || property == nameof(ProductInstance.Type)) + { return resolver.Extend(new ProductResolver(property)); + } return base.AddToChain(resolver, property); } @@ -142,15 +146,15 @@ protected sealed override object Resolve(object source) switch (source) { case Process process: - { - var product = (process.Recipe as IProductRecipe)?.Product; - return product; - } + { + var product = (process.Recipe as IProductRecipe)?.Product; + return product; + } case Activity activity: - { - var product = (activity.Process.Recipe as IProductRecipe)?.Product; - return product; - } + { + var product = (activity.Process.Recipe as IProductRecipe)?.Product; + return product; + } case ProductInstance instance: return instance.Type; } diff --git a/src/Moryx.AbstractionLayer/Processes/ProcessRecipeLink.cs b/src/Moryx.AbstractionLayer/Processes/ProcessRecipeLink.cs index f5c957c50f..f8aed168ad 100644 --- a/src/Moryx.AbstractionLayer/Processes/ProcessRecipeLink.cs +++ b/src/Moryx.AbstractionLayer/Processes/ProcessRecipeLink.cs @@ -17,4 +17,4 @@ public class ProcessRecipeLink /// The ID of the recipe used to handle this process. /// public long RecipeId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Processes/ProcessWorkplanContext.cs b/src/Moryx.AbstractionLayer/Processes/ProcessWorkplanContext.cs index c72c5eff61..6206fc0cdd 100644 --- a/src/Moryx.AbstractionLayer/Processes/ProcessWorkplanContext.cs +++ b/src/Moryx.AbstractionLayer/Processes/ProcessWorkplanContext.cs @@ -29,4 +29,4 @@ public virtual bool IsDisabled(IWorkplanStep step) { return ((IWorkplanRecipe)Process.Recipe).DisabledSteps.Contains(step.Id); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Processes/ProductionProcess.cs b/src/Moryx.AbstractionLayer/Processes/ProductionProcess.cs index f962c53912..d870e99340 100644 --- a/src/Moryx.AbstractionLayer/Processes/ProductionProcess.cs +++ b/src/Moryx.AbstractionLayer/Processes/ProductionProcess.cs @@ -14,4 +14,4 @@ public class ProductionProcess : Process /// The product instance produced by this process. /// public ProductInstance ProductInstance { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IProductInstance.cs b/src/Moryx.AbstractionLayer/Products/IProductInstance.cs index 2a7321bcb4..b666c0c282 100644 --- a/src/Moryx.AbstractionLayer/Products/IProductInstance.cs +++ b/src/Moryx.AbstractionLayer/Products/IProductInstance.cs @@ -27,4 +27,4 @@ public interface IProductInstance /// The current state of the instance /// ProductInstanceState State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IProductManagement.cs b/src/Moryx.AbstractionLayer/Products/IProductManagement.cs index e44285b71e..5b57741cdc 100644 --- a/src/Moryx.AbstractionLayer/Products/IProductManagement.cs +++ b/src/Moryx.AbstractionLayer/Products/IProductManagement.cs @@ -171,4 +171,4 @@ Task> LoadInstancesAsync(ExpressionFull name of the type /// ProductTypeWrapper GetTypeWrapper(string typeName); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IProductPartLink.cs b/src/Moryx.AbstractionLayer/Products/IProductPartLink.cs index 1ac2cd99d8..82b7203830 100644 --- a/src/Moryx.AbstractionLayer/Products/IProductPartLink.cs +++ b/src/Moryx.AbstractionLayer/Products/IProductPartLink.cs @@ -45,4 +45,4 @@ public static List Instantiate(this IEnumerable (TInstance)p.Instantiate()).ToList(); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IProductType.cs b/src/Moryx.AbstractionLayer/Products/IProductType.cs index 9c5d10564c..35a425d372 100644 --- a/src/Moryx.AbstractionLayer/Products/IProductType.cs +++ b/src/Moryx.AbstractionLayer/Products/IProductType.cs @@ -24,4 +24,4 @@ public interface IProductType : IPersistentObject, IIdentifiableObject /// Create instance of this type /// ProductInstance CreateInstance(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IProductionDate.cs b/src/Moryx.AbstractionLayer/Products/IProductionDate.cs index a82a0fdb6c..0f31553ea2 100644 --- a/src/Moryx.AbstractionLayer/Products/IProductionDate.cs +++ b/src/Moryx.AbstractionLayer/Products/IProductionDate.cs @@ -12,4 +12,4 @@ public interface IProductionDate /// Date of production /// DateTime ProductionDate { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/IdentityConflictException.cs b/src/Moryx.AbstractionLayer/Products/IdentityConflictException.cs index 40b09d3941..952a7c3cb4 100644 --- a/src/Moryx.AbstractionLayer/Products/IdentityConflictException.cs +++ b/src/Moryx.AbstractionLayer/Products/IdentityConflictException.cs @@ -32,4 +32,4 @@ public IdentityConflictException(bool invalidTemplate) { InvalidTemplate = invalidTemplate; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/FileImportParameters.cs b/src/Moryx.AbstractionLayer/Products/Import/FileImportParameters.cs index 0f9de0a2ec..655f1d1ea7 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/FileImportParameters.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/FileImportParameters.cs @@ -35,4 +35,4 @@ public Stream ReadFile() var bytes = Convert.FromBase64String(File); return new MemoryStream(bytes); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/IProductImporter.cs b/src/Moryx.AbstractionLayer/Products/Import/IProductImporter.cs index 833a4417a4..8e01008233 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/IProductImporter.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/IProductImporter.cs @@ -34,4 +34,4 @@ public interface IProductImporter : IAsyncConfiguredPlugin Task ImportAsync(ProductImportContext context, object parameters, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/ProductImportContext.cs b/src/Moryx.AbstractionLayer/Products/Import/ProductImportContext.cs index 36dffda0b9..a53e22fd04 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/ProductImportContext.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/ProductImportContext.cs @@ -12,4 +12,4 @@ public class ProductImportContext /// Session guid of the import /// public Guid Session { get; } = Guid.NewGuid(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterBase.cs b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterBase.cs index 77ce04e463..3b7608e8b2 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterBase.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterBase.cs @@ -86,4 +86,4 @@ Task IProductImporter.ImportAsync(ProductImportContext co /// Import products using typed parameters /// protected abstract Task ImportAsync(ProductImportContext context, TParameters parameters, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterConfig.cs b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterConfig.cs index d11eb42e34..7e5b537a63 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterConfig.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterConfig.cs @@ -20,4 +20,4 @@ public class ProductImporterConfig : IPluginConfig [DataMember, Description("PluginName of the importer")] [PluginNameSelector(typeof(IProductImporter))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterResult.cs b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterResult.cs index 57d573b21c..c81d95b685 100644 --- a/src/Moryx.AbstractionLayer/Products/Import/ProductImporterResult.cs +++ b/src/Moryx.AbstractionLayer/Products/Import/ProductImporterResult.cs @@ -12,4 +12,4 @@ public class ProductImporterResult : ProductImportResult /// Flag if all objects were saved /// public bool Saved { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/ProductIdentity.cs b/src/Moryx.AbstractionLayer/Products/ProductIdentity.cs index 46b100f89b..d4dbf1fceb 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductIdentity.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductIdentity.cs @@ -50,7 +50,9 @@ public static ProductIdentity Parse(string identityString) var match = IdentityPattern().Match(identityString); if (!match.Success || !short.TryParse(match.Groups["revision"].Value, NumberStyles.None, CultureInfo.InvariantCulture, out var revision)) + { throw new FormatException($"'{identityString}' does not match the expected pattern '{IdentityPattern()}'."); + } return new ProductIdentity(match.Groups["identifier"].Value, revision); } @@ -133,7 +135,9 @@ public override bool Equals(object obj) public static bool operator ==(ProductIdentity id1, ProductIdentity id2) { if (((object)id1) == null || ((object)id2) == null) + { return Object.Equals(id1, id2); + } return id1.Equals(id2); } @@ -147,7 +151,9 @@ public override bool Equals(object obj) public static bool operator !=(ProductIdentity id1, ProductIdentity id2) { if (((object)id1) == null || ((object)id2) == null) + { return !Object.Equals(id1, id2); + } return !(id1.Equals(id2)); } diff --git a/src/Moryx.AbstractionLayer/Products/ProductImportResult.cs b/src/Moryx.AbstractionLayer/Products/ProductImportResult.cs index 253e512d40..749283e74c 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductImportResult.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductImportResult.cs @@ -12,4 +12,4 @@ public class ProductImportResult /// Types that were imported /// public IReadOnlyList ImportedTypes { get; set; } = new List(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/ProductInstance.cs b/src/Moryx.AbstractionLayer/Products/ProductInstance.cs index 0fe202b09f..98f913efec 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductInstance.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductInstance.cs @@ -46,4 +46,4 @@ public abstract class ProductInstance : ProductInstance get => (TProduct)base.Type; set => base.Type = value; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/ProductPartLink.cs b/src/Moryx.AbstractionLayer/Products/ProductPartLink.cs index d733575a75..4b6a74bdce 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductPartLink.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductPartLink.cs @@ -79,4 +79,4 @@ public ProductPartLink(long id) : base(id) get => (TProduct)base.Product; set => base.Product = value; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/ProductType.cs b/src/Moryx.AbstractionLayer/Products/ProductType.cs index ca197eae84..e8e5d0c80d 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductType.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductType.cs @@ -48,4 +48,4 @@ public ProductInstance CreateInstance() /// /// New instance protected abstract ProductInstance Instantiate(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Products/ProductTypeWrapper.cs b/src/Moryx.AbstractionLayer/Products/ProductTypeWrapper.cs index b8ac5cecef..c9b48a3ad5 100644 --- a/src/Moryx.AbstractionLayer/Products/ProductTypeWrapper.cs +++ b/src/Moryx.AbstractionLayer/Products/ProductTypeWrapper.cs @@ -24,4 +24,4 @@ public ProductTypeWrapper(string identifier, Func constructor, Dict Properties = properties; PartLinks = properties.Where(p => typeof(ProductPartLink).IsAssignableFrom(p.PropertyType) || typeof(IEnumerable).IsAssignableFrom(p.PropertyType)); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/IProductRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/IProductRecipe.cs index 28969acfa7..576b674a1c 100644 --- a/src/Moryx.AbstractionLayer/Recipes/IProductRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/IProductRecipe.cs @@ -22,4 +22,4 @@ public interface IProductRecipe : IRecipe /// not have to. /// ProductType Target { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/IRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/IRecipe.cs index 720bbb7b9e..1754fa5e48 100644 --- a/src/Moryx.AbstractionLayer/Recipes/IRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/IRecipe.cs @@ -49,4 +49,4 @@ public interface IRecipe : IPersistentObject /// Creates a clone of the current recipe /// IRecipe Clone(); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/IRecipeProvider.cs b/src/Moryx.AbstractionLayer/Recipes/IRecipeProvider.cs index accbcd058c..6e5f7efcce 100644 --- a/src/Moryx.AbstractionLayer/Recipes/IRecipeProvider.cs +++ b/src/Moryx.AbstractionLayer/Recipes/IRecipeProvider.cs @@ -22,4 +22,4 @@ public interface IRecipeProvider /// A recipe was changed, give users the chance to update their reference /// event EventHandler RecipeChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/IWorkplanRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/IWorkplanRecipe.cs index a6f52befb8..c05e994a70 100644 --- a/src/Moryx.AbstractionLayer/Recipes/IWorkplanRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/IWorkplanRecipe.cs @@ -19,4 +19,4 @@ public interface IWorkplanRecipe : IRecipe /// Steps that shall be skipped /// ICollection DisabledSteps { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/ProductRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/ProductRecipe.cs index ca9f3ddb99..384332e16b 100644 --- a/src/Moryx.AbstractionLayer/Recipes/ProductRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/ProductRecipe.cs @@ -37,4 +37,4 @@ public override IRecipe Clone() { return new ProductRecipe(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/ProductRecipeReference.cs b/src/Moryx.AbstractionLayer/Recipes/ProductRecipeReference.cs index 6dba2bbb7d..ec0f5555f0 100644 --- a/src/Moryx.AbstractionLayer/Recipes/ProductRecipeReference.cs +++ b/src/Moryx.AbstractionLayer/Recipes/ProductRecipeReference.cs @@ -22,4 +22,4 @@ public class ProductRecipeReference : RecipeReference, IProductRecipe public ProductRecipeReference(long recipeId) : base(recipeId) { } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/ProductionRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/ProductionRecipe.cs index 36ad716a95..941a2dfd5e 100644 --- a/src/Moryx.AbstractionLayer/Recipes/ProductionRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/ProductionRecipe.cs @@ -42,4 +42,4 @@ public override Process CreateProcess() => /// public override IRecipe Clone() => new ProductionRecipe(this); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/Recipe.cs b/src/Moryx.AbstractionLayer/Recipes/Recipe.cs index 1b42964246..6226583afc 100644 --- a/src/Moryx.AbstractionLayer/Recipes/Recipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/Recipe.cs @@ -71,4 +71,4 @@ object ICloneable.Clone() { return Clone(); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/RecipeBindingResolverFactory.cs b/src/Moryx.AbstractionLayer/Recipes/RecipeBindingResolverFactory.cs index 03a11112b4..5b7d2929a0 100644 --- a/src/Moryx.AbstractionLayer/Recipes/RecipeBindingResolverFactory.cs +++ b/src/Moryx.AbstractionLayer/Recipes/RecipeBindingResolverFactory.cs @@ -39,22 +39,28 @@ protected override IBindingResolverChain AddToChain(IBindingResolverChain resolv resolver = resolver.Extend(new PartLinkShortCut()); if (property == nameof(IIdentity.Identifier)) + { return resolver.Extend(new IdentifierShortCut()); + } var wpResolver = resolver as WorkplanResolver; if (wpResolver == null) + { return base.AddToChain(resolver, property); + } var match = _wpOperationRegex.Match(property); if (!match.Success) + { return base.AddToChain(resolver, property); + } var argument = match.Groups["name"].Value; var stepResolver = new StepResolver(argument); return resolver.Append(stepResolver); } - private class WorkplanResolver : BindingResolverBase + private sealed class WorkplanResolver : BindingResolverBase { protected override object Resolve(object source) { @@ -68,7 +74,7 @@ protected override bool Update(object source, object value) } } - private class StepResolver : BindingResolverBase + private sealed class StepResolver : BindingResolverBase { private readonly string _stepName; diff --git a/src/Moryx.AbstractionLayer/Recipes/RecipeClassification.cs b/src/Moryx.AbstractionLayer/Recipes/RecipeClassification.cs index 7c8048ab3c..87287ada9f 100644 --- a/src/Moryx.AbstractionLayer/Recipes/RecipeClassification.cs +++ b/src/Moryx.AbstractionLayer/Recipes/RecipeClassification.cs @@ -45,4 +45,4 @@ public enum RecipeClassification /// Recipe is a clone of any of the previous types /// Clone = int.MinValue -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/RecipeState.cs b/src/Moryx.AbstractionLayer/Recipes/RecipeState.cs index 03c93d2a96..9916b05997 100644 --- a/src/Moryx.AbstractionLayer/Recipes/RecipeState.cs +++ b/src/Moryx.AbstractionLayer/Recipes/RecipeState.cs @@ -22,4 +22,4 @@ public enum RecipeState /// The recipe is revoked and must not be for regular jobs anymore. /// Revoked = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Recipes/WorkplanRecipe.cs b/src/Moryx.AbstractionLayer/Recipes/WorkplanRecipe.cs index 303172c5a3..f7aead2bdc 100644 --- a/src/Moryx.AbstractionLayer/Recipes/WorkplanRecipe.cs +++ b/src/Moryx.AbstractionLayer/Recipes/WorkplanRecipe.cs @@ -39,4 +39,4 @@ public override IRecipe Clone() { return new WorkplanRecipe(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/AvailableCapabilitiesAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/AvailableCapabilitiesAttribute.cs index efe52c9bea..ec0d1cd67e 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/AvailableCapabilitiesAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/AvailableCapabilitiesAttribute.cs @@ -66,19 +66,21 @@ private static object Instantiate(Type type) { // Value Types can be instantiated like this if (type.IsValueType) + { return Activator.CreateInstance(type); + } // Check if there is a default constructor for that type var defaultCtor = type.GetConstructor(Type.EmptyTypes); if (defaultCtor != null) + { return Activator.CreateInstance(type); + } // If nothing helps: get a parameter constructor and instanciate default values for the parameters. var constructorInfo = type.GetConstructors().First(); - - object[] ctorArgs = null; var parameters = constructorInfo.GetParameters(); - ctorArgs = new object[parameters.Length]; + var ctorArgs = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { var parameterInfo = parameters[i]; @@ -94,4 +96,4 @@ private IDictionary GetCapabilities() return ReflectionTool.GetPublicClasses(type => _capabilitiesFilter(type)) .ToDictionary(t => t.FullName, t => t); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ReferenceOverrideAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ReferenceOverrideAttribute.cs index 5707d4d4f1..65ef43a7b2 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ReferenceOverrideAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ReferenceOverrideAttribute.cs @@ -28,4 +28,4 @@ public ReferenceOverrideAttribute(string source) { Source = source; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceAvailableAsAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceAvailableAsAttribute.cs index f6972ebf32..8c239c7da9 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceAvailableAsAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceAvailableAsAttribute.cs @@ -21,4 +21,4 @@ public ResourceAvailableAsAttribute(params Type[] interfaces) { AvailableAs = interfaces; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceConstructorAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceConstructorAttribute.cs index 7c4288d09a..a1c33f4a34 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceConstructorAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceConstructorAttribute.cs @@ -13,4 +13,4 @@ public class ResourceConstructorAttribute : Attribute /// Flag if this method represents the default constructor /// public bool IsDefault { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceReferenceAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceReferenceAttribute.cs index 82b36e5b21..9bb8de910a 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceReferenceAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceReferenceAttribute.cs @@ -81,4 +81,4 @@ public ResourceReferenceAttribute(ResourceRelationType relationType, ResourceRef Name = name; RelationType = relationType; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceRegistrationAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceRegistrationAttribute.cs index 6d40adef73..ef3c33c6d7 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceRegistrationAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceRegistrationAttribute.cs @@ -40,4 +40,4 @@ public ResourceRegistrationAttribute(Type customRegistration, params Type[] cust : base(LifeCycle.Singleton, customRegistrations.Union([typeof(IResource), customRegistration]).ToArray()) { } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs index 59ea7b7255..744828d19c 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceSynchronizationAttribute.cs @@ -1,8 +1,6 @@ -// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; - namespace Moryx.AbstractionLayer.Resources.Attributes; /// @@ -10,7 +8,7 @@ namespace Moryx.AbstractionLayer.Resources.Attributes; /// across multiple application instances. /// [AttributeUsage(AttributeTargets.Class, Inherited = false)] -public class ResourceSynchronizationAttribute(string SynchronizationTypeId): Attribute +public class ResourceSynchronizationAttribute(string SynchronizationTypeId) : Attribute { /// /// Defines the property serialization strategy for this resource. @@ -38,4 +36,4 @@ public enum SynchronizationMode /// serialized and synchronized. /// Selective -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceTypesAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceTypesAttribute.cs index f5dc5bb0a9..6f95a98b6a 100644 --- a/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceTypesAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Attributes/ResourceTypesAttribute.cs @@ -53,9 +53,12 @@ private static IEnumerable SelectTypeNames(IEnumerable @@ -12,5 +10,5 @@ namespace Moryx.AbstractionLayer.Resources.Attributes; [AttributeUsage(AttributeTargets.Property)] public class SynchronizableMemberAttribute : Attribute { - + } diff --git a/src/Moryx.AbstractionLayer/Resources/Extensions/ResourceInitializerExtensions.cs b/src/Moryx.AbstractionLayer/Resources/Extensions/ResourceInitializerExtensions.cs index 4d684d3add..2fb0495965 100644 --- a/src/Moryx.AbstractionLayer/Resources/Extensions/ResourceInitializerExtensions.cs +++ b/src/Moryx.AbstractionLayer/Resources/Extensions/ResourceInitializerExtensions.cs @@ -71,4 +71,4 @@ public static TResource Instantiate(this IResourceGraph graph, string r.Description = description; }); } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IReferences.cs b/src/Moryx.AbstractionLayer/Resources/IReferences.cs index 0e8cad88e0..f5b7f51b2e 100644 --- a/src/Moryx.AbstractionLayer/Resources/IReferences.cs +++ b/src/Moryx.AbstractionLayer/Resources/IReferences.cs @@ -9,4 +9,4 @@ namespace Moryx.AbstractionLayer.Resources; public interface IReferences : ICollection, IReferenceCollection where TResource : IResource { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IResource.cs b/src/Moryx.AbstractionLayer/Resources/IResource.cs index ff3d18d2db..aa4d4ea10c 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResource.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResource.cs @@ -29,4 +29,4 @@ public interface IResource /// Raised when the capabilities have changed. /// event EventHandler CapabilitiesChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IResourceGraph.cs b/src/Moryx.AbstractionLayer/Resources/IResourceGraph.cs index 64f7f62d2e..e1fd58d613 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResourceGraph.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResourceGraph.cs @@ -81,4 +81,4 @@ TResource Instantiate(string type) /// Remove a resource permanently and irreversible /// Task DestroyAsync(IResource resource, bool permanent, CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IResourceManagement.cs b/src/Moryx.AbstractionLayer/Resources/IResourceManagement.cs index 9f7d9b5bee..e297c8ef58 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResourceManagement.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResourceManagement.cs @@ -163,4 +163,4 @@ IEnumerable GetResourcesUnsafe(Func predi /// Raised when the capabilities have changed. /// event EventHandler CapabilitiesChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IResourceTypeNode.cs b/src/Moryx.AbstractionLayer/Resources/IResourceTypeNode.cs index b6fa855fdd..b13a5951f9 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResourceTypeNode.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResourceTypeNode.cs @@ -46,4 +46,4 @@ public interface IResourceTypeNode Dictionary> ReferenceOverrides { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/IResourceTypeTree.cs b/src/Moryx.AbstractionLayer/Resources/IResourceTypeTree.cs index da962a87f2..7e5cea51b7 100644 --- a/src/Moryx.AbstractionLayer/Resources/IResourceTypeTree.cs +++ b/src/Moryx.AbstractionLayer/Resources/IResourceTypeTree.cs @@ -27,4 +27,4 @@ public interface IResourceTypeTree /// Find all resource type trees that implement the given type constraints /// IEnumerable SupportedTypes(ICollection constraints); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Initializer/IResourceInitializer.cs b/src/Moryx.AbstractionLayer/Resources/Initializer/IResourceInitializer.cs index d1c52b5c28..49cc88c709 100644 --- a/src/Moryx.AbstractionLayer/Resources/Initializer/IResourceInitializer.cs +++ b/src/Moryx.AbstractionLayer/Resources/Initializer/IResourceInitializer.cs @@ -26,4 +26,4 @@ public interface IResourceInitializer : IAsyncConfiguredPlugin Task ExecuteAsync(IResourceGraph graph, object parameters, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerAttribute.cs b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerAttribute.cs index 2481790d22..6c64644efe 100644 --- a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerAttribute.cs +++ b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerAttribute.cs @@ -20,4 +20,4 @@ public ResourceInitializerAttribute(string name) { Name = name; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerBase.cs b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerBase.cs index 40496f2faf..524d51ef01 100644 --- a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerBase.cs +++ b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerBase.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.Logging; -using Moryx.Modules; namespace Moryx.AbstractionLayer.Resources; diff --git a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerConfig.cs b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerConfig.cs index d831d75c37..e31b0977b2 100644 --- a/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerConfig.cs +++ b/src/Moryx.AbstractionLayer/Resources/Initializer/ResourceInitializerConfig.cs @@ -28,4 +28,4 @@ public override string ToString() { return PluginName; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/ProxyDetachedException.cs b/src/Moryx.AbstractionLayer/Resources/ProxyDetachedException.cs index 613e23567b..e8300cf8a3 100644 --- a/src/Moryx.AbstractionLayer/Resources/ProxyDetachedException.cs +++ b/src/Moryx.AbstractionLayer/Resources/ProxyDetachedException.cs @@ -17,4 +17,4 @@ public class ProxyDetachedException : Exception public ProxyDetachedException() : base(Strings.ProxyDetachedException_Message) { } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/Resource.cs b/src/Moryx.AbstractionLayer/Resources/Resource.cs index fcdc6c61a2..f23299451c 100644 --- a/src/Moryx.AbstractionLayer/Resources/Resource.cs +++ b/src/Moryx.AbstractionLayer/Resources/Resource.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Capabilities; +using Moryx.AbstractionLayer.Properties; using Moryx.Logging; using Moryx.Modules; using Moryx.Serialization; -using System.ComponentModel.DataAnnotations; -using Moryx.AbstractionLayer.Properties; namespace Moryx.AbstractionLayer.Resources; diff --git a/src/Moryx.AbstractionLayer/Resources/ResourceBindingResolverFactory.cs b/src/Moryx.AbstractionLayer/Resources/ResourceBindingResolverFactory.cs index 3a80718cb3..656d67f472 100644 --- a/src/Moryx.AbstractionLayer/Resources/ResourceBindingResolverFactory.cs +++ b/src/Moryx.AbstractionLayer/Resources/ResourceBindingResolverFactory.cs @@ -21,4 +21,4 @@ protected override IBindingResolverChain CreateBaseResolver(string baseKey) return null; } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/ResourceFacadeExtensions.cs b/src/Moryx.AbstractionLayer/Resources/ResourceFacadeExtensions.cs index 0bc4dc421b..4bc0264106 100644 --- a/src/Moryx.AbstractionLayer/Resources/ResourceFacadeExtensions.cs +++ b/src/Moryx.AbstractionLayer/Resources/ResourceFacadeExtensions.cs @@ -102,4 +102,4 @@ public Task CreateUnsafeAsync(Func initializer return facade.CreateUnsafeAsync(typeof(TResource), r => initializer((TResource)r), cancellationToken); } } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/ResourceNotFoundException.cs b/src/Moryx.AbstractionLayer/Resources/ResourceNotFoundException.cs index b6feed06ee..f7d297f392 100644 --- a/src/Moryx.AbstractionLayer/Resources/ResourceNotFoundException.cs +++ b/src/Moryx.AbstractionLayer/Resources/ResourceNotFoundException.cs @@ -35,4 +35,4 @@ public ResourceNotFoundException(long id) : base(string.Format(Strings.ResourceNotFoundException_ById_Message, id)) { } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/ResourceReferenceRole.cs b/src/Moryx.AbstractionLayer/Resources/ResourceReferenceRole.cs index 837bf4a99b..6e1658e96b 100644 --- a/src/Moryx.AbstractionLayer/Resources/ResourceReferenceRole.cs +++ b/src/Moryx.AbstractionLayer/Resources/ResourceReferenceRole.cs @@ -17,4 +17,4 @@ public enum ResourceReferenceRole /// The referenced resource is the source entity in the relation /// Source = 1 -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Resources/ResourceRelationType.cs b/src/Moryx.AbstractionLayer/Resources/ResourceRelationType.cs index adf5060661..bd9b670df6 100644 --- a/src/Moryx.AbstractionLayer/Resources/ResourceRelationType.cs +++ b/src/Moryx.AbstractionLayer/Resources/ResourceRelationType.cs @@ -80,4 +80,4 @@ public enum ResourceRelationType /// Undefined custom relation that uses the RelationName field /// Custom = (int.MaxValue & ~3) // FF FF FF FC -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Workplans/ITask.cs b/src/Moryx.AbstractionLayer/Workplans/ITask.cs index 6463a7711f..b0b631796c 100644 --- a/src/Moryx.AbstractionLayer/Workplans/ITask.cs +++ b/src/Moryx.AbstractionLayer/Workplans/ITask.cs @@ -45,4 +45,4 @@ public interface ITask /// Complete task /// void Completed(ActivityResult result); -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Workplans/ITaskStep.cs b/src/Moryx.AbstractionLayer/Workplans/ITaskStep.cs index e926ae8630..e851b13e3f 100644 --- a/src/Moryx.AbstractionLayer/Workplans/ITaskStep.cs +++ b/src/Moryx.AbstractionLayer/Workplans/ITaskStep.cs @@ -16,4 +16,4 @@ public interface ITaskStep : IWorkplanStep /// Parameters of this step. This only offers a getter to use covariance and update the object instead of replacing it /// TParam Parameters { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Workplans/TaskStep.cs b/src/Moryx.AbstractionLayer/Workplans/TaskStep.cs index 472df5006c..9b590079e3 100644 --- a/src/Moryx.AbstractionLayer/Workplans/TaskStep.cs +++ b/src/Moryx.AbstractionLayer/Workplans/TaskStep.cs @@ -55,14 +55,14 @@ protected TaskStep() private static OutputDescription[] DescriptionsFromEnum(Type enumType) { return (from value in Enum.GetValues(enumType).OfType() - let name = GetEnumName(value, enumType) - let numeric = (int)value - select new OutputDescription - { - Name = name, - OutputType = OutputTypeFromEnum(enumType, value, numeric), - MappingValue = numeric - }).ToArray(); + let name = GetEnumName(value, enumType) + let numeric = (int)value + select new OutputDescription + { + Name = name, + OutputType = OutputTypeFromEnum(enumType, value, numeric), + MappingValue = numeric + }).ToArray(); } /// @@ -110,7 +110,9 @@ private static OutputType OutputTypeFromEnum(Type enumType, object value, int nu protected override TransitionBase Instantiate(IWorkplanContext context) { if (context.IsDisabled(this)) + { return new NullTransition(); + } // Create transition var indexResolver = _indexResolver ?? (_indexResolver = TransitionBase.CreateIndexResolver(OutputDescriptions)); @@ -131,4 +133,4 @@ public abstract class TaskStep : TaskStep, new() where TParam : IParameters, new() { -} \ No newline at end of file +} diff --git a/src/Moryx.AbstractionLayer/Workplans/TaskTransition.cs b/src/Moryx.AbstractionLayer/Workplans/TaskTransition.cs index 31eee40e0b..857f9d61c9 100644 --- a/src/Moryx.AbstractionLayer/Workplans/TaskTransition.cs +++ b/src/Moryx.AbstractionLayer/Workplans/TaskTransition.cs @@ -49,7 +49,9 @@ protected override void InputTokenAdded(object sender, IToken token) // Raise the triggered event if engine is still running if (!_paused) + { Triggered(this, EventArgs.Empty); + } } /// @@ -66,7 +68,10 @@ public override void Resume() { // Only trigger if we did not return from a pause if (!_paused) + { Triggered(this, EventArgs.Empty); + } + _paused = false; } diff --git a/src/Moryx.AbstractionLayer/Workplans/WorkplanExtensions.cs b/src/Moryx.AbstractionLayer/Workplans/WorkplanExtensions.cs index 5a3666a9ca..c809de37d6 100644 --- a/src/Moryx.AbstractionLayer/Workplans/WorkplanExtensions.cs +++ b/src/Moryx.AbstractionLayer/Workplans/WorkplanExtensions.cs @@ -37,7 +37,9 @@ public TaskStep AddStep(TaskStep AddStep diff --git a/src/Moryx.AspNetCore/MoryxExceptionFilter.cs b/src/Moryx.AspNetCore/MoryxExceptionFilter.cs index bdc6782438..c8e68aada5 100644 --- a/src/Moryx.AspNetCore/MoryxExceptionFilter.cs +++ b/src/Moryx.AspNetCore/MoryxExceptionFilter.cs @@ -19,4 +19,4 @@ public void OnException(ExceptionContext context) Exception = context.Exception.ToString() + headers }); } -} \ No newline at end of file +} diff --git a/src/Moryx.AspNetCore/MoryxExceptionResponse.cs b/src/Moryx.AspNetCore/MoryxExceptionResponse.cs index 1d1ab73a3a..2d1d8d9315 100644 --- a/src/Moryx.AspNetCore/MoryxExceptionResponse.cs +++ b/src/Moryx.AspNetCore/MoryxExceptionResponse.cs @@ -8,4 +8,4 @@ public class MoryxExceptionResponse public string Title { get; set; } public string Exception { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkActivity.cs b/src/Moryx.Benchmarking/BenchmarkActivity.cs index 9c147bee0b..89eb983313 100644 --- a/src/Moryx.Benchmarking/BenchmarkActivity.cs +++ b/src/Moryx.Benchmarking/BenchmarkActivity.cs @@ -58,4 +58,4 @@ protected override ActivityResult CreateFailureResult() { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkCapabilities.cs b/src/Moryx.Benchmarking/BenchmarkCapabilities.cs index 297f549dbe..1ef855b7d5 100644 --- a/src/Moryx.Benchmarking/BenchmarkCapabilities.cs +++ b/src/Moryx.Benchmarking/BenchmarkCapabilities.cs @@ -34,4 +34,4 @@ protected override bool ProvidedBy(ICapabilities provided) var benchmark = provided as BenchmarkCapabilities; return benchmark != null && benchmark.Step == Step; } -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkInstance.cs b/src/Moryx.Benchmarking/BenchmarkInstance.cs index 6ffe71b637..76c0f94763 100644 --- a/src/Moryx.Benchmarking/BenchmarkInstance.cs +++ b/src/Moryx.Benchmarking/BenchmarkInstance.cs @@ -7,4 +7,4 @@ namespace Moryx.Benchmarking; public class BenchmarkInstance : ProductInstance { -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkProduct.cs b/src/Moryx.Benchmarking/BenchmarkProduct.cs index 018e58d5dd..6709346c41 100644 --- a/src/Moryx.Benchmarking/BenchmarkProduct.cs +++ b/src/Moryx.Benchmarking/BenchmarkProduct.cs @@ -17,4 +17,4 @@ protected override ProductInstance Instantiate() { return new BenchmarkInstance(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkResult.cs b/src/Moryx.Benchmarking/BenchmarkResult.cs index 924cf54b5b..8ee351dfb7 100644 --- a/src/Moryx.Benchmarking/BenchmarkResult.cs +++ b/src/Moryx.Benchmarking/BenchmarkResult.cs @@ -8,4 +8,4 @@ public enum BenchmarkResult Success = 0, Rework = 1, Failed = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkStep.cs b/src/Moryx.Benchmarking/BenchmarkStep.cs index ab81124573..1e8558f20a 100644 --- a/src/Moryx.Benchmarking/BenchmarkStep.cs +++ b/src/Moryx.Benchmarking/BenchmarkStep.cs @@ -7,4 +7,4 @@ namespace Moryx.Benchmarking; public class BenchmarkStep : TaskStep { -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkTracing.cs b/src/Moryx.Benchmarking/BenchmarkTracing.cs index 122510bd19..9543c16b62 100644 --- a/src/Moryx.Benchmarking/BenchmarkTracing.cs +++ b/src/Moryx.Benchmarking/BenchmarkTracing.cs @@ -13,4 +13,4 @@ public class BenchmarkTracing : Tracing [DataMember] [DisplayName("Runtime"), Description("Processing time of the activity")] public long RuntimeMs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Benchmarking/BenchmarkTrigger.cs b/src/Moryx.Benchmarking/BenchmarkTrigger.cs index 3a7db43810..10a4668022 100644 --- a/src/Moryx.Benchmarking/BenchmarkTrigger.cs +++ b/src/Moryx.Benchmarking/BenchmarkTrigger.cs @@ -38,4 +38,4 @@ public override IReadOnlyList CreateSteps(IProductRecipe recipe) } ]; } -} \ No newline at end of file +} diff --git a/src/Moryx.CommandCenter.Web/Pages/CommandCenter.cshtml.cs b/src/Moryx.CommandCenter.Web/Pages/CommandCenter.cshtml.cs index bdaeb6d849..0cf8c5becc 100644 --- a/src/Moryx.CommandCenter.Web/Pages/CommandCenter.cshtml.cs +++ b/src/Moryx.CommandCenter.Web/Pages/CommandCenter.cshtml.cs @@ -11,4 +11,4 @@ public void OnGet() { } -} \ No newline at end of file +} diff --git a/src/Moryx.Communication.Serial/DataBitTypes.cs b/src/Moryx.Communication.Serial/DataBitTypes.cs index 00afd22bef..02c7612401 100644 --- a/src/Moryx.Communication.Serial/DataBitTypes.cs +++ b/src/Moryx.Communication.Serial/DataBitTypes.cs @@ -17,4 +17,4 @@ public enum DataBitTypes /// 8 bits at a time /// Eight = 8 -} \ No newline at end of file +} diff --git a/src/Moryx.Communication.Serial/SerialBinaryConfig.cs b/src/Moryx.Communication.Serial/SerialBinaryConfig.cs index f65c936197..523ec808e5 100644 --- a/src/Moryx.Communication.Serial/SerialBinaryConfig.cs +++ b/src/Moryx.Communication.Serial/SerialBinaryConfig.cs @@ -83,4 +83,4 @@ public class SerialBinaryConfig : BinaryConnectionConfig [DataMember] [DefaultValue(100)] public int WriteBufferSize { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Communication.Serial/SerialBinaryConnection.cs b/src/Moryx.Communication.Serial/SerialBinaryConnection.cs index ad8f886541..535f854690 100644 --- a/src/Moryx.Communication.Serial/SerialBinaryConnection.cs +++ b/src/Moryx.Communication.Serial/SerialBinaryConnection.cs @@ -82,7 +82,9 @@ public void Start() public void Stop() { if (_serialPort == null) + { return; + } _serialPort.DataReceived -= OnDataReceived; _serialPort.Dispose(); @@ -121,7 +123,7 @@ public async Task SendAsync(BinaryMessage message, CancellationToken cancellatio { // Create bytes from message var bytes = _validator.Interpreter.SerializeMessage(message); - await _serialPort.BaseStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken); + await _serialPort.BaseStream.WriteAsync(bytes, cancellationToken); await _serialPort.BaseStream.FlushAsync(cancellationToken); } @@ -145,4 +147,4 @@ private void PublishCompleteMessage(BinaryMessage binaryMessage) /// public event EventHandler NotifyConnectionState; -} \ No newline at end of file +} diff --git a/src/Moryx.Communication.Serial/SerialPortFactory.cs b/src/Moryx.Communication.Serial/SerialPortFactory.cs index 272d25cd1c..1dcf22425c 100644 --- a/src/Moryx.Communication.Serial/SerialPortFactory.cs +++ b/src/Moryx.Communication.Serial/SerialPortFactory.cs @@ -51,4 +51,4 @@ internal static SerialPort FromConfig(SerialBinaryConfig config, IModuleLogger l throw; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Container/CastleContainer.cs b/src/Moryx.Container/CastleContainer.cs index 4eaa00e63d..7e6dadddb4 100644 --- a/src/Moryx.Container/CastleContainer.cs +++ b/src/Moryx.Container/CastleContainer.cs @@ -70,15 +70,21 @@ public CastleContainer(IDictionary strategies, IServiceProvider se public object Resolve(Type service, string name) { if (name == null && _strategies.TryGetValue(service, out var strategy)) + { name = strategy; + } // Resolve by name if given or determined if (name != null && _container.Kernel.HasComponent(name)) + { return _container.Resolve(name, service); + } // Resolve by type if found if (_container.Kernel.HasComponent(service)) + { return _container.Resolve(service); + } // Otherwise return null return null; @@ -111,7 +117,9 @@ public void Register(Type type, Type[] services, string name, LifeCycle lifeCycl // Make sure component is not registered yet var componentName = name ?? type.FullName; if (_container.Kernel.HasComponent(componentName)) + { return; + } var registration = Component.For(services).ImplementedBy(type); @@ -170,7 +178,9 @@ public void RegisterInstance(Type[] services, object instance, string name) var registration = Component.For(services).Instance(instance); if (!string.IsNullOrEmpty(name)) + { registration.Named(name); + } _container.Register(registration); } diff --git a/src/Moryx.Container/ChildContainerSubResolver.cs b/src/Moryx.Container/ChildContainerSubResolver.cs index e3fb44f56e..2152ef3461 100644 --- a/src/Moryx.Container/ChildContainerSubResolver.cs +++ b/src/Moryx.Container/ChildContainerSubResolver.cs @@ -8,7 +8,7 @@ namespace Moryx.Container; -internal class ChildContainerSubResolver : ISubDependencyResolver +internal sealed class ChildContainerSubResolver : ISubDependencyResolver { private readonly IKernel _kernel; @@ -60,4 +60,4 @@ private static UseChildAttribute GetAttribute(Type targetType, DependencyModel d } return att; } -} \ No newline at end of file +} diff --git a/src/Moryx.Container/ComponentSelectors/ConfigBasedComponentSelector.cs b/src/Moryx.Container/ComponentSelectors/ConfigBasedComponentSelector.cs index 998bc16cf8..6190c55be0 100644 --- a/src/Moryx.Container/ComponentSelectors/ConfigBasedComponentSelector.cs +++ b/src/Moryx.Container/ComponentSelectors/ConfigBasedComponentSelector.cs @@ -13,7 +13,7 @@ namespace Moryx.Container; /// Selector that uses the given config object to determine component name and execute initialize. /// The Create method must have the first parameter "config" of type T. /// -internal class ConfigBasedComponentSelector : DefaultTypedFactoryComponentSelector, IConfigBasedComponentSelector +internal sealed class ConfigBasedComponentSelector : DefaultTypedFactoryComponentSelector, IConfigBasedComponentSelector { private const string ConfigParameterName = "config"; private const string CancellationTokenParameterName = "cancellationToken"; @@ -64,7 +64,9 @@ protected override Func BuildFactoryCom { ExecuteInitialize(targetComponentType, configType, instance, config, kernel); if (!isAsync) + { return instance; + } // Warn if mixing sync initialize with async factory kernel.Logger.WarnFormat(CultureInfo.InvariantCulture, @@ -180,7 +182,7 @@ private static object ToTypedTask(Type targetComponentType, Task origina return typedTask; } - private class TaskHelperClass + private sealed class TaskHelperClass { public static Task CastTaskResult(Task task) { diff --git a/src/Moryx.Container/ComponentSelectors/NameBasedComponentSelector.cs b/src/Moryx.Container/ComponentSelectors/NameBasedComponentSelector.cs index 457d2898ad..3c0e46f2b7 100644 --- a/src/Moryx.Container/ComponentSelectors/NameBasedComponentSelector.cs +++ b/src/Moryx.Container/ComponentSelectors/NameBasedComponentSelector.cs @@ -9,7 +9,7 @@ namespace Moryx.Container; /// /// Component selector for name based selection /// -internal class NameBasedComponentSelector : DefaultTypedFactoryComponentSelector, INameBasedComponentSelector +internal sealed class NameBasedComponentSelector : DefaultTypedFactoryComponentSelector, INameBasedComponentSelector { /// /// Selecting the right component name based on first argument @@ -23,4 +23,4 @@ protected override string GetComponentName(MethodInfo method, object[] arguments ArgumentException.ThrowIfNullOrEmpty(name); return name; } -} \ No newline at end of file +} diff --git a/src/Moryx.Container/MoryxFacility.cs b/src/Moryx.Container/MoryxFacility.cs index c2fe3e79f9..5e9ba4d970 100644 --- a/src/Moryx.Container/MoryxFacility.cs +++ b/src/Moryx.Container/MoryxFacility.cs @@ -8,7 +8,7 @@ namespace Moryx.Container; -internal class MoryxFacility : IFacility +internal sealed class MoryxFacility : IFacility { private IDictionary _strategies; private IServiceProvider _serviceProvider; @@ -41,10 +41,12 @@ public void Init(IKernel kernel, IConfiguration facilityConfig) // Bridge to ServiceProvider - added last so Windsor-registered components take precedence if (_serviceProvider != null) + { kernel.Resolver.AddSubResolver(new ServiceProviderSubResolver((IKernelInternal)kernel, _serviceProvider, _serviceProviderTypeFilter)); + } } public void Terminate() { } -} \ No newline at end of file +} diff --git a/src/Moryx.Container/NamedDependencyResolver.cs b/src/Moryx.Container/NamedDependencyResolver.cs index bbff5ae6df..f60bd5296b 100644 --- a/src/Moryx.Container/NamedDependencyResolver.cs +++ b/src/Moryx.Container/NamedDependencyResolver.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Reflection; using Castle.Core; -using Castle.MicroKernel.Context; using Castle.MicroKernel; -using System.Reflection; +using Castle.MicroKernel.Context; namespace Moryx.Container; -internal class NamedDependencyResolver : ISubDependencyResolver +internal sealed class NamedDependencyResolver : ISubDependencyResolver { private readonly IKernel _kernel; @@ -46,4 +46,4 @@ private static NamedAttribute GetAttribute(Type targetType, DependencyModel depe } return att; } -} \ No newline at end of file +} diff --git a/src/Moryx.Container/ServiceProviderSubResolver.cs b/src/Moryx.Container/ServiceProviderSubResolver.cs index 8ecc4610ef..5fedecfdb2 100644 --- a/src/Moryx.Container/ServiceProviderSubResolver.cs +++ b/src/Moryx.Container/ServiceProviderSubResolver.cs @@ -12,7 +12,7 @@ namespace Moryx.Container; /// Castle Windsor sub-resolver that delegates to an /// for types not registered in Windsor. This bridges the ServiceProvider into module containers. /// -internal class ServiceProviderSubResolver(IKernelInternal kernel, IServiceProvider serviceProvider, Predicate typeFilter = null) : ISubDependencyResolver +internal sealed class ServiceProviderSubResolver(IKernelInternal kernel, IServiceProvider serviceProvider, Predicate typeFilter = null) : ISubDependencyResolver { public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dep) { diff --git a/src/Moryx.Container/StrategySubResolver.cs b/src/Moryx.Container/StrategySubResolver.cs index a89d3709c4..225f569c36 100644 --- a/src/Moryx.Container/StrategySubResolver.cs +++ b/src/Moryx.Container/StrategySubResolver.cs @@ -2,12 +2,12 @@ // Licensed under the Apache License, Version 2.0 using Castle.Core; -using Castle.MicroKernel.Context; using Castle.MicroKernel; +using Castle.MicroKernel.Context; namespace Moryx.Container; -internal class StrategySubResolver : ISubDependencyResolver +internal sealed class StrategySubResolver : ISubDependencyResolver { private readonly IKernel _kernel; private readonly IDictionary _strategies; @@ -28,4 +28,4 @@ public object Resolve(CreationContext context, ISubDependencyResolver contextHan // The dependency is a registered strategy, resolve by strategy name instead return _kernel.Resolve(_strategies[dependency.TargetType], dependency.TargetType); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/JobManagementController.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/JobManagementController.cs index a160cd39f8..e784b65662 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/JobManagementController.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/JobManagementController.cs @@ -3,12 +3,12 @@ using System.Text.Json; using System.Text.Json.Serialization; +using System.Threading.Channels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Moryx.ControlSystem.Jobs.Endpoints.Properties; -using System.Threading.Channels; using Moryx.AspNetCore; +using Moryx.ControlSystem.Jobs.Endpoints.Properties; namespace Moryx.ControlSystem.Jobs.Endpoints; @@ -40,7 +40,9 @@ public ActionResult GetJob(long jobId) { var job = _jobManagement.Get(jobId); if (job == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.JobManagementController_JobNotFound }); + } return Converter.ToModel(job); } @@ -59,7 +61,9 @@ public ActionResult Complete(long jobId) { var job = _jobManagement.Get(jobId); if (job == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.JobManagementController_JobNotFound }); + } _jobManagement.Complete(job); return Ok(); @@ -72,7 +76,9 @@ public ActionResult Abort(long jobId) { var job = _jobManagement.Get(jobId); if (job == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.JobManagementController_JobNotFound }); + } _jobManagement.Abort(job); return Ok(); diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/JobPermissions.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/JobPermissions.cs index dba6151349..53a372891f 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/JobPermissions.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/JobPermissions.cs @@ -9,4 +9,4 @@ public static class JobPermissions public const string CanView = _prefix + "CanView"; public const string CanComplete = _prefix + "CanComplete"; public const string CanAbort = _prefix + "CanAbort"; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/Converter.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/Converter.cs index 551a4489fc..cc66bedf71 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/Converter.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/Converter.cs @@ -85,10 +85,14 @@ private static StepState ConvertActivityState(Job job, long stepId) private static StepState GetStepState(Tracing tracing) { if (tracing.Completed is not null) + { return StepState.Completed; + } if (tracing.Started is not null) + { return StepState.Running; + } return StepState.Initial; } diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/JobModel.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/JobModel.cs index cacc4dd8a0..6229a39f9e 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/JobModel.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/JobModel.cs @@ -40,4 +40,4 @@ public class JobModel [DataMember] public SetupJobModel SetupJob { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/ProductionJobModel.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/ProductionJobModel.cs index f9122396db..78d52384a9 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/ProductionJobModel.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/ProductionJobModel.cs @@ -25,4 +25,4 @@ public class ProductionJobModel [DataMember] public int ReworkedCount { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/SetupJobModel.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/SetupJobModel.cs index d1c59beca0..0602377dfb 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/SetupJobModel.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/SetupJobModel.cs @@ -41,4 +41,4 @@ public enum SetupJobClassification Prepare, Cleanup, Manual, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/StateChangeModel.cs b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/StateChangeModel.cs index 318c3e62a3..e66c8f2585 100644 --- a/src/Moryx.ControlSystem.Jobs.Endpoints/Models/StateChangeModel.cs +++ b/src/Moryx.ControlSystem.Jobs.Endpoints/Models/StateChangeModel.cs @@ -17,4 +17,4 @@ public class StateChangeModel [DataMember] public JobClassification CurrentState { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.MaterialManager/Components/IMaterialManager.cs b/src/Moryx.ControlSystem.MaterialManager/Components/IMaterialManager.cs index 7e312dd4a7..911bd6baef 100644 --- a/src/Moryx.ControlSystem.MaterialManager/Components/IMaterialManager.cs +++ b/src/Moryx.ControlSystem.MaterialManager/Components/IMaterialManager.cs @@ -7,4 +7,4 @@ namespace Moryx.ControlSystem.MaterialManager; internal interface IMaterialManager : IAsyncPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.MaterialManager/Implementation/MaterialManager.cs b/src/Moryx.ControlSystem.MaterialManager/Implementation/MaterialManager.cs index 7c1856ba27..b4c8ae2cb8 100644 --- a/src/Moryx.ControlSystem.MaterialManager/Implementation/MaterialManager.cs +++ b/src/Moryx.ControlSystem.MaterialManager/Implementation/MaterialManager.cs @@ -11,7 +11,7 @@ namespace Moryx.ControlSystem.MaterialManager; [Component(LifeCycle.Singleton, typeof(IMaterialManager))] -internal class MaterialManager : IMaterialManager +internal sealed class MaterialManager : IMaterialManager { /// /// Access material containers @@ -67,7 +67,9 @@ private async void OnMaterialChanged(object sender, EventArgs empty) private async Task SetProduct(IMaterialContainer container) { if (container.ProvidedMaterial == null) + { return; + } // Update reference with values from product management if (container.ProvidedMaterial is ProductReference && container.ProvidedMaterial.Identity is ProductIdentity prodIdent) @@ -76,4 +78,4 @@ private async Task SetProduct(IMaterialContainer container) container.SetMaterial(material); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConfig.cs b/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConfig.cs index 44230d4219..70757a7871 100644 --- a/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConfig.cs @@ -12,4 +12,4 @@ namespace Moryx.ControlSystem.MaterialManager; [DataContract] public class ModuleConfig : ConfigBase { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConsole.cs b/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConsole.cs index 49c6a5999e..3aca722834 100644 --- a/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ControlSystem.MaterialManager/ModuleController/ModuleConsole.cs @@ -6,9 +6,9 @@ namespace Moryx.ControlSystem.MaterialManager; [ServerModuleConsole] -internal class ModuleConsole : IServerModuleConsole +internal sealed class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Facades/JobManagementFacade.cs b/src/Moryx.ControlSystem.ProcessEngine/Facades/JobManagementFacade.cs index 7f94ef3593..8257c47903 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Facades/JobManagementFacade.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Facades/JobManagementFacade.cs @@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations; using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Recipes; -using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs.Setup; @@ -106,7 +105,9 @@ public JobEvaluation Evaluate(IProductRecipe recipe, int amount) { ValidateHealthState(); if (recipe is not ProductionRecipe prodRecipe) + { throw new ArgumentException($"Process engine only supports {nameof(ProductionRecipe)}.", nameof(recipe)); + } return new JobEvaluation { @@ -128,7 +129,9 @@ private void RaiseEvaluationsOutdated(ICapabilities obj) public async Task> AddAsync(JobCreationContext context, CancellationToken cancellationToken = default) { if (!JobManager.AcceptingExternalJobs) + { throw new HealthStateException(ServerModuleState.Stopping); + } context.Templates.ForEach(t => ValidateRecipe(t.Recipe)); @@ -170,7 +173,9 @@ private void ValidateRecipe(IProductRecipe recipe) ArgumentNullException.ThrowIfNull(recipe); if (recipe.Origin == null) + { throw new ArgumentException("Origin must not be null on recipe.", nameof(recipe)); + } var productionRecipe = recipe as ProductionRecipe ?? throw new NotSupportedException($"Process engine only supports '{nameof(ProductionRecipe)}'."); diff --git a/src/Moryx.ControlSystem.ProcessEngine/IdShiftGenerator.cs b/src/Moryx.ControlSystem.ProcessEngine/IdShiftGenerator.cs index 06e0a5d1f6..a9884748ff 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/IdShiftGenerator.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/IdShiftGenerator.cs @@ -46,4 +46,4 @@ public static long ExtractChild(long combinedKey) mask >>= (32 - ShiftSpace); return combinedKey & mask; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/BrokenJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/BrokenJobData.cs index b7487020dd..a9ac986b98 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/BrokenJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/BrokenJobData.cs @@ -99,4 +99,4 @@ public void Load() { } public void UpdateSetup(SetupRecipe updatedRecipe) => throw new NotImplementedException(); #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDataList.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDataList.cs index f266ec85a0..248af72086 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDataList.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDataList.cs @@ -72,4 +72,4 @@ internal interface IJobDataList : IPlugin, IEnumerable /// Raised whenever a job progress was updated /// event EventHandler ProgressChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDispatcher.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDispatcher.cs index a81df2a63f..1b86c9dea3 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDispatcher.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobDispatcher.cs @@ -52,4 +52,4 @@ internal interface IJobDispatcher : IPlugin /// Aborts the given job /// void Abort(IJobData jobData); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHandler.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHandler.cs index 5f972643b3..75752dd877 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHandler.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHandler.cs @@ -13,4 +13,4 @@ internal interface IJobHandler /// /// Jobs to handle void Handle(LinkedList jobs); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHistory.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHistory.cs index 62aaccb418..ab1a667f37 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHistory.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobHistory.cs @@ -15,4 +15,4 @@ internal interface IJobHistory /// /// The requested job or null if there is no job with the given ID. Job Get(long jobId); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobManager.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobManager.cs index 90a3d0814e..b3a340ce6f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobManager.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/IJobManager.cs @@ -33,4 +33,4 @@ internal interface IJobManager : IPlugin /// Adds multiple jobs at once for the jobList queue /// Task> Add(JobCreationContext context); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/ModifiedJobsFragment.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/ModifiedJobsFragment.cs index 0d54ad34db..3411244fae 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/ModifiedJobsFragment.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Components/ModifiedJobsFragment.cs @@ -23,4 +23,4 @@ public ModifiedJobsFragment(IReadOnlyList affectedJobs, long? previous AffectedJobs = affectedJobs; PreviousId = previousId; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/EngineJob.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/EngineJob.cs index 7e76009f57..2a3376c958 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/EngineJob.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/EngineJob.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Diagnostics; -using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; using Moryx.Tools; @@ -38,4 +37,4 @@ public void UpdateStateDisplayName(JobStateBase jobState) } IReadOnlyList IPredictiveJob.PredictedFailures => PredictedFailures; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobData.cs index 88916b7f6d..b4d237e8c1 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobData.cs @@ -152,4 +152,4 @@ internal interface IJobData /// Event raised when the job state changed /// event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobDataFactory.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobDataFactory.cs index 958bc2fa5c..640d21ef82 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobDataFactory.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobDataFactory.cs @@ -43,10 +43,14 @@ public IJobData Create(IWorkplanRecipe recipe, int amount) IJobData jobData = null; if (recipe is ProductionRecipe) + { jobData = InternalFactory.CreateProductionJob(recipe, amount); + } if (recipe is SetupRecipe) + { jobData = InternalFactory.CreateSetupJob(recipe); + } ValidateCreatedJob(jobData, recipe); @@ -58,10 +62,14 @@ public IJobData Restore(JobEntity entity, IWorkplanRecipe recipe) IJobData jobData = null; if (recipe is ProductionRecipe) + { jobData = InternalFactory.CreateProductionJob(recipe, entity); + } if (recipe is SetupRecipe) + { jobData = InternalFactory.CreateSetupJob(recipe, entity); + } ValidateCreatedJob(jobData, recipe); @@ -71,7 +79,9 @@ public IJobData Restore(JobEntity entity, IWorkplanRecipe recipe) private static void ValidateCreatedJob(IJobData jobData, IWorkplanRecipe recipe) { if (jobData == null) + { throw new InvalidOperationException($"Cannot find job type for recipe of type: {recipe.GetType().FullName}."); + } } public void Destroy(IJobData jobData) => InternalFactory.Destroy(jobData); diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobState.cs index cf8c87743b..69c81c1cbf 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IJobState.cs @@ -19,4 +19,4 @@ internal interface IJobState /// Classification of the job /// JobClassification Classification { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IProductionJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IProductionJobData.cs index 0abdb063cb..1191ca56cd 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/IProductionJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/IProductionJobData.cs @@ -39,4 +39,4 @@ internal interface IProductionJobData : IJobData /// Summary of running, success and failed processes /// int ProcessCount { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ISetupJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ISetupJobData.cs index 8e1263a528..824a1f9d1b 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ISetupJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ISetupJobData.cs @@ -41,4 +41,4 @@ internal interface ISetupJobData : IJobData /// It must retry with a new recipe that should make the necessary changes. /// void UpdateSetup(SetupRecipe updatedRecipe); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/IJobStorage.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/IJobStorage.cs index b000c454dd..144acfcd14 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/IJobStorage.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/IJobStorage.cs @@ -25,4 +25,4 @@ internal interface IJobStorage : IPlugin /// Only update a jobs state in the database /// void UpdateState(IJobData jobData, IJobState jobState); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobDispatcher.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobDispatcher.cs index 2a5cda9196..18f6313984 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobDispatcher.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobDispatcher.cs @@ -46,7 +46,9 @@ public void Start() public void Stop() { foreach (var jobData in JobList.ToList()) + { jobData.Interrupt(); + } } /// @@ -106,4 +108,4 @@ public void Cleanup(IJobData jobData) => /// public void Interrupt(IJobData jobData) => ProcessController.Interrupt(jobData.RunningProcesses, false); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobList.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobList.cs index 3acc196b01..7e7ad7cebb 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobList.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobList.cs @@ -67,15 +67,19 @@ private void AwaitCleanJobList() stopWatch.Start(); var timeOut = Config.JobListStopTimeout * 1000; while (stopWatch.ElapsedMilliseconds < timeOut && _jobs.Any(j => !j.IsStable)) + { Thread.Sleep(1); + } if (_jobs.Any(j => !j.IsStable)) + { Logger.LogWarning("Reached shutdown-timout of the {name} after {seconds}s. Unfinished jobs: {jobs}", nameof(JobList), Config.JobListStopTimeout, string.Join(", ", _jobs.Select(j => j.Id))); + } } /// - public void Dispose() + public static void Dispose() { } @@ -188,7 +192,9 @@ public void Restore(IReadOnlyList restoredJobs, Action restoredJobs, Action jobDatas, JobPosition jobPosition, Action saveCallback) { if (jobDatas is null || jobDatas.Count == 0) + { return; + } // Enter write lock because we generate a new sort order _jobLock.EnterWriteLock(); @@ -293,7 +301,9 @@ private IReadOnlyList ExecuteAdd(LinkedList jobDatas, JobPos affectedJobs.Add(jobData); } if (node.Next != null) + { affectedJobs.Add(node.Next.Value); + } return null; } @@ -308,13 +318,17 @@ private IReadOnlyList ExecuteAdd(LinkedList jobDatas, JobPos && referenceNode.Previous?.Value is ISetupJobData setup && setup.Recipe.Execution == Setups.SetupExecution.BeforeProduction && setup.Recipe.TargetRecipe.Id == referenceNode.Value.Recipe.Id) + { referenceNode = referenceNode.Previous; + } if (referenceNode.Value.Recipe.Id != jobDatas.First().Recipe.Id && referenceNode.Previous?.Value is ISetupJobData cleanup && cleanup.Recipe.Execution == Setups.SetupExecution.AfterProduction && cleanup.Recipe.TargetRecipe.Id == jobDatas.Last().Recipe.Id) + { referenceNode = referenceNode.Previous; + } var previousId = referenceNode.Previous?.Value.Id; foreach (var jobData in jobDatas) @@ -336,7 +350,9 @@ private IReadOnlyList ExecuteAdd(LinkedList jobDatas, JobPos if (referenceNode.Value.Recipe.Id != jobDatas.First().Recipe.Id && referenceNode.Next?.Value is ISetupJobData setup && setup.Recipe.TargetRecipe.Id == referenceNode.Value.Recipe.Id) + { referenceNode = referenceNode.Next; + } var previousId = referenceNode.Value.Id; foreach (var jobData in jobDatas) @@ -345,7 +361,9 @@ private IReadOnlyList ExecuteAdd(LinkedList jobDatas, JobPos affectedJobs.Add(jobData); } if (referenceNode.Next != null) + { affectedJobs.Add(referenceNode.Next.Value); + } return previousId; } @@ -356,7 +374,10 @@ private LinkedListNode GetById(long id) while (currentNode != null) { if (currentNode.Value.Id == id) + { return currentNode; + } + currentNode = currentNode.Next; } @@ -403,7 +424,9 @@ private LinkedListNode GetById(long id) { // For existing nodes skip forward till we are in sync again while (referenceNode != null && currentNode.Value != referenceNode.Value) + { referenceNode = referenceNode.Next; + } if (referenceNode == null) { @@ -419,7 +442,9 @@ private LinkedListNode GetById(long id) // Job directly after the affected jobs is also affected if (referenceNode.Next != null) + { affectedJobs.Add(referenceNode.Next.Value); + } return previousId; } @@ -432,7 +457,9 @@ private LinkedListNode GetById(long id) { var job = referenceNode.Value; if (job.Recipe.Id == jobPosition.ReferenceId) + { break; + } referenceNode = referenceNode.Previous; } @@ -445,7 +472,9 @@ private LinkedListNode GetById(long id) affectedJobs.Add(jobData); } if (referenceNode.Next != null) + { affectedJobs.Add(referenceNode.Next.Value); + } return previousId; } @@ -498,7 +527,10 @@ public void Remove(IJobData completedJob, Action saveCallb return; } if (jobNode.Next != null) + { affected.Add(jobNode.Next.Value); + } + var previousId = jobNode.Previous?.Value.Id; // Completed jobs should be removed @@ -596,9 +628,13 @@ public bool MoveNext() } if (_current == null) + { _current = _forward ? _parent._jobs.First : _parent._jobs.Last; + } else + { _current = _forward ? _current.Next : _current.Previous; + } return _current != null; } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobManager.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobManager.cs index 2768659c22..ec5976ae52 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobManager.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobManager.cs @@ -148,7 +148,9 @@ public async Task> Add(JobCreationContext cont // Now schedule the scheduling if (_running) + { _taskQueue.Enqueue(UseAvailableSlots); + } // Return the jobs without awaiting the task return jobDatas; @@ -170,7 +172,9 @@ private void AddJobs(List jobDatas, JobPosition position, Ta private void OnSlotsAvailable(object sender, EventArgs args) { if (_running) + { _taskQueue.Enqueue(UseAvailableSlots); + } } private void UseAvailableSlots() @@ -185,7 +189,9 @@ private void UseAvailableSlots() // Restore order of jobs var ordered = jobDatas.Where(jd => schedulable.Any(j => j == jd.Job)).ToList(); if (ordered.Count == 0) + { return; + } // Split into chunks if schedulable jobs have gaps in JobList var totalJobs = new List(); @@ -198,27 +204,38 @@ private void UseAvailableSlots() // See if there is a next one and it is a direct neighbor if (index < ordered.Count - 1 && ordered[index + 1] == JobList.Next(jobData)) + { continue; + } // Handle what we have so far and add to JobList foreach (var handler in JobHandlers) + { handler.Handle(linkedJobs); + } + JobList.Add(linkedJobs, JobPosition.Expand, JobStorage.Save); // Add to total jobs totalJobs.AddRange(linkedJobs); // Reset if we have more if (index < ordered.Count - 1) + { linkedJobs = new LinkedList(); + } } // If non of the available jobs could be readied if (totalJobs.Count == 0) + { return; + } // Set ready AFTER they were added to the job list to avoid race conditions foreach (var jobData in totalJobs) + { jobData.Ready(); + } // Inform the scheduler about our new jobs _scheduler.JobsReady(totalJobs.Select(j => j.Job)); @@ -255,7 +272,9 @@ private void ProcessJobState(JobStateEventArgs eventArgs) var oldClassification = eventArgs.PreviousState.Classification; var classification = eventArgs.CurrentState.Classification; if (_running && oldClassification != classification && classification >= JobClassification.Running) + { _scheduler.JobUpdated(eventArgs.JobData.Job, classification); + } } private void ProcessJobCompleted(IJobData completedJob) @@ -273,4 +292,4 @@ private void ProcessJobCompleted(IJobData completedJob) JobDataFactory.Destroy(completedJob); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobStorage.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobStorage.cs index 45f72bb0ce..67321a6958 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobStorage.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/JobStorage.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Model; -using Moryx.Model.Repositories; +using Microsoft.Extensions.Logging; +using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; using Moryx.Container; @@ -11,11 +11,11 @@ using Moryx.ControlSystem.ProcessEngine.Model; using Moryx.ControlSystem.ProcessEngine.Processes; using Moryx.ControlSystem.Setups; -using ProcessContext = Moryx.ControlSystem.ProcessEngine.Model.ProcessContext; -using Microsoft.Extensions.Logging; -using Moryx.AbstractionLayer.Processes; using Moryx.Logging; +using Moryx.Model; +using Moryx.Model.Repositories; using Moryx.Threading; +using ProcessContext = Moryx.ControlSystem.ProcessEngine.Model.ProcessContext; namespace Moryx.ControlSystem.ProcessEngine.Jobs; @@ -85,7 +85,9 @@ public void Stop() { // Await all pending storage tasks while (_pendingTasks > 0) + { Thread.Sleep(100); + } } #endregion @@ -118,7 +120,9 @@ public IReadOnlyList GetAll() // If there are still jobs left, the database was corrupted if (dbJobs.Any()) + { throw new InvalidOperationException("Failed to restore sorted jobs. Database corrupted."); + } // return sorted list return jobs; @@ -157,32 +161,38 @@ Job IJobHistory.Get(long jobId) using var uow = UnitOfWorkFactory.Create(); var repo = uow.GetRepository(); var result = (from entity in repo.Linq - where entity.Id == jobId - select new QueryJob - { - Id = entity.Id, - EntityAmount = entity.Amount, - Classification = JobClassification.Completed, - SuccessCount = entity.Processes.Count(p => p.State == (int)ProcessState.Success), - FailureCount = entity.Processes.Count(p => p.State == (int)ProcessState.Failure), - ReworkedCount = entity.Processes.Count(p => p.JobId == jobId && p.Rework && - (p.State == (int)ProcessState.Success || - p.State == (int)ProcessState.Failure)), - RecipeId = entity.RecipeId, - - StateKey = entity.State, - RecipeProvider = entity.RecipeProvider - }).FirstOrDefault(); + where entity.Id == jobId + select new QueryJob + { + Id = entity.Id, + EntityAmount = entity.Amount, + Classification = JobClassification.Completed, + SuccessCount = entity.Processes.Count(p => p.State == (int)ProcessState.Success), + FailureCount = entity.Processes.Count(p => p.State == (int)ProcessState.Failure), + ReworkedCount = entity.Processes.Count(p => p.JobId == jobId && p.Rework && + (p.State == (int)ProcessState.Success || + p.State == (int)ProcessState.Failure)), + RecipeId = entity.RecipeId, + + StateKey = entity.State, + RecipeProvider = entity.RecipeProvider + }).FirstOrDefault(); if (result == null) + { return null; + } if (result.StateKey != JobStateBase.CompletedKey) + { throw new InvalidOperationException("Only completed jobs can be loaded by the history."); + } var provider = RecipeProviders.First(p => p.Name == result.RecipeProvider); if (provider is not IProductManagement) + { throw new InvalidOperationException("Only jobs based on product recipes can be reloaded."); + } result.DelayedRecipe = provider.LoadRecipeAsync(result.RecipeId).GetAwaiter().GetResult(); return result; @@ -220,9 +230,13 @@ private static void ExecuteSave(IUnitOfWork uow, ModifiedJobsFragment modifiedJo // Fetch entity and update state OR create new one var jobEntity = jobEntities.FirstOrDefault(j => j.Id == job.Id); if (jobEntity == null) + { jobEntity = Add(uow, job, previousJob); + } else if (jobEntity.State != job.State.Key) + { jobEntity.State = job.State.Key; + } // Do not update previousJob for completed jobs to close the gap if (job.State.Classification == JobClassification.Completed) @@ -234,7 +248,9 @@ private static void ExecuteSave(IUnitOfWork uow, ModifiedJobsFragment modifiedJo // Update previous link if (jobEntity.Previous != previousJob) + { jobEntity.Previous = previousJob; + } previousJob = jobEntity; } @@ -253,7 +269,9 @@ private static void ExecuteUpdateState(IUnitOfWork uow, IJobData jobData) var stateKey = jobData.State.Key; // Completion should only be set by CompletionFragment if (jobEntity.State != stateKey && stateKey != JobStateBase.CompletedKey) + { jobEntity.State = stateKey; + } } private void ConcurrentAccess(IReadOnlyList modifiedJobs, Action callback, TArgument argument) @@ -289,7 +307,9 @@ private void ConcurrentAccess(IReadOnlyList modifiedJobs, A { // Remove jobs as they are no longer updated foreach (var job in modifiedJobs) + { _processedJobs.Remove(job); + } } Interlocked.Decrement(ref _pendingTasks); diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelScheduler.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelScheduler.cs index 86f71261e8..17755fe86f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelScheduler.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelScheduler.cs @@ -109,7 +109,9 @@ public override void JobUpdated(Job job, JobClassification classification) { // Changes below Completing do not interest us if (classification < JobClassification.Completing) + { return; + } // If the completed job was a cleanup, release the slot if (classification == JobClassification.Completed && job.IsCleanup() && _slots.TryRelease(job)) @@ -135,7 +137,9 @@ public override void JobUpdated(Job job, JobClassification classification) // Flag if this job is a follow-up for the completing job var followUp = next.SameRecipeAs(job) && RemoveDependency(next, job); if (followUp && _slots.TryReplace(job, next)) + { RaiseJobScheduled(next); + } } else { @@ -164,4 +168,4 @@ public override void JobUpdated(Job job, JobClassification classification) } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelSchedulerConfig.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelSchedulerConfig.cs index 5cb78c7989..5a58bd07b5 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelSchedulerConfig.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/ParallelSchedulerConfig.cs @@ -22,4 +22,4 @@ internal class ParallelSchedulerConfig : JobSchedulerConfig [DataMember, DefaultValue(1)] [Description("Maximum amount of active jobs!")] public ushort MaxActiveJobs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SchedulerExtensions.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SchedulerExtensions.cs index 83b7551144..d337908a0c 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SchedulerExtensions.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SchedulerExtensions.cs @@ -20,10 +20,14 @@ internal static class SchedulerExtensions public bool SameRecipeAs(Job other) { if (one == null || other == null) + { return false; + } if (one.Recipe is SetupRecipe || other.Recipe is SetupRecipe) + { return false; // Setups can not be identical + } return one.Recipe.Id == other.Recipe.Id; } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessScheduler.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessScheduler.cs index 2ece42dee0..653110f1fc 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessScheduler.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessScheduler.cs @@ -64,9 +64,14 @@ public override IEnumerable SchedulableJobs(IEnumerable jobs) { // Initial job or follow up if (last == null || last.SameRecipeAs(job)) + { yield return job; + } else + { yield break; + } + last = job; } } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessSchedulerConfig.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessSchedulerConfig.cs index 94a0080ce1..fa59832564 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessSchedulerConfig.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Implementation/SeamlessSchedulerConfig.cs @@ -12,4 +12,4 @@ internal class SeamlessSchedulerConfig : JobSchedulerConfig { /// public override string PluginName => nameof(SeamlessScheduler); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobDataBase.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobDataBase.cs index c2c39676aa..49045ef994 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobDataBase.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobDataBase.cs @@ -188,7 +188,9 @@ protected void InvokeStateMachine(Action stateMachine) } // Only publish changes of classification if (oldState != State) + { StateChanged?.Invoke(this, new JobStateEventArgs(this, oldState, State)); + } } /// @@ -281,7 +283,9 @@ internal virtual void ProcessCompleted(ProcessData processData) { // Only raise progress changed while we have running processes if (RunningProcesses.Count > 0) + { RaiseProgressChanged(); + } } /// @@ -312,4 +316,4 @@ public override int GetHashCode() /// public event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateBase.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateBase.cs index 26203c011b..6ca04a8161 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateBase.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateBase.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Runtime.CompilerServices; using Microsoft.Extensions.Logging; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Processes; using Moryx.Logging; using Moryx.StateMachines; -using System.Runtime.CompilerServices; namespace Moryx.ControlSystem.ProcessEngine.Jobs; @@ -79,4 +79,4 @@ public virtual void ProcessChanged(ProcessData processData, ProcessState trigger { InvalidJobState(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateEventArgs.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateEventArgs.cs index d42bdf4620..6032e59af6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateEventArgs.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/JobStateEventArgs.cs @@ -32,4 +32,4 @@ public JobStateEventArgs(IJobData job, IJobState previous, IJobState current) PreviousState = previous; CurrentState = current; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessDataIterator.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessDataIterator.cs index 004014b43c..ee8dbb99a6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessDataIterator.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessDataIterator.cs @@ -43,4 +43,4 @@ public void Dispose() public T Current { get; private set; } object IEnumerator.Current => Current; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessList.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessList.cs index 2a4dbd21f3..14d51876b4 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessList.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/ProcessList.cs @@ -25,4 +25,4 @@ IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobData.cs index 988ef268dd..bee816130d 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobData.cs @@ -85,7 +85,10 @@ internal override void LoadProcesses() public override void FailurePredicted(ProcessData processData) { lock (_predictedFailures) + { _predictedFailures.Add(processData); + } + Job.PredictedFailures.Add(processData.Process); RaiseProgressChanged(); @@ -107,22 +110,34 @@ internal override void ProcessCompleted(ProcessData processData) Job.Running.Remove(processData.Process); lock (_predictedFailures) + { _predictedFailures.Remove(processData); + } Job.PredictedFailures.Remove(processData.Process); // Count the reworked process which could be also a success or failure process if (processData.Rework && (processData.State == ProcessState.Success || processData.State == ProcessState.Failure)) + { Job.ReworkedCount = ++ReworkedCount; + } if (processData.State == ProcessState.Discarded) + { AllProcesses.Remove(processData); // Discarded processes are removed from all processes as well + } else if (processData.State == ProcessState.Success) + { Job.SuccessCount = ++SuccessCount; + } else if (processData.State == ProcessState.Failure) + { Job.FailureCount = ++FailureCount; + } else + { return; + } base.ProcessCompleted(processData); } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobStateBase.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobStateBase.cs index e5d7bc133e..ec46e6f8cf 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobStateBase.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/ProductionJobStateBase.cs @@ -19,9 +19,13 @@ protected void PerformCleanup() { Context.LoadProcesses(); if (Context.RunningProcesses.Any()) + { NextState(StateCleanUp); + } else + { NextState(StateCompleted); + } } [StateDefinition(typeof(InitialState), IsInitial = true)] @@ -77,4 +81,4 @@ protected void PerformCleanup() [StateDefinition(typeof(CompletedState))] protected const int StateCompleted = CompletedKey; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/AbortingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/AbortingState.cs index dd7d772632..0ed52284d8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/AbortingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/AbortingState.cs @@ -50,4 +50,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpState.cs index 3abcdcc319..b979f78bb8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpState.cs @@ -25,7 +25,9 @@ public override void Load() Context.LoadProcesses(); if (Context.RunningProcesses.Count == 0) + { NextState(StateCompleted); + } } catch (Exception) { @@ -60,4 +62,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge // We might receive interruption events here if we came from the waiting state // but they are irrelevant } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpWaitingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpWaitingState.cs index 5763c378a8..47c5f9e970 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpWaitingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleanUpWaitingState.cs @@ -59,4 +59,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge { // Ignore events here } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleaningUpState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleaningUpState.cs index 1db904331c..c602f0bbee 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleaningUpState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CleaningUpState.cs @@ -64,4 +64,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletedState.cs index 81574b8b1d..b8f6f34235 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletedState.cs @@ -25,4 +25,4 @@ public override void Complete() { // Already completed, nothing to do } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedState.cs index dbaa9633b7..6769f91ffd 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedState.cs @@ -42,4 +42,4 @@ public override void Abort() { NextState(StateCleanUp); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedWaitingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedWaitingState.cs index 42e69f7ae2..cb84b291f8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedWaitingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptedWaitingState.cs @@ -46,4 +46,4 @@ public override void Interrupt() NextState(StateCompletingInterrupting); Context.InterruptProcesses(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptingState.cs index acf12d646f..c76ad23ae6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingInterruptingState.cs @@ -30,11 +30,15 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge { // Only remove completed processes if (trigger >= ProcessState.Interrupted) + { Context.ProcessCompleted(processData); + } // Wait till all running processes have reported a stable state if (Context.RunningProcesses.Count > 0) + { return; + } // Iterate all processes from the back, looking for any non-completed process // If the job actually completed, this WILL iterate the entire list @@ -42,7 +46,9 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge for (var i = Context.AllProcesses.Count - 1; i >= 0; i--) { if (Context.AllProcesses[i].State > ProcessState.Interrupted) + { continue; + } anyInterrupted = true; break; @@ -50,8 +56,12 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge // If we found any interrupted job, we are interrupted, otherwise completed if (anyInterrupted) + { NextState(StateCompletingInterrupted); + } else + { NextState(StateCompleted); + } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingState.cs index 25d452a10c..e46ef0a2ef 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/CompletingState.cs @@ -53,4 +53,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DiscardingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DiscardingState.cs index 781ab00d87..e82543751f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DiscardingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DiscardingState.cs @@ -50,4 +50,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DispatchedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DispatchedState.cs index 3abd575d0e..11f6543394 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DispatchedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/DispatchedState.cs @@ -95,4 +95,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge base.ProcessChanged(processData, trigger); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InitialState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InitialState.cs index 3697ee6592..4440118f64 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InitialState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InitialState.cs @@ -46,7 +46,9 @@ public override void Interrupt() { // Nothing to interrupt if (Context.Dispatcher.RebootCompleteInitial) + { NextState(StateCompleted); + } } public override void ProcessChanged(ProcessData processData, ProcessState trigger) @@ -62,4 +64,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge base.ProcessChanged(processData, trigger); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedState.cs index c69a1a94a1..2e619b34a3 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedState.cs @@ -45,4 +45,4 @@ public override void Abort() { NextState(StateCleanUp); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedWaitingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedWaitingState.cs index 8c7c897cf4..fbfd643033 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedWaitingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptedWaitingState.cs @@ -71,4 +71,4 @@ public override void Interrupt() Context.InterruptProcesses(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptingState.cs index d0464e6696..86e7391d11 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/InterruptingState.cs @@ -40,4 +40,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/RunningState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/RunningState.cs index 6b2bd31695..1455c643e6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/RunningState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/RunningState.cs @@ -70,4 +70,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge NextState(StateCompleting); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/SuspendedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/SuspendedState.cs index 1cc4067e8a..3830558e55 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/SuspendedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/SuspendedState.cs @@ -75,4 +75,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge NextState(StateCompleting); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/WaitingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/WaitingState.cs index 7b61a2f2ff..0c2ac90982 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/WaitingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Production/States/WaitingState.cs @@ -60,4 +60,4 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge base.ProcessChanged(processData, trigger); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/ISetupJobHandler.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/ISetupJobHandler.cs index 9c07bdd053..f5956d818b 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/ISetupJobHandler.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/ISetupJobHandler.cs @@ -7,4 +7,4 @@ namespace Moryx.ControlSystem.ProcessEngine.Jobs.Setup; internal interface ISetupJobHandler : IPlugin, IJobHandler { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobData.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobData.cs index e59ed9e417..eca453d275 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobData.cs @@ -101,7 +101,9 @@ internal void UpdateRecipe(IWorkplanRecipe recipe) var step = recipe.Workplan.Steps.FirstOrDefault(step => step.GetType() == disabledStep.GetType()); // set disabled step in new recipe if (step != null) + { recipe.DisabledSteps.Add(step.Id); + } } } @@ -112,7 +114,9 @@ internal void UpdateRecipe(IWorkplanRecipe recipe) internal bool IsRetryLimitReached() { if (ModuleConfig.SetupJobRetryLimit < 0) + { return false; + } return _retryCounter > ModuleConfig.SetupJobRetryLimit; } @@ -181,7 +185,9 @@ private void OnActivityChanged(object sender, ActivityData activityData) // Only publish progress changed while we execute something if (RunningCount > 0) + { RaiseProgressChanged(); + } } /// diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobHandler.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobHandler.cs index 18f31cfb2a..693d36458f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobHandler.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobHandler.cs @@ -154,10 +154,15 @@ private ISetupJobData FollowingCleanup(IJobData jobData) { // Skip all identical production jobs if (next.Recipe.Id == recipeId) + { continue; + } if (next is ISetupJobData cleanup && cleanup.Recipe.TargetRecipe.Id == recipeId) + { return cleanup; + } + break; } return null; @@ -238,7 +243,9 @@ private void InterruptJobsBackward(LinkedListNode current, Exception e if (FirstOfRecipe(jobToBeAborted.Value)) { if (previous?.Value is SetupJobData setupJobData && setupJobData.Recipe.TargetRecipe.Id != jobToBeAborted.Value.Recipe.Id) + { break; + } // Interrupt the setup for this set of jobs abortedJobIds.Add(previous.Value.Id); @@ -268,9 +275,13 @@ private void OnJobStateChanged(object sender, JobStateEventArgs args) { var jobData = args.JobData; if (args.CurrentState.Classification < JobClassification.Completed) + { CheckRecipeUpdate(jobData); + } else + { OnJobCompleted(jobData); + } } private void CheckRecipeUpdate(IJobData jobData) @@ -278,7 +289,9 @@ private void CheckRecipeUpdate(IJobData jobData) // Check if setup job requires a new recipe var setupJob = jobData as ISetupJobData; if (setupJob?.RecipeRequired != true) + { return; + } // Fetch current recipe and check if setup is complete var currentRecipe = setupJob.Recipe; @@ -294,12 +307,16 @@ private void OnJobCompleted(IJobData jobData) // Otherwise check if a production job was completed var productionJob = jobData as IProductionJobData; if (productionJob == null) + { return; + } // If we have a follow-up job with the same recipe, we don't have to do anything var followUp = JobList.Next(jobData)?.Recipe.Id == jobData.Recipe.Id; if (followUp) + { return; + } // Check if the previous job is a setup targeting the completed job // Clean-up jobs don't need to be aborted. They are updated when started by the scheduler @@ -342,4 +359,4 @@ public override void SequenceCompleted(SequenceCompleted completed) { } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobStateBase.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobStateBase.cs index ebffd4346a..7ba8beb398 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobStateBase.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/SetupJobStateBase.cs @@ -51,4 +51,4 @@ public virtual void UnBlockRetrySetup() [StateDefinition(typeof(CompletedState))] protected const int StateCompleted = CompletedKey; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/AbortingSetupState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/AbortingSetupState.cs index c4e2b3f559..49ecd7a0d4 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/AbortingSetupState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/AbortingSetupState.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Processes; using Moryx.ControlSystem.ProcessEngine.Properties; -using System.ComponentModel.DataAnnotations; namespace Moryx.ControlSystem.ProcessEngine.Jobs.Setup; @@ -28,9 +28,11 @@ public override void Interrupt() public override void ProcessChanged(ProcessData processData, ProcessState trigger) { if (trigger < ProcessState.Interrupted) + { return; + } Context.ProcessCompleted(processData); NextState(StateCompleted); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/CompletedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/CompletedState.cs index cdb60abb5f..ef4f31f9e8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/CompletedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/CompletedState.cs @@ -15,4 +15,4 @@ public CompletedState(JobDataBase context, StateMap stateMap) : base(context, stateMap, JobClassification.Completed) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InitialState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InitialState.cs index 4c50f832e3..ced2e59ba1 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InitialState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InitialState.cs @@ -36,4 +36,4 @@ public override void Abort() { NextState(StateCompleted); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InterruptingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InterruptingState.cs index ae88d1c5ef..80d6ee1390 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InterruptingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/InterruptingState.cs @@ -34,6 +34,8 @@ public override void Stop() public override void ProcessChanged(ProcessData processData, ProcessState trigger) { if (trigger >= ProcessState.Interrupted) + { NextState(StateCompleted); + } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RequestRecipeState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RequestRecipeState.cs index 6f3f29fd84..d19b8e9d50 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RequestRecipeState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RequestRecipeState.cs @@ -48,4 +48,4 @@ public override void Abort() { NextState(StateCompleted); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RetrySetupBlockedState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RetrySetupBlockedState.cs index 8a3754a7c5..f47eab9c62 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RetrySetupBlockedState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RetrySetupBlockedState.cs @@ -54,4 +54,4 @@ public override void Abort() { NextState(StateCompleted); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RunningState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RunningState.cs index 13d1ddcdfd..a0c339928c 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RunningState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/RunningState.cs @@ -52,7 +52,9 @@ public override void Abort() public override void ProcessChanged(ProcessData processData, ProcessState trigger) { if (trigger != ProcessState.Success && trigger != ProcessState.Failure) + { return; + } Context.ProcessCompleted(processData); if (trigger == ProcessState.Success) @@ -64,9 +66,13 @@ public override void ProcessChanged(ProcessData processData, ProcessState trigge Context.IncrementRetry(); // Check if we reached the limit if (Context.IsRetryLimitReached()) + { NextState(StateRetrySetupBlocked); // Enter blocked state and await user confirmation + } else + { NextState(StateRequestRecipe); // Request an updated setup from the setup manager + } } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/WaitingState.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/WaitingState.cs index 51092f8db5..3e887b02a6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/WaitingState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/States/WaitingState.cs @@ -44,11 +44,15 @@ public override void Start() public override void UpdateSetup(SetupRecipe newRecipe) { if (newRecipe == null) + { // Empty recipe means setup is no longer necessary NextState(StateCompleted); + } else + { // Until the process is started, we can still update the recipe Context.UpdateRecipe(newRecipe); + } } public override void Interrupt() @@ -60,4 +64,4 @@ public override void Abort() { NextState(StateCompleted); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/TemporarySetupProvider.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/TemporarySetupProvider.cs index 7e5480475e..320f3295c0 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/TemporarySetupProvider.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/Setup/TemporarySetupProvider.cs @@ -43,4 +43,4 @@ public SetupRecipe CreateTemporary(ProductionRecipe recipe) } public event EventHandler RecipeChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Jobs/WorkplanValidation.cs b/src/Moryx.ControlSystem.ProcessEngine/Jobs/WorkplanValidation.cs index f879017f6e..60100935be 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Jobs/WorkplanValidation.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Jobs/WorkplanValidation.cs @@ -28,7 +28,9 @@ public static IReadOnlyList Validate(IWorkplan workplan) foreach (var step in workplan.Steps) { if (step.Outputs.Any(o => o is null)) + { errors.Add(string.Format(Strings.WorkplanValidation_OutputUnset, step.Name)); + } } // Validate step parameters @@ -44,10 +46,12 @@ public static IReadOnlyList Validate(IWorkplan workplan) DisplayName = property.GetDisplayName() ?? property.Name }); if (!string.IsNullOrEmpty(result?.ErrorMessage)) + { errors.Add(result.ErrorMessage); + } } } return errors; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IActivityEntityRepository.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IActivityEntityRepository.cs index a156f001cb..2fc6d275cc 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IActivityEntityRepository.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IActivityEntityRepository.cs @@ -28,4 +28,4 @@ public IEnumerable GetRunning(long processId) => /// public IEnumerable GetCompleted(long processId) => DbSet.Where(a => a.ProcessId == processId && a.Result != null); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IJobEntityRepository.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IJobEntityRepository.cs index 88f5bf42ea..4fe524bff7 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IJobEntityRepository.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IJobEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.ControlSystem.ProcessEngine.Model; public interface IJobEntityRepository : IRepository { IEnumerable GetAllByState(int state); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IProcessEntityRepository.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IProcessEntityRepository.cs index c59620b761..c92b430622 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/API/IProcessEntityRepository.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/API/IProcessEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.ControlSystem.ProcessEngine.Model; public interface IProcessEntityRepository : IRepository { ICollection GetAllByState(int state); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITokenHolderEntityRepository.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITokenHolderEntityRepository.cs index b2cb63b1a4..a885a8e262 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITokenHolderEntityRepository.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITokenHolderEntityRepository.cs @@ -21,4 +21,4 @@ public interface ITokenHolderEntityRepository : IRepository /// Creates instance with all not nullable properties prefilled /// TokenHolderEntity Create(long holderId, string tokens); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITracingTypeRepository.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITracingTypeRepository.cs index d35d39ae0b..b81fbea7d2 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITracingTypeRepository.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/API/ITracingTypeRepository.cs @@ -12,4 +12,4 @@ public interface ITracingTypeRepository : IRepository /// Creates instance with all not nullable properties prefilled /// TracingType Create(string assembly, string nameSpace, string classname); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ActivityEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ActivityEntity.cs index 13228ea851..c36cf30e28 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ActivityEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ActivityEntity.cs @@ -18,7 +18,9 @@ public virtual long Id set { if (field == value) + { return; + } field = value; IdChanged?.Invoke(this, EventArgs.Empty); @@ -62,4 +64,4 @@ public virtual long Id #endregion public event EventHandler IdChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/JobEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/JobEntity.cs index eff66b5b7f..b3d1ba7344 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/JobEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/JobEntity.cs @@ -25,4 +25,4 @@ public class JobEntity : ModificationTrackedEntityBase public virtual JobEntity Previous { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ProcessEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ProcessEntity.cs index 57e4ed2fe6..0cef46a37f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ProcessEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/ProcessEntity.cs @@ -37,4 +37,4 @@ public override long Id public virtual JobEntity Job { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TokenHolderEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TokenHolderEntity.cs index 87236c0c7b..cdb7b8dc0f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TokenHolderEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TokenHolderEntity.cs @@ -22,4 +22,4 @@ public class TokenHolderEntity : EntityBase public virtual ProcessEntity Process { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TracingType.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TracingType.cs index 3fd43837cb..ca5e4c2f2e 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TracingType.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Entities/TracingType.cs @@ -13,4 +13,4 @@ public class TracingType : EntityBase public virtual string NameSpace { get; set; } public virtual string Classname { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20220831123023_InitialCreate.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20220831123023_InitialCreate.cs index 06e852f935..e8dcb99b9c 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20220831123023_InitialCreate.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20220831123023_InitialCreate.cs @@ -215,4 +215,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "JobEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251030111419_TableNames.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251030111419_TableNames.cs index 84f51255e8..a3115d6b15 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251030111419_TableNames.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251030111419_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -549,4 +549,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251202141815_RemovedTypeNameProcessEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251202141815_RemovedTypeNameProcessEntity.cs index b9c1762ec8..2cd7da38ae 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251202141815_RemovedTypeNameProcessEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Npgsql/20251202141815_RemovedTypeNameProcessEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -29,4 +29,4 @@ protected override void Down(MigrationBuilder migrationBuilder) type: "text", nullable: true); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20230216064711_InitialCreate.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20230216064711_InitialCreate.cs index 8121cace60..cab9db9ba8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20230216064711_InitialCreate.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20230216064711_InitialCreate.cs @@ -212,4 +212,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "JobEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251030111412_TableNames.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251030111412_TableNames.cs index 542c2056d6..8195f4ea9e 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251030111412_TableNames.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251030111412_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -397,4 +397,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251202141833_RemovedTypeNameProcessEntity.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251202141833_RemovedTypeNameProcessEntity.cs index 5b0a09f063..8bc4d4062d 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251202141833_RemovedTypeNameProcessEntity.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/Migrations/Sqlite/20251202141833_RemovedTypeNameProcessEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -29,4 +29,4 @@ protected override void Down(MigrationBuilder migrationBuilder) type: "TEXT", nullable: true); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/NpgsqlProcessContext.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/NpgsqlProcessContext.cs index 37d76efb83..29ba435634 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/NpgsqlProcessContext.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/NpgsqlProcessContext.cs @@ -21,4 +21,4 @@ public NpgsqlProcessContext() public NpgsqlProcessContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/ProcessContext.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/ProcessContext.cs index 5466ca0944..9ef5c5302e 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/ProcessContext.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/ProcessContext.cs @@ -82,4 +82,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .WithMany(p => p.TokenHolders) .IsRequired(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Model/SqliteProcessContext.cs b/src/Moryx.ControlSystem.ProcessEngine/Model/SqliteProcessContext.cs index 1d7d57a655..9d5d9fa0f8 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Model/SqliteProcessContext.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Model/SqliteProcessContext.cs @@ -27,4 +27,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ComponentOrchestration.cs b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ComponentOrchestration.cs index f3e7777600..b9f6a0c385 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ComponentOrchestration.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ComponentOrchestration.cs @@ -55,7 +55,9 @@ public void Start() // Boot all listeners foreach (var listener in PoolListeners.OrderBy(l => l.StartOrder)) + { listener.Initialize(); + } JobList.Start(); @@ -68,10 +70,14 @@ public void Start() // Start execution foreach (var listener in PoolListeners.OrderBy(l => l.StartOrder)) + { listener.Start(); + } if (JobManager.AwaitBoot(Config.BootSyncTimeoutSec)) + { Logger.Log(LogLevel.Warning, new TimeoutException("Job manager ran into a timeout trying to restore the previous job list state!"), "Timeout"); + } } public void Stop() @@ -101,4 +107,4 @@ public void Stop() JobStorage.Stop(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConfig.cs b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConfig.cs index 72ce1ba3d8..71272b61b2 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConfig.cs @@ -171,4 +171,4 @@ public enum TimeoutCalculationType /// Estimate timeout manually /// Manual, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConsole.cs b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConsole.cs index 2bac855507..0dc205a589 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleConsole.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel.DataAnnotations; -using Moryx.AbstractionLayer.Constraints; using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.ProcessEngine.Jobs; diff --git a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleController.cs b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleController.cs index a37b3d656d..79f08e7346 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleController.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/ModuleController/ModuleController.cs @@ -87,7 +87,9 @@ protected override Task OnInitializeAsync(CancellationToken cancellationToken) .SetInstance(ProductManagement); // Register optional setup dependency if (SetupProvider != null) + { Container.SetInstance(SetupProvider); + } // Register process plugins Container.LoadComponents(); diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/ActivityState.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/ActivityState.cs index 8948f2f568..8c515333cb 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/ActivityState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/ActivityState.cs @@ -49,4 +49,4 @@ public enum ActivityState /// The Activity is finished and its Result is set. /// Completed = 8192, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/CellReference.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/CellReference.cs index a3c923892b..0fa979f47d 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/CellReference.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/CellReference.cs @@ -60,4 +60,4 @@ public void SequenceCompleted(SequenceCompleted completed) public event EventHandler CapabilitiesChanged; #pragma warning restore 67 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ActivityEventArgs.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ActivityEventArgs.cs index aa0a26ea5d..6eb4ae9316 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ActivityEventArgs.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ActivityEventArgs.cs @@ -26,4 +26,4 @@ public ActivityEventArgs(ActivityData activityData, ActivityState trigger) /// Trigger state of the activity for executing the event chain /// public ActivityState Trigger { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityDispatcher.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityDispatcher.cs index 3fc2ed9589..ac64ab1e8b 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityDispatcher.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityDispatcher.cs @@ -12,4 +12,4 @@ internal interface IActivityDispatcher /// Export sessions /// ResourceAndSession[] ExportSessions(); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityPoolListener.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityPoolListener.cs index dffe5db69e..5bf784afb6 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityPoolListener.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IActivityPoolListener.cs @@ -14,4 +14,4 @@ internal interface IActivityPoolListener : IInitializablePlugin /// Determines the boot and shutdown order /// int StartOrder { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ICellSelectorFactory.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ICellSelectorFactory.cs index 5f74c1fdb8..1bad3aad9b 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ICellSelectorFactory.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ICellSelectorFactory.cs @@ -24,4 +24,4 @@ internal interface ICellSelectorFactory /// /// void Destroy(ICellSelector instance); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IFailurePredictor.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IFailurePredictor.cs index 46e466b4fe..323b2ad26a 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IFailurePredictor.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IFailurePredictor.cs @@ -13,4 +13,4 @@ internal interface IFailurePredictor : IActivityPoolListener /// Event raised when a process will fail in the near future /// event EventHandler ProcessWillFail; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessController.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessController.cs index 3b47c95e5b..9ce4cbd681 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessController.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessController.cs @@ -40,4 +40,4 @@ internal interface IProcessController /// Occurs when the process state changed /// event EventHandler ProcessChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessStorage.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessStorage.cs index 090ce306b3..821edcc634 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessStorage.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IProcessStorage.cs @@ -57,4 +57,4 @@ internal interface IProcessStorage : IPlugin /// Append information about a completed activity to the process /// void AddCompletedActivity(ProcessData processData, ActivityData activityData); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IResourceAssignment.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IResourceAssignment.cs index 231a543b41..bce24dd408 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IResourceAssignment.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/IResourceAssignment.cs @@ -15,4 +15,4 @@ internal interface IResourceAssignment /// Capabilities of a managed cell has changed /// event EventHandler CapabilitiesChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ProcessEventArgs.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ProcessEventArgs.cs index e38a92d1c3..e3caf0e636 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ProcessEventArgs.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Components/ProcessEventArgs.cs @@ -26,4 +26,4 @@ public ProcessEventArgs(ProcessData processData, ProcessState trigger) /// State at the time of triggering /// public ProcessState Trigger { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityDispatcher.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityDispatcher.cs index f9b6bcb330..e45bee102a 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityDispatcher.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityDispatcher.cs @@ -117,7 +117,9 @@ public void Stop() try { foreach (var session in cell.ProcessEngineDetached().OfType()) + { HandleActivityCompleted(cell, session); + } } catch (Exception e) { @@ -146,7 +148,9 @@ public void Dispose() public ResourceAndSession[] ExportSessions() { lock (_reportedSessions) + { return _reportedSessions.ToArray(); + } } private void HandleAttachedCells(IEnumerable pairs) @@ -161,7 +165,10 @@ private void HandleAttachedCells(IEnumerable pairs) { Logger.Log(LogLevel.Warning, "Received {0} for unknown process {1}!", session.GetType().Name, session.Reference); if (session is ReadyToWork rtw) + { Decouple(() => cell.SequenceCompleted(rtw.CompleteSequence(null, false)), nameof(ICell.SequenceCompleted), cell); + } + continue; } @@ -170,7 +177,10 @@ private void HandleAttachedCells(IEnumerable pairs) if (processData is { State: < ProcessState.EngineStarted }) { lock (processData.ReportedSessions) + { processData.ReportedSessions.Add(pair); + } + continue; } @@ -193,10 +203,14 @@ private void HandleAttachedCells(IEnumerable pairs) private void OnResourcesAdded(object sender, IResource e) { if (e is not ICell cell) + { return; + } if (_cells.Any(c => c.Id == cell.Id)) + { return; + } _cells.Add(cell); @@ -215,7 +229,9 @@ private void OnResourceRemoved(object sender, IResource e) { var cell = e as ICell; if (cell == null) + { return; + } _cells.Remove(cell); @@ -226,14 +242,18 @@ private void OnResourceRemoved(object sender, IResource e) // Remove already reported session lock (_reportedSessions) + { _reportedSessions.RemoveAll(s => s.Resource.Equals(e)); + } } private void UpdateToRunning(ActivityStart activityStart) { var activity = ActivityPool.GetByActivity(activityStart.Activity); if (activity != null) + { ActivityPool.TryUpdateActivity(activity, ActivityState.Running); + } } private void OnActivityChanged(object sender, ActivityEventArgs args) @@ -247,7 +267,10 @@ private void OnActivityChanged(object sender, ActivityEventArgs args) // Do not dispatch activities before the engine was flagged as started if (processData.State >= ProcessState.EngineStarted // OR any activities are still processing results && processData.Activities.All(a => a.State <= ActivityState.Running | a.State >= ActivityState.Completed)) + { HandleConfiguredActivity(activityData, processData); + } + break; case ActivityState.EngineProceeded: // First complete the session @@ -257,7 +280,10 @@ private void OnActivityChanged(object sender, ActivityEventArgs args) // NOW dispatch new activities var configured = processData.Activities.Where(a => a.State == ActivityState.Configured); foreach (var activity in configured) + { HandleConfiguredActivity(activity, processData); + } + break; } @@ -297,15 +323,23 @@ private void HandleConfiguredActivity(ActivityData activityData, ProcessData pro // We found no match for the activity if (match == null) + { return; + } // Start the activity if we have a match AND it's a ready to work if (match.ReadyToWork != null) + { ParallelOperations.ExecuteParallel(() => StartActivity(match.Resource, match.ReadyToWork, activityData)); + } else if (match.Session is ActivityStart) + { ActivityPool.TryUpdateActivity(activityData, ActivityState.Running); + } else if (match.Session is ActivityCompleted completedSession) + { HandleActivityCompleted(match.Resource, completedSession); + } } /// @@ -339,7 +373,9 @@ private void ProcessLoaded(ProcessData processData) // Now that the process is loaded we can process its open activities var openActivities = ActivityPool.GetAllOpen(processData); foreach (var openActivity in openActivities) + { HandleConfiguredActivity(openActivity, processData); + } // The code above already takes care of all matching sessions, for all remaining // session we can send Finish OR SequenceCompleted @@ -394,7 +430,9 @@ private void ProcessCompleted(ProcessData processData) { // A completed process might still have running activities, we should inform the cells if (processData.State >= ProcessState.Success) + { ProcessAborting(processData); + } // Complete and clear open sessions lock (processData.ReportedSessions) @@ -552,15 +590,25 @@ private void HandleActivityCompleted(ICell resource, ActivityCompleted message) var activity = ActivityPool.GetByActivity(message.CompletedActivity); if (activity is null) + { HandleForUnknownActivity(resource, message); + } else if (activity.State == ActivityState.Completed) + { HandleForAlreadyCompletedActivity(resource, message, activity); + } else if (activity.State >= ActivityState.ResultReceived) + { HandleForCurrentlyCompletingActivity(resource, message, activity); + } else if (message is UnknownActivityAborted) + { HandleForUnknownSession(resource, activity); + } else + { HandleActivityCompleted(resource, message, activity); + } } private void HandleForUnknownActivity(ICell resource, ActivityCompleted message) @@ -593,8 +641,8 @@ private void HandleActivityCompleted(ICell resource, ActivityCompleted message, { Logger.Log(LogLevel.Debug, "Received result '{result}' for activity '{activity}'", message.CompletedActivity.Result.Numeric, activity); - void ApplyDataAfterCompletion(ActivityData data) - { + void ApplyDataAfterCompletion(ActivityData data) + { // Update session and resource data.Session = message; data.Resource = resource; @@ -603,7 +651,7 @@ void ApplyDataAfterCompletion(ActivityData data) data.Result = message.CompletedActivity.Result; data.Tracing = message.CompletedActivity.Tracing; data.Tracing.Completed = DateTime.Now; - } + } ActivityPool.TryUpdateActivity(activity, ActivityState.ResultReceived, ApplyDataAfterCompletion); } @@ -639,7 +687,9 @@ private void OnCellNotReadyToWork(object sender, NotReadyToWork message) var sessionCache = GetSessionCache(message.Reference); lock (sessionCache) + { sessionCache.RemoveAll(resourceAndSession => resourceAndSession.ReadyToWork?.Id == message.Id); + } } /// diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityPool.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityPool.cs index 9463f4d6f3..3964b81cb3 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityPool.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityPool.cs @@ -49,7 +49,9 @@ internal sealed class ActivityPool : ILoggingComponent, IActivityDataPool, IActi public void AddProcess(ProcessData processData) { lock (_runningProcesses) + { _runningProcesses.Add(processData); + } RaiseProcessChanged(processData, processData.State); } @@ -59,7 +61,10 @@ public void AddActivity(ProcessData processData, ActivityData activityData) activityData.ProcessData = processData; // Generate an id BEFORE adding to the pool if (activityData.Id == 0) + { activityData.Id = IdShiftGenerator.Generate(processData.Id, processData.ActivityIndex++); + } + processData.AddActivity(activityData); _activitiesLock.EnterWriteLock(); @@ -90,7 +95,9 @@ public void UpdateProcess(ProcessData processData, ProcessState newState) // Remove the process lock (_runningProcesses) + { _runningProcesses.Remove(processData); + } } } @@ -157,7 +164,10 @@ private void RaiseProcessChanged(ProcessData processData, ProcessState trigger) case ProcessState.Interrupted: case ProcessState.Discarded: foreach (var activity in processData.Activities.Where(a => a.State <= ActivityState.Configured)) + { ActivityUpdated?.Invoke(this, new ActivityUpdatedEventArgs(activity.Activity, ActivityProgress.Completed)); + } + progress = ProcessProgress.Interrupted; break; case ProcessState.Success: @@ -266,7 +276,9 @@ public ProcessData GetProcess(long id) public ProcessData GetProcess(ProcessReference reference) { if (reference.IsEmpty) + { return null; + } lock (_runningProcesses) { @@ -340,7 +352,10 @@ private static IReadOnlyList FastExtraction(IReadOnlyLi { var extracted = new TDomain[source.Count]; for (int i = 0; i < source.Count; i++) + { extracted[i] = extractor(source[i]); + } + return extracted; } } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityProvider.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityProvider.cs index af7a388bde..64db606287 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityProvider.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityProvider.cs @@ -187,11 +187,11 @@ private static WorkplanSnapshot LoadSnapshot(IUnitOfWork uow, ProcessData proces var snapshot = new WorkplanSnapshot { Holders = (from holder in holders - select new HolderSnapshot - { - HolderId = holder.HolderId, - Tokens = JsonConvert.DeserializeObject(holder.Tokens, JsonSettings.Minimal) - }).ToArray() + select new HolderSnapshot + { + HolderId = holder.HolderId, + Tokens = JsonConvert.DeserializeObject(holder.Tokens, JsonSettings.Minimal) + }).ToArray() }; // Remove holder entities after snapshot was created @@ -212,7 +212,9 @@ private void SuspendWorkflow(ProcessData processData) using var uow = UnitOfWorkFactory.Create(); // Workflow was not loaded and its snapshot is still valid if (processData.ActivityCount() == 0) + { return; + } // Create snapshot and write to db var holderRepo = uow.GetRepository(); @@ -240,12 +242,16 @@ private void SuspendWorkflow(ProcessData processData) private void OnActivityChanged(object sender, ActivityEventArgs args) { if (args.Trigger != ActivityState.ResultProcessed) + { return; + } // Very specific exclusion of activities that the ProcessRemoval created, // would be better to only include things the ActivityProvider provided if (args.ActivityData.Activity is ProcessFixupActivity) + { return; + } var activityData = args.ActivityData; activityData.Task.Completed(activityData.Result); @@ -265,13 +271,19 @@ private void OnWorkflowCompleted(object sender, IPlace place) case NodeClassification.End: // TODO: This is not a good place, but timing sucks if (processData.Process is ProductionProcess prodProcess) + { prodProcess.ProductInstance.State = ProductInstanceState.Success; + } + ActivityPool.UpdateProcess(processData, ProcessState.Success); break; case NodeClassification.Failed: // TODO: This is not a good place, but timing sucks if (processData.Process is ProductionProcess failedProcess) + { failedProcess.ProductInstance.State = ProductInstanceState.Failure; + } + ActivityPool.UpdateProcess(processData, ProcessState.Failure); break; } @@ -282,7 +294,9 @@ private void OnTransitionTriggered(object sender, ITransition transition) var processData = GetProcessByEngine((IWorkplanEngine)sender); // Stop creating activities for stopping processes if (processData.State > ProcessState.Running) + { return; + } var taskTransition = (ITaskTransition)transition; try @@ -291,7 +305,9 @@ private void OnTransitionTriggered(object sender, ITransition transition) var activityData = new ActivityData(activity) { Task = taskTransition }; // Try to reload the activity for restored processes, this will ONLY find a match for previously running activities if (processData.State == ProcessState.RestoredReady) + { ProcessStorage.TryReloadRunningActivity(processData.Id, activityData); + } ActivityPool.AddActivity(processData, activityData); } @@ -337,7 +353,9 @@ private void RemoveWorkflow(ProcessData processData) var workflow = processData.Engine; if (processData.State > ProcessState.Interrupted) + { DeleteHolders(processData); // Delete all remaining holders of the process + } workflow.TransitionTriggered -= OnTransitionTriggered; workflow.Completed -= OnWorkflowCompleted; diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityTimeoutObserver.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityTimeoutObserver.cs index 8ecd6f0c03..4780e52423 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityTimeoutObserver.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ActivityTimeoutObserver.cs @@ -48,8 +48,12 @@ public void Start() public void Stop() { lock (_runningTimers) + { foreach (var runningTimer in _runningTimers.Values) + { ParallelOperations.StopExecution(runningTimer); + } + } _runningTimers.Clear(); } @@ -64,7 +68,9 @@ private void OnActivityChanged(object sender, ActivityEventArgs args) { var timeoutParameters = args.ActivityData.Activity.Parameters as IActivityTimeoutParameters; if (timeoutParameters == null || timeoutParameters.Timeout <= 0) + { return; + } switch (args.Trigger) { @@ -109,7 +115,9 @@ private void ActivityResultReceived(ActivityData activityData) NotificationAdapter.AcknowledgeAll(this, activityData); if (!_runningTimers.TryGetValue(activityData, out var timer)) + { return; + } ParallelOperations.StopExecution(timer); _runningTimers.Remove(activityData); diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/FailurePredictor.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/FailurePredictor.cs index 064a5b0e78..cfac5cb945 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/FailurePredictor.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/FailurePredictor.cs @@ -79,7 +79,9 @@ private void MonitorProcess(ProcessData processData) { // Only monitor production jobs if (!(processData.Recipe is IProductRecipe)) + { return; + } var recipe = (IWorkplanRecipe)processData.Recipe; if (!_predictorCache.TryGetValue(recipe.Id, out var cachedPredictor)) @@ -97,7 +99,10 @@ private void CleanUp(ProcessData process) { var recipe = process.Recipe; if (!_predictorCache.TryGetValue(recipe.Id, out var predictor) || !predictor.Remove(process.Engine) || predictor.MonitoredEngines > 0) + { return; + } + predictor.Dispose(); _predictorCache.Remove(recipe.Id); } @@ -108,7 +113,9 @@ private void OnPathPrediction(object sender, PathPredictionEventArgs predictionE var processData = ActivityPool.GetProcess(processContext.Process); if (predictionEventArgs.PredictedOutcome == NodeClassification.Failed) + { ProcessWillFail?.Invoke(this, processData); + } } public event EventHandler ProcessWillFail; diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessArchive.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessArchive.cs index bb5392c4c8..3149f49b98 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessArchive.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessArchive.cs @@ -62,8 +62,8 @@ public async Task> GetProcesses(ProductInstance productIn var processRepo = uow.GetRepository(); var query = (from processEntity in processRepo.Linq - where processEntity.ReferenceId == productInstance.Id - select new { processEntity.Id, processEntity.Job.RecipeId }).ToList(); // TODO use ToListAsync and fix tests + where processEntity.ReferenceId == productInstance.Id + select new { processEntity.Id, processEntity.Job.RecipeId }).ToList(); // TODO use ToListAsync and fix tests var processes = new List(); foreach (var match in query) @@ -123,7 +123,9 @@ public async IAsyncEnumerable GetProcesses(ProcessRequestFilter f using var uow = UnitOfWorkFactory.Create(); var relevantJobs = GetJobs(uow, filterType, start, end, jobIds); if (relevantJobs.Count == 0) + { yield break; + } foreach (var relevantJob in relevantJobs) { @@ -145,11 +147,17 @@ private IReadOnlyList GetJobs(IUnitOfWork uow, ProcessRequestFilter f var all = jobRepo.Linq.Where(j => j.RecipeProvider == ProductManagement.Name); // Filter only production jobs if (filterType.HasFlag(ProcessRequestFilter.Jobs)) + { all = all.Where(j => ((IEnumerable)jobIds).Contains(j.Id)); + } + if (filterType.HasFlag(ProcessRequestFilter.Timed)) + { all = all.Where(job => job.Created >= start && job.Created <= end // Job began within the time frame || job.Updated >= start && job.Updated <= end // Job changed within the time frame || job.Created <= start && job.Updated >= end); // Job exceeds time frame + } + return all.ToList(); } @@ -167,13 +175,13 @@ private async Task GetFromStorage(IUnitOfWork uow, JobEntity jobE // Fetch all relevant processes for this job // This looks like partial Copy&Paste, but we need to optimize the s**t out of this var query = (from processEntity in processRepo.Linq - where processEntity.State >= (int)ProcessState.Success && processEntity.JobId == job.Id && processEntity.Activities.Any() - let firstActivity = processEntity.Activities.OrderBy(a => a.Started).FirstOrDefault() - let lastActivity = processEntity.Activities.OrderByDescending(a => a.Started).FirstOrDefault() - where firstActivity.Started >= start && firstActivity.Started <= end // Process started in the time frame - || lastActivity.Completed >= start && lastActivity.Completed <= end // Process ended in the time frame - || firstActivity.Started <= start && lastActivity.Completed >= end // Process spans over time frame - select new { processEntity.Id, processEntity.ReferenceId }).ToList(); // TODO use ToListAsync and fix tests + where processEntity.State >= (int)ProcessState.Success && processEntity.JobId == job.Id && processEntity.Activities.Any() + let firstActivity = processEntity.Activities.OrderBy(a => a.Started).FirstOrDefault() + let lastActivity = processEntity.Activities.OrderByDescending(a => a.Started).FirstOrDefault() + where firstActivity.Started >= start && firstActivity.Started <= end // Process started in the time frame + || lastActivity.Completed >= start && lastActivity.Completed <= end // Process ended in the time frame + || firstActivity.Started <= start && lastActivity.Completed >= end // Process spans over time frame + select new { processEntity.Id, processEntity.ReferenceId }).ToList(); // TODO use ToListAsync and fix tests var processes = new Process[query.Count]; // Prepare fake process and task map @@ -223,7 +231,9 @@ public JobDataChunk(IProductionJobData jobData, DateTime start, DateTime end) private IProductionJobData TryGetJob() { if (_jobData.TryGetTarget(out var job)) + { return job; + } throw new ObjectDisposedException("Target of the chunk has been disposed."); } @@ -272,8 +282,9 @@ public bool MoveNext() _currentProcess = _processes[_currentIndex]; if (_currentProcess.Completed >= _start && _currentProcess.Started <= _end) + { return true; - + } } _currentProcess = null; diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessController.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessController.cs index 504eea6536..0f5244d5bb 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessController.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessController.cs @@ -130,4 +130,4 @@ public void Resume(IEnumerable processes) } public event EventHandler ProcessChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessInterruption.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessInterruption.cs index 5c6252dfe9..c473889e8f 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessInterruption.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessInterruption.cs @@ -97,7 +97,9 @@ private void OnProcessChanged(object sender, ProcessEventArgs args) private void OnActivityChanged(object sender, ActivityEventArgs args) { if (args.Trigger != ActivityState.Completed) + { return; + } var activityData = args.ActivityData; var processData = activityData.ProcessData; @@ -110,7 +112,9 @@ private void OnActivityChanged(object sender, ActivityEventArgs args) private void ValidateStableState(ProcessState trigger, ProcessData processData) { if (trigger != ProcessState.Stopping) + { return; + } var activities = processData.Activities; @@ -126,9 +130,13 @@ private void ValidateStableState(ProcessState trigger, ProcessData processData) { // Check if process has any progress worth saving if (activities.Any(a => a.State >= ActivityState.Running)) + { ActivityPool.UpdateProcess(processData, ProcessState.Interrupted); + } else + { ActivityPool.UpdateProcess(processData, ProcessState.Discarded); + } } } @@ -141,7 +149,9 @@ private long TimeoutCalculation() { // Use manual timeout if (Config.TimeoutCalculation == TimeoutCalculationType.Manual) + { return Config.ManualShutdownTimeoutSec * 1000; + } // Fetch sample size and their execution times from db IList executionTimes; @@ -149,23 +159,25 @@ private long TimeoutCalculation() { var activityRepo = uow.GetRepository(); executionTimes = (from activity in activityRepo.Linq - where activity.Result != null - orderby activity.Id descending - // This is not fully correct, but faster then ordering by timestamp - select new { activity.Completed, activity.Started }) + where activity.Result != null + orderby activity.Id descending + // This is not fully correct, but faster then ordering by timestamp + select new { activity.Completed, activity.Started }) .Take(Config.SampleSize).ToList() .Select(diff => (diff.Completed.Value - diff.Started.Value).TotalMilliseconds).ToList(); } // If there are no activities yet we use manual value as well if (!executionTimes.Any()) + { return Config.ManualShutdownTimeoutSec * 1000; + } // Calculate average and sigma range var averageTime = executionTimes.Average(); var derivation = (from executionTime in executionTimes - let diff = averageTime - executionTime - select diff * diff).Average(); + let diff = averageTime - executionTime + select diff * diff).Average(); var deviation = Math.Sqrt(derivation); var timeout = averageTime; @@ -186,4 +198,4 @@ orderby activity.Id descending return (long)timeout; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessRemoval.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessRemoval.cs index c908a5fcc6..5194786fe7 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessRemoval.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ProcessRemoval.cs @@ -129,7 +129,9 @@ private void CheckProcessAborted(ProcessData processData) // If there are no more open activities, the process can be removed var openActivities = ActivityPool.GetAllOpen(processData); if (openActivities.Count == 0) + { ActivityPool.UpdateProcess(processData, ProcessState.RemoveBroken); + } } private void HandleRemoval(ProcessData processData) @@ -213,11 +215,11 @@ private void OnProcessRemoved(object sender, Process process) private static bool RequiresUnmount(ProcessData process) { var lastAction = (from activity in process.Activities - where activity.State >= ActivityState.Completed && activity.Activity is IMountingActivity - let action = ((IMountingActivity)activity.Activity).Operation - where action != MountOperation.Unchanged - orderby activity.Tracing.Completed descending - select action).FirstOrDefault(); + where activity.State >= ActivityState.Completed && activity.Activity is IMountingActivity + let action = ((IMountingActivity)activity.Activity).Operation + where action != MountOperation.Unchanged + orderby activity.Tracing.Completed descending + select action).FirstOrDefault(); return lastAction == MountOperation.Mount; } @@ -267,4 +269,4 @@ public void Completed(ActivityResult result) // This method is not of interest for us } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ResourceAssignment.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ResourceAssignment.cs index abb41ce42a..3ca3c2b4aa 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ResourceAssignment.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/ResourceAssignment.cs @@ -130,9 +130,13 @@ private void OnActivityAdded(object sender, ActivityEventArgs args) { var activityData = args.ActivityData; if (args.Trigger == ActivityState.Initial) + { AssignAndUpdateActivity(activityData); + } else if (args.Trigger == ActivityState.ResultReceived) + { activityData.Targets = ActivityData.EmptyTargets; + } } private void OnProcessChanged(object sender, ProcessEventArgs e) @@ -141,7 +145,9 @@ private void OnProcessChanged(object sender, ProcessEventArgs e) { // Restore cell on completed activities foreach (var completedActivity in e.ProcessData.Activities.Where(a => a.State == ActivityState.Completed)) + { completedActivity.Resource = ResourceManagement.GetResource(completedActivity.Resource.Id); + } } else if (e.Trigger >= ProcessState.Interrupted) { @@ -186,7 +192,9 @@ private void OnCapabilitiesChanged(object sender, ICapabilities changedCapabilit { // Check if the sender was a sell if (sender is not ICell cell) + { return; + } // Update possible resources for non-running activities var openActivities = ActivityPool.GetAllOpen(); @@ -263,7 +271,9 @@ private void OnResourceRemoved(object sender, IResource resource) { // Check if the sender was a sell if (resource is not ICell cell) + { return; + } // Update possible resources for non-running activities var openActivities = ActivityPool.GetAllOpen(); @@ -289,12 +299,16 @@ public void Acknowledge(Notification notification, object tag) { var activityData = tag as ActivityData; if (activityData == null) + { return; + } // Check if activity has a target before accepting the acknowledgement if (activityData.Resource is null // Check whether assignement was already successful && activityData.Targets.Count == 0) // Check whether assignement could now be done successfully + { return; + } NotificationAdapter.Acknowledge(this, notification); } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/StorageTrigger.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/StorageTrigger.cs index 578969f4a2..2360f3136b 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/StorageTrigger.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/Implementation/StorageTrigger.cs @@ -80,19 +80,28 @@ private void OnProcessChanged(object sender, ProcessEventArgs args) { case ProcessState.Ready: if (processData.Process is ProductionProcess prodProcess) + { prodProcess.ProductInstance = ((IProductRecipe)prodProcess.Recipe).Target.CreateInstance(); + } + break; case ProcessState.CleaningUp: case ProcessState.Restored: if (processData.Process is ProductionProcess) + { ParallelOperations.ExecuteParallel(LoadProductInstance, processData); + } + break; case ProcessState.Interrupted: // Interrupted processes are saved synchronous for secure shutdown ProcessStorage.SaveProcess(args.ProcessData); // Save instances if existing and configured if (ModuleConfig.SaveInstancesOnInterrupt && (processData.Process as ProductionProcess)?.ProductInstance?.Id > 0) + { ParallelOperations.ExecuteParallel(SaveInstance, processData); + } + break; case ProcessState.Success: case ProcessState.Failure: @@ -100,7 +109,10 @@ private void OnProcessChanged(object sender, ProcessEventArgs args) ParallelOperations.ExecuteParallel(ProcessStorage.SaveProcess, args.ProcessData); //Only update the instance if it exists and is not just a prepared object if ((processData.Process as ProductionProcess)?.ProductInstance?.Id > 0) + { ParallelOperations.ExecuteParallel(SaveInstance, processData); + } + break; } } @@ -112,14 +124,18 @@ private void OnActivityChanged(object sender, ActivityEventArgs args) { // Only completed activities can change an article if (args.Trigger != ActivityState.ResultReceived) + { return; + } var activityData = args.ActivityData; var processData = activityData.ProcessData; // We are only interested in IArticleModificationActivities on ProductionProcesses if (activityData.ProcessData.Process is ProductionProcess && activityData.Activity is IInstanceModificationActivity activity) + { ProcessArticleModification(activityData, processData, activity); + } SaveCompletedActivity(processData, activityData); @@ -139,7 +155,9 @@ private void SaveCompletedActivity(ProcessData processData, ActivityData activit { // Someone else is creating/created the process if (processData.EntityCreated || _creatingProcesses.Contains(processData)) + { continue; + } // We create the process _creatingProcesses.Add(processData); @@ -197,15 +215,23 @@ private void LoadProductInstance(ProcessData processData) { var prodProcess = (ProductionProcess)processData.Process; if (processData.ReferenceId > 0) // Only load article if the process already has one! + { prodProcess.ProductInstance = ProductManagement.LoadInstanceAsync(processData.ReferenceId).GetAwaiter().GetResult(); + } else // Otherwise provide a prepared, unsaved instance + { prodProcess.ProductInstance = ((IProductRecipe)prodProcess.Recipe).Target.CreateInstance(); + } // Signal process ready for execution if (processData.State == ProcessState.Restored) + { ActivityPool.UpdateProcess(processData, ProcessState.RestoredReady); + } else if (processData.State == ProcessState.CleaningUp) + { ActivityPool.UpdateProcess(processData, ProcessState.CleaningUpReady); + } } /// diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessData.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessData.cs index 8d46c5d442..b61d51e813 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessData.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessData.cs @@ -101,9 +101,13 @@ public ProcessState State // Update Start and End when altering the process state if (field == ProcessState.Running) + { Started = Activities.FirstOrDefault()?.Tracing.Started ?? DateTime.Now; + } else if (field >= ProcessState.Success) + { Completed = Activities.LastOrDefault()?.Tracing.Completed ?? DateTime.Now; + } } } @@ -129,7 +133,9 @@ public ProcessState State public void AddActivity(ActivityData activity) { lock (_activities) + { _activities.Add(activity); + } } /// @@ -143,7 +149,9 @@ public void AddActivity(ActivityData activity) public int ActivityCount(Func predicate) { lock (_activities) + { return _activities.Count(predicate); + } } /// @@ -154,7 +162,9 @@ public IReadOnlyList Activities get { lock (_activities) + { return _activities.ToArray(); + } } } @@ -184,11 +194,20 @@ public bool Equals(ProcessData other) public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) + { return false; + } + if (ReferenceEquals(this, obj)) + { return true; + } + if (obj.GetType() != this.GetType()) + { return false; + } + return Equals((ProcessData)obj); } @@ -196,4 +215,4 @@ public override int GetHashCode() { return Id.GetHashCode(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessState.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessState.cs index 177e9214a6..279d699782 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessState.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessState.cs @@ -84,4 +84,4 @@ public enum ProcessState /// Flag if process execution created a negative result /// Failure = 4500 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessStorage.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessStorage.cs index 2041ea07cd..3d25959ef0 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessStorage.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/ProcessStorage.cs @@ -61,14 +61,18 @@ public void Start() { // Check if entity and type represent the same tracing if (entity.NameSpace != tracingType.Namespace || entity.Classname != tracingType.Name) + { return false; + } tracingWrapper.Id = entity.Id; return true; }); if (isEntityExisting) + { continue; + } var typeEntity = typeRepo.Create(tracingType.Assembly.GetName().Name, tracingType.Namespace, tracingType.Name); uow.LinkEntityToBusinessObject(tracingWrapper, typeEntity); @@ -99,16 +103,16 @@ public IReadOnlyList GetRunningProcesses(IUnitOfWork uow, IJobData }).ToList(); return (from dbProcess in dbProcesses - let process = job.Recipe.CreateProcess() - select new ProcessData(process) - { - Id = dbProcess.Id, - Recipe = job.Recipe, - EntityCreated = true, - Rework = dbProcess.Rework, - ReferenceId = dbProcess.ReferenceId, - ActivityIndex = (int)IdShiftGenerator.ExtractChild(dbProcess.MaxIndex) + 1, - }).ToList(); + let process = job.Recipe.CreateProcess() + select new ProcessData(process) + { + Id = dbProcess.Id, + Recipe = job.Recipe, + EntityCreated = true, + Rework = dbProcess.Rework, + ReferenceId = dbProcess.ReferenceId, + ActivityIndex = (int)IdShiftGenerator.ExtractChild(dbProcess.MaxIndex) + 1, + }).ToList(); } /// @@ -142,9 +146,13 @@ public void LoadCompletedProcesses(IUnitOfWork uow, IJobData jobData, ICollectio if (process is ProductionProcess prodProcess) { if (processData.ReferenceId > 0) // Only load article if the process already has one! + { prodProcess.ProductInstance = ProductManagement.LoadInstanceAsync(processData.ReferenceId).GetAwaiter().GetResult(); + } else // Otherwise provide a prepared, unsaved instance + { prodProcess.ProductInstance = ((IProductRecipe)prodProcess.Recipe).Target.CreateInstance(); + } } // Restore activities from workflow @@ -153,7 +161,9 @@ public void LoadCompletedProcesses(IUnitOfWork uow, IJobData jobData, ICollectio .Select(step => step.CreateInstance(context)) .OfType().ToDictionary(task => task.Id, task => task); foreach (var activityData in LoadCompletedActivities(uow, processData, taskMap)) + { processData.AddActivity(activityData); + } allProcesses.Add(processData); } @@ -202,7 +212,9 @@ public void TryReloadRunningActivity(long processId, ActivityData activityData) var configured = activityRepo.GetRunning(processId); var match = configured.FirstOrDefault(ae => ae.TaskId == activityData.Task.Id); if (match == null) + { return; + } activityData.Id = match.Id; activityData.EntityCreated = true; @@ -265,11 +277,15 @@ public Tracing LoadTracing(ActivityEntity activityEntity) // Process holder tracing if (tracing is ProcessHolderTracing processHolderTracing) + { processHolderTracing.HolderId = activityEntity.ProcessHolderId ?? -1; + } // Load extended properties from JSON if there is any if (activityEntity.TracingData?.Length > 2) + { JsonConvert.PopulateObject(activityEntity.TracingData, tracing); + } return tracing; } @@ -378,7 +394,9 @@ private void SaveActivity(IUnitOfWork uow, ActivityData activity // Only set the other values for completed activities if (activityData.Result == null) + { return; + } // Save result var activityResult = activity.Result; @@ -406,23 +424,36 @@ private void SaveTracing(Activity source, ActivityEntity target) // Process holder tracing data if (source.Tracing is ProcessHolderTracing processHolderTracing) + { target.ProcessHolderId = processHolderTracing.HolderId; + } // Extended tracing data var json = JsonConvert.SerializeObject(source.Tracing, JsonSettings.Minimal); if (json.Length > 2) + { target.TracingData = json; + } } private static DateTime? ConvertToUtc(DateTime? dateTime) { - if (dateTime == null) return null; + if (dateTime == null) + { + return null; + } var nonNullDateTime = (DateTime)dateTime; if (nonNullDateTime.Kind == DateTimeKind.Utc) + { return nonNullDateTime; + } + if (nonNullDateTime.Kind == DateTimeKind.Local) + { return TimeZoneInfo.ConvertTimeToUtc(nonNullDateTime, TimeZoneInfo.Local); + } + throw new ArgumentException($"Provided {nameof(DateTime)} is neither UTC nor Local Time."); } diff --git a/src/Moryx.ControlSystem.ProcessEngine/Processes/ResourceAndSession.cs b/src/Moryx.ControlSystem.ProcessEngine/Processes/ResourceAndSession.cs index f986b6275e..7f64a8339c 100644 --- a/src/Moryx.ControlSystem.ProcessEngine/Processes/ResourceAndSession.cs +++ b/src/Moryx.ControlSystem.ProcessEngine/Processes/ResourceAndSession.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.Cells; namespace Moryx.ControlSystem.ProcessEngine.Processes; @@ -32,36 +31,52 @@ public bool MatchesActivity(ActivityData activityData) { // Dispatch only configured or running activities if (activityData.State < ActivityState.Configured || activityData.State > ActivityState.Running) + { return false; + } // Only redeliver running activities if they refer to a process if (activityData.State >= ActivityState.Running && Session.Reference.IsEmpty) + { return false; + } // Do not dispatch activities for incomplete or stopping processes if (activityData.ProcessData.State < ProcessState.EngineStarted || activityData.ProcessData.State >= ProcessState.Stopping) + { return false; + } // Make sure activity can run in this resource if (activityData.Targets.All(possible => possible != Resource)) + { return false; + } // Check if session accepts the classification var activity = activityData.Activity; if ((activityData.Classification & Session.AcceptedClassification) == 0) + { return false; + } // If a reference is given, it must match the activities process if (Session.Reference.HasReference && !Session.Reference.Matches(activity.Process)) + { return false; + } if (Session.Reference.IsEmpty && activity.ProcessRequirement == ProcessRequirement.Required) + { return false; + } // Validate the constraints on the rtw with the activity. var constraintContext = new ActivityConstraintContext(activity); if (ReadyToWork?.Constraints.Any(c => !c.Check(constraintContext)) == true) + { return false; + } // If we made it here, all conditions are met return true; @@ -77,4 +92,4 @@ public bool Equals(ResourceAndSession other) && Session.AcceptedClassification == other.Session.AcceptedClassification && Session.Reference == other.Session.Reference; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/EventHandlers/ProcessHolderEventHandlers.cs b/src/Moryx.ControlSystem.Processes.Endpoints/EventHandlers/ProcessHolderEventHandlers.cs index 29b443e440..fab5ff6b21 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/EventHandlers/ProcessHolderEventHandlers.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/EventHandlers/ProcessHolderEventHandlers.cs @@ -7,7 +7,7 @@ namespace Moryx.ControlSystem.Processes.Endpoints.EventHandlers; -internal class ProcessHolderEventHandlers +internal sealed class ProcessHolderEventHandlers { public static EventHandler OnResourceRemoved(EventHandler processChanged, EventHandler groupChanged) { diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/ActivityResourceModel.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/ActivityResourceModel.cs index 8e210aa85c..5cd50e7a9e 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/ActivityResourceModel.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/ActivityResourceModel.cs @@ -13,4 +13,4 @@ public class ActivityResourceModel [DataMember] public string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/Converter.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/Converter.cs index 576de27c3c..d8cef2ce48 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/Converter.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/Converter.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Resources; -using Moryx.ControlSystem.Activities; -using Moryx.Serialization; using System.Reflection; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; +using Moryx.AbstractionLayer.Resources; +using Moryx.ControlSystem.Activities; +using Moryx.Serialization; namespace Moryx.ControlSystem.Processes.Endpoints; @@ -35,13 +35,21 @@ internal static JobProcessModel ConvertProcess(Process process, IProcessControl private static ProcessProgress InferProcessState(List activities) { if (activities == null || activities.Count == 0) + { return ProcessProgress.Ready; + } else if (activities.All(a => a.Tracing.Completed != null)) + { return ProcessProgress.Completed; + } else if (activities.Any(a => a.Tracing.Started != null)) + { return ProcessProgress.Running; + } else + { return ProcessProgress.Ready; + } } /// @@ -87,20 +95,31 @@ private static string InferResultName(Activity activity, long? resultNumber) private static ActivityClassification InferActivityClassification(Activity activity) { if (activity.Process is ProductionProcess) + { return ActivityClassification.Production; + } else if (activity is IControlSystemActivity controlActivity) + { return controlActivity.Classification; + } + return ActivityClassification.Unknown; } private static string InferActivityState(Activity activity) { if (activity.Result != null) + { return nameof(ActivityProgress.Completed); + } else if (activity.Tracing?.Started != null) + { return nameof(ActivityProgress.Running); + } else + { return nameof(ActivityProgress.Ready); + } } internal static TracingModel ConvertTracing(Tracing tracing) => new() diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/JobProcessModel.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/JobProcessModel.cs index 5f3b256a21..7a448b4a77 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/JobProcessModel.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/JobProcessModel.cs @@ -31,4 +31,4 @@ public class JobProcessModel [DataMember] public bool IsRunning { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/ProcessActivityModel.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/ProcessActivityModel.cs index 271849db0d..d2684c39f5 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/ProcessActivityModel.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/ProcessActivityModel.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.ControlSystem.Activities; using System.Runtime.Serialization; +using Moryx.ControlSystem.Activities; namespace Moryx.ControlSystem.Processes.Endpoints; @@ -44,4 +44,4 @@ public class ProcessActivityModel [DataMember] public bool IsCompleted { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingModel.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingModel.cs index a6263f74a6..5950741b58 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingModel.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingModel.cs @@ -26,4 +26,4 @@ public class TracingModel [DataMember] public Entry Properties { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingSerialization.cs b/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingSerialization.cs index e87e84e056..3284b77be6 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingSerialization.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/Models/TracingSerialization.cs @@ -17,4 +17,4 @@ public override IEnumerable GetProperties(Type sourceType) // Only simple properties not defined in the base return base.GetProperties(sourceType).Where(p => !filteredProperties.Contains(p.Name)); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/ProcessPermissions.cs b/src/Moryx.ControlSystem.Processes.Endpoints/ProcessPermissions.cs index 8a2ca22eb2..3023488f75 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/ProcessPermissions.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/ProcessPermissions.cs @@ -7,4 +7,4 @@ public static class ProcessPermissions { private const string _prefix = "Moryx.Processes."; public const string CanView = _prefix + "CanView"; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Processes.Endpoints/StreamServices/ProcessHolderGroupStream.cs b/src/Moryx.ControlSystem.Processes.Endpoints/StreamServices/ProcessHolderGroupStream.cs index eb832021dc..8f94ee381b 100644 --- a/src/Moryx.ControlSystem.Processes.Endpoints/StreamServices/ProcessHolderGroupStream.cs +++ b/src/Moryx.ControlSystem.Processes.Endpoints/StreamServices/ProcessHolderGroupStream.cs @@ -13,7 +13,7 @@ namespace Moryx.ControlSystem.Processes.Endpoints.StreamServices; /// /// Provides the streaming functionality for the process holder Group /// -internal class ProcessHolderGroupStream(IResourceManagement resourceManagement) +internal sealed class ProcessHolderGroupStream(IResourceManagement resourceManagement) { private static readonly JsonSerializerOptions _serializerOptions = new() { diff --git a/src/Moryx.ControlSystem.SetupProvider/Components/ISetupManager.cs b/src/Moryx.ControlSystem.SetupProvider/Components/ISetupManager.cs index 189e013f53..18fca82569 100644 --- a/src/Moryx.ControlSystem.SetupProvider/Components/ISetupManager.cs +++ b/src/Moryx.ControlSystem.SetupProvider/Components/ISetupManager.cs @@ -11,4 +11,4 @@ namespace Moryx.ControlSystem.SetupProvider; internal interface ISetupManager : IPlugin { SetupRecipe RequiredSetup(SetupExecution execution, ProductionRecipe recipe, ISetupTarget targetSystem); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.SetupProvider/Components/ISetupTriggerFactory.cs b/src/Moryx.ControlSystem.SetupProvider/Components/ISetupTriggerFactory.cs index bf8983e39a..c3f1e069eb 100644 --- a/src/Moryx.ControlSystem.SetupProvider/Components/ISetupTriggerFactory.cs +++ b/src/Moryx.ControlSystem.SetupProvider/Components/ISetupTriggerFactory.cs @@ -21,4 +21,4 @@ internal interface ISetupTriggerFactory /// Destroy a setup trigger instance /// void Destroy(ISetupTrigger instance); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.SetupProvider/Facades/SetupProviderFacade.cs b/src/Moryx.ControlSystem.SetupProvider/Facades/SetupProviderFacade.cs index f334f72595..92099afe9f 100644 --- a/src/Moryx.ControlSystem.SetupProvider/Facades/SetupProviderFacade.cs +++ b/src/Moryx.ControlSystem.SetupProvider/Facades/SetupProviderFacade.cs @@ -48,10 +48,10 @@ public SetupRecipe RequiredSetup(SetupExecution execution, ProductionRecipe reci ValidateHealthState(); var setup = SetupManager.RequiredSetup(execution, recipe, targetSystem); - if (setup != null) - setup.Origin = this; + setup?.Origin = this; + return setup; } public event EventHandler RecipeChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.SetupProvider/Implementation/SetupManager.cs b/src/Moryx.ControlSystem.SetupProvider/Implementation/SetupManager.cs index 1bd3f6ec91..b04915b84b 100644 --- a/src/Moryx.ControlSystem.SetupProvider/Implementation/SetupManager.cs +++ b/src/Moryx.ControlSystem.SetupProvider/Implementation/SetupManager.cs @@ -254,7 +254,7 @@ private static void WireWorkplan(Workplan workplan, IDictionary [DataMember, PluginConfigs(typeof(ISetupTrigger))] public List SetupTriggers { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.SetupProvider/ModuleController/ModuleConsole.cs b/src/Moryx.ControlSystem.SetupProvider/ModuleController/ModuleConsole.cs index 5b423abd85..3eda6a7966 100644 --- a/src/Moryx.ControlSystem.SetupProvider/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ControlSystem.SetupProvider/ModuleController/ModuleConsole.cs @@ -9,7 +9,7 @@ namespace Moryx.ControlSystem.SetupProvider; internal class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Simulator/Components/IProcessSimulator.cs b/src/Moryx.ControlSystem.Simulator/Components/IProcessSimulator.cs index 9ad89c0c2a..b2e4460c89 100644 --- a/src/Moryx.ControlSystem.Simulator/Components/IProcessSimulator.cs +++ b/src/Moryx.ControlSystem.Simulator/Components/IProcessSimulator.cs @@ -7,4 +7,4 @@ namespace Moryx.ControlSystem.Simulator; internal interface IProcessSimulator : IPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Simulator/Extensions/ConcurrentDictionaryExtensions.cs b/src/Moryx.ControlSystem.Simulator/Extensions/ConcurrentDictionaryExtensions.cs index 91e659d5e4..160e666f30 100644 --- a/src/Moryx.ControlSystem.Simulator/Extensions/ConcurrentDictionaryExtensions.cs +++ b/src/Moryx.ControlSystem.Simulator/Extensions/ConcurrentDictionaryExtensions.cs @@ -1,9 +1,7 @@ -// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 -using System; using System.Collections.Concurrent; -using System.Threading.Tasks; -using System.Threading; namespace Moryx.Simulation.Simulator.Extensions; diff --git a/src/Moryx.ControlSystem.Simulator/Implementation/ProcessMovement.cs b/src/Moryx.ControlSystem.Simulator/Implementation/ProcessMovement.cs index e99e131b52..96476ad777 100644 --- a/src/Moryx.ControlSystem.Simulator/Implementation/ProcessMovement.cs +++ b/src/Moryx.ControlSystem.Simulator/Implementation/ProcessMovement.cs @@ -20,4 +20,4 @@ internal class ProcessMovement public DateTime Started { get; set; } public TimeSpan Duration { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.Simulator/Implementation/ProcessSimulator.cs b/src/Moryx.ControlSystem.Simulator/Implementation/ProcessSimulator.cs index 3272210702..7f7c46c810 100644 --- a/src/Moryx.ControlSystem.Simulator/Implementation/ProcessSimulator.cs +++ b/src/Moryx.ControlSystem.Simulator/Implementation/ProcessSimulator.cs @@ -1,6 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Collections.Concurrent; using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; @@ -14,7 +15,6 @@ using Moryx.Simulation.Simulator.Extensions; using Moryx.Threading; using Moryx.Tools; -using System.Collections.Concurrent; namespace Moryx.ControlSystem.Simulator.Implementation; @@ -46,7 +46,6 @@ internal sealed class ProcessSimulator : IProcessSimulator #endregion - public void Start() { _running = true; @@ -69,9 +68,13 @@ public void Start() foreach (var activity in activities) { if (activity.Tracing.Started == null) + { ActivityReady(activity); + } else + { ActivityRunning(activity); + } } } @@ -82,7 +85,9 @@ private void SimulationStateChanged(object sender, SimulationState newState) var runningProcesses = ProcessControl.GetRunningProcesses().ToList(); if (newState == SimulationState.Offline || newState > SimulationState.Idle) + { return; + } Activity nextActivity; lock (_scheduledMovements) @@ -104,7 +109,10 @@ private void SimulationStateChanged(object sender, SimulationState newState) .FirstOrDefault(pair => pair.Index >= 0 && pair.Activity != null)?.Activity; } - if (nextActivity is null) return; + if (nextActivity is null) + { + return; + } SimulateReady(driver, nextActivity); } @@ -301,7 +309,9 @@ private void ActivityRunning(Activity activity) private int CalculateExecutionTime(Activity activity) { if (activity.Parameters is ISimulationParameters simulationParameters) + { return (int)(simulationParameters.ExecutionTime.TotalMilliseconds / Config.Acceleration); + } var settings = Config.SpecificExecutionTimeSettings.Where(s => s.Activity.Equals(activity.GetType().FullName)); if (!settings.Any()) @@ -312,11 +322,15 @@ private int CalculateExecutionTime(Activity activity) var resourceId = activity.Tracing.ResourceId; var specificSetting = settings.FirstOrDefault(s => s.CellId == resourceId); if (specificSetting != null) + { return (int)(specificSetting.ExecutionTime / Config.Acceleration); + } specificSetting = settings.FirstOrDefault(s => s.CellId == 0); if (specificSetting != null) + { return (int)(specificSetting.ExecutionTime / Config.Acceleration); + } return (int)(Config.DefaultExecutionTime / Config.Acceleration); } diff --git a/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleConsole.cs b/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleConsole.cs index e32c086c17..a2ffbdb910 100644 --- a/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleConsole.cs @@ -8,5 +8,5 @@ namespace Moryx.ControlSystem.Simulator; [ServerModuleConsole] public class ModuleConsole : IServerModuleConsole { - -} \ No newline at end of file + +} diff --git a/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleController.cs b/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleController.cs index 834e66b173..95d40a63b5 100644 --- a/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleController.cs +++ b/src/Moryx.ControlSystem.Simulator/ModuleController/ModuleController.cs @@ -1,13 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Resources; using Moryx.Configuration; using Moryx.Container; using Moryx.ControlSystem.Processes; using Moryx.Runtime.Modules; -using System.ComponentModel; namespace Moryx.ControlSystem.Simulator; diff --git a/src/Moryx.ControlSystem.Simulator/Properties/AssemblyInfo.cs b/src/Moryx.ControlSystem.Simulator/Properties/AssemblyInfo.cs index c1ed34b246..b8d847aa01 100644 --- a/src/Moryx.ControlSystem.Simulator/Properties/AssemblyInfo.cs +++ b/src/Moryx.ControlSystem.Simulator/Properties/AssemblyInfo.cs @@ -5,4 +5,4 @@ [assembly: InternalsVisibleTo("Makma.Controller.Tests")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -[assembly: InternalsVisibleTo("Moryx.Simulation.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Moryx.Simulation.Tests")] diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivity.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivity.cs index cbc8c06560..5fa24477e7 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivity.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivity.cs @@ -36,4 +36,4 @@ protected override ActivityResult CreateFailureResult() /// public abstract class AssembleActivity : AssembleActivity { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivityResult.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivityResult.cs index e9e2d42ddc..96536829b3 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivityResult.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleActivityResult.cs @@ -25,4 +25,4 @@ public enum AssembleActivityResult /// A technical failure occured /// TechnicalError = 2, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleParameters.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleParameters.cs index b58c334620..b6d65a89af 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleParameters.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleParameters.cs @@ -44,4 +44,4 @@ protected override void Populate(Process process, Parameters instance) var recipe = (IProductRecipe)process.Recipe; parameters.Product = recipe.Target; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupActivity.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupActivity.cs index d361e258a1..097ef0c7af 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupActivity.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupActivity.cs @@ -44,4 +44,4 @@ public class AssembleSetupActivity : AssembleSetupActivity public override ICapabilities RequiredCapabilities => Parameters.RequiredCapabilities; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupParameters.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupParameters.cs index 82e5f54e45..b1cb6d23bf 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupParameters.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupParameters.cs @@ -55,4 +55,4 @@ protected override void Populate(Process process, Parameters instance) parameters.PropertyName = PropertyName; parameters.Value = Value; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTask.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTask.cs index c9c132d5a4..51e4ec003c 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTask.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTask.cs @@ -11,4 +11,4 @@ namespace Moryx.ControlSystem.Assemble; /// public class AssembleSetupTask : TaskStep { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTrigger.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTrigger.cs index eb0301993b..0d130b8519 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTrigger.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTrigger.cs @@ -8,9 +8,9 @@ using Moryx.Container; using Moryx.ControlSystem.Capabilities; using Moryx.ControlSystem.Setups; -using Moryx.VisualInstructions; using Moryx.Modules; using Moryx.Tools; +using Moryx.VisualInstructions; using Moryx.Workplans; namespace Moryx.ControlSystem.Assemble; @@ -39,40 +39,52 @@ public override void Initialize(SetupTriggerConfig config) // Validate type and create constructor delegate if (string.IsNullOrWhiteSpace(Config.RequiredCapabilityType)) + { throw new NullReferenceException($"{nameof(AssembleSetupTriggerConfig.RequiredCapabilityType)} is null."); + } var requiredAssembleCapabilitiesType = ReflectionTool .GetPublicClasses(type => type.Name == Config.RequiredCapabilityType) .FirstOrDefault(); if (requiredAssembleCapabilitiesType == null) + { throw new InvalidConfigException(Config.RequiredCapabilityType, $"{nameof(AssembleSetupTriggerConfig.RequiredCapabilityType)} was not found."); + } _capabilitiesConstructor = ReflectionTool.ConstructorDelegate(requiredAssembleCapabilitiesType); ; // Validate property and create accessor if (string.IsNullOrWhiteSpace(Config.ValueSource)) + { throw new NullReferenceException($"{nameof(AssembleSetupTriggerConfig.ValueSource)} is null."); + } _sourceResolver = RecipeResolverFactory.Create(Config.ValueSource); if (string.IsNullOrWhiteSpace(Config.TargetPropertyName)) + { throw new NullReferenceException($"{nameof(AssembleSetupTriggerConfig.TargetPropertyName)} is null."); + } var targetProperty = requiredAssembleCapabilitiesType.GetProperty(Config.TargetPropertyName); if (targetProperty == null) + { throw new ArgumentException($"{nameof(AssembleSetupTriggerConfig.TargetPropertyName)} is not available in {Config.RequiredCapabilityType}."); + } // Make custom descriptor instance _descriptorAccessor = ReflectionTool.PropertyAccessor(targetProperty); // Only create resolve if config was valid if (!string.IsNullOrEmpty(Config.Instruction)) + { _instructionBinder = new VisualInstructionBinder([new VisualInstruction { Type = InstructionContentType.Text, Content = Config.Instruction }], RecipeResolverFactory); + } } /// diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTriggerConfig.cs b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTriggerConfig.cs index 86195d2b15..96db48e88d 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTriggerConfig.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/AssembleSetupTriggerConfig.cs @@ -53,4 +53,4 @@ public class AssembleSetupTriggerConfig : SetupTriggerConfig /// [DataMember, Description("Name of property within capability.")] public string TargetPropertyName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleActivity.cs b/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleActivity.cs index 11bdb650e2..3dbc01c643 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleActivity.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleActivity.cs @@ -10,4 +10,4 @@ namespace Moryx.ControlSystem.Assemble; /// public interface IAssembleActivity : IActivity { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleSetupActivity.cs b/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleSetupActivity.cs index 2fcf065bb5..e712dadab6 100644 --- a/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleSetupActivity.cs +++ b/src/Moryx.ControlSystem.TestTools.Assemble/IAssembleSetupActivity.cs @@ -10,4 +10,4 @@ namespace Moryx.ControlSystem.Assemble; /// public interface IAssembleSetupActivity : IControlSystemActivity { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityActivity.cs b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityActivity.cs index c2b1b24c6d..4f66786b7e 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityActivity.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityActivity.cs @@ -46,4 +46,4 @@ protected override ActivityResult CreateFailureResult() { return ActivityResult.Create(AssignIdentityResults.TechnicalFailure); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityParameters.cs b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityParameters.cs index 9615b2043e..b35091ced2 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityParameters.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityParameters.cs @@ -53,7 +53,9 @@ protected override void Populate(Process process, Parameters instance) var parameters = (AssignIdentityParameters)instance; if (_resolver == null && !string.IsNullOrWhiteSpace(TargetBinding)) + { _resolver = ResolverFactory.Create(TargetBinding); + } var target = _resolver?.Resolve(process) ?? (process as ProductionProcess)?.ProductInstance; @@ -63,4 +65,4 @@ protected override void Populate(Process process, Parameters instance) parameters.Amount = Amount; parameters.Source = Source; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityResults.cs b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityResults.cs index 4f6826f7cf..9f82b4d0fb 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityResults.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Identity/AssignIdentityResults.cs @@ -27,4 +27,4 @@ public enum AssignIdentityResults /// The activity could not be started at all. /// TechnicalFailure = 3 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Identity/IAssignIdentityParameters.cs b/src/Moryx.ControlSystem.TestTools/Activities/Identity/IAssignIdentityParameters.cs index c0f1b51c2b..c53eee47dd 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Identity/IAssignIdentityParameters.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Identity/IAssignIdentityParameters.cs @@ -30,4 +30,4 @@ public interface IAssignIdentityParameters : IParameters /// Target the Identity should be assigned to. /// object Target { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountActivity.cs b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountActivity.cs index 75a89ef790..65bff2a775 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountActivity.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountActivity.cs @@ -47,4 +47,4 @@ protected override ActivityResult CreateFailureResult() { return ActivityResult.Create(MountingResult.TechnicalFailure); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingParameters.cs b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingParameters.cs index b7c794f76a..6b4b781546 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingParameters.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingParameters.cs @@ -12,4 +12,4 @@ namespace Moryx.ControlSystem.TestTools.Activities; [DataContract] public class MountingParameters : VisualInstructionParameters { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingResult.cs b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingResult.cs index 2a3b1ad008..c89a09397f 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingResult.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/MountingResult.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.VisualInstructions; using System.ComponentModel.DataAnnotations; +using Moryx.VisualInstructions; namespace Moryx.ControlSystem.TestTools.Activities; @@ -21,4 +21,4 @@ public enum MountingResult /// The activity could not be started at all. /// TechnicalFailure = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountActivity.cs b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountActivity.cs index f85f608a88..70920b0c11 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountActivity.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountActivity.cs @@ -39,4 +39,4 @@ protected override ActivityResult CreateFailureResult() { return ActivityResult.Create(UnmountingResult.TechnicalFailure); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountingResult.cs b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountingResult.cs index 9579e99cf2..9827f7bd1e 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountingResult.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/Mounting/UnmountingResult.cs @@ -22,4 +22,4 @@ public enum UnmountingResult /// The activity could not be started at all. /// TechnicalFailure = 2 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanActivity.cs b/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanActivity.cs index 58ca0d54f1..ef5f94c432 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanActivity.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanActivity.cs @@ -34,4 +34,4 @@ protected override ActivityResult CreateFailureResult() { return ActivityResult.Create(false, Parameters.FailureResult); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanParameters.cs b/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanParameters.cs index 6ca017c6f4..71942c440b 100644 --- a/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanParameters.cs +++ b/src/Moryx.ControlSystem.TestTools/Activities/SubWorkplan/SubWorkplanParameters.cs @@ -49,4 +49,4 @@ protected SubWorkplanParameters(SubWorkplanParameters original) internal long FailureResult { get; set; } internal long SuccessResult { get; set; } // ------------------> -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Capabilities/AssembleCapabilities.cs b/src/Moryx.ControlSystem.TestTools/Capabilities/AssembleCapabilities.cs index 23d71726d9..6e8d767bc7 100644 --- a/src/Moryx.ControlSystem.TestTools/Capabilities/AssembleCapabilities.cs +++ b/src/Moryx.ControlSystem.TestTools/Capabilities/AssembleCapabilities.cs @@ -17,4 +17,4 @@ protected override bool ProvidedBy(ICapabilities provided) { return provided is AssembleCapabilities; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Capabilities/AssignIdentityCapabilities.cs b/src/Moryx.ControlSystem.TestTools/Capabilities/AssignIdentityCapabilities.cs index 7f6ee24578..10cd862a17 100644 --- a/src/Moryx.ControlSystem.TestTools/Capabilities/AssignIdentityCapabilities.cs +++ b/src/Moryx.ControlSystem.TestTools/Capabilities/AssignIdentityCapabilities.cs @@ -42,4 +42,4 @@ protected override bool ProvidedBy(ICapabilities provided) // Make sure all schemes are supported return casted != null && Schemes.All(casted.Schemes.Contains) && Source.HasFlag(casted.Source); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Capabilities/IdentitySource.cs b/src/Moryx.ControlSystem.TestTools/Capabilities/IdentitySource.cs index e5588ca9ee..0867bac88b 100644 --- a/src/Moryx.ControlSystem.TestTools/Capabilities/IdentitySource.cs +++ b/src/Moryx.ControlSystem.TestTools/Capabilities/IdentitySource.cs @@ -33,4 +33,4 @@ public enum IdentitySource /// Identity should be assigned by a camera (also manually) /// Scanner = 1 << 12, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Capabilities/MountCapabilities.cs b/src/Moryx.ControlSystem.TestTools/Capabilities/MountCapabilities.cs index ce178b87fd..f1c02348c2 100644 --- a/src/Moryx.ControlSystem.TestTools/Capabilities/MountCapabilities.cs +++ b/src/Moryx.ControlSystem.TestTools/Capabilities/MountCapabilities.cs @@ -47,7 +47,9 @@ protected override bool ProvidedBy(ICapabilities provided) { var capabilities = provided as MountCapabilities; if (capabilities == null) + { return false; + } if (CanMount && !capabilities.CanMount) { @@ -61,4 +63,4 @@ protected override bool ProvidedBy(ICapabilities provided) return true; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/DummyActivity.cs b/src/Moryx.ControlSystem.TestTools/DummyActivity.cs index 6aac36f45e..27f03e0034 100644 --- a/src/Moryx.ControlSystem.TestTools/DummyActivity.cs +++ b/src/Moryx.ControlSystem.TestTools/DummyActivity.cs @@ -65,4 +65,4 @@ public enum DummyResult /// The activity could not be started at all. /// TechnicalFailure -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/DummyRecipe.cs b/src/Moryx.ControlSystem.TestTools/DummyRecipe.cs index ad8a3b9d53..db65248fd9 100644 --- a/src/Moryx.ControlSystem.TestTools/DummyRecipe.cs +++ b/src/Moryx.ControlSystem.TestTools/DummyRecipe.cs @@ -89,9 +89,13 @@ private static IWorkplanStep BuildTaskStep(IWorkplanStep task, IConnector input, for (var i = 0; i < task.Outputs.Length; i++) { if (outputs.Length > i) + { task.Outputs[i] = outputs[i]; + } else + { task.Outputs[i] = outputs[outputs.Length - 1]; // Use last for all missing + } } return task; } @@ -104,4 +108,4 @@ public override IRecipe Clone() { return new DummyRecipe(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Identity/NumberingSchemeIdentity.cs b/src/Moryx.ControlSystem.TestTools/Identity/NumberingSchemeIdentity.cs index 4b0c2c73e9..60ff25d2cb 100644 --- a/src/Moryx.ControlSystem.TestTools/Identity/NumberingSchemeIdentity.cs +++ b/src/Moryx.ControlSystem.TestTools/Identity/NumberingSchemeIdentity.cs @@ -45,4 +45,4 @@ public int Scheme get => (int)NumberType; set => NumberType = (int)value; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Identity/TestNumberIdentity.cs b/src/Moryx.ControlSystem.TestTools/Identity/TestNumberIdentity.cs index 8f0dbba211..58e60ddc4a 100644 --- a/src/Moryx.ControlSystem.TestTools/Identity/TestNumberIdentity.cs +++ b/src/Moryx.ControlSystem.TestTools/Identity/TestNumberIdentity.cs @@ -14,4 +14,4 @@ public TestNumberIdentity(int numberType) : base(numberType) public TestNumberIdentity(int numberType, string identifier) : base(numberType, identifier) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Tasks/AssignIdentityTask.cs b/src/Moryx.ControlSystem.TestTools/Tasks/AssignIdentityTask.cs index c6dfea7d89..8b85bb4a9c 100644 --- a/src/Moryx.ControlSystem.TestTools/Tasks/AssignIdentityTask.cs +++ b/src/Moryx.ControlSystem.TestTools/Tasks/AssignIdentityTask.cs @@ -11,4 +11,4 @@ namespace Moryx.ControlSystem.TestTools.Tasks; /// public class AssignIdentityTask : TaskStep { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Tasks/MountTask.cs b/src/Moryx.ControlSystem.TestTools/Tasks/MountTask.cs index 1daab94d0c..afd84066f9 100644 --- a/src/Moryx.ControlSystem.TestTools/Tasks/MountTask.cs +++ b/src/Moryx.ControlSystem.TestTools/Tasks/MountTask.cs @@ -11,4 +11,4 @@ namespace Moryx.ControlSystem.TestTools.Tasks; /// public class MountTask : TaskStep { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Tasks/SubWorkplanTask.cs b/src/Moryx.ControlSystem.TestTools/Tasks/SubWorkplanTask.cs index 3b06fc2a1c..fad8cf080c 100644 --- a/src/Moryx.ControlSystem.TestTools/Tasks/SubWorkplanTask.cs +++ b/src/Moryx.ControlSystem.TestTools/Tasks/SubWorkplanTask.cs @@ -41,7 +41,9 @@ protected SubWorkplanTask(IWorkplan workplan) protected override TransitionBase Instantiate(IWorkplanContext context) { if (context.IsDisabled(this)) + { return new NullTransition(); + } // Lazy index resolver creation var indexResolver = _indexResolver ?? (_indexResolver = TransitionBase.CreateIndexResolver(OutputDescriptions)); @@ -66,4 +68,4 @@ protected virtual TParameters CreateParameters() FailureResult = failure.Id }; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem.TestTools/Tasks/UnmountTask.cs b/src/Moryx.ControlSystem.TestTools/Tasks/UnmountTask.cs index 604482235b..16280b8ce8 100644 --- a/src/Moryx.ControlSystem.TestTools/Tasks/UnmountTask.cs +++ b/src/Moryx.ControlSystem.TestTools/Tasks/UnmountTask.cs @@ -11,4 +11,4 @@ namespace Moryx.ControlSystem.TestTools.Tasks; /// public class UnmountTask : TaskStep { -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/ActivityClassification.cs b/src/Moryx.ControlSystem/Activities/ActivityClassification.cs index 68a2ce8da7..d863f49670 100644 --- a/src/Moryx.ControlSystem/Activities/ActivityClassification.cs +++ b/src/Moryx.ControlSystem/Activities/ActivityClassification.cs @@ -38,4 +38,4 @@ public enum ActivityClassification /// Activity performs a preparation, for example for a activity /// Preparation = 0x08, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/IActivityTimeoutParameters.cs b/src/Moryx.ControlSystem/Activities/IActivityTimeoutParameters.cs index 2b5e78a29a..21c966c096 100644 --- a/src/Moryx.ControlSystem/Activities/IActivityTimeoutParameters.cs +++ b/src/Moryx.ControlSystem/Activities/IActivityTimeoutParameters.cs @@ -14,4 +14,4 @@ public interface IActivityTimeoutParameters : IParameters /// Timeout in seconds for this activity /// int Timeout { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/IControlSystemActivity.cs b/src/Moryx.ControlSystem/Activities/IControlSystemActivity.cs index 40439abc2c..cbde683716 100644 --- a/src/Moryx.ControlSystem/Activities/IControlSystemActivity.cs +++ b/src/Moryx.ControlSystem/Activities/IControlSystemActivity.cs @@ -14,4 +14,4 @@ public interface IControlSystemActivity : IActivity /// The classification of this activity /// ActivityClassification Classification { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/IInstanceModificationActivity.cs b/src/Moryx.ControlSystem/Activities/IInstanceModificationActivity.cs index 4f79452067..2299351c48 100644 --- a/src/Moryx.ControlSystem/Activities/IInstanceModificationActivity.cs +++ b/src/Moryx.ControlSystem/Activities/IInstanceModificationActivity.cs @@ -21,4 +21,4 @@ public interface IInstanceModificationActivity : IActivity /// Modification that was performed on the product instance depending on the activities result /// InstanceModificationType ModificationType { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/IMountingActivity.cs b/src/Moryx.ControlSystem/Activities/IMountingActivity.cs index aaea44c8b3..e5d234b72c 100644 --- a/src/Moryx.ControlSystem/Activities/IMountingActivity.cs +++ b/src/Moryx.ControlSystem/Activities/IMountingActivity.cs @@ -35,4 +35,4 @@ public interface IMountingActivity : IActivity /// Operation this activity performs /// MountOperation Operation { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/InstanceModificationType.cs b/src/Moryx.ControlSystem/Activities/InstanceModificationType.cs index c413d50d5c..704f110dd6 100644 --- a/src/Moryx.ControlSystem/Activities/InstanceModificationType.cs +++ b/src/Moryx.ControlSystem/Activities/InstanceModificationType.cs @@ -24,4 +24,4 @@ public enum InstanceModificationType /// An instance was loaded and must be read from the database /// Loaded -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Activities/ProcessFixupActivity.cs b/src/Moryx.ControlSystem/Activities/ProcessFixupActivity.cs index bd4682b957..30a836199a 100644 --- a/src/Moryx.ControlSystem/Activities/ProcessFixupActivity.cs +++ b/src/Moryx.ControlSystem/Activities/ProcessFixupActivity.cs @@ -47,4 +47,4 @@ protected override ActivityResult CreateFailureResult() { return ActivityResult.Create(ProcessFixupResult.Fixed); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Capabilities/ProcessFixupCapapabilities.cs b/src/Moryx.ControlSystem/Capabilities/ProcessFixupCapapabilities.cs index d5e73b2d25..a2d86e6701 100644 --- a/src/Moryx.ControlSystem/Capabilities/ProcessFixupCapapabilities.cs +++ b/src/Moryx.ControlSystem/Capabilities/ProcessFixupCapapabilities.cs @@ -17,4 +17,4 @@ protected override bool ProvidedBy(ICapabilities provided) { return provided is ProcessFixupCapabilities; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs b/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs index 8dfd8a1975..e762aae99d 100644 --- a/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs +++ b/src/Moryx.ControlSystem/Cells/ActivityCompleted.cs @@ -30,4 +30,4 @@ public SequenceCompleted CompleteSequence(Process process, bool processActive, p // Ignore process as its still set return new SequenceCompleted(this, processActive, nextCells); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ActivityStart.cs b/src/Moryx.ControlSystem/Cells/ActivityStart.cs index 7ceaaab420..54932d1b58 100644 --- a/src/Moryx.ControlSystem/Cells/ActivityStart.cs +++ b/src/Moryx.ControlSystem/Cells/ActivityStart.cs @@ -30,7 +30,9 @@ internal ActivityStart(Session currentSession, Activity activity) public ActivityCompleted CreateResult() { if (Activity.Result == null) + { throw new InvalidOperationException("Can not create completed message for activity without result."); + } return new ActivityCompleted(Activity, this); } @@ -41,7 +43,9 @@ public ActivityCompleted CreateResult() public ActivityCompleted CreateResult(long result) { if (Activity.Result == null) + { Activity.Complete(result); + } return new ActivityCompleted(Activity, this); } diff --git a/src/Moryx.ControlSystem/Cells/Cell.cs b/src/Moryx.ControlSystem/Cells/Cell.cs index 3564d599e6..c6f124484e 100644 --- a/src/Moryx.ControlSystem/Cells/Cell.cs +++ b/src/Moryx.ControlSystem/Cells/Cell.cs @@ -83,4 +83,4 @@ public void PublishActivityCompleted(ActivityCompleted activityResult) /// public event EventHandler ActivityCompleted; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/CellSelectorBase.cs b/src/Moryx.ControlSystem/Cells/CellSelectorBase.cs index af8c8df5c1..152fc8e5ae 100644 --- a/src/Moryx.ControlSystem/Cells/CellSelectorBase.cs +++ b/src/Moryx.ControlSystem/Cells/CellSelectorBase.cs @@ -44,4 +44,4 @@ public virtual Task StopAsync(CancellationToken cancellationToken = default) /// public abstract Task> SelectCellsAsync(Activity activity, IReadOnlyList availableCells, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/CellSelectorConfig.cs b/src/Moryx.ControlSystem/Cells/CellSelectorConfig.cs index e9fddfd2da..4febb6d2f9 100644 --- a/src/Moryx.ControlSystem/Cells/CellSelectorConfig.cs +++ b/src/Moryx.ControlSystem/Cells/CellSelectorConfig.cs @@ -24,4 +24,4 @@ public class CellSelectorConfig : IPluginConfig, ISortableObject [DataMember] [Description("Order of execution for all resource selectors")] public int SortOrder { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ICell.cs b/src/Moryx.ControlSystem/Cells/ICell.cs index bfabe1dc28..253b1871e0 100644 --- a/src/Moryx.ControlSystem/Cells/ICell.cs +++ b/src/Moryx.ControlSystem/Cells/ICell.cs @@ -53,4 +53,4 @@ public interface ICell : IResource /// Event raised when the resource has completed the activity /// event EventHandler ActivityCompleted; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ICellSelector.cs b/src/Moryx.ControlSystem/Cells/ICellSelector.cs index 61a189c6cf..dbea883e48 100644 --- a/src/Moryx.ControlSystem/Cells/ICellSelector.cs +++ b/src/Moryx.ControlSystem/Cells/ICellSelector.cs @@ -16,4 +16,4 @@ public interface ICellSelector : IAsyncConfiguredPlugin /// the target resources /// Task> SelectCellsAsync(Activity activity, IReadOnlyList availableCells, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ICompletableSession.cs b/src/Moryx.ControlSystem/Cells/ICompletableSession.cs index 3652bb6e65..4f47a7a8d6 100644 --- a/src/Moryx.ControlSystem/Cells/ICompletableSession.cs +++ b/src/Moryx.ControlSystem/Cells/ICompletableSession.cs @@ -14,4 +14,4 @@ public interface ICompletableSession /// Complete the current sequence /// SequenceCompleted CompleteSequence(Process process, bool processActive, params long[] nextCells); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/NotReadyToWork.cs b/src/Moryx.ControlSystem/Cells/NotReadyToWork.cs index eb737dbe6c..8f9ed43946 100644 --- a/src/Moryx.ControlSystem/Cells/NotReadyToWork.cs +++ b/src/Moryx.ControlSystem/Cells/NotReadyToWork.cs @@ -26,4 +26,4 @@ public ReadyToWork ResumeSession() { return _pausedSession; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ProcessReference.cs b/src/Moryx.ControlSystem/Cells/ProcessReference.cs index 7732b37e3d..0211c3be61 100644 --- a/src/Moryx.ControlSystem/Cells/ProcessReference.cs +++ b/src/Moryx.ControlSystem/Cells/ProcessReference.cs @@ -43,12 +43,16 @@ private ProcessReference(long processId, IIdentity identity) public bool Matches(Process process) { if (_processId != IrrelevantId) + { return _processId == process.Id; + } var prodProcess = process as ProductionProcess; var identity = (prodProcess?.ProductInstance as IIdentifiableObject)?.Identity; if (identity == null || _identity == null) + { return false; + } return identity.Equals(_identity); } @@ -72,7 +76,9 @@ public bool Matches(Process process) public override string ToString() { if (IsEmpty) + { return "Empty reference"; + } return _processId == IrrelevantId ? $"Identity: {_identity}" : $"ProcessId: {_processId}"; } @@ -91,7 +97,10 @@ public bool Equals(ProcessReference other) public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) + { return false; + } + return obj is ProcessReference && Equals((ProcessReference)obj); } @@ -113,4 +122,4 @@ public override int GetHashCode() return (_processId.GetHashCode() * 397) ^ (_identity != null ? _identity.GetHashCode() : 0); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ReadyToWork.cs b/src/Moryx.ControlSystem/Cells/ReadyToWork.cs index 3d60a07ffa..5219ee7544 100644 --- a/src/Moryx.ControlSystem/Cells/ReadyToWork.cs +++ b/src/Moryx.ControlSystem/Cells/ReadyToWork.cs @@ -73,4 +73,4 @@ public NotReadyToWork PauseSession() { return new NotReadyToWork(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/ReadyToWorkType.cs b/src/Moryx.ControlSystem/Cells/ReadyToWorkType.cs index 9171fbc097..ba2f19b17a 100644 --- a/src/Moryx.ControlSystem/Cells/ReadyToWorkType.cs +++ b/src/Moryx.ControlSystem/Cells/ReadyToWorkType.cs @@ -20,4 +20,4 @@ public enum ReadyToWorkType /// The pull /// Pull -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/SequenceCompleted.cs b/src/Moryx.ControlSystem/Cells/SequenceCompleted.cs index d38c7870ad..bef90c79c3 100644 --- a/src/Moryx.ControlSystem/Cells/SequenceCompleted.cs +++ b/src/Moryx.ControlSystem/Cells/SequenceCompleted.cs @@ -35,4 +35,4 @@ public ReadyToWork ContinueSession() { return new ReadyToWork(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/Session.cs b/src/Moryx.ControlSystem/Cells/Session.cs index 15769a9dd4..5bbeca4a63 100644 --- a/src/Moryx.ControlSystem/Cells/Session.cs +++ b/src/Moryx.ControlSystem/Cells/Session.cs @@ -168,4 +168,4 @@ internal SessionContext(ActivityClassification classification, Guid sessionId, P public object Tag; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/SessionExtensions.cs b/src/Moryx.ControlSystem/Cells/SessionExtensions.cs index 3b53465705..84726f0501 100644 --- a/src/Moryx.ControlSystem/Cells/SessionExtensions.cs +++ b/src/Moryx.ControlSystem/Cells/SessionExtensions.cs @@ -129,4 +129,4 @@ public TProductType GetProductType() where TProductType : ProductT return default; } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs b/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs index f55b22c148..5a4e8b6305 100644 --- a/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs +++ b/src/Moryx.ControlSystem/Cells/UnknownActivityAborted.cs @@ -22,4 +22,4 @@ internal UnknownActivityAborted(Activity aborted, Session wrapper) /// Activity that was aborted /// public Activity AbortedActivity { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/IJobList.cs b/src/Moryx.ControlSystem/Jobs/IJobList.cs index ff0cc639ea..edfa41fc05 100644 --- a/src/Moryx.ControlSystem/Jobs/IJobList.cs +++ b/src/Moryx.ControlSystem/Jobs/IJobList.cs @@ -42,4 +42,4 @@ public interface IJobList /// Raised whenever a job progress was updated /// event EventHandler ProgressChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/IJobManagement.cs b/src/Moryx.ControlSystem/Jobs/IJobManagement.cs index 2ba8b9b29c..82ac4c18ca 100644 --- a/src/Moryx.ControlSystem/Jobs/IJobManagement.cs +++ b/src/Moryx.ControlSystem/Jobs/IJobManagement.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Recipes; -using Moryx.AbstractionLayer.Resources; namespace Moryx.ControlSystem.Jobs; @@ -61,4 +60,4 @@ public interface IJobManagement /// Raised whenever a job has changes. /// event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/IJobScheduler.cs b/src/Moryx.ControlSystem/Jobs/IJobScheduler.cs index e47b30887c..ddc4b3b702 100644 --- a/src/Moryx.ControlSystem/Jobs/IJobScheduler.cs +++ b/src/Moryx.ControlSystem/Jobs/IJobScheduler.cs @@ -39,4 +39,4 @@ public interface IJobScheduler : IConfiguredPlugin /// Event raised when a job is suspended and shall be stopped /// event EventHandler Suspended; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/IPredictiveJob.cs b/src/Moryx.ControlSystem/Jobs/IPredictiveJob.cs index 900efb81e5..1f0231cd7b 100644 --- a/src/Moryx.ControlSystem/Jobs/IPredictiveJob.cs +++ b/src/Moryx.ControlSystem/Jobs/IPredictiveJob.cs @@ -14,4 +14,4 @@ public interface IPredictiveJob /// Processes that are predicted to fail based on workplan and current progress /// IReadOnlyList PredictedFailures { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobClassification.cs b/src/Moryx.ControlSystem/Jobs/JobClassification.cs index 71696356aa..de573e3bf3 100644 --- a/src/Moryx.ControlSystem/Jobs/JobClassification.cs +++ b/src/Moryx.ControlSystem/Jobs/JobClassification.cs @@ -33,4 +33,4 @@ public enum JobClassification /// The job is completed. No processes are running and all work is done /// Completed = 1 << 16 -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobCreationContext.cs b/src/Moryx.ControlSystem/Jobs/JobCreationContext.cs index e0fed3df9c..f8e15cc389 100644 --- a/src/Moryx.ControlSystem/Jobs/JobCreationContext.cs +++ b/src/Moryx.ControlSystem/Jobs/JobCreationContext.cs @@ -111,4 +111,4 @@ internal JobTemplate(ProductionRecipe recipe, uint amount) /// Amount of the new job /// public uint Amount { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobEvaluation.cs b/src/Moryx.ControlSystem/Jobs/JobEvaluation.cs index 982b687a4c..1a03be5951 100644 --- a/src/Moryx.ControlSystem/Jobs/JobEvaluation.cs +++ b/src/Moryx.ControlSystem/Jobs/JobEvaluation.cs @@ -13,4 +13,4 @@ public class JobEvaluation /// Possible errors in the workplan /// public IReadOnlyList WorkplanErrors { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobExtensions.cs b/src/Moryx.ControlSystem/Jobs/JobExtensions.cs index 72b8869072..0f03d4893f 100644 --- a/src/Moryx.ControlSystem/Jobs/JobExtensions.cs +++ b/src/Moryx.ControlSystem/Jobs/JobExtensions.cs @@ -21,7 +21,9 @@ public static class JobExtensions public int CountPredictedFailures() { if (job is IPredictiveJob predictiveJob) + { return predictiveJob.PredictedFailures.Count; + } return 0; } @@ -50,4 +52,4 @@ public bool IsPreparingSetup() public bool IsCleaningUpSetup() => job.Recipe is SetupRecipe setup && setup.Execution == SetupExecution.AfterProduction; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobPosition.cs b/src/Moryx.ControlSystem/Jobs/JobPosition.cs index 6949866556..bf7bc69647 100644 --- a/src/Moryx.ControlSystem/Jobs/JobPosition.cs +++ b/src/Moryx.ControlSystem/Jobs/JobPosition.cs @@ -39,4 +39,4 @@ public JobPosition(JobPositionType positionType, long? reference) /// Position new jobs around the ones already part of the list /// public static JobPosition Expand = new(JobPositionType.AroundExisting, null); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobPositionType.cs b/src/Moryx.ControlSystem/Jobs/JobPositionType.cs index 0024024965..5b008a5fd9 100644 --- a/src/Moryx.ControlSystem/Jobs/JobPositionType.cs +++ b/src/Moryx.ControlSystem/Jobs/JobPositionType.cs @@ -37,4 +37,4 @@ public enum JobPositionType /// Append job(s) to group of jobs with the same recipe /// AppendToRecipe = 5, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobSchedulerBase.cs b/src/Moryx.ControlSystem/Jobs/JobSchedulerBase.cs index 7ae9769410..c1fa6baafd 100644 --- a/src/Moryx.ControlSystem/Jobs/JobSchedulerBase.cs +++ b/src/Moryx.ControlSystem/Jobs/JobSchedulerBase.cs @@ -80,7 +80,9 @@ protected bool RemoveDependency(Job target, Job dependency) var removed = targetsDependencies.Remove(dependency); if (_dependencies[target].Count == 0) + { _dependencies.Remove(target); + } return removed; } diff --git a/src/Moryx.ControlSystem/Jobs/JobSchedulerConfig.cs b/src/Moryx.ControlSystem/Jobs/JobSchedulerConfig.cs index 37561d5c61..a94090f503 100644 --- a/src/Moryx.ControlSystem/Jobs/JobSchedulerConfig.cs +++ b/src/Moryx.ControlSystem/Jobs/JobSchedulerConfig.cs @@ -17,4 +17,4 @@ public abstract class JobSchedulerConfig : UpdatableEntry, IPluginConfig /// Name of the component represented by this entry /// public abstract string PluginName { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobSlots.cs b/src/Moryx.ControlSystem/Jobs/JobSlots.cs index 3f73862ec0..efbec22a8f 100644 --- a/src/Moryx.ControlSystem/Jobs/JobSlots.cs +++ b/src/Moryx.ControlSystem/Jobs/JobSlots.cs @@ -60,7 +60,9 @@ public JobSlots(int slotCount) { AvailableSlots = slotCount; for (int i = 0; i < slotCount; i++) + { _slots.Add(new TSlot()); // Prepare slot wrapper for each slot + } } /// @@ -102,21 +104,29 @@ public bool TryResize(int size) { // If the size is identical this is easy if (size == Size) + { return true; + } // Make sure the new size fits all assigned slots // Decreasing is only possible if all taken slots fit in the new size if (size < Size - AvailableSlots) + { return false; + } // Now add or remove slots until the size matches AvailableSlots += size - Size; while (size != Size) { if (size > Size) + { _slots.Add(new TSlot()); + } else + { _slots.RemoveAll(s => s.Target == null); + } } return true; } @@ -128,7 +138,10 @@ public bool TryAssign(Job runningJob) { var result = TryReplace(null, runningJob); if (result) + { AvailableSlots--; + } + return result; } @@ -139,7 +152,10 @@ public bool TryRelease(Job runningJob) { var result = TryReplace(runningJob, null); if (result) + { AvailableSlots++; + } + return result; } @@ -152,7 +168,9 @@ public bool TryReplace(Job currentReference, Job newReference) var currentSlot = _slots.FirstOrDefault(s => s.Target == currentReference && s.CanAssign(newReference)); // We failed to assign this job to a slot if (currentSlot == null) + { return false; + } // Assign new job to the slot currentSlot.Assign(newReference); @@ -170,4 +188,4 @@ public IEnumerator GetEnumerator() } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Jobs/JobStateChangedEventArgs.cs b/src/Moryx.ControlSystem/Jobs/JobStateChangedEventArgs.cs index be23c613b6..64d1700fed 100644 --- a/src/Moryx.ControlSystem/Jobs/JobStateChangedEventArgs.cs +++ b/src/Moryx.ControlSystem/Jobs/JobStateChangedEventArgs.cs @@ -32,4 +32,4 @@ public JobStateChangedEventArgs(Job job, JobClassification previousState, JobCla PreviousState = previousState; CurrentState = currentState; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Materials/IMaterialContainer.cs b/src/Moryx.ControlSystem/Materials/IMaterialContainer.cs index f0a4aa6cac..e98068f04e 100644 --- a/src/Moryx.ControlSystem/Materials/IMaterialContainer.cs +++ b/src/Moryx.ControlSystem/Materials/IMaterialContainer.cs @@ -46,4 +46,4 @@ public interface IMaterialContainer : IResource /// Event raised when the filling level changed /// event EventHandler FillingLevelChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Materials/MaterialCapabilities.cs b/src/Moryx.ControlSystem/Materials/MaterialCapabilities.cs index 7d9d894d21..da89850bff 100644 --- a/src/Moryx.ControlSystem/Materials/MaterialCapabilities.cs +++ b/src/Moryx.ControlSystem/Materials/MaterialCapabilities.cs @@ -15,4 +15,4 @@ protected override bool ProvidedBy(ICapabilities provided) { return provided is MaterialCapabilities; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/ActivityUpdatedEventArgs.cs b/src/Moryx.ControlSystem/Processes/ActivityUpdatedEventArgs.cs index 7e719f0db4..7986896ace 100644 --- a/src/Moryx.ControlSystem/Processes/ActivityUpdatedEventArgs.cs +++ b/src/Moryx.ControlSystem/Processes/ActivityUpdatedEventArgs.cs @@ -47,4 +47,4 @@ public ActivityUpdatedEventArgs(Activity activity, ActivityProgress progress) Activity = activity; Progress = progress; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/EmptyProcess.cs b/src/Moryx.ControlSystem/Processes/EmptyProcess.cs index 65b2c5ad75..d56071a352 100644 --- a/src/Moryx.ControlSystem/Processes/EmptyProcess.cs +++ b/src/Moryx.ControlSystem/Processes/EmptyProcess.cs @@ -29,4 +29,4 @@ public EmptyProcess() : base(ProcessId) public EmptyProcess(long processId) : base(processId) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/IActivityPool.cs b/src/Moryx.ControlSystem/Processes/IActivityPool.cs index 4127ba1547..4d38ad7d7f 100644 --- a/src/Moryx.ControlSystem/Processes/IActivityPool.cs +++ b/src/Moryx.ControlSystem/Processes/IActivityPool.cs @@ -53,4 +53,4 @@ public interface IActivityPool /// If the activity's state reached Finished the activity is removed from the Pool after this event was fired. /// event EventHandler ActivityUpdated; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/IProcessControl.cs b/src/Moryx.ControlSystem/Processes/IProcessControl.cs index 9bda58bb3b..e8b592d5f9 100644 --- a/src/Moryx.ControlSystem/Processes/IProcessControl.cs +++ b/src/Moryx.ControlSystem/Processes/IProcessControl.cs @@ -60,4 +60,4 @@ public interface IProcessControl /// An activity has changed /// event EventHandler ActivityUpdated; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/IProcessHolderGroup.cs b/src/Moryx.ControlSystem/Processes/IProcessHolderGroup.cs index 54eaedc688..1da900e3be 100644 --- a/src/Moryx.ControlSystem/Processes/IProcessHolderGroup.cs +++ b/src/Moryx.ControlSystem/Processes/IProcessHolderGroup.cs @@ -32,4 +32,4 @@ public interface IProcessHolderGroup : IProcessHolderGroup /// All positions of the group /// new IEnumerable Positions { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/IProcessHolderPosition.cs b/src/Moryx.ControlSystem/Processes/IProcessHolderPosition.cs index 58f97402f3..452fa51731 100644 --- a/src/Moryx.ControlSystem/Processes/IProcessHolderPosition.cs +++ b/src/Moryx.ControlSystem/Processes/IProcessHolderPosition.cs @@ -58,4 +58,4 @@ public interface IProcessHolderPosition : IResource /// Event raised when the position was reset /// event EventHandler ResetExecuted; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/IProcessReporter.cs b/src/Moryx.ControlSystem/Processes/IProcessReporter.cs index b7ff07df48..762caba9d1 100644 --- a/src/Moryx.ControlSystem/Processes/IProcessReporter.cs +++ b/src/Moryx.ControlSystem/Processes/IProcessReporter.cs @@ -21,4 +21,4 @@ public interface IProcessReporter : IResource /// Event raised when the process failed and was already removed from the system /// event EventHandler ProcessRemoved; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/MountInformation.cs b/src/Moryx.ControlSystem/Processes/MountInformation.cs index 6c44921abf..0a3b6164f4 100644 --- a/src/Moryx.ControlSystem/Processes/MountInformation.cs +++ b/src/Moryx.ControlSystem/Processes/MountInformation.cs @@ -31,4 +31,4 @@ public MountInformation(Process process, Session session) Process = process; Session = session; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/ProcessHolderExtensions.cs b/src/Moryx.ControlSystem/Processes/ProcessHolderExtensions.cs index 808832bdac..59f1c3daf6 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessHolderExtensions.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessHolderExtensions.cs @@ -99,7 +99,10 @@ public static bool TryGetEmptyPosition(this IProcessHolderGroup group, out IProc foreach (var possible in group.Positions) { if (!possible.IsEmpty()) + { continue; + } + position = possible; return true; } @@ -127,7 +130,9 @@ public static TSession ConvertSession(this IProcessHolderPosition hold public static IEnumerable Attach(this ProcessHolderPosition position) { if (position.Session != null) + { return [position.Session]; + } return position.Process == null ? [] : [position.StartSession()]; } @@ -155,10 +160,14 @@ public static IEnumerable Attach(this IProcessHolderGroup group) } if (position.Process is null) + { continue; + } if (position is ProcessHolderPosition php) + { sessions.Add(php.StartSession()); + } } return sessions; } @@ -269,10 +278,12 @@ public TTracing Tracing() public void Update(Session session) { if (position.Session.Id != session.Id) + { throw new InvalidOperationException($"Tried to update the {nameof(Session)} on an " + $"{nameof(IProcessHolderPosition)} with a different session. Make sure to " + $"{nameof(IProcessHolderPosition.Reset)} the {nameof(IProcessHolderPosition)} before " + $"assigning a new {nameof(Session)}."); + } if (position is ProcessHolderPosition explicitPosition) { diff --git a/src/Moryx.ControlSystem/Processes/ProcessHolderGroup.cs b/src/Moryx.ControlSystem/Processes/ProcessHolderGroup.cs index 09ba3ae60e..be553cf1bf 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessHolderGroup.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessHolderGroup.cs @@ -31,4 +31,4 @@ public void Reset() position.Reset(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/ProcessHolderTracing.cs b/src/Moryx.ControlSystem/Processes/ProcessHolderTracing.cs index 80ed5fe3e2..03c74bf63b 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessHolderTracing.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessHolderTracing.cs @@ -19,4 +19,4 @@ public class ProcessHolderTracing : Tracing /// public virtual double Relative => Progress; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/ProcessMovement.cs b/src/Moryx.ControlSystem/Processes/ProcessMovement.cs index 0a25b99d56..17f9189876 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessMovement.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessMovement.cs @@ -85,7 +85,9 @@ public static bool Move(IProcessHolderPosition source, IProcessHolderPosition ta using (var transaction = new ProcessMovement(source, target)) { if (transaction.Progress == MovementProgress.Aborted) + { return false; + } transaction.MountOnTarget(); @@ -103,7 +105,9 @@ public static bool Move(IProcessHolderPosition source, IProcessHolderPosition ta public void MountOnTarget() { if (Progress < MovementProgress.InformationRetrieved) + { throw new InvalidOperationException("Can not mount before initiating the transaction."); + } _target.Mount(MountInformation); Progress = MovementProgress.MountedOnTarget; @@ -115,7 +119,9 @@ public void MountOnTarget() public void RemoveOnSource() { if (Progress < MovementProgress.MountedOnTarget) + { throw new InvalidOperationException("Can not remove before mounting on target."); + } _source.Unmount(); Progress = MovementProgress.RemovedFromSource; @@ -127,7 +133,9 @@ public void RemoveOnSource() public void Confirm() { if (Progress < MovementProgress.MountedOnTarget) + { throw new InvalidOperationException("Can not confirm before everything was completed."); + } Progress = MovementProgress.Completed; } @@ -157,6 +165,8 @@ public void RollBack() public void Dispose() { if (Progress < MovementProgress.Completed) + { RollBack(); + } } } diff --git a/src/Moryx.ControlSystem/Processes/ProcessReplacement.cs b/src/Moryx.ControlSystem/Processes/ProcessReplacement.cs index fb0299f36c..1d8057209a 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessReplacement.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessReplacement.cs @@ -3,7 +3,6 @@ using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; -using Moryx.AbstractionLayer.Recipes; namespace Moryx.ControlSystem.Processes; diff --git a/src/Moryx.ControlSystem/Processes/ProcessUpdatedEventArgs.cs b/src/Moryx.ControlSystem/Processes/ProcessUpdatedEventArgs.cs index a879aa8cda..55255122fd 100644 --- a/src/Moryx.ControlSystem/Processes/ProcessUpdatedEventArgs.cs +++ b/src/Moryx.ControlSystem/Processes/ProcessUpdatedEventArgs.cs @@ -52,4 +52,4 @@ public ProcessUpdatedEventArgs(Process process, ProcessProgress progress) Process = process; Progress = progress; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/ReportAction.cs b/src/Moryx.ControlSystem/Processes/ReportAction.cs index 31b086a3f5..f31e7f8c0c 100644 --- a/src/Moryx.ControlSystem/Processes/ReportAction.cs +++ b/src/Moryx.ControlSystem/Processes/ReportAction.cs @@ -16,4 +16,4 @@ public enum ReportAction /// The process was physically removed /// Removed -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Processes/UnknownProcess.cs b/src/Moryx.ControlSystem/Processes/UnknownProcess.cs index eeb6750689..2dc9b36ba8 100644 --- a/src/Moryx.ControlSystem/Processes/UnknownProcess.cs +++ b/src/Moryx.ControlSystem/Processes/UnknownProcess.cs @@ -28,4 +28,4 @@ public UnknownProcess() : base(ProcessId) public UnknownProcess(long processId) : base(processId) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Recipes/IOrderBasedRecipe.cs b/src/Moryx.ControlSystem/Recipes/IOrderBasedRecipe.cs index 1fbda68612..398aa631d0 100644 --- a/src/Moryx.ControlSystem/Recipes/IOrderBasedRecipe.cs +++ b/src/Moryx.ControlSystem/Recipes/IOrderBasedRecipe.cs @@ -19,4 +19,4 @@ public interface IOrderBasedRecipe : IRecipe /// Operation number /// string OperationNumber { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Recipes/IRecipeExtensions.cs b/src/Moryx.ControlSystem/Recipes/IRecipeExtensions.cs index 743d36962e..b70bb7b6b4 100644 --- a/src/Moryx.ControlSystem/Recipes/IRecipeExtensions.cs +++ b/src/Moryx.ControlSystem/Recipes/IRecipeExtensions.cs @@ -22,4 +22,4 @@ public static string GetOrderOperationString(this IRecipe recipe, string seperat var target = (recipe is SetupRecipe setup ? setup.TargetRecipe : recipe) as IOrderBasedRecipe; return $"{target?.OrderNumber}{(target is null ? "" : seperator)}{target?.OperationNumber}"; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Recipes/OrderBasedRecipe.cs b/src/Moryx.ControlSystem/Recipes/OrderBasedRecipe.cs index 4549e561bb..9d25fc2695 100644 --- a/src/Moryx.ControlSystem/Recipes/OrderBasedRecipe.cs +++ b/src/Moryx.ControlSystem/Recipes/OrderBasedRecipe.cs @@ -48,4 +48,4 @@ public override IRecipe Clone() { return new OrderBasedRecipe(this); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Recipes/SetupRecipe.cs b/src/Moryx.ControlSystem/Recipes/SetupRecipe.cs index 32ab793e2a..a7a0176cc2 100644 --- a/src/Moryx.ControlSystem/Recipes/SetupRecipe.cs +++ b/src/Moryx.ControlSystem/Recipes/SetupRecipe.cs @@ -35,4 +35,4 @@ public override IRecipe Clone() { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/CurrentResourceTarget.cs b/src/Moryx.ControlSystem/Setups/CurrentResourceTarget.cs index 6e9e98bab5..c16ac00404 100644 --- a/src/Moryx.ControlSystem/Setups/CurrentResourceTarget.cs +++ b/src/Moryx.ControlSystem/Setups/CurrentResourceTarget.cs @@ -29,4 +29,4 @@ public IReadOnlyList Cells(ICapabilities capabilities) { return _resourceManagement.GetResources(capabilities).ToList(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/ISetupProvider.cs b/src/Moryx.ControlSystem/Setups/ISetupProvider.cs index d42b5a0102..1f66efe8cf 100644 --- a/src/Moryx.ControlSystem/Setups/ISetupProvider.cs +++ b/src/Moryx.ControlSystem/Setups/ISetupProvider.cs @@ -16,4 +16,4 @@ public interface ISetupProvider : IRecipeProvider /// /// null if no setup is required, otherwise a setup recipe with a reconfiguration workplan SetupRecipe RequiredSetup(SetupExecution execution, ProductionRecipe recipe, ISetupTarget targetSystem); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/ISetupStep.cs b/src/Moryx.ControlSystem/Setups/ISetupStep.cs index 03d7a7384c..12a5ff6e8f 100644 --- a/src/Moryx.ControlSystem/Setups/ISetupStep.cs +++ b/src/Moryx.ControlSystem/Setups/ISetupStep.cs @@ -12,4 +12,4 @@ public interface ISetupStep /// Classification of the step /// SetupClassification Classification { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/ISetupTarget.cs b/src/Moryx.ControlSystem/Setups/ISetupTarget.cs index be378746af..16d368aff4 100644 --- a/src/Moryx.ControlSystem/Setups/ISetupTarget.cs +++ b/src/Moryx.ControlSystem/Setups/ISetupTarget.cs @@ -16,4 +16,4 @@ public interface ISetupTarget /// Return all cells that provide given, required capabilities /// IReadOnlyList Cells(ICapabilities capabilities); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/ISetupTrigger.cs b/src/Moryx.ControlSystem/Setups/ISetupTrigger.cs index c678901061..466af02753 100644 --- a/src/Moryx.ControlSystem/Setups/ISetupTrigger.cs +++ b/src/Moryx.ControlSystem/Setups/ISetupTrigger.cs @@ -29,4 +29,4 @@ public interface ISetupTrigger : IConfiguredPlugin, ISortabl /// Create a list of setup tasks that performs the necessary setup actions /// IReadOnlyList CreateSteps(IProductRecipe recipe); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/SetupClassification.cs b/src/Moryx.ControlSystem/Setups/SetupClassification.cs index 6f2edca577..069b9654ed 100644 --- a/src/Moryx.ControlSystem/Setups/SetupClassification.cs +++ b/src/Moryx.ControlSystem/Setups/SetupClassification.cs @@ -44,4 +44,4 @@ public enum SetupClassification /// Part of the setup can only be performed by skilled staff /// SkilledWorker = 1 << 18, -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/SetupEvaluation.cs b/src/Moryx.ControlSystem/Setups/SetupEvaluation.cs index 057fc21411..365b3aeb77 100644 --- a/src/Moryx.ControlSystem/Setups/SetupEvaluation.cs +++ b/src/Moryx.ControlSystem/Setups/SetupEvaluation.cs @@ -150,4 +150,4 @@ public Change(SetupClassification classification, ICapabilities current, ICapabi /// Release capabilities and indicate the provided setup information is no longer valid /// public static SetupEvaluation Release(ICapabilities capabilities, SetupClassification classification) => new Reservation(capabilities, classification); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/SetupExecution.cs b/src/Moryx.ControlSystem/Setups/SetupExecution.cs index 603d83678e..0824d1e0ea 100644 --- a/src/Moryx.ControlSystem/Setups/SetupExecution.cs +++ b/src/Moryx.ControlSystem/Setups/SetupExecution.cs @@ -17,4 +17,4 @@ public enum SetupExecution /// Trigger is relevant after execution /// AfterProduction -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/SetupTriggerBase.cs b/src/Moryx.ControlSystem/Setups/SetupTriggerBase.cs index e003533ac5..1feae2f117 100644 --- a/src/Moryx.ControlSystem/Setups/SetupTriggerBase.cs +++ b/src/Moryx.ControlSystem/Setups/SetupTriggerBase.cs @@ -61,4 +61,4 @@ public virtual void Stop() /// public abstract IReadOnlyList CreateSteps(IProductRecipe recipe); -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Setups/SetupTriggerConfig.cs b/src/Moryx.ControlSystem/Setups/SetupTriggerConfig.cs index 60c1c20127..5d31c1049a 100644 --- a/src/Moryx.ControlSystem/Setups/SetupTriggerConfig.cs +++ b/src/Moryx.ControlSystem/Setups/SetupTriggerConfig.cs @@ -33,4 +33,4 @@ public class SetupTriggerConfig : IPluginConfig [DataMember] [Display(Name = nameof(Strings.SetupTriggerConfig_Disabled_Name), Description = nameof(Strings.SetupTriggerConfig_Disabled_Description), ResourceType = typeof(Strings))] public bool Disabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Simulation/ISimulationDriver.cs b/src/Moryx.ControlSystem/Simulation/ISimulationDriver.cs index 2d165a9f5a..3f6819e8a2 100644 --- a/src/Moryx.ControlSystem/Simulation/ISimulationDriver.cs +++ b/src/Moryx.ControlSystem/Simulation/ISimulationDriver.cs @@ -56,4 +56,4 @@ public class SimulationResult /// Activity the result is for /// public Activity Activity { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Simulation/ISimulationParameters.cs b/src/Moryx.ControlSystem/Simulation/ISimulationParameters.cs index 270dc81d11..fd0a3c7521 100644 --- a/src/Moryx.ControlSystem/Simulation/ISimulationParameters.cs +++ b/src/Moryx.ControlSystem/Simulation/ISimulationParameters.cs @@ -15,4 +15,4 @@ public interface ISimulationParameters /// Execution time of the activity in /// public TimeSpan ExecutionTime { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Simulation/SimulationState.cs b/src/Moryx.ControlSystem/Simulation/SimulationState.cs index 6361c57dcf..11f01f86f0 100644 --- a/src/Moryx.ControlSystem/Simulation/SimulationState.cs +++ b/src/Moryx.ControlSystem/Simulation/SimulationState.cs @@ -28,4 +28,4 @@ public enum SimulationState /// Cell has received instructions and executed the process /// Executing -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Transport/ITransportSystem.cs b/src/Moryx.ControlSystem/Transport/ITransportSystem.cs index 668e7bfedd..dffce0ae9f 100644 --- a/src/Moryx.ControlSystem/Transport/ITransportSystem.cs +++ b/src/Moryx.ControlSystem/Transport/ITransportSystem.cs @@ -45,4 +45,4 @@ public interface ITransportSystem : IResource /// Event raised, when a group was removed /// event EventHandler GroupRemoved; -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Transport/TransportCapabilities.cs b/src/Moryx.ControlSystem/Transport/TransportCapabilities.cs index 2aa4131ec8..6176cb86ca 100644 --- a/src/Moryx.ControlSystem/Transport/TransportCapabilities.cs +++ b/src/Moryx.ControlSystem/Transport/TransportCapabilities.cs @@ -22,15 +22,21 @@ protected override bool ProvidedBy(ICapabilities provided) { var capabilities = provided as TransportCapabilities; if (capabilities == null) + { return false; + } if (ConnectedResources == null || ConnectedResources.Length == 0) + { return true; + } // If resources are specified we must check whether we are connected to all of them if (ConnectedResources.All(requiredRes => capabilities.ConnectedResources.Contains(requiredRes))) + { return true; + } return false; } -} \ No newline at end of file +} diff --git a/src/Moryx.ControlSystem/Transport/TransportMode.cs b/src/Moryx.ControlSystem/Transport/TransportMode.cs index 1ffe116422..4888b4dfda 100644 --- a/src/Moryx.ControlSystem/Transport/TransportMode.cs +++ b/src/Moryx.ControlSystem/Transport/TransportMode.cs @@ -25,4 +25,4 @@ public enum TransportMode /// Routing per /// PositionRouting = 0x2 -} \ No newline at end of file +} diff --git a/src/Moryx.DependentTestModule/Facades/DependentTestModuleFacade.cs b/src/Moryx.DependentTestModule/Facades/DependentTestModuleFacade.cs index bd6a2cdb7d..0b7283a17a 100644 --- a/src/Moryx.DependentTestModule/Facades/DependentTestModuleFacade.cs +++ b/src/Moryx.DependentTestModule/Facades/DependentTestModuleFacade.cs @@ -7,4 +7,4 @@ namespace Moryx.DependentTestModule; public class DependentTestModuleFacade : FacadeBase, IDependentTestModule { -} \ No newline at end of file +} diff --git a/src/Moryx.DependentTestModule/Facades/IDependentTestModule.cs b/src/Moryx.DependentTestModule/Facades/IDependentTestModule.cs index 73a093bbe2..a439d3c682 100644 --- a/src/Moryx.DependentTestModule/Facades/IDependentTestModule.cs +++ b/src/Moryx.DependentTestModule/Facades/IDependentTestModule.cs @@ -11,4 +11,4 @@ public interface IDependentTestModule /* * Define the API exported by TestModule */ -} \ No newline at end of file +} diff --git a/src/Moryx.DependentTestModule/ModuleController/ModuleConfig.cs b/src/Moryx.DependentTestModule/ModuleController/ModuleConfig.cs index 964a795491..34299fcc8f 100644 --- a/src/Moryx.DependentTestModule/ModuleController/ModuleConfig.cs +++ b/src/Moryx.DependentTestModule/ModuleController/ModuleConfig.cs @@ -10,4 +10,4 @@ namespace Moryx.DependentTestModule; public class ModuleConfig : ConfigBase { public int Foo { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.DependentTestModule/ModuleController/ModuleConsole.cs b/src/Moryx.DependentTestModule/ModuleController/ModuleConsole.cs index 4cbc2cadcc..b642f5aa57 100644 --- a/src/Moryx.DependentTestModule/ModuleController/ModuleConsole.cs +++ b/src/Moryx.DependentTestModule/ModuleController/ModuleConsole.cs @@ -45,4 +45,4 @@ public void CreateTestLogMessage(LogLevel logLevel) throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null); } } -} \ No newline at end of file +} diff --git a/src/Moryx.DependentTestModule/ModuleController/ModuleController.cs b/src/Moryx.DependentTestModule/ModuleController/ModuleController.cs index ca47318ce7..68bb861710 100644 --- a/src/Moryx.DependentTestModule/ModuleController/ModuleController.cs +++ b/src/Moryx.DependentTestModule/ModuleController/ModuleController.cs @@ -66,4 +66,4 @@ protected override async Task OnStopAsync(CancellationToken cancellationToken) IDependentTestModule IFacadeContainer.Facade => _testModuleFacade; #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.Mqtt/MqttDriver.cs b/src/Moryx.Drivers.Mqtt/MqttDriver.cs index 8771f7da94..3a46add37e 100644 --- a/src/Moryx.Drivers.Mqtt/MqttDriver.cs +++ b/src/Moryx.Drivers.Mqtt/MqttDriver.cs @@ -1,25 +1,25 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics; using System.Runtime.Serialization; +using System.Security.Claims; +using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Drivers; -using MQTTnet; -using System.ComponentModel; using Moryx.AbstractionLayer.Drivers.Message; using Moryx.AbstractionLayer.Resources; +using Moryx.Configuration; +using Moryx.Drivers.Mqtt.Properties; +using Moryx.Drivers.Mqtt.States; using Moryx.Serialization; using Moryx.StateMachines; using Moryx.Threading; +using MQTTnet; +using MQTTnet.Exceptions; using MQTTnet.Formatter; -using Microsoft.Extensions.Logging; using MQTTnet.Protocol; -using Moryx.Configuration; -using System.Security.Claims; -using Moryx.Drivers.Mqtt.Properties; -using System.ComponentModel.DataAnnotations; -using Moryx.Drivers.Mqtt.States; -using System.Diagnostics; -using MQTTnet.Exceptions; namespace Moryx.Drivers.Mqtt; @@ -377,7 +377,7 @@ private Task OnDisconnected(MqttClientDisconnectedEventArgs args) internal async Task Disconnect() { - if(_scheduledReconnect != 0) + if (_scheduledReconnect != 0) { ParallelOperations.StopExecution(_scheduledReconnect); _scheduledReconnect = 0; @@ -678,7 +678,10 @@ internal void DelayedConnectionAttempt() { // early return, when reconnect was cancelled if (_scheduledReconnect == 0) + { return; + } + try { await Connect(false); diff --git a/src/Moryx.Drivers.Mqtt/MqttTopic.cs b/src/Moryx.Drivers.Mqtt/MqttTopic.cs index f1e4bd83dc..7f1e2b26fd 100644 --- a/src/Moryx.Drivers.Mqtt/MqttTopic.cs +++ b/src/Moryx.Drivers.Mqtt/MqttTopic.cs @@ -1,23 +1,23 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Buffers; using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Diagnostics; using System.Runtime.Serialization; +using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Drivers; using Moryx.AbstractionLayer.Drivers.Message; using Moryx.AbstractionLayer.Resources; using Moryx.Bindings; +using Moryx.Drivers.Mqtt.Messages; +using Moryx.Drivers.Mqtt.Properties; using Moryx.Serialization; using Moryx.Threading; using Moryx.Tools; -using Moryx.Drivers.Mqtt.Properties; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics; -using Moryx.Drivers.Mqtt.Messages; -using System.Buffers; -using System.Text.Json; namespace Moryx.Drivers.Mqtt; diff --git a/src/Moryx.Drivers.Mqtt/States/ConnectedToBrokerState.cs b/src/Moryx.Drivers.Mqtt/States/ConnectedToBrokerState.cs index 21a41b41e2..c5cfc7a7b0 100644 --- a/src/Moryx.Drivers.Mqtt/States/ConnectedToBrokerState.cs +++ b/src/Moryx.Drivers.Mqtt/States/ConnectedToBrokerState.cs @@ -46,4 +46,4 @@ internal override void TriedConnecting(bool successful) base.TriedConnecting(successful); } -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.Mqtt/States/ConnectingToBrokerState.cs b/src/Moryx.Drivers.Mqtt/States/ConnectingToBrokerState.cs index fbbc6e6803..1110e4834b 100644 --- a/src/Moryx.Drivers.Mqtt/States/ConnectingToBrokerState.cs +++ b/src/Moryx.Drivers.Mqtt/States/ConnectingToBrokerState.cs @@ -30,4 +30,4 @@ public override void Disconnect() // method async void (not preferable) or use Wait here (also ugly but better). ExecuteDisconnect().Wait(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.Mqtt/States/DisconnectedState.cs b/src/Moryx.Drivers.Mqtt/States/DisconnectedState.cs index 832c1ff520..3968dbf3b9 100644 --- a/src/Moryx.Drivers.Mqtt/States/DisconnectedState.cs +++ b/src/Moryx.Drivers.Mqtt/States/DisconnectedState.cs @@ -28,4 +28,4 @@ internal override void TriedConnecting(bool successful) { // Nothing happens } -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.Mqtt/Topics/JsonOptionsExtension.cs b/src/Moryx.Drivers.Mqtt/Topics/JsonOptionsExtension.cs index 125a9583af..d5cd389723 100644 --- a/src/Moryx.Drivers.Mqtt/Topics/JsonOptionsExtension.cs +++ b/src/Moryx.Drivers.Mqtt/Topics/JsonOptionsExtension.cs @@ -11,7 +11,8 @@ namespace Moryx.Drivers.Mqtt.Topics; /// public static class JsonOptionsExtension { - extension(JsonIgnoreCondition ignoreCondition) { + extension(JsonIgnoreCondition ignoreCondition) + { /// /// Converts to specific JsonIgnoreCondition for System.Text.Json /// diff --git a/src/Moryx.Drivers.Mqtt/Topics/MqttTopicJson.cs b/src/Moryx.Drivers.Mqtt/Topics/MqttTopicJson.cs index d572f1d499..59fd0f9985 100644 --- a/src/Moryx.Drivers.Mqtt/Topics/MqttTopicJson.cs +++ b/src/Moryx.Drivers.Mqtt/Topics/MqttTopicJson.cs @@ -37,7 +37,6 @@ public override string MessageName [Display(Name = nameof(Strings.MqttTopicJson_Format), ResourceType = typeof(Strings))] public JsonFormat Format { get; set; } - /// /// Controls if enums should be serialized as strings or as ints /// diff --git a/src/Moryx.Drivers.OpcUa/DataValueResult.cs b/src/Moryx.Drivers.OpcUa/DataValueResult.cs index 6287b4cbed..4109086a51 100644 --- a/src/Moryx.Drivers.OpcUa/DataValueResult.cs +++ b/src/Moryx.Drivers.OpcUa/DataValueResult.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Opc.Ua; using Moryx.Tools; +using Opc.Ua; namespace Moryx.Drivers.OpcUa; diff --git a/src/Moryx.Drivers.OpcUa/Exceptions/InvalidCertificateException.cs b/src/Moryx.Drivers.OpcUa/Exceptions/InvalidCertificateException.cs index 6bc680d0ec..d01ea3badc 100644 --- a/src/Moryx.Drivers.OpcUa/Exceptions/InvalidCertificateException.cs +++ b/src/Moryx.Drivers.OpcUa/Exceptions/InvalidCertificateException.cs @@ -17,4 +17,4 @@ public InvalidCertificateException(string message) : base(message) public InvalidCertificateException(string message, Exception innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.OpcUa/NodeIdAlias.cs b/src/Moryx.Drivers.OpcUa/NodeIdAlias.cs index 62a0bb5f48..336ba0a914 100644 --- a/src/Moryx.Drivers.OpcUa/NodeIdAlias.cs +++ b/src/Moryx.Drivers.OpcUa/NodeIdAlias.cs @@ -12,4 +12,4 @@ public override string ToString() { return Alias; } -} \ No newline at end of file +} diff --git a/src/Moryx.Drivers.OpcUa/OpcUaInput.cs b/src/Moryx.Drivers.OpcUa/OpcUaInput.cs index 268fef75ac..8ce5232f0a 100644 --- a/src/Moryx.Drivers.OpcUa/OpcUaInput.cs +++ b/src/Moryx.Drivers.OpcUa/OpcUaInput.cs @@ -20,7 +20,9 @@ public OpcUaInput(OpcUaDriver driver) private void OnReceived(object sender, object e) { if (e is not IIdentifierMessage opcUaMessage) + { return; + } var eventArgs = new InputChangedEventArgs(opcUaMessage.Identifier, opcUaMessage); InputChanged?.Invoke(this, eventArgs); diff --git a/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInOutDriver.cs b/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInOutDriver.cs index b3d7f57992..5e558cb6d3 100644 --- a/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInOutDriver.cs +++ b/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInOutDriver.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; +using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Drivers; using Moryx.AbstractionLayer.Drivers.InOut; using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Simulation; using Moryx.Serialization; -using System.ComponentModel; -using Moryx.AbstractionLayer.Activities; namespace Moryx.Drivers.Simulation.InOutDriver; diff --git a/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInput.cs b/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInput.cs index 416c8239db..f1d93f3261 100644 --- a/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInput.cs +++ b/src/Moryx.Drivers.Simulation/InOutDriver/SimulatedInput.cs @@ -48,7 +48,7 @@ public object this[int index] /// /// Raise the input changed event for a given key /// - public void RaiseInputChanged(object value) => InputChanged?.Invoke(this, new InputChangedEventArgs { Value = value}); + public void RaiseInputChanged(object value) => InputChanged?.Invoke(this, new InputChangedEventArgs { Value = value }); /// /// Raise the input changed event for a given key diff --git a/src/Moryx.Factory/EntryVisualizationAttribute.cs b/src/Moryx.Factory/EntryVisualizationAttribute.cs index eb4e959775..7bc13e0ecd 100644 --- a/src/Moryx.Factory/EntryVisualizationAttribute.cs +++ b/src/Moryx.Factory/EntryVisualizationAttribute.cs @@ -23,4 +23,4 @@ public EntryVisualizationAttribute(string unit, string icon) /// Icon to display for this property inside the Factory Monitor UI /// public string Icon { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/ILocation.cs b/src/Moryx.Factory/ILocation.cs index 1e700c290b..da2611691c 100644 --- a/src/Moryx.Factory/ILocation.cs +++ b/src/Moryx.Factory/ILocation.cs @@ -29,4 +29,4 @@ public interface ILocation : IResource /// Transport paths that are coming to this location /// IEnumerable Destinations { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/IMachineGroup.cs b/src/Moryx.Factory/IMachineGroup.cs index 71ee2bffee..8a25bfadb6 100644 --- a/src/Moryx.Factory/IMachineGroup.cs +++ b/src/Moryx.Factory/IMachineGroup.cs @@ -14,4 +14,4 @@ public interface IMachineGroup : IResource /// Default icon for this resource group /// string DefaultIcon { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/IMachineLocation.cs b/src/Moryx.Factory/IMachineLocation.cs index b52670c3b9..19f18ef8e1 100644 --- a/src/Moryx.Factory/IMachineLocation.cs +++ b/src/Moryx.Factory/IMachineLocation.cs @@ -19,4 +19,4 @@ public interface IMachineLocation : ILocation, IResource /// Icon for the machine at this location /// string SpecificIcon { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/IManufacturingFactory.cs b/src/Moryx.Factory/IManufacturingFactory.cs index 837ea4b2fd..1c938cae87 100644 --- a/src/Moryx.Factory/IManufacturingFactory.cs +++ b/src/Moryx.Factory/IManufacturingFactory.cs @@ -14,4 +14,4 @@ public interface IManufacturingFactory : IResource /// Background URL of the factory monitor /// string BackgroundUrl { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/ITransportPath.cs b/src/Moryx.Factory/ITransportPath.cs index 2c695af873..88aebc249e 100644 --- a/src/Moryx.Factory/ITransportPath.cs +++ b/src/Moryx.Factory/ITransportPath.cs @@ -24,4 +24,4 @@ public interface ITransportPath : IResource /// Trajectory to follow from origin to reach the destination /// List WayPoints { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/MachineGroup.cs b/src/Moryx.Factory/MachineGroup.cs index 045003f990..c25fcfedb1 100644 --- a/src/Moryx.Factory/MachineGroup.cs +++ b/src/Moryx.Factory/MachineGroup.cs @@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; -using Moryx.Serialization; using Moryx.Factory.Properties; +using Moryx.Serialization; namespace Moryx.Factory; @@ -18,4 +18,4 @@ public class MachineGroup : Resource, IMachineGroup { [DataMember, EntrySerialize, DefaultValue("settings")] public string DefaultIcon { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/MachineLocation.cs b/src/Moryx.Factory/MachineLocation.cs index 3ccbf75b72..8c68b16db3 100644 --- a/src/Moryx.Factory/MachineLocation.cs +++ b/src/Moryx.Factory/MachineLocation.cs @@ -2,12 +2,12 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Cells; -using Moryx.Serialization; using Moryx.Factory.Properties; -using System.ComponentModel.DataAnnotations; +using Moryx.Serialization; namespace Moryx.Factory; @@ -61,4 +61,4 @@ public Position Position IEnumerable ILocation.Origins => Origins; IEnumerable ILocation.Destinations => Destinations; -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/ManufacturingFactory.cs b/src/Moryx.Factory/ManufacturingFactory.cs index 090e5c5adf..046c12714d 100644 --- a/src/Moryx.Factory/ManufacturingFactory.cs +++ b/src/Moryx.Factory/ManufacturingFactory.cs @@ -18,4 +18,4 @@ public class ManufacturingFactory : Resource, IManufacturingFactory [DataMember, EntrySerialize, DefaultValue("https://www.phoenixcontact.com/common/assets/images/signal-chain.svg")] [Display(Name = nameof(Strings.ManufacturingFactory_BackgroundUrl), Description = nameof(Strings.ManufacturingFactory_BackgroundUrl_Description), ResourceType = typeof(Strings))] public string BackgroundUrl { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/Position.cs b/src/Moryx.Factory/Position.cs index 9f1b715a02..2e67cbccb2 100644 --- a/src/Moryx.Factory/Position.cs +++ b/src/Moryx.Factory/Position.cs @@ -16,4 +16,4 @@ public class Position [DataMember] public double PositionY { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/SwitchPoint.cs b/src/Moryx.Factory/SwitchPoint.cs index 26c18fda7f..b7ce8e7494 100644 --- a/src/Moryx.Factory/SwitchPoint.cs +++ b/src/Moryx.Factory/SwitchPoint.cs @@ -1,11 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; -using Moryx.Serialization; using Moryx.Factory.Properties; -using System.ComponentModel.DataAnnotations; +using Moryx.Serialization; namespace Moryx.Factory; @@ -39,4 +39,4 @@ public Position Position public IEnumerable Destinations { get; set; } public string Image { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Factory/TransportPath.cs b/src/Moryx.Factory/TransportPath.cs index 87f1550770..c17f302f8e 100644 --- a/src/Moryx.Factory/TransportPath.cs +++ b/src/Moryx.Factory/TransportPath.cs @@ -1,11 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Resources; -using Moryx.Serialization; using Moryx.Factory.Properties; -using System.ComponentModel.DataAnnotations; +using Moryx.Serialization; namespace Moryx.Factory; @@ -24,4 +24,4 @@ public class TransportPath : Resource, ITransportPath [DataMember, EntrySerialize] [Display(Name = nameof(Strings.TransportPath_WayPoints), ResourceType = typeof(Strings))] public List WayPoints { get; set; } = new List(); -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Converter/CellSerialization.cs b/src/Moryx.FactoryMonitor.Endpoints/Converter/CellSerialization.cs index 4810a25a8c..5de944fded 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Converter/CellSerialization.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Converter/CellSerialization.cs @@ -79,4 +79,4 @@ public object GetService(Type serviceType) throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Converter/Converter.cs b/src/Moryx.FactoryMonitor.Endpoints/Converter/Converter.cs index d46931c5cf..3ff6120fa8 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Converter/Converter.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Converter/Converter.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Resources; -using Moryx.ControlSystem.Cells; using Moryx.Factory; using Moryx.FactoryMonitor.Endpoints.Models; using Moryx.Orders; diff --git a/src/Moryx.FactoryMonitor.Endpoints/Exceptions/NoRootFactoryException.cs b/src/Moryx.FactoryMonitor.Endpoints/Exceptions/NoRootFactoryException.cs index 96ca621655..85c5c51915 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Exceptions/NoRootFactoryException.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Exceptions/NoRootFactoryException.cs @@ -8,4 +8,4 @@ public class NoRootFactoryException : Exception public NoRootFactoryException(string message) : base(message) { } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Extensions/CellExtensions.cs b/src/Moryx.FactoryMonitor.Endpoints/Extensions/CellExtensions.cs index b49eb2bfd1..624db3d22f 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Extensions/CellExtensions.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Extensions/CellExtensions.cs @@ -4,7 +4,6 @@ using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Processes; -using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Processes; @@ -39,9 +38,13 @@ public ActivityChangedModel GetActivityChangedModel(Activity activity, }; if (activity.Process is ProductionProcess) + { activityChangedModel.Classification = ActivityClassification.Production; + } else if (activity is IControlSystemActivity controlActivity) + { activityChangedModel.Classification = controlActivity.Classification; + } var recipe = activity.Process.Recipe as IOrderBasedRecipe; var orderModel = orderModels. @@ -56,12 +59,16 @@ private CellState GetCellState(ActivityProgress activityProgress) { var state = GetCellState(cell); if (state is CellState.NotReadyToWork) + { return state; + } // Currently we are targetting running activity or completed activity // to-do: add more cellstate, state like tearup, teardown etc... if (activityProgress is ActivityProgress.Running) + { return CellState.Running; + } return CellState.Idle; } @@ -70,7 +77,9 @@ private CellState GetCellState() { var currentCapabilities = cell.Capabilities.GetAll(); if ((currentCapabilities.Count() == 1 && currentCapabilities.Single() is NullCapabilities) || !currentCapabilities.Any()) + { return CellState.NotReadyToWork; + } return CellState.Idle; } diff --git a/src/Moryx.FactoryMonitor.Endpoints/Extensions/FactoryMonitorHelper.cs b/src/Moryx.FactoryMonitor.Endpoints/Extensions/FactoryMonitorHelper.cs index 1916f8eebc..111214bc68 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Extensions/FactoryMonitorHelper.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Extensions/FactoryMonitorHelper.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Resources; using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Processes; diff --git a/src/Moryx.FactoryMonitor.Endpoints/Extensions/ResourceExtensions.cs b/src/Moryx.FactoryMonitor.Endpoints/Extensions/ResourceExtensions.cs index b6c8a4a9c6..b6c0132775 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Extensions/ResourceExtensions.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Extensions/ResourceExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Resources; -using Moryx.ControlSystem.Cells; using Moryx.Factory; using Moryx.FactoryMonitor.Endpoints.Models; diff --git a/src/Moryx.FactoryMonitor.Endpoints/Extensions/SimpleGraphExtensions.cs b/src/Moryx.FactoryMonitor.Endpoints/Extensions/SimpleGraphExtensions.cs index 1d0ef5b78b..a3c6abb7b9 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Extensions/SimpleGraphExtensions.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Extensions/SimpleGraphExtensions.cs @@ -6,4 +6,4 @@ namespace Moryx.FactoryMonitor.Endpoints.Extensions; internal static class SimpleGraphExtensions { -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorController.cs b/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorController.cs index b92b53290b..c903fd399d 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorController.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorController.cs @@ -195,13 +195,16 @@ public ActionResult> FactoryContent(long factoryId) public ActionResult GetNavigation(long factoryId) { var root = _resourceManager.GetRootFactory(); - if (factoryId == root.Id) return new FactoryModel + if (factoryId == root.Id) { - Id = factoryId, - Title = root.Name, - BackgroundURL = + return new FactoryModel + { + Id = factoryId, + Title = root.Name, + BackgroundURL = root.BackgroundUrl - }; + }; + } var factory = _resourceManager.ReadUnsafe(factoryId, e => (ManufacturingFactory)e); if (factory is not ManufacturingFactory manufacturingFactory) @@ -347,11 +350,16 @@ await _resourceManager.ModifyUnsafeAsync(cellLocation, r => public async Task ChangeBackground(long resourceId, string url) { if (string.IsNullOrEmpty(url)) + { return UnprocessableEntity($"The provided {nameof(url)} is invalid"); + } var manufacturingConfig = _resourceManager.GetResources().SingleOrDefault(f => f.Id == resourceId); if (manufacturingConfig is null) + { return NotFound("The resource to be modified could not be found"); + } + await _resourceManager.ModifyUnsafeAsync(manufacturingConfig.Id, r => { ((IManufacturingFactory)r).BackgroundUrl = url; @@ -374,7 +382,9 @@ public ActionResult> GetCellPropertiesS .FirstOrDefault(x => x.Machine?.Id.ToString(CultureInfo.CurrentCulture) == identifier); if (cellLocation == null) + { return NotFound(new MoryxExceptionResponse { Title = "Cell/Resource not found" }); + } var converter = new Converter.Converter(_serialization, _logger); var cell = _resourceManager.ReadUnsafe(cellLocation.Machine.Id, r => r); @@ -431,7 +441,9 @@ public async Task CellSettings(long id, CellSettingsModel settings var cellLocation = _resourceManager.GetResource(l => l.Machine?.Id == id); if (cellLocation is null) + { return NotFound(); + } await _resourceManager.ModifyUnsafeAsync(cellLocation, r => { diff --git a/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorPermissions.cs b/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorPermissions.cs index 503191ccc9..3bcf8b9243 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorPermissions.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/FactoryMonitorPermissions.cs @@ -7,4 +7,4 @@ public static class FactoryMonitorPermissions { public const string _prefix = "Moryx.FactoryMonitor."; public const string CanView = _prefix + "CanView"; -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/ActivityChangedModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/ActivityChangedModel.cs index 96c9e98f99..c5b00f7faa 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/ActivityChangedModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/ActivityChangedModel.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.ControlSystem.Activities; using System.Runtime.Serialization; +using Moryx.ControlSystem.Activities; namespace Moryx.FactoryMonitor.Endpoints.Models; @@ -26,4 +26,4 @@ public class ActivityChangedModel [DataMember] public OrderReferenceModel OrderReferenceModel { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/CellLocationModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/CellLocationModel.cs index 2488a1321d..5d4c0de120 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/CellLocationModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/CellLocationModel.cs @@ -20,4 +20,4 @@ public class CellLocationModel [DataMember] public virtual double PositionY { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/CellSettingsModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/CellSettingsModel.cs index 36557deddc..8a29191c99 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/CellSettingsModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/CellSettingsModel.cs @@ -12,4 +12,4 @@ public class CellSettingsModel public virtual string Image { get; set; } [DataMember] public virtual string Icon { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/CellState.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/CellState.cs index 185dda011b..ec9ff50c44 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/CellState.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/CellState.cs @@ -27,4 +27,4 @@ public enum CellState /// Not able to work /// NotReadyToWork -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/CellStateChangedModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/CellStateChangedModel.cs index 977595a9d9..2ff26c9bd1 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/CellStateChangedModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/CellStateChangedModel.cs @@ -17,4 +17,4 @@ public class CellStateChangedModel [DataMember] public CellState State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryModel.cs index e8b87226dc..3a56e653df 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryModel.cs @@ -28,4 +28,4 @@ public class FactoryModel [DataMember] public virtual string Title { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryStateModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryStateModel.cs index e0c0b2ab73..50fd0a0872 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryStateModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/FactoryStateModel.cs @@ -29,4 +29,4 @@ public class FactoryStateModel : VisualizableItemModel [DataMember] public List ResourceChangedModels { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/MachineGroupModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/MachineGroupModel.cs index e92bf4e3fb..eec4ecf3ba 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/MachineGroupModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/MachineGroupModel.cs @@ -19,4 +19,4 @@ public class MachineGroupModel [DataMember] public virtual string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderChangedModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderChangedModel.cs index e6a7b80fc0..7a3e2f4b39 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderChangedModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderChangedModel.cs @@ -19,4 +19,4 @@ public class OrderChangedModel //can't inherit OrderReferenceModel as before, be [DataMember] public InternalOperationClassification State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderModel.cs index abfb7da517..cda1088ce8 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderModel.cs @@ -13,4 +13,4 @@ public class OrderModel : OrderChangedModel { [DataMember] public string Color { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderReferenceModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderReferenceModel.cs index d00ebed51e..33e80daf8c 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/OrderReferenceModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/OrderReferenceModel.cs @@ -15,4 +15,4 @@ public class OrderReferenceModel [DataMember] public string Operation { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleFactoryGraph.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleFactoryGraph.cs index eae288795b..8e92d17712 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleFactoryGraph.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleFactoryGraph.cs @@ -29,4 +29,4 @@ public class SimpleFactoryGraph /// Contains the elements that should be displayed in the current factory /// public List Children { get; set; } = []; -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleGraph.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleGraph.cs index 515b20719a..789936583b 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleGraph.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/SimpleGraph.cs @@ -135,7 +135,6 @@ public void Append(Resource addition) } } - /// /// Appends a leaf node to the current /// diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/TransportPathModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/TransportPathModel.cs index e2c796d7f4..3693eb74bc 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/TransportPathModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/TransportPathModel.cs @@ -22,4 +22,4 @@ public class TransportPathModel [DataMember] public virtual List WayPoints { get; set; } = []; -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/TransportRouteModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/TransportRouteModel.cs index baaa5029e0..aff5cfa1d4 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/TransportRouteModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/TransportRouteModel.cs @@ -20,4 +20,4 @@ public class TransportRouteModel [DataMember] public virtual List Paths { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Endpoints/Models/VisualizableItemModel.cs b/src/Moryx.FactoryMonitor.Endpoints/Models/VisualizableItemModel.cs index eb8e392e1b..c04f6895ba 100644 --- a/src/Moryx.FactoryMonitor.Endpoints/Models/VisualizableItemModel.cs +++ b/src/Moryx.FactoryMonitor.Endpoints/Models/VisualizableItemModel.cs @@ -22,4 +22,4 @@ public class VisualizableItemModel [DataMember] public virtual bool IsACell { get; set; } = false; -} \ No newline at end of file +} diff --git a/src/Moryx.FactoryMonitor.Web/Pages/FactoryMonitor.cshtml.cs b/src/Moryx.FactoryMonitor.Web/Pages/FactoryMonitor.cshtml.cs index ae15cf3b97..c443446859 100644 --- a/src/Moryx.FactoryMonitor.Web/Pages/FactoryMonitor.cshtml.cs +++ b/src/Moryx.FactoryMonitor.Web/Pages/FactoryMonitor.cshtml.cs @@ -7,7 +7,7 @@ namespace Moryx.FactoryMonitor.Web.Pages; public class FactoryMonitorModel : PageModel { - public void OnGet() - { - } + public void OnGet() + { + } } diff --git a/src/Moryx.Identity.AccessManagement/Constants/Roles.cs b/src/Moryx.Identity.AccessManagement/Constants/Roles.cs index a49f66607e..5041bce239 100644 --- a/src/Moryx.Identity.AccessManagement/Constants/Roles.cs +++ b/src/Moryx.Identity.AccessManagement/Constants/Roles.cs @@ -12,4 +12,4 @@ public static class Roles /// Defines the SuperAdmin role /// public const string SuperAdmin = "SuperAdmin"; -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/API/AuthController.cs b/src/Moryx.Identity.AccessManagement/Controllers/API/AuthController.cs index 3069652803..acc80521b4 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/API/AuthController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/API/AuthController.cs @@ -154,7 +154,9 @@ public async Task SignIn(UserLoginModel userLoginModel) var user = await _userManager.GetUserAsync(HttpContext.User); if (user is null) + { return NotFound("User not found"); + } var token = Request.Cookies[MoryxIdentityDefaults.JWT_COOKIE_NAME]; await _tokenService.InvalidateRefreshTokenAsync(token); @@ -186,7 +188,9 @@ public async Task RefreshToken() var result = await _tokenService.VerifyAndGenerateRefreshTokenAsync(tokenRequest); if (!result.Success) + { return BadRequest(result); + } HttpContext.Response.Cookies.SetJwtCookie(result); return Ok(JsonSerializer.Serialize(result)); @@ -200,7 +204,9 @@ public async Task GetUser() { var user = await _userManager.GetUserAsync(HttpContext.User); if (user is null) + { return NotFound("User not found"); + } var userModel = ModelConverter.GetUserModelFromUser(user); return Ok(userModel); @@ -227,7 +233,9 @@ public async Task> GetUserPermissions([FromQuery] string { var user = await _userManager.GetUserAsync(HttpContext.User); if (user is null) + { return NotFound("User not found"); + } filter ??= ""; var roles = await _userManager.GetRolesAsync(user); @@ -247,7 +255,9 @@ public IActionResult VerifyToken([FromBody] string token) { var isValid = _tokenService.IsTokenValid(token); if (isValid) + { return Accepted(); + } return Forbid(); } @@ -380,7 +390,9 @@ public async Task AddPermissionToRole(string roleName, [FromBody] var result = await _permissionManager.AddToRoleAsync(roleName, [permission]); if (result.Succeeded) + { return Ok(); + } return Problem(result.Errors.First().Description, null, 500); } @@ -476,7 +488,9 @@ public async Task CreatePermission([FromBody] string permission) var result = await _permissionManager.CreateAsync(permission); if (result.Succeeded) + { return Ok(); + } return Problem(result.Errors.First().Description, null, 500); } @@ -492,7 +506,9 @@ public async Task DeletePermission(string permissionId) var result = await _permissionManager.DeleteAsync(permissionId); if (result.Succeeded) + { return Ok(); + } return Problem(result.Errors.First().Description, null, 500); } @@ -520,7 +536,9 @@ public async Task DeleteUser(string userName) var result = await _userManager.DeleteAsync(user); if (result.Succeeded) + { return Ok(); + } return Problem(result.Errors.First().Description, null, 500); } @@ -529,4 +547,4 @@ private static bool IsSuperAdmin(string roleName) { return roleName == Roles.SuperAdmin; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/HomeController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/HomeController.cs index 18b09b7f1c..dfbc355f63 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/HomeController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/HomeController.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using Moryx.Identity.AccessManagement.Models; -using System.Diagnostics; namespace Moryx.Identity.AccessManagement.Controllers; @@ -20,4 +20,4 @@ public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/LoginController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/LoginController.cs index 930eec2e83..44a3609503 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/LoginController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/LoginController.cs @@ -40,20 +40,29 @@ public async Task Login(UserLoginModel userLoginModel, [FromQuery var user = await _userManager.FindByNameAsync(userLoginModel.UserName); if (user is null) + { return ReturnIndexWithError(returnUrl); + } var passwordCorrect = await _userManager.CheckPasswordAsync(user, userLoginModel.Password); if (!passwordCorrect) + { return ReturnIndexWithError(returnUrl); + } var tokenResult = await _tokenService.GenerateTokenAsync(user); HttpContext.Response.Cookies.SetJwtCookie(tokenResult, user); if (!string.IsNullOrEmpty(returnUrl)) + { return Redirect(Request.Query["returnUrl"]); + } if (await _userManager.IsInRoleAsync(user, Roles.SuperAdmin)) + { return RedirectToAction("Index", "Users"); + } + return RedirectToAction("Index", "Home"); } @@ -62,7 +71,9 @@ private IActionResult ReturnIndexWithError(string returnUrl) ViewBag.ErrorMessage = "UserName or Password incorrect!"; if (returnUrl != null) + { return RedirectToAction("Index", "Login", new { returnUrl = returnUrl, viewBagError = ViewBag.ErrorMessage }); + } return RedirectToAction("Index", "Login", new { viewBagError = ViewBag.ErrorMessage }); } @@ -74,11 +85,13 @@ public IActionResult Register() public async Task RegisterExecute(MoryxUserRegisterModel userModel) { - var user = ModelConverter.GetUserFromUserRegisterModel(userModel);; + var user = ModelConverter.GetUserFromUserRegisterModel(userModel); ; var userCreateResult = await _userManager.CreateAsync(user, userModel.Password); if (userCreateResult.Succeeded) + { return RedirectToAction("Index", "Home"); + } ViewBag.ErrorMessage = userCreateResult.Errors.First().Description; return View("Register"); @@ -140,4 +153,4 @@ public async Task ResetPassword(MoryxUserResetPasswordModel reset return RedirectToAction("Index", new { returnUrl = returnUrl }); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/PermissionsController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/PermissionsController.cs index 5db18b1c87..4cbb430863 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/PermissionsController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/PermissionsController.cs @@ -44,7 +44,9 @@ public async Task AddPermission(string permission) var creationResult = await _permissionManager.CreateAsync(permission); if (!creationResult.Succeeded) + { ViewBag.ErrorMessage = creationResult.Errors.First().Description; + } return RedirectToAction("Index", routeValues: new { viewBagError = ViewBag.ErrorMessage }); } @@ -54,8 +56,10 @@ public async Task Delete(string permissionId) var deletionResult = await _permissionManager.DeleteAsync(permissionId); if (!deletionResult.Succeeded) + { return BadRequest(deletionResult); + } return RedirectToAction("Index"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolePermissionsController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolePermissionsController.cs index fe3d490747..c06fe8ae4c 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolePermissionsController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolePermissionsController.cs @@ -40,7 +40,9 @@ public async Task Index(string roleId) var permissionViewModel = new PermissionViewModel { Value = permission }; if (authorizedPermissions.Any(authorized => authorized == permission)) + { permissionViewModel.Selected = true; + } model.Permissions.Add(permissionViewModel); } @@ -68,4 +70,4 @@ public async Task Update(RolePermissionsViewModel model) return RedirectToAction("Index", new { roleId = model.RoleId }); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolesController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolesController.cs index 6fe3e8f8df..10f9e2fdeb 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolesController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/RolesController.cs @@ -65,4 +65,4 @@ public async Task Delete(string roleId) return RedirectToAction("Index"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/UserRolesController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/UserRolesController.cs index 48408d8d7b..1f9f6c49b0 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/UserRolesController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/UserRolesController.cs @@ -76,4 +76,4 @@ public async Task Update(string id, ManageUserRolesViewModel mode return RedirectToAction("Index", new { userId = id }); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Controllers/MVC/UsersController.cs b/src/Moryx.Identity.AccessManagement/Controllers/MVC/UsersController.cs index a2cfabf068..a1c0b48dda 100644 --- a/src/Moryx.Identity.AccessManagement/Controllers/MVC/UsersController.cs +++ b/src/Moryx.Identity.AccessManagement/Controllers/MVC/UsersController.cs @@ -36,7 +36,10 @@ public async Task Edit(string userId) var userModel = ModelConverter.GetUserUpdateModelFromUser(user); var pwReset = await _pwResetService.GetPasswordResetAsync(userId); if (pwReset != null) + { userModel.PasswordResetToken = pwReset.ResetToken; + } + return View(userModel); } @@ -44,11 +47,15 @@ public async Task GenerateResetToken(MoryxUserUpdateModel model) { var user = await _userManager.FindByNameAsync(model.UserName); if (user == null) + { return NotFound(model.UserName); + } var oldPwReset = await _pwResetService.GetPasswordResetAsync(user.Id); if (oldPwReset != null) + { await _pwResetService.RemovePasswordResetAsync(oldPwReset); + } await _pwResetService.GeneratePasswordResetAsync(user.Id); return RedirectToAction("Edit", new { userId = user.Id }); @@ -58,7 +65,9 @@ public async Task Update(MoryxUserUpdateModel model) { var user = await _userManager.FindByNameAsync(model.UserName); if (user == null) + { return NotFound(model.UserName); + } user.Email = model.Email; user.Firstname = model.FirstName; @@ -72,11 +81,13 @@ public async Task Delete(string userId) { var user = await _userManager.FindByIdAsync(userId); if (user == null) + { return NotFound(userId); + } if (User.Identity.Name != user.UserName) { - var result = await _userManager.DeleteAsync(user); + _ = await _userManager.DeleteAsync(user); } else { @@ -85,4 +96,4 @@ public async Task Delete(string userId) return RedirectToAction("Index"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/MoryxIdentitiesDbContext.cs b/src/Moryx.Identity.AccessManagement/Data/MoryxIdentitiesDbContext.cs index f466c48c5a..f7c0d87da3 100644 --- a/src/Moryx.Identity.AccessManagement/Data/MoryxIdentitiesDbContext.cs +++ b/src/Moryx.Identity.AccessManagement/Data/MoryxIdentitiesDbContext.cs @@ -59,4 +59,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public DbSet RefreshTokens { get; set; } public DbSet PasswordResets { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/MoryxRole.cs b/src/Moryx.Identity.AccessManagement/Data/MoryxRole.cs index 52b1e2f1cf..d4a95a2278 100644 --- a/src/Moryx.Identity.AccessManagement/Data/MoryxRole.cs +++ b/src/Moryx.Identity.AccessManagement/Data/MoryxRole.cs @@ -25,4 +25,4 @@ public MoryxRole(string roleName) : base(roleName) /// Set of permissions assigned to this role. /// public virtual ICollection Permissions { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/MoryxUser.cs b/src/Moryx.Identity.AccessManagement/Data/MoryxUser.cs index 39e63be6f1..2ccd04d273 100644 --- a/src/Moryx.Identity.AccessManagement/Data/MoryxUser.cs +++ b/src/Moryx.Identity.AccessManagement/Data/MoryxUser.cs @@ -27,4 +27,4 @@ public class MoryxUser : IdentityUser public DateTime LastSignIn { get; set; } public virtual PasswordReset PasswordReset { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/PasswordReset.cs b/src/Moryx.Identity.AccessManagement/Data/PasswordReset.cs index 07f20fece5..984b432782 100644 --- a/src/Moryx.Identity.AccessManagement/Data/PasswordReset.cs +++ b/src/Moryx.Identity.AccessManagement/Data/PasswordReset.cs @@ -36,4 +36,4 @@ public class PasswordReset /// [ForeignKey(nameof(UserId))] public MoryxUser User { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/Permission.cs b/src/Moryx.Identity.AccessManagement/Data/Permission.cs index 954702ef8f..217126f391 100644 --- a/src/Moryx.Identity.AccessManagement/Data/Permission.cs +++ b/src/Moryx.Identity.AccessManagement/Data/Permission.cs @@ -30,4 +30,4 @@ public Permission() /// The collection of roles this permission is assigned to. /// public virtual ICollection Roles { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/PermissionRole.cs b/src/Moryx.Identity.AccessManagement/Data/PermissionRole.cs index 470c9fa1eb..cc9846e2db 100644 --- a/src/Moryx.Identity.AccessManagement/Data/PermissionRole.cs +++ b/src/Moryx.Identity.AccessManagement/Data/PermissionRole.cs @@ -27,4 +27,4 @@ public class PermissionRole /// The referenced permission /// public virtual Permission Permission { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Data/RefreshToken.cs b/src/Moryx.Identity.AccessManagement/Data/RefreshToken.cs index 42919a8a77..8f786ef347 100644 --- a/src/Moryx.Identity.AccessManagement/Data/RefreshToken.cs +++ b/src/Moryx.Identity.AccessManagement/Data/RefreshToken.cs @@ -58,4 +58,4 @@ public class RefreshToken /// [ForeignKey(nameof(UserId))] public MoryxUser User { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Extensions/ClaimsPrincipalExtension.cs b/src/Moryx.Identity.AccessManagement/Extensions/ClaimsPrincipalExtension.cs index de147bd48f..d6ea876ebb 100644 --- a/src/Moryx.Identity.AccessManagement/Extensions/ClaimsPrincipalExtension.cs +++ b/src/Moryx.Identity.AccessManagement/Extensions/ClaimsPrincipalExtension.cs @@ -12,7 +12,9 @@ internal static class ClaimsPrincipalExtension public string GeUserId() { if (principal == null) + { return string.Empty; + } var userId = principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier); return userId != null ? userId.Value : string.Empty; @@ -21,7 +23,9 @@ public string GeUserId() public string GetFullName() { if (principal == null) + { return string.Empty; + } var firstName = principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.GivenName); var lastName = principal.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Surname); @@ -44,4 +48,4 @@ public string GetFullName() return $"{firstName?.Value} {lastName?.Value}"; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Extensions/CookiesExtensions.cs b/src/Moryx.Identity.AccessManagement/Extensions/CookiesExtensions.cs index 1862123303..c5815047a8 100644 --- a/src/Moryx.Identity.AccessManagement/Extensions/CookiesExtensions.cs +++ b/src/Moryx.Identity.AccessManagement/Extensions/CookiesExtensions.cs @@ -30,12 +30,14 @@ internal void SetJwtCookie(AuthResult authResult, MoryxUser user = null) }); if (user != null) + { cookies.Append(MoryxIdentityDefaults.USER_COOKIE_NAME, user.UserName, new CookieOptions { Secure = true, SameSite = SameSiteMode.Lax, Domain = authResult.Domain, }); + } } internal void RemoveJwtCookie(string domain) @@ -52,4 +54,4 @@ internal void RemoveJwtCookie(string domain) cookies.Delete(MoryxIdentityDefaults.USER_COOKIE_NAME, cookieOption); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Extensions/HostExtensions.cs b/src/Moryx.Identity.AccessManagement/Extensions/HostExtensions.cs index 0d0e2f71f7..2b27cf1f26 100644 --- a/src/Moryx.Identity.AccessManagement/Extensions/HostExtensions.cs +++ b/src/Moryx.Identity.AccessManagement/Extensions/HostExtensions.cs @@ -139,7 +139,9 @@ private static async Task SeedDatabase(MoryxUserManager userManager, { logger.LogError("Super admin role could not be created"); foreach (var error in roleCreationResult.Errors) + { logger.LogError("{0}: {1}", error.Code, error.Description); + } return false; } @@ -168,7 +170,9 @@ private static async Task SeedDatabase(MoryxUserManager userManager, { logger.LogError("Admin user could not be created"); foreach (var error in userResult.Errors) + { logger.LogError("{0}: {1}", error.Code, error.Description); + } return false; } @@ -188,10 +192,12 @@ private static async Task SeedDatabase(MoryxUserManager userManager, { logger.LogError("Permission '{0}' could not be created", permission); foreach (var error in permissionResult.Errors) + { logger.LogError("{0}: {1}", error.Code, error.Description); + } } } return true; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Extensions/HtmlHelperExtensions.cs b/src/Moryx.Identity.AccessManagement/Extensions/HtmlHelperExtensions.cs index c65b0f1a06..21d56c3bc1 100644 --- a/src/Moryx.Identity.AccessManagement/Extensions/HtmlHelperExtensions.cs +++ b/src/Moryx.Identity.AccessManagement/Extensions/HtmlHelperExtensions.cs @@ -17,12 +17,16 @@ public string IsActionSelected(string controllerName, params string[] actionName string contextAction = (string)html.ViewContext.RouteData.Values["action"]; if (!string.Equals(contextController, controllerName, StringComparison.CurrentCultureIgnoreCase)) + { return string.Empty; + } foreach (string action in actionNames) { if (string.Equals(contextAction, action, StringComparison.CurrentCultureIgnoreCase)) + { return _selectedClass; + } } return string.Empty; } @@ -34,9 +38,11 @@ public string IsControllerSelected(params string[] controllerNames) foreach (string controller in controllerNames) { if (string.Equals(contextController, controller, StringComparison.CurrentCultureIgnoreCase)) + { return _selectedClass; + } } return string.Empty; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Extensions/ServiceCollectionExtensions.cs b/src/Moryx.Identity.AccessManagement/Extensions/ServiceCollectionExtensions.cs index 780e37ad6c..02fa85d1b0 100644 --- a/src/Moryx.Identity.AccessManagement/Extensions/ServiceCollectionExtensions.cs +++ b/src/Moryx.Identity.AccessManagement/Extensions/ServiceCollectionExtensions.cs @@ -154,4 +154,4 @@ public IServiceCollection AddMoryxAccessManagement(IConfiguration jwtConfigurati return services; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/AppClaimsPrincipalFactory.cs b/src/Moryx.Identity.AccessManagement/Identity/AppClaimsPrincipalFactory.cs index 90423ed660..db62786f15 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/AppClaimsPrincipalFactory.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/AppClaimsPrincipalFactory.cs @@ -34,14 +34,20 @@ public override async Task CreateAsync(MoryxUser user) var claimIdentity = ((ClaimsIdentity)principal.Identity); if (claimIdentity == null) + { return principal; + } if (!string.IsNullOrEmpty(user.Firstname)) + { claimIdentity.AddClaim(new Claim(ClaimTypes.GivenName, user.Firstname)); + } if (!string.IsNullOrEmpty(user.LastName)) + { claimIdentity.AddClaim(new Claim(ClaimTypes.Surname, user.LastName)); + } return principal; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/IPasswordResetService.cs b/src/Moryx.Identity.AccessManagement/Identity/IPasswordResetService.cs index a6143eed59..ff6e6bfbb0 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/IPasswordResetService.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/IPasswordResetService.cs @@ -12,4 +12,4 @@ public interface IPasswordResetService Task GeneratePasswordResetAsync(string userId); Task RemovePasswordResetAsync(PasswordReset passwordReset); -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/IPermissionManager.cs b/src/Moryx.Identity.AccessManagement/Identity/IPermissionManager.cs index 23e1daee6b..a5eb7f6f8e 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/IPermissionManager.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/IPermissionManager.cs @@ -60,4 +60,4 @@ public interface IPermissionManager /// The list of permissions to be removed from the role. /// An of the RemoveFromRole operation. Task UpdatePermissionsAsync(string roleName, IEnumerable permissions); -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/ITokenService.cs b/src/Moryx.Identity.AccessManagement/Identity/ITokenService.cs index b2d73dd3ef..b7579fce5d 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/ITokenService.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/ITokenService.cs @@ -51,4 +51,4 @@ public interface ITokenService /// /// All roles to be taken into account in the enumeration Task> GetAllPermissionClaimsAsync(IList roles); -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/MoryxUserManager.cs b/src/Moryx.Identity.AccessManagement/Identity/MoryxUserManager.cs index e8adb3654d..163ff24c62 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/MoryxUserManager.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/MoryxUserManager.cs @@ -63,4 +63,4 @@ public MoryxRoleManager(IRoleStore store, : base(store, roleValidators, keyNormalizer, errors, logger) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/PasswordResetService.cs b/src/Moryx.Identity.AccessManagement/Identity/PasswordResetService.cs index eeb84f46e3..56fbe10694 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/PasswordResetService.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/PasswordResetService.cs @@ -7,7 +7,7 @@ namespace Moryx.Identity.AccessManagement; -internal class PasswordResetService : IPasswordResetService +internal sealed class PasswordResetService : IPasswordResetService { private readonly MoryxIdentitiesDbContext _dbContext; @@ -47,4 +47,4 @@ private static string RandomString(int length = 5) return new string(Enumerable.Repeat(chars, length) .Select(s => s[RandomNumberGenerator.GetInt32(s.Length)]).ToArray()); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/PermissionManager.cs b/src/Moryx.Identity.AccessManagement/Identity/PermissionManager.cs index 2d8c20630c..35834ed9af 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/PermissionManager.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/PermissionManager.cs @@ -9,7 +9,7 @@ namespace Moryx.Identity.AccessManagement; /// -internal class PermissionManager : IPermissionManager +internal sealed class PermissionManager : IPermissionManager { private readonly MoryxRoleManager _roleManager; private readonly MoryxIdentitiesDbContext _identitiesDbContext; @@ -32,13 +32,17 @@ public PermissionManager(MoryxRoleManager roleManager, MoryxIdentitiesDbContext public async Task CreateAsync(string permission) { if (string.IsNullOrEmpty(permission)) + { return IdentityResult.Failed(new IdentityError { Description = "Permission cannot be empty" }); + } var friendlyName = FriendlyName(permission); var existing = await _identitiesDbContext.Permissions.FirstOrDefaultAsync(p => p.Name == friendlyName); if (existing != null) + { return IdentityResult.Failed(new IdentityError { Description = "Permission already exists" }); + } var permissionEntity = new Permission { Name = friendlyName }; @@ -53,7 +57,9 @@ public async Task DeleteAsync(string permissionId) { var existing = await _identitiesDbContext.Permissions.FirstOrDefaultAsync(p => p.Id == permissionId); if (existing == null) + { return IdentityResult.Failed(new IdentityError { Description = "Permission does not exists" }); + } _identitiesDbContext.Permissions.Remove(existing); @@ -66,7 +72,9 @@ public async Task DeleteAsync(string permissionId) public Task> FindForRoleAsync(string roleName) { if (roleName == Roles.SuperAdmin) + { return GetSuperAdminPermissionsAsync(); + } var role = _roleManager.Roles .Include(r => r.Permissions) @@ -84,13 +92,17 @@ public async Task RemoveFromRoleAsync(string roleName, IEnumerab { var role = await _roleManager.FindByNameAsync(roleName); if (role == null) + { return IdentityResult.Failed(new IdentityError { Description = "Role was not found" }); + } foreach (var permissionToRemove in permissions) { var permissionEntry = role.Permissions.FirstOrDefault(p => p.Id == permissionToRemove.Id); if (permissionEntry != null) + { role.Permissions.Remove(permissionEntry); + } } await _identitiesDbContext.SaveChangesAsync(); @@ -131,7 +143,9 @@ public async Task AddToRoleAsync(string roleName, IEnumerable r.Name == roleName); if (role == null) + { return IdentityResult.Failed(new IdentityError { Description = "Role was not found" }); + } var permissionEntities = _identitiesDbContext.Permissions.Where(permissionEntity => permissions.Contains(permissionEntity.Name)); @@ -173,4 +187,4 @@ private static string FriendlyName(string s) return res; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Identity/TokenService.cs b/src/Moryx.Identity.AccessManagement/Identity/TokenService.cs index 41694d42c7..e38ffedbe8 100644 --- a/src/Moryx.Identity.AccessManagement/Identity/TokenService.cs +++ b/src/Moryx.Identity.AccessManagement/Identity/TokenService.cs @@ -15,7 +15,7 @@ namespace Moryx.Identity.AccessManagement; /// -internal class TokenService : ITokenService +internal sealed class TokenService : ITokenService { private readonly JwtSettings _jwtSettings; private readonly TokenValidationParameters _tokenValidationParameters; @@ -60,10 +60,14 @@ public async Task GenerateTokenAsync(MoryxUser user) }; if (!string.IsNullOrEmpty(user.Firstname)) + { claims.Add(new Claim(ClaimTypes.GivenName, user.Firstname)); + } if (!string.IsNullOrEmpty(user.LastName)) + { claims.Add(new Claim(ClaimTypes.Surname, user.LastName)); + } // Add roles of the user var roles = await _userManager.GetRolesAsync(user); @@ -144,27 +148,41 @@ public async Task VerifyAndGenerateRefreshTokenAsync(TokenRequest to var jwtSecurityToken = validatedToken as JwtSecurityToken; var result = jwtSecurityToken?.Header.Alg.Equals(SecurityAlgorithms.HmacSha256, StringComparison.InvariantCultureIgnoreCase); if (result == false) + { return FailureResult($"The token uses invalid security algorithm {jwtSecurityToken.Header.Alg}.", tokenRequest); + } var jtiClaim = principal.Claims.SingleOrDefault(x => x.Type == JwtRegisteredClaimNames.Jti); if (jtiClaim == null) + { return FailureResult($"The token does not contain an ID.", tokenRequest); + } var storedRefreshToken = await _dbContext.RefreshTokens.FirstOrDefaultAsync(x => x.Token == tokenRequest.RefreshToken); if (storedRefreshToken == null) + { return FailureResult("The token does not exist.", tokenRequest); + } if (DateTime.UtcNow > storedRefreshToken.ExpiryDate) + { return FailureResult("The token has expired, user needs to login again.", tokenRequest); + } if (storedRefreshToken.IsUsed) + { return FailureResult("The refresh token has already been used.", tokenRequest); + } if (storedRefreshToken.IsRevoked) + { return FailureResult("The token has been revoked.", tokenRequest); + } if (storedRefreshToken.JwtId != jtiClaim.Value) + { return FailureResult("The token does not matched the stored token for this user.", tokenRequest); + } storedRefreshToken.IsUsed = true; _dbContext.RefreshTokens.Update(storedRefreshToken); @@ -202,7 +220,10 @@ public async Task InvalidateRefreshTokenAsync(string token) var refreshToken = await _dbContext.RefreshTokens.Where(token => token.JwtId == securityToken.Id).SingleOrDefaultAsync(); if (refreshToken == null) + { return; + } + _dbContext.RefreshTokens.Remove(refreshToken); await _dbContext.SaveChangesAsync(); } @@ -237,12 +258,4 @@ private static string RandomString(int length) return new string(Enumerable.Repeat(chars, length) .Select(s => s[RandomNumberGenerator.GetInt32(s.Length)]).ToArray()); } - - private static DateTime UnixTimeStampToDateTime(double unixTimeStamp) - { - // Unix timestamp is seconds past epoch - var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc); - dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToUniversalTime(); - return dtDateTime; - } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20210902100252_CreateIdentity.cs b/src/Moryx.Identity.AccessManagement/Migrations/20210902100252_CreateIdentity.cs index 09101ae669..66a4115006 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20210902100252_CreateIdentity.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20210902100252_CreateIdentity.cs @@ -5,268 +5,267 @@ using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +public partial class CreateIdentity : Migration { - public partial class CreateIdentity : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AspNetRoles", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "AspNetRoles", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoles", x => x.Id); + }); - migrationBuilder.CreateTable( - name: "AspNetUsers", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - Firstname = table.Column(type: "text", nullable: true), - LastName = table.Column(type: "text", nullable: true), - LastSignIn = table.Column(type: "timestamp without time zone", nullable: false), - UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "boolean", nullable: false), - PasswordHash = table.Column(type: "text", nullable: true), - SecurityStamp = table.Column(type: "text", nullable: true), - ConcurrencyStamp = table.Column(type: "text", nullable: true), - PhoneNumber = table.Column(type: "text", nullable: true), - PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), - TwoFactorEnabled = table.Column(type: "boolean", nullable: false), - LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), - LockoutEnabled = table.Column(type: "boolean", nullable: false), - AccessFailedCount = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "AspNetUsers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Firstname = table.Column(type: "text", nullable: true), + LastName = table.Column(type: "text", nullable: true), + LastSignIn = table.Column(type: "timestamp without time zone", nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUsers", x => x.Id); + }); - migrationBuilder.CreateTable( - name: "Permissions", - columns: table => new - { - Id = table.Column(type: "text", nullable: false), - Name = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Permissions", x => x.Id); - }); + migrationBuilder.CreateTable( + name: "Permissions", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Permissions", x => x.Id); + }); - migrationBuilder.CreateTable( - name: "AspNetRoleClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - RoleId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "AspNetRoleClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "AspNetUserClaims", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - UserId = table.Column(type: "text", nullable: false), - ClaimType = table.Column(type: "text", nullable: true), - ClaimValue = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AspNetUserClaims_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "AspNetUserClaims", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AspNetUserClaims_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "AspNetUserLogins", - columns: table => new - { - LoginProvider = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ProviderKey = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - ProviderDisplayName = table.Column(type: "text", nullable: true), - UserId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); - table.ForeignKey( - name: "FK_AspNetUserLogins_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "AspNetUserLogins", + columns: table => new + { + LoginProvider = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + ProviderKey = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); + table.ForeignKey( + name: "FK_AspNetUserLogins_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "AspNetUserRoles", - columns: table => new - { - UserId = table.Column(type: "text", nullable: false), - RoleId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AspNetUserRoles_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "AspNetUserRoles", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + RoleId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AspNetUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "AspNetUserTokens", - columns: table => new - { - UserId = table.Column(type: "text", nullable: false), - LoginProvider = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AspNetUserTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "AspNetUserTokens", + columns: table => new + { + UserId = table.Column(type: "text", nullable: false), + LoginProvider = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Name = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AspNetUserTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateTable( - name: "PermissionRoles", - columns: table => new - { - RoleId = table.Column(type: "text", nullable: false), - PermissionId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PermissionRoles", x => new { x.RoleId, x.PermissionId }); - table.ForeignKey( - name: "FK_PermissionRoles_AspNetRoles_RoleId", - column: x => x.RoleId, - principalTable: "AspNetRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PermissionRoles_Permissions_PermissionId", - column: x => x.PermissionId, - principalTable: "Permissions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "PermissionRoles", + columns: table => new + { + RoleId = table.Column(type: "text", nullable: false), + PermissionId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PermissionRoles", x => new { x.RoleId, x.PermissionId }); + table.ForeignKey( + name: "FK_PermissionRoles_AspNetRoles_RoleId", + column: x => x.RoleId, + principalTable: "AspNetRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PermissionRoles_Permissions_PermissionId", + column: x => x.PermissionId, + principalTable: "Permissions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_AspNetRoleClaims_RoleId", - table: "AspNetRoleClaims", - column: "RoleId"); + migrationBuilder.CreateIndex( + name: "IX_AspNetRoleClaims_RoleId", + table: "AspNetRoleClaims", + column: "RoleId"); - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "AspNetRoles", - column: "NormalizedName", - unique: true); + migrationBuilder.CreateIndex( + name: "RoleNameIndex", + table: "AspNetRoles", + column: "NormalizedName", + unique: true); - migrationBuilder.CreateIndex( - name: "IX_AspNetUserClaims_UserId", - table: "AspNetUserClaims", - column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_AspNetUserClaims_UserId", + table: "AspNetUserClaims", + column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_AspNetUserLogins_UserId", - table: "AspNetUserLogins", - column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_AspNetUserLogins_UserId", + table: "AspNetUserLogins", + column: "UserId"); - migrationBuilder.CreateIndex( - name: "IX_AspNetUserRoles_RoleId", - table: "AspNetUserRoles", - column: "RoleId"); + migrationBuilder.CreateIndex( + name: "IX_AspNetUserRoles_RoleId", + table: "AspNetUserRoles", + column: "RoleId"); - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "AspNetUsers", - column: "NormalizedEmail"); + migrationBuilder.CreateIndex( + name: "EmailIndex", + table: "AspNetUsers", + column: "NormalizedEmail"); - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "AspNetUsers", - column: "NormalizedUserName", - unique: true); + migrationBuilder.CreateIndex( + name: "UserNameIndex", + table: "AspNetUsers", + column: "NormalizedUserName", + unique: true); - migrationBuilder.CreateIndex( - name: "IX_PermissionRoles_PermissionId", - table: "PermissionRoles", - column: "PermissionId"); - } + migrationBuilder.CreateIndex( + name: "IX_PermissionRoles_PermissionId", + table: "PermissionRoles", + column: "PermissionId"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AspNetRoleClaims"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AspNetRoleClaims"); - migrationBuilder.DropTable( - name: "AspNetUserClaims"); + migrationBuilder.DropTable( + name: "AspNetUserClaims"); - migrationBuilder.DropTable( - name: "AspNetUserLogins"); + migrationBuilder.DropTable( + name: "AspNetUserLogins"); - migrationBuilder.DropTable( - name: "AspNetUserRoles"); + migrationBuilder.DropTable( + name: "AspNetUserRoles"); - migrationBuilder.DropTable( - name: "AspNetUserTokens"); + migrationBuilder.DropTable( + name: "AspNetUserTokens"); - migrationBuilder.DropTable( - name: "PermissionRoles"); + migrationBuilder.DropTable( + name: "PermissionRoles"); - migrationBuilder.DropTable( - name: "AspNetUsers"); + migrationBuilder.DropTable( + name: "AspNetUsers"); - migrationBuilder.DropTable( - name: "AspNetRoles"); + migrationBuilder.DropTable( + name: "AspNetRoles"); - migrationBuilder.DropTable( - name: "Permissions"); - } + migrationBuilder.DropTable( + name: "Permissions"); } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20210903081444_AddedRefreshTokensTable.cs b/src/Moryx.Identity.AccessManagement/Migrations/20210903081444_AddedRefreshTokensTable.cs index f1ac1122db..c65bd63cef 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20210903081444_AddedRefreshTokensTable.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20210903081444_AddedRefreshTokensTable.cs @@ -5,48 +5,47 @@ using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +public partial class AddedRefreshTokensTable : Migration { - public partial class AddedRefreshTokensTable : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "RefreshTokens", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Token = table.Column(type: "text", nullable: true), - JwtId = table.Column(type: "text", nullable: true), - IsUsed = table.Column(type: "boolean", nullable: false), - IsRevoked = table.Column(type: "boolean", nullable: false), - AddedDate = table.Column(type: "timestamp without time zone", nullable: false), - ExpiryDate = table.Column(type: "timestamp without time zone", nullable: false), - UserId = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_RefreshTokens", x => x.Id); - table.ForeignKey( - name: "FK_RefreshTokens_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); + migrationBuilder.CreateTable( + name: "RefreshTokens", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Token = table.Column(type: "text", nullable: true), + JwtId = table.Column(type: "text", nullable: true), + IsUsed = table.Column(type: "boolean", nullable: false), + IsRevoked = table.Column(type: "boolean", nullable: false), + AddedDate = table.Column(type: "timestamp without time zone", nullable: false), + ExpiryDate = table.Column(type: "timestamp without time zone", nullable: false), + UserId = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_RefreshTokens", x => x.Id); + table.ForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); - migrationBuilder.CreateIndex( - name: "IX_RefreshTokens_UserId", - table: "RefreshTokens", - column: "UserId"); - } + migrationBuilder.CreateIndex( + name: "IX_RefreshTokens_UserId", + table: "RefreshTokens", + column: "UserId"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "RefreshTokens"); - } + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "RefreshTokens"); } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20230309102819_UpdateTimestampType.cs b/src/Moryx.Identity.AccessManagement/Migrations/20230309102819_UpdateTimestampType.cs index 1315ff3ddf..f786371331 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20230309102819_UpdateTimestampType.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20230309102819_UpdateTimestampType.cs @@ -6,63 +6,62 @@ #nullable disable -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +public partial class UpdateTimestampType : Migration { - public partial class UpdateTimestampType : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ExpiryDate", - table: "RefreshTokens", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "RefreshTokens", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp without time zone"); - migrationBuilder.AlterColumn( - name: "AddedDate", - table: "RefreshTokens", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); + migrationBuilder.AlterColumn( + name: "AddedDate", + table: "RefreshTokens", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp without time zone"); - migrationBuilder.AlterColumn( - name: "LastSignIn", - table: "AspNetUsers", - type: "timestamp with time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp without time zone"); - } + migrationBuilder.AlterColumn( + name: "LastSignIn", + table: "AspNetUsers", + type: "timestamp with time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp without time zone"); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "ExpiryDate", - table: "RefreshTokens", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ExpiryDate", + table: "RefreshTokens", + type: "timestamp without time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); - migrationBuilder.AlterColumn( - name: "AddedDate", - table: "RefreshTokens", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); + migrationBuilder.AlterColumn( + name: "AddedDate", + table: "RefreshTokens", + type: "timestamp without time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); - migrationBuilder.AlterColumn( - name: "LastSignIn", - table: "AspNetUsers", - type: "timestamp without time zone", - nullable: false, - oldClrType: typeof(DateTime), - oldType: "timestamp with time zone"); - } + migrationBuilder.AlterColumn( + name: "LastSignIn", + table: "AspNetUsers", + type: "timestamp without time zone", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp with time zone"); } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20230403163720_AddedPasswordResets.cs b/src/Moryx.Identity.AccessManagement/Migrations/20230403163720_AddedPasswordResets.cs index 342fbdf4f8..9898f7c48f 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20230403163720_AddedPasswordResets.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20230403163720_AddedPasswordResets.cs @@ -7,45 +7,44 @@ #nullable disable -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +public partial class AddedPasswordResets : Migration { - public partial class AddedPasswordResets : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "PasswordResets", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ResetToken = table.Column(type: "text", nullable: false), - ExpiryTime = table.Column(type: "timestamp with time zone", nullable: false), - UserId = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PasswordResets", x => x.Id); - table.ForeignKey( - name: "FK_PasswordResets_AspNetUsers_UserId", - column: x => x.UserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); + migrationBuilder.CreateTable( + name: "PasswordResets", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ResetToken = table.Column(type: "text", nullable: false), + ExpiryTime = table.Column(type: "timestamp with time zone", nullable: false), + UserId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PasswordResets", x => x.Id); + table.ForeignKey( + name: "FK_PasswordResets_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); - migrationBuilder.CreateIndex( - name: "IX_PasswordResets_UserId", - table: "PasswordResets", - column: "UserId", - unique: true); - } + migrationBuilder.CreateIndex( + name: "IX_PasswordResets_UserId", + table: "PasswordResets", + column: "UserId", + unique: true); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PasswordResets"); - } + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PasswordResets"); } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20240920134143_ChangeRefreshTokensOnDelete.cs b/src/Moryx.Identity.AccessManagement/Migrations/20240920134143_ChangeRefreshTokensOnDelete.cs index 0e68fc3064..fbfe100ab5 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20240920134143_ChangeRefreshTokensOnDelete.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20240920134143_ChangeRefreshTokensOnDelete.cs @@ -5,42 +5,41 @@ #nullable disable -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +/// +public partial class ChangeRefreshTokensOnDelete : Migration { /// - public partial class ChangeRefreshTokensOnDelete : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_RefreshTokens_AspNetUsers_UserId", - table: "RefreshTokens"); - - migrationBuilder.AddForeignKey( - name: "FK_RefreshTokens_AspNetUsers_UserId", - table: "RefreshTokens", - column: "UserId", - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_RefreshTokens_AspNetUsers_UserId", - table: "RefreshTokens"); - - migrationBuilder.AddForeignKey( - name: "FK_RefreshTokens_AspNetUsers_UserId", - table: "RefreshTokens", - column: "UserId", - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } + migrationBuilder.DropForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + table: "RefreshTokens"); + + migrationBuilder.AddForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + table: "RefreshTokens", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + table: "RefreshTokens"); + + migrationBuilder.AddForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + table: "RefreshTokens", + column: "UserId", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); } } diff --git a/src/Moryx.Identity.AccessManagement/Migrations/20260108201039_MORYX10.cs b/src/Moryx.Identity.AccessManagement/Migrations/20260108201039_MORYX10.cs index 3cee4a1198..268b1ad9f9 100644 --- a/src/Moryx.Identity.AccessManagement/Migrations/20260108201039_MORYX10.cs +++ b/src/Moryx.Identity.AccessManagement/Migrations/20260108201039_MORYX10.cs @@ -5,90 +5,89 @@ #nullable disable -namespace Moryx.Identity.AccessManagement.Migrations +namespace Moryx.Identity.AccessManagement.Migrations; + +/// +public partial class MORYX10 : Migration { /// - public partial class MORYX10 : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Name", - table: "AspNetUserTokens", - type: "character varying(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "text"); + migrationBuilder.AlterColumn( + name: "Name", + table: "AspNetUserTokens", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); - migrationBuilder.AlterColumn( - name: "LoginProvider", - table: "AspNetUserTokens", - type: "character varying(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "text"); + migrationBuilder.AlterColumn( + name: "LoginProvider", + table: "AspNetUserTokens", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); - migrationBuilder.AlterColumn( - name: "ProviderKey", - table: "AspNetUserLogins", - type: "character varying(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "text"); + migrationBuilder.AlterColumn( + name: "ProviderKey", + table: "AspNetUserLogins", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); - migrationBuilder.AlterColumn( - name: "LoginProvider", - table: "AspNetUserLogins", - type: "character varying(128)", - maxLength: 128, - nullable: false, - oldClrType: typeof(string), - oldType: "text"); - } + migrationBuilder.AlterColumn( + name: "LoginProvider", + table: "AspNetUserLogins", + type: "character varying(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + } - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Name", - table: "AspNetUserTokens", - type: "text", - nullable: false, - oldClrType: typeof(string), - oldType: "character varying(128)", - oldMaxLength: 128); + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Name", + table: "AspNetUserTokens", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); - migrationBuilder.AlterColumn( - name: "LoginProvider", - table: "AspNetUserTokens", - type: "text", - nullable: false, - oldClrType: typeof(string), - oldType: "character varying(128)", - oldMaxLength: 128); + migrationBuilder.AlterColumn( + name: "LoginProvider", + table: "AspNetUserTokens", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); - migrationBuilder.AlterColumn( - name: "ProviderKey", - table: "AspNetUserLogins", - type: "text", - nullable: false, - oldClrType: typeof(string), - oldType: "character varying(128)", - oldMaxLength: 128); + migrationBuilder.AlterColumn( + name: "ProviderKey", + table: "AspNetUserLogins", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); - migrationBuilder.AlterColumn( - name: "LoginProvider", - table: "AspNetUserLogins", - type: "text", - nullable: false, - oldClrType: typeof(string), - oldType: "character varying(128)", - oldMaxLength: 128); - } + migrationBuilder.AlterColumn( + name: "LoginProvider", + table: "AspNetUserLogins", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(128)", + oldMaxLength: 128); } } diff --git a/src/Moryx.Identity.AccessManagement/Models/ErrorViewModel.cs b/src/Moryx.Identity.AccessManagement/Models/ErrorViewModel.cs index 8d3e07ad8a..27cbfa3e65 100644 --- a/src/Moryx.Identity.AccessManagement/Models/ErrorViewModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/ErrorViewModel.cs @@ -17,4 +17,4 @@ public class ErrorViewModel /// True if the exists; false otherwise. /// public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/MoryxUserModel.cs b/src/Moryx.Identity.AccessManagement/Models/MoryxUserModel.cs index 24a18a94fa..3d4a7e5a32 100644 --- a/src/Moryx.Identity.AccessManagement/Models/MoryxUserModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/MoryxUserModel.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Identity; using Moryx.Identity.AccessManagement.Data; -using System.ComponentModel.DataAnnotations; namespace Moryx.Identity.AccessManagement.Models; @@ -38,4 +38,4 @@ public class MoryxUserModel /// Maps to . /// public string Password { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/MoryxUserRegisterModel.cs b/src/Moryx.Identity.AccessManagement/Models/MoryxUserRegisterModel.cs index 87d5d34267..3db94c5c4a 100644 --- a/src/Moryx.Identity.AccessManagement/Models/MoryxUserRegisterModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/MoryxUserRegisterModel.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Identity; using Moryx.Identity.AccessManagement.Data; -using System.ComponentModel.DataAnnotations; namespace Moryx.Identity.AccessManagement.Models; @@ -39,4 +39,4 @@ public class MoryxUserRegisterModel /// [Required] public string Password { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/MoryxUserResetPasswordModel.cs b/src/Moryx.Identity.AccessManagement/Models/MoryxUserResetPasswordModel.cs index b223a33e07..afbfe3141d 100644 --- a/src/Moryx.Identity.AccessManagement/Models/MoryxUserResetPasswordModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/MoryxUserResetPasswordModel.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Identity; using Moryx.Identity.AccessManagement.Data; -using System.ComponentModel.DataAnnotations; namespace Moryx.Identity.AccessManagement.Models; @@ -36,4 +36,4 @@ public class MoryxUserResetPasswordModel /// [Required] public string ResetToken { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/MoryxUserUpdateModel.cs b/src/Moryx.Identity.AccessManagement/Models/MoryxUserUpdateModel.cs index abf2ae2a75..b01a604a32 100644 --- a/src/Moryx.Identity.AccessManagement/Models/MoryxUserUpdateModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/MoryxUserUpdateModel.cs @@ -39,4 +39,4 @@ public class MoryxUserUpdateModel /// [Editable(false)] public string PasswordResetToken { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/PermissionModel.cs b/src/Moryx.Identity.AccessManagement/Models/PermissionModel.cs index c1c42bba8d..c493983081 100644 --- a/src/Moryx.Identity.AccessManagement/Models/PermissionModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/PermissionModel.cs @@ -24,4 +24,4 @@ public class PermissionModel /// Maps to . /// public string[] Roles { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/PermissionsViewModel.cs b/src/Moryx.Identity.AccessManagement/Models/PermissionsViewModel.cs index 53bb6c1386..56628deb70 100644 --- a/src/Moryx.Identity.AccessManagement/Models/PermissionsViewModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/PermissionsViewModel.cs @@ -24,4 +24,4 @@ public class PermissionsViewModel /// Maps to /// public string[] Roles { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/RolePermissionsViewModel.cs b/src/Moryx.Identity.AccessManagement/Models/RolePermissionsViewModel.cs index 13f80452af..b182da3860 100644 --- a/src/Moryx.Identity.AccessManagement/Models/RolePermissionsViewModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/RolePermissionsViewModel.cs @@ -41,4 +41,4 @@ public class PermissionViewModel /// True if the permission is to be assigned to the role; false otherwise. /// public bool Selected { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/TokenRequest.cs b/src/Moryx.Identity.AccessManagement/Models/TokenRequest.cs index 8ea8a29e33..9aed4e4c2d 100644 --- a/src/Moryx.Identity.AccessManagement/Models/TokenRequest.cs +++ b/src/Moryx.Identity.AccessManagement/Models/TokenRequest.cs @@ -21,4 +21,4 @@ public class TokenRequest /// [Required] public string RefreshToken { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/UserLoginModel.cs b/src/Moryx.Identity.AccessManagement/Models/UserLoginModel.cs index 9ce50ef458..cc682f15f9 100644 --- a/src/Moryx.Identity.AccessManagement/Models/UserLoginModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/UserLoginModel.cs @@ -21,4 +21,4 @@ public class UserLoginModel /// [Required] public string Password { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Models/UserRolesViewModel.cs b/src/Moryx.Identity.AccessManagement/Models/UserRolesViewModel.cs index b90e0ad7f2..1a0410e79c 100644 --- a/src/Moryx.Identity.AccessManagement/Models/UserRolesViewModel.cs +++ b/src/Moryx.Identity.AccessManagement/Models/UserRolesViewModel.cs @@ -41,4 +41,4 @@ public class UserRolesViewModel /// True if the role is to be assigned to the user; false otherwise. /// public bool Selected { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity.AccessManagement/Settings/JwtSettings.cs b/src/Moryx.Identity.AccessManagement/Settings/JwtSettings.cs index 1465896b12..31c8dc78be 100644 --- a/src/Moryx.Identity.AccessManagement/Settings/JwtSettings.cs +++ b/src/Moryx.Identity.AccessManagement/Settings/JwtSettings.cs @@ -27,4 +27,4 @@ public class JwtSettings /// Expiration Time of the token in minutes /// public int ExpirationInMinutes { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/Models/AuthResult.cs b/src/Moryx.Identity/Models/AuthResult.cs index 2624633c55..74a1eef030 100644 --- a/src/Moryx.Identity/Models/AuthResult.cs +++ b/src/Moryx.Identity/Models/AuthResult.cs @@ -32,4 +32,4 @@ public class AuthResult /// The domain associated with the authentication request. /// public string Domain { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxAccessManagementClient.cs b/src/Moryx.Identity/MoryxAccessManagementClient.cs index f68ee5143c..10c219374a 100644 --- a/src/Moryx.Identity/MoryxAccessManagementClient.cs +++ b/src/Moryx.Identity/MoryxAccessManagementClient.cs @@ -151,4 +151,4 @@ public async Task> GetPermissionsAsync(string token, string return await JsonSerializer.DeserializeAsync>(await result.Content.ReadAsStreamAsync()); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxAuthorizationPolicyProvider.cs b/src/Moryx.Identity/MoryxAuthorizationPolicyProvider.cs index d63ef80187..63c55bc759 100644 --- a/src/Moryx.Identity/MoryxAuthorizationPolicyProvider.cs +++ b/src/Moryx.Identity/MoryxAuthorizationPolicyProvider.cs @@ -31,4 +31,4 @@ public override async Task GetPolicyAsync(string policyName } return policy; } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxIdentityDefaults.cs b/src/Moryx.Identity/MoryxIdentityDefaults.cs index 71bbdc97a4..5b7cb44cce 100644 --- a/src/Moryx.Identity/MoryxIdentityDefaults.cs +++ b/src/Moryx.Identity/MoryxIdentityDefaults.cs @@ -27,4 +27,4 @@ public static class MoryxIdentityDefaults /// Name of the user cookie /// public const string USER_COOKIE_NAME = "moryx_user"; -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxIdentityExtensions.cs b/src/Moryx.Identity/MoryxIdentityExtensions.cs index 78ff028fbd..964921a631 100644 --- a/src/Moryx.Identity/MoryxIdentityExtensions.cs +++ b/src/Moryx.Identity/MoryxIdentityExtensions.cs @@ -57,4 +57,4 @@ public AuthenticationBuilder AddMoryxIdentity(Action confi public AuthenticationBuilder AddMoryxIdentity(string authenticationScheme, Action configureOptions) => builder.AddScheme(authenticationScheme, configureOptions); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxIdentityHandler.cs b/src/Moryx.Identity/MoryxIdentityHandler.cs index 9ced3a9070..e39ebf37c9 100644 --- a/src/Moryx.Identity/MoryxIdentityHandler.cs +++ b/src/Moryx.Identity/MoryxIdentityHandler.cs @@ -48,25 +48,36 @@ protected override async Task HandleAuthenticateAsync() var metadata = Context.GetEndpoint()?.Metadata; var authorizeAttributes = metadata?.OfType(); if (authorizeAttributes?.Any() != true || metadata.GetMetadata() != null) + { return AuthenticateResult.NoResult(); // endpoint has AllowAnonymous or no Authorize attribute + } if (Context.User == null) + { return AuthenticateResult.Fail("User not found."); + } var token = Context.Request.Cookies[MoryxIdentityDefaults.JWT_COOKIE_NAME]; if (token == null) + { return AuthenticateResult.Fail("JwtToken not found"); + } var refreshToken = Context.Request.Cookies[MoryxIdentityDefaults.REFRESH_TOKEN_COOKIE_NAME]; if (refreshToken == null) + { return AuthenticateResult.Fail("RefreshToken not found"); + } var decodedJwt = _jwtTokenHandler.ReadJwtToken(token); if (decodedJwt.ValidTo < DateTime.UtcNow) { var refreshResult = await _client.GetRefreshedTokensAsync(token, refreshToken); if (refreshResult is null || !refreshResult.Success) + { return AuthenticateResult.Fail("Token is expired and could not be refreshed"); + } + token = refreshResult.Token; refreshToken = refreshResult.RefreshToken; Context.Response.Cookies.Append(MoryxIdentityDefaults.JWT_COOKIE_NAME, token, new CookieOptions @@ -89,17 +100,24 @@ protected override async Task HandleAuthenticateAsync() string requiredPolicy = ""; var distinctPolicies = authorizeAttributes.Select(a => a.Policy).Where(s => !string.IsNullOrEmpty(s)).Distinct(); if (distinctPolicies.Count() == 1) + { requiredPolicy = distinctPolicies.First(); + } var permissions = await _client.GetPermissionsAsync(token, refreshToken, requiredPolicy); if (permissions == null) + { return AuthenticateResult.Fail("Retrieving Permissions failed"); + } var appIdentity = new ClaimsIdentity(MoryxIdentityOptions.MoryxIdentity); foreach (var perm in permissions) + { appIdentity.AddClaim(new Claim("Permission", perm)); + } + var ticket = new AuthenticationTicket( new ClaimsPrincipal(appIdentity), this.Scheme.Name); return AuthenticateResult.Success(ticket); } -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxIdentityOptions.cs b/src/Moryx.Identity/MoryxIdentityOptions.cs index 9ff847fbbc..a67255fbf1 100644 --- a/src/Moryx.Identity/MoryxIdentityOptions.cs +++ b/src/Moryx.Identity/MoryxIdentityOptions.cs @@ -29,4 +29,4 @@ public class MoryxIdentityOptions : AuthenticationSchemeOptions /// Uri to retrieve a new token using a refresh token /// public string RefreshTokenUri { get; } = "/api/auth/RefreshToken"; -} \ No newline at end of file +} diff --git a/src/Moryx.Identity/MoryxIdentityResultHandler.cs b/src/Moryx.Identity/MoryxIdentityResultHandler.cs index 65fdde6279..9cb4e00260 100644 --- a/src/Moryx.Identity/MoryxIdentityResultHandler.cs +++ b/src/Moryx.Identity/MoryxIdentityResultHandler.cs @@ -46,4 +46,4 @@ public async Task HandleAsync( } await _handler.HandleAsync(requestDelegate, httpContext, authorizationPolicy, policyAuthorizationResult); } -} \ No newline at end of file +} diff --git a/src/Moryx.Launcher/IShellNavigator.cs b/src/Moryx.Launcher/IShellNavigator.cs index c739a8f43f..1eff007e5f 100644 --- a/src/Moryx.Launcher/IShellNavigator.cs +++ b/src/Moryx.Launcher/IShellNavigator.cs @@ -15,4 +15,4 @@ public interface IShellNavigator /// Gathers the available Web Modules to display in the shell /// Task> GetModuleItemsAsync(HttpContext context); -} \ No newline at end of file +} diff --git a/src/Moryx.Launcher/LauncherRegionAttribute.cs b/src/Moryx.Launcher/LauncherRegionAttribute.cs index d404c45b30..a96cb89dce 100644 --- a/src/Moryx.Launcher/LauncherRegionAttribute.cs +++ b/src/Moryx.Launcher/LauncherRegionAttribute.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 - /// /// Decorator for partial view (Region) /// diff --git a/src/Moryx.Launcher/Models/CultureModel.cs b/src/Moryx.Launcher/Models/CultureModel.cs index ce10f5c3b7..d089b4aaeb 100644 --- a/src/Moryx.Launcher/Models/CultureModel.cs +++ b/src/Moryx.Launcher/Models/CultureModel.cs @@ -3,7 +3,7 @@ namespace Moryx.Launcher; // TODO: move to ns *.Models in the next major -internal class CultureModel +internal sealed class CultureModel { public string Name { get; set; } diff --git a/src/Moryx.Launcher/Models/RegionItem.cs b/src/Moryx.Launcher/Models/RegionItem.cs index b69488ae76..3d1d2e85f8 100644 --- a/src/Moryx.Launcher/Models/RegionItem.cs +++ b/src/Moryx.Launcher/Models/RegionItem.cs @@ -6,7 +6,7 @@ namespace Moryx.Launcher; // TODO: move to ns *.Models in the next major /// /// Describes a region in the launcher /// -internal class RegionItem +internal sealed class RegionItem { /// /// Name of the partial for the given region diff --git a/src/Moryx.Launcher/ShellNavigator.cs b/src/Moryx.Launcher/ShellNavigator.cs index e4731ad5cc..cb3c67a9d6 100644 --- a/src/Moryx.Launcher/ShellNavigator.cs +++ b/src/Moryx.Launcher/ShellNavigator.cs @@ -111,10 +111,10 @@ private static RegionItem[] LoadRegions() // Transform to models var regions = (from pV in partialViews - let regionAttr = pV.GetCustomAttribute() - let config = _launcherConfig.Regions.FirstOrDefault(x => x.Name == regionAttr.Name) - where config != null - select new RegionItem { PartialView = regionAttr.Name, Region = config.Region }).ToArray(); + let regionAttr = pV.GetCustomAttribute() + let config = _launcherConfig.Regions.FirstOrDefault(x => x.Name == regionAttr.Name) + where config != null + select new RegionItem { PartialView = regionAttr.Name, Region = config.Region }).ToArray(); return regions; } @@ -146,7 +146,7 @@ private static PageActionDescriptorAndModuleItem[] LoadCompiledActionDescriptors var index = _launcherConfig.ModuleSortIndices.Select(i => i.SortIndex).DefaultIfEmpty(0).Max(); foreach (var descriptorAndModule in descriptorModuleTuples.OrderBy(t => t.ModuleItem.Title)) { - var module = descriptorAndModule.ModuleItem; + var module = descriptorAndModule.ModuleItem; var route = module is ExternalModuleItem ? module.Route.Replace("external/", "") : module.Route; var indexConfig = _launcherConfig.ModuleSortIndices.FirstOrDefault(m => m.Route == route); if (indexConfig != null) @@ -178,7 +178,9 @@ private static WebModuleItem CreateWebModuleItem(CompiledPageActionDescriptor pa { var webModuleAttribute = pageActionDescriptor.EndpointMetadata.OfType().SingleOrDefault(); if (webModuleAttribute is null) + { return null; + } var streamAttribute = pageActionDescriptor.EndpointMetadata.OfType().SingleOrDefault(); return new WebModuleItem diff --git a/src/Moryx.Media.Endpoints/MediaModelConverter.cs b/src/Moryx.Media.Endpoints/MediaModelConverter.cs index 9fb7e4c04e..8d225c3a1e 100644 --- a/src/Moryx.Media.Endpoints/MediaModelConverter.cs +++ b/src/Moryx.Media.Endpoints/MediaModelConverter.cs @@ -10,7 +10,9 @@ internal static class MediaModelConverter public static ContentDescriptorModel ConvertContent(ContentDescriptor contentDescriptor) { if (contentDescriptor == null) + { return null; + } var variants = contentDescriptor.Variants.ToList(); return new ContentDescriptorModel @@ -21,4 +23,4 @@ public static ContentDescriptorModel ConvertContent(ContentDescriptor contentDes Master = contentDescriptor.GetMaster() }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/MediaPermissions.cs b/src/Moryx.Media.Endpoints/MediaPermissions.cs index 68f0a8711b..795e6e14c5 100644 --- a/src/Moryx.Media.Endpoints/MediaPermissions.cs +++ b/src/Moryx.Media.Endpoints/MediaPermissions.cs @@ -9,4 +9,4 @@ public static class MediaPermissions public const string CanView = _prefix + "CanView"; public const string CanAdd = _prefix + "CanAdd"; public const string CanRemove = _prefix + "CanRemove"; -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/MediaServerController.cs b/src/Moryx.Media.Endpoints/MediaServerController.cs index e28dc5936f..485123e11a 100644 --- a/src/Moryx.Media.Endpoints/MediaServerController.cs +++ b/src/Moryx.Media.Endpoints/MediaServerController.cs @@ -1,13 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Net; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Moryx.Media.Endpoints.Properties; -using System.Net; using Moryx.AspNetCore; using Moryx.Media.Endpoints.Models; +using Moryx.Media.Endpoints.Properties; namespace Moryx.Media.Endpoints; @@ -36,7 +36,10 @@ public ActionResult GetAll() var contents = _mediaServer.GetAll(); var contentModels = new List(); foreach (var c in contents) + { contentModels.Add(MediaModelConverter.ConvertContent(c)); + } + return contentModels.ToArray(); } @@ -50,11 +53,15 @@ public ActionResult GetAll() public ActionResult Get(string guid) { if (!Guid.TryParse(guid, out var parsedGuid)) + { return BadRequest(); + } var content = _mediaServer.Get(parsedGuid); if (content is null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } return MediaModelConverter.ConvertContent(content); } @@ -69,11 +76,15 @@ public ActionResult Get(string guid) public ActionResult GetVariant(string guid, string variantName) { if (!Guid.TryParse(guid, out var parsedGuid)) + { return BadRequest(); + } var variant = _mediaServer.GetVariant(parsedGuid, variantName); if (variant is null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } return variant; } @@ -88,24 +99,36 @@ public ActionResult GetVariant(string guid, string variantNam public async Task GetVariantStream(string guid, string variantName, bool preview = false) { if (!Guid.TryParse(guid, out var parsedGuid)) + { return BadRequest(); + } var variant = _mediaServer.GetVariant(parsedGuid, variantName); if (variant is null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } if (string.IsNullOrEmpty(variant.FileHash) || string.IsNullOrEmpty(variant.MimeType)) + { return BadRequest(); + } FileDescriptor usedDescriptor; if (preview) + { usedDescriptor = variant.Preview; + } else + { usedDescriptor = variant; + } var stream = _mediaServer.GetStream(usedDescriptor); if (stream is null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } return new FileStreamResult(stream, usedDescriptor.MimeType) { @@ -123,7 +146,9 @@ public async Task GetVariantStream(string guid, string variantName public async Task> AddMaster(IFormFile formFile) { if (!UploadValidation.ValidateFormFile(formFile, _mediaServer, out var errorMessage)) + { return BadRequest(errorMessage); + } if (formFile.Length > 0) { @@ -154,13 +179,19 @@ public async Task> AddVariant(string contentId, string varian { if (!UploadValidation.ValidateFormFile(formFile, _mediaServer, out var errorMessage)) + { return BadRequest(errorMessage); + } if (!Guid.TryParse(contentId, out var parsedGuid)) + { return BadRequest($"Invalid guid {contentId}"); + } if (_mediaServer.Get(parsedGuid) is null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } if (formFile.Length > 0) { @@ -171,7 +202,9 @@ public async Task> AddVariant(string contentId, string varian if (resultData.Result != ContentAddingResult.Ok) { if (resultGuid.Equals(contentId)) + { return Conflict($"{trustedFileName} file already exists in this content."); + } else { return Conflict($"{trustedFileName} file already exists in content {resultGuid} with content name {resultData.Descriptor.Name}."); @@ -194,10 +227,14 @@ public async Task> AddVariant(string contentId, string varian public ActionResult RemoveContent(string guid) { if (!Guid.TryParse(guid, out var parsedGuid)) + { return BadRequest(); + } if (!_mediaServer.DeleteContent(parsedGuid)) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } return Ok(); } @@ -211,11 +248,15 @@ public ActionResult RemoveContent(string guid) public ActionResult RemoveVariant(string guid, string variantName) { if (!Guid.TryParse(guid, out var parsedGuid)) + { return BadRequest(); + } if (!_mediaServer.DeleteVariant(parsedGuid, variantName)) + { return NotFound(new MoryxExceptionResponse { Title = Strings.MediaServerController_MediaNotFound }); + } return Ok(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/Models/ContentDescriptorModel.cs b/src/Moryx.Media.Endpoints/Models/ContentDescriptorModel.cs index b83c95ab63..ab8818dec1 100644 --- a/src/Moryx.Media.Endpoints/Models/ContentDescriptorModel.cs +++ b/src/Moryx.Media.Endpoints/Models/ContentDescriptorModel.cs @@ -30,4 +30,4 @@ public class ContentDescriptorModel /// [DataMember] public VariantDescriptor Master { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/Models/FileDescriptorModel.cs b/src/Moryx.Media.Endpoints/Models/FileDescriptorModel.cs index 6ef162e3ed..5baed69244 100644 --- a/src/Moryx.Media.Endpoints/Models/FileDescriptorModel.cs +++ b/src/Moryx.Media.Endpoints/Models/FileDescriptorModel.cs @@ -37,4 +37,4 @@ internal abstract class FileDescriptorModel /// [DataMember] public string MimeType { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/Models/PreviewDescriptorModel.cs b/src/Moryx.Media.Endpoints/Models/PreviewDescriptorModel.cs index 0458fa4255..b63ab65c58 100644 --- a/src/Moryx.Media.Endpoints/Models/PreviewDescriptorModel.cs +++ b/src/Moryx.Media.Endpoints/Models/PreviewDescriptorModel.cs @@ -6,11 +6,11 @@ namespace Moryx.Media.Endpoints.Models; [DataContract] -internal class PreviewDescriptorModel : FileDescriptorModel +internal sealed class PreviewDescriptorModel : FileDescriptorModel { /// /// State of the preview /// [DataMember] public PreviewState PreviewState { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Endpoints/UploadValidation.cs b/src/Moryx.Media.Endpoints/UploadValidation.cs index dcb0cfc7be..32ac6fc3d7 100644 --- a/src/Moryx.Media.Endpoints/UploadValidation.cs +++ b/src/Moryx.Media.Endpoints/UploadValidation.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Microsoft.AspNetCore.Http; using System.Net; +using Microsoft.AspNetCore.Http; namespace Moryx.Media.Endpoints; @@ -39,12 +39,16 @@ public static bool ValidateFormFile(IFormFile formFile, errorMessage = $"{trustedFileName} file size of 0 MB is to small!"; if (formFile.Length == 0) + { return false; + } var megabyteSizeLimit = mediaServer.FileSizeLimitInMb(); errorMessage = $"{trustedFileName} exceeds {megabyteSizeLimit:N1} MB."; if (formFile.Length > megabyteSizeLimit * Megabyte) + { return false; + } try { @@ -53,16 +57,22 @@ public static bool ValidateFormFile(IFormFile formFile, // Check if the file's only content was a BOM errorMessage = $"{trustedFileName} file size of 0 MB is to small!"; if (reader.EndOfStream) + { return false; + } var fileTypes = mediaServer.GetSupportedFileTypes(); errorMessage = $"{trustedFileName} file type isn't permitted."; if (!fileTypes.Contains(Path.GetExtension(formFile.FileName))) + { return false; + } errorMessage = $"{trustedFileName} file signature doesn't match the file's extension."; if (!IsValidFileExtensionAndSignature(formFile.FileName, readStream, fileTypes)) + { return false; + } } catch { @@ -77,11 +87,15 @@ public static bool ValidateFormFile(IFormFile formFile, private static bool IsValidFileExtensionAndSignature(string fileName, Stream data, string[] permittedExtensions) { if (string.IsNullOrEmpty(fileName) || data == null || data.Length == 0) + { return false; + } var extension = Path.GetExtension(fileName).ToLowerInvariant(); if (string.IsNullOrEmpty(extension) || !permittedExtensions.Contains(extension)) + { return false; + } data.Position = 0; @@ -90,8 +104,12 @@ private static bool IsValidFileExtensionAndSignature(string fileName, Stream dat { // Limits characters to ASCII encoding. for (var i = 0; i < data.Length; i++) + { if (reader.ReadByte() > sbyte.MaxValue) + { return false; + } + } return true; } @@ -106,4 +124,4 @@ private static bool IsValidFileExtensionAndSignature(string fileName, Stream dat var headerBytes = reader.ReadBytes(signatures.Max(m => m.Length)); return signatures.Any(signature => headerBytes.Take(signature.Length).SequenceEqual(signature)); } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/ContentManager/ContentManager.cs b/src/Moryx.Media.Server/ContentManager/ContentManager.cs index 5e67b2f3c6..93c24a24f2 100644 --- a/src/Moryx.Media.Server/ContentManager/ContentManager.cs +++ b/src/Moryx.Media.Server/ContentManager/ContentManager.cs @@ -48,11 +48,15 @@ public void Start() PreviewService.PreviewJobCompleted += OnPreviewJobCompleted; if (!Directory.Exists(Config.StoragePath)) + { Directory.CreateDirectory(Config.StoragePath); + } _descriptorDirectory = Path.Combine(Config.StoragePath, "descriptors"); if (!Directory.Exists(_descriptorDirectory)) + { Directory.CreateDirectory(_descriptorDirectory); + } LoadDescriptors(); @@ -87,8 +91,10 @@ public IReadOnlyList GetDescriptors(uint start, uint offset) { var descriptors = new List((int)offset); if (start > _descriptors.Count) + { throw new ArgumentOutOfRangeException(nameof(start), start, $"Start value is greater than list count {_descriptors.Count}"); + } for (var idx = start; idx < start + offset && idx < _descriptors.Count; idx++) { @@ -102,7 +108,9 @@ public IReadOnlyList GetDescriptors(uint start, uint offset) public Stream GetStream(FileDescriptor fileDescriptor) { if (string.IsNullOrEmpty(fileDescriptor.FileHash)) + { return null; + } var variantFilePath = HashPath.FromHash(fileDescriptor.FileHash).FilePath(Config.StoragePath); return File.Exists(variantFilePath) ? new FileStream(variantFilePath, FileMode.Open, FileAccess.Read) : null; @@ -111,7 +119,9 @@ public Stream GetStream(FileDescriptor fileDescriptor) public async Task AddMaster(string fileName, Stream contentStream) { if (!contentStream.CanSeek) + { throw new NotSupportedException("Stream needs to be seekable."); + } var hashPath = HashPath.FromStream(contentStream); @@ -155,12 +165,16 @@ public async Task AddMaster(string fileName, Stream contentSt public async Task AddVariant(Guid contentId, string variantName, string fileName, Stream contentStream) { if (variantName == MediaConstants.MasterName) + { return new ContentAddingInfo { Descriptor = null, Result = ContentAddingResult.VariantNameReserved }; + } var descriptor = GetDescriptor(contentId); var variant = descriptor?.GetVariant(variantName); if (variant != null) + { return new ContentAddingInfo { Descriptor = descriptor, Result = ContentAddingResult.AlreadyExists }; + } var hash = HashPath.FromStream(contentStream); if (File.Exists(hash.FilePath(Config.StoragePath))) @@ -238,7 +252,9 @@ private Tuple GetVariantByHash(string hash } if (existingVariant != null) + { return new Tuple(currentDescriptor, existingVariant); + } } return null; @@ -248,11 +264,16 @@ private bool Delete(ContentDescriptor contentDescriptor) { var variants = contentDescriptor.Variants.ToArray(); foreach (var variantDescriptor in variants) + { Delete(contentDescriptor, variantDescriptor); + } var descriptorFile = Path.Combine(_descriptorDirectory, contentDescriptor.Id.ToString()); if (File.Exists(descriptorFile)) + { File.Delete(descriptorFile); + } + var hashPath = HashPath.FromHash(contentDescriptor.FileHash); hashPath.DeleteFile(Config.StoragePath, Logger); @@ -265,11 +286,16 @@ private bool Delete(ContentDescriptor contentDescriptor, VariantDescriptor varia hashPath.DeleteFile(Config.StoragePath, Logger); if (variantDescriptor.Preview.State == PreviewState.Created) + { RemovePreview(variantDescriptor); + } contentDescriptor.Variants.Remove(variantDescriptor); if (contentDescriptor.Variants.Count > 0) + { SaveDescriptorToFile(contentDescriptor); + } + return true; } @@ -280,7 +306,9 @@ public bool DeleteContent(Guid contentId, string variantName) var variant = descriptor?.GetVariant(variantName); if (variant == null) + { return false; + } return isMaster ? Delete(descriptor) : Delete(descriptor, variant); } @@ -288,7 +316,9 @@ public bool DeleteContent(Guid contentId, string variantName) private async Task AddPreview(VariantDescriptor variantDescriptor, Stream previewStream) { if (!string.IsNullOrWhiteSpace(variantDescriptor.Preview.FileHash)) + { RemovePreview(variantDescriptor); + } var hashPath = HashPath.FromStream(previewStream); await hashPath.SaveStream(previewStream, Config.StoragePath, Logger); @@ -320,7 +350,9 @@ private async Task HandleCompletedPreview(PreviewJob job, PreviewJobResult resul try { if (result.PreviewState == PreviewState.Created) + { await AddPreview(variant, result.Preview); + } result.Dispose(); @@ -364,7 +396,9 @@ private async Task SaveDescriptorToFile(ContentDescriptor descriptor) // Remove old file if (!string.IsNullOrEmpty(descriptor.FileHash) && descriptor.FileHash != file.Hash) + { HashPath.FromHash(descriptor.FileHash).DeleteFile(Config.StoragePath, Logger); + } // Overwrite hash on object descriptor.FileHash = file.Hash; diff --git a/src/Moryx.Media.Server/ContentManager/HashPath.cs b/src/Moryx.Media.Server/ContentManager/HashPath.cs index 6c008ed46b..3105a3dba4 100644 --- a/src/Moryx.Media.Server/ContentManager/HashPath.cs +++ b/src/Moryx.Media.Server/ContentManager/HashPath.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Microsoft.Extensions.Logging; -using Moryx.Logging; using System.Security.Cryptography; using System.Text; +using Microsoft.Extensions.Logging; +using Moryx.Logging; namespace Moryx.Media.Server; @@ -83,7 +83,9 @@ public async Task SaveStream(Stream stream, string storagePath, IModuleLogger lo try { if (!Directory.Exists(targetPath)) + { Directory.CreateDirectory(targetPath); + } } catch (Exception e) { @@ -92,7 +94,9 @@ public async Task SaveStream(Stream stream, string storagePath, IModuleLogger lo var fileName = FilePath(storagePath); if (File.Exists(fileName)) + { return; + } try { @@ -149,7 +153,9 @@ private void RemoveFile(string storagePath, IModuleLogger logger) try { if (File.Exists(filePath)) + { File.Delete(filePath); + } } catch (Exception e) { @@ -163,7 +169,9 @@ private void CleanUpDirectory(string storagePath, IModuleLogger logger) try { if (Directory.GetFiles(directoryPath).Length == 0) + { Directory.Delete(directoryPath); + } } catch (Exception e) { @@ -171,4 +179,4 @@ private void CleanUpDirectory(string storagePath, IModuleLogger logger) } } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/ContentManager/IContentManager.cs b/src/Moryx.Media.Server/ContentManager/IContentManager.cs index ccf2e70ffb..3e19c27c30 100644 --- a/src/Moryx.Media.Server/ContentManager/IContentManager.cs +++ b/src/Moryx.Media.Server/ContentManager/IContentManager.cs @@ -58,4 +58,4 @@ internal interface IContentManager : IPlugin /// Return the maximum allowed file size to be uploaded in MB /// int FileSizeLimitInMb(); -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Facades/MediaServerFacade.cs b/src/Moryx.Media.Server/Facades/MediaServerFacade.cs index ea1f0090b9..1b2181b4f7 100644 --- a/src/Moryx.Media.Server/Facades/MediaServerFacade.cs +++ b/src/Moryx.Media.Server/Facades/MediaServerFacade.cs @@ -86,4 +86,4 @@ public int FileSizeLimitInMb() ValidateHealthState(); return ContentManager.FileSizeLimitInMb(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/InternalConstants.cs b/src/Moryx.Media.Server/InternalConstants.cs index 36cf37e13f..96347fadfd 100644 --- a/src/Moryx.Media.Server/InternalConstants.cs +++ b/src/Moryx.Media.Server/InternalConstants.cs @@ -8,4 +8,4 @@ internal class InternalConstants public const string FileUriTemplate = "files/{contentId}/{variantName}"; public const string PreviewUriTemplate = "files/{contentId}/{variantName}/preview"; -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/ModuleController/ModuleConfig.cs b/src/Moryx.Media.Server/ModuleController/ModuleConfig.cs index e1c554d75e..50afb9b8c8 100644 --- a/src/Moryx.Media.Server/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Media.Server/ModuleController/ModuleConfig.cs @@ -56,4 +56,4 @@ public override void Initialize() new ImagePreviewCreatorConfig() ]; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/ModuleController/ModuleConsole.cs b/src/Moryx.Media.Server/ModuleController/ModuleConsole.cs index 669f53000d..f171fded16 100644 --- a/src/Moryx.Media.Server/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Media.Server/ModuleController/ModuleConsole.cs @@ -8,7 +8,7 @@ namespace Moryx.Media.Server; [ServerModuleConsole] internal class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/ModuleController/ModuleController.cs b/src/Moryx.Media.Server/ModuleController/ModuleController.cs index fd0ac6aefd..0764325dc8 100644 --- a/src/Moryx.Media.Server/ModuleController/ModuleController.cs +++ b/src/Moryx.Media.Server/ModuleController/ModuleController.cs @@ -99,4 +99,4 @@ private async Task StartCreators(CancellationToken cancellationToken) IMediaServer IFacadeContainer.Facade => _mediaServer; #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreator.cs b/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreator.cs index 71007226ce..27db368049 100644 --- a/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreator.cs +++ b/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreator.cs @@ -62,7 +62,9 @@ public override Task CreatePreviewAsync(PreviewJob job, Cancel process.Start(); var exited = process.WaitForExit(5000); if (!exited) + { process.Kill(); + } if (!File.Exists(tempPreview)) { @@ -81,4 +83,4 @@ public override Task CreatePreviewAsync(PreviewJob job, Cancel return Task.FromResult(result); } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreatorConfig.cs b/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreatorConfig.cs index beb5f7423a..1be610a757 100644 --- a/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreatorConfig.cs +++ b/src/Moryx.Media.Server/Previews/FFmpeg/FFmpegPreviewCreatorConfig.cs @@ -19,4 +19,4 @@ internal class FFmpegPreviewCreatorConfig : PreviewCreatorConfig [DataMember, DefaultValue(5000)] [Description("Timeout for FFmpeg to create a preview from video")] public int Timeout { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/IPreviewCreatorFactory.cs b/src/Moryx.Media.Server/Previews/IPreviewCreatorFactory.cs index 99f0c3fbd1..1a83f24cae 100644 --- a/src/Moryx.Media.Server/Previews/IPreviewCreatorFactory.cs +++ b/src/Moryx.Media.Server/Previews/IPreviewCreatorFactory.cs @@ -18,4 +18,4 @@ internal interface IPreviewCreatorFactory /// Destroy a module instance /// void Destroy(IPreviewCreator instance); -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/IPreviewService.cs b/src/Moryx.Media.Server/Previews/IPreviewService.cs index 8c1acc1db8..3f62ed458d 100644 --- a/src/Moryx.Media.Server/Previews/IPreviewService.cs +++ b/src/Moryx.Media.Server/Previews/IPreviewService.cs @@ -13,4 +13,4 @@ internal interface IPreviewService : IPlugin void QueuePreviewJob(PreviewJob job); event PreviewCreationResultHandler PreviewJobCompleted; -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreator.cs b/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreator.cs index fa2ac4703d..64b3301e4e 100644 --- a/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreator.cs +++ b/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreator.cs @@ -36,9 +36,13 @@ public override async Task CreatePreviewAsync(PreviewJob job, int width = 0, height = 0; if (image.Width > image.Height) + { width = Config.LongestEdge; + } else if (image.Height > image.Width) + { height = Config.LongestEdge; + } else { width = Config.LongestEdge; @@ -66,4 +70,4 @@ public override async Task CreatePreviewAsync(PreviewJob job, return result; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreatorConfig.cs b/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreatorConfig.cs index 60ab53e901..f35047547e 100644 --- a/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreatorConfig.cs +++ b/src/Moryx.Media.Server/Previews/Image/ImagePreviewCreatorConfig.cs @@ -19,4 +19,4 @@ internal class ImagePreviewCreatorConfig : PreviewCreatorConfig [DataMember, DefaultValue(80)] [Description("Image quality between 0 - 100")] public int Quality { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media.Server/Previews/PreviewService.cs b/src/Moryx.Media.Server/Previews/PreviewService.cs index 32edee5aa3..69b624198b 100644 --- a/src/Moryx.Media.Server/Previews/PreviewService.cs +++ b/src/Moryx.Media.Server/Previews/PreviewService.cs @@ -46,7 +46,9 @@ public void Start() public void Stop() { lock (_jobLock) + { _jobs.Clear(); + } } private void PreviewCreationThread() @@ -57,9 +59,13 @@ private void PreviewCreationThread() lock (_jobLock) { if (_jobs.Any()) + { job = _jobs.Dequeue(); + } else + { return; + } } var creator = PickCreator(job); @@ -85,7 +91,9 @@ private void PreviewCreationThread() lock (_jobLock) { if (_jobs.Any()) + { ParallelOperations.ExecuteParallel(PreviewCreationThread); + } } } @@ -95,4 +103,4 @@ private IPreviewCreator PickCreator(PreviewJob job) } public event PreviewCreationResultHandler PreviewJobCompleted; -} \ No newline at end of file +} diff --git a/src/Moryx.Media/ContentAddingInfo.cs b/src/Moryx.Media/ContentAddingInfo.cs index 29380c91ee..53028e539f 100644 --- a/src/Moryx.Media/ContentAddingInfo.cs +++ b/src/Moryx.Media/ContentAddingInfo.cs @@ -48,4 +48,4 @@ public class ContentAddingInfo /// /// public ContentAddingResult Result { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/ContentDescriptor.cs b/src/Moryx.Media/ContentDescriptor.cs index b527449c36..231b68a098 100644 --- a/src/Moryx.Media/ContentDescriptor.cs +++ b/src/Moryx.Media/ContentDescriptor.cs @@ -53,4 +53,4 @@ public ContentDescriptor(Guid id) /// /// public VariantDescriptor GetVariant(string variantName) => Variants.FirstOrDefault(v => v.Name == variantName); -} \ No newline at end of file +} diff --git a/src/Moryx.Media/FileDescriptor.cs b/src/Moryx.Media/FileDescriptor.cs index 70396dec7d..d2413f2fb8 100644 --- a/src/Moryx.Media/FileDescriptor.cs +++ b/src/Moryx.Media/FileDescriptor.cs @@ -26,4 +26,4 @@ public abstract class FileDescriptor /// [DataMember] public long Size { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/IMediaServer.cs b/src/Moryx.Media/IMediaServer.cs index 364fb0de26..25cbb1ad54 100644 --- a/src/Moryx.Media/IMediaServer.cs +++ b/src/Moryx.Media/IMediaServer.cs @@ -87,4 +87,4 @@ Task AddVariantAsync(Guid contentId, string variantName, stri /// Return the maximum allowed file size to be uploaded in MB /// int FileSizeLimitInMb(); -} \ No newline at end of file +} diff --git a/src/Moryx.Media/MediaConstants.cs b/src/Moryx.Media/MediaConstants.cs index bba457bec1..00707d3c5a 100644 --- a/src/Moryx.Media/MediaConstants.cs +++ b/src/Moryx.Media/MediaConstants.cs @@ -12,4 +12,4 @@ public class MediaConstants /// Name of the root variant of each content /// public const string MasterName = "master"; -} \ No newline at end of file +} diff --git a/src/Moryx.Media/PreviewDescriptor.cs b/src/Moryx.Media/PreviewDescriptor.cs index eabf67cfaf..9671c68c84 100644 --- a/src/Moryx.Media/PreviewDescriptor.cs +++ b/src/Moryx.Media/PreviewDescriptor.cs @@ -16,4 +16,4 @@ public sealed class PreviewDescriptor : FileDescriptor /// [DataMember] public PreviewState State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/PreviewState.cs b/src/Moryx.Media/PreviewState.cs index e1d6f6d505..89a2bbd34f 100644 --- a/src/Moryx.Media/PreviewState.cs +++ b/src/Moryx.Media/PreviewState.cs @@ -32,4 +32,4 @@ public enum PreviewState /// Preview was removed and is not available anymore /// Removed -} \ No newline at end of file +} diff --git a/src/Moryx.Media/Previews/IPreviewCreator.cs b/src/Moryx.Media/Previews/IPreviewCreator.cs index ae66d7232a..99a607963b 100644 --- a/src/Moryx.Media/Previews/IPreviewCreator.cs +++ b/src/Moryx.Media/Previews/IPreviewCreator.cs @@ -24,4 +24,4 @@ public interface IPreviewCreator : IAsyncConfiguredPlugin /// The token to monitor for cancellation requests. The default value is None. /// True if preview creation was successful otherwise false Task CreatePreviewAsync(PreviewJob job, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Media/Previews/PreviewCreatorBase.cs b/src/Moryx.Media/Previews/PreviewCreatorBase.cs index 6d435aa6e8..d3d592f121 100644 --- a/src/Moryx.Media/Previews/PreviewCreatorBase.cs +++ b/src/Moryx.Media/Previews/PreviewCreatorBase.cs @@ -60,4 +60,4 @@ public virtual Task StopAsync(CancellationToken cancellationToken = default) /// /// public abstract Task CreatePreviewAsync(PreviewJob job, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Media/Previews/PreviewCreatorConfig.cs b/src/Moryx.Media/Previews/PreviewCreatorConfig.cs index 167e05b0bc..41e325de12 100644 --- a/src/Moryx.Media/Previews/PreviewCreatorConfig.cs +++ b/src/Moryx.Media/Previews/PreviewCreatorConfig.cs @@ -14,4 +14,4 @@ public abstract class PreviewCreatorConfig : IPluginConfig { /// public abstract string PluginName { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/Previews/PreviewJob.cs b/src/Moryx.Media/Previews/PreviewJob.cs index c9d4c53cdd..6d61e3d654 100644 --- a/src/Moryx.Media/Previews/PreviewJob.cs +++ b/src/Moryx.Media/Previews/PreviewJob.cs @@ -22,4 +22,4 @@ public class PreviewJob /// Path to the preview image /// public string SourcePath { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/Previews/PreviewJobResult.cs b/src/Moryx.Media/Previews/PreviewJobResult.cs index c02547da1d..7e88cb7aea 100644 --- a/src/Moryx.Media/Previews/PreviewJobResult.cs +++ b/src/Moryx.Media/Previews/PreviewJobResult.cs @@ -33,4 +33,4 @@ public void Dispose() { Preview?.Dispose(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Media/VariantDescriptor.cs b/src/Moryx.Media/VariantDescriptor.cs index e8df2598f1..a481892a00 100644 --- a/src/Moryx.Media/VariantDescriptor.cs +++ b/src/Moryx.Media/VariantDescriptor.cs @@ -36,4 +36,4 @@ public VariantDescriptor() /// [DataMember] public PreviewDescriptor Preview { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model.InMemory/InMemoryDbContextManager.cs b/src/Moryx.Model.InMemory/InMemoryDbContextManager.cs index 80cfd83dc8..c12141c5ed 100644 --- a/src/Moryx.Model.InMemory/InMemoryDbContextManager.cs +++ b/src/Moryx.Model.InMemory/InMemoryDbContextManager.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; namespace Moryx.Model.InMemory; @@ -82,4 +81,4 @@ public void UpdateConfig(Type dbContextType, Type configuratorType, DatabaseConf { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model.InMemory/InMemoryUnitOfWorkFactory.cs b/src/Moryx.Model.InMemory/InMemoryUnitOfWorkFactory.cs index 3a0fdbf32c..c1c5d0b0fb 100644 --- a/src/Moryx.Model.InMemory/InMemoryUnitOfWorkFactory.cs +++ b/src/Moryx.Model.InMemory/InMemoryUnitOfWorkFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; using Moryx.Model.Repositories; namespace Moryx.Model.InMemory; @@ -39,4 +38,4 @@ public IUnitOfWork Create() => /// public IUnitOfWork Create(DatabaseConfig config) => _internalFactory.Create(config); -} \ No newline at end of file +} diff --git a/src/Moryx.Model.PostgreSQL/NpgsqlDatabaseConfig.cs b/src/Moryx.Model.PostgreSQL/NpgsqlDatabaseConfig.cs index 94c08de967..10d3dd1179 100644 --- a/src/Moryx.Model.PostgreSQL/NpgsqlDatabaseConfig.cs +++ b/src/Moryx.Model.PostgreSQL/NpgsqlDatabaseConfig.cs @@ -62,4 +62,4 @@ public class NpgsqlDatabaseConfig : DatabaseConfig [Description("Port of the database server")] [ConnectionStringKey("Port")] public int Port { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model.SqlServer/SqlServerDatabaseConfig.cs b/src/Moryx.Model.SqlServer/SqlServerDatabaseConfig.cs index 36a2ace319..55590daf02 100644 --- a/src/Moryx.Model.SqlServer/SqlServerDatabaseConfig.cs +++ b/src/Moryx.Model.SqlServer/SqlServerDatabaseConfig.cs @@ -41,7 +41,7 @@ public class SqlServerDatabaseConfig : DatabaseConfig /// [DefaultValue("sa")] [Description("User ID to be used when connecting to SQL Server")] - [ConnectionStringKey("User Id") ] + [ConnectionStringKey("User Id")] public string UserId { get; set; } /// diff --git a/src/Moryx.Model.SqlServer/SqlServerDbContextAttribute.cs b/src/Moryx.Model.SqlServer/SqlServerDbContextAttribute.cs index 729c093e72..b41b3f31a8 100644 --- a/src/Moryx.Model.SqlServer/SqlServerDbContextAttribute.cs +++ b/src/Moryx.Model.SqlServer/SqlServerDbContextAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Model.Attributes; diff --git a/src/Moryx.Model.SqlServer/SqlServerModelConfigurator.cs b/src/Moryx.Model.SqlServer/SqlServerModelConfigurator.cs index 258a304422..6777910313 100644 --- a/src/Moryx.Model.SqlServer/SqlServerModelConfigurator.cs +++ b/src/Moryx.Model.SqlServer/SqlServerModelConfigurator.cs @@ -1,11 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; +using System.Data.Common; using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Moryx.Model.Configuration; -using System.ComponentModel; -using System.Data.Common; namespace Moryx.Model.SqlServer; diff --git a/src/Moryx.Model.Sqlite/SqliteDatabaseConfig.cs b/src/Moryx.Model.Sqlite/SqliteDatabaseConfig.cs index e563204e35..3019350ac9 100644 --- a/src/Moryx.Model.Sqlite/SqliteDatabaseConfig.cs +++ b/src/Moryx.Model.Sqlite/SqliteDatabaseConfig.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.ComponentModel.DataAnnotations; using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Microsoft.Data.Sqlite; using Moryx.Model.Attributes; @@ -42,4 +42,4 @@ public class SqliteDatabaseConfig : DatabaseConfig [Description("Caching mode that will be used when opening a connection")] [ConnectionStringKey("Cache")] public SqliteCacheMode CacheMode { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model.Sqlite/SqliteDbContextAttribute.cs b/src/Moryx.Model.Sqlite/SqliteDbContextAttribute.cs index 89a1f8bae6..8496e9cf86 100644 --- a/src/Moryx.Model.Sqlite/SqliteDbContextAttribute.cs +++ b/src/Moryx.Model.Sqlite/SqliteDbContextAttribute.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Model.Attributes; diff --git a/src/Moryx.Model.Sqlite/SqliteDbContextManager.cs b/src/Moryx.Model.Sqlite/SqliteDbContextManager.cs index 096e8b04ef..24ab0bcab6 100644 --- a/src/Moryx.Model.Sqlite/SqliteDbContextManager.cs +++ b/src/Moryx.Model.Sqlite/SqliteDbContextManager.cs @@ -3,7 +3,6 @@ using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; namespace Moryx.Model.Sqlite; @@ -104,4 +103,4 @@ public void UpdateConfig(Type dbContextType, Type configuratorType, DatabaseConf { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model.Sqlite/SqliteModelConfigurator.cs b/src/Moryx.Model.Sqlite/SqliteModelConfigurator.cs index 746ef5cc60..90a9530a1c 100644 --- a/src/Moryx.Model.Sqlite/SqliteModelConfigurator.cs +++ b/src/Moryx.Model.Sqlite/SqliteModelConfigurator.cs @@ -40,7 +40,9 @@ public override Task DeleteDatabaseAsync(DatabaseConfig config, CancellationToke var dbFilePath = GetFilePath(config); if (File.Exists(dbFilePath)) + { File.Delete(dbFilePath); + } return Task.CompletedTask; } diff --git a/src/Moryx.Model/Annotations/DateTimeKindAnnotation.cs b/src/Moryx.Model/Annotations/DateTimeKindAnnotation.cs index 54236ef1fc..f17c5e0e51 100644 --- a/src/Moryx.Model/Annotations/DateTimeKindAnnotation.cs +++ b/src/Moryx.Model/Annotations/DateTimeKindAnnotation.cs @@ -30,9 +30,13 @@ public static class DateTimeKindAnnotation private static DateTime ConvertToUtc(DateTime dateTime) { if (dateTime.Kind == DateTimeKind.Utc) + { return dateTime; + } else + { return TimeZoneInfo.ConvertTimeToUtc(dateTime, TimeZoneInfo.Local); + } } private static DateTime ConvertToLocal(DateTime timeUtc) @@ -87,7 +91,9 @@ public static PropertyBuilder HasDateTimeKind(this PropertyBuilder(); if (attribute != null) + { return attribute.Kind; + } return (DateTimeKind?)property.FindAnnotation(AnnotationName)?.Value; } diff --git a/src/Moryx.Model/Attributes/DateTimeKindAttribute.cs b/src/Moryx.Model/Attributes/DateTimeKindAttribute.cs index 0c98dbca4f..4b0ac297ab 100644 --- a/src/Moryx.Model/Attributes/DateTimeKindAttribute.cs +++ b/src/Moryx.Model/Attributes/DateTimeKindAttribute.cs @@ -9,4 +9,4 @@ public DateTimeKindAttribute(DateTimeKind kind) => Kind = kind; public DateTimeKind Kind { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Attributes/DefaultSchemaAttribute.cs b/src/Moryx.Model/Attributes/DefaultSchemaAttribute.cs index bdc6ea7a21..3481fdd55a 100644 --- a/src/Moryx.Model/Attributes/DefaultSchemaAttribute.cs +++ b/src/Moryx.Model/Attributes/DefaultSchemaAttribute.cs @@ -24,4 +24,4 @@ public DefaultSchemaAttribute(string schema) { Schema = schema; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Attributes/ModelSetupAttribute.cs b/src/Moryx.Model/Attributes/ModelSetupAttribute.cs index df4f954511..d42649205b 100644 --- a/src/Moryx.Model/Attributes/ModelSetupAttribute.cs +++ b/src/Moryx.Model/Attributes/ModelSetupAttribute.cs @@ -21,4 +21,4 @@ public ModelSetupAttribute(Type targetContext) { TargetContext = targetContext; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Configuration/ModelConfiguratorBase.cs b/src/Moryx.Model/Configuration/ModelConfiguratorBase.cs index c689fac128..a786b48bb4 100644 --- a/src/Moryx.Model/Configuration/ModelConfiguratorBase.cs +++ b/src/Moryx.Model/Configuration/ModelConfiguratorBase.cs @@ -37,8 +37,10 @@ public void Initialize(Type contextType, DatabaseConfig config, ILogger logger) Config = config as TConfig; if (Config == null) + { throw new InvalidOperationException( $"Configuration for model '{contextType.FullName}' is not of expected type '{typeof(TConfig).FullName}'"); + } } /// @@ -64,24 +66,32 @@ public DbContext CreateContext(Type contextType, DbContextOptions dbContextOptio public virtual async Task TestConnectionAsync(DatabaseConfig config, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(config.ConnectionString)) + { return TestConnectionResult.ConfigurationError; + } // Simple ef independent database connection var connectionResult = await TestServerConnection(config, cancellationToken); if (!connectionResult) + { return TestConnectionResult.ConnectionError; + } await using var context = CreateContext(config); // Ef dependent database connection var canConnect = await context.Database.CanConnectAsync(cancellationToken); if (!canConnect) + { return TestConnectionResult.ConnectionOkDbDoesNotExist; + } // If connection is ok, test migrations var pendingMigrations = (await context.Database.GetPendingMigrationsAsync(cancellationToken: cancellationToken)).ToArray(); if (pendingMigrations.Any()) + { return TestConnectionResult.PendingMigrations; + } return TestConnectionResult.Success; } @@ -246,7 +256,9 @@ protected async Task> AppliedMigrationsAsync(DbContext con private async Task TestServerConnection(DatabaseConfig config, CancellationToken cancellationToken) { if (!CheckDatabaseConfig(config)) + { return false; + } await using var conn = CreateConnection(config, false); try @@ -254,7 +266,7 @@ private async Task TestServerConnection(DatabaseConfig config, Cancellatio await conn.OpenAsync(cancellationToken); return true; } - catch(Exception e) + catch (Exception e) { return false; } diff --git a/src/Moryx.Model/ContextFactory.cs b/src/Moryx.Model/ContextFactory.cs index 1a4215e409..c1243072fd 100644 --- a/src/Moryx.Model/ContextFactory.cs +++ b/src/Moryx.Model/ContextFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; namespace Moryx.Model; @@ -31,4 +30,4 @@ public TContext Create(DatabaseConfig config) { return _manager.Create(config); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/DataModification.cs b/src/Moryx.Model/DataModification.cs index 76519d421b..d2ac6af9a8 100644 --- a/src/Moryx.Model/DataModification.cs +++ b/src/Moryx.Model/DataModification.cs @@ -42,7 +42,10 @@ public class ModifiedEntity : DataModification, IEquatable other) { if (other == null) + { return false; + } + return Data.Id == other.Data.Id; } } @@ -62,7 +65,10 @@ public class ModifiedId : DataModification, IEquatable public bool Equals(ModifiedId other) { if (other == null) + { return false; + } + return Data == other.Data; } } @@ -85,4 +91,4 @@ public enum ModificationType /// The entry was flagged as deleted [EnumMember] Delete = 0x04, -} \ No newline at end of file +} diff --git a/src/Moryx.Model/DatabaseConfig.cs b/src/Moryx.Model/DatabaseConfig.cs index 00315b1398..f79f1636c5 100644 --- a/src/Moryx.Model/DatabaseConfig.cs +++ b/src/Moryx.Model/DatabaseConfig.cs @@ -31,7 +31,9 @@ public class DatabaseConfig : ConfigBase public void UpdatePropertiesFromConnectionString() { if (string.IsNullOrEmpty(ConnectionString)) + { return; + } var keyPropertyMap = GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance) @@ -48,7 +50,9 @@ public void UpdatePropertiesFromConnectionString() { var keyValue = stringPair.Split(['='], 2); if (keyValue.Length != 2) + { continue; + } if (keyPropertyMap.TryGetValue(keyValue[0], out var property)) { diff --git a/src/Moryx.Model/DbContextManager.cs b/src/Moryx.Model/DbContextManager.cs index ddae91a62a..a38718ce67 100644 --- a/src/Moryx.Model/DbContextManager.cs +++ b/src/Moryx.Model/DbContextManager.cs @@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging; using Moryx.Configuration; using Moryx.Model.Attributes; -using Moryx.Model.Configuration; using Moryx.Tools; namespace Moryx.Model; @@ -55,7 +54,9 @@ private static PossibleModelWrapper[] GetPossibleModels() var dbTypeAttributes = type.GetCustomAttributes()!; return dbTypeAttributes.Select(attr => new { - DbContextType = type, BaseDbContextType = attr.BaseDbContextType ?? type, ModelConfiguratorType = attr.ModelConfiguratorType + DbContextType = type, + BaseDbContextType = attr.BaseDbContextType ?? type, + ModelConfiguratorType = attr.ModelConfiguratorType }); }).GroupBy(pc => pc.BaseDbContextType).Select(g => { @@ -98,7 +99,9 @@ private ConfiguredModelWrapper[] GetConfiguredModels() } if (configuratorType == null || specificDbContextType == null) + { throw new InvalidOperationException($"No valid configurator found for DbContext '{possibleModel.DbContext.FullName}'."); + } var configType = configuratorType.BaseType.GenericTypeArguments.First(); @@ -162,7 +165,9 @@ public IModelConfigurator GetConfigurator(Type contextType, Type configuratorTyp { var possibleModel = _possibleModels.FirstOrDefault(pm => pm.DbContext == contextType); if (possibleModel == null) + { return null; + } if (possibleModel.ModelConfiguratorMap.TryGetValue(configuratorType, out var specificDbContextType)) { @@ -189,7 +194,9 @@ public IModelSetupExecutor GetSetupExecutor(Type contextType) { var configuredContext = _configuredModels.FirstOrDefault(m => m.BaseDbContextType == contextType); if (configuredContext == null) + { throw new InvalidOperationException($"Context {contextType.FullName} not configured."); + } var setupExecutorType = typeof(ModelSetupExecutor<>).MakeGenericType(configuredContext.BaseDbContextType); return (IModelSetupExecutor)Activator.CreateInstance(setupExecutorType, this); @@ -204,7 +211,9 @@ public TContext Create(DatabaseConfig config) where TContext : DbConte { var wrapper = _configuredModels.FirstOrDefault(k => k.BaseDbContextType == typeof(TContext)); if (wrapper == null) + { throw new InvalidOperationException("Unknown model."); + } var configurator = wrapper.Configurator; @@ -213,7 +222,7 @@ public TContext Create(DatabaseConfig config) where TContext : DbConte : (TContext)configurator.CreateContext(); } - private class ConfiguredModelWrapper + private sealed class ConfiguredModelWrapper { public Type BaseDbContextType { get; set; } @@ -224,7 +233,7 @@ private class ConfiguredModelWrapper public DatabaseConfig DatabaseConfig { get; set; } } - private class PossibleModelWrapper + private sealed class PossibleModelWrapper { public Type DbContext { get; set; } diff --git a/src/Moryx.Model/EntityBase.cs b/src/Moryx.Model/EntityBase.cs index 192f37dedc..a72f2a1fb2 100644 --- a/src/Moryx.Model/EntityBase.cs +++ b/src/Moryx.Model/EntityBase.cs @@ -15,4 +15,4 @@ public abstract class EntityBase : IEntity [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual long Id { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Extensions/DbContextExtensions.cs b/src/Moryx.Model/Extensions/DbContextExtensions.cs index 6fb1345a43..7404c03af7 100644 --- a/src/Moryx.Model/Extensions/DbContextExtensions.cs +++ b/src/Moryx.Model/Extensions/DbContextExtensions.cs @@ -21,4 +21,4 @@ public static TEntity GetEntity(this DbContext dbContext, IPersistentOb { return dbContext.Set().GetEntity(obj); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Extensions/DbSetExtensions.cs b/src/Moryx.Model/Extensions/DbSetExtensions.cs index d4d9887b0c..a6acc7c234 100644 --- a/src/Moryx.Model/Extensions/DbSetExtensions.cs +++ b/src/Moryx.Model/Extensions/DbSetExtensions.cs @@ -21,7 +21,9 @@ public static TEntity GetEntity(this DbSet dbSet, IPersistentO { var entity = dbSet.FirstOrDefault(e => e.Id == obj.Id); if (entity != null) + { return entity; + } entity = new TEntity(); dbSet.Add(entity); @@ -41,4 +43,4 @@ public static TEntity RemoveSoft(this DbSet dbSet, TEntity ent entity.Deleted = DateTime.Now; return entity; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Extensions/QueryableExtensions.cs b/src/Moryx.Model/Extensions/QueryableExtensions.cs index 7e83d4f5b5..41ff85af78 100644 --- a/src/Moryx.Model/Extensions/QueryableExtensions.cs +++ b/src/Moryx.Model/Extensions/QueryableExtensions.cs @@ -120,4 +120,4 @@ public TEntity GetByKey(long key) return query.FirstOrDefault(e => e.Id == key); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Extensions/UnitOfWorkExtensions.cs b/src/Moryx.Model/Extensions/UnitOfWorkExtensions.cs index 0ea31fb2b2..b8e46b4a7f 100644 --- a/src/Moryx.Model/Extensions/UnitOfWorkExtensions.cs +++ b/src/Moryx.Model/Extensions/UnitOfWorkExtensions.cs @@ -103,4 +103,4 @@ public async Task CreateEntityAsync(IPersistentObject obj) return entity; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/IContextFactory.cs b/src/Moryx.Model/IContextFactory.cs index 817fa9494e..6a78aa228b 100644 --- a/src/Moryx.Model/IContextFactory.cs +++ b/src/Moryx.Model/IContextFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; namespace Moryx.Model; @@ -21,4 +20,4 @@ public interface IContextFactory /// Create context using standard mode and alternative config /// TContext Create(DatabaseConfig config); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/IDbContextManager.cs b/src/Moryx.Model/IDbContextManager.cs index 5d8eaa602c..f4ee7f495f 100644 --- a/src/Moryx.Model/IDbContextManager.cs +++ b/src/Moryx.Model/IDbContextManager.cs @@ -58,4 +58,4 @@ TContext Create(DatabaseConfig config) /// Configurator type /// Database config void UpdateConfig(Type dbContextType, Type configuratorType, DatabaseConfig dbConfig); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/IEntity.cs b/src/Moryx.Model/IEntity.cs index 60c1464839..2f7c6d220a 100644 --- a/src/Moryx.Model/IEntity.cs +++ b/src/Moryx.Model/IEntity.cs @@ -33,4 +33,4 @@ public interface IModificationTrackedEntity : IEntity /// Time this entity was deleted /// DateTime? Deleted { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/IModelSetup.cs b/src/Moryx.Model/IModelSetup.cs index 712903e010..5581e0503c 100644 --- a/src/Moryx.Model/IModelSetup.cs +++ b/src/Moryx.Model/IModelSetup.cs @@ -37,4 +37,4 @@ public interface IModelSetup /// Any data for the setup, excel or sql etc /// The token to monitor for cancellation requests. The default value is None. Task ExecuteAsync(IUnitOfWork openContext, string setupData, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/IModelSetupExecutor.cs b/src/Moryx.Model/IModelSetupExecutor.cs index 1687acfa44..c2cec99f59 100644 --- a/src/Moryx.Model/IModelSetupExecutor.cs +++ b/src/Moryx.Model/IModelSetupExecutor.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Model.Configuration; - namespace Moryx.Model; /// @@ -19,4 +17,4 @@ public interface IModelSetupExecutor /// Executes the given setup /// Task ExecuteAsync(DatabaseConfig config, IModelSetup setup, string setupData, CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/ModelServiceCollectionExtension.cs b/src/Moryx.Model/ModelServiceCollectionExtension.cs index 9b5cbe9553..2f5627132b 100644 --- a/src/Moryx.Model/ModelServiceCollectionExtension.cs +++ b/src/Moryx.Model/ModelServiceCollectionExtension.cs @@ -18,4 +18,4 @@ public static void AddMoryxModels(this IServiceCollection serviceCollection) // Register config manager serviceCollection.AddSingleton(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/ModelSetupExecutor.cs b/src/Moryx.Model/ModelSetupExecutor.cs index c14d94164c..e8b8a52471 100644 --- a/src/Moryx.Model/ModelSetupExecutor.cs +++ b/src/Moryx.Model/ModelSetupExecutor.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore; using Moryx.Model.Attributes; -using Moryx.Model.Configuration; using Moryx.Model.Repositories; using Moryx.Tools; @@ -44,4 +43,4 @@ public async Task ExecuteAsync(DatabaseConfig config, IModelSetup setup, string await setup.ExecuteAsync(uow, setupData, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/ModificationTrackedEntityBase.cs b/src/Moryx.Model/ModificationTrackedEntityBase.cs index c7d3bcb9f2..f493d2358c 100644 --- a/src/Moryx.Model/ModificationTrackedEntityBase.cs +++ b/src/Moryx.Model/ModificationTrackedEntityBase.cs @@ -17,4 +17,4 @@ public abstract class ModificationTrackedEntityBase : EntityBase, IModificationT /// public virtual DateTime? Deleted { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/MoryxDbContext.cs b/src/Moryx.Model/MoryxDbContext.cs index 462835f488..d8ed13f675 100644 --- a/src/Moryx.Model/MoryxDbContext.cs +++ b/src/Moryx.Model/MoryxDbContext.cs @@ -75,14 +75,18 @@ private void ApplyModificationTracking() // Added gets created if (entry.State == EntityState.Added) + { entity.Created = timeStamp; + } // All states gets updated entity.Updated = timeStamp; // Override deleted date of entity to sync between updated and deleted if (entry.State == EntityState.Modified && entry.OriginalValues[nameof(IModificationTrackedEntity.Deleted)] == null && entity.Deleted != null) + { entity.Deleted = timeStamp; + } } } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/IRepository.cs b/src/Moryx.Model/Repositories/IRepository.cs index 7e6f69dd48..6041c3f8d2 100644 --- a/src/Moryx.Model/Repositories/IRepository.cs +++ b/src/Moryx.Model/Repositories/IRepository.cs @@ -134,4 +134,4 @@ public interface IRepository : IRepository where T : class /// Remove a range of entities permanent /// IEnumerable RemoveRange(IEnumerable entities, bool permanent); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/IUnitOfWork.cs b/src/Moryx.Model/Repositories/IUnitOfWork.cs index f7e8b94f35..38cbebe5a5 100644 --- a/src/Moryx.Model/Repositories/IUnitOfWork.cs +++ b/src/Moryx.Model/Repositories/IUnitOfWork.cs @@ -57,4 +57,4 @@ public interface IUnitOfWork : IUnitOfWork /// Underlying database context of this unit of work /// new TContext DbContext { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/IUnitOfWorkFactory.cs b/src/Moryx.Model/Repositories/IUnitOfWorkFactory.cs index 21fafa2b3f..6793e27630 100644 --- a/src/Moryx.Model/Repositories/IUnitOfWorkFactory.cs +++ b/src/Moryx.Model/Repositories/IUnitOfWorkFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; namespace Moryx.Model.Repositories; @@ -21,4 +20,4 @@ public interface IUnitOfWorkFactory /// Create unit of work using standard mode and alternative config /// IUnitOfWork Create(DatabaseConfig config); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Proxy/IMethodProxyStrategy.cs b/src/Moryx.Model/Repositories/Proxy/IMethodProxyStrategy.cs index 5d283639ae..51016d8562 100644 --- a/src/Moryx.Model/Repositories/Proxy/IMethodProxyStrategy.cs +++ b/src/Moryx.Model/Repositories/Proxy/IMethodProxyStrategy.cs @@ -11,4 +11,4 @@ internal interface IMethodProxyStrategy bool CanImplement(MethodInfo methodInfo); void Implement(TypeBuilder typeBuilder, MethodInfo methodInfo, Type baseType, Type targetType); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Proxy/MethodProxyStrategyBase.cs b/src/Moryx.Model/Repositories/Proxy/MethodProxyStrategyBase.cs index 1bce0a214d..114bb0e3f1 100644 --- a/src/Moryx.Model/Repositories/Proxy/MethodProxyStrategyBase.cs +++ b/src/Moryx.Model/Repositories/Proxy/MethodProxyStrategyBase.cs @@ -29,10 +29,14 @@ protected static ParameterPropertyMap MapParameterToProperty(ParameterInfo param var targetProperty = targetType.GetProperty(propertyName); if (targetProperty == null) + { throw new InvalidOperationException($"Cannot find property with name '{propertyName}' on target type '{targetType.Name}'."); + } if (!targetProperty.PropertyType.IsAssignableFrom(parameterInfo.ParameterType)) + { throw new InvalidOperationException($"Types doesn't match: Property '{parameterInfo.Name}', Target type: {targetProperty.PropertyType}, Source type: {parameterInfo.ParameterType}."); + } return new ParameterPropertyMap(parameterInfo, targetProperty); } @@ -48,21 +52,27 @@ protected static void MatchReturnType(MethodInfo methodInfo, Type targetType) //TODO: Find more / better ways to check generic return type // More than one generic argument if (methodReturnType.GetGenericArguments().Length != 1) + { throw exception; + } var genericArg = methodReturnType.GetGenericArguments()[0]; if (!genericArg.IsAssignableFrom(targetType)) + { throw exception; + } } else { // If type is not assignable if (!methodInfo.ReturnType.IsAssignableFrom(targetType)) + { throw exception; + } } } public abstract bool CanImplement(MethodInfo methodInfo); public abstract void Implement(TypeBuilder typeBuilder, MethodInfo methodInfo, Type baseType, Type targetType); -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Proxy/ParameterPropertyMap.cs b/src/Moryx.Model/Repositories/Proxy/ParameterPropertyMap.cs index acc74c1fa8..099e2d6a90 100644 --- a/src/Moryx.Model/Repositories/Proxy/ParameterPropertyMap.cs +++ b/src/Moryx.Model/Repositories/Proxy/ParameterPropertyMap.cs @@ -5,7 +5,7 @@ namespace Moryx.Model.Repositories.Proxy; -internal class ParameterPropertyMap +internal sealed class ParameterPropertyMap { public ParameterPropertyMap(ParameterInfo parameter, PropertyInfo property) { @@ -16,4 +16,4 @@ public ParameterPropertyMap(ParameterInfo parameter, PropertyInfo property) public ParameterInfo Parameter { get; } public PropertyInfo Property { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Proxy/RepositoryProxyBuilder.cs b/src/Moryx.Model/Repositories/Proxy/RepositoryProxyBuilder.cs index 25be073e10..95d603cf4f 100644 --- a/src/Moryx.Model/Repositories/Proxy/RepositoryProxyBuilder.cs +++ b/src/Moryx.Model/Repositories/Proxy/RepositoryProxyBuilder.cs @@ -48,7 +48,9 @@ public Type Build(Type repoApi) var generatedType = ModuleBuilder.GetType(proxyName); if (generatedType != null) + { return generatedType; + } var entityType = repoApi.GetInterfaces().Single(i => i.GetGenericArguments().Length == 1 && @@ -89,18 +91,24 @@ public Type Build(Type repoApi, Type repoImpl) var generatedType = ModuleBuilder.GetType(proxyName); if (generatedType != null) + { return generatedType; + } // Select base type var baseType = repoImpl.BaseType; if (baseType == null || baseType.GetGenericArguments().Length != 1) + { throw new InvalidOperationException($"{repoImpl.Name} must have the base type {nameof(Repository)}."); + } var entityType = baseType.GetGenericArguments()[0]; if (IsModificationTracked(entityType) && baseType.GetGenericTypeDefinition() != typeof(ModificationTrackedRepository<>)) + { throw new InvalidOperationException($"{entityType.Name} is modification tracked " + "but the repository is not derived from ModificationTrackedRepository."); + } // Get Methods and matching Strategies var methodStrategyMaps = repoImpl.IsAbstract @@ -135,7 +143,9 @@ private static MethodStrategyMap[] GetInterfaceMethodStrategies(Type repoApi) // Check for invalid strategies var invalidStrategy = methodStrategyMaps.FirstOrDefault(ms => ms.Strategy == null); if (invalidStrategy != null) + { throw new Exception($"Method '{invalidStrategy.MethodInfo.Name}' cannot be implemented because of invalid name."); + } return methodStrategyMaps; } @@ -152,7 +162,9 @@ private static MethodStrategyMap[] GetAbstractMethodStartegies(Type repoImpl) var invalidStrategy = methodStrategyMaps.FirstOrDefault(ms => ms.Strategy == null); if (invalidStrategy != null) + { throw new Exception($"Method '{invalidStrategy.MethodInfo.Name}' cannot be implemented because of invalid name."); + } return methodStrategyMaps; } @@ -162,13 +174,13 @@ private static MethodStrategyMap[] GetVirutalMethodStrategies(Type repoImpl) // Virtual methods will be implemented var methods = repoImpl.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(m => m.IsVirtual); var methodStrategyMaps = (from methodInfo in methods - let strategy = MethodStrategies.SingleOrDefault(s => s.CanImplement(methodInfo)) - where strategy != null // Methods which cannot be implemented can be ignored - select new MethodStrategyMap - { - MethodInfo = methodInfo, - Strategy = strategy - }).ToArray(); + let strategy = MethodStrategies.SingleOrDefault(s => s.CanImplement(methodInfo)) + where strategy != null // Methods which cannot be implemented can be ignored + select new MethodStrategyMap + { + MethodInfo = methodInfo, + Strategy = strategy + }).ToArray(); return methodStrategyMaps; } @@ -183,7 +195,7 @@ private static void ImplementMethods(TypeBuilder typeBuilder, IEnumerable var requiredType = typeof(ICollection<>).MakeGenericType(genericArg); if (requiredType.IsAssignableFrom(propertyType)) + { throw new InvalidOperationException("Create entities with collection is currently not supported."); + } else + { throw new InvalidOperationException("Method parameter is type of IEnumerable but the target property is not of type ICollection."); + } } else { diff --git a/src/Moryx.Model/Repositories/Proxy/Strategies/FilterMethodStrategy.cs b/src/Moryx.Model/Repositories/Proxy/Strategies/FilterMethodStrategy.cs index bb7a15255a..252cce9d69 100644 --- a/src/Moryx.Model/Repositories/Proxy/Strategies/FilterMethodStrategy.cs +++ b/src/Moryx.Model/Repositories/Proxy/Strategies/FilterMethodStrategy.cs @@ -8,7 +8,7 @@ namespace Moryx.Model.Repositories.Proxy; -internal class FilterMethodStrategy : MethodProxyStrategyBase +internal sealed class FilterMethodStrategy : MethodProxyStrategyBase { private static readonly IDictionary FilterMethods = new Dictionary(); private static readonly Regex FilterRegex; @@ -187,7 +187,7 @@ public override void Implement(TypeBuilder typeBuilder, MethodInfo methodInfo, T typeBuilder.DefineMethodOverride(methodBuilder, methodInfo); } - private class MethodFilter + private sealed class MethodFilter { public Filter Filter { get; set; } public Selector Selector { get; set; } @@ -351,4 +351,4 @@ private static void LoadExpressionMethods() m.GetParameters()[0].ParameterType == expressionType && m.GetParameters()[1].ParameterType == typeof(ParameterExpression[])); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Proxy/Strategies/RemoveMethodStrategy.cs b/src/Moryx.Model/Repositories/Proxy/Strategies/RemoveMethodStrategy.cs index 97ef215633..20f2380b8c 100644 --- a/src/Moryx.Model/Repositories/Proxy/Strategies/RemoveMethodStrategy.cs +++ b/src/Moryx.Model/Repositories/Proxy/Strategies/RemoveMethodStrategy.cs @@ -6,7 +6,7 @@ namespace Moryx.Model.Repositories.Proxy; -internal class RemoveMethodStrategy : MethodProxyStrategyBase +internal sealed class RemoveMethodStrategy : MethodProxyStrategyBase { public override bool CanImplement(MethodInfo methodInfo) { @@ -17,4 +17,4 @@ public override void Implement(TypeBuilder typeBuilder, MethodInfo methodInfo, T { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/Repository.cs b/src/Moryx.Model/Repositories/Repository.cs index c52aa34fe4..5848ced99b 100644 --- a/src/Moryx.Model/Repositories/Repository.cs +++ b/src/Moryx.Model/Repositories/Repository.cs @@ -92,7 +92,9 @@ public T Create(bool addToContext) { var newInstance = new T(); if (addToContext) + { DbSet.Add(newInstance); + } return newInstance; } @@ -102,7 +104,9 @@ public async Task CreateAsync(bool addToContext, CancellationToken cancellati { var newInstance = new T(); if (addToContext) + { await DbSet.AddAsync(newInstance, cancellationToken); + } return newInstance; } @@ -190,13 +194,17 @@ protected override T ExecuteRemove(T entity, bool permanent) protected override IEnumerable ExecuteRemoveRange(IEnumerable entities, bool permanent) { if (permanent) + { return base.ExecuteRemoveRange(entities, true); + } var list = entities.ToArray(); foreach (var entity in list) + { DbSet.RemoveSoft(entity); + } return list; } -} \ No newline at end of file +} diff --git a/src/Moryx.Model/Repositories/UnitOfWorkFactory.cs b/src/Moryx.Model/Repositories/UnitOfWorkFactory.cs index 37f490c6c6..e6a2e85ced 100644 --- a/src/Moryx.Model/Repositories/UnitOfWorkFactory.cs +++ b/src/Moryx.Model/Repositories/UnitOfWorkFactory.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; -using Moryx.Model.Configuration; using Moryx.Model.Repositories.Proxy; using Moryx.Tools; @@ -58,9 +57,9 @@ private static void RegisterRepositories() var types = typeof(TContext).Assembly.GetTypes(); var repoApis = from type in types - let genericApi = type.GetInterfaces().FirstOrDefault(i => i.GetGenericArguments().Length == 1 && typeof(IRepository<>) == i.GetGenericTypeDefinition()) - where type.IsInterface && genericApi != null - select new { RepoApi = type, GenericApi = genericApi }; + let genericApi = type.GetInterfaces().FirstOrDefault(i => i.GetGenericArguments().Length == 1 && typeof(IRepository<>) == i.GetGenericTypeDefinition()) + where type.IsInterface && genericApi != null + select new { RepoApi = type, GenericApi = genericApi }; foreach (var apiPair in repoApis) { @@ -82,4 +81,4 @@ private static void RegisterRepositories() _repositories[apiPair.RepoApi] = _repositories[apiPair.GenericApi] = constructorDelegate; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Endpoints/Models/Converter.cs b/src/Moryx.Notifications.Endpoints/Models/Converter.cs index a3fcf932e6..8f70594468 100644 --- a/src/Moryx.Notifications.Endpoints/Models/Converter.cs +++ b/src/Moryx.Notifications.Endpoints/Models/Converter.cs @@ -30,7 +30,10 @@ internal static NotificationModel ToModel(Notification notification) }; if (notification.Created != null) + { model.Created = (System.DateTime)notification.Created; + } + return model; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Endpoints/Models/NotificationModel.cs b/src/Moryx.Notifications.Endpoints/Models/NotificationModel.cs index f5d11104bd..c7840a372d 100644 --- a/src/Moryx.Notifications.Endpoints/Models/NotificationModel.cs +++ b/src/Moryx.Notifications.Endpoints/Models/NotificationModel.cs @@ -77,4 +77,4 @@ public class NotificationModel /// [DataMember] public string Source { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Endpoints/NotificationPermissions.cs b/src/Moryx.Notifications.Endpoints/NotificationPermissions.cs index 89341d34a3..f4d1bab931 100644 --- a/src/Moryx.Notifications.Endpoints/NotificationPermissions.cs +++ b/src/Moryx.Notifications.Endpoints/NotificationPermissions.cs @@ -8,4 +8,4 @@ public static class NotificationPermissions private const string _prefix = "Moryx.Notifications."; public const string CanView = _prefix + "CanView"; public const string CanAcknowledge = _prefix + "CanAcknowledge"; -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/INotificationManager.cs b/src/Moryx.Notifications.Publisher/INotificationManager.cs index fb847d929a..26449ede18 100644 --- a/src/Moryx.Notifications.Publisher/INotificationManager.cs +++ b/src/Moryx.Notifications.Publisher/INotificationManager.cs @@ -29,4 +29,4 @@ internal interface INotificationManager : IInitializablePlugin /// Raised if notification was acknowledged /// event EventHandler Acknowledged; -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/API/INotificationEntityRepository.cs b/src/Moryx.Notifications.Publisher/Model/API/INotificationEntityRepository.cs index 5236c66bed..952b39fd6c 100644 --- a/src/Moryx.Notifications.Publisher/Model/API/INotificationEntityRepository.cs +++ b/src/Moryx.Notifications.Publisher/Model/API/INotificationEntityRepository.cs @@ -12,4 +12,4 @@ public interface INotificationEntityRepository : IRepository /// Creates instance with all not nullable properties prefilled /// NotificationEntity Create(Guid identifier, string source, string sender); -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/API/INotificationTypeEntityRepository.cs b/src/Moryx.Notifications.Publisher/Model/API/INotificationTypeEntityRepository.cs index 95f449dac6..e748540ea1 100644 --- a/src/Moryx.Notifications.Publisher/Model/API/INotificationTypeEntityRepository.cs +++ b/src/Moryx.Notifications.Publisher/Model/API/INotificationTypeEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.Notifications.Publisher.Model; public interface INotificationTypeEntityRepository : IRepository { NotificationTypeEntity Create(string type, int severity); -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Entities/NotificationEntity.cs b/src/Moryx.Notifications.Publisher/Model/Entities/NotificationEntity.cs index e74a3fadf4..188911c47a 100644 --- a/src/Moryx.Notifications.Publisher/Model/Entities/NotificationEntity.cs +++ b/src/Moryx.Notifications.Publisher/Model/Entities/NotificationEntity.cs @@ -29,4 +29,4 @@ public class NotificationEntity : EntityBase public virtual long TypeId { get; set; } public virtual NotificationTypeEntity Type { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Entities/NotificationTypeEntity.cs b/src/Moryx.Notifications.Publisher/Model/Entities/NotificationTypeEntity.cs index 10311fed41..27f274136b 100644 --- a/src/Moryx.Notifications.Publisher/Model/Entities/NotificationTypeEntity.cs +++ b/src/Moryx.Notifications.Publisher/Model/Entities/NotificationTypeEntity.cs @@ -17,4 +17,4 @@ public class NotificationTypeEntity : EntityBase public virtual string ExtensionData { get; set; } public virtual bool IsDisabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20220825085020_InitialCreate.cs b/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20220825085020_InitialCreate.cs index 5cdd606dc2..68b2a4ff34 100644 --- a/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20220825085020_InitialCreate.cs +++ b/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20220825085020_InitialCreate.cs @@ -80,4 +80,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "NotificationTypeEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20251030111139_TableNames.cs b/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20251030111139_TableNames.cs index 897f050a61..25536e693b 100644 --- a/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20251030111139_TableNames.cs +++ b/src/Moryx.Notifications.Publisher/Model/Migrations/Npgsql/20251030111139_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -165,4 +165,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20230215155009_InitialCreate.cs b/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20230215155009_InitialCreate.cs index 00c8438b63..b65eb9909c 100644 --- a/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20230215155009_InitialCreate.cs +++ b/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20230215155009_InitialCreate.cs @@ -81,4 +81,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "NotificationTypeEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20251030111147_TableNames.cs b/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20251030111147_TableNames.cs index b63ef03e09..6b840b96d4 100644 --- a/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20251030111147_TableNames.cs +++ b/src/Moryx.Notifications.Publisher/Model/Migrations/Sqlite/20251030111147_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -127,4 +127,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/NotificationsContext.cs b/src/Moryx.Notifications.Publisher/Model/NotificationsContext.cs index 685db9d486..eeaf5db1f2 100644 --- a/src/Moryx.Notifications.Publisher/Model/NotificationsContext.cs +++ b/src/Moryx.Notifications.Publisher/Model/NotificationsContext.cs @@ -54,4 +54,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) /// There are no comments for NotificationTypeEntity in the schema. /// public virtual DbSet NotificationTypes { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/NpgsqlNotificationsContext.cs b/src/Moryx.Notifications.Publisher/Model/NpgsqlNotificationsContext.cs index 07dc3fc8da..1f064bb531 100644 --- a/src/Moryx.Notifications.Publisher/Model/NpgsqlNotificationsContext.cs +++ b/src/Moryx.Notifications.Publisher/Model/NpgsqlNotificationsContext.cs @@ -21,4 +21,4 @@ public NpgsqlNotificationsContext() public NpgsqlNotificationsContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Model/SqliteNotificationsContext.cs b/src/Moryx.Notifications.Publisher/Model/SqliteNotificationsContext.cs index 2f288094ad..ced14ebcb1 100644 --- a/src/Moryx.Notifications.Publisher/Model/SqliteNotificationsContext.cs +++ b/src/Moryx.Notifications.Publisher/Model/SqliteNotificationsContext.cs @@ -21,4 +21,4 @@ public SqliteNotificationsContext() public SqliteNotificationsContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/ModuleController/ModuleConfig.cs b/src/Moryx.Notifications.Publisher/ModuleController/ModuleConfig.cs index 621fb6418a..d7c061002c 100644 --- a/src/Moryx.Notifications.Publisher/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Notifications.Publisher/ModuleController/ModuleConfig.cs @@ -12,4 +12,4 @@ namespace Moryx.Notifications.Publisher; [DataContract] public class ModuleConfig : ConfigBase { -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/ModuleController/ModuleController.cs b/src/Moryx.Notifications.Publisher/ModuleController/ModuleController.cs index 4d82b08300..34542fac9f 100644 --- a/src/Moryx.Notifications.Publisher/ModuleController/ModuleController.cs +++ b/src/Moryx.Notifications.Publisher/ModuleController/ModuleController.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; using Microsoft.Extensions.Logging; using Moryx.Configuration; using Moryx.Container; using Moryx.Model; using Moryx.Runtime.Modules; -using System.ComponentModel; namespace Moryx.Notifications.Publisher; @@ -51,7 +51,9 @@ protected override Task OnInitializeAsync(CancellationToken cancellationToken) // Register sources foreach (var source in NotificationSources) + { Container.SetInstance(source, source.Name); + } // Initialize components Container.Resolve().Initialize(); diff --git a/src/Moryx.Notifications.Publisher/NotificationManager.cs b/src/Moryx.Notifications.Publisher/NotificationManager.cs index 125728e4e7..5a0f891ce2 100644 --- a/src/Moryx.Notifications.Publisher/NotificationManager.cs +++ b/src/Moryx.Notifications.Publisher/NotificationManager.cs @@ -1,13 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using Microsoft.Extensions.Logging; using Moryx.Container; using Moryx.Logging; using Moryx.Model.Repositories; +using Moryx.Notifications.Publisher.Model; using Moryx.Threading; using Moryx.Tools; -using Microsoft.Extensions.Logging; -using Moryx.Notifications.Publisher.Model; namespace Moryx.Notifications.Publisher; @@ -81,7 +81,9 @@ public void Start() // Add to private list lock (_current) + { _current.AddRange(current); + } // Register to all sources foreach (var source in Sources) @@ -90,7 +92,9 @@ public void Start() source.Acknowledged += OnNotificationAcknowledged; if (source.IsActivated) + { source.Sync(); + } source.StateChanged += OnSourceStateChanged; } @@ -114,7 +118,7 @@ public void Stop() Processors.ForEach(p => p.Stop()); } - public void Dispose() + public static void Dispose() { } @@ -145,13 +149,17 @@ private void OnSourceStateChanged(object sender, bool activated) // Add to running tasks lock (_deactivationTasks) + { _deactivationTasks.Add(task); + } // If task finishes, remove from running tasks task.ContinueWith(delegate (Task target) { lock (_deactivationTasks) + { _deactivationTasks.Remove(target); + } }); } @@ -160,10 +168,14 @@ private void AcknowledgeFromDeactivatedSource(INotificationSource source) // Load published NotificationMap[] current; lock (_current) + { current = _current.Where(m => m.Source == source).ToArray(); + } if (current.Length <= 0) + { return; + } // Acknowledge in database using (var uow = UnitOfWorkFactory.Create()) @@ -171,8 +183,8 @@ private void AcknowledgeFromDeactivatedSource(INotificationSource source) var notificationRepo = uow.GetRepository(); var entities = (from entity in notificationRepo.Linq - where !entity.Acknowledged.HasValue && entity.Source == source.Name - select entity).ToArray(); + where !entity.Acknowledged.HasValue && entity.Source == source.Name + select entity).ToArray(); var timeStamp = DateTime.UtcNow; if (entities.Length > 0) @@ -184,7 +196,9 @@ private void AcknowledgeFromDeactivatedSource(INotificationSource source) // Remove from private list lock (_current) + { _current.RemoveRange(current); + } // Log and raise foreach (var notification in current.Select(c => c.Notification)) @@ -200,7 +214,9 @@ private void AcknowledgeFromDeactivatedSource(INotificationSource source) public Notification[] GetAll() { lock (_current) + { return _current.Select(m => m.Notification).ToArray(); + } } /// @@ -208,7 +224,9 @@ public void Acknowledge(Guid identifier) { NotificationMap map; lock (_current) + { map = _current.SingleOrDefault(m => m.Notification.Identifier == identifier); + } // Acknowledge on Source map?.Source.Acknowledge(map.Notification); @@ -224,7 +242,9 @@ private void OnNotificationOccurred(object sender, Notification notification) }; lock (_current) + { _current.Add(map); + } // Change to a different thread so the caller doesn't have to wait, or breaks down if an exception occurs... ParallelOperations.ExecuteParallel(ProcessNotification, map); @@ -254,11 +274,15 @@ private void ProcessNotification(NotificationMap map) // Raise event for processed notifications if (processResult == NotificationProcessorResult.Processed) + { RaiseNotificationPublished(notification); + } // Check if notification was acknowledged if (isPendingAck) + { ProcessAcknowledgement(map); + } } private void OnNotificationAcknowledged(object sender, Notification notification) @@ -271,7 +295,9 @@ private void ProcessAcknowledgement(INotificationSource source, Notification not { NotificationMap map; lock (_current) + { map = _current.Single(m => m.Notification == notification); + } ProcessAcknowledgement(map); } @@ -303,7 +329,9 @@ private void ProcessAcknowledgement(NotificationMap map) // Remove from private list lock (_current) + { _current.Remove(map); + } // Log and raise Logger.Log(LogLevel.Information, "{0} was acknowledged by {1}. Title: {2}", notification.GetType().Name, @@ -311,7 +339,9 @@ private void ProcessAcknowledgement(NotificationMap map) // Raise event for acknowledged notifications if (ackResult == NotificationProcessorResult.Processed) + { RaiseNotificationAcknowledged(notification); + } } private void SyncWithDatabase(IReadOnlyList existing) @@ -319,13 +349,15 @@ private void SyncWithDatabase(IReadOnlyList existing) using var uow = UnitOfWorkFactory.Create(); var notificationRepo = uow.GetRepository(); var entities = (from entity in notificationRepo.Linq - where !entity.Acknowledged.HasValue - select entity).ToArray(); + where !entity.Acknowledged.HasValue + select entity).ToArray(); // If entity exists which is not existing anymore, we acknowledge it var acknowledged = entities.Where(entity => existing.All(n => n.Identifier != entity.Identifier)).ToArray(); if (acknowledged.Length <= 0) + { return; + } acknowledged.ForEach(a => a.Acknowledged = DateTime.UtcNow); uow.SaveChanges(); @@ -359,4 +391,4 @@ internal enum NotificationState PendingAcknowledge, Acknowledged, } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/INotificationProcessor.cs b/src/Moryx.Notifications.Publisher/Processors/INotificationProcessor.cs index 1171e23109..1eba054a35 100644 --- a/src/Moryx.Notifications.Publisher/Processors/INotificationProcessor.cs +++ b/src/Moryx.Notifications.Publisher/Processors/INotificationProcessor.cs @@ -44,4 +44,4 @@ public interface INotificationProcessor : IPlugin /// Access to the processor for loading acknowledged notifications /// IReadOnlyList GetHistory(DateTime start, DateTime end, Severity[] severity); -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/INotificationType.cs b/src/Moryx.Notifications.Publisher/Processors/INotificationType.cs index b7121c63ba..644875c595 100644 --- a/src/Moryx.Notifications.Publisher/Processors/INotificationType.cs +++ b/src/Moryx.Notifications.Publisher/Processors/INotificationType.cs @@ -27,4 +27,4 @@ public interface INotificationType : IPersistentObject /// Indicator if notification is disabled /// bool IsDisabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessor.cs b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessor.cs index fe14cb800c..74489f9da4 100644 --- a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessor.cs +++ b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessor.cs @@ -11,4 +11,4 @@ namespace Moryx.Notifications.Publisher; [Plugin(LifeCycle.Singleton, typeof(INotificationProcessor))] internal class NotificationProcessor : NotificationProcessorBase { -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorBase.cs b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorBase.cs index 66897a1e67..ce3cb95724 100644 --- a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorBase.cs +++ b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorBase.cs @@ -62,7 +62,9 @@ public virtual void Stop() { // Clear loaded types if initialized if (_types == null) + { return; + } _typeLock.EnterWriteLock(); @@ -107,7 +109,9 @@ public NotificationProcessorResult Process(Notification notification) // If ignored, we do not have to save if (processResult == NotificationProcessorResult.Ignored) + { return processResult; + } using var uow = UnitOfWorkFactory.Create(); var entity = GetNotificationByIdentifier(uow, notification.Identifier); @@ -218,7 +222,9 @@ public virtual NotificationProcessorResult Acknowledge(Notification notification var ackResult = OnAcknowledge(notification, type); if (ackResult == NotificationProcessorResult.Ignored) + { return ackResult; + } using var uow = UnitOfWorkFactory.Create(); var entity = GetNotificationByIdentifier(uow, notification.Identifier); @@ -303,9 +309,15 @@ private static void CopyFromNotificationToEntity(NotificationEntity entity, TNot entity.Title = notification.Title; entity.Message = notification.Message; if (notification.Created != null) + { entity.Created = ConvertToUtc((DateTime)notification.Created); + } + if (notification.Acknowledged != null) + { entity.Acknowledged = ConvertToUtc((DateTime)notification.Acknowledged); + } + entity.Sender = notification.Sender; entity.Source = notification.Source; @@ -315,9 +327,15 @@ private static void CopyFromNotificationToEntity(NotificationEntity entity, TNot private static DateTime ConvertToUtc(DateTime dateTime) { if (dateTime.Kind == DateTimeKind.Utc) + { return dateTime; + } + if (dateTime.Kind == DateTimeKind.Local) + { return TimeZoneInfo.ConvertTimeToUtc(dateTime, TimeZoneInfo.Local); + } + throw new ArgumentException($"Provided {nameof(DateTime)} is neither UTC nor Local Time."); } @@ -340,7 +358,9 @@ private TNotification CopyFromEntityToNotification(NotificationEntity entity) CopyTypeInformationToNotification(type, notification); if (!string.IsNullOrEmpty(entity.ExtensionData)) + { JsonConvert.PopulateObject(entity.ExtensionData, notification, JsonSettings.Minimal); + } return notification; } @@ -378,13 +398,15 @@ public virtual IReadOnlyList GetSelectedHistory(DateTime start, Da var notificationRepo = uow.GetRepository(); var filter = from n in notificationRepo.Linq - where n.Created >= start && n.Created <= end && - n.Type.Severity == (int)severity && - n.Type.Type == typeof(TNotification).Name - select n; + where n.Created >= start && n.Created <= end && + n.Type.Severity == (int)severity && + n.Type.Type == typeof(TNotification).Name + select n; if (!string.IsNullOrEmpty(title)) + { filter = filter.Where(n => n.Title.Equals(title)); + } var results = filter.ToArray(); diff --git a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorResult.cs b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorResult.cs index 5d2064e14b..cecd0296ca 100644 --- a/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorResult.cs +++ b/src/Moryx.Notifications.Publisher/Processors/NotificationProcessorResult.cs @@ -17,4 +17,4 @@ public enum NotificationProcessorResult /// Notification was ignored by the processor /// Ignored -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/NotificationType.cs b/src/Moryx.Notifications.Publisher/Processors/NotificationType.cs index 0503e158c8..343754cb90 100644 --- a/src/Moryx.Notifications.Publisher/Processors/NotificationType.cs +++ b/src/Moryx.Notifications.Publisher/Processors/NotificationType.cs @@ -24,4 +24,4 @@ public class NotificationType : INotificationType /// public bool IsDisabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications.Publisher/Processors/NotificationTypeList.cs b/src/Moryx.Notifications.Publisher/Processors/NotificationTypeList.cs index c344da4ec5..5b9797ca40 100644 --- a/src/Moryx.Notifications.Publisher/Processors/NotificationTypeList.cs +++ b/src/Moryx.Notifications.Publisher/Processors/NotificationTypeList.cs @@ -53,4 +53,4 @@ public bool MoveNext() => public void Reset() => ((IEnumerator)_localEnumerator).Reset(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/Adapter/INotificationSender.cs b/src/Moryx.Notifications/Adapter/INotificationSender.cs index 4f0fd6f8b2..32dba0e062 100644 --- a/src/Moryx.Notifications/Adapter/INotificationSender.cs +++ b/src/Moryx.Notifications/Adapter/INotificationSender.cs @@ -17,4 +17,4 @@ public interface INotificationSender /// Inform the sender about the acknowledged notification /// void Acknowledge(Notification notification, object tag); -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/Adapter/INotificationSourceAdapter.cs b/src/Moryx.Notifications/Adapter/INotificationSourceAdapter.cs index ada234c4e4..1418fef0cf 100644 --- a/src/Moryx.Notifications/Adapter/INotificationSourceAdapter.cs +++ b/src/Moryx.Notifications/Adapter/INotificationSourceAdapter.cs @@ -42,4 +42,4 @@ public interface INotificationSourceAdapter /// Event to publish an acknowledged notification /// event EventHandler Acknowledged; -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/Adapter/NotificationAdapter.cs b/src/Moryx.Notifications/Adapter/NotificationAdapter.cs index 8b8103bc3e..0d76b54bed 100644 --- a/src/Moryx.Notifications/Adapter/NotificationAdapter.cs +++ b/src/Moryx.Notifications/Adapter/NotificationAdapter.cs @@ -59,10 +59,14 @@ public void Publish(INotificationSender sender, Notification notification) public void Publish(INotificationSender sender, Notification notification, object tag) { if (string.IsNullOrEmpty(sender.Identifier)) + { throw new InvalidOperationException("The identifier of the sender must be set."); + } if (notification == null) + { throw new ArgumentNullException(nameof(notification), "Notification must be set"); + } lock (_listLock) { @@ -71,7 +75,10 @@ public void Publish(INotificationSender sender, Notification notification, objec .Any(n => n.Notification == notification); if (isPending) + { throw new InvalidOperationException("Notification cannot be published twice."); + } + notification.Created = DateTime.Now; notification.Sender = sender.Identifier; @@ -85,10 +92,14 @@ public void Publish(INotificationSender sender, Notification notification, objec public void Acknowledge(INotificationSender sender, Notification notification) { if (string.IsNullOrEmpty(sender.Identifier)) + { throw new InvalidOperationException("The identifier of the sender must be set."); + } if (notification == null) + { throw new ArgumentNullException(nameof(notification), "Notification must be set"); + } notification.Acknowledged = DateTime.Now; notification.Acknowledger = sender.Identifier; @@ -98,14 +109,18 @@ public void Acknowledge(INotificationSender sender, Notification notification) { published = _published.SingleOrDefault(n => n.Notification.Identifier == notification.Identifier); if (published is not null) + { _published.Remove(published); + } else { published = _pendingPubs.SingleOrDefault(n => n.Notification.Identifier == notification.Identifier); if (published is null) + { throw new InvalidOperationException("Notification was not managed by the adapter. " + "The sender was not registered on the adapter."); + } _pendingPubs.Remove(published); } @@ -114,7 +129,9 @@ public void Acknowledge(INotificationSender sender, Notification notification) } if (published is not null) + { Acknowledged?.Invoke(this, published.Notification); + } } /// @@ -151,7 +168,9 @@ private void AcknowledgeByFilter(INotificationSender sender, Predicate string Name { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/Facade/NotificationSourceFacade.cs b/src/Moryx.Notifications/Facade/NotificationSourceFacade.cs index 07faeae276..34145d91ea 100644 --- a/src/Moryx.Notifications/Facade/NotificationSourceFacade.cs +++ b/src/Moryx.Notifications/Facade/NotificationSourceFacade.cs @@ -104,4 +104,4 @@ private void OnNotificationAcknowledged(object sender, Notification notification /// public event EventHandler Acknowledged; -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/INotificationPublisher.cs b/src/Moryx.Notifications/INotificationPublisher.cs index 4bdf560cec..d662b47fb4 100644 --- a/src/Moryx.Notifications/INotificationPublisher.cs +++ b/src/Moryx.Notifications/INotificationPublisher.cs @@ -36,4 +36,4 @@ public interface INotificationPublisher /// Raised if notification was acknowledged /// event EventHandler Acknowledged; -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/Notification/Notification.cs b/src/Moryx.Notifications/Notification/Notification.cs index 2e199cf919..70d1f628e4 100644 --- a/src/Moryx.Notifications/Notification/Notification.cs +++ b/src/Moryx.Notifications/Notification/Notification.cs @@ -53,9 +53,13 @@ public virtual DateTime? Acknowledged set { if (field is null) + { field = value; + } else + { throw new InvalidOperationException($"Tried to update {nameof(Acknowledged)}."); + } } } @@ -69,9 +73,13 @@ public virtual string Acknowledger set { if (field is null) + { field = value; + } else + { throw new InvalidOperationException($"Tried to update {nameof(Acknowledger)}."); + } } } @@ -84,9 +92,13 @@ public virtual DateTime? Created set { if (field is null) + { field = value; + } else + { throw new InvalidOperationException($"Tried to update {nameof(Created)}."); + } } } @@ -115,4 +127,4 @@ public Notification(string title, string message, Severity severity, bool isAckn { IsAcknowledgable = isAcknowledgable; } -} \ No newline at end of file +} diff --git a/src/Moryx.Notifications/NotificationExtensions.cs b/src/Moryx.Notifications/NotificationExtensions.cs index 99b4c6ae22..73a9ef6a62 100644 --- a/src/Moryx.Notifications/NotificationExtensions.cs +++ b/src/Moryx.Notifications/NotificationExtensions.cs @@ -25,4 +25,4 @@ public static IContainer RegisterNotifications(this IContainer container) return container; } -} \ No newline at end of file +} diff --git a/src/Moryx.Operators.Endpoints/Models/Converter.cs b/src/Moryx.Operators.Endpoints/Models/Converter.cs index 79978e7687..9a258c065b 100644 --- a/src/Moryx.Operators.Endpoints/Models/Converter.cs +++ b/src/Moryx.Operators.Endpoints/Models/Converter.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Microsoft.AspNetCore.Mvc.ModelBinding; using Moryx.AbstractionLayer.Capabilities; using Moryx.Operators.Attendances; using Moryx.Operators.Skills; @@ -50,7 +49,8 @@ internal static SkillCreationContext ToContext(this SkillCreationContextModel mo LastName = @operator.LastName, Pseudonym = @operator.Pseudonym, Identifier = @operator.Identifier, - AssignedResources = @operator switch { + AssignedResources = @operator switch + { AssignableOperator assignable => assignable.AssignedResources.Select(ToModel), _ => [] } @@ -62,7 +62,10 @@ internal static SkillTypeModel ToModel(this SkillType type, bool full) var capabilitySerialize = EntryConvert.EncodeObject(type.AcquiredCapabilities); model.Capabilities = capabilitySerialize; - if (!full) return model; + if (!full) + { + return model; + } // Only serialize prototypes for detail view model.Capabilities.Prototypes = [.. _capabilitiyPrototypes.Values]; @@ -86,8 +89,7 @@ internal static SkillTypeModel ToModel(this SkillType type, bool full) ExpiresOn = skill.ObtainedOn.AddDays((int)skill.Type.Duration.TotalDays) }; - - internal static SignInStatusChangedModel ToModel(this SignInStatusChangedArgs eventArgs) => new () + internal static SignInStatusChangedModel ToModel(this SignInStatusChangedArgs eventArgs) => new() { Status = eventArgs.Status, Operator = ToModel(eventArgs.Operator), diff --git a/src/Moryx.Operators.Endpoints/Models/OperatorModel.cs b/src/Moryx.Operators.Endpoints/Models/OperatorModel.cs index 7fb383f658..3891d16273 100644 --- a/src/Moryx.Operators.Endpoints/Models/OperatorModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/OperatorModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Endpoints.Models; diff --git a/src/Moryx.Operators.Endpoints/Models/SignInStatusChangedModel.cs b/src/Moryx.Operators.Endpoints/Models/SignInStatusChangedModel.cs index 4075588e1a..8d879697d0 100644 --- a/src/Moryx.Operators.Endpoints/Models/SignInStatusChangedModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/SignInStatusChangedModel.cs @@ -1,11 +1,13 @@ +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + using Moryx.Operators.Attendances; -namespace Moryx.Operators.Endpoints.Models +namespace Moryx.Operators.Endpoints.Models; + +internal sealed class SignInStatusChangedModel { - internal class SignInStatusChangedModel - { - public required SignInStatus Status { get; set; } - public required ExtendedOperatorModel Operator { get; set; } - public required AttendableResourceModel Assignable { get; set; } - } -} \ No newline at end of file + public required SignInStatus Status { get; set; } + public required ExtendedOperatorModel Operator { get; set; } + public required AttendableResourceModel Assignable { get; set; } +} diff --git a/src/Moryx.Operators.Endpoints/Models/SkillCreationContextModel.cs b/src/Moryx.Operators.Endpoints/Models/SkillCreationContextModel.cs index 2d2253728a..07ad08dc83 100644 --- a/src/Moryx.Operators.Endpoints/Models/SkillCreationContextModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/SkillCreationContextModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Endpoints.Models; diff --git a/src/Moryx.Operators.Endpoints/Models/SkillModel.cs b/src/Moryx.Operators.Endpoints/Models/SkillModel.cs index 93ed47d1cc..a78b28c774 100644 --- a/src/Moryx.Operators.Endpoints/Models/SkillModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/SkillModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Endpoints.Models; diff --git a/src/Moryx.Operators.Endpoints/Models/SkillTypeCreationContextModel.cs b/src/Moryx.Operators.Endpoints/Models/SkillTypeCreationContextModel.cs index a83e480e62..7f1c6c2bad 100644 --- a/src/Moryx.Operators.Endpoints/Models/SkillTypeCreationContextModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/SkillTypeCreationContextModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Serialization; diff --git a/src/Moryx.Operators.Endpoints/Models/SkillTypeModel.cs b/src/Moryx.Operators.Endpoints/Models/SkillTypeModel.cs index 91f2ce4c91..5ef986dc7f 100644 --- a/src/Moryx.Operators.Endpoints/Models/SkillTypeModel.cs +++ b/src/Moryx.Operators.Endpoints/Models/SkillTypeModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Serialization; diff --git a/src/Moryx.Operators.Endpoints/OperatorPermissions.cs b/src/Moryx.Operators.Endpoints/OperatorPermissions.cs index 024b2e9f1b..858bcd53c9 100644 --- a/src/Moryx.Operators.Endpoints/OperatorPermissions.cs +++ b/src/Moryx.Operators.Endpoints/OperatorPermissions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Endpoints; diff --git a/src/Moryx.Operators.Endpoints/SkillPermissions.cs b/src/Moryx.Operators.Endpoints/SkillPermissions.cs index a23e36bb3b..3400abd54d 100644 --- a/src/Moryx.Operators.Endpoints/SkillPermissions.cs +++ b/src/Moryx.Operators.Endpoints/SkillPermissions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Endpoints; diff --git a/src/Moryx.Operators.Management/Components/IOperatorManager.cs b/src/Moryx.Operators.Management/Components/IOperatorManager.cs index 642dc74f3d..b7e2959621 100644 --- a/src/Moryx.Operators.Management/Components/IOperatorManager.cs +++ b/src/Moryx.Operators.Management/Components/IOperatorManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Modules; diff --git a/src/Moryx.Operators.Management/Components/ISkillManager.cs b/src/Moryx.Operators.Management/Components/ISkillManager.cs index 3ca3c89d95..c10625e219 100644 --- a/src/Moryx.Operators.Management/Components/ISkillManager.cs +++ b/src/Moryx.Operators.Management/Components/ISkillManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Modules; diff --git a/src/Moryx.Operators.Management/Facade/UserResource.cs b/src/Moryx.Operators.Management/Facade/UserResource.cs index 276f050689..6d72a1cc2c 100644 --- a/src/Moryx.Operators.Management/Facade/UserResource.cs +++ b/src/Moryx.Operators.Management/Facade/UserResource.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; diff --git a/src/Moryx.Operators.Management/Implementation/OperatorManager.cs b/src/Moryx.Operators.Management/Implementation/OperatorManager.cs index 1456750100..16ed4624ae 100644 --- a/src/Moryx.Operators.Management/Implementation/OperatorManager.cs +++ b/src/Moryx.Operators.Management/Implementation/OperatorManager.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Container; -using Moryx.Model.Repositories; -using Moryx.Operators.Management.Model; using Moryx.AbstractionLayer.Resources; +using Moryx.Container; using Moryx.Model; +using Moryx.Model.Repositories; using Moryx.Operators.Attendances; +using Moryx.Operators.Management.Model; namespace Moryx.Operators.Management; diff --git a/src/Moryx.Operators.Management/Implementation/OperatorStorage.cs b/src/Moryx.Operators.Management/Implementation/OperatorStorage.cs index 23dd8abd67..9e503c28be 100644 --- a/src/Moryx.Operators.Management/Implementation/OperatorStorage.cs +++ b/src/Moryx.Operators.Management/Implementation/OperatorStorage.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Resources; @@ -23,7 +23,9 @@ public static OperatorEntity Save(IUnitOfWork uow, OperatorDat entity.Pseudonym = operatorData.Pseudonym; if (AttendancesChanged(operatorData, entity)) + { SaveAttendances(operatorData, uow, entity); + } uow.SaveChanges(); return entity; diff --git a/src/Moryx.Operators.Management/Implementation/SkillManager.cs b/src/Moryx.Operators.Management/Implementation/SkillManager.cs index db14c96b2a..a4f6f0a56f 100644 --- a/src/Moryx.Operators.Management/Implementation/SkillManager.cs +++ b/src/Moryx.Operators.Management/Implementation/SkillManager.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Container; using System.Runtime.CompilerServices; -using Moryx.Operators.Skills; using Microsoft.Extensions.Logging; -using Moryx.Tools; +using Moryx.Container; using Moryx.Logging; +using Moryx.Operators.Skills; +using Moryx.Tools; [assembly: InternalsVisibleTo("Moryx.Operators.Management.IntegrationTests")] diff --git a/src/Moryx.Operators.Management/Implementation/SkillStorage.cs b/src/Moryx.Operators.Management/Implementation/SkillStorage.cs index 9320c179e6..3b78517932 100644 --- a/src/Moryx.Operators.Management/Implementation/SkillStorage.cs +++ b/src/Moryx.Operators.Management/Implementation/SkillStorage.cs @@ -40,7 +40,9 @@ public void Start() { // Abstract classes and those without parameterles ctor will throw an exception if (!c.IsAbstract && c.GetConstructor(Type.EmptyTypes) is not null) + { return c; + } Logger.LogInformation("Skipping {type}, because it is abstract or does not provide an empty constructor.", c.Name); return null; @@ -163,7 +165,9 @@ private ICapabilities DeserializeCapabilities(SkillTypeEntity typeEntity) var capabilityType = capabilityContructor().GetType(); if (JsonConvert.DeserializeObject(typeEntity.CapabilitiesData, capabilityType) is ICapabilities capabilityData) + { return capabilityData; + } Logger.LogError("Capability of type {type} could not be constructed. Deserialization of capability failed.", typeEntity.CapabilitiesType); return new FaultyCapabilities() { OriginalType = typeEntity.CapabilitiesType }; diff --git a/src/Moryx.Operators.Management/Model/API/IOperatorEntityRepository.cs b/src/Moryx.Operators.Management/Model/API/IOperatorEntityRepository.cs index e90c6aba1d..08916a4b73 100644 --- a/src/Moryx.Operators.Management/Model/API/IOperatorEntityRepository.cs +++ b/src/Moryx.Operators.Management/Model/API/IOperatorEntityRepository.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member diff --git a/src/Moryx.Operators.Management/Model/API/ISkillEntityRepository.cs b/src/Moryx.Operators.Management/Model/API/ISkillEntityRepository.cs index c0bf2d25d7..9bb6878c2d 100644 --- a/src/Moryx.Operators.Management/Model/API/ISkillEntityRepository.cs +++ b/src/Moryx.Operators.Management/Model/API/ISkillEntityRepository.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member diff --git a/src/Moryx.Operators.Management/Model/API/ISkillTypeRepository.cs b/src/Moryx.Operators.Management/Model/API/ISkillTypeRepository.cs index 7b366a6927..9353a3035f 100644 --- a/src/Moryx.Operators.Management/Model/API/ISkillTypeRepository.cs +++ b/src/Moryx.Operators.Management/Model/API/ISkillTypeRepository.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member diff --git a/src/Moryx.Operators.Management/Model/Entities/OperatorEntity.cs b/src/Moryx.Operators.Management/Model/Entities/OperatorEntity.cs index 65b9198e06..027db0f9eb 100644 --- a/src/Moryx.Operators.Management/Model/Entities/OperatorEntity.cs +++ b/src/Moryx.Operators.Management/Model/Entities/OperatorEntity.cs @@ -1,11 +1,11 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -using Moryx.Model; -using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Moryx.Model; namespace Moryx.Operators.Management.Model; diff --git a/src/Moryx.Operators.Management/Model/Entities/ResourceLinkEntity.cs b/src/Moryx.Operators.Management/Model/Entities/ResourceLinkEntity.cs index 34726c7bc0..a448438f35 100644 --- a/src/Moryx.Operators.Management/Model/Entities/ResourceLinkEntity.cs +++ b/src/Moryx.Operators.Management/Model/Entities/ResourceLinkEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member diff --git a/src/Moryx.Operators.Management/Model/Entities/SkillTypeEntity.cs b/src/Moryx.Operators.Management/Model/Entities/SkillTypeEntity.cs index bf625f0651..ae6efec83d 100644 --- a/src/Moryx.Operators.Management/Model/Entities/SkillTypeEntity.cs +++ b/src/Moryx.Operators.Management/Model/Entities/SkillTypeEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. diff --git a/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20240808094933_InitialCreate.cs b/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20240808094933_InitialCreate.cs index 8aadda2429..d8ace0b06e 100644 --- a/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20240808094933_InitialCreate.cs +++ b/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20240808094933_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; diff --git a/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20251030110809_TableNames.cs b/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20251030110809_TableNames.cs index 4a22f1b7cc..cebe0af7c1 100644 --- a/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20251030110809_TableNames.cs +++ b/src/Moryx.Operators.Management/Model/Migrations/Npgsql/20251030110809_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -235,4 +235,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20240808095012_InitialCreate.cs b/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20240808095012_InitialCreate.cs index 4df9523082..3ac81e0104 100644 --- a/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20240808095012_InitialCreate.cs +++ b/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20240808095012_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; diff --git a/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20251030110844_TableNames.cs b/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20251030110844_TableNames.cs index 65006ff2fe..b06b3000df 100644 --- a/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20251030110844_TableNames.cs +++ b/src/Moryx.Operators.Management/Model/Migrations/Sqlite/20251030110844_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -235,4 +235,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Operators.Management/Model/NpgsqlOperatorsContext.cs b/src/Moryx.Operators.Management/Model/NpgsqlOperatorsContext.cs index db2444ea9e..282d45a88d 100644 --- a/src/Moryx.Operators.Management/Model/NpgsqlOperatorsContext.cs +++ b/src/Moryx.Operators.Management/Model/NpgsqlOperatorsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; diff --git a/src/Moryx.Operators.Management/Model/OperatorsContext.cs b/src/Moryx.Operators.Management/Model/OperatorsContext.cs index 2ecf84e621..b5439ddbb6 100644 --- a/src/Moryx.Operators.Management/Model/OperatorsContext.cs +++ b/src/Moryx.Operators.Management/Model/OperatorsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; diff --git a/src/Moryx.Operators.Management/Model/SqliteOperatorsContext.cs b/src/Moryx.Operators.Management/Model/SqliteOperatorsContext.cs index b11cdb9fb2..1f5d18057a 100644 --- a/src/Moryx.Operators.Management/Model/SqliteOperatorsContext.cs +++ b/src/Moryx.Operators.Management/Model/SqliteOperatorsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; diff --git a/src/Moryx.Operators.Management/ModuleController/ModuleConfig.cs b/src/Moryx.Operators.Management/ModuleController/ModuleConfig.cs index 003d49faee..5eaf220e20 100644 --- a/src/Moryx.Operators.Management/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Operators.Management/ModuleController/ModuleConfig.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using System.ComponentModel; diff --git a/src/Moryx.Operators.Management/ModuleController/ModuleConsole.cs b/src/Moryx.Operators.Management/ModuleController/ModuleConsole.cs index 96128a3b79..1697befbd6 100644 --- a/src/Moryx.Operators.Management/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Operators.Management/ModuleController/ModuleConsole.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Runtime.Modules; @@ -8,7 +8,7 @@ namespace Moryx.Operators.Management; [ServerModuleConsole] internal class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } } diff --git a/src/Moryx.Operators.Web/Pages/Operators.cshtml.cs b/src/Moryx.Operators.Web/Pages/Operators.cshtml.cs index d509ac78f3..038e6c77d8 100644 --- a/src/Moryx.Operators.Web/Pages/Operators.cshtml.cs +++ b/src/Moryx.Operators.Web/Pages/Operators.cshtml.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/src/Moryx.Operators/Attendances/AssignableOperator.cs b/src/Moryx.Operators/Attendances/AssignableOperator.cs index a7868d0094..b8a2cf67f1 100644 --- a/src/Moryx.Operators/Attendances/AssignableOperator.cs +++ b/src/Moryx.Operators/Attendances/AssignableOperator.cs @@ -21,4 +21,4 @@ public class AssignableOperator(string identifier) : Operator(identifier) /// Id of the resource, which the operator is assigned to /// public virtual IReadOnlyList AssignedResources { get; protected set; } = []; -} \ No newline at end of file +} diff --git a/src/Moryx.Operators/IOperatorManagement.cs b/src/Moryx.Operators/IOperatorManagement.cs index 2ac97caa91..fd67e8d682 100644 --- a/src/Moryx.Operators/IOperatorManagement.cs +++ b/src/Moryx.Operators/IOperatorManagement.cs @@ -35,4 +35,4 @@ public interface IOperatorManagement /// Event to inform that an operator has changed /// event EventHandler OperatorChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Operators/Operator.cs b/src/Moryx.Operators/Operator.cs index aad63f125c..e7c568f576 100644 --- a/src/Moryx.Operators/Operator.cs +++ b/src/Moryx.Operators/Operator.cs @@ -31,4 +31,4 @@ public class Operator(string identifier) /// Pseudonym of the opoerator for display purposes /// public virtual string? Pseudonym { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Operators/Skills/AttendableResource.cs b/src/Moryx.Operators/Skills/AttendableResource.cs index f110b3c0b3..364fe66afb 100644 --- a/src/Moryx.Operators/Skills/AttendableResource.cs +++ b/src/Moryx.Operators/Skills/AttendableResource.cs @@ -1,16 +1,15 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Capabilities; -using Moryx.AbstractionLayer.Resources; -using Moryx.Serialization; -using Moryx.Tools; -using System.Collections.Immutable; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; using System.Runtime.Serialization; +using Moryx.AbstractionLayer.Capabilities; +using Moryx.AbstractionLayer.Resources; using Moryx.Operators.Attendances; using Moryx.Operators.Properties; +using Moryx.Serialization; +using Moryx.Tools; namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/Extensions/SkillExtensions.cs b/src/Moryx.Operators/Skills/Extensions/SkillExtensions.cs index 3b1a210fba..8a0d6c1c84 100644 --- a/src/Moryx.Operators/Skills/Extensions/SkillExtensions.cs +++ b/src/Moryx.Operators/Skills/Extensions/SkillExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; @@ -14,4 +14,4 @@ public static class SkillExtensions /// public static ICapabilities AcquiredCapabilities(this Skill skill) => skill.Type.AcquiredCapabilities; -} \ No newline at end of file +} diff --git a/src/Moryx.Operators/Skills/FaultyCapabilities.cs b/src/Moryx.Operators/Skills/FaultyCapabilities.cs index 47dc40ecbc..a9b9a7f1e0 100644 --- a/src/Moryx.Operators/Skills/FaultyCapabilities.cs +++ b/src/Moryx.Operators/Skills/FaultyCapabilities.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Capabilities; using System.ComponentModel; using System.ComponentModel.DataAnnotations; +using Moryx.AbstractionLayer.Capabilities; using Moryx.Operators.Properties; namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/ISkillManagement.cs b/src/Moryx.Operators/Skills/ISkillManagement.cs index c05b3c6945..ce5940f3de 100644 --- a/src/Moryx.Operators/Skills/ISkillManagement.cs +++ b/src/Moryx.Operators/Skills/ISkillManagement.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SimpleSkill.cs b/src/Moryx.Operators/Skills/SimpleSkill.cs index acd470fd45..aec20215c5 100644 --- a/src/Moryx.Operators/Skills/SimpleSkill.cs +++ b/src/Moryx.Operators/Skills/SimpleSkill.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Capabilities; using System.ComponentModel.DataAnnotations; +using Moryx.AbstractionLayer.Capabilities; using Moryx.Operators.Properties; namespace Moryx.Operators.Skills; @@ -27,10 +27,14 @@ protected override bool ProvidedBy(ICapabilities provided) { var simpleSkill = provided as SimpleSkill; if (simpleSkill == null) + { return false; + } if (string.IsNullOrEmpty(Name) || !Equals(Name, simpleSkill.Name)) + { return false; + } return true; } diff --git a/src/Moryx.Operators/Skills/Skill.cs b/src/Moryx.Operators/Skills/Skill.cs index c2906060ff..76e9f9953a 100644 --- a/src/Moryx.Operators/Skills/Skill.cs +++ b/src/Moryx.Operators/Skills/Skill.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillChange.cs b/src/Moryx.Operators/Skills/SkillChange.cs index c83f47b58e..4ec45c8072 100644 --- a/src/Moryx.Operators/Skills/SkillChange.cs +++ b/src/Moryx.Operators/Skills/SkillChange.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillChangedEventArgs.cs b/src/Moryx.Operators/Skills/SkillChangedEventArgs.cs index f2844b1c9c..b2cff07cd2 100644 --- a/src/Moryx.Operators/Skills/SkillChangedEventArgs.cs +++ b/src/Moryx.Operators/Skills/SkillChangedEventArgs.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillCreationContext.cs b/src/Moryx.Operators/Skills/SkillCreationContext.cs index 2ccc15da92..1b92703cb9 100644 --- a/src/Moryx.Operators/Skills/SkillCreationContext.cs +++ b/src/Moryx.Operators/Skills/SkillCreationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillType.cs b/src/Moryx.Operators/Skills/SkillType.cs index b3553e448c..66af78a094 100644 --- a/src/Moryx.Operators/Skills/SkillType.cs +++ b/src/Moryx.Operators/Skills/SkillType.cs @@ -1,8 +1,8 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Capabilities; using System.ComponentModel.DataAnnotations; +using Moryx.AbstractionLayer.Capabilities; using Moryx.Operators.Properties; namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillTypeChange.cs b/src/Moryx.Operators/Skills/SkillTypeChange.cs index 88014268ff..043cedd140 100644 --- a/src/Moryx.Operators/Skills/SkillTypeChange.cs +++ b/src/Moryx.Operators/Skills/SkillTypeChange.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillTypeChangedEventArgs.cs b/src/Moryx.Operators/Skills/SkillTypeChangedEventArgs.cs index d65a9a2a45..294638e909 100644 --- a/src/Moryx.Operators/Skills/SkillTypeChangedEventArgs.cs +++ b/src/Moryx.Operators/Skills/SkillTypeChangedEventArgs.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 namespace Moryx.Operators.Skills; diff --git a/src/Moryx.Operators/Skills/SkillTypeCreationContext.cs b/src/Moryx.Operators/Skills/SkillTypeCreationContext.cs index 334b78c5d0..ba1daf6121 100644 --- a/src/Moryx.Operators/Skills/SkillTypeCreationContext.cs +++ b/src/Moryx.Operators/Skills/SkillTypeCreationContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; diff --git a/src/Moryx.Orders.Endpoints/ClientOperationSource.cs b/src/Moryx.Orders.Endpoints/ClientOperationSource.cs index 17a77a1604..9488191485 100644 --- a/src/Moryx.Orders.Endpoints/ClientOperationSource.cs +++ b/src/Moryx.Orders.Endpoints/ClientOperationSource.cs @@ -6,7 +6,7 @@ namespace Moryx.Orders.Endpoints; [Display(Name = "MORYX Orders Endpoint Source", Description = "Source for operations created at the MORYX Orders Endpoint")] -internal class ClientOperationSource : IOperationSource +internal sealed class ClientOperationSource : IOperationSource { public string Type => typeof(ClientOperationSource).ToString(); @@ -31,4 +31,4 @@ public ClientOperationSource(string clientId) /// [Display(Name = "Client ID", Description = "The ID of client that created the operation.")] public string ClientId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/AdviceModel.cs b/src/Moryx.Orders.Endpoints/Models/AdviceModel.cs index 6dda0e6ad3..c9580caf72 100644 --- a/src/Moryx.Orders.Endpoints/Models/AdviceModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/AdviceModel.cs @@ -16,4 +16,4 @@ public class AdviceModel [DataMember] public long? PartId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/BeginModel.cs b/src/Moryx.Orders.Endpoints/Models/BeginModel.cs index c3b035fca7..d9a1224372 100644 --- a/src/Moryx.Orders.Endpoints/Models/BeginModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/BeginModel.cs @@ -13,4 +13,4 @@ public class BeginModel [DataMember] public string? UserId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/DocumentModel.cs b/src/Moryx.Orders.Endpoints/Models/DocumentModel.cs index 0758c72fdc..efef8ca7ce 100644 --- a/src/Moryx.Orders.Endpoints/Models/DocumentModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/DocumentModel.cs @@ -28,4 +28,4 @@ public class DocumentModel [DataMember] public string Source { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/OperationChangedModel.cs b/src/Moryx.Orders.Endpoints/Models/OperationChangedModel.cs index 516ca5eb76..c99064241b 100644 --- a/src/Moryx.Orders.Endpoints/Models/OperationChangedModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/OperationChangedModel.cs @@ -59,4 +59,4 @@ public enum OperationTypes Report, Advice, Update -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/OperationCreationContextModel.cs b/src/Moryx.Orders.Endpoints/Models/OperationCreationContextModel.cs index 82f192984f..660d5f1163 100644 --- a/src/Moryx.Orders.Endpoints/Models/OperationCreationContextModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/OperationCreationContextModel.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Runtime.Serialization; using Moryx.Serialization; using Moryx.Tools; -using System.Runtime.Serialization; namespace Moryx.Orders.Endpoints.Models; @@ -77,7 +77,10 @@ public OperationCreationContext ConvertToContext() { var type = materialParameterTypes.FirstOrDefault(t => t.Name.Equals(materialEntry.Value.Default)); if (type == null) + { continue; + } + var materialParameter = (IMaterialParameter)EntryConvert.CreateInstance(type, materialEntry); context.MaterialParameters.Add(materialParameter); } @@ -184,4 +187,4 @@ public OperationCreationContext ConvertToContext() /// Additional operation depending parameters for the production /// public Entry[] MaterialParameters { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/OperationLogMessageModel.cs b/src/Moryx.Orders.Endpoints/Models/OperationLogMessageModel.cs index d8a6235e3e..6a7a898349 100644 --- a/src/Moryx.Orders.Endpoints/Models/OperationLogMessageModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/OperationLogMessageModel.cs @@ -20,4 +20,4 @@ public class OperationLogMessageModel [DataMember] public DateTime TimeStamp { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/OperationModel.cs b/src/Moryx.Orders.Endpoints/Models/OperationModel.cs index e12466ed3b..3154f6e756 100644 --- a/src/Moryx.Orders.Endpoints/Models/OperationModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/OperationModel.cs @@ -153,4 +153,4 @@ public OperationModel() public bool HasPartList { get; set; } public Entry OperationSource { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/OperationRecipeModel.cs b/src/Moryx.Orders.Endpoints/Models/OperationRecipeModel.cs index d745f20cf9..36172c85d7 100644 --- a/src/Moryx.Orders.Endpoints/Models/OperationRecipeModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/OperationRecipeModel.cs @@ -13,4 +13,4 @@ public class OperationRecipeModel [DataMember] public string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/ProductPartModel.cs b/src/Moryx.Orders.Endpoints/Models/ProductPartModel.cs index b3de267262..5c0dacc8a8 100644 --- a/src/Moryx.Orders.Endpoints/Models/ProductPartModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/ProductPartModel.cs @@ -28,4 +28,4 @@ public class ProductPartModel [DataMember] public PartClassification Classification { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/Models/ReportModel.cs b/src/Moryx.Orders.Endpoints/Models/ReportModel.cs index 566fd01b8a..c52d063ea2 100644 --- a/src/Moryx.Orders.Endpoints/Models/ReportModel.cs +++ b/src/Moryx.Orders.Endpoints/Models/ReportModel.cs @@ -22,4 +22,4 @@ public class ReportModel [DataMember] public string UserIdentifier { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Endpoints/OrderManagementController.cs b/src/Moryx.Orders.Endpoints/OrderManagementController.cs index aeedc234e3..ea8655a73d 100644 --- a/src/Moryx.Orders.Endpoints/OrderManagementController.cs +++ b/src/Moryx.Orders.Endpoints/OrderManagementController.cs @@ -1,19 +1,19 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Moryx.AbstractionLayer.Products; -using Moryx.Orders.Endpoints.Properties; -using Moryx.Users; using System.Net; using System.Net.ServerSentEvents; using System.Text.Json; using System.Text.Json.Serialization; using System.Threading.Channels; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Moryx.AbstractionLayer.Products; using Moryx.AspNetCore; using Moryx.Orders.Endpoints.Models; +using Moryx.Orders.Endpoints.Properties; +using Moryx.Users; namespace Moryx.Orders.Endpoints; @@ -152,7 +152,9 @@ public async Task> GetOperation(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } return Converter.ToModel(operation); } @@ -167,7 +169,9 @@ public async Task> GetDocuments(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_GetDocuments_DocumentNotFound }); + } return operation.Documents.Select(Converter.ToModel).ToArray(); } @@ -183,14 +187,20 @@ public async Task GetDocumentStream(Guid guid, string identifier) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_GetDocuments_DocumentNotFound }); + } var document = operation.Documents.FirstOrDefault(x => x.Identifier == identifier); if (document == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_GetDocuments_DocumentNotFound }); + } if (string.IsNullOrEmpty(document.ContentType)) + { return BadRequest(); + } return new FileStreamResult(document.GetStream(), document.ContentType); } @@ -205,7 +215,9 @@ public async Task> GetProductParts(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_GetProductParts_ProductPartsNotFound }); + } return operation.Parts.Select(Converter.ToModel).ToArray(); } @@ -243,11 +255,15 @@ public async Task> GetReportContext(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } var reportContext = _orderManagement.GetReportContext(operation); if (reportContext == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } return reportContext; } @@ -262,11 +278,15 @@ public async Task> GetInterruptContext(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } var reportContext = _orderManagement.GetInterruptContext(operation); if (reportContext == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } return reportContext; } @@ -281,11 +301,15 @@ public async Task> GetAdviceContext(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } var adviceContext = _orderManagement.GetAdviceContext(operation); if (adviceContext == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } return adviceContext; } @@ -299,7 +323,9 @@ public async Task> GetLogs(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } return _orderManagement.GetLogs(operation).Select(Converter.ToModel).ToArray(); } @@ -326,7 +352,9 @@ public async Task> AddOperation(OperationCreationCo var context = contextModel.ConvertToContext(); if (context == null) + { return BadRequest("Context is null"); + } if (sourceId == null) { @@ -350,7 +378,9 @@ public async Task BeginOperation(Guid guid, BeginModel beginModel) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } if (beginModel.UserId is null) { @@ -374,7 +404,9 @@ public async Task AbortOperation(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } await _orderManagement.AbortOperationAsync(operation); return Ok(); @@ -428,13 +460,19 @@ public async Task AdviceOperation(Guid guid, AdviceModel advice) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } var result = await _orderManagement.TryAdviceAsync(operation, Converter.FromModel(advice, operation)); if (result.Success) + { return Ok(); + } else + { return BadRequest(result.Message); + } } #endregion @@ -450,7 +488,9 @@ public async Task UpdateOperation(Guid guid, OperationUpdateModel { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } await _orderManagement.UpdateOperationAsync(operation, Converter.FromModel(update)); return Ok(); @@ -466,7 +506,9 @@ public async Task Reload(Guid guid) { var operation = await _orderManagement.LoadOperationAsync(guid); if (operation == null) + { return NotFound(new MoryxExceptionResponse { Title = Strings.OrderManagementController_OperationNotFound }); + } await _orderManagement.ReloadAsync(operation); return Ok(); diff --git a/src/Moryx.Orders.Endpoints/OrderPermissions.cs b/src/Moryx.Orders.Endpoints/OrderPermissions.cs index f418d74416..96f40da5a1 100644 --- a/src/Moryx.Orders.Endpoints/OrderPermissions.cs +++ b/src/Moryx.Orders.Endpoints/OrderPermissions.cs @@ -14,4 +14,4 @@ public static class OrderPermissions public const string CanInterrupt = _prefix + "CanInterrupt"; public const string CanReport = _prefix + "CanReport"; public const string CanAdvice = _prefix + "CanAdvice"; -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/AdviceEventArgs.cs b/src/Moryx.Orders.Management/Components/AdviceEventArgs.cs index 976efdf660..e76a32f614 100644 --- a/src/Moryx.Orders.Management/Components/AdviceEventArgs.cs +++ b/src/Moryx.Orders.Management/Components/AdviceEventArgs.cs @@ -20,4 +20,4 @@ public AdviceEventArgs(IOperationData operationData, OperationAdvice advice) : b { Advice = advice; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/IOperationData.cs b/src/Moryx.Orders.Management/Components/IOperationData.cs index 8f76444563..917a36545f 100644 --- a/src/Moryx.Orders.Management/Components/IOperationData.cs +++ b/src/Moryx.Orders.Management/Components/IOperationData.cs @@ -212,4 +212,4 @@ internal interface IOperationData /// Raised if the progress was changed /// event EventHandler ProgressChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/IOperationFactory.cs b/src/Moryx.Orders.Management/Components/IOperationFactory.cs index 7610c3b872..e516a48b18 100644 --- a/src/Moryx.Orders.Management/Components/IOperationFactory.cs +++ b/src/Moryx.Orders.Management/Components/IOperationFactory.cs @@ -11,4 +11,4 @@ internal interface IOperationFactory IOperationData Create(IOperationSavingContext savingContext); void Destroy(IOperationData operationData); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/IOrderData.cs b/src/Moryx.Orders.Management/Components/IOrderData.cs index 13ced8141e..52c8133f6e 100644 --- a/src/Moryx.Orders.Management/Components/IOrderData.cs +++ b/src/Moryx.Orders.Management/Components/IOrderData.cs @@ -39,4 +39,4 @@ internal interface IOrderData /// Removes an operation from the order data /// void RemoveOperation(IOperationData operationData); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/OperationAssignState.cs b/src/Moryx.Orders.Management/Components/OperationAssignState.cs index 38b8c594bd..3acae52308 100644 --- a/src/Moryx.Orders.Management/Components/OperationAssignState.cs +++ b/src/Moryx.Orders.Management/Components/OperationAssignState.cs @@ -13,4 +13,4 @@ internal enum OperationAssignState Changed = 1 << 3, Failed = Changed | 1 << 4, -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/OperationEventArgs.cs b/src/Moryx.Orders.Management/Components/OperationEventArgs.cs index 9cbc65dbc6..f7eab34815 100644 --- a/src/Moryx.Orders.Management/Components/OperationEventArgs.cs +++ b/src/Moryx.Orders.Management/Components/OperationEventArgs.cs @@ -20,4 +20,4 @@ public OperationEventArgs(IOperationData operationData) { OperationData = operationData; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/ReportEventArgs.cs b/src/Moryx.Orders.Management/Components/ReportEventArgs.cs index d494b3149e..e8378049e8 100644 --- a/src/Moryx.Orders.Management/Components/ReportEventArgs.cs +++ b/src/Moryx.Orders.Management/Components/ReportEventArgs.cs @@ -21,4 +21,4 @@ public ReportEventArgs(IOperationData operationData, OperationReport report) { Report = report; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Components/StartedEventArgs.cs b/src/Moryx.Orders.Management/Components/StartedEventArgs.cs index 4d1f6cbbf4..634cefbed5 100644 --- a/src/Moryx.Orders.Management/Components/StartedEventArgs.cs +++ b/src/Moryx.Orders.Management/Components/StartedEventArgs.cs @@ -22,4 +22,4 @@ public StartedEventArgs(IOperationData operationData, User user) : base(operatio { User = user; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Facade/OrderManagementFacade.cs b/src/Moryx.Orders.Management/Facade/OrderManagementFacade.cs index 378b0f53d7..a4510c0181 100644 --- a/src/Moryx.Orders.Management/Facade/OrderManagementFacade.cs +++ b/src/Moryx.Orders.Management/Facade/OrderManagementFacade.cs @@ -116,14 +116,18 @@ private void OnOperationBeginRequest(object sender, BeginRequestEventArgs e) private void OnOperationReportRequest(object sender, ReportRequestEventArgs e) { if (OperationReportRequest == null) + { return; + } var request = new OperationReportRequestEventArgs(e.OperationData.Operation, e.ReportType); OperationReportRequest(this, request); foreach (var restriction in request.Restrictions) + { e.AddRestriction(restriction); + } } public IReadOnlyList GetOperations(Func filter) @@ -254,7 +258,9 @@ public Task UpdateOperationAsync(Operation operation, OperationUpdate update, Ca { var operationData = OperationDataPool.Get(operation); if (operationData == null) + { throw new ArgumentException($"Operation with identifier {operation.Identifier} not found."); + } return operationData.UpdateAsync(update, cancellationToken); } @@ -263,7 +269,9 @@ private IOperationData GetOperationDataSave(Operation operation) { var operationData = OperationDataPool.Get(operation); if (operationData == null) + { throw new ArgumentException($"Operation with identifier {operation.Identifier} not found."); + } return operationData; } @@ -307,7 +315,9 @@ public IReadOnlyCollection GetLogs(Operation operation) var operationData = OperationDataPool.Get(operation); var operationLogger = LoggerProvider.GetLogger(operationData); if (operationLogger == null) + { return Array.Empty(); + } return operationLogger.Messages; } diff --git a/src/Moryx.Orders.Management/Implementation/Advice/AdviceManager.cs b/src/Moryx.Orders.Management/Implementation/Advice/AdviceManager.cs index 14c09b65ef..5b3ab0a5f1 100644 --- a/src/Moryx.Orders.Management/Implementation/Advice/AdviceManager.cs +++ b/src/Moryx.Orders.Management/Implementation/Advice/AdviceManager.cs @@ -73,8 +73,10 @@ private async Task Advice(IOperationData operationData, T } if (result.Success) + { await operationData.Advice(advice); + } return result; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Advice/IAdviceManager.cs b/src/Moryx.Orders.Management/Implementation/Advice/IAdviceManager.cs index 8f7980bc87..6b326dcff0 100644 --- a/src/Moryx.Orders.Management/Implementation/Advice/IAdviceManager.cs +++ b/src/Moryx.Orders.Management/Implementation/Advice/IAdviceManager.cs @@ -27,4 +27,4 @@ internal interface IAdviceManager : IAsyncPlugin /// Number of the ToteBox to advice /// Task PickPartAdvice(IOperationData operationData, string toteBoxNumber, ProductPart part); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Advice/NullAdviceExecutor.cs b/src/Moryx.Orders.Management/Implementation/Advice/NullAdviceExecutor.cs index 5ee432ad73..5dc3573bfc 100644 --- a/src/Moryx.Orders.Management/Implementation/Advice/NullAdviceExecutor.cs +++ b/src/Moryx.Orders.Management/Implementation/Advice/NullAdviceExecutor.cs @@ -47,4 +47,4 @@ public Task AdviceAsync(Operation operation, PickPartAdvice advice Message = "Advices are not allowed" }); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/DefaultPartsAssignment.cs b/src/Moryx.Orders.Management/Implementation/Assignment/DefaultPartsAssignment.cs index 80108817c7..b8c46244e8 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/DefaultPartsAssignment.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/DefaultPartsAssignment.cs @@ -127,4 +127,4 @@ private static void IteratePartLinkCollections(ProductType product, Dictionary

SelectProductAsync(Operation operation, IOpera var productIdentity = (ProductIdentity)operation.Product.Identity; return ProductManagement.LoadTypeAsync(productIdentity, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/DefaultRecipeAssignment.cs b/src/Moryx.Orders.Management/Implementation/Assignment/DefaultRecipeAssignment.cs index 78798c1365..10bab38d56 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/DefaultRecipeAssignment.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/DefaultRecipeAssignment.cs @@ -49,4 +49,4 @@ public override Task ProcessRecipeAsync(IProductRecipe clone, Operation op return Task.FromResult(true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/DocumentAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/DocumentAssignStep.cs index f2946244df..1ebe0600ac 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/DocumentAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/DocumentAssignStep.cs @@ -67,11 +67,15 @@ public async Task AssignStep(IOperationData operationData, IOperationLogge } if (availableDocuments.Count == 0) + { return true; + } var fullPath = GetFullFolderPath(identity); if (!Directory.Exists(fullPath)) + { Directory.CreateDirectory(fullPath); + } var localDocuments = new List(); foreach (var document in availableDocuments) @@ -167,4 +171,4 @@ private static string GetDefaultExtension(string mimeType) } return result; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/IAssignStepFactory.cs b/src/Moryx.Orders.Management/Implementation/Assignment/IAssignStepFactory.cs index faed9c0196..bc0a7c4d73 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/IAssignStepFactory.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/IAssignStepFactory.cs @@ -9,4 +9,4 @@ namespace Moryx.Orders.Management.Assignment; internal interface IAssignStepFactory { IOperationAssignStep Create(string name); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignStep.cs index 3b343178e6..3e0c5fc80e 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignStep.cs @@ -19,4 +19,4 @@ internal interface IOperationAssignStep : IPlugin /// Executes the restore /// Task RestoreStep(IOperationData operationData, IOperationLogger operationLogger); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignment.cs b/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignment.cs index cbf47d1548..afb342529b 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignment.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/IOperationAssignment.cs @@ -24,4 +24,4 @@ internal interface IOperationAssignment : IPlugin /// Restores an operation /// Task Restore(IOperationData operationData); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/NullDocumentLoader.cs b/src/Moryx.Orders.Management/Implementation/Assignment/NullDocumentLoader.cs index 14f1868d1a..d84ce8efdb 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/NullDocumentLoader.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/NullDocumentLoader.cs @@ -35,4 +35,4 @@ public Task StopAsync(CancellationToken cancellationToken = default) /// public Task> LoadAsync(Operation operation, CancellationToken cancellationToken) => Task.FromResult(EmptyDocuments); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/NullOperationValidation.cs b/src/Moryx.Orders.Management/Implementation/Assignment/NullOperationValidation.cs index d4ecbbaa44..52655cef79 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/NullOperationValidation.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/NullOperationValidation.cs @@ -33,4 +33,4 @@ public Task ValidateAsync(Operation operation, IOperationLogger operationL { return Task.FromResult(true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/NullPartsAssignment.cs b/src/Moryx.Orders.Management/Implementation/Assignment/NullPartsAssignment.cs index 8e20280272..779ed0a630 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/NullPartsAssignment.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/NullPartsAssignment.cs @@ -36,4 +36,4 @@ public Task StopAsync(CancellationToken cancellationToken = default) public Task> LoadPartsAsync(Operation operation, IOperationLogger operationLogger, CancellationToken cancellationToken) => Task.FromResult(operation.Parts ?? (IReadOnlyList)Enumerable.Empty()); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/OperationAssignment.cs b/src/Moryx.Orders.Management/Implementation/Assignment/OperationAssignment.cs index 3d988e3ebf..adbadaf4bc 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/OperationAssignment.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/OperationAssignment.cs @@ -88,7 +88,9 @@ private async Task RunAssignment(IOperationData operationData) { result = await createStep.AssignStep(operationData, operationLogger); if (!result) + { break; + } operationLogger.Log(LogLevel.Information, Strings.OperationAssignment_Successful, createStep.GetType().Name); } @@ -143,7 +145,9 @@ public async Task Restore(IOperationData operationData) { var result = await restoreStep.RestoreStep(operationData, operationLogger); if (result) + { continue; + } throw new InvalidOperationException($"{restoreStep.GetType().Name} has failed."); } diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/PartsAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/PartsAssignStep.cs index 88738d4960..42c7fafd8c 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/PartsAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/PartsAssignStep.cs @@ -45,4 +45,4 @@ public async Task AssignStep(IOperationData operationData, IOperationLogge public Task RestoreStep(IOperationData operationData, IOperationLogger operationLogger) => Task.FromResult(true); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/ProductAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/ProductAssignStep.cs index 03f48afc57..e04a49c62d 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/ProductAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/ProductAssignStep.cs @@ -40,13 +40,17 @@ public async Task AssignStep(IOperationData operationData, IOperationLogge public async Task RestoreStep(IOperationData operationData, IOperationLogger operationLogger) { if (operationData.Product == null) + { return false; + } var productId = operationData.Product.Id; ProductType product = null; if (productId != 0) + { product = await ProductManagement.LoadTypeAsync(operationData.Product.Id); + } if (product == null) { @@ -57,4 +61,4 @@ public async Task RestoreStep(IOperationData operationData, IOperationLogg operationData.AssignProduct(product); return true; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/RecipeAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/RecipeAssignStep.cs index 75ebc0477d..e00e307956 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/RecipeAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/RecipeAssignStep.cs @@ -210,4 +210,4 @@ private static bool CheckProductPartLinksRecursive(ProductType type, long produc return references.Any(link => CheckProductPartLinksRecursive(link.Product, productId)); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidation.cs b/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidation.cs index 442f05d9b4..b6ed91e5e4 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidation.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidation.cs @@ -54,16 +54,24 @@ public Task ValidateAsync(Operation operation, IOperationLogger operationL var recipesResult = operation.Recipes.Any() && operation.Recipes.All(ValidateRecipe); if (numberResult && amountResult && recipesResult) + { return Task.FromResult(true); + } if (!numberResult) + { operationLogger.Log(LogLevel.Error, Strings.RegexOperationValidation_Regex_Match_Failed, _config.RegularExpression); + } if (!amountResult) + { operationLogger.Log(LogLevel.Error, Strings.RegexOperationValidation_Wrong_Amount); + } if (!recipesResult) + { operationLogger.Log(LogLevel.Error, Strings.RegexOperationValidation_No_Valid_Recipe); + } return Task.FromResult(false); } @@ -77,7 +85,9 @@ public virtual Task ValidateCreationContextAsync(OrderCreationContext orde ValidateOperationAmount(operation.TotalAmount); if (validationResult == false) + { return Task.FromResult(false); + } } return Task.FromResult(true); @@ -112,4 +122,4 @@ private static bool ValidateRecipe(IRecipe recipe) { return recipe != null; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidationConfig.cs b/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidationConfig.cs index 90acda9ebd..84f1e5907c 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidationConfig.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/RegexOperationValidationConfig.cs @@ -32,4 +32,4 @@ public RegexOperationValidationConfig() [DefaultValue(@"^[\S+]{4}$")] [Description("Regex applied to validate the operation number")] public string RegularExpression { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/UserAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/UserAssignStep.cs index cefe2336d0..410a6b0e09 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/UserAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/UserAssignStep.cs @@ -36,4 +36,4 @@ public Task RestoreStep(IOperationData operationData, IOperationLogger ope return Task.FromResult(true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Assignment/ValidateAssignStep.cs b/src/Moryx.Orders.Management/Implementation/Assignment/ValidateAssignStep.cs index c72478283f..d12fc999b3 100644 --- a/src/Moryx.Orders.Management/Implementation/Assignment/ValidateAssignStep.cs +++ b/src/Moryx.Orders.Management/Implementation/Assignment/ValidateAssignStep.cs @@ -28,4 +28,4 @@ public Task RestoreStep(IOperationData operationData, IOperationLogger ope { return Task.FromResult(true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/CountStrategy/DoNotReplaceScrapStrategy.cs b/src/Moryx.Orders.Management/Implementation/CountStrategy/DoNotReplaceScrapStrategy.cs index dd826fa9ec..84697b2272 100644 --- a/src/Moryx.Orders.Management/Implementation/CountStrategy/DoNotReplaceScrapStrategy.cs +++ b/src/Moryx.Orders.Management/Implementation/CountStrategy/DoNotReplaceScrapStrategy.cs @@ -55,4 +55,4 @@ public IReadOnlyList MissingAmounts(Operation operation) ? [new DispatchContext((ProductionRecipe)operation.Recipes.Single(), (uint)missingAmount)] : Array.Empty(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/CountStrategy/ReplaceScrapStrategy.cs b/src/Moryx.Orders.Management/Implementation/CountStrategy/ReplaceScrapStrategy.cs index 4dbbfaf82c..6ad684c98c 100644 --- a/src/Moryx.Orders.Management/Implementation/CountStrategy/ReplaceScrapStrategy.cs +++ b/src/Moryx.Orders.Management/Implementation/CountStrategy/ReplaceScrapStrategy.cs @@ -47,12 +47,19 @@ public int ReachableAmount(Operation operation) private static int Reachable(int sum, Job job) { if (job.Classification >= JobClassification.Completing) + { sum = sum + job.RunningProcesses.Count; + } else + { sum = sum + job.Amount - job.SuccessCount - job.FailureCount; + } if (job is IPredictiveJob predictive) + { sum -= predictive.PredictedFailures.Count; + } + return sum; } @@ -63,4 +70,4 @@ public IReadOnlyList MissingAmounts(Operation operation) ? [new DispatchContext((ProductionRecipe)operation.Recipes.Single(), (uint)missingAmount)] : Array.Empty(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/JobHandler/IJobHandler.cs b/src/Moryx.Orders.Management/Implementation/JobHandler/IJobHandler.cs index 8ff73befcd..a9a5e9bf9c 100644 --- a/src/Moryx.Orders.Management/Implementation/JobHandler/IJobHandler.cs +++ b/src/Moryx.Orders.Management/Implementation/JobHandler/IJobHandler.cs @@ -27,4 +27,4 @@ internal interface IJobHandler : IPlugin /// Will load all given jobs by their id from the /// IEnumerable Restore(IEnumerable jobIds); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/JobHandler/JobHandler.cs b/src/Moryx.Orders.Management/Implementation/JobHandler/JobHandler.cs index c1a19fdb16..9bce9cb35a 100644 --- a/src/Moryx.Orders.Management/Implementation/JobHandler/JobHandler.cs +++ b/src/Moryx.Orders.Management/Implementation/JobHandler/JobHandler.cs @@ -63,7 +63,9 @@ private async void OnJobsDispatched(object sender, JobDispatchedEventArgs eventA var operationData = OperationDataPool.Get(eventArgs.Operation); foreach (var addedJob in eventArgs.Jobs) + { await operationData.AddJob(addedJob); + } } catch (Exception e) { @@ -79,7 +81,9 @@ private async void OnJobProgressChanged(object sender, Job job) // If operation was found and currently not dispatching, we can throw updates if (operationData == null) + { return; + } await operationData.JobProgressChanged(job); await Dispatcher.JobProgressChangedAsync(operationData.Operation, job, CancellationToken.None); @@ -103,7 +107,9 @@ private async void OnJobStateChanged(object sender, JobStateChangedEventArgs eve // If operation was found and currently not dispatching, we can throw updates if (operationData == null) + { return; + } await operationData.JobStateChanged(eventArgs); await Dispatcher.JobStateChangedAsync(operationData.Operation, eventArgs, CancellationToken.None); @@ -128,5 +134,5 @@ public Task Complete(IOperationData operationData) /// public IEnumerable Restore(IEnumerable jobIds) - => jobIds.Select(id => JobManagement.Get(id)); -} \ No newline at end of file + => jobIds.Select(JobManagement.Get); +} diff --git a/src/Moryx.Orders.Management/Implementation/JobHandler/SingleJobOperationDispatcher.cs b/src/Moryx.Orders.Management/Implementation/JobHandler/SingleJobOperationDispatcher.cs index 6ce098563f..7ca489fe71 100644 --- a/src/Moryx.Orders.Management/Implementation/JobHandler/SingleJobOperationDispatcher.cs +++ b/src/Moryx.Orders.Management/Implementation/JobHandler/SingleJobOperationDispatcher.cs @@ -27,7 +27,9 @@ public override async Task DispatchAsync(Operation operation, IReadOnlyList j.Classification >= JobClassification.Completing); if (!allCompleting) + { return; + } var lastJob = operation.Jobs.LastOrDefault(j => j.Classification < JobClassification.Completed); @@ -35,7 +37,9 @@ public override async Task DispatchAsync(Operation operation, IReadOnlyList creationContext.Add(c.Recipe, c.Amount)); if (lastJob != null) + { creationContext.After(lastJob); + } try { @@ -57,4 +61,4 @@ public override Task CompleteAsync(Operation operation, CancellationToken cancel return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Logging/IOperationLoggerProvider.cs b/src/Moryx.Orders.Management/Implementation/Logging/IOperationLoggerProvider.cs index 404626715a..779c54124b 100644 --- a/src/Moryx.Orders.Management/Implementation/Logging/IOperationLoggerProvider.cs +++ b/src/Moryx.Orders.Management/Implementation/Logging/IOperationLoggerProvider.cs @@ -17,4 +17,4 @@ internal interface IOperationLoggerProvider /// Removes a logger for the given operation /// void RemoveLogger(IOperationData operationData); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Logging/OperationLoggerProvider.cs b/src/Moryx.Orders.Management/Implementation/Logging/OperationLoggerProvider.cs index e0c063234d..04d8fa9bba 100644 --- a/src/Moryx.Orders.Management/Implementation/Logging/OperationLoggerProvider.cs +++ b/src/Moryx.Orders.Management/Implementation/Logging/OperationLoggerProvider.cs @@ -27,7 +27,9 @@ public IOperationLogger GetLogger(IOperationData operationData) { IOperationLogger operationLogger; if (_logger.TryGetValue(operationData, out var existingLogger)) + { operationLogger = existingLogger; + } else { operationLogger = new OperationLogger(Logger, operationData); @@ -40,7 +42,9 @@ public IOperationLogger GetLogger(IOperationData operationData) public void RemoveLogger(IOperationData operationData) { if (!_logger.ContainsKey(operationData)) + { return; + } _logger.Remove(operationData); } diff --git a/src/Moryx.Orders.Management/Implementation/NullUserManagement.cs b/src/Moryx.Orders.Management/Implementation/NullUserManagement.cs index db89d79309..78681b28a1 100644 --- a/src/Moryx.Orders.Management/Implementation/NullUserManagement.cs +++ b/src/Moryx.Orders.Management/Implementation/NullUserManagement.cs @@ -43,4 +43,4 @@ public DummyUser() SignedIn = true; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperation.cs b/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperation.cs index 415ca5e1c1..9845b75f53 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperation.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperation.cs @@ -237,4 +237,4 @@ public InternalOperation() get => base.Jobs; set => base.Jobs = value; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperationProgress.cs b/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperationProgress.cs index 463ce9c4cd..4194a2d6f2 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperationProgress.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/InternalOperationProgress.cs @@ -64,4 +64,4 @@ internal class InternalOperationProgress : OperationProgress get => base.ProgressPending; set => base.ProgressPending = value; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/OperationData.cs b/src/Moryx.Orders.Management/Implementation/OperationData/OperationData.cs index 457343eb2c..684fa3712f 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/OperationData.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/OperationData.cs @@ -1,17 +1,17 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.ControlSystem.Jobs; +using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; using Moryx.Container; +using Moryx.ControlSystem.Jobs; using Moryx.Logging; using Moryx.Orders.Management.Assignment; using Moryx.Orders.Management.Model; using Moryx.StateMachines; using Moryx.Tools; using Moryx.Users; -using Microsoft.Extensions.Logging; namespace Moryx.Orders.Management; diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/AbortedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/AbortedState.cs index dc6c38d1d2..0d9b65f50f 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/AbortedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/AbortedState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -13,4 +13,4 @@ public AbortedState(OperationData context, StateMap stateMap) : base(context, stateMap, OperationStateClassification.Aborted) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignFailedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignFailedState.cs index f3b479d8e8..d73dc96de6 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignFailedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignFailedState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignState.cs index 4398bf4569..eb76c3da9d 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedAssignState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -26,4 +26,4 @@ public override Task Resume() { return NextStateAsync(StateAmountReached); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedState.cs index ad9f8a0b0f..e536df7c18 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/AmountReachedState.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Logging; using Moryx.ControlSystem.Jobs; using Moryx.Logging; -using System.ComponentModel.DataAnnotations; using Moryx.Orders.Management.Properties; using Moryx.Users; @@ -99,4 +99,4 @@ public override Task JobsUpdated(JobStateChangedEventArgs args) return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/CompletedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/CompletedState.cs index 2c918fa279..28cf8b06d6 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/CompletedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/CompletedState.cs @@ -25,4 +25,4 @@ public override Task Advice(OperationAdvice advice) { return Context.HandleAdvice(advice); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/IOperationState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/IOperationState.cs index cdbee0904a..d063b3b206 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/IOperationState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/IOperationState.cs @@ -72,4 +72,4 @@ internal interface IOperationState /// Flag if the operation has reached the target amount /// bool IsAmountReached { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignFailedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignFailedState.cs index 4b06d21145..8cd6f0cef0 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignFailedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignFailedState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -31,4 +31,4 @@ public override async Task Abort() await NextStateAsync(StateAborted); await Context.HandleAbort(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignState.cs index 27da543cb4..6a381e73b9 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialAssignState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -33,4 +33,4 @@ public override Task Abort() // cannot be aborted, but should also not throw an error return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialState.cs index 144065ffae..33aab2e61a 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InitialState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -23,4 +23,4 @@ public override async Task Assign() await NextStateAsync(StateInitialAssign); Context.HandleAssign(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignFailedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignFailedState.cs index ec97d93ad7..10a4c67415 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignFailedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignFailedState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignState.cs index 4150635ca7..962b0c27d2 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedAssignState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -26,4 +26,4 @@ public override Task Resume() { return NextStateAsync(StateInterrupted); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedState.cs index 59e40f33b0..edf02eacbd 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptedState.cs @@ -75,4 +75,4 @@ public override Task Resume() { return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptingState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptingState.cs index ec96b26a7b..a06d4fde0e 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptingState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/InterruptingState.cs @@ -59,7 +59,9 @@ public override async Task Report(OperationReport report) public override async Task JobsUpdated(JobStateChangedEventArgs args) { if (args.CurrentState < JobClassification.Completed) + { return; + } if (Context.Operation.Jobs.All(j => j.Classification == JobClassification.Completed)) { @@ -86,4 +88,4 @@ public override async Task Resume() await Context.HandleInterrupted(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/OperationDataStateBase.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/OperationDataStateBase.cs index bd6474b3ea..b10cd502d9 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/OperationDataStateBase.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/OperationDataStateBase.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; using Moryx.StateMachines; using Moryx.Users; @@ -86,22 +85,44 @@ public OperationStateClassification GetFullClassification() // TODO: This overrides the base classification, rework classification in next major. GitHub issue: #1066. if (IsFailed) + { classification = OperationStateClassification.Failed; + } + if (IsAssigning) + { classification = OperationStateClassification.Assigning; + } if (CanAssign && Context.AssignState.HasFlag(OperationAssignState.Changed)) + { classification |= OperationStateClassification.CanReload; + } + if (CanBegin) + { classification |= OperationStateClassification.CanBegin; + } + if (CanInterrupt) + { classification |= OperationStateClassification.CanInterrupt; + } + if (CanPartialReport || CanFinalReport) + { classification |= OperationStateClassification.CanReport; + } + if (CanAdvice) + { classification |= OperationStateClassification.CanAdvice; + } + if (IsAmountReached) + { classification |= OperationStateClassification.IsAmountReached; + } return classification; } diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignFailedState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignFailedState.cs index fcc33fcb50..d7eb1ae624 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignFailedState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignFailedState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignState.cs index 7d22d86c87..b7d8c3d58d 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyAssignState.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Orders.Management.Properties; using System.ComponentModel.DataAnnotations; +using Moryx.Orders.Management.Properties; namespace Moryx.Orders.Management; @@ -32,4 +32,4 @@ public override Task Abort() // Cannot abort here return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyState.cs index ff8fb382d0..7c678a7ffe 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/ReadyState.cs @@ -80,4 +80,4 @@ public override async Task Assign() await NextStateAsync(StateReadyAssign); Context.HandleReassign(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationData/States/RunningState.cs b/src/Moryx.Orders.Management/Implementation/OperationData/States/RunningState.cs index 66711dc6d8..a2b830001c 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationData/States/RunningState.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationData/States/RunningState.cs @@ -101,4 +101,4 @@ private async Task EvaluateJobs() await Context.DispatchJob(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationManager/IOperationManager.cs b/src/Moryx.Orders.Management/Implementation/OperationManager/IOperationManager.cs index 60c6809222..2b82494bd4 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationManager/IOperationManager.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationManager/IOperationManager.cs @@ -100,4 +100,4 @@ public ReportRequestEventArgs(IOperationData operationData, ReportType reportTyp { ReportType = reportType; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OperationManager/OperationManager.cs b/src/Moryx.Orders.Management/Implementation/OperationManager/OperationManager.cs index 0c81a11232..fbb52d4109 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationManager/OperationManager.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationManager/OperationManager.cs @@ -123,13 +123,19 @@ private ReportContext GetReportContext(IOperationData operationData, ReportType var canFinal = operationData.State.CanFinalReport; if (canPartial == false && canFinal == false) + { restrictions.Add(new ReportRestriction(false, false, Strings.OperationManager_NoReportErrorText, RestrictionSeverity.Error)); + } if (!canPartial && canFinal) + { restrictions.Add(new ReportRestriction(false, true, Strings.OperationManager_NoPartialReportErrorText, RestrictionSeverity.Warning)); + } if (canPartial && !canFinal) + { restrictions.Add(new ReportRestriction(true, false, Strings.OperationManager_NoFinalReportErrorText, RestrictionSeverity.Warning)); + } // Collect external restrictions var externalRequest = new ReportRequestEventArgs(operationData, reportType); diff --git a/src/Moryx.Orders.Management/Implementation/OperationStorage.cs b/src/Moryx.Orders.Management/Implementation/OperationStorage.cs index 655aebd4ad..d6b534b664 100644 --- a/src/Moryx.Orders.Management/Implementation/OperationStorage.cs +++ b/src/Moryx.Orders.Management/Implementation/OperationStorage.cs @@ -58,9 +58,15 @@ public static async Task SaveOperation(IUnitOfWork uow, IOperat entity.PlannedStart = ConvertToUtc(operation.PlannedStart); entity.PlannedEnd = ConvertToUtc(operation.PlannedEnd); if (operation.Start != null) + { entity.ActualStart = ConvertToUtc((DateTime)operation.Start); + } + if (operation.End != null) + { entity.ActualEnd = ConvertToUtc((DateTime)operation.End); + } + entity.TargetCycleTime = operation.TargetCycleTime; entity.TargetStock = operation.TargetStock; entity.Unit = operation.Unit; @@ -248,12 +254,14 @@ public static void RemoveOperation(IUnitOfWork uow, IOperationData operationData var entity = operationRepo.Linq.FirstOrDefault(o => o.Identifier.Equals(operationData.Identifier)); if (entity == null) // This operation was not saved before + { return; + } operationRepo.Remove(entity); } - private static DateTime ConvertToUtc(DateTime dateTime, [CallerArgumentExpression(nameof(dateTime))]string member = "") + private static DateTime ConvertToUtc(DateTime dateTime, [CallerArgumentExpression(nameof(dateTime))] string member = "") { switch (dateTime.Kind) { diff --git a/src/Moryx.Orders.Management/Implementation/OrderData/InternalOrder.cs b/src/Moryx.Orders.Management/Implementation/OrderData/InternalOrder.cs index 8a72c53237..f70c105c54 100644 --- a/src/Moryx.Orders.Management/Implementation/OrderData/InternalOrder.cs +++ b/src/Moryx.Orders.Management/Implementation/OrderData/InternalOrder.cs @@ -39,4 +39,4 @@ public InternalOrder() _operations.AddRange(value); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/OrderData/OrderData.cs b/src/Moryx.Orders.Management/Implementation/OrderData/OrderData.cs index 5a4c8e848f..d016e50756 100644 --- a/src/Moryx.Orders.Management/Implementation/OrderData/OrderData.cs +++ b/src/Moryx.Orders.Management/Implementation/OrderData/OrderData.cs @@ -63,4 +63,4 @@ public void RemoveOperation(IOperationData operationData) // Remove mapping of public order operationData.Operation.Order = null; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Pool/IOperationDataPool.cs b/src/Moryx.Orders.Management/Implementation/Pool/IOperationDataPool.cs index c72ce774a3..7f21a325c6 100644 --- a/src/Moryx.Orders.Management/Implementation/Pool/IOperationDataPool.cs +++ b/src/Moryx.Orders.Management/Implementation/Pool/IOperationDataPool.cs @@ -84,4 +84,4 @@ internal interface IOperationDataPool : IAsyncPlugin /// Raised if an operation progress changed /// event EventHandler OperationProgressChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Implementation/Pool/OperationDataPool.cs b/src/Moryx.Orders.Management/Implementation/Pool/OperationDataPool.cs index db11fae7df..a316932925 100644 --- a/src/Moryx.Orders.Management/Implementation/Pool/OperationDataPool.cs +++ b/src/Moryx.Orders.Management/Implementation/Pool/OperationDataPool.cs @@ -46,14 +46,18 @@ public async Task StartAsync(CancellationToken cancellationToken = default) .Where(o => o.State < OperationDataStateBase.CompletedKey).ToArrayAsync(cancellationToken); foreach (var entity in restored) + { await RestoreByEntity(entity); + } _lock.EnterReadLock(); var operations = _operations.ToList(); _lock.ExitReadLock(); foreach (var operationData in operations) + { await operationData.Resume(); + } } public Task StopAsync(CancellationToken cancellationToken = default) @@ -157,7 +161,9 @@ private async Task GetOperationByIdentifier(Func GetOperationByIdentifier(Func Add(OperationCreationContext context, IOperati // If operation is existing and not completed, it can be returned without creating a new one var existingOperation = orderData.Operations.FirstOrDefault(o => o.Number.Equals(context.Number) && o.State.Key < OperationDataStateBase.CompletedKey); if (existingOperation != null) + { return existingOperation; + } // Create new operation var operationData = OperationFactory.Create(_savingContext); diff --git a/src/Moryx.Orders.Management/Model/API/IOperationAdviceEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOperationAdviceEntityRepository.cs index 9b9cdcb94c..3d8bbdbdfd 100644 --- a/src/Moryx.Orders.Management/Model/API/IOperationAdviceEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOperationAdviceEntityRepository.cs @@ -12,4 +12,4 @@ public interface IOperationAdviceEntityRepository : IRepository OperationAdviceEntity Create(string loadingEquipment, int amount); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IOperationEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOperationEntityRepository.cs index 1ff6aa3cf8..88e2ab1d87 100644 --- a/src/Moryx.Orders.Management/Model/API/IOperationEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOperationEntityRepository.cs @@ -11,4 +11,4 @@ public interface IOperationEntityRepository : IRepository OperationEntity Create(string number, int state); OperationEntity Create(Guid identifier, string number, int state, DateTime plannedStart, DateTime plannedEnd); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IOperationJobReferenceEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOperationJobReferenceEntityRepository.cs index 79d1a77f40..ccc61d94f4 100644 --- a/src/Moryx.Orders.Management/Model/API/IOperationJobReferenceEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOperationJobReferenceEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.Orders.Management.Model; public interface IOperationJobReferenceEntityRepository : IRepository { OperationJobReferenceEntity Create(long jobId); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IOperationRecipeReferenceEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOperationRecipeReferenceEntityRepository.cs index 252f14f1d2..44327b4c57 100644 --- a/src/Moryx.Orders.Management/Model/API/IOperationRecipeReferenceEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOperationRecipeReferenceEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.Orders.Management.Model; public interface IOperationRecipeReferenceEntityRepository : IRepository { OperationRecipeReferenceEntity Create(long recipeId); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IOperationReportEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOperationReportEntityRepository.cs index 3cbf66b028..ee505ea3b8 100644 --- a/src/Moryx.Orders.Management/Model/API/IOperationReportEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOperationReportEntityRepository.cs @@ -9,4 +9,4 @@ namespace Moryx.Orders.Management.Model; public interface IOperationReportEntityRepository : IRepository { OperationReportEntity Create(int successCount, int failureCount, DateTime reportedDate); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IOrderEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IOrderEntityRepository.cs index 483fc3f7b0..e025547c3a 100644 --- a/src/Moryx.Orders.Management/Model/API/IOrderEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IOrderEntityRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Orders.Management.Model; public interface IOrderEntityRepository : IRepository { -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/API/IProductPartEntityRepository.cs b/src/Moryx.Orders.Management/Model/API/IProductPartEntityRepository.cs index 51c72dd4d4..2bf65d517a 100644 --- a/src/Moryx.Orders.Management/Model/API/IProductPartEntityRepository.cs +++ b/src/Moryx.Orders.Management/Model/API/IProductPartEntityRepository.cs @@ -12,4 +12,4 @@ public interface IProductPartEntityRepository : IRepository /// Creates instance with all not nullable properties prefilled /// ProductPartEntity Create(string description, string number, double quantity, string unit); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OperationAdviceEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OperationAdviceEntity.cs index 9bb749c464..c01118f50f 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OperationAdviceEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OperationAdviceEntity.cs @@ -23,4 +23,4 @@ public class OperationAdviceEntity : EntityBase public virtual OperationEntity Operation { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OperationEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OperationEntity.cs index 03fb776b3d..3a0ff97d7e 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OperationEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OperationEntity.cs @@ -70,4 +70,4 @@ public OperationEntity() ProductParts = new List(); Advices = new List(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OperationJobReferenceEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OperationJobReferenceEntity.cs index 1525a2bf29..75b549beff 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OperationJobReferenceEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OperationJobReferenceEntity.cs @@ -17,4 +17,4 @@ public class OperationJobReferenceEntity : EntityBase public virtual OperationEntity Operation { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OperationRecipeReferenceEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OperationRecipeReferenceEntity.cs index 0019112d3d..58d79a0476 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OperationRecipeReferenceEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OperationRecipeReferenceEntity.cs @@ -20,4 +20,4 @@ public class OperationRecipeReferenceEntity : EntityBase public virtual OperationEntity Operation { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OperationReportEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OperationReportEntity.cs index 05aa3e71b7..802897514f 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OperationReportEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OperationReportEntity.cs @@ -27,4 +27,4 @@ public class OperationReportEntity : EntityBase public virtual OperationEntity Operation { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/OrderEntity.cs b/src/Moryx.Orders.Management/Model/Entities/OrderEntity.cs index bce3c24289..6f7229302b 100644 --- a/src/Moryx.Orders.Management/Model/Entities/OrderEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/OrderEntity.cs @@ -17,4 +17,4 @@ public class OrderEntity : ModificationTrackedEntityBase public virtual ICollection Operations { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Entities/ProductPartEntity.cs b/src/Moryx.Orders.Management/Model/Entities/ProductPartEntity.cs index 2b1bcdeb07..5053f26ba6 100644 --- a/src/Moryx.Orders.Management/Model/Entities/ProductPartEntity.cs +++ b/src/Moryx.Orders.Management/Model/Entities/ProductPartEntity.cs @@ -25,4 +25,4 @@ public class ProductPartEntity : EntityBase public virtual long OperationId { get; set; } public virtual OperationEntity Operation { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20220825105205_InitialCreate.cs b/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20220825105205_InitialCreate.cs index 0b7b797417..4fd0ff31ca 100644 --- a/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20220825105205_InitialCreate.cs +++ b/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20220825105205_InitialCreate.cs @@ -267,4 +267,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "OrderEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20251030110554_TableNames.cs b/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20251030110554_TableNames.cs index 0561e61ec4..f18f99fbf7 100644 --- a/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20251030110554_TableNames.cs +++ b/src/Moryx.Orders.Management/Model/Migrations/Npgsql/20251030110554_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -713,4 +713,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20230215153734_InitialCreate.cs b/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20230215153734_InitialCreate.cs index caafaa0dab..cfd3b87705 100644 --- a/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20230215153734_InitialCreate.cs +++ b/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20230215153734_InitialCreate.cs @@ -268,4 +268,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "OrderEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20251030110420_TableNames.cs b/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20251030110420_TableNames.cs index 8539fbf48b..33c45f32da 100644 --- a/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20251030110420_TableNames.cs +++ b/src/Moryx.Orders.Management/Model/Migrations/Sqlite/20251030110420_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -507,4 +507,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/NpgsqlOrdersContext.cs b/src/Moryx.Orders.Management/Model/NpgsqlOrdersContext.cs index b962095b2c..2be7554252 100644 --- a/src/Moryx.Orders.Management/Model/NpgsqlOrdersContext.cs +++ b/src/Moryx.Orders.Management/Model/NpgsqlOrdersContext.cs @@ -21,4 +21,4 @@ public NpgsqlOrdersContext() public NpgsqlOrdersContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/OrdersContext.cs b/src/Moryx.Orders.Management/Model/OrdersContext.cs index 5debf127c0..682e38585f 100644 --- a/src/Moryx.Orders.Management/Model/OrdersContext.cs +++ b/src/Moryx.Orders.Management/Model/OrdersContext.cs @@ -46,4 +46,4 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) optionsBuilder.UseLazyLoadingProxies(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/Model/SqliteOrdersContext.cs b/src/Moryx.Orders.Management/Model/SqliteOrdersContext.cs index 941521e67b..9f8214b45b 100644 --- a/src/Moryx.Orders.Management/Model/SqliteOrdersContext.cs +++ b/src/Moryx.Orders.Management/Model/SqliteOrdersContext.cs @@ -21,4 +21,4 @@ public SqliteOrdersContext() public SqliteOrdersContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/ComponentOrchestration.cs b/src/Moryx.Orders.Management/ModuleController/ComponentOrchestration.cs index 9c417aabf3..a6938bd8f0 100644 --- a/src/Moryx.Orders.Management/ModuleController/ComponentOrchestration.cs +++ b/src/Moryx.Orders.Management/ModuleController/ComponentOrchestration.cs @@ -99,4 +99,4 @@ public async Task StopAsync(CancellationToken cancellationToken = default) // --Stop pool await OperationDataPool.StopAsync(cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/Config/AdviceConfig.cs b/src/Moryx.Orders.Management/ModuleController/Config/AdviceConfig.cs index c1440b6c44..d16542674e 100644 --- a/src/Moryx.Orders.Management/ModuleController/Config/AdviceConfig.cs +++ b/src/Moryx.Orders.Management/ModuleController/Config/AdviceConfig.cs @@ -26,4 +26,4 @@ public class AdviceConfig /// [DataMember, Description("Indicates if the configured executor should be used for order advices")] public bool UseAdviceExecutorForOrderAdvice { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/Config/UsersConfig.cs b/src/Moryx.Orders.Management/ModuleController/Config/UsersConfig.cs index 40fa97d575..e41b634a0a 100644 --- a/src/Moryx.Orders.Management/ModuleController/Config/UsersConfig.cs +++ b/src/Moryx.Orders.Management/ModuleController/Config/UsersConfig.cs @@ -23,4 +23,4 @@ public class UsersConfig /// [DataMember, Description("Ignores sign-in status of a user attached to actions")] public bool IgnoreUserStatus { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/ModuleConfig.cs b/src/Moryx.Orders.Management/ModuleController/ModuleConfig.cs index 2a415424fd..37d7b458c9 100644 --- a/src/Moryx.Orders.Management/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Orders.Management/ModuleController/ModuleConfig.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel; -using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; using Moryx.Configuration; using Moryx.Orders.Advice; @@ -138,4 +137,4 @@ public ModuleConfig() /// [DataMember, Description("Configuration of notifications")] public OperationNotificationConfig Notifications { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/ModuleConsole.cs b/src/Moryx.Orders.Management/ModuleController/ModuleConsole.cs index 21bdb1dad8..aa41309be1 100644 --- a/src/Moryx.Orders.Management/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Orders.Management/ModuleController/ModuleConsole.cs @@ -46,4 +46,4 @@ public string AbortOperation(string orderNumber, string operationNumber) return "ok"; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders.Management/ModuleController/ModuleController.cs b/src/Moryx.Orders.Management/ModuleController/ModuleController.cs index 3f7e5a28d8..1023df4b20 100644 --- a/src/Moryx.Orders.Management/ModuleController/ModuleController.cs +++ b/src/Moryx.Orders.Management/ModuleController/ModuleController.cs @@ -1,19 +1,19 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; +using Microsoft.Extensions.Logging; using Moryx.AbstractionLayer.Products; +using Moryx.Configuration; +using Moryx.Container; using Moryx.ControlSystem.Jobs; -using Moryx.Notifications; -using Moryx.Runtime.Modules; -using System.ComponentModel; using Moryx.Model; +using Moryx.Notifications; using Moryx.Orders.Advice; using Moryx.Orders.Assignment; using Moryx.Orders.Dispatcher; +using Moryx.Runtime.Modules; using Moryx.Users; -using Moryx.Container; -using Moryx.Configuration; -using Microsoft.Extensions.Logging; namespace Moryx.Orders.Management; @@ -103,7 +103,9 @@ protected override Task OnInitializeAsync(CancellationToken cancellationToken) protected override async Task OnStartAsync(CancellationToken cancellationToken) { if (Config.Users.UserRequired && UserManagement is NullUserManagement) + { throw new InvalidOperationException("UserRequired configured but there is no UserManagement module available."); + } await Container.Resolve().StartAsync(cancellationToken); diff --git a/src/Moryx.Orders/Advice/AdviceExecutorConfig.cs b/src/Moryx.Orders/Advice/AdviceExecutorConfig.cs index 7abfdf8890..c3e7eecabb 100644 --- a/src/Moryx.Orders/Advice/AdviceExecutorConfig.cs +++ b/src/Moryx.Orders/Advice/AdviceExecutorConfig.cs @@ -17,4 +17,4 @@ public class AdviceExecutorConfig : IPluginConfig [DataMember, Description("PluginName of the advice executor")] [PluginNameSelector(typeof(IAdviceExecutor))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Advice/AdviceResult.cs b/src/Moryx.Orders/Advice/AdviceResult.cs index bd660a8e80..aacacf73a7 100644 --- a/src/Moryx.Orders/Advice/AdviceResult.cs +++ b/src/Moryx.Orders/Advice/AdviceResult.cs @@ -48,4 +48,4 @@ public AdviceResult(OperationAdvice advice, int error) : this(advice) /// If success or error a message can be attached /// public string Message { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Advice/IAdviceExecutor.cs b/src/Moryx.Orders/Advice/IAdviceExecutor.cs index 78a358b039..b7d82a2087 100644 --- a/src/Moryx.Orders/Advice/IAdviceExecutor.cs +++ b/src/Moryx.Orders/Advice/IAdviceExecutor.cs @@ -25,4 +25,4 @@ public interface IAdviceExecutor : IAsyncConfiguredPlugin /// Pick part advice information /// The token to monitor for cancellation requests. The default value is None. Task AdviceAsync(Operation operation, PickPartAdvice advice, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Documents/DocumentLoaderConfig.cs b/src/Moryx.Orders/Assignment/Documents/DocumentLoaderConfig.cs index 9fc6a5d0d3..dc582f073b 100644 --- a/src/Moryx.Orders/Assignment/Documents/DocumentLoaderConfig.cs +++ b/src/Moryx.Orders/Assignment/Documents/DocumentLoaderConfig.cs @@ -16,4 +16,4 @@ public class DocumentLoaderConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IDocumentLoader))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Documents/IDocumentLoader.cs b/src/Moryx.Orders/Assignment/Documents/IDocumentLoader.cs index aaceaedc4b..79211f5e67 100644 --- a/src/Moryx.Orders/Assignment/Documents/IDocumentLoader.cs +++ b/src/Moryx.Orders/Assignment/Documents/IDocumentLoader.cs @@ -15,4 +15,4 @@ public interface IDocumentLoader : IAsyncConfiguredPlugin /// Load document information for the given operation /// Task> LoadAsync(Operation operation, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Parts/IPartsAssignment.cs b/src/Moryx.Orders/Assignment/Parts/IPartsAssignment.cs index 8b292a8fb1..91f8505bc7 100644 --- a/src/Moryx.Orders/Assignment/Parts/IPartsAssignment.cs +++ b/src/Moryx.Orders/Assignment/Parts/IPartsAssignment.cs @@ -14,4 +14,4 @@ public interface IPartsAssignment : IAsyncConfiguredPlugin Task> LoadPartsAsync(Operation operation, IOperationLogger operationLogger, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Parts/ProductAssignmentConfig.cs b/src/Moryx.Orders/Assignment/Parts/ProductAssignmentConfig.cs index 9c32d77abd..3f21baebd1 100644 --- a/src/Moryx.Orders/Assignment/Parts/ProductAssignmentConfig.cs +++ b/src/Moryx.Orders/Assignment/Parts/ProductAssignmentConfig.cs @@ -17,4 +17,4 @@ public class PartsAssignmentConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IPartsAssignment))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Products/IProductAssignment.cs b/src/Moryx.Orders/Assignment/Products/IProductAssignment.cs index 165f5ad967..f9245fad3f 100644 --- a/src/Moryx.Orders/Assignment/Products/IProductAssignment.cs +++ b/src/Moryx.Orders/Assignment/Products/IProductAssignment.cs @@ -16,4 +16,4 @@ public interface IProductAssignment : IAsyncConfiguredPlugin /// Task SelectProductAsync(Operation operation, IOperationLogger operationLogger, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Products/ProductAssignmentBase.cs b/src/Moryx.Orders/Assignment/Products/ProductAssignmentBase.cs index c1b2cd1213..b8a053e853 100644 --- a/src/Moryx.Orders/Assignment/Products/ProductAssignmentBase.cs +++ b/src/Moryx.Orders/Assignment/Products/ProductAssignmentBase.cs @@ -59,4 +59,4 @@ public virtual Task StopAsync(CancellationToken cancellationToken = default) /// public abstract Task SelectProductAsync(Operation operation, IOperationLogger operationLogger, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Products/ProductAssignmentConfig.cs b/src/Moryx.Orders/Assignment/Products/ProductAssignmentConfig.cs index 88de292ad4..52e57a33a5 100644 --- a/src/Moryx.Orders/Assignment/Products/ProductAssignmentConfig.cs +++ b/src/Moryx.Orders/Assignment/Products/ProductAssignmentConfig.cs @@ -17,4 +17,4 @@ public class ProductAssignmentConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IProductAssignment))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Recipes/IRecipeAssignment.cs b/src/Moryx.Orders/Assignment/Recipes/IRecipeAssignment.cs index 8c55d4e138..ba8c350d97 100644 --- a/src/Moryx.Orders/Assignment/Recipes/IRecipeAssignment.cs +++ b/src/Moryx.Orders/Assignment/Recipes/IRecipeAssignment.cs @@ -28,4 +28,4 @@ Task> SelectRecipesAsync(Operation operation, IOpe /// Task ProcessRecipeAsync(IProductRecipe clone, Operation operation, IOperationLogger operationLogger, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentBase.cs b/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentBase.cs index 9e7413a0ac..e0ed1a0e28 100644 --- a/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentBase.cs +++ b/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentBase.cs @@ -55,7 +55,9 @@ public virtual async Task> PossibleRecipesAsync(Pr { var product = await ProductManagement.LoadTypeAsync(identity, cancellationToken); if (product == null) + { return Array.Empty(); + } var recipes = await ProductManagement.LoadRecipesAsync(product, RecipeClassification.Default | RecipeClassification.Alternative, cancellationToken); return recipes; @@ -84,4 +86,4 @@ protected async Task LoadDefaultRecipeAsync(ProductType sourcePr return defaultRecipe; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentConfig.cs b/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentConfig.cs index a2c08651d0..914de2a82d 100644 --- a/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentConfig.cs +++ b/src/Moryx.Orders/Assignment/Recipes/RecipeAssignmentConfig.cs @@ -16,4 +16,4 @@ public class RecipeAssignmentConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IRecipeAssignment))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Validation/IOperationValidation.cs b/src/Moryx.Orders/Assignment/Validation/IOperationValidation.cs index ba46562d51..ab5b63a949 100644 --- a/src/Moryx.Orders/Assignment/Validation/IOperationValidation.cs +++ b/src/Moryx.Orders/Assignment/Validation/IOperationValidation.cs @@ -19,4 +19,4 @@ public interface IOperationValidation : IAsyncConfiguredPlugin Task ValidateCreationContextAsync(OrderCreationContext orderContext, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Assignment/Validation/OperationValidationConfig.cs b/src/Moryx.Orders/Assignment/Validation/OperationValidationConfig.cs index 893a78b0ac..e740173cb9 100644 --- a/src/Moryx.Orders/Assignment/Validation/OperationValidationConfig.cs +++ b/src/Moryx.Orders/Assignment/Validation/OperationValidationConfig.cs @@ -17,4 +17,4 @@ public class OperationValidationConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IOperationValidation))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/DispatchContext.cs b/src/Moryx.Orders/DispatchContext.cs index 8bcfff6ab5..68d7bf61a8 100644 --- a/src/Moryx.Orders/DispatchContext.cs +++ b/src/Moryx.Orders/DispatchContext.cs @@ -28,4 +28,4 @@ public DispatchContext(ProductionRecipe recipe, uint amount) /// The amount which should be dispatched /// public uint Amount { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Dispatcher/IOperationDispatcher.cs b/src/Moryx.Orders/Dispatcher/IOperationDispatcher.cs index 5b6e09ee14..4d3b3b6092 100644 --- a/src/Moryx.Orders/Dispatcher/IOperationDispatcher.cs +++ b/src/Moryx.Orders/Dispatcher/IOperationDispatcher.cs @@ -36,4 +36,4 @@ public interface IOperationDispatcher : IAsyncConfiguredPlugin event EventHandler JobsDispatched; -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Dispatcher/JobDispatchedEventArgs.cs b/src/Moryx.Orders/Dispatcher/JobDispatchedEventArgs.cs index eb08695101..486b7f790c 100644 --- a/src/Moryx.Orders/Dispatcher/JobDispatchedEventArgs.cs +++ b/src/Moryx.Orders/Dispatcher/JobDispatchedEventArgs.cs @@ -28,4 +28,4 @@ public JobDispatchedEventArgs(Operation operation, IReadOnlyList jobs) Operation = operation; Jobs = jobs; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Dispatcher/OperationDispatcherBase.cs b/src/Moryx.Orders/Dispatcher/OperationDispatcherBase.cs index 9b0c9e7bcf..92302a99d0 100644 --- a/src/Moryx.Orders/Dispatcher/OperationDispatcherBase.cs +++ b/src/Moryx.Orders/Dispatcher/OperationDispatcherBase.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.ControlSystem.Jobs; -using Moryx.Threading; namespace Moryx.Orders.Dispatcher; @@ -87,4 +86,4 @@ protected async Task AddJobsAsync(Operation operation, JobCreationContext contex public abstract class OperationDispatcherBase : OperationDispatcherBase { -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Dispatcher/OperationDispatcherConfig.cs b/src/Moryx.Orders/Dispatcher/OperationDispatcherConfig.cs index 7ce5192aec..a5a644e457 100644 --- a/src/Moryx.Orders/Dispatcher/OperationDispatcherConfig.cs +++ b/src/Moryx.Orders/Dispatcher/OperationDispatcherConfig.cs @@ -17,4 +17,4 @@ public class OperationDispatcherConfig : IPluginConfig [DataMember] [PluginNameSelector(typeof(IOperationDispatcher))] public virtual string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Documents/Document.cs b/src/Moryx.Orders/Documents/Document.cs index b489101e6e..3943be6a03 100644 --- a/src/Moryx.Orders/Documents/Document.cs +++ b/src/Moryx.Orders/Documents/Document.cs @@ -72,4 +72,4 @@ protected Document(string number, short revision) /// Returns the stream to get the document file /// public abstract Stream GetStream(); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Documents/FileSystemDocument.cs b/src/Moryx.Orders/Documents/FileSystemDocument.cs index 0cb4a26d65..3c72fdec49 100644 --- a/src/Moryx.Orders/Documents/FileSystemDocument.cs +++ b/src/Moryx.Orders/Documents/FileSystemDocument.cs @@ -37,4 +37,4 @@ public override Stream GetStream() { return new FileStream(Path, FileMode.Open); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Documents/WebDocument.cs b/src/Moryx.Orders/Documents/WebDocument.cs index e0120a5497..0bd0a3694c 100644 --- a/src/Moryx.Orders/Documents/WebDocument.cs +++ b/src/Moryx.Orders/Documents/WebDocument.cs @@ -42,4 +42,4 @@ public override Stream GetStream() return response.Content.ReadAsStreamAsync().Result; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Facade/IOrderManagement.cs b/src/Moryx.Orders/Facade/IOrderManagement.cs index 285ededb20..b0e2b5b704 100644 --- a/src/Moryx.Orders/Facade/IOrderManagement.cs +++ b/src/Moryx.Orders/Facade/IOrderManagement.cs @@ -160,4 +160,4 @@ public interface IOrderManagement /// Returns a set of recipes this OrderManagement can assign to an Operation corresponding to the . /// Task> GetAssignableRecipesAsync(ProductIdentity identity, CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Facade/OperationActionRequestEventArgs.cs b/src/Moryx.Orders/Facade/OperationActionRequestEventArgs.cs index 447090346a..65258e4edc 100644 --- a/src/Moryx.Orders/Facade/OperationActionRequestEventArgs.cs +++ b/src/Moryx.Orders/Facade/OperationActionRequestEventArgs.cs @@ -31,4 +31,4 @@ public void AddRestriction(TRestrictionType restriction) { _restrictions.Add(restriction); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Facade/OperationAdviceEventArgs.cs b/src/Moryx.Orders/Facade/OperationAdviceEventArgs.cs index 175d077dfe..1125be553f 100644 --- a/src/Moryx.Orders/Facade/OperationAdviceEventArgs.cs +++ b/src/Moryx.Orders/Facade/OperationAdviceEventArgs.cs @@ -20,4 +20,4 @@ public OperationAdviceEventArgs(Operation operation, OperationAdvice advice) : b { Advice = advice; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Facade/OperationBeginRequestEventArgs.cs b/src/Moryx.Orders/Facade/OperationBeginRequestEventArgs.cs index 112e6cbafb..9bfe694afb 100644 --- a/src/Moryx.Orders/Facade/OperationBeginRequestEventArgs.cs +++ b/src/Moryx.Orders/Facade/OperationBeginRequestEventArgs.cs @@ -16,4 +16,4 @@ public class OperationBeginRequestEventArgs : OperationActionRequestEventArgs public ICollection MaterialParameters { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/OperationExtensions.cs b/src/Moryx.Orders/OperationExtensions.cs index 4c5130680f..24067fabb4 100644 --- a/src/Moryx.Orders/OperationExtensions.cs +++ b/src/Moryx.Orders/OperationExtensions.cs @@ -26,4 +26,4 @@ public int ReportedFailureCount() return operation.Reports.Sum(r => r.FailureCount); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/OperationInfo.cs b/src/Moryx.Orders/OperationInfo.cs index ae51ac97ac..2d5acd09cc 100644 --- a/src/Moryx.Orders/OperationInfo.cs +++ b/src/Moryx.Orders/OperationInfo.cs @@ -17,4 +17,4 @@ public abstract class OperationInfo /// Current failure count of the operation /// public int ScrapCount { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/PartClassification.cs b/src/Moryx.Orders/PartClassification.cs index 30b83e26d1..ecbec4795b 100644 --- a/src/Moryx.Orders/PartClassification.cs +++ b/src/Moryx.Orders/PartClassification.cs @@ -11,4 +11,4 @@ public enum PartClassification CarrierMaterial, ScrapMaterial, BranchMaterial, -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/PartCreationContext.cs b/src/Moryx.Orders/PartCreationContext.cs index 6aa1cbf7f0..d5b148ce37 100644 --- a/src/Moryx.Orders/PartCreationContext.cs +++ b/src/Moryx.Orders/PartCreationContext.cs @@ -37,4 +37,4 @@ public class PartCreationContext /// Classification of this part /// public PartClassification Classification { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/ProductPart.cs b/src/Moryx.Orders/ProductPart.cs index 5ded1a0651..7855031201 100644 --- a/src/Moryx.Orders/ProductPart.cs +++ b/src/Moryx.Orders/ProductPart.cs @@ -47,4 +47,4 @@ protected override ProductInstance Instantiate() { throw new NotSupportedException("Creating an instance of this product is not supported."); } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/ReportContext.cs b/src/Moryx.Orders/ReportContext.cs index 213cd2b69d..ff76ac3b37 100644 --- a/src/Moryx.Orders/ReportContext.cs +++ b/src/Moryx.Orders/ReportContext.cs @@ -44,4 +44,4 @@ public class ReportContext : OperationInfo /// Reasons why a report is not possible /// public RestrictionDescription[] Restrictions { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/ReportType.cs b/src/Moryx.Orders/ReportType.cs index 1688c0131d..64bf2f5304 100644 --- a/src/Moryx.Orders/ReportType.cs +++ b/src/Moryx.Orders/ReportType.cs @@ -7,4 +7,4 @@ public enum ReportType { Interrupt, Report -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Restrictions/BeginRestriction.cs b/src/Moryx.Orders/Restrictions/BeginRestriction.cs index 8d1fc70ef2..a2d66124f4 100644 --- a/src/Moryx.Orders/Restrictions/BeginRestriction.cs +++ b/src/Moryx.Orders/Restrictions/BeginRestriction.cs @@ -76,4 +76,4 @@ public BeginRestriction(bool canBegin, bool canReduce, int minimalTargetAmount, /// Description of the Result why the rule was not complied /// public RestrictionDescription Description { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Restrictions/IOperationRestriction.cs b/src/Moryx.Orders/Restrictions/IOperationRestriction.cs index 92fa0dc545..26597834d3 100644 --- a/src/Moryx.Orders/Restrictions/IOperationRestriction.cs +++ b/src/Moryx.Orders/Restrictions/IOperationRestriction.cs @@ -6,4 +6,4 @@ namespace Moryx.Orders.Restrictions; public interface IOperationRestriction { RestrictionDescription Description { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Restrictions/ReportRestriction.cs b/src/Moryx.Orders/Restrictions/ReportRestriction.cs index 8a8a02b685..ece119625e 100644 --- a/src/Moryx.Orders/Restrictions/ReportRestriction.cs +++ b/src/Moryx.Orders/Restrictions/ReportRestriction.cs @@ -40,4 +40,4 @@ public ReportRestriction(bool canPartialReport, bool canFinalReport, string text /// Description of the results about rules which are not complied /// public RestrictionDescription Description { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Restrictions/RestrictionDescription.cs b/src/Moryx.Orders/Restrictions/RestrictionDescription.cs index 4f451d35c1..52679205ec 100644 --- a/src/Moryx.Orders/Restrictions/RestrictionDescription.cs +++ b/src/Moryx.Orders/Restrictions/RestrictionDescription.cs @@ -26,4 +26,4 @@ public RestrictionDescription(string text, RestrictionSeverity severity) /// Severity of the result /// public RestrictionSeverity Severity { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/Restrictions/RestrictionSeverity.cs b/src/Moryx.Orders/Restrictions/RestrictionSeverity.cs index fc449bb32b..fc6671e796 100644 --- a/src/Moryx.Orders/Restrictions/RestrictionSeverity.cs +++ b/src/Moryx.Orders/Restrictions/RestrictionSeverity.cs @@ -22,4 +22,4 @@ public enum RestrictionSeverity /// A result which is a problem and must be avoided /// Error -} \ No newline at end of file +} diff --git a/src/Moryx.Orders/StagingIndicator.cs b/src/Moryx.Orders/StagingIndicator.cs index ad96d274ab..16139242a3 100644 --- a/src/Moryx.Orders/StagingIndicator.cs +++ b/src/Moryx.Orders/StagingIndicator.cs @@ -44,4 +44,4 @@ public enum StagingIndicator /// These materials are staged directly in WM using a production material request /// EwmStaging = 5 -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConfig.cs b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConfig.cs index d94fba0745..c09652e151 100644 --- a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConfig.cs @@ -33,4 +33,4 @@ public ModuleConfig() [DataMember] [Description("The data bound to this Measurand is gathered on any change of a notification within the system.")] public List NotificationBindings { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConsole.cs b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConsole.cs index e4dd61bbf4..554d250612 100644 --- a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleConsole.cs @@ -6,9 +6,9 @@ namespace Moryx.ProcessData.Adapter.NotificationPublisher; [ServerModuleConsole] -internal class ModuleConsole : IServerModuleConsole +internal sealed class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleController.cs b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleController.cs index 67861567fe..070b9643b9 100644 --- a/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleController.cs +++ b/src/Moryx.ProcessData.Adapter.NotificationPublisher/ModuleController/ModuleController.cs @@ -58,4 +58,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) Container.Resolve().Stop(); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationBindingResolverFactory.cs b/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationBindingResolverFactory.cs index 10e11417f0..f85db30d50 100644 --- a/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationBindingResolverFactory.cs +++ b/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationBindingResolverFactory.cs @@ -5,7 +5,7 @@ namespace Moryx.ProcessData.Adapter.NotificationPublisher; -internal class NotificationBindingResolverFactory : BindingResolverFactory +internal sealed class NotificationBindingResolverFactory : BindingResolverFactory { protected override IBindingResolverChain CreateBaseResolver(string baseKey) { @@ -17,4 +17,4 @@ protected override IBindingResolverChain CreateBaseResolver(string baseKey) return null; } } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationPublisherAdapter.cs b/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationPublisherAdapter.cs index 1905ad8e5a..e12d0966f0 100644 --- a/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationPublisherAdapter.cs +++ b/src/Moryx.ProcessData.Adapter.NotificationPublisher/NotificationPublisherAdapter.cs @@ -9,7 +9,7 @@ namespace Moryx.ProcessData.Adapter.NotificationPublisher; [Plugin(LifeCycle.Singleton)] -internal class NotificationPublisherAdapter : IPlugin +internal sealed class NotificationPublisherAdapter : IPlugin { private const string MeasurementPrefix = "notifications_"; private MeasurementBindingProcessor _notificationBindingProcessor; @@ -49,7 +49,9 @@ private void OnNotificationAcknowledged(object sender, Notification notification var duration = notification.Acknowledged - notification.Created; if (duration.HasValue) + { measurement.Add(new DataField("duration", duration.Value)); + } measurement.Add(new DataTag("severity", notification.Severity.ToString())); measurement.Add(new DataTag("type", notification.GetType().Name)); diff --git a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConfig.cs b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConfig.cs index 9960b427e9..23f4ce2a50 100644 --- a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConfig.cs @@ -19,4 +19,4 @@ public class ModuleConfig : ConfigBase [DataMember, Description("Interval for reporting progress changes")] [DefaultValue(10000)] public int ReportInterval { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConsole.cs b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConsole.cs index 006600676f..bce6dbda4e 100644 --- a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleConsole.cs @@ -6,9 +6,9 @@ namespace Moryx.ProcessData.Adapter.OrderManagement; [ServerModuleConsole] -internal class ModuleConsole : IServerModuleConsole +internal sealed class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleController.cs b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleController.cs index 9ba7308fe9..73329b6b3c 100644 --- a/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleController.cs +++ b/src/Moryx.ProcessData.Adapter.OrderManagement/ModuleController/ModuleController.cs @@ -58,4 +58,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) Container.Resolve().Stop(); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.OrderManagement/OrderManagementAdapter.cs b/src/Moryx.ProcessData.Adapter.OrderManagement/OrderManagementAdapter.cs index a499114f25..b595294ee3 100644 --- a/src/Moryx.ProcessData.Adapter.OrderManagement/OrderManagementAdapter.cs +++ b/src/Moryx.ProcessData.Adapter.OrderManagement/OrderManagementAdapter.cs @@ -11,7 +11,7 @@ namespace Moryx.ProcessData.Adapter.OrderManagement; [Plugin(LifeCycle.Singleton)] -internal class OrderManagementAdapter : IPlugin +internal sealed class OrderManagementAdapter : IPlugin { private const string MeasurementPrefix = "orders_"; @@ -60,13 +60,17 @@ private void OnOperationProgressChanged(object sender, OperationChangedEventArgs // If operation is currently in queue, replace facade object var existing = _pendingProgressChanges.FirstOrDefault(o => o.Identifier == operation.Identifier); if (existing != null) + { _pendingProgressChanges.Remove(existing); + } _pendingProgressChanges.Add(operation); } if (_timerId == 0) + { _timerId = ParallelOperations.ScheduleExecution(ReportProgressMeasurement, ModuleConfig.ReportInterval, -1); + } } private void ReportProgressMeasurement() diff --git a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConfig.cs b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConfig.cs index 5a3bed791b..90ca7feaee 100644 --- a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConfig.cs @@ -50,4 +50,4 @@ public ModuleConfig() [DataMember] [Description("The data bound to this Measurand is gathered on any change of a activity within the system.")] public List ActivityBindings { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConsole.cs b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConsole.cs index e928231542..f856150a16 100644 --- a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleConsole.cs @@ -6,9 +6,9 @@ namespace Moryx.ProcessData.Adapter.ProcessEngine; [ServerModuleConsole] -internal class ModuleConsole : IServerModuleConsole +internal sealed class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleController.cs b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleController.cs index 7ba737816d..377c46cf05 100644 --- a/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleController.cs +++ b/src/Moryx.ProcessData.Adapter.ProcessEngine/ModuleController/ModuleController.cs @@ -74,4 +74,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) Container.Resolve().Stop(); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ProcessEngine/ProcessEngineAdapter.cs b/src/Moryx.ProcessData.Adapter.ProcessEngine/ProcessEngineAdapter.cs index e6e0ab2130..616d578660 100644 --- a/src/Moryx.ProcessData.Adapter.ProcessEngine/ProcessEngineAdapter.cs +++ b/src/Moryx.ProcessData.Adapter.ProcessEngine/ProcessEngineAdapter.cs @@ -14,7 +14,7 @@ namespace Moryx.ProcessData.Adapter.ProcessEngine; [Plugin(LifeCycle.Singleton)] -internal class ProcessEngineAdapter : IPlugin +internal sealed class ProcessEngineAdapter : IPlugin { private const string MeasurementPrefix = "processEngine_"; @@ -81,7 +81,9 @@ private void OnProcessUpdated(object sender, ProcessUpdatedEventArgs e) { var cycleTime = lastActivity.Tracing.Completed - firstActivity.Tracing.Started; if (cycleTime.HasValue) + { measurement.Add(new DataField("cycleTime", cycleTime.Value)); + } } _processBindingProcessor.Apply(measurement, process); diff --git a/src/Moryx.ProcessData.Adapter.ProcessEngine/ResourceActivityBindingResolverFactory.cs b/src/Moryx.ProcessData.Adapter.ProcessEngine/ResourceActivityBindingResolverFactory.cs index 8032fc0d0a..d5eccc7a2f 100644 --- a/src/Moryx.ProcessData.Adapter.ProcessEngine/ResourceActivityBindingResolverFactory.cs +++ b/src/Moryx.ProcessData.Adapter.ProcessEngine/ResourceActivityBindingResolverFactory.cs @@ -1,14 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Reflection; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Resources; using Moryx.Bindings; namespace Moryx.ProcessData.Adapter.ProcessEngine; -internal class ResourceActivityBindingResolverFactory : ActivityBindingResolverFactory +internal sealed class ResourceActivityBindingResolverFactory : ActivityBindingResolverFactory { private readonly IResourceManagement _resourceManagement; @@ -27,7 +26,7 @@ protected override IBindingResolverChain CreateBaseResolver(string baseKey) } } -internal class TracingResourceResolver : BindingResolverBase +internal sealed class TracingResourceResolver : BindingResolverBase { private readonly IResourceManagement _resourceManagement; @@ -40,7 +39,9 @@ protected override object Resolve(object source) { var tracing = ((Activity)source).Tracing.Transform(); if (tracing == null) + { return null; + } // Usage of original resource instead of proxy var resource = _resourceManagement.GetResourcesUnsafe(r => r.Id == tracing.ResourceId) diff --git a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConfig.cs b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConfig.cs index bba147acdc..ebc44c940f 100644 --- a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConfig.cs @@ -12,4 +12,4 @@ namespace Moryx.ProcessData.Adapter.ResourceManagement; [DataContract] public class ModuleConfig : ConfigBase { -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConsole.cs b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConsole.cs index 36c26af2e5..fe07806d45 100644 --- a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleConsole.cs @@ -6,9 +6,9 @@ namespace Moryx.ProcessData.Adapter.ResourceManagement; [ServerModuleConsole] -internal class ModuleConsole : IServerModuleConsole +internal sealed class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleController.cs b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleController.cs index de2262ffeb..d6e05d1fec 100644 --- a/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleController.cs +++ b/src/Moryx.ProcessData.Adapter.ResourceManagement/ModuleController/ModuleController.cs @@ -58,4 +58,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) Container.Resolve().Stop(); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Adapter.ResourceManagement/ResourceManagementAdapter.cs b/src/Moryx.ProcessData.Adapter.ResourceManagement/ResourceManagementAdapter.cs index 8f2e6323fd..101c27236c 100644 --- a/src/Moryx.ProcessData.Adapter.ResourceManagement/ResourceManagementAdapter.cs +++ b/src/Moryx.ProcessData.Adapter.ResourceManagement/ResourceManagementAdapter.cs @@ -8,7 +8,7 @@ namespace Moryx.ProcessData.Adapter.ResourceManagement; [Plugin(LifeCycle.Singleton)] -internal class ResourceManagementAdapter : IPlugin +internal sealed class ResourceManagementAdapter : IPlugin { private readonly ICollection _resources = new List(); @@ -28,7 +28,9 @@ public void Start() var processDataPublishers = ResourceManagement.GetResources().OfType(); foreach (var publisher in processDataPublishers) + { RegisterToResource(publisher); + } } ///

@@ -40,7 +42,9 @@ public void Stop() ResourceManagement.ResourceRemoved -= OnResourceRemoved; foreach (var resource in _resources) + { resource.ProcessDataOccurred -= OnProcessDataOccurred; + } _resources.Clear(); } @@ -48,13 +52,17 @@ public void Stop() private void OnResourceAdded(object sender, IResource addedResource) { if (addedResource is IProcessDataPublisher publisher) + { RegisterToResource(publisher); + } } private void OnResourceRemoved(object sender, IResource addedResource) { if (addedResource is IProcessDataPublisher publisher) + { UnregisterFromResource(publisher); + } } private void RegisterToResource(IProcessDataPublisher publisher) @@ -73,4 +81,4 @@ private void OnProcessDataOccurred(object sender, Measurement measurement) { ProcessDataMonitor.Add(measurement); } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Controllers/ProcessDataController.cs b/src/Moryx.ProcessData.Endpoints/Controllers/ProcessDataController.cs index 07710ef7ca..031ca19e5e 100644 --- a/src/Moryx.ProcessData.Endpoints/Controllers/ProcessDataController.cs +++ b/src/Moryx.ProcessData.Endpoints/Controllers/ProcessDataController.cs @@ -2,10 +2,10 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.AspNetCore.Mvc; -using Moryx.ProcessData.Endpoints.Services; +using Moryx.Configuration; using Moryx.ProcessData.Endpoints.Models; +using Moryx.ProcessData.Endpoints.Services; using Moryx.Runtime.Modules; -using Moryx.Configuration; namespace Moryx.ProcessData.Endpoints.Controllers; @@ -148,4 +148,4 @@ private ActionResult MeasurandNotFound(string name) private ActionResult ListenerNotFound(string name) => NotFound($"Listener with name \"{name}\" not found"); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Models/ConfiguredBindings.cs b/src/Moryx.ProcessData.Endpoints/Models/ConfiguredBindings.cs index 5d79b68533..a3a013230f 100644 --- a/src/Moryx.ProcessData.Endpoints/Models/ConfiguredBindings.cs +++ b/src/Moryx.ProcessData.Endpoints/Models/ConfiguredBindings.cs @@ -11,4 +11,4 @@ public class ConfiguredBindings /// List of all configured bindings for this measurand /// public List Bindings { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Models/ListenersResponse.cs b/src/Moryx.ProcessData.Endpoints/Models/ListenersResponse.cs index 7bcd846b2a..0194f184d8 100644 --- a/src/Moryx.ProcessData.Endpoints/Models/ListenersResponse.cs +++ b/src/Moryx.ProcessData.Endpoints/Models/ListenersResponse.cs @@ -36,4 +36,4 @@ public class ListenerMeasurand /// Indicates if measurand is enabled /// public bool IsEnabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Models/MeasurandBindingsResponse.cs b/src/Moryx.ProcessData.Endpoints/Models/MeasurandBindingsResponse.cs index 678f6b4772..4eeb1245be 100644 --- a/src/Moryx.ProcessData.Endpoints/Models/MeasurandBindingsResponse.cs +++ b/src/Moryx.ProcessData.Endpoints/Models/MeasurandBindingsResponse.cs @@ -9,4 +9,4 @@ public class MeasurandBindings /// List of all available bindings for this measurand /// public List Bindings { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Models/MeasurandResponse.cs b/src/Moryx.ProcessData.Endpoints/Models/MeasurandResponse.cs index b51658744c..6d7e819dc4 100644 --- a/src/Moryx.ProcessData.Endpoints/Models/MeasurandResponse.cs +++ b/src/Moryx.ProcessData.Endpoints/Models/MeasurandResponse.cs @@ -24,4 +24,4 @@ public MeasurandResponse(string name) : base(name) /// Module which is the source of this measurand /// public string Source { get; internal set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Models/NameIdentifierResponse.cs b/src/Moryx.ProcessData.Endpoints/Models/NameIdentifierResponse.cs index 68a8879403..4e206bdd1b 100644 --- a/src/Moryx.ProcessData.Endpoints/Models/NameIdentifierResponse.cs +++ b/src/Moryx.ProcessData.Endpoints/Models/NameIdentifierResponse.cs @@ -12,4 +12,4 @@ internal static class NameIdentifierResponseExtensions { public static NameIdentifierResponse AsNameIdResponse(this string name) => new() { Name = name }; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Services/ConfigurationService.cs b/src/Moryx.ProcessData.Endpoints/Services/ConfigurationService.cs index 3c03d2f8fb..eaa1306754 100644 --- a/src/Moryx.ProcessData.Endpoints/Services/ConfigurationService.cs +++ b/src/Moryx.ProcessData.Endpoints/Services/ConfigurationService.cs @@ -1,6 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Reflection; +using Moryx.AbstractionLayer.Activities; +using Moryx.AbstractionLayer.Processes; using Moryx.Configuration; using Moryx.Modules; using Moryx.Notifications; @@ -8,13 +11,10 @@ using Moryx.ProcessData.Endpoints.Models; using Moryx.Runtime.Modules; using Moryx.Tools; -using System.Reflection; -using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; namespace Moryx.ProcessData.Endpoints.Services; -internal class ConfigurationService : IConfigurationService +internal sealed class ConfigurationService : IConfigurationService { private readonly IModuleManager _moduleManager; private readonly IConfigManager _configManager; @@ -66,12 +66,14 @@ private static List FindMeasurandBindings(ConfigBase config, .FirstOrDefault(p => p.PropertyType == typeof(List) && p.Name == measurandName); if (bindings == null) + { return []; + } return bindings.GetMeasurementBindings(config); } - public List GetAvailableBindings(Type typeInQuestion) + public static List GetAvailableBindings(Type typeInQuestion) => AppDomain.CurrentDomain.GetAssemblies() .SelectMany(domainAssembly => domainAssembly.GetTypes()) .Where(type => typeInQuestion.IsAssignableFrom(type) && !type.IsAbstract) @@ -79,7 +81,7 @@ public List GetAvailableBindings(Type typeInQuestion) .Distinct() .ToList(); - public List ListProperties(Type root, string name, Type baseType) + public static List ListProperties(Type root, string name, Type baseType) { var properties = root.GetRuntimeProperties().ToArray(); if (properties.Length == 0 || root.IsValueType || root == typeof(string)) @@ -126,11 +128,20 @@ private static MeasurandResponse MeasurandFromModuleProperty(IServerModule modul private static string GetGeneratedName(PropertyInfo p) { if (p.Name == "ActivityBindings") + { return "controlSystem_activities"; + } + if (p.Name == "ProcessBindings") + { return "controlSystem_processes"; + } + if (p.Name == "NotificationBindings") + { return "notifications_acknowledged"; + } + return p.Name; } diff --git a/src/Moryx.ProcessData.Endpoints/Services/IConfigurationService.cs b/src/Moryx.ProcessData.Endpoints/Services/IConfigurationService.cs index d578acba08..ef278920be 100644 --- a/src/Moryx.ProcessData.Endpoints/Services/IConfigurationService.cs +++ b/src/Moryx.ProcessData.Endpoints/Services/IConfigurationService.cs @@ -16,4 +16,4 @@ public interface IConfigurationService List GetMeasuarands(); IServerModule GetModule(string moduleName); ConfiguredBindings UpdateMeasuarandBindings(string name, ConfiguredBindings measurandBindings); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Services/IListenerService.cs b/src/Moryx.ProcessData.Endpoints/Services/IListenerService.cs index ec773a0576..cdb3f19a98 100644 --- a/src/Moryx.ProcessData.Endpoints/Services/IListenerService.cs +++ b/src/Moryx.ProcessData.Endpoints/Services/IListenerService.cs @@ -10,4 +10,4 @@ public interface IListenerService Models.Listener GetListener(string name); ListenersResponse GetListeners(); Models.Listener UpdateListener(string name, Models.Listener listenerDto); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Endpoints/Services/ListenerService.cs b/src/Moryx.ProcessData.Endpoints/Services/ListenerService.cs index dac9ebd3f5..035df7485a 100644 --- a/src/Moryx.ProcessData.Endpoints/Services/ListenerService.cs +++ b/src/Moryx.ProcessData.Endpoints/Services/ListenerService.cs @@ -9,7 +9,7 @@ namespace Moryx.ProcessData.Endpoints.Services; -internal class ListenerService : IListenerService +internal sealed class ListenerService : IListenerService { private readonly IModuleManager _moduleManager; private readonly IConfigManager _configManager; @@ -84,7 +84,7 @@ private static List FindListeners(ConfigBase config) .SelectMany(info => (List)info.GetValue(config, null)) .ToList(); - public List GetAvailableBindings(Type typeInQuestion) + public static List GetAvailableBindings(Type typeInQuestion) => AppDomain.CurrentDomain.GetAssemblies() .SelectMany(domainAssembly => domainAssembly.GetTypes()) .Where(type => typeInQuestion.IsAssignableFrom(type) && !type.IsAbstract) @@ -110,4 +110,4 @@ private static ListenerMeasurand ToDto(this MeasurandConfig mc) IsEnabled = mc.IsEnabled, Name = mc.Name, }; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListener.cs b/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListener.cs index 9b8ac15135..3010d3d0b6 100644 --- a/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListener.cs +++ b/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListener.cs @@ -31,7 +31,9 @@ public class InfluxDbListener : ProcessDataListenerBase protected override void OnMeasurandAdded(Measurand measurand) { lock (_pendingPoints) + { _pendingPoints.AddRange(measurand.Measurements.Select(GetPointFromMeasurement)); + } CheckOrStartTimer(); } @@ -40,7 +42,9 @@ protected override void OnMeasurandAdded(Measurand measurand) protected override void OnMeasurementAdded(Measurement measurement) { lock (_pendingPoints) + { _pendingPoints.Add(GetPointFromMeasurement(measurement)); + } CheckOrStartTimer(); } @@ -48,7 +52,9 @@ protected override void OnMeasurementAdded(Measurement measurement) private void CheckOrStartTimer() { if (_timerId == 0) + { _timerId = ParallelOperations.ScheduleExecution(Report, Config.ReportIntervalMs, -1); + } } private void Report() @@ -69,7 +75,9 @@ private async Task Upload(LineProtocolPoint[] points) var payload = new LineProtocolPayload(); foreach (var point in points) + { payload.Add(point); + } var client = new LineProtocolClient(new Uri($"http://{Config.Host}:{Config.Port}"), Config.DatabaseName, Config.Username, Config.Password); try @@ -92,7 +100,9 @@ private async Task Upload(LineProtocolPoint[] points) void AddPointsBackToTheList() { lock (_pendingPoints) + { _pendingPoints.AddRange(points); + } } } @@ -115,4 +125,4 @@ private LineProtocolPoint GetPointFromMeasurement(Measurement measurement) throw; } } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListenerV2.cs b/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListenerV2.cs index 6cff890212..d6a36b1755 100644 --- a/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListenerV2.cs +++ b/src/Moryx.ProcessData.InfluxDbListener/InfluxDbListenerV2.cs @@ -102,7 +102,9 @@ public override void Stop() protected override void OnMeasurandAdded(Measurand measurand) { lock (_pendingPointsLock) + { _pendingPoints.AddRange(measurand.Measurements.Select(GetPointFromMeasurement)); + } StartTimerIfStopped(); } @@ -111,7 +113,9 @@ protected override void OnMeasurandAdded(Measurand measurand) protected override void OnMeasurementAdded(Measurement measurement) { lock (_pendingPointsLock) + { _pendingPoints.Add(GetPointFromMeasurement(measurement)); + } StartTimerIfStopped(); } @@ -138,7 +142,9 @@ private async Task ReportAsync(CancellationToken cancellationToken) } if (points.Length > 0) + { await UploadAsync(points, cancellationToken); + } } private async Task UploadAsync(PointData[] points, CancellationToken cancellationToken) @@ -158,7 +164,9 @@ private async Task UploadAsync(PointData[] points, CancellationToken cancellatio "Remaining retries: {retries}", Config.DatabaseName, points.Length, --_retries); lock (_pendingPointsLock) + { _pendingPoints.AddRange(points); + } if (_retries < 0) { @@ -174,9 +182,15 @@ private PointData GetPointFromMeasurement(Measurement measurement) { var builder = PointData.Builder.Measurement(measurement.Measurand); foreach (var tag in measurement.Tags) + { builder.Tag(tag.Name, tag.Value); + } + foreach (var field in measurement.Fields) + { AddDataToPoint(builder, field.Name, field.Value); + } + builder.Tag("application", Platform.Current.ProductName); builder.Timestamp(measurement.TimeStamp.ToUniversalTime(), WritePrecision.Ms); @@ -253,15 +267,15 @@ private void AddDataToPoint(PointData.Builder point, string prefix, object value } break; case IEnumerable enumerable: - { - var i = 0; - foreach (var elem in enumerable) { - AddDataToPoint(point, $"{prefix}_{i}", elem); - i++; + var i = 0; + foreach (var elem in enumerable) + { + AddDataToPoint(point, $"{prefix}_{i}", elem); + i++; + } + point.Field($"{prefix}_Length", i); } - point.Field($"{prefix}_Length", i); - } break; default: var type = value.GetType(); diff --git a/src/Moryx.ProcessData.Monitor/Facade/ProcessDataMonitorFacade.cs b/src/Moryx.ProcessData.Monitor/Facade/ProcessDataMonitorFacade.cs index c361f2a729..4a8abbd435 100644 --- a/src/Moryx.ProcessData.Monitor/Facade/ProcessDataMonitorFacade.cs +++ b/src/Moryx.ProcessData.Monitor/Facade/ProcessDataMonitorFacade.cs @@ -30,4 +30,4 @@ public void Add(Measurand measurand) ValidateHealthState(); ProcessDataCollector.AddMeasurand(measurand); } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/IProcessDataCollector.cs b/src/Moryx.ProcessData.Monitor/IProcessDataCollector.cs index 1cae8834f6..18f4ba1b2c 100644 --- a/src/Moryx.ProcessData.Monitor/IProcessDataCollector.cs +++ b/src/Moryx.ProcessData.Monitor/IProcessDataCollector.cs @@ -29,4 +29,4 @@ internal interface IProcessDataCollector : IPlugin /// Will be raised if a measurement was added /// event EventHandler MeasurementAdded; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/Listener/IProcessDataListenerFactory.cs b/src/Moryx.ProcessData.Monitor/Listener/IProcessDataListenerFactory.cs index a06e639281..f888f59350 100644 --- a/src/Moryx.ProcessData.Monitor/Listener/IProcessDataListenerFactory.cs +++ b/src/Moryx.ProcessData.Monitor/Listener/IProcessDataListenerFactory.cs @@ -22,4 +22,4 @@ internal interface IProcessDataListenerFactory /// /// void Destroy(IProcessDataListener listener); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/Listener/LogListener.cs b/src/Moryx.ProcessData.Monitor/Listener/LogListener.cs index 1bc546649d..90d04ef2a6 100644 --- a/src/Moryx.ProcessData.Monitor/Listener/LogListener.cs +++ b/src/Moryx.ProcessData.Monitor/Listener/LogListener.cs @@ -31,7 +31,9 @@ protected override void OnMeasurementAdded(Measurement measurement) strBuilder.Append($"{field.Name}: {field}"); if (index < measurement.Fields.Count - 1) + { strBuilder.Append(", "); + } } strBuilder.Append(") Tags ("); @@ -42,10 +44,12 @@ protected override void OnMeasurementAdded(Measurement measurement) strBuilder.Append($"{tag.Name}: {tag.Value}"); if (index < measurement.Tags.Count - 1) + { strBuilder.Append(", "); + } } - strBuilder.Append(")"); + strBuilder.Append(')'); Logger.Log(LogLevel.Trace, strBuilder.ToString()); } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConfig.cs b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConfig.cs index bd9560034b..4e66aa3156 100644 --- a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConfig.cs +++ b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConfig.cs @@ -21,4 +21,4 @@ public class ModuleConfig : ConfigBase [DataMember, PluginConfigs(typeof(IProcessDataListener), true)] [Description("List of listeners for process data events")] public List Listeners { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConsole.cs b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConsole.cs index c491ad26f3..37fbb82dd3 100644 --- a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConsole.cs +++ b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleConsole.cs @@ -8,7 +8,7 @@ namespace Moryx.ProcessData.Monitor; [ServerModuleConsole] internal class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleController.cs b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleController.cs index 4edf23e82a..c388e71462 100644 --- a/src/Moryx.ProcessData.Monitor/ModuleController/ModuleController.cs +++ b/src/Moryx.ProcessData.Monitor/ModuleController/ModuleController.cs @@ -52,4 +52,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) private readonly ProcessDataMonitorFacade _processDataMonitorFacade = new(); IProcessDataMonitor IFacadeContainer.Facade => _processDataMonitorFacade; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/ProcessDataCollector.cs b/src/Moryx.ProcessData.Monitor/ProcessDataCollector.cs index 6823d0b817..5044ca8108 100644 --- a/src/Moryx.ProcessData.Monitor/ProcessDataCollector.cs +++ b/src/Moryx.ProcessData.Monitor/ProcessDataCollector.cs @@ -83,7 +83,9 @@ private void ValidateListeners(string measurandName) { var measurandConfig = listenerConfig.MeasurandConfigs.FirstOrDefault(m => m.Name == measurandName); if (measurandConfig != null) + { continue; + } listenerConfig.MeasurandConfigs.Add(new MeasurandConfig { @@ -94,10 +96,14 @@ private void ValidateListeners(string measurandName) } if (!modified) + { return; + } lock (_configSaveLock) + { RuntimeConfigManager.SaveConfiguration(ModuleConfig); + } } /// @@ -105,4 +111,4 @@ private void ValidateListeners(string measurandName) /// public event EventHandler MeasurementAdded; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.Monitor/Properties/AssemblyInfo.cs b/src/Moryx.ProcessData.Monitor/Properties/AssemblyInfo.cs index 91f1289496..7eeecf5e6c 100644 --- a/src/Moryx.ProcessData.Monitor/Properties/AssemblyInfo.cs +++ b/src/Moryx.ProcessData.Monitor/Properties/AssemblyInfo.cs @@ -3,4 +3,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/Moryx.ProcessData.SpreadsheetsListener/CsvRow.cs b/src/Moryx.ProcessData.SpreadsheetsListener/CsvRow.cs index c5c8c35424..966518b1a8 100644 --- a/src/Moryx.ProcessData.SpreadsheetsListener/CsvRow.cs +++ b/src/Moryx.ProcessData.SpreadsheetsListener/CsvRow.cs @@ -21,4 +21,4 @@ public object ElementAt(int index) { return Fields.ElementAt(index); } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.SpreadsheetsListener/CsvStructure.cs b/src/Moryx.ProcessData.SpreadsheetsListener/CsvStructure.cs index 5aa2763bc2..1fc473de46 100644 --- a/src/Moryx.ProcessData.SpreadsheetsListener/CsvStructure.cs +++ b/src/Moryx.ProcessData.SpreadsheetsListener/CsvStructure.cs @@ -1,13 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Globalization; +using System.Runtime.CompilerServices; using CsvHelper; using CsvHelper.Configuration; using Microsoft.Extensions.Logging; using Moryx.Logging; using Moryx.Tools; -using System.Globalization; -using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Moryx.ProcessData.SpreadsheetsListener.Tests")] namespace Moryx.ProcessData.SpreadsheetsListener; @@ -39,7 +39,10 @@ internal CsvStructure(SpreadsheetsListenerConfig config, string measurand, IModu _measurand = measurand; _maxNumOfRows = Math.Max(2, config.MaxNumOfRows); if (config.Delimiter != null) + { _csvConfig.Delimiter = config.Delimiter; + } + _logger = logger; CreateNewFile(); } @@ -56,16 +59,24 @@ private async Task AdjustHeaderAddRow(IList header, CsvRow row) { List tempHeader; lock (_headerLock) + { tempHeader = _header.ToList(); + } var addHeadings = header.Except(tempHeader).ToArray(); if (addHeadings.Length != 0) { lock (_headerLock) + { _header.AddRange(addHeadings); + } + await OverwriteHeader(); if (_writtenRows == 0) + { _writtenRows++; + } + OpenFile(); } @@ -82,17 +93,19 @@ private async Task AdjustHeaderAddRow(IList header, CsvRow row) csvRow = new CsvRow(rowArray); } lock (_rowsLock) + { _rows.Add(csvRow); + } } public void Close() { if (_csvWriter != null && _fileStream != null && _fileStream.CanWrite) - _csvWriter.Flush(); - if (_streamWriter != null) { - _streamWriter.Close(); + _csvWriter.Flush(); } + + _streamWriter?.Close(); } private void CreateNewFile() @@ -128,11 +141,15 @@ private IDictionary MeasurementToDictionary(Measurement measurem measurement.Tags.ForEach(f => sortedDictionary.Add(f.Name, f.Value)); var currentPlatform = Platform.Current; if (currentPlatform != null) + { sortedDictionary.Add("application", currentPlatform.ProductName); + } // time stamps should be in the first column foreach (var element in sortedDictionary) + { measurementDictionary.Add(element.Key, element.Value); + } return measurementDictionary; } @@ -147,7 +164,9 @@ private async Task OverwriteHeader() { List tempHeader; lock (_headerLock) + { tempHeader = _header.ToList(); + } Close(); string tempfile = Path.GetTempFileName(); @@ -163,7 +182,9 @@ private async Task OverwriteHeader() await csv.NextRecordAsync(); await reader.ReadLineAsync(); while (!reader.EndOfStream) + { await writer.WriteLineAsync(reader.ReadLine()); + } } File.Copy(tempfile, _completeFilePath, true); File.Delete(tempfile); @@ -173,7 +194,9 @@ private async Task WriteHeader() { List tempHeader; lock (_headerLock) + { tempHeader = _header.ToList(); + } _logger.Log(LogLevel.Debug, "Writing {0} headings to header of spreadsheet '{1}'", tempHeader.Count, Path.GetFileName(_completeFilePath)); foreach (var heading in tempHeader) @@ -221,14 +244,19 @@ public async Task WriteRows() if (tempRows.Count > 0) { lock (_rowsLock) + { _rows.AddRange(tempRows); + } + Close(); CreateNewFile(); await WriteHeader(); await WriteRows(); } else + { await _csvWriter.FlushAsync(); + } } catch (Exception e) { diff --git a/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListener.cs b/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListener.cs index ff7f1d7f3c..3f765718a6 100644 --- a/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListener.cs +++ b/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListener.cs @@ -1,11 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using Microsoft.Extensions.Logging; using Moryx.Container; using Moryx.Modules; using Moryx.ProcessData.Listener; using Moryx.Threading; -using Microsoft.Extensions.Logging; namespace Moryx.ProcessData.SpreadsheetsListener; @@ -29,7 +29,10 @@ public override void Stop() lock (_pendingCsvMeasurements) { if (_timerId != 0) + { ParallelOperations.StopExecution(_timerId); + } + foreach (var csvStructure in _pendingCsvMeasurements.Values) { csvStructure.WriteRows().Wait(); @@ -45,7 +48,9 @@ protected override void OnMeasurandAdded(Measurand measurand) lock (_pendingCsvMeasurements) { foreach (var measurement in measurand.Measurements) + { AddPendingMeasurement(measurement).Wait(); + } } CheckOrStartTimer(); } @@ -63,7 +68,9 @@ protected override void OnMeasurementAdded(Measurement measurement) private void CheckOrStartTimer() { if (_timerId == 0) + { _timerId = ParallelOperations.ScheduleExecution(Report, Config.ReportIntervalMs, -1); + } } private void Report() @@ -99,4 +106,4 @@ private async Task WriteCsvFiles() await csvStructure.WriteRows(); } } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListenerConfig.cs b/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListenerConfig.cs index b1d6587065..967ebe9670 100644 --- a/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListenerConfig.cs +++ b/src/Moryx.ProcessData.SpreadsheetsListener/SpreadsheetsListenerConfig.cs @@ -47,4 +47,4 @@ public override string PluginName [DataMember, DefaultValue(";")] [Description("Delimiter used to separate values")] public string Delimiter { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Bindings/MeasurementBindingProcessor.cs b/src/Moryx.ProcessData/Bindings/MeasurementBindingProcessor.cs index dbc9557105..6e2b986c04 100644 --- a/src/Moryx.ProcessData/Bindings/MeasurementBindingProcessor.cs +++ b/src/Moryx.ProcessData/Bindings/MeasurementBindingProcessor.cs @@ -35,16 +35,22 @@ public void Apply(Measurement measurement, object source) { var value = resolver.BindingResolver.Resolve(source); if (value == null) + { continue; + } if (resolver.IsField) + { measurement.Add(new DataField(resolver.Name, value)); + } else + { measurement.Add(new DataTag(resolver.Name, value.ToString())); + } } } - private class ResolverDescription + private sealed class ResolverDescription { public string Name { get; set; } @@ -52,4 +58,4 @@ private class ResolverDescription public bool IsField { get; set; } } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Configuration/MeasurementBinding.cs b/src/Moryx.ProcessData/Configuration/MeasurementBinding.cs index cbc459a576..40637a3a94 100644 --- a/src/Moryx.ProcessData/Configuration/MeasurementBinding.cs +++ b/src/Moryx.ProcessData/Configuration/MeasurementBinding.cs @@ -35,4 +35,4 @@ public class MeasurementBinding /// public override string ToString() => $"{Name}: {Binding}"; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Configuration/ValueTarget.cs b/src/Moryx.ProcessData/Configuration/ValueTarget.cs index d5ea8a1e3f..55fcdcdd98 100644 --- a/src/Moryx.ProcessData/Configuration/ValueTarget.cs +++ b/src/Moryx.ProcessData/Configuration/ValueTarget.cs @@ -17,4 +17,4 @@ public enum ValueTarget /// Target of the value should be measurement tags /// Tag -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/DataField.cs b/src/Moryx.ProcessData/DataField.cs index 712be49a29..4aad82e7b3 100644 --- a/src/Moryx.ProcessData/DataField.cs +++ b/src/Moryx.ProcessData/DataField.cs @@ -30,4 +30,4 @@ public DataField(string name, object value) /// public override string ToString() => Value.ToString(); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/DataTag.cs b/src/Moryx.ProcessData/DataTag.cs index f98901de0e..bda3093e9d 100644 --- a/src/Moryx.ProcessData/DataTag.cs +++ b/src/Moryx.ProcessData/DataTag.cs @@ -26,4 +26,4 @@ public DataTag(string name, string value) Name = name; Value = value; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/IProcessDataMonitor.cs b/src/Moryx.ProcessData/IProcessDataMonitor.cs index 98b0b390b1..04898bf2ee 100644 --- a/src/Moryx.ProcessData/IProcessDataMonitor.cs +++ b/src/Moryx.ProcessData/IProcessDataMonitor.cs @@ -17,4 +17,4 @@ public interface IProcessDataMonitor /// Adds a full measurand which is containing multiple measurements /// void Add(Measurand measurand); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/IProcessDataPublisher.cs b/src/Moryx.ProcessData/IProcessDataPublisher.cs index ca6bc84b34..05d2c9960a 100644 --- a/src/Moryx.ProcessData/IProcessDataPublisher.cs +++ b/src/Moryx.ProcessData/IProcessDataPublisher.cs @@ -12,4 +12,4 @@ public interface IProcessDataPublisher /// Will be raised if process data is occurred /// event EventHandler ProcessDataOccurred; -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Listener/IProcessDataListener.cs b/src/Moryx.ProcessData/Listener/IProcessDataListener.cs index e0d5d3d7d3..990569ac4f 100644 --- a/src/Moryx.ProcessData/Listener/IProcessDataListener.cs +++ b/src/Moryx.ProcessData/Listener/IProcessDataListener.cs @@ -19,4 +19,4 @@ public interface IProcessDataListener : IConfiguredPlugin void MeasurementAdded(Measurement measurement); -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Listener/ProcessDataListenerBase.cs b/src/Moryx.ProcessData/Listener/ProcessDataListenerBase.cs index c52bf17c2f..f0ba23d71c 100644 --- a/src/Moryx.ProcessData/Listener/ProcessDataListenerBase.cs +++ b/src/Moryx.ProcessData/Listener/ProcessDataListenerBase.cs @@ -47,7 +47,9 @@ public virtual void Stop() public void MeasurandAdded(Measurand measurand) { if (!IsMeasurandEnabled(measurand.Name)) + { return; + } OnMeasurandAdded(measurand); } @@ -56,7 +58,9 @@ public void MeasurandAdded(Measurand measurand) public void MeasurementAdded(Measurement measurement) { if (!IsMeasurandEnabled(measurement.Measurand)) + { return; + } OnMeasurementAdded(measurement); } @@ -80,4 +84,4 @@ private bool IsMeasurandEnabled(string measurandName) var config = Config.MeasurandConfigs.FirstOrDefault(m => m.Name == measurandName); return config?.IsEnabled ?? false; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Listener/ProcessDataListenerConfig.cs b/src/Moryx.ProcessData/Listener/ProcessDataListenerConfig.cs index d59009775b..28ca9641b6 100644 --- a/src/Moryx.ProcessData/Listener/ProcessDataListenerConfig.cs +++ b/src/Moryx.ProcessData/Listener/ProcessDataListenerConfig.cs @@ -68,4 +68,4 @@ public override string ToString() var status = IsEnabled ? "Enabled" : "Disabled"; return $"{Name}: {status}"; } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Measurand.cs b/src/Moryx.ProcessData/Measurand.cs index 6cd5ec0433..3571b8457d 100644 --- a/src/Moryx.ProcessData/Measurand.cs +++ b/src/Moryx.ProcessData/Measurand.cs @@ -39,4 +39,4 @@ public Measurand() Id = Guid.NewGuid(); Measurements = new List(); } -} \ No newline at end of file +} diff --git a/src/Moryx.ProcessData/Measurement.cs b/src/Moryx.ProcessData/Measurement.cs index c5464e71b0..976677c46f 100644 --- a/src/Moryx.ProcessData/Measurement.cs +++ b/src/Moryx.ProcessData/Measurement.cs @@ -56,4 +56,4 @@ public Measurement(string measurand, DateTime timeStamp) /// Shortcut to add a data tag /// public void Add(DataTag tag) => Tags.Add(tag); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IConfiguredTypesProvider.cs b/src/Moryx.Products.Management/Components/IConfiguredTypesProvider.cs index ae8dd06bce..96e858b2b4 100644 --- a/src/Moryx.Products.Management/Components/IConfiguredTypesProvider.cs +++ b/src/Moryx.Products.Management/Components/IConfiguredTypesProvider.cs @@ -14,4 +14,4 @@ internal interface IConfiguredTypesProvider /// Returns all currently configuret recipe types /// public IReadOnlyList ProductTypes { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductImporterFactory.cs b/src/Moryx.Products.Management/Components/IProductImporterFactory.cs index fad362616f..38815b3fd8 100644 --- a/src/Moryx.Products.Management/Components/IProductImporterFactory.cs +++ b/src/Moryx.Products.Management/Components/IProductImporterFactory.cs @@ -21,4 +21,4 @@ internal interface IProductImporterFactory /// Destroy an importer /// void Destroy(IProductImporter instance); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductInstanceStrategy.cs b/src/Moryx.Products.Management/Components/IProductInstanceStrategy.cs index 793b7e828e..df7716a5e2 100644 --- a/src/Moryx.Products.Management/Components/IProductInstanceStrategy.cs +++ b/src/Moryx.Products.Management/Components/IProductInstanceStrategy.cs @@ -37,4 +37,4 @@ public interface IProductInstanceStrategy : IAsyncConfiguredInitializable Task LoadInstanceAsync(IGenericColumns source, ProductInstance target, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductLinkStrategy.cs b/src/Moryx.Products.Management/Components/IProductLinkStrategy.cs index 915fce9d3b..cc02ac1c00 100644 --- a/src/Moryx.Products.Management/Components/IProductLinkStrategy.cs +++ b/src/Moryx.Products.Management/Components/IProductLinkStrategy.cs @@ -41,4 +41,4 @@ public interface IProductLinkStrategy : IAsyncConfiguredInitializable Task DeletePartLinkAsync(IReadOnlyList deprecatedEntities, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductManager.cs b/src/Moryx.Products.Management/Components/IProductManager.cs index d5ffac04f5..4436b7c84b 100644 --- a/src/Moryx.Products.Management/Components/IProductManager.cs +++ b/src/Moryx.Products.Management/Components/IProductManager.cs @@ -113,4 +113,4 @@ internal interface IProductManager : IAsyncPlugin /// Full name of the type /// ProductTypeWrapper GetTypeWrapper(string typeName); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductRecipeStrategy.cs b/src/Moryx.Products.Management/Components/IProductRecipeStrategy.cs index b0200e235d..54c826d917 100644 --- a/src/Moryx.Products.Management/Components/IProductRecipeStrategy.cs +++ b/src/Moryx.Products.Management/Components/IProductRecipeStrategy.cs @@ -26,4 +26,4 @@ public interface IProductRecipeStrategy : IAsyncConfiguredInitializable Task LoadRecipeAsync(IGenericColumns source, IProductRecipe target, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductStorage.cs b/src/Moryx.Products.Management/Components/IProductStorage.cs index 9cbff649f2..afaf388df0 100644 --- a/src/Moryx.Products.Management/Components/IProductStorage.cs +++ b/src/Moryx.Products.Management/Components/IProductStorage.cs @@ -112,4 +112,4 @@ public interface IProductStorage : IAsyncPlugin /// /// Task CheckDatabase(CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IProductTypeStrategy.cs b/src/Moryx.Products.Management/Components/IProductTypeStrategy.cs index ce60fea0dd..f8eae5f2a1 100644 --- a/src/Moryx.Products.Management/Components/IProductTypeStrategy.cs +++ b/src/Moryx.Products.Management/Components/IProductTypeStrategy.cs @@ -37,4 +37,4 @@ public interface IProductTypeStrategy : IAsyncConfiguredInitializable Expression> TransformSelector(Expression> selector); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IPropertyMappedConfiguration.cs b/src/Moryx.Products.Management/Components/IPropertyMappedConfiguration.cs index 598636e877..eae19cde56 100644 --- a/src/Moryx.Products.Management/Components/IPropertyMappedConfiguration.cs +++ b/src/Moryx.Products.Management/Components/IPropertyMappedConfiguration.cs @@ -12,4 +12,4 @@ public interface IPropertyMappedConfiguration /// Configuration for individual property mappers /// List PropertyConfigs { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IRecipeManagement.cs b/src/Moryx.Products.Management/Components/IRecipeManagement.cs index 6e7d066dc6..f55e8ce116 100644 --- a/src/Moryx.Products.Management/Components/IRecipeManagement.cs +++ b/src/Moryx.Products.Management/Components/IRecipeManagement.cs @@ -47,4 +47,4 @@ internal interface IRecipeManagement /// Full name of the recipe type /// IProductRecipe CreateRecipe(string recipeType); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Components/IStorageStrategyFactory.cs b/src/Moryx.Products.Management/Components/IStorageStrategyFactory.cs index 2b06d6196d..7f22edeb41 100644 --- a/src/Moryx.Products.Management/Components/IStorageStrategyFactory.cs +++ b/src/Moryx.Products.Management/Components/IStorageStrategyFactory.cs @@ -35,4 +35,4 @@ internal interface IStorageStrategyFactory /// Destroy an instance /// void Destroy(object strategy); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Facades/ProductManagementFacade.cs b/src/Moryx.Products.Management/Facades/ProductManagementFacade.cs index 0246216f7b..072937242e 100644 --- a/src/Moryx.Products.Management/Facades/ProductManagementFacade.cs +++ b/src/Moryx.Products.Management/Facades/ProductManagementFacade.cs @@ -91,7 +91,10 @@ public async Task LoadTypeAsync(long id, CancellationToken cancella ValidateHealthState(); var type = await ProductManager.LoadType(id); if (type == null) + { throw new ProductNotFoundException(id); + } + return type; } @@ -143,7 +146,9 @@ public async Task> LoadRecipesAsync(ProductType pr ValidateHealthState(); var recipes = await RecipeManagement.LoadRecipes(productType, classification); if (recipes == null) + { return null; + } recipes.ForEach(ReplaceOrigin); @@ -177,7 +182,10 @@ public async Task LoadWorkplanAsync(long workplanId, CancellationToken ValidateHealthState(); var wp = await Workplans.LoadWorkplanAsync(workplanId, cancellationToken); if (wp == null) + { throw new KeyNotFoundException($"No workplan with id '{workplanId}' found."); + } + return wp; } @@ -286,7 +294,9 @@ public Task> LoadInstancesAsync(Expression(TRecipe recipe) diff --git a/src/Moryx.Products.Management/Implementation/ImportState.cs b/src/Moryx.Products.Management/Implementation/ImportState.cs index bcd4601312..cc0a8a5bc4 100644 --- a/src/Moryx.Products.Management/Implementation/ImportState.cs +++ b/src/Moryx.Products.Management/Implementation/ImportState.cs @@ -23,10 +23,14 @@ public ImportState(ProductManager manager) public void TaskCompleted(Task task) { if (task.IsCompleted) + { _manager.HandleResult(task.Result); + } Completed = task.IsCompleted | task.IsFaulted; if (task.IsFaulted) + { ErrorMsg = task.Exception.Message; + } } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/ProductManager.cs b/src/Moryx.Products.Management/Implementation/ProductManager.cs index 4fe303bf57..03988853fe 100644 --- a/src/Moryx.Products.Management/Implementation/ProductManager.cs +++ b/src/Moryx.Products.Management/Implementation/ProductManager.cs @@ -83,7 +83,10 @@ public ProductType CreateType(string type) { var wrapper = Storage.GetTypeWrapper(type); if (wrapper == null || wrapper.Constructor == null) + { return (ProductType)TypeTool.CreateInstance(type); + } + return wrapper.Constructor(); } @@ -98,10 +101,14 @@ public async Task DuplicateType(ProductType template, IIdentity new var existing = await LoadTypes(new ProductQuery { Identifier = newIdentity.Identifier }); // Check if the same revision already exists if (existing.Any(e => ((ProductIdentity)e.Identity).Revision == newProductIdentity.Revision)) + { throw new IdentityConflictException(); + } // If there are any products for this identifier, the source object must be one of them if (existing.Any() && template.Identity.Identifier != newIdentity.Identifier) + { throw new IdentityConflictException(true); + } // Reset database id, assign identity and save var duplicate = await Storage.LoadTypeAsync(template.Id); @@ -142,10 +149,14 @@ public async Task Import(string importerName, object parame internal void HandleResult(ProductImporterResult result) { if (result.Saved) + { return; + } foreach (var product in result.ImportedTypes) + { SaveType(product).GetAwaiter().GetResult(); // TODO save async + } } public ImportState ImportParallel(string importerName, object parameters) @@ -160,7 +171,9 @@ public ImportState ImportParallel(string importerName, object parameters) // Wait for the task unless it is long running if (!importer.LongRunning) + { task.Wait(new TimeSpan(0, 0, 0, Config.MaxImporterWait)); + } // Return session object, it can be running, completed or faulted in the meantime return session; @@ -180,7 +193,10 @@ public async Task CreateInstance(ProductType productType, bool { var instance = productType.CreateInstance(); if (save) + { await SaveInstances(instance); + } + return instance; } @@ -212,4 +228,4 @@ public ProductTypeWrapper GetTypeWrapper(string typeName) } public event EventHandler TypeChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/RecipeManagement.cs b/src/Moryx.Products.Management/Implementation/RecipeManagement.cs index 26890f3634..527edd0c40 100644 --- a/src/Moryx.Products.Management/Implementation/RecipeManagement.cs +++ b/src/Moryx.Products.Management/Implementation/RecipeManagement.cs @@ -27,7 +27,9 @@ public Task Get(long recipeId) { var recipe = Storage.LoadRecipeAsync(recipeId); if (recipe == null) + { throw new RecipeNotFoundException(recipeId); + } return recipe; } @@ -63,13 +65,13 @@ public Task> LoadAllWorkplansAsync(CancellationToken can using var uow = ModelFactory.Create(); var repo = uow.GetRepository(); var workplans = (from entity in repo.Linq.Active() - select new Workplan - { - Id = entity.Id, - Name = entity.Name, - Version = entity.Version, - State = (WorkplanState)entity.State - }).ToArray(); + select new Workplan + { + Id = entity.Id, + Name = entity.Name, + Version = entity.Version, + State = (WorkplanState)entity.State + }).ToArray(); return Task.FromResult>(workplans); } @@ -90,7 +92,9 @@ public Task> LoadVersionsAsync(long workplanId, Cancella var currentVersion = workplanRepo.GetByKey(workplanId); if (currentVersion == null) + { return Task.FromResult>(versions); + } // Convert current version versions.Add(new Workplan @@ -106,18 +110,20 @@ public Task> LoadVersionsAsync(long workplanId, Cancella do { var result = (from reference in referenceRepo.Linq - where reference.TargetId == currentId && reference.ReferenceType == (int)WorkplanReferenceType.NewVersion - let entity = reference.Source - select new Workplan - { - Id = entity.Id, - Name = entity.Name, - Version = entity.Version, - State = (WorkplanState)entity.State - }).FirstOrDefault(); + where reference.TargetId == currentId && reference.ReferenceType == (int)WorkplanReferenceType.NewVersion + let entity = reference.Source + select new Workplan + { + Id = entity.Id, + Name = entity.Name, + Version = entity.Version, + State = (WorkplanState)entity.State + }).FirstOrDefault(); if (result == null) + { break; + } versions.Add(result); currentId = result.Id; @@ -128,18 +134,20 @@ public Task> LoadVersionsAsync(long workplanId, Cancella do { var result = (from reference in referenceRepo.Linq - where reference.SourceId == currentId && reference.ReferenceType == (int)WorkplanReferenceType.NewVersion - let entity = reference.Target - select new Workplan - { - Id = entity.Id, - Name = entity.Name, - Version = entity.Version, - State = (WorkplanState)entity.State - }).FirstOrDefault(); + where reference.SourceId == currentId && reference.ReferenceType == (int)WorkplanReferenceType.NewVersion + let entity = reference.Target + select new Workplan + { + Id = entity.Id, + Name = entity.Name, + Version = entity.Version, + State = (WorkplanState)entity.State + }).FirstOrDefault(); if (result == null) + { break; + } versions.Add(result); currentId = result.Id; @@ -188,7 +196,10 @@ public Task DeleteWorkplanAsync(long workplanId, CancellationToken cancell var repo = uow.GetRepository(); var workplan = repo.GetByKey(workplanId); if (workplan == null) + { return Task.FromResult(false); + } + repo.Remove(workplan); uow.SaveChanges(); return Task.FromResult(true); diff --git a/src/Moryx.Products.Management/Implementation/RecipeStorage.cs b/src/Moryx.Products.Management/Implementation/RecipeStorage.cs index b6964d362f..3b38615e1b 100644 --- a/src/Moryx.Products.Management/Implementation/RecipeStorage.cs +++ b/src/Moryx.Products.Management/Implementation/RecipeStorage.cs @@ -39,7 +39,9 @@ public static void CopyToRecipe(ProductRecipeEntity recipeEntity, IProductRecipe productRecipe.Product = new ProductReference(recipeEntity.ProductId); if (productRecipe is IWorkplanRecipe workplanRecipe) + { workplanRecipe.Workplan = LoadWorkplan(recipeEntity.Workplan); + } } /// @@ -58,7 +60,9 @@ public static ProductRecipeEntity ToRecipeEntity(IUnitOfWork uow, IProductRecipe entity.ProductId = recipe.Product.Id; if (recipe is IWorkplanRecipe workplanRecipe) + { entity.WorkplanId = workplanRecipe.Workplan.Id; + } return entity; } @@ -118,7 +122,9 @@ private static List LoadSteps(WorkplanEntity workplan, IDictionar foreach (var stepEntity in workplan.Steps) { if (!_stepTypes.Value.TryGetValue(stepEntity.TypeName, out var type)) + { throw new TypeLoadException($"Step type {stepEntity.TypeName} not found."); + } // Create instance using public and private constructors var step = (WorkplanStepBase)Activator.CreateInstance(type, true); @@ -142,11 +148,15 @@ private static List LoadSteps(WorkplanEntity workplan, IDictionar // Restore parameters from JSON if (step is ITaskStep taskStep) + { PopulateStepParameters(stepEntity, taskStep); + } // Restore Subworkplan if necessary if (step is ISubworkplanStep subworkplanStep) + { subworkplanStep.Workplan = LoadWorkplan(stepEntity.SubWorkplan); + } // Link inputs and outputs step.Inputs = RestoreReferences(stepEntity, ConnectorRole.Input, connectors); @@ -161,11 +171,15 @@ private static List LoadSteps(WorkplanEntity workplan, IDictionar private static void PopulateStepParameters(WorkplanStepEntity stepEntity, ITaskStep taskStep) { if (taskStep.Parameters is null) + { throw new InvalidOperationException($"{nameof(taskStep.Parameters)} could not " + $"be populated from the database. Make sure the property of {taskStep.GetType()} " + $"is initilized on instance creation."); + } else + { JsonConvert.PopulateObject(stepEntity.Parameters, taskStep.Parameters); + } } /// @@ -180,7 +194,9 @@ private static IConnector[] RestoreReferences(WorkplanStepEntity stepEntity, Con { var referenceEntity = referenceEntities.First(f => f.Index == index); if (referenceEntity.ConnectorId.HasValue) + { references[index] = connectors[referenceEntity.ConnectorId.Value]; + } } return references; @@ -316,11 +332,15 @@ private static IDictionary SaveSteps(IUnitOfWork uow, // Task steps need parameters if (step is ITaskStep taskStep) + { stepEntity.Parameters = JsonConvert.SerializeObject(taskStep.Parameters); + } // Subworkplan steps and need a reference to the workplan if (step is ISubworkplanStep subworkPlanStep) + { stepEntity.SubWorkplanId = subworkPlanStep.WorkplanId; + } stepEntities[step.Id] = stepEntity; } diff --git a/src/Moryx.Products.Management/Implementation/Storage/ConstructorStrategyInformation.cs b/src/Moryx.Products.Management/Implementation/Storage/ConstructorStrategyInformation.cs index 348bb8a2ca..c7301a8003 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/ConstructorStrategyInformation.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/ConstructorStrategyInformation.cs @@ -66,9 +66,14 @@ public IList GetAllPartLinks(ProductType modifiedInstance) var value = property.GetValue(modifiedInstance); var partLink = new PartLinkInfo(linkStrategy, value); if (typeof(ProductPartLink).IsAssignableFrom(property.PropertyType)) + { partLink.Type = PartLinkType.single; + } else if (typeof(IEnumerable).IsAssignableFrom(property.PropertyType)) + { partLink.Type = PartLinkType.list; + } + result.Add(partLink); } return result; @@ -78,7 +83,10 @@ public ProductTypeWrapper GetTypeWrapper() { var partLinks = new Dictionary>(); foreach (var partLinkInfo in PartLinksInformation) + { partLinks.Add(partLinkInfo.Key, partLinkInfo.Value.Constructor); + } + return new ProductTypeWrapper(Identifier, Constructor, partLinks, _properties.Values.ToList()); } @@ -104,4 +112,4 @@ internal enum PartLinkType none, single, list -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/FloatStrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Implementation/Storage/FloatStrategyConfigurationAttribute.cs index 4aa42fbfcc..4eb6f784d4 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/FloatStrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/FloatStrategyConfigurationAttribute.cs @@ -17,4 +17,4 @@ public FloatStrategyConfigurationAttribute() typeof(decimal) ]; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/InstanceStrategyBase.cs b/src/Moryx.Products.Management/Implementation/Storage/InstanceStrategyBase.cs index 68b9c96a98..3191dce85e 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/InstanceStrategyBase.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/InstanceStrategyBase.cs @@ -69,4 +69,4 @@ public override async Task InitializeAsync(ProductInstanceConfiguration config, /// public abstract Task LoadInstanceAsync(IGenericColumns source, ProductInstance target, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/IntegerStrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Implementation/Storage/IntegerStrategyConfigurationAttribute.cs index f1a8b3a03d..96c6fe3478 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/IntegerStrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/IntegerStrategyConfigurationAttribute.cs @@ -31,7 +31,9 @@ public IntegerStrategyConfigurationAttribute() public override int TypeCompliance(Type targetType) { if (targetType.IsEnum) + { return PerfectMatch; + } return base.TypeCompliance(targetType); } diff --git a/src/Moryx.Products.Management/Implementation/Storage/LinkStrategyBase.cs b/src/Moryx.Products.Management/Implementation/Storage/LinkStrategyBase.cs index 798c84274d..eabb5f3651 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/LinkStrategyBase.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/LinkStrategyBase.cs @@ -52,4 +52,4 @@ public virtual Task DeletePartLinkAsync(IReadOnlyList deprecate { return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/PartSourceStrategy.cs b/src/Moryx.Products.Management/Implementation/Storage/PartSourceStrategy.cs index 8dc84e9745..d1d09a90c6 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/PartSourceStrategy.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/PartSourceStrategy.cs @@ -17,4 +17,4 @@ public enum PartSourceStrategy /// Create parts from entity relation /// FromEntities = 10, -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/ProductExpressionHelpers.cs b/src/Moryx.Products.Management/Implementation/Storage/ProductExpressionHelpers.cs index f3fae6a8e8..2259450592 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/ProductExpressionHelpers.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/ProductExpressionHelpers.cs @@ -13,15 +13,22 @@ internal static class ProductExpressionHelpers public static object ExtractExpressionValue(Expression expression) { if (expression is ConstantExpression constEx) + { return constEx.Value; + } if (expression is MemberExpression memEx) { var container = (memEx.Expression as ConstantExpression)?.Value; if (memEx.Member is FieldInfo field) + { return field.GetValue(container); + } + if (memEx.Member is PropertyInfo prop) + { return prop.GetValue(container); + } } throw new NotSupportedException("Expression type not supported yet."); @@ -74,7 +81,10 @@ private static bool IsTypeExpression(MemberExpression expression, out MemberInfo do { if (expression.Member is PropertyInfo propertyInfo && typeof(ProductType).IsAssignableFrom(propertyInfo.PropertyType)) + { return true; + } + typeMember = expression.Member; expression = expression.Expression as MemberExpression; } while (expression is not null); diff --git a/src/Moryx.Products.Management/Implementation/Storage/ProductStorage.cs b/src/Moryx.Products.Management/Implementation/Storage/ProductStorage.cs index 3a1110a374..54a7d7a436 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/ProductStorage.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/ProductStorage.cs @@ -2,21 +2,21 @@ // Licensed under the Apache License, Version 2.0 using System.Collections; -using Moryx.Model; using System.Linq.Expressions; using System.Reflection; using System.Text.RegularExpressions; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Moryx.AbstractionLayer.Identity; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; using Moryx.Container; +using Moryx.Logging; +using Moryx.Model; using Moryx.Model.Repositories; +using Moryx.Products.Management.Model; using Moryx.Tools; using static Moryx.Products.Management.ProductExpressionHelpers; -using Moryx.Logging; -using Microsoft.Extensions.Logging; -using Moryx.AbstractionLayer.Identity; -using Moryx.Products.Management.Model; namespace Moryx.Products.Management; @@ -92,10 +92,14 @@ public async Task StartAsync(CancellationToken cancellationToken = default) foreach (var config in Config.TypeStrategies) { var strategy = await StrategyFactory.CreateTypeStrategy(config, cancellationToken); - if (!_typeInformation.ContainsKey(config.TargetType)) - _typeInformation.Add(config.TargetType, new ProductTypeInformation(strategy.TargetType)); - _typeInformation[config.TargetType].Strategy = strategy; - _typeInformation[config.TargetType].Constructor = ReflectionTool.ConstructorDelegate(strategy.TargetType); + if (!_typeInformation.TryGetValue(config.TargetType, out var value)) + { + value = new ProductTypeInformation(strategy.TargetType); + _typeInformation.Add(config.TargetType, value); + } + + value.Strategy = strategy; + value.Constructor = ReflectionTool.ConstructorDelegate(strategy.TargetType); } // Create instance strategies @@ -109,13 +113,17 @@ public async Task StartAsync(CancellationToken cancellationToken = default) foreach (var config in Config.LinkStrategies) { if (!_typeInformation.TryGetValue(config.TargetType, out var typeInfo)) + { continue; + } var strategy = await StrategyFactory.CreateLinkStrategy(config, cancellationToken); - if (!typeInfo.PartLinksInformation.ContainsKey(config.PartName)) - typeInfo.PartLinksInformation.Add(config.PartName, new ConstructorStrategyInformation()); + if (!typeInfo.PartLinksInformation.TryGetValue(config.PartName, out var partLinkInfo)) + { + partLinkInfo = new ConstructorStrategyInformation(); + typeInfo.PartLinksInformation.Add(config.PartName, partLinkInfo); + } - var partLinkInfo = typeInfo.PartLinksInformation[config.PartName]; partLinkInfo.Strategy = strategy; var property = strategy.TargetType.GetProperty(config.PartName); @@ -141,11 +149,14 @@ public async Task StartAsync(CancellationToken cancellationToken = default) foreach (var config in Config.RecipeStrategies) { var strategy = await StrategyFactory.CreateRecipeStrategy(config, cancellationToken); - if (!_recipeInformation.ContainsKey(config.TargetType)) - _recipeInformation.Add(config.TargetType, new ConstructorStrategyInformation()); + if (!_recipeInformation.TryGetValue(config.TargetType, out var value)) + { + value = new ConstructorStrategyInformation(); + _recipeInformation.Add(config.TargetType, value); + } - _recipeInformation[config.TargetType].Strategy = strategy; - _recipeInformation[config.TargetType].Constructor = ReflectionTool.ConstructorDelegate(strategy.TargetType); + value.Strategy = strategy; + value.Constructor = ReflectionTool.ConstructorDelegate(strategy.TargetType); } } @@ -175,7 +186,9 @@ public async Task> LoadRecipesAsync(long productId var repo = uow.GetRepository(); var productEntity = repo.GetByKey(productId); if (productEntity == null) + { return null; + } var classificationMask = (int)classifications; var recipeEntities = (from recipeEntity in uow.GetRepository().Linq.Active() @@ -273,7 +286,9 @@ public async Task> LoadTypesAsync(ProductQuery query, if (!string.IsNullOrEmpty(query.TypeName)) { if (query.ExcludeDerivedTypes) + { productsQuery = productsQuery.Where(p => p.TypeName == query.TypeName); + } else { var baseType = _typeInformation[query.TypeName].Type; @@ -281,10 +296,15 @@ public async Task> LoadTypesAsync(ProductQuery query, { // Check if any interface matches if (type.GetInterface(query.TypeName) != null) + { return true; + } // Check if type or base type matches if (baseType == null) + { return false; + } + return baseType.IsAssignableFrom(type); }).Select(t => t.FullName); productsQuery = productsQuery.Where(p => allTypes.Contains(p.TypeName)); @@ -323,13 +343,21 @@ public async Task> LoadTypesAsync(ProductQuery query, var identifierMatches = Regex.Match(query.Identifier, "(?\\*)?(?\\w*)(?\\*)?"); var identifier = identifierMatches.Groups["filter"].Value.ToLower(); if (identifierMatches.Groups["startCard"].Success && identifierMatches.Groups["endCard"].Success) + { productsQuery = productsQuery.Where(p => p.Identifier.ToLower().Contains(identifier)); + } else if (identifierMatches.Groups["startCard"].Success) + { productsQuery = productsQuery.Where(p => p.Identifier.ToLower().EndsWith(identifier)); + } else if (identifierMatches.Groups["endCard"].Success) + { productsQuery = productsQuery.Where(p => p.Identifier.ToLower().StartsWith(identifier)); + } else + { productsQuery = productsQuery.Where(p => p.Identifier.ToLower() == identifier); + } } // Filter by revision @@ -345,13 +373,19 @@ public async Task> LoadTypesAsync(ProductQuery query, // Filter by name if (!string.IsNullOrEmpty(query.Name)) + { productsQuery = productsQuery.Where(p => p.Name.ToLower().Contains(query.Name.ToLower())); + } // Filter by recipe if (query.RecipeFilter == RecipeFilter.WithRecipe) + { productsQuery = productsQuery.Where(p => p.Recipes.Any()); + } else if (query.RecipeFilter == RecipeFilter.WithoutRecipes) + { productsQuery = productsQuery.Where(p => p.Recipes.Count == 0); + } // Apply selector productsQuery = query.Selector switch @@ -438,14 +472,15 @@ public async Task> LoadTypesAsync(Expression Nothing to do List entities; if (query == null || (entities = query.ToList()).Count == 0) + { return Array.Empty(); + } var loadedProducts = new Dictionary(); var transformed = entities.Select(entity => Transform(uow, entity, false, cancellationToken, loadedProducts)); var instances = (await Task.WhenAll(transformed)).OfType().ToArray(); - // Final check against compiled expression var compiledSelector = selector.Compile(); // Only return matches against compiled expression @@ -486,9 +521,13 @@ public async Task LoadTypeAsync(IIdentity identity, CancellationTok .Where(p => p.Identifier == identity.Identifier) .Select(p => p.Revision).ToList(); if (revisions.Any()) + { revision = revisions.Max(); + } else + { return null; + } } var product = uow.GetRepository().Linq.Active() @@ -503,7 +542,9 @@ private async Task Transform(IUnitOfWork uow, ProductTypeEntity typ // Take converted product from dictionary if we already transformed it if (loadedProducts.TryGetValue(typeEntity.Id, out var loadedProduct)) + { return loadedProduct; + } // Strategy to load product and its parts var strategy = _typeInformation[typeEntity.TypeName].Strategy; @@ -518,7 +559,9 @@ private async Task Transform(IUnitOfWork uow, ProductTypeEntity typ // Don't load parts and parent for partial view if (full) + { await LoadParts(uow, typeEntity, product, loadedProducts, cancellationToken); + } // Assign instance to dictionary of loaded products loadedProducts[typeEntity.Id] = product; @@ -716,7 +759,9 @@ private async Task GetPartEntity(ProductPartsSaverContext sav } if (link.Product.Id == 0) + { return await SaveType(saverContext, link.Product, cancellationToken); + } return saverContext.UnitOfWork.GetEntity(link.Product); } @@ -823,7 +868,9 @@ private async Task> LoadWithStrategy(Express // No query or no result => Nothing to do List entities; if (query == null || (entities = query.ToList()).Count == 0) + { return Array.Empty(); + } var instances = (await TransformInstances(uow, entities, cancellationToken)).OfType().ToArray(); // Final check against compiled expression @@ -877,7 +924,9 @@ private async Task TransformInstance(IUnitOfWork uow, ProductInstanceEntity enti // Check if instances of this type are persisted var strategy = _instanceStrategies[productInstance.ProductInstanceTypeName()]; if (strategy.SkipInstances) + { return; + } // Transform entity to instance await strategy.LoadInstanceAsync(entity, productInstance, cancellationToken); @@ -951,7 +1000,9 @@ public async Task SaveInstancesAsync(ProductInstance[] productInstances, Cancell // Write all to entity objects foreach (var instance in productInstances) + { await SaveInstance(uow, instance, cancellationToken); + } // Save transaction uow.SaveChanges(); @@ -965,7 +1016,9 @@ private async Task SaveInstance(IUnitOfWork uow, ProductI // Check if this type is persisted var strategy = _instanceStrategies[productInstance.ProductInstanceTypeName()]; if (strategy.SkipInstances) + { return null; + } // Save to entity var archived = uow.GetEntity(productInstance); @@ -981,7 +1034,9 @@ private async Task SaveInstance(IUnitOfWork uow, ProductI { var partEntity = await SaveInstance(uow, part, cancellationToken); if (partEntity == null) // Parts are null when they are skipped + { continue; + } partEntity.Parent = archived; partEntity.PartLinkEntityId = part.PartLink.Id; @@ -994,10 +1049,14 @@ private async Task SaveInstance(IUnitOfWork uow, ProductI public IProductRecipe CreateRecipe(string recipeType) { if (!_recipeInformation.TryGetValue(recipeType, out var recipeInfo)) + { return null; + } if (recipeInfo.Constructor == null) + { return null; + } var result = recipeInfo.Constructor(); @@ -1007,7 +1066,9 @@ public IProductRecipe CreateRecipe(string recipeType) public ProductTypeWrapper GetTypeWrapper(string typeName) { if (!_typeInformation.TryGetValue(typeName, out var typeInfo)) + { return null; + } return typeInfo.GetTypeWrapper(); } @@ -1034,11 +1095,15 @@ public Task DeleteTypeAsync(long productId, CancellationToken cancellation }).FirstOrDefault(); // No match, nothing removed! if (queryResult == null) + { return Task.FromResult(false); + } // If products would be affected by the removal, we do not remove it if (queryResult.parentCount >= 1) + { return Task.FromResult(false); + } // No products affected, so we can remove the product productRepo.Remove(queryResult.entity); diff --git a/src/Moryx.Products.Management/Implementation/Storage/ProductTypeConfiguration.cs b/src/Moryx.Products.Management/Implementation/Storage/ProductTypeConfiguration.cs index a1d813a1ff..59a5e40d22 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/ProductTypeConfiguration.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/ProductTypeConfiguration.cs @@ -107,4 +107,4 @@ public override string ToString() { return $"{TargetType} => {PluginName}"; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/PropertyStrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Implementation/Storage/PropertyStrategyConfigurationAttribute.cs index 17870a8054..31cb3b214a 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/PropertyStrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/PropertyStrategyConfigurationAttribute.cs @@ -21,4 +21,4 @@ public class PropertyStrategyConfigurationAttribute : StrategyConfigurationAttri public PropertyStrategyConfigurationAttribute(params Type[] supportedTypes) : base(supportedTypes) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/RecipeStrategyBase.cs b/src/Moryx.Products.Management/Implementation/Storage/RecipeStrategyBase.cs index 59374807c7..7d2511982e 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/RecipeStrategyBase.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/RecipeStrategyBase.cs @@ -34,4 +34,4 @@ public override async Task InitializeAsync(ProductRecipeConfiguration config, Ca /// public abstract Task LoadRecipeAsync(IGenericColumns source, IProductRecipe target, CancellationToken cancellationToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/StrategyBase.cs b/src/Moryx.Products.Management/Implementation/Storage/StrategyBase.cs index a9cd1e05e7..6601f06aca 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/StrategyBase.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/StrategyBase.cs @@ -27,4 +27,4 @@ public virtual Task InitializeAsync(TConfigBase config, CancellationToken cancel Config = (TConfig)config; return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/StrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Implementation/Storage/StrategyConfigurationAttribute.cs index 3bbd484198..d4f650db87 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/StrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/StrategyConfigurationAttribute.cs @@ -46,7 +46,9 @@ public virtual int TypeCompliance(Type targetType) do { if (SupportedTypes.Contains(current)) + { return compliance; + } current = current.BaseType; compliance++; @@ -54,9 +56,11 @@ public virtual int TypeCompliance(Type targetType) // Use full distance if it is an interface match if (targetType.GetInterfaces().Any(SupportedTypes.Contains)) + { return compliance; + } // Otherwise it is no match return BadCompliance; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/TextStrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Implementation/Storage/TextStrategyConfigurationAttribute.cs index 96daf684a9..d0f224265f 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/TextStrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/TextStrategyConfigurationAttribute.cs @@ -17,14 +17,18 @@ public override int TypeCompliance(Type targetType) { // Fallback for interfaces if (targetType.IsInterface) + { return BadCompliance - 1; + } // Non-primitive structs like Vector3 are JSON-serialized into a text column // Exclude types explicitly listed in SupportedTypes (e.g. Guid) if (targetType.IsValueType && !targetType.IsPrimitive && !targetType.IsEnum && !SupportedTypes.Contains(targetType)) + { return PerfectMatch + 1; + } return base.TypeCompliance(targetType); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/Storage/TypeStrategyBase.cs b/src/Moryx.Products.Management/Implementation/Storage/TypeStrategyBase.cs index d1ec600f78..c583a0c6b8 100644 --- a/src/Moryx.Products.Management/Implementation/Storage/TypeStrategyBase.cs +++ b/src/Moryx.Products.Management/Implementation/Storage/TypeStrategyBase.cs @@ -40,4 +40,4 @@ public override async Task InitializeAsync(ProductTypeConfiguration config, Canc /// public abstract Expression> TransformSelector(Expression> selector); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Implementation/WorkplanReferenceType.cs b/src/Moryx.Products.Management/Implementation/WorkplanReferenceType.cs index 7b65cc7c3a..3329274f9e 100644 --- a/src/Moryx.Products.Management/Implementation/WorkplanReferenceType.cs +++ b/src/Moryx.Products.Management/Implementation/WorkplanReferenceType.cs @@ -17,4 +17,4 @@ public enum WorkplanReferenceType /// The workplan is a copy of the other workplan /// Copy = 2000, -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IPartLinkRepository.cs b/src/Moryx.Products.Management/Model/API/IPartLinkRepository.cs index 857cf9fc6e..d3ef815655 100644 --- a/src/Moryx.Products.Management/Model/API/IPartLinkRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IPartLinkRepository.cs @@ -14,4 +14,4 @@ public interface IPartLinkRepository : IRepository /// Creates instance with all not nullable properties prefilled /// PartLinkEntity Create(string propertyName); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IProductInstanceRepository.cs b/src/Moryx.Products.Management/Model/API/IProductInstanceRepository.cs index bab4e5f373..52097e7408 100644 --- a/src/Moryx.Products.Management/Model/API/IProductInstanceRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IProductInstanceRepository.cs @@ -10,4 +10,4 @@ namespace Moryx.Products.Management.Model; /// public interface IProductInstanceRepository : IRepository { -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IProductTypeRepository.cs b/src/Moryx.Products.Management/Model/API/IProductTypeRepository.cs index bb568fc1cf..0f52b28ccb 100644 --- a/src/Moryx.Products.Management/Model/API/IProductTypeRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IProductTypeRepository.cs @@ -21,4 +21,4 @@ public interface IProductTypeRepository : IRepository /// Value for MaterialNumber the ProductEntity has to match /// Value for Revision the ProductEntity has to match ProductTypeEntity GetByIdentity(string identifier, short revision); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IWorkplanConnectorReferenceRepository.cs b/src/Moryx.Products.Management/Model/API/IWorkplanConnectorReferenceRepository.cs index 421da00c71..29d76729fc 100644 --- a/src/Moryx.Products.Management/Model/API/IWorkplanConnectorReferenceRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IWorkplanConnectorReferenceRepository.cs @@ -14,4 +14,4 @@ public interface IWorkplanConnectorReferenceRepository : IRepository WorkplanConnectorReferenceEntity Create(int index, ConnectorRole role); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IWorkplanReferenceRepository.cs b/src/Moryx.Products.Management/Model/API/IWorkplanReferenceRepository.cs index 45105a9463..c5addd952a 100644 --- a/src/Moryx.Products.Management/Model/API/IWorkplanReferenceRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IWorkplanReferenceRepository.cs @@ -14,4 +14,4 @@ public interface IWorkplanReferenceRepository : IRepository WorkplanReferenceEntity Create(int referenceType); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/API/IWorkplanRepository.cs b/src/Moryx.Products.Management/Model/API/IWorkplanRepository.cs index 205bb3f12e..12fc6aef9a 100644 --- a/src/Moryx.Products.Management/Model/API/IWorkplanRepository.cs +++ b/src/Moryx.Products.Management/Model/API/IWorkplanRepository.cs @@ -14,4 +14,4 @@ public interface IWorkplanRepository : IRepository /// Creates instance with all not nullable properties prefilled /// WorkplanEntity Create(string name, int version, int state); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/IGenericColumns.cs b/src/Moryx.Products.Management/Model/Entities/IGenericColumns.cs index 0c5a979318..389d3988d6 100644 --- a/src/Moryx.Products.Management/Model/Entities/IGenericColumns.cs +++ b/src/Moryx.Products.Management/Model/Entities/IGenericColumns.cs @@ -32,4 +32,4 @@ public interface IGenericColumns string Text6 { get; set; } string Text7 { get; set; } string Text8 { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/PartLinkEntity.cs b/src/Moryx.Products.Management/Model/Entities/PartLinkEntity.cs index cfafdbd36a..d4fe6ed992 100644 --- a/src/Moryx.Products.Management/Model/Entities/PartLinkEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/PartLinkEntity.cs @@ -46,4 +46,4 @@ public class PartLinkEntity : EntityBase, IGenericColumns public virtual string Text8 { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/ProductTypeEntity.cs b/src/Moryx.Products.Management/Model/Entities/ProductTypeEntity.cs index 4404808ab7..be25fec563 100644 --- a/src/Moryx.Products.Management/Model/Entities/ProductTypeEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/ProductTypeEntity.cs @@ -42,10 +42,14 @@ public ProductTypeEntity() public void SetCurrentVersion(ProductTypePropertiesEntity properties) { if (CurrentVersion == properties) + { return; + } if (CurrentVersion != null) + { OldVersions.Add(CurrentVersion); + } CurrentVersion = properties; } diff --git a/src/Moryx.Products.Management/Model/Entities/ProductTypePropertiesEntity.cs b/src/Moryx.Products.Management/Model/Entities/ProductTypePropertiesEntity.cs index f46753acd0..cc915fa7c1 100644 --- a/src/Moryx.Products.Management/Model/Entities/ProductTypePropertiesEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/ProductTypePropertiesEntity.cs @@ -42,4 +42,4 @@ public class ProductTypePropertiesEntity : ModificationTrackedEntityBase, IGener public virtual string Text8 { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorEntity.cs b/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorEntity.cs index bb784465c3..7dd09b6298 100644 --- a/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorEntity.cs @@ -25,4 +25,4 @@ public class WorkplanConnectorEntity : EntityBase public virtual WorkplanEntity Workplan { get; set; } public virtual ICollection Usages { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorReferenceEntity.cs b/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorReferenceEntity.cs index 889883a42c..2d46a0db41 100644 --- a/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorReferenceEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/WorkplanConnectorReferenceEntity.cs @@ -18,4 +18,4 @@ public class WorkplanConnectorReferenceEntity : EntityBase public virtual WorkplanConnectorEntity Connector { get; set; } public virtual WorkplanStepEntity WorkplanStep { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/WorkplanEntity.cs b/src/Moryx.Products.Management/Model/Entities/WorkplanEntity.cs index 399ab2fb34..9b66bc9b62 100644 --- a/src/Moryx.Products.Management/Model/Entities/WorkplanEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/WorkplanEntity.cs @@ -37,4 +37,4 @@ public WorkplanEntity() Steps = new List(); Parents = new List(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/WorkplanOutputDescriptionEntity.cs b/src/Moryx.Products.Management/Model/Entities/WorkplanOutputDescriptionEntity.cs index 61ab131ce8..8ac4e9bd1a 100644 --- a/src/Moryx.Products.Management/Model/Entities/WorkplanOutputDescriptionEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/WorkplanOutputDescriptionEntity.cs @@ -19,4 +19,4 @@ public class WorkplanOutputDescriptionEntity : EntityBase public virtual long WorkplanStepId { get; set; } public virtual WorkplanStepEntity WorkplanStep { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Entities/WorkplanReferenceEntity.cs b/src/Moryx.Products.Management/Model/Entities/WorkplanReferenceEntity.cs index 17efa8f388..de19fe1995 100644 --- a/src/Moryx.Products.Management/Model/Entities/WorkplanReferenceEntity.cs +++ b/src/Moryx.Products.Management/Model/Entities/WorkplanReferenceEntity.cs @@ -17,4 +17,4 @@ public class WorkplanReferenceEntity : EntityBase public virtual WorkplanEntity Target { get; set; } public virtual WorkplanEntity Source { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251202131135_StepTypeName.cs b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251202131135_StepTypeName.cs index b1d61a5448..bca9bbcbd6 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251202131135_StepTypeName.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251202131135_StepTypeName.cs @@ -62,4 +62,4 @@ protected override void Down(MigrationBuilder migrationBuilder) type: "text", nullable: true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251203182754_RecipeTypeName.cs b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251203182754_RecipeTypeName.cs index 20076c17ca..7d997f1598 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251203182754_RecipeTypeName.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251203182754_RecipeTypeName.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -29,4 +29,4 @@ protected override void Down(MigrationBuilder migrationBuilder) table: "ProductRecipes", newName: "Type"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251210085949_ProductState.cs b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251210085949_ProductState.cs index ce090b19c4..74c1dba078 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251210085949_ProductState.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Npgsql/20251210085949_ProductState.cs @@ -42,4 +42,4 @@ protected override void Down(MigrationBuilder migrationBuilder) oldClrType: typeof(int), oldType: "integer"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251202123359_StepTypeName.cs b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251202123359_StepTypeName.cs index 3b6e80b94d..a08861d341 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251202123359_StepTypeName.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251202123359_StepTypeName.cs @@ -62,4 +62,4 @@ protected override void Down(MigrationBuilder migrationBuilder) type: "TEXT", nullable: true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251203182818_RecipeTypeName.cs b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251203182818_RecipeTypeName.cs index 075e961c5a..7c2789e351 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251203182818_RecipeTypeName.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251203182818_RecipeTypeName.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -29,4 +29,4 @@ protected override void Down(MigrationBuilder migrationBuilder) table: "ProductRecipes", newName: "Type"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251210093915_ProductState.cs b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251210093915_ProductState.cs index e03c00a7c9..f38bbb14d2 100644 --- a/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251210093915_ProductState.cs +++ b/src/Moryx.Products.Management/Model/Migrations/Sqlite/20251210093915_ProductState.cs @@ -24,4 +24,4 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.Sql($"UPDATE ProductInstances SET State = 3 WHERE State = {(int)ProductInstanceState.Success};"); migrationBuilder.Sql($"UPDATE ProductInstances SET State = 4 WHERE State = {(int)ProductInstanceState.Failure};"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/ModuleController/ModuleConfig.cs b/src/Moryx.Products.Management/ModuleController/ModuleConfig.cs index d81ae4c67c..82de5d7bd0 100644 --- a/src/Moryx.Products.Management/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Products.Management/ModuleController/ModuleConfig.cs @@ -72,4 +72,4 @@ public override void Initialize() [DataMember, Description("Configured strategies for the different product recipes")] [PluginConfigs(typeof(IProductRecipeStrategy))] public List RecipeStrategies { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/ModuleController/ModuleConsole.cs b/src/Moryx.Products.Management/ModuleController/ModuleConsole.cs index ebf23e4a84..a38e019bb3 100644 --- a/src/Moryx.Products.Management/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Products.Management/ModuleController/ModuleConsole.cs @@ -44,4 +44,4 @@ public void SaveConfig() { ConfigManager.SaveConfiguration(Configurator.Config); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/AvailableColumnsAttribute.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/AvailableColumnsAttribute.cs index b8dc0cbf80..65ca6d3b4d 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/AvailableColumnsAttribute.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/AvailableColumnsAttribute.cs @@ -44,4 +44,4 @@ public override IEnumerable GetValues(IContainer container, IServiceProv .Select(p => p.Name) .OrderBy(p => p); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/ConversionAccessor.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/ConversionAccessor.cs index 298c697797..38ccafdaab 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/ConversionAccessor.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/ConversionAccessor.cs @@ -39,4 +39,4 @@ public void WriteProperty(object instance, TColumn value) var converted = ToProperty(value); Target.WriteProperty(instance, converted); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/DifferentialContractResolver.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/DifferentialContractResolver.cs index c1f7607e23..3e5ae65ac3 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/DifferentialContractResolver.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/DifferentialContractResolver.cs @@ -30,14 +30,20 @@ protected override IList CreateProperties(Type type, MemberSeriali private bool ShouldSerialize(JsonProperty property) { if (_ignoredProperties.Any(prop => prop == property.PropertyName)) + { return false; + } if (typeof(TReference).IsAssignableFrom(property.PropertyType)) + { return false; + } if (typeof(IEnumerable).IsAssignableFrom(property.PropertyType)) + { return false; + } return true; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericEntityMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericEntityMapper.cs index a055f41d82..8714a28c49 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericEntityMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericEntityMapper.cs @@ -29,7 +29,6 @@ internal class GenericEntityMapper : IGenericMapper private IPropertyMapper[] _configuredMappers; - private JsonSerializerSettings _jsonSettings; private IPropertyAccessor _jsonAccessor; diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceConfiguration.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceConfiguration.cs index 9978c816c8..10d42dcffc 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceConfiguration.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceConfiguration.cs @@ -27,4 +27,4 @@ public override string PluginName /// [DataMember, Description] public List PropertyConfigs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceStrategy.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceStrategy.cs index 09ea5c2ff9..e15b11084d 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericInstanceStrategy.cs @@ -48,4 +48,4 @@ public override Task LoadInstanceAsync(IGenericColumns source, ProductInstance t EntityMapper.ReadValue(source, target); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkConfiguration.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkConfiguration.cs index e36342a3d8..f26ff6c0f1 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkConfiguration.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkConfiguration.cs @@ -27,4 +27,4 @@ public override string PluginName /// [DataMember, Description] public List PropertyConfigs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkStrategy.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkStrategy.cs index 44f693ad2f..715110d2eb 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericLinkStrategy.cs @@ -52,4 +52,4 @@ public override Task SavePartLinkAsync(ProductPartLink source, IGenericColumns t return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeConfiguration.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeConfiguration.cs index a3dbc9792f..a86f7cc776 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeConfiguration.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeConfiguration.cs @@ -23,4 +23,4 @@ public override string PluginName /// [DataMember, Description] public List PropertyConfigs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeStrategy.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeStrategy.cs index 8783ef3d0c..c9a4c52ef6 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericRecipeStrategy.cs @@ -43,4 +43,4 @@ public override Task LoadRecipeAsync(IGenericColumns source, IProductRecipe targ EntityMapper.ReadValue(source, target); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeConfiguration.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeConfiguration.cs index d8b9120ee5..bd72f51bb4 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeConfiguration.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeConfiguration.cs @@ -27,4 +27,4 @@ public override string PluginName /// [DataMember, Description] public List PropertyConfigs { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeStrategy.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeStrategy.cs index 10f3fd5b46..e3757078cf 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/GenericTypeStrategy.cs @@ -53,4 +53,4 @@ public override Task LoadTypeAsync(IGenericColumns source, ProductType target, C EntityMapper.ReadValue(source, target); return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapper.cs index a5d66b1848..27c50eddd7 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapper.cs @@ -24,4 +24,4 @@ public interface IGenericMapper /// Write the value from the object to the database entity /// void WriteValue(object source, IGenericColumns target); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapperConfiguration.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapperConfiguration.cs index 0abd2425ec..6281dfbf47 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapperConfiguration.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/IGenericMapperConfiguration.cs @@ -12,4 +12,4 @@ internal interface IGenericMapperConfiguration : IPropertyMappedConfiguration /// Column that should be used to store all non-configured properties as JSON /// string JsonColumn { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapper.cs index a709030acf..310d89c755 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapper.cs @@ -21,4 +21,4 @@ public interface IPropertyMapper : IConfiguredPlugin, IGen /// Convert a given property value into a database binary expression searching for that value /// Expression ToColumnExpression(ParameterExpression columnParam, ExpressionType type, object value); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapperFactory.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapperFactory.cs index 191c8f5bd8..430157f33b 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapperFactory.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/IPropertyMapperFactory.cs @@ -20,4 +20,4 @@ internal interface IPropertyMapperFactory /// Destroy a mapper instance /// void Destroy(IPropertyMapper instance); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/IntegerColumnMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/IntegerColumnMapper.cs index 922f134817..0f3463a18c 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/IntegerColumnMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/IntegerColumnMapper.cs @@ -31,16 +31,24 @@ protected override IPropertyAccessor CreatePropertyAccessor(Proper } if (objectProp.PropertyType == typeof(DateTime)) + { return new ConversionAccessor(objectProp, dt => dt.Ticks, DateTime.FromBinary); + } if (objectProp.PropertyType == typeof(DateOnly)) + { return new ConversionAccessor(objectProp, d => d.DayNumber, l => DateOnly.FromDayNumber((int)l)); + } if (objectProp.PropertyType == typeof(TimeOnly)) + { return new ConversionAccessor(objectProp, t => t.Ticks, l => new TimeOnly(l)); + } if (objectProp.PropertyType == typeof(bool)) + { return new ConversionAccessor(objectProp, v => v ? 1 : 0, l => l > 0); + } return base.CreatePropertyAccessor(objectProp); } @@ -48,19 +56,29 @@ protected override IPropertyAccessor CreatePropertyAccessor(Proper protected override object ToExpressionValue(object value) { if (Property.PropertyType.IsEnum) + { return ReadEnum(value); + } if (Property.PropertyType == typeof(DateTime)) + { return ((DateTime)value).Ticks; + } if (Property.PropertyType == typeof(DateOnly)) + { return (long)((DateOnly)value).DayNumber; + } if (Property.PropertyType == typeof(TimeOnly)) + { return ((TimeOnly)value).Ticks; + } if (Property.PropertyType == typeof(bool)) + { return (bool)value ? 1L : 0L; + } return base.ToExpressionValue(value); } diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/NullPropertyMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/NullPropertyMapper.cs index 77413148d3..03b0119329 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/NullPropertyMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/NullPropertyMapper.cs @@ -55,4 +55,4 @@ public Expression ToColumnExpression(ParameterExpression columnParam, Expression { return Expression.Constant(true); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapper.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapper.cs index 3031028b9f..5e2cddbfae 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapper.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapper.cs @@ -49,14 +49,18 @@ public void Initialize(PropertyMapperConfig config) // Create accessor for the column property Column = typeof(IGenericColumns).GetProperty(config.Column); if (Column == null || Column.PropertyType != typeof(TColumn)) + { throw new ArgumentException($"Column not found or type mismatch {config.PropertyName}."); + } ColumnAccessor = ReflectionTool.PropertyAccessor(Column); // Retrieve and validate properties Property = TargetType.GetProperty(config.PropertyName); if (Property == null) + { throw new ArgumentException($"Target type {TargetType.Name} does not have a property {config.PropertyName}."); + } // Create delegates for the object property as well ObjectAccessor = CreatePropertyAccessor(Property); @@ -109,7 +113,9 @@ public bool HasChanged(IGenericColumns current, object updated) var columnValue = ColumnAccessor.ReadProperty(current); if (columnValue == null) + { return objectValue != null; + } return !columnValue.Equals(objectValue); } diff --git a/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapperConfig.cs b/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapperConfig.cs index 49e53517f4..7a2140ef11 100644 --- a/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapperConfig.cs +++ b/src/Moryx.Products.Management/Plugins/GenericStrategies/PropertyMapperConfig.cs @@ -35,4 +35,4 @@ public override string ToString() { return $"{PropertyName}=>{Column}({PluginName})"; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/Importers/DefaultImporter.cs b/src/Moryx.Products.Management/Plugins/Importers/DefaultImporter.cs index db70f26c7d..5b2c46714a 100644 --- a/src/Moryx.Products.Management/Plugins/Importers/DefaultImporter.cs +++ b/src/Moryx.Products.Management/Plugins/Importers/DefaultImporter.cs @@ -42,4 +42,4 @@ public class DefaultImporterParameters : PrototypeParameters [DisplayName("Product type"), Description("Type of product to import")] [Required, PossibleTypes(typeof(ProductType))] public string ProductType { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/NullStrategies/PropertylessStrategyConfigurationAttribute.cs b/src/Moryx.Products.Management/Plugins/NullStrategies/PropertylessStrategyConfigurationAttribute.cs index 0633c3775b..b0993e5651 100644 --- a/src/Moryx.Products.Management/Plugins/NullStrategies/PropertylessStrategyConfigurationAttribute.cs +++ b/src/Moryx.Products.Management/Plugins/NullStrategies/PropertylessStrategyConfigurationAttribute.cs @@ -29,4 +29,4 @@ public override int TypeCompliance(Type targetType) return targetProps.All(baseProperties.Contains) ? PerfectMatch : BadCompliance; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/NullStrategies/SimpleLinkStrategy.cs b/src/Moryx.Products.Management/Plugins/NullStrategies/SimpleLinkStrategy.cs index 2565892cd8..d1b745d77c 100644 --- a/src/Moryx.Products.Management/Plugins/NullStrategies/SimpleLinkStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/NullStrategies/SimpleLinkStrategy.cs @@ -25,4 +25,4 @@ public override Task SavePartLinkAsync(ProductPartLink source, IGenericColumns t // We have no custom properties return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/Plugins/NullStrategies/SkipInstancesStrategy.cs b/src/Moryx.Products.Management/Plugins/NullStrategies/SkipInstancesStrategy.cs index c8199196b6..ef7516450c 100644 --- a/src/Moryx.Products.Management/Plugins/NullStrategies/SkipInstancesStrategy.cs +++ b/src/Moryx.Products.Management/Plugins/NullStrategies/SkipInstancesStrategy.cs @@ -49,4 +49,4 @@ public sealed override Task LoadInstanceAsync(IGenericColumns source, ProductIns // Nothing return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Management/TypeTool.cs b/src/Moryx.Products.Management/TypeTool.cs index 2a8d7feeb8..2e6af8cfbb 100644 --- a/src/Moryx.Products.Management/TypeTool.cs +++ b/src/Moryx.Products.Management/TypeTool.cs @@ -11,8 +11,11 @@ public static object CreateInstance(string typeName) { var type = ReflectionTool.GetPublicClasses(t => t.Name == typeName).FirstOrDefault(); if (type == null) + { return null; + } + var obj = Activator.CreateInstance(type); return obj; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Importer/FileImporterConfig.cs b/src/Moryx.Products.Samples/Importer/FileImporterConfig.cs index 799c83d2f5..346c9238fa 100644 --- a/src/Moryx.Products.Samples/Importer/FileImporterConfig.cs +++ b/src/Moryx.Products.Samples/Importer/FileImporterConfig.cs @@ -13,4 +13,4 @@ public class FileImporterConfig : ProductImporterConfig /// Name of the component represented by this entry /// public override string PluginName => nameof(FileImporter); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Importer/JsonProductTypeImporter.cs b/src/Moryx.Products.Samples/Importer/JsonProductTypeImporter.cs index 12c299785a..8582641a40 100644 --- a/src/Moryx.Products.Samples/Importer/JsonProductTypeImporter.cs +++ b/src/Moryx.Products.Samples/Importer/JsonProductTypeImporter.cs @@ -53,8 +53,7 @@ protected override Task ImportAsync(ProductImportContext ComplexData1 = new ComplexData() }; - - var result = new ProductImporterResult + _ = new ProductImporterResult { ImportedTypes = [product] }; diff --git a/src/Moryx.Products.Samples/Importer/WatchImporter.cs b/src/Moryx.Products.Samples/Importer/WatchImporter.cs index 8962e56e67..3a098235df 100644 --- a/src/Moryx.Products.Samples/Importer/WatchImporter.cs +++ b/src/Moryx.Products.Samples/Importer/WatchImporter.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel.DataAnnotations; +using Moryx.AbstractionLayer.Products; using Moryx.Modules; using Moryx.Products.Management; -using Moryx.AbstractionLayer.Products; namespace Moryx.Products.Samples; @@ -50,4 +50,4 @@ public class SpecializedWatchImportParameters : PrototypeParameters [Required] public string MinuteNeedleIdentifier { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Importer/WatchImporterConfig.cs b/src/Moryx.Products.Samples/Importer/WatchImporterConfig.cs index 7b1477d415..83495ac8f6 100644 --- a/src/Moryx.Products.Samples/Importer/WatchImporterConfig.cs +++ b/src/Moryx.Products.Samples/Importer/WatchImporterConfig.cs @@ -13,4 +13,4 @@ public class WatchImporterConfig : ProductImporterConfig /// Name of the component represented by this entry /// public override string PluginName => nameof(WatchImporter); -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductInstances/NeedleInstance.cs b/src/Moryx.Products.Samples/ProductInstances/NeedleInstance.cs index 49a38cce7e..84723cc7ca 100644 --- a/src/Moryx.Products.Samples/ProductInstances/NeedleInstance.cs +++ b/src/Moryx.Products.Samples/ProductInstances/NeedleInstance.cs @@ -8,4 +8,4 @@ namespace Moryx.Products.Samples; public class NeedleInstance : ProductInstance { public NeedleRole Role { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductInstances/WatchInstance.cs b/src/Moryx.Products.Samples/ProductInstances/WatchInstance.cs index f8629cf7f5..46810f68c0 100644 --- a/src/Moryx.Products.Samples/ProductInstances/WatchInstance.cs +++ b/src/Moryx.Products.Samples/ProductInstances/WatchInstance.cs @@ -17,4 +17,4 @@ public class WatchInstance : ProductInstance, IIdentifiableObject public WatchFaceInstance WatchFace { get; set; } public ICollection Needles { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductInstances/WatchPackageInstance.cs b/src/Moryx.Products.Samples/ProductInstances/WatchPackageInstance.cs index 0e6f705bf2..cea6fe3bca 100644 --- a/src/Moryx.Products.Samples/ProductInstances/WatchPackageInstance.cs +++ b/src/Moryx.Products.Samples/ProductInstances/WatchPackageInstance.cs @@ -14,4 +14,4 @@ public class WatchPackageInstance : ProductInstance /// Reference to the watch packed in this box /// public WatchInstance PackedWatch { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductInstances/WatchfaceInstance.cs b/src/Moryx.Products.Samples/ProductInstances/WatchfaceInstance.cs index 675595cb1b..18b08e1af9 100644 --- a/src/Moryx.Products.Samples/ProductInstances/WatchfaceInstance.cs +++ b/src/Moryx.Products.Samples/ProductInstances/WatchfaceInstance.cs @@ -17,4 +17,4 @@ public WatchFaceInstance() Identifier = Guid.NewGuid(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/NeedlePartLink.cs b/src/Moryx.Products.Samples/ProductTypes/NeedlePartLink.cs index 1212853be1..60b809716a 100644 --- a/src/Moryx.Products.Samples/ProductTypes/NeedlePartLink.cs +++ b/src/Moryx.Products.Samples/ProductTypes/NeedlePartLink.cs @@ -25,4 +25,4 @@ public override ProductInstance Instantiate() needle.Role = Role; return needle; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/NeedleRole.cs b/src/Moryx.Products.Samples/ProductTypes/NeedleRole.cs index c2ec76abd9..b90f83e7d5 100644 --- a/src/Moryx.Products.Samples/ProductTypes/NeedleRole.cs +++ b/src/Moryx.Products.Samples/ProductTypes/NeedleRole.cs @@ -27,4 +27,4 @@ public enum NeedleRole /// Needle is used for a dedicated stopwatch /// Stopwatch -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/NeedleType.cs b/src/Moryx.Products.Samples/ProductTypes/NeedleType.cs index 346c61fbca..0558c4e9bb 100644 --- a/src/Moryx.Products.Samples/ProductTypes/NeedleType.cs +++ b/src/Moryx.Products.Samples/ProductTypes/NeedleType.cs @@ -16,4 +16,4 @@ protected override ProductInstance Instantiate() { return new NeedleInstance(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/WatchPackageType.cs b/src/Moryx.Products.Samples/ProductTypes/WatchPackageType.cs index 7f2b2a4600..b3ab546859 100644 --- a/src/Moryx.Products.Samples/ProductTypes/WatchPackageType.cs +++ b/src/Moryx.Products.Samples/ProductTypes/WatchPackageType.cs @@ -22,4 +22,4 @@ protected override ProductInstance Instantiate() { return new WatchPackageInstance(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/WatchType.cs b/src/Moryx.Products.Samples/ProductTypes/WatchType.cs index 017536b3e4..f3531c1706 100644 --- a/src/Moryx.Products.Samples/ProductTypes/WatchType.cs +++ b/src/Moryx.Products.Samples/ProductTypes/WatchType.cs @@ -32,4 +32,4 @@ protected override ProductInstance Instantiate() Needles = Needles.Instantiate() }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/ProductTypes/WatchfaceType.cs b/src/Moryx.Products.Samples/ProductTypes/WatchfaceType.cs index ad8ce6c3c5..2a077071df 100644 --- a/src/Moryx.Products.Samples/ProductTypes/WatchfaceType.cs +++ b/src/Moryx.Products.Samples/ProductTypes/WatchfaceType.cs @@ -43,4 +43,4 @@ protected override ProductInstance Instantiate() { return new WatchFaceInstance(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Recipe/SampleRecipe.cs b/src/Moryx.Products.Samples/Recipe/SampleRecipe.cs index 00d4cbfd8e..260d1495b4 100644 --- a/src/Moryx.Products.Samples/Recipe/SampleRecipe.cs +++ b/src/Moryx.Products.Samples/Recipe/SampleRecipe.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; using Moryx.AbstractionLayer.Recipes; using Moryx.Serialization; -using System.ComponentModel; namespace Moryx.Products.Samples.Recipe; @@ -32,4 +32,4 @@ public enum ProductionType manually, automatically, withoutAir -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Recipe/WatchProductRecipe.cs b/src/Moryx.Products.Samples/Recipe/WatchProductRecipe.cs index 02a87e53c7..be39c4de9f 100644 --- a/src/Moryx.Products.Samples/Recipe/WatchProductRecipe.cs +++ b/src/Moryx.Products.Samples/Recipe/WatchProductRecipe.cs @@ -52,4 +52,4 @@ public class CaseDescription [EntrySerialize] [DisplayName("Material")] public int CaseMaterial { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Samples/Strategies/WatchStrategy.cs b/src/Moryx.Products.Samples/Strategies/WatchStrategy.cs index 9048dcf643..4996edab53 100644 --- a/src/Moryx.Products.Samples/Strategies/WatchStrategy.cs +++ b/src/Moryx.Products.Samples/Strategies/WatchStrategy.cs @@ -96,4 +96,4 @@ public override Task SavePartLinkAsync(ProductPartLink source, IGenericColumns t return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Products.Web/Pages/Products.cshtml.cs b/src/Moryx.Products.Web/Pages/Products.cshtml.cs index 1419098e35..9cdda2afe3 100644 --- a/src/Moryx.Products.Web/Pages/Products.cshtml.cs +++ b/src/Moryx.Products.Web/Pages/Products.cshtml.cs @@ -11,4 +11,4 @@ public void OnGet() { } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/AssemblyCell.cs b/src/Moryx.Resources.Benchmarking/AssemblyCell.cs index b2f9ef9892..dfab21ef32 100644 --- a/src/Moryx.Resources.Benchmarking/AssemblyCell.cs +++ b/src/Moryx.Resources.Benchmarking/AssemblyCell.cs @@ -72,4 +72,4 @@ private void OnMessageReceived(object sender, object message) break; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/BenchmarkInitializer.cs b/src/Moryx.Resources.Benchmarking/BenchmarkInitializer.cs index 1a77cea410..5cfcea764b 100644 --- a/src/Moryx.Resources.Benchmarking/BenchmarkInitializer.cs +++ b/src/Moryx.Resources.Benchmarking/BenchmarkInitializer.cs @@ -50,4 +50,4 @@ public override Task ExecuteAsync(IResourceGraph grap return InitializedAsync([reporter]); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/BenchmarkReporter.cs b/src/Moryx.Resources.Benchmarking/BenchmarkReporter.cs index 3a16f05267..465abf6a22 100644 --- a/src/Moryx.Resources.Benchmarking/BenchmarkReporter.cs +++ b/src/Moryx.Resources.Benchmarking/BenchmarkReporter.cs @@ -10,9 +10,9 @@ using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.VisualInstructions; -using Moryx.VisualInstructions; using Moryx.Serialization; using Moryx.Threading; +using Moryx.VisualInstructions; namespace Moryx.Resources.Benchmarking; @@ -109,7 +109,9 @@ private void LogValues() { var reports = BenchmarkCells.Select(r => r.GetReport()).Where(r => r.ActivityCount > 0).ToArray(); if (reports.Length == 0) + { return; // Machine idle + } var total = reports.Sum(r => r.ActivityCount); var avgRtwWait = reports.Average(r => r.ReadyToWorkWait / r.ActivityCount); @@ -119,4 +121,4 @@ private void LogValues() "Total: {0} activities/second - ReadyToWorkWait: {1:F2}ms - ActivityCompletedWait: {2:F2}ms", total, avgRtwWait, avgAcWait); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/BenchmarkReporterConfig.cs b/src/Moryx.Resources.Benchmarking/BenchmarkReporterConfig.cs index d7f2494971..4158053578 100644 --- a/src/Moryx.Resources.Benchmarking/BenchmarkReporterConfig.cs +++ b/src/Moryx.Resources.Benchmarking/BenchmarkReporterConfig.cs @@ -8,4 +8,4 @@ namespace Moryx.Resources.Benchmarking; [DataContract] public class BenchmarkReporterConfig { -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/BenchmarkResource.cs b/src/Moryx.Resources.Benchmarking/BenchmarkResource.cs index 19572fc320..56df8c12ad 100644 --- a/src/Moryx.Resources.Benchmarking/BenchmarkResource.cs +++ b/src/Moryx.Resources.Benchmarking/BenchmarkResource.cs @@ -234,7 +234,9 @@ public void AcknowledgeLastNotification() { var notifications = NotificationAdapter.GetPublished(this); if (notifications.Any()) + { NotificationAdapter.Acknowledge(this, notifications.Last()); + } } [EntrySerialize] diff --git a/src/Moryx.Resources.Benchmarking/IBenchmarkResource.cs b/src/Moryx.Resources.Benchmarking/IBenchmarkResource.cs index 28d834d78b..bf4fd0efa0 100644 --- a/src/Moryx.Resources.Benchmarking/IBenchmarkResource.cs +++ b/src/Moryx.Resources.Benchmarking/IBenchmarkResource.cs @@ -35,4 +35,4 @@ public struct BenchmarkReport /// Time spent waiting for an ActivityCompleted response /// public long ActivityCompletionWait; -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/Messages/AssembleProductMessage.cs b/src/Moryx.Resources.Benchmarking/Messages/AssembleProductMessage.cs index 683f350dca..97ec235da9 100644 --- a/src/Moryx.Resources.Benchmarking/Messages/AssembleProductMessage.cs +++ b/src/Moryx.Resources.Benchmarking/Messages/AssembleProductMessage.cs @@ -9,4 +9,4 @@ namespace Moryx.Resources.Benchmarking.Messages; public class AssembleProductMessage { public long ActivityId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/Messages/AssemblyCompletedMessage.cs b/src/Moryx.Resources.Benchmarking/Messages/AssemblyCompletedMessage.cs index 57692b220d..e3ce878b8a 100644 --- a/src/Moryx.Resources.Benchmarking/Messages/AssemblyCompletedMessage.cs +++ b/src/Moryx.Resources.Benchmarking/Messages/AssemblyCompletedMessage.cs @@ -12,4 +12,4 @@ public class AssemblyCompletedMessage /// Result of the completed activity, that can be mapped to its enum value /// public int Result { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/Messages/ReleaseWorkpiece.cs b/src/Moryx.Resources.Benchmarking/Messages/ReleaseWorkpiece.cs index a35a5d345e..154e9324eb 100644 --- a/src/Moryx.Resources.Benchmarking/Messages/ReleaseWorkpiece.cs +++ b/src/Moryx.Resources.Benchmarking/Messages/ReleaseWorkpiece.cs @@ -5,4 +5,4 @@ namespace Moryx.Resources.Benchmarking.Messages; public class ReleaseWorkpieceMessage { -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/Messages/WorkpieceArrivedMessage.cs b/src/Moryx.Resources.Benchmarking/Messages/WorkpieceArrivedMessage.cs index fd7bd64c60..2827067c0d 100644 --- a/src/Moryx.Resources.Benchmarking/Messages/WorkpieceArrivedMessage.cs +++ b/src/Moryx.Resources.Benchmarking/Messages/WorkpieceArrivedMessage.cs @@ -12,4 +12,4 @@ public class WorkpieceArrivedMessage /// Id of the process that will be started in the cell /// public long ProcessId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Benchmarking/SimulatedFakeDriver.cs b/src/Moryx.Resources.Benchmarking/SimulatedFakeDriver.cs index ca6daee14f..6ac35e161a 100644 --- a/src/Moryx.Resources.Benchmarking/SimulatedFakeDriver.cs +++ b/src/Moryx.Resources.Benchmarking/SimulatedFakeDriver.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Resources; using Moryx.AbstractionLayer.Activities; -using Moryx.ControlSystem.Cells; -using Moryx.AbstractionLayer.Drivers.Message; using Moryx.AbstractionLayer.Drivers; -using Moryx.StateMachines; +using Moryx.AbstractionLayer.Drivers.Message; +using Moryx.AbstractionLayer.Resources; +using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Simulation; using Moryx.Resources.Benchmarking.Messages; +using Moryx.StateMachines; namespace Moryx.Resources.Benchmarking; @@ -52,10 +52,10 @@ public void Send(object payload) { switch (payload) { - case AssembleProductMessage assemble: + case AssembleProductMessage: SimulatedState = SimulationState.Executing; break; - case ReleaseWorkpieceMessage release: + case ReleaseWorkpieceMessage: SimulatedState = SimulationState.Idle; break; } @@ -96,4 +96,4 @@ public void ForceState(StateClassification classification) { Classification = classification; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Extensions/ResourceExtensions.cs b/src/Moryx.Resources.Management/Extensions/ResourceExtensions.cs index 18e3d813f5..4e24d56e10 100644 --- a/src/Moryx.Resources.Management/Extensions/ResourceExtensions.cs +++ b/src/Moryx.Resources.Management/Extensions/ResourceExtensions.cs @@ -25,4 +25,4 @@ public static IEnumerable Proxify(this IEnumerableType of the resource /// Identifier for the type internal static string ResourceType(this Type resourceType) => resourceType.FullName; -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Facades/ResourceManagementFacade.cs b/src/Moryx.Resources.Management/Facades/ResourceManagementFacade.cs index 3e3454d86a..60c2765b7d 100644 --- a/src/Moryx.Resources.Management/Facades/ResourceManagementFacade.cs +++ b/src/Moryx.Resources.Management/Facades/ResourceManagementFacade.cs @@ -126,7 +126,6 @@ public async Task CreateUnsafeAsync(Type resourceType, Func(long id, Func accessor) { ValidateHealthState(); @@ -143,11 +142,15 @@ public async Task ModifyUnsafeAsync(long id, Func> modifier var resource = ResourceGraph.Get(id); if (resource == null) + { throw new KeyNotFoundException($"No resource with Id {id} found."); + } var result = await modifier(resource); if (result) + { await ResourceGraph.SaveAsync(resource, cancellationToken); + } } public async Task DeleteAsync(long id, CancellationToken cancellationToken = default) @@ -156,7 +159,9 @@ public async Task DeleteAsync(long id, CancellationToken cancellationToken var resource = ResourceGraph.Get(id); if (resource == null) + { return false; + } return await ResourceGraph.DestroyAsync(resource, cancellationToken); } @@ -179,9 +184,8 @@ public async Task ExecuteInitializerAsync(ResourceInitializerConfig initializerC { ValidateHealthState(); - var initializer =await InitializerFactory.Create(initializerConfig, cancellationToken); - - var result = await ResourceManager.ExecuteInitializer(initializer, parameters); + var initializer = await InitializerFactory.Create(initializerConfig, cancellationToken); + _ = await ResourceManager.ExecuteInitializer(initializer, parameters); InitializerFactory.Destroy(initializer); } diff --git a/src/Moryx.Resources.Management/Facades/ResourceTypeTreeFacade.cs b/src/Moryx.Resources.Management/Facades/ResourceTypeTreeFacade.cs index 63e86c8266..02c643bd25 100644 --- a/src/Moryx.Resources.Management/Facades/ResourceTypeTreeFacade.cs +++ b/src/Moryx.Resources.Management/Facades/ResourceTypeTreeFacade.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Resources; @@ -27,4 +27,4 @@ public IEnumerable SupportedTypes(ICollection constrain { return TypeTree.SupportedTypes(constraints); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/API/IResourceRelationRepository.cs b/src/Moryx.Resources.Management/Model/API/IResourceRelationRepository.cs index 5e07768a50..3f5d7d811e 100644 --- a/src/Moryx.Resources.Management/Model/API/IResourceRelationRepository.cs +++ b/src/Moryx.Resources.Management/Model/API/IResourceRelationRepository.cs @@ -14,4 +14,4 @@ public interface IResourceRelationRepository : IRepository ResourceRelationEntity Create(int relationType); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/API/IResourceRepository.cs b/src/Moryx.Resources.Management/Model/API/IResourceRepository.cs index f8758ce524..a19f35b7ab 100644 --- a/src/Moryx.Resources.Management/Model/API/IResourceRepository.cs +++ b/src/Moryx.Resources.Management/Model/API/IResourceRepository.cs @@ -14,4 +14,4 @@ public interface IResourceRepository : IRepository /// Creates instance with all not nullable properties prefilled /// ResourceEntity Create(string name, string type); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/Entities/ResourceEntity.cs b/src/Moryx.Resources.Management/Model/Entities/ResourceEntity.cs index 6464fb0897..41a0b01c61 100644 --- a/src/Moryx.Resources.Management/Model/Entities/ResourceEntity.cs +++ b/src/Moryx.Resources.Management/Model/Entities/ResourceEntity.cs @@ -19,4 +19,4 @@ public class ResourceEntity : ModificationTrackedEntityBase public virtual ICollection Targets { get; set; } public virtual ICollection Sources { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/Entities/ResourceRelationEntity.cs b/src/Moryx.Resources.Management/Model/Entities/ResourceRelationEntity.cs index 4c701d961c..01ce422418 100644 --- a/src/Moryx.Resources.Management/Model/Entities/ResourceRelationEntity.cs +++ b/src/Moryx.Resources.Management/Model/Entities/ResourceRelationEntity.cs @@ -21,4 +21,4 @@ public class ResourceRelationEntity : EntityBase public virtual ResourceEntity Source { get; set; } public virtual ResourceEntity Target { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20211104134830_InitialCreate.cs b/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20211104134830_InitialCreate.cs index 8a9ba05d0c..652cf96785 100644 --- a/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20211104134830_InitialCreate.cs +++ b/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20211104134830_InitialCreate.cs @@ -97,4 +97,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Resources", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20251124065017_UpdateEf10.cs b/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20251124065017_UpdateEf10.cs index 46d67bd163..5571ab9444 100644 --- a/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20251124065017_UpdateEf10.cs +++ b/src/Moryx.Resources.Management/Model/Migrations/Npgsql/20251124065017_UpdateEf10.cs @@ -1,7 +1,6 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -74,4 +73,4 @@ protected override void Down(MigrationBuilder migrationBuilder) oldClrType: typeof(DateTime), oldType: "timestamp with time zone"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/Migrations/Sqlite/20230215071938_InitialCreate.cs b/src/Moryx.Resources.Management/Model/Migrations/Sqlite/20230215071938_InitialCreate.cs index b741b23506..b7b47b8120 100644 --- a/src/Moryx.Resources.Management/Model/Migrations/Sqlite/20230215071938_InitialCreate.cs +++ b/src/Moryx.Resources.Management/Model/Migrations/Sqlite/20230215071938_InitialCreate.cs @@ -98,4 +98,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Resources", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/NpgsqlResourcesContext.cs b/src/Moryx.Resources.Management/Model/NpgsqlResourcesContext.cs index 49b7ab8dce..9017c9b018 100644 --- a/src/Moryx.Resources.Management/Model/NpgsqlResourcesContext.cs +++ b/src/Moryx.Resources.Management/Model/NpgsqlResourcesContext.cs @@ -21,4 +21,4 @@ public NpgsqlResourcesContext() public NpgsqlResourcesContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/ResourcesContext.cs b/src/Moryx.Resources.Management/Model/ResourcesContext.cs index 466dd57a31..0131cfffe7 100644 --- a/src/Moryx.Resources.Management/Model/ResourcesContext.cs +++ b/src/Moryx.Resources.Management/Model/ResourcesContext.cs @@ -53,4 +53,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasMany(r => r.Targets) .WithOne(r => r.Source).IsRequired(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Model/SqliteResourcesContext.cs b/src/Moryx.Resources.Management/Model/SqliteResourcesContext.cs index dd3b13ade9..04b4a7ddbc 100644 --- a/src/Moryx.Resources.Management/Model/SqliteResourcesContext.cs +++ b/src/Moryx.Resources.Management/Model/SqliteResourcesContext.cs @@ -21,4 +21,4 @@ public SqliteResourcesContext() public SqliteResourcesContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/ModuleController/ModuleConfig.cs b/src/Moryx.Resources.Management/ModuleController/ModuleConfig.cs index def9ab8df9..0b9e5781ce 100644 --- a/src/Moryx.Resources.Management/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Resources.Management/ModuleController/ModuleConfig.cs @@ -28,4 +28,4 @@ public override void Initialize() base.Initialize(); Initializers = new List(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/ModuleController/ModuleConsole.cs b/src/Moryx.Resources.Management/ModuleController/ModuleConsole.cs index be4e6f6384..a35f04680a 100644 --- a/src/Moryx.Resources.Management/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Resources.Management/ModuleController/ModuleConsole.cs @@ -41,7 +41,7 @@ public string CallResourceInitializer([PluginConfigs(typeof(IResourceInitializer } catch (Exception e) { - Logger.LogError(e,"Resource initializer failed for plugin {Plugin}",config.PluginName); + Logger.LogError(e, "Resource initializer failed for plugin {Plugin}", config.PluginName); return $"{config.PluginName} failed to run: {e.Message}"; } } diff --git a/src/Moryx.Resources.Management/Properties/AssemblyInfo.cs b/src/Moryx.Resources.Management/Properties/AssemblyInfo.cs index ecdecdf180..e34f6ea2ee 100644 --- a/src/Moryx.Resources.Management/Properties/AssemblyInfo.cs +++ b/src/Moryx.Resources.Management/Properties/AssemblyInfo.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Runtime.CompilerServices; -using Moryx.Resources.Management; [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: InternalsVisibleTo("Moryx.Resources.IntegrationTests")] diff --git a/src/Moryx.Resources.Management/Resources/IManagedResourceGraph.cs b/src/Moryx.Resources.Management/Resources/IManagedResourceGraph.cs index 3b59fe065b..7796be7996 100644 --- a/src/Moryx.Resources.Management/Resources/IManagedResourceGraph.cs +++ b/src/Moryx.Resources.Management/Resources/IManagedResourceGraph.cs @@ -43,4 +43,4 @@ internal interface IManagedResourceGraph : IResourceGraph /// TODO: Find a better way /// Func> DestroyDelegate { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/IResourceFactory.cs b/src/Moryx.Resources.Management/Resources/IResourceFactory.cs index 7bef6d569f..48ef367cd3 100644 --- a/src/Moryx.Resources.Management/Resources/IResourceFactory.cs +++ b/src/Moryx.Resources.Management/Resources/IResourceFactory.cs @@ -22,4 +22,4 @@ internal interface IResourceFactory /// Machs kaputt! /// void Destroy(IResource resource); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/IResourceInitializerFactory.cs b/src/Moryx.Resources.Management/Resources/IResourceInitializerFactory.cs index c4478208b3..4e3f858c2a 100644 --- a/src/Moryx.Resources.Management/Resources/IResourceInitializerFactory.cs +++ b/src/Moryx.Resources.Management/Resources/IResourceInitializerFactory.cs @@ -21,4 +21,4 @@ internal interface IResourceInitializerFactory /// Destroys an /// void Destroy(IResourceInitializer resourceInitializer); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/IResourceLinker.cs b/src/Moryx.Resources.Management/Resources/IResourceLinker.cs index 7f61f26117..a8ab6db24e 100644 --- a/src/Moryx.Resources.Management/Resources/IResourceLinker.cs +++ b/src/Moryx.Resources.Management/Resources/IResourceLinker.cs @@ -45,4 +45,4 @@ internal interface IResourceLinker /// Resource that is being deleted /// Resource referencing the deleted instance void RemoveLinking(IResource deletedInstance, IResource reference); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/IResourceManager.cs b/src/Moryx.Resources.Management/Resources/IResourceManager.cs index ecf428df9c..59f8ae0eaa 100644 --- a/src/Moryx.Resources.Management/Resources/IResourceManager.cs +++ b/src/Moryx.Resources.Management/Resources/IResourceManager.cs @@ -41,4 +41,4 @@ internal interface IResourceManager : IAsyncInitializablePlugin /// Raised when the capabilities have changed. /// event EventHandler CapabilitiesChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/IResourceTypeController.cs b/src/Moryx.Resources.Management/Resources/IResourceTypeController.cs index 6d7e80325b..21c1f44aa2 100644 --- a/src/Moryx.Resources.Management/Resources/IResourceTypeController.cs +++ b/src/Moryx.Resources.Management/Resources/IResourceTypeController.cs @@ -40,4 +40,4 @@ internal interface IResourceTypeController : IPlugin /// Find all resource type trees that implement the given type constraints /// IEnumerable SupportedTypes(ICollection constraints); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/ResourceEntityAccessor.cs b/src/Moryx.Resources.Management/Resources/ResourceEntityAccessor.cs index 127d6a510d..8b4315bfbf 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceEntityAccessor.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceEntityAccessor.cs @@ -90,12 +90,20 @@ public static async Task SaveToEntity(IUnitOfWork uow, Resource // All those checks are necessary since EF change tracker does not recognize equal values as such if (entity.Name != instance.Name) + { entity.Name = instance.Name; + } + if (entity.Description != instance.Description) + { entity.Description = instance.Description; + } + var extensionData = JsonConvert.SerializeObject(instance, JsonSettings.Minimal); if (entity.ExtensionData != extensionData) + { entity.ExtensionData = extensionData; + } return entity; } @@ -109,8 +117,8 @@ public static async Task> FetchResourceTempl var resources = await (from res in resourceRepo.Linq - where res.Deleted == null - select res) + where res.Deleted == null + select res) .ToListAsync(); var resourceEntityAccessors = resources @@ -123,13 +131,13 @@ public static async Task> FetchResourceTempl Description = res.Description, ExtensionData = res.ExtensionData, Relations = (from target in res.Targets - where target.Target.Deleted == null - // Attention: This is Copy&Paste because of LinQ limitations - select new ResourceRelationAccessor - { - Entity = target, - Role = ResourceReferenceRole.Target, - }).Concat( + where target.Target.Deleted == null + // Attention: This is Copy&Paste because of LinQ limitations + select new ResourceRelationAccessor + { + Entity = target, + Role = ResourceReferenceRole.Target, + }).Concat( from source in res.Sources where source.Source.Deleted == null // Attention: This is Copy&Paste because of LinQ limitations @@ -194,17 +202,19 @@ internal class ResourceRelationAccessor public static async Task> FromEntity(IUnitOfWork uow, ResourceEntity entity) { if (entity.Id <= 0) + { return Array.Empty(); + } var relationRepo = uow.GetRepository(); var result = (from target in relationRepo.Linq - where target.Target.Deleted == null && target.SourceId == entity.Id - // Attention: This is Copy&Paste because of LinQ limitations - select new ResourceRelationAccessor - { - Entity = target, - Role = ResourceReferenceRole.Target, - }).Concat( + where target.Target.Deleted == null && target.SourceId == entity.Id + // Attention: This is Copy&Paste because of LinQ limitations + select new ResourceRelationAccessor + { + Entity = target, + Role = ResourceReferenceRole.Target, + }).Concat( from source in relationRepo.Linq where source.Source.Deleted == null && source.TargetId == entity.Id // Attention: This is Copy&Paste because of LinQ limitations @@ -222,13 +232,13 @@ from source in relationRepo.Linq public static ICollection FromQueryable(IQueryable relations, ResourceEntity instance) { var result = (from target in relations - where target.Target.Deleted == null && target.Source == instance - // Attention: This is Copy&Paste because of LinQ limitations - select new ResourceRelationAccessor - { - Entity = target, - Role = ResourceReferenceRole.Target, - }).Concat( + where target.Target.Deleted == null && target.Source == instance + // Attention: This is Copy&Paste because of LinQ limitations + select new ResourceRelationAccessor + { + Entity = target, + Role = ResourceReferenceRole.Target, + }).Concat( from source in relations where source.Source.Deleted == null && source.Target == instance // Attention: This is Copy&Paste because of LinQ limitations @@ -239,4 +249,4 @@ from source in relations }).ToList(); return result; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/ResourceGraph.cs b/src/Moryx.Resources.Management/Resources/ResourceGraph.cs index a57b7e6044..b69a9d4d78 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceGraph.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceGraph.cs @@ -92,7 +92,9 @@ public TResource GetResource(Func predicate) // Return a single resource var match = GetResources(predicate).SingleOrDefault(); if (match == null) + { throw new ResourceNotFoundException(); + } return match; } @@ -107,9 +109,9 @@ public IEnumerable GetResources(Func pred IEnumerable matches; _graphLock.EnterReadLock(); matches = from resource in _graph.Values - let target = resource as TResource - where target != null && predicate(target) - select target; + let target = resource as TResource + where target != null && predicate(target) + select target; _graphLock.ExitReadLock(); return matches; diff --git a/src/Moryx.Resources.Management/Resources/ResourceLinker.cs b/src/Moryx.Resources.Management/Resources/ResourceLinker.cs index a1323348c5..217f3f33c4 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceLinker.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceLinker.cs @@ -492,7 +492,7 @@ public void RemoveLinking(IResource deletedInstance, IResource reference) // Try to find a property on the reference back-linking to the deleted instance var type = reference.GetType(); var backReference = (from property in ReferenceProperties(type, false) - // Instead of comparing the resource type we simply look for the object reference + // Instead of comparing the resource type we simply look for the object reference let value = property.GetValue(reference) where value == deletedInstance || ((value as IEnumerable)?.Contains(deletedInstance) ?? false) select property).FirstOrDefault(); diff --git a/src/Moryx.Resources.Management/Resources/ResourceManager.cs b/src/Moryx.Resources.Management/Resources/ResourceManager.cs index 63fc31ade3..54131a2aa2 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceManager.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceManager.cs @@ -130,7 +130,9 @@ public async Task InitializeAsync(CancellationToken cancellationToken = default) // Create all objects var allResources = await ResourceEntityAccessor.FetchResourceTemplates(uow); if (allResources.Count > 0) + { await LoadResources(allResources); + } } _startup = ResourceStartupPhase.Initializing; @@ -155,7 +157,9 @@ private async ValueTask InitializeResource(Resource resource, CancellationToken Logger.Log(LogLevel.Warning, e, "Failed to initialize resource {0}-{1}", resource.Id, resource.Name); // Track resources as failed to exclude from future calls lock (_failedResources) + { _failedResources.Add(resource); + } } } @@ -187,7 +191,9 @@ private async Task LoadResources(ICollection allResource // Register events after all links were set foreach (var resource in Graph.GetAll()) + { RegisterEvents(resource); + } } /// @@ -216,7 +222,9 @@ private async Task AddResource(Resource instance, bool registerEvents) // Register to events if (registerEvents) + { RegisterEvents(instance); + } switch (_startup) { @@ -263,7 +271,9 @@ private void RegisterEvents(Resource instance) instance.CapabilitiesChanged += RaiseCapabilitiesChanged; foreach (var autoSaveCollection in ResourceReferenceTools.GetAutoSaveCollections(instance)) + { autoSaveCollection.CollectionChanged += OnAutoSaveCollectionChanged; + } } /// @@ -275,7 +285,9 @@ private void UnregisterEvents(Resource instance) instance.CapabilitiesChanged -= RaiseCapabilitiesChanged; foreach (var autoSaveCollection in ResourceReferenceTools.GetAutoSaveCollections(instance)) + { autoSaveCollection.CollectionChanged -= OnAutoSaveCollectionChanged; + } } /// @@ -343,7 +355,9 @@ public async Task SaveAsync(Resource resource) var saveResult = await ResourceEntityAccessor.SaveToEntity(uow, resource); var entity = saveResult; if (uow.IsLinked(resource)) + { newResources.Add(resource); + } var references = new Dictionary(); var newInstances = await ResourceLinker.SaveReferencesAsync(uow, resource, entity, references); @@ -356,7 +370,10 @@ public async Task SaveAsync(Resource resource) foreach (var instance in newResources) { if (!references.TryGetValue(instance, out var reference)) + { continue; + } + instance.Id = reference.Id; } @@ -368,7 +385,9 @@ public async Task SaveAsync(Resource resource) } foreach (var instance in newResources) + { await AddResource(instance, true); + } if (!isNew) { @@ -471,7 +490,9 @@ public async Task Destroy(IResource resource, bool permanent) ResourceLinker.RemoveLinking(resource, reference); if (permanent) + { relationRepository.Remove(relation.Entity); + } } resourceRepository.Remove(entity, permanent); @@ -487,7 +508,9 @@ public async Task Destroy(IResource resource, bool permanent) // Notify listeners about the removal of the resource if (removed) + { RaiseResourceRemoved(instance); + } // Destroy the object TypeController.Destroy(instance); @@ -523,7 +546,9 @@ private void RaiseResourceChanged(IResource changedResource) private void RaiseCapabilitiesChanged(object originalSender, ICapabilities capabilities) { if (Graph.GetAll().Any(x => x.Id == ((IResource)originalSender).Id)) + { CapabilitiesChanged?.Invoke(originalSender, capabilities); + } } #endregion diff --git a/src/Moryx.Resources.Management/Resources/ResourceReferenceTools.cs b/src/Moryx.Resources.Management/Resources/ResourceReferenceTools.cs index 66e1a5fb5d..fd1e0f8cd4 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceReferenceTools.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceReferenceTools.cs @@ -24,11 +24,15 @@ public static void InitializeCollections(Resource instance) { var attribute = property.GetCustomAttribute(); if (attribute == null) + { // Create collection and set on property CreateCollection(instance, property); + } else + { // Save overrides for later overrides[property] = attribute; + } } // Now set the reference overrides @@ -56,11 +60,15 @@ private static void CreateCollection(Resource instance, PropertyInfo property, I { // Set target property to property if it is not given if (targetProperty == null) + { targetProperty = property; + } // Create underlying collection if it is not given if (underlyingCollection == null) + { underlyingCollection = new List(); + } var propertyType = property.PropertyType; var referenceType = propertyType.GetGenericArguments()[0]; // Type of resource from ICollection @@ -77,10 +85,10 @@ private static void CreateCollection(Resource instance, PropertyInfo property, I public static ICollection GetAutoSaveCollections(Resource instance) { return (from collectionProperty in CollectionReferenceProperties(instance.GetType()) - let refAtt = collectionProperty.GetCustomAttribute() - let overrideAtt = collectionProperty.GetCustomAttribute() - where (refAtt?.AutoSave ?? false) || (overrideAtt?.AutoSave ?? false) - select (IReferenceCollection)collectionProperty.GetValue(instance)).ToList(); + let refAtt = collectionProperty.GetCustomAttribute() + let overrideAtt = collectionProperty.GetCustomAttribute() + where (refAtt?.AutoSave ?? false) || (overrideAtt?.AutoSave ?? false) + select (IReferenceCollection)collectionProperty.GetValue(instance)).ToList(); } /// @@ -89,9 +97,9 @@ public static ICollection GetAutoSaveCollections(Resource public static IEnumerable CollectionReferenceProperties(Type resourceType) { return from referenceProperty in ReferenceProperties(resourceType, true) - let propertyType = referenceProperty.PropertyType - where propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IReferences<>) - select referenceProperty; + let propertyType = referenceProperty.PropertyType + where propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(IReferences<>) + select referenceProperty; } /// @@ -100,9 +108,9 @@ public static IEnumerable CollectionReferenceProperties(Type resou public static IEnumerable ReferenceProperties(Type resourceType, bool includeOverrides) { return from property in resourceType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) - where property.CanWrite && - (Attribute.IsDefined(property, typeof(ResourceReferenceAttribute)) - || includeOverrides && Attribute.IsDefined(property, typeof(ReferenceOverrideAttribute))) - select property; + where property.CanWrite && + (Attribute.IsDefined(property, typeof(ResourceReferenceAttribute)) + || includeOverrides && Attribute.IsDefined(property, typeof(ReferenceOverrideAttribute))) + select property; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Management/Resources/ResourceTypeController.cs b/src/Moryx.Resources.Management/Resources/ResourceTypeController.cs index 28e1348585..6cd9008739 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceTypeController.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceTypeController.cs @@ -80,9 +80,15 @@ private void BuildTypeTree() do { if (buffer.IsGenericType) // Generic base types appear multiple times, use only the generic type + { buffer = buffer.GetGenericTypeDefinition(); + } + if (!allTypes.Contains(buffer)) + { allTypes.Add(buffer); + } + buffer = buffer.BaseType; } while (buffer != null && buffer != typeof(Resource)); } @@ -100,10 +106,10 @@ private ResourceTypeNode Convert(Type type, ICollection allTypes, ICollect BaseType = baseType, IsRegistered = registeredTypes.Contains(type), Constructors = (from method in type.GetMethods() - let att = method.GetCustomAttribute() - where att != null - orderby att.IsDefault descending - select method).ToArray() + let att = method.GetCustomAttribute() + where att != null + orderby att.IsDefault descending + select method).ToArray() }; // Find all derived types @@ -120,9 +126,14 @@ orderby att.IsDefault descending public Resource Create(string type) { if (!_typeCache.TryGetValue(type, out var linker)) + { throw new KeyNotFoundException($"No resource of type {type} found."); + } + if (!linker.Creatable) + { throw new InvalidOperationException($"The resource of type {type} is not creatable."); + } var instance = linker.IsRegistered ? (Resource)ResourceFactory.Create(type) // Create with factory @@ -141,9 +152,13 @@ public void Destroy(Resource instance) // Only factory instances need to be destroyed if (linker.IsRegistered) + { ResourceFactory.Destroy(instance); + } else + { ((IDisposable)instance).Dispose(); + } // If there is currently a proxy for this resource detach and destroy it var id = instance.Id; @@ -227,17 +242,17 @@ private static List RelevantInterfaces(ResourceTypeNode node) // Add all interfaces derived from IResource, including IResource itself relevantInterfaces.AddRange(from resourceInterface in interfaces - where resourceInterface.IsPublic - && (typeof(IResource).IsAssignableFrom(resourceInterface) - || additionalPublicInterfaces.Contains(resourceInterface)) - select resourceInterface); + where resourceInterface.IsPublic + && (typeof(IResource).IsAssignableFrom(resourceInterface) + || additionalPublicInterfaces.Contains(resourceInterface)) + select resourceInterface); // Add all interfaces that are NOT derived from IResource BUT part of any of the relevant interfaces relevantInterfaces.AddRange(from generalInterface in interfaces - where !generalInterface.IsAssignableFrom(typeof(IResource)) // It should not be a base type if IResource - && !relevantInterfaces.Contains(generalInterface) // It should not be part of the relevant interfaces yet - && relevantInterfaces.Any(generalInterface.IsAssignableFrom) // It is a base type of a relevant interface - select generalInterface); + where !generalInterface.IsAssignableFrom(typeof(IResource)) // It should not be a base type if IResource + && !relevantInterfaces.Contains(generalInterface) // It should not be part of the relevant interfaces yet + && relevantInterfaces.Any(generalInterface.IsAssignableFrom) // It is a base type of a relevant interface + select generalInterface); // Filter open generic interfaces (e.g. IFoo<>) that Castle cannot proxy relevantInterfaces = relevantInterfaces.Where(candidate => !candidate.IsGenericTypeDefinition).ToList(); diff --git a/src/Moryx.Resources.Management/Resources/ResourceTypeNode.cs b/src/Moryx.Resources.Management/Resources/ResourceTypeNode.cs index c5765f6d05..85f6fd4348 100644 --- a/src/Moryx.Resources.Management/Resources/ResourceTypeNode.cs +++ b/src/Moryx.Resources.Management/Resources/ResourceTypeNode.cs @@ -25,19 +25,19 @@ public Type ResourceType field = value; PropertiesOfResourceType = field.GetProperties(); ReferenceOverrides = (from prop in PropertiesOfResourceType - let overrideAtt = prop.GetCustomAttribute() - where overrideAtt != null - let targetType = typeof(IEnumerable).IsAssignableFrom(prop.PropertyType) - ? EntryConvert.ElementType(prop.PropertyType) : prop.PropertyType - group targetType by overrideAtt.Source into g - select new { g.Key, overrides = g.ToList() }).ToDictionary(v => v.Key, v => v.overrides); + let overrideAtt = prop.GetCustomAttribute() + where overrideAtt != null + let targetType = typeof(IEnumerable).IsAssignableFrom(prop.PropertyType) + ? EntryConvert.ElementType(prop.PropertyType) : prop.PropertyType + group targetType by overrideAtt.Source into g + select new { g.Key, overrides = g.ToList() }).ToDictionary(v => v.Key, v => v.overrides); References = (from prop in PropertiesOfResourceType - let propType = prop.PropertyType - // Find all properties referencing a resource or a collection of resources - // Exclude read only properties, because they are simple type overrides of other references - where prop.CanWrite && Attribute.IsDefined(prop, typeof(ResourceReferenceAttribute)) - select prop).ToList(); + let propType = prop.PropertyType + // Find all properties referencing a resource or a collection of resources + // Exclude read only properties, because they are simple type overrides of other references + where prop.CanWrite && Attribute.IsDefined(prop, typeof(ResourceReferenceAttribute)) + select prop).ToList(); } } @@ -76,4 +76,4 @@ group targetType by overrideAtt.Source into g /// public override string ToString() => $"{ResourceType.Name}(Registered={IsRegistered})"; -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/AssembleResource.cs b/src/Moryx.Resources.Samples/AssembleResource.cs index e1dfca2019..d7e8564399 100644 --- a/src/Moryx.Resources.Samples/AssembleResource.cs +++ b/src/Moryx.Resources.Samples/AssembleResource.cs @@ -63,4 +63,4 @@ public void ChangeNumber(string fooNumber) FooNumber = fooNumber; RaiseResourceChanged(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/BufferResource.cs b/src/Moryx.Resources.Samples/BufferResource.cs index fe9e59dd19..33f45b1e0c 100644 --- a/src/Moryx.Resources.Samples/BufferResource.cs +++ b/src/Moryx.Resources.Samples/BufferResource.cs @@ -32,7 +32,10 @@ public async Task RemoveValueAsync(string name) { var value = Values.FirstOrDefault(v => v.Name == name); if (value != null) + { await Graph.DestroyAsync(value, true); + } + return Values.Count; } } diff --git a/src/Moryx.Resources.Samples/Cell.cs b/src/Moryx.Resources.Samples/Cell.cs index 8a5f9cd3fc..6451650b36 100644 --- a/src/Moryx.Resources.Samples/Cell.cs +++ b/src/Moryx.Resources.Samples/Cell.cs @@ -40,4 +40,4 @@ public void PerformSelfTest() public void Move(Axes axis, AxisPosition position) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/GateResource.cs b/src/Moryx.Resources.Samples/GateResource.cs index 8474ba7a26..e14d34d3aa 100644 --- a/src/Moryx.Resources.Samples/GateResource.cs +++ b/src/Moryx.Resources.Samples/GateResource.cs @@ -43,4 +43,4 @@ public void RotateCounterClockwise() _target.MoveAxes(Axes.Door, AxisPosition.RotateCounterClockwise); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/IVisualInstructor.cs b/src/Moryx.Resources.Samples/IVisualInstructor.cs index 8237d028f8..0ec4179fd1 100644 --- a/src/Moryx.Resources.Samples/IVisualInstructor.cs +++ b/src/Moryx.Resources.Samples/IVisualInstructor.cs @@ -68,4 +68,4 @@ public void Clear() public class AwesomeInstructor : VisualInstructor { -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializer.cs b/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializer.cs index 5ed7b5dc50..12c5aab5ba 100644 --- a/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializer.cs +++ b/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializer.cs @@ -60,4 +60,4 @@ public override Task ExecuteAsync(IResourceGraph grap return InitializedAsync([machine]); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializerConfig.cs b/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializerConfig.cs index 6bd6ae1b4d..2399050698 100644 --- a/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializerConfig.cs +++ b/src/Moryx.Resources.Samples/Initializer/SampleMachineInitializerConfig.cs @@ -18,4 +18,4 @@ public override string PluginName [DisplayName("Machine Name"), Description("Defines the name of the machine.")] [DefaultValue("Sample")] public string MachineName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/Machine.cs b/src/Moryx.Resources.Samples/Machine.cs index a456dd7c2c..b5753ef28e 100644 --- a/src/Moryx.Resources.Samples/Machine.cs +++ b/src/Moryx.Resources.Samples/Machine.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel; -using System; using System.Runtime.Serialization; using Moryx.AbstractionLayer.Identity; using Moryx.AbstractionLayer.Resources; diff --git a/src/Moryx.Resources.Samples/RefreshResource.cs b/src/Moryx.Resources.Samples/RefreshResource.cs index 008c784f0b..5b9b0e6ecc 100644 --- a/src/Moryx.Resources.Samples/RefreshResource.cs +++ b/src/Moryx.Resources.Samples/RefreshResource.cs @@ -10,4 +10,4 @@ public class RefreshResource : Resource { [EntrySerialize] public string CurrentTime => DateTime.Now.ToLongTimeString(); -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/RoutingResource.cs b/src/Moryx.Resources.Samples/RoutingResource.cs index 65b194e0a7..899bd630cb 100644 --- a/src/Moryx.Resources.Samples/RoutingResource.cs +++ b/src/Moryx.Resources.Samples/RoutingResource.cs @@ -50,4 +50,4 @@ public void CreatePositions(int count) public class WpcPosition : Resource { -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/SolderingCell.cs b/src/Moryx.Resources.Samples/SolderingCell.cs index 3f5b31109b..b5ee8d54a3 100644 --- a/src/Moryx.Resources.Samples/SolderingCell.cs +++ b/src/Moryx.Resources.Samples/SolderingCell.cs @@ -57,4 +57,4 @@ public class SolderingStation : Station public override void ProcessActivity(Activity sa) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.Samples/TcpDriverSample.cs b/src/Moryx.Resources.Samples/TcpDriverSample.cs index 67d69587a2..231894986a 100644 --- a/src/Moryx.Resources.Samples/TcpDriverSample.cs +++ b/src/Moryx.Resources.Samples/TcpDriverSample.cs @@ -1,11 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Runtime.Serialization; using Moryx.AbstractionLayer.Drivers; using Moryx.AbstractionLayer.Resources; using Moryx.Communication; using Moryx.Serialization; -using System.Runtime.Serialization; namespace Moryx.Resources.Samples; @@ -21,7 +21,6 @@ public class TcpDriverSample : Driver protected override async Task OnInitializeAsync(CancellationToken cancellationToken) { await base.OnInitializeAsync(cancellationToken); - - var connection = ConnectionFactory.Create(TcpConfig, null); + _ = ConnectionFactory.Create(TcpConfig, null); } -} \ No newline at end of file +} diff --git a/src/Moryx.Resources.VisualInstructions/VisualInstructor.cs b/src/Moryx.Resources.VisualInstructions/VisualInstructor.cs index 7e3a0a0200..af1add2681 100644 --- a/src/Moryx.Resources.VisualInstructions/VisualInstructor.cs +++ b/src/Moryx.Resources.VisualInstructions/VisualInstructor.cs @@ -49,7 +49,9 @@ internal long[] CurrentInstructionIds get { lock (_instructionDict) + { return _instructionDict.Keys.ToArray(); + } } } @@ -66,7 +68,9 @@ public IReadOnlyList Instructions get { lock (_instructionDict) + { return _instructionDict.Values.Select(p => p?.Model).ToList(); + } } } @@ -80,11 +84,15 @@ public void Completed(ActiveInstructionResponse response) lock (_instructionDict) { if (!_instructionDict.TryGetValue(response.Id, out pair)) + { return; + } } if (pair.Model.Results.Count == 0) + { return; + } // Invoke callback pair.Callback(response); @@ -114,7 +122,9 @@ public long Display(ActiveInstruction activeInstruction) }; lock (_instructionDict) + { _instructionDict.Add(activeInstruction.Id, instructionPair); + } Added?.Invoke(this, activeInstruction); @@ -135,11 +145,13 @@ public long Execute(ActiveInstruction activeInstruction, Action GetApplicationInfo() { var entryAssembly = Assembly.GetEntryAssembly(); if (entryAssembly is null) + { return BadRequest("Entry assembly could not be determined."); + } return new ApplicationInformationResponse { diff --git a/src/Moryx.Runtime.Endpoints/Common/Response/HostInformationResponse.cs b/src/Moryx.Runtime.Endpoints/Common/Response/HostInformationResponse.cs index 05defe2cba..18a722a20e 100644 --- a/src/Moryx.Runtime.Endpoints/Common/Response/HostInformationResponse.cs +++ b/src/Moryx.Runtime.Endpoints/Common/Response/HostInformationResponse.cs @@ -23,4 +23,4 @@ public class HostInformationResponse /// Time the system is running /// public long UpTime { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Common/Response/ServerTimeResponse.cs b/src/Moryx.Runtime.Endpoints/Common/Response/ServerTimeResponse.cs index e075c87b66..db7eaf4fb2 100644 --- a/src/Moryx.Runtime.Endpoints/Common/Response/ServerTimeResponse.cs +++ b/src/Moryx.Runtime.Endpoints/Common/Response/ServerTimeResponse.cs @@ -12,4 +12,4 @@ public class ServerTimeResponse /// Server time as string /// public string ServerTime { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/DatabaseController.cs b/src/Moryx.Runtime.Endpoints/Databases/DatabaseController.cs index fd396b0803..c4e6944efe 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/DatabaseController.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/DatabaseController.cs @@ -1,14 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Reflection; using System.Text.RegularExpressions; -using Moryx.Model; -using Moryx.Model.Configuration; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using System.Reflection; +using Microsoft.AspNetCore.Mvc; using Moryx.Configuration; +using Moryx.Model; using Moryx.Model.Attributes; +using Moryx.Model.Configuration; using Moryx.Runtime.Endpoints.Databases.Models; using Moryx.Runtime.Endpoints.Databases.Request; using Moryx.Runtime.Endpoints.Databases.Response; @@ -47,7 +47,7 @@ public async Task> GetAll() var dataModels = await Task.WhenAll(contexts.Select(ConvertAsync)); - var configurators = contexts.SelectMany(c => _dbContextManager.GetConfigurators(c)).Distinct().ToArray(); + var configurators = contexts.SelectMany(_dbContextManager.GetConfigurators).Distinct().ToArray(); var configuratorModels = configurators.Select(configurator => new ModelConfiguratorModel { Name = configurator.GetDisplayName(), @@ -70,7 +70,9 @@ public async Task> GetModel([FromRoute] string targetMod { var model = _dbContextManager.Contexts.FirstOrDefault(context => TargetModelName(context) == targetModel); if (model == null) + { return NotFound($"Model \"{targetModel}\" could not be found"); + } return await ConvertAsync(model); } @@ -81,13 +83,17 @@ public async Task> SetDatabaseConfig([FromRoute] string { var targetConfigurator = GetTargetConfigurator(targetModel, config); if (targetConfigurator == null) + { return NotFound($"Configurator for target model \"{targetModel}\" could not be found"); + } var configInstance = DeserializeConfig(targetConfigurator, config); var dbContextType = _dbContextManager.Contexts.FirstOrDefault(c => c.FullName == targetModel); if (dbContextType == null) + { return NotFound($"Model \"{targetModel}\" could not be found"); + } var result = _databaseUpdateService.UpdateModel(dbContextType, configInstance); var dbContext = _dbContextManager.Contexts.First(c => TargetModelName(c) == targetModel); @@ -102,7 +108,9 @@ public async Task> TestDatabaseConfig(strin { var targetConfigurator = GetTargetConfigurator(targetModel, config); if (targetConfigurator == null) + { return NotFound($"Configurator for target model \"{targetModel}\" could not be found"); + } if (targetConfigurator is NullModelConfigurator) { @@ -130,7 +138,9 @@ public async Task> CreateDatabase(string target { var targetConfigurator = GetTargetConfigurator(targetModel, config); if (targetConfigurator == null) + { return NotFound($"Configurator for target model \"{targetModel}\" could not be found"); + } var configInstance = DeserializeConfig(targetConfigurator, config); @@ -170,7 +180,9 @@ public async Task> MigrateDatabaseModel(s { var targetConfigurator = GetTargetConfigurator(targetModel, configModel); if (targetConfigurator == null) + { return NotFound($"Configurator for target model \"{targetModel}\" could not be found"); + } var configInstance = DeserializeConfig(targetConfigurator, configModel); @@ -184,7 +196,9 @@ public async Task> ExecuteSetup(string targetMo var contextType = _dbContextManager.Contexts.First(c => TargetModelName(c) == targetModel); var targetConfigurator = _dbContextManager.GetConfigurator(contextType); if (targetConfigurator == null) + { return NotFound($"Configurator for target model \"{targetModel}\" could not be found"); + } // Update config copy from model var configInstance = DeserializeConfig(targetConfigurator, request.Config); @@ -193,7 +207,9 @@ public async Task> ExecuteSetup(string targetMo var setupExecutor = _dbContextManager.GetSetupExecutor(contextType); var targetSetup = setupExecutor.GetAllSetups().FirstOrDefault(s => s.GetType().FullName == request.Setup.Fullname); if (targetSetup == null) + { return NotFound("No matching setup found"); + } // Provide logger for model await setupExecutor.ExecuteAsync(configInstance, targetSetup, request.Setup.SetupData); @@ -344,7 +360,9 @@ private IEnumerable GetAllSetups(Type contextType) .Select(ConvertSetup).OrderBy(setup => setup.SortOrder).ToList(); string[] files; if (!Directory.Exists(_dataDirectory) || !(files = Directory.GetFiles(_dataDirectory)).Any()) + { return setups.ToArray(); + } var fileSetups = allSetups.Where(setup => !string.IsNullOrEmpty(setup.SupportedFileRegex)) .Select(ConvertSetup).ToList(); @@ -410,7 +428,7 @@ private async Task BulkOperationAsync(Func ope } } -internal class DatabaseConfigSerialization : DefaultSerialization +internal sealed class DatabaseConfigSerialization : DefaultSerialization { public override IEnumerable GetProperties(Type sourceType) { diff --git a/src/Moryx.Runtime.Endpoints/Databases/Exceptions/BadRequestException.cs b/src/Moryx.Runtime.Endpoints/Databases/Exceptions/BadRequestException.cs index 0fd6cdd3c4..dc38cf32b9 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Exceptions/BadRequestException.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Exceptions/BadRequestException.cs @@ -11,4 +11,4 @@ public BadRequestException(string[] errors) : base(string.Join("\n", errors)) { Errors = errors; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Models/DataModel.cs b/src/Moryx.Runtime.Endpoints/Databases/Models/DataModel.cs index 0292611773..2713803699 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Models/DataModel.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Models/DataModel.cs @@ -37,4 +37,4 @@ public class DataModel /// Installed migrations for this context /// public DbMigrationsModel[] AppliedMigrations { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Models/DatabaseConfigModel.cs b/src/Moryx.Runtime.Endpoints/Databases/Models/DatabaseConfigModel.cs index ffec5a0e4c..4747effc02 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Models/DatabaseConfigModel.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Models/DatabaseConfigModel.cs @@ -24,4 +24,4 @@ public record DatabaseConfigModel /// Configuration of the database model. /// public Entry Properties { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Models/DbMigrationsModel.cs b/src/Moryx.Runtime.Endpoints/Databases/Models/DbMigrationsModel.cs index 888a597c7b..fb6ed0da2b 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Models/DbMigrationsModel.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Models/DbMigrationsModel.cs @@ -12,4 +12,4 @@ public class DbMigrationsModel /// Name of the script. /// public string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Models/ModelConfiguratorModel.cs b/src/Moryx.Runtime.Endpoints/Databases/Models/ModelConfiguratorModel.cs index 6943a5e299..81eeb5a6d0 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Models/ModelConfiguratorModel.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Models/ModelConfiguratorModel.cs @@ -34,4 +34,4 @@ public class ModelConfiguratorModel /// Properties to be configured for the given configurator /// public Entry ConfigPrototype { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Models/SetupModel.cs b/src/Moryx.Runtime.Endpoints/Databases/Models/SetupModel.cs index 20f164d4ff..eeae58f709 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Models/SetupModel.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Models/SetupModel.cs @@ -50,4 +50,4 @@ internal SetupModel CopyWithFile(string file) }; return copy; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Request/ExecuteSetupRequest.cs b/src/Moryx.Runtime.Endpoints/Databases/Request/ExecuteSetupRequest.cs index efd53184c2..0a76b102b4 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Request/ExecuteSetupRequest.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Request/ExecuteSetupRequest.cs @@ -19,4 +19,4 @@ public class ExecuteSetupRequest /// Setup to be executed /// public SetupModel Setup { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Response/DatabasesResponse.cs b/src/Moryx.Runtime.Endpoints/Databases/Response/DatabasesResponse.cs index c55fb3921d..f6c51f9c9c 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Response/DatabasesResponse.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Response/DatabasesResponse.cs @@ -10,4 +10,4 @@ public class DatabasesResponse public DataModel[] Databases { get; set; } public ModelConfiguratorModel[] Configurators { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Response/TestConnectionResponse.cs b/src/Moryx.Runtime.Endpoints/Databases/Response/TestConnectionResponse.cs index 494368ff13..c42203bad2 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Response/TestConnectionResponse.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Response/TestConnectionResponse.cs @@ -14,4 +14,4 @@ public class TestConnectionResponse /// Result of the connection test /// public TestConnectionResult Result { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Services/DatabaseConfigUpdateService.cs b/src/Moryx.Runtime.Endpoints/Databases/Services/DatabaseConfigUpdateService.cs index 43ddd6ac40..dc7a8757dc 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Services/DatabaseConfigUpdateService.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Services/DatabaseConfigUpdateService.cs @@ -37,4 +37,4 @@ public Type UpdateModel(Type dbContextType, DatabaseConfig config) return dbContextType; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Databases/Services/IDatabaseConfigUpdateService.cs b/src/Moryx.Runtime.Endpoints/Databases/Services/IDatabaseConfigUpdateService.cs index 9fe99536ae..f0ce8ecae7 100644 --- a/src/Moryx.Runtime.Endpoints/Databases/Services/IDatabaseConfigUpdateService.cs +++ b/src/Moryx.Runtime.Endpoints/Databases/Services/IDatabaseConfigUpdateService.cs @@ -8,4 +8,4 @@ namespace Moryx.Runtime.Endpoints.Databases.Services; public interface IDatabaseConfigUpdateService { Type UpdateModel(string targetModel, DatabaseConfigModel config); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/InvocationResponse.cs b/src/Moryx.Runtime.Endpoints/InvocationResponse.cs index cd40d2b80e..714d88457d 100644 --- a/src/Moryx.Runtime.Endpoints/InvocationResponse.cs +++ b/src/Moryx.Runtime.Endpoints/InvocationResponse.cs @@ -49,4 +49,4 @@ public InvocationResponse(string errorMessage) /// Error message of the exception /// public string ErrorMessage { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/AssemblyModel.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/AssemblyModel.cs index a0850b2443..9c867e4561 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/AssemblyModel.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/AssemblyModel.cs @@ -27,4 +27,4 @@ public class AssemblyModel /// AssemblyInformationalVersion of the assembly. /// public string InformationalVersion { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/Config.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/Config.cs index a28de47598..89b8cd0750 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/Config.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/Config.cs @@ -14,4 +14,4 @@ public class Config /// Entry converted configuration /// public Entry Root { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/ConfigUpdateMode.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/ConfigUpdateMode.cs index 52ea12e807..c16b0fbfe2 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/ConfigUpdateMode.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/ConfigUpdateMode.cs @@ -22,4 +22,4 @@ public enum ConfigUpdateMode /// Update current config object live while plugin is still running /// UpdateLiveAndSave -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/DependencyEvaluation.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/DependencyEvaluation.cs index 6e99a81e32..73e708e9e6 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/DependencyEvaluation.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/DependencyEvaluation.cs @@ -61,4 +61,4 @@ private static int CalculateTreeDepth(int currentLevel, IModuleDependency branch var childLevel = currentLevel + 1; return branch.Dependents.Any() ? branch.Dependents.Max(dependency => CalculateTreeDepth(childLevel, dependency)) : currentLevel; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/ModuleNotificationModel.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/ModuleNotificationModel.cs index 6eb665b809..90b40ef486 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/ModuleNotificationModel.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/ModuleNotificationModel.cs @@ -27,7 +27,10 @@ public ModuleNotificationModel(IModuleNotification notification) { Timestamp = notification.Timestamp; if (notification.Exception != null) + { Exception = new SerializableException(notification.Exception); + } + Message = notification.Message; Severity = notification.Severity; } @@ -51,4 +54,4 @@ public ModuleNotificationModel(IModuleNotification notification) /// Kind of notification /// public Severity Severity { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/SerializableException.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/SerializableException.cs index 4978eab0fc..e507493bcd 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/SerializableException.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/SerializableException.cs @@ -52,4 +52,4 @@ public SerializableException(Exception e) /// Contains an inner exception of type if exists. /// public SerializableException InnerException { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Models/ServerModuleModel.cs b/src/Moryx.Runtime.Endpoints/Modules/Models/ServerModuleModel.cs index 58ec6eaa94..742eff39a3 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Models/ServerModuleModel.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Models/ServerModuleModel.cs @@ -53,4 +53,4 @@ public ServerModuleModel() /// The configured assembly. /// public AssemblyModel Assembly { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/ModulesController.cs b/src/Moryx.Runtime.Endpoints/Modules/ModulesController.cs index b8cc1a46f2..859356de51 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/ModulesController.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/ModulesController.cs @@ -77,7 +77,9 @@ public ActionResult HealthState([FromRoute] string moduleName { var module = _moduleManager.AllModules.FirstOrDefault(m => m.Name == moduleName); if (module != null) + { return module.State; + } return NotFound($"Module with name \"{moduleName}\" could not be found"); } @@ -90,7 +92,9 @@ public ActionResult> Notifications([FromRou { var module = _moduleManager.AllModules.FirstOrDefault(m => m.Name == moduleName); if (module != null) + { return Ok(module.Notifications.Select(n => new ModuleNotificationModel(n))); + } return NotFound($"Module with name \"{moduleName}\" could not be found"); } @@ -103,7 +107,9 @@ public ActionResult Start([FromRoute] string moduleName) { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } Task.Run(() => _moduleManager.StartModuleAsync(module)); return Ok(); @@ -117,7 +123,9 @@ public ActionResult Stop([FromRoute] string moduleName) { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } Task.Run(() => _moduleManager.StopModuleAsync(module)); return Ok(); @@ -131,7 +139,9 @@ public ActionResult Reincarnate([FromRoute] string moduleName) { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } Task.Run(() => _moduleManager.ReincarnateModuleAsync(module)); return Ok(); @@ -145,19 +155,27 @@ public ActionResult Reincarnate([FromRoute] string moduleName) public ActionResult Update([FromRoute] string moduleName, [FromBody] ServerModuleModel module) { if (module == null) + { return BadRequest("Module is required"); + } var serverModule = GetModuleFromManager(moduleName); if (serverModule == null) + { return NotFound($"Server module with name \"{moduleName}\" could not be found"); + } var startBehaviour = _moduleManager.BehaviourAccess(serverModule); if (startBehaviour.Behaviour != module.StartBehaviour) + { startBehaviour.Behaviour = module.StartBehaviour; + } var failureBehaviour = _moduleManager.BehaviourAccess(serverModule); if (failureBehaviour.Behaviour != module.FailureBehaviour) + { failureBehaviour.Behaviour = module.FailureBehaviour; + } return Ok(); } @@ -170,11 +188,15 @@ public ActionResult ConfirmWarning([FromRoute] string moduleName) { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } var notifications = module.Notifications.ToArray(); foreach (var notification in notifications) + { module.AcknowledgeNotification(notification); + } _moduleManager.InitializeModuleAsync(module); return Ok(); @@ -191,7 +213,9 @@ public ActionResult GetConfig([FromRoute] string moduleName) { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } var serialization = CreateSerialization(module); @@ -217,13 +241,17 @@ public ActionResult GetConfig([FromRoute] string moduleName) public ActionResult SetConfig([FromRoute] string moduleName, [FromBody] SaveConfigRequest request) { if (request.Config == null) + { return BadRequest("Config is required"); + } try { var module = GetModuleFromManager(moduleName); if (module == null) + { return NotFound($"Module with name \"{moduleName}\" could not be found"); + } var serialization = CreateSerialization(module); var config = GetConfig(module, true); @@ -231,8 +259,11 @@ public ActionResult SetConfig([FromRoute] string moduleName, [FromBody] SaveConf _configManager.SaveConfiguration(config, request.UpdateMode == ConfigUpdateMode.UpdateLiveAndSave); if (request.UpdateMode == ConfigUpdateMode.SaveAndReincarnate) + { // This has to be done parallel so we can also reincarnate the Maintenance itself Task.Run(() => _moduleManager.ReincarnateModuleAsync(module)); + } + return Ok(); } catch (Exception ex) @@ -250,10 +281,14 @@ public ActionResult> GetMethods([FromRoute] string modu var methods = Enumerable.Empty(); var serverModule = GetModuleFromManager(moduleName); if (serverModule == null) + { return NotFound($"Server module with name \"{moduleName}\" could not be found"); + } if (serverModule?.Console != null) + { methods = EntryConvert.EncodeMethods(serverModule.Console, CreateEditorSerializeSerialization(serverModule)); + } return Ok(methods); } @@ -267,11 +302,15 @@ public ActionResult> GetMethods([FromRoute] string modu public async Task> InvokeMethod([FromRoute] string moduleName, [FromBody] MethodEntry method) { if (method == null) + { return BadRequest("Method is required"); + } var serverModule = GetModuleFromManager(moduleName); if (serverModule == null) + { return NotFound($"Server module with name \"{moduleName}\" could not be found"); + } try { @@ -288,7 +327,7 @@ public async Task> InvokeMethod([FromRoute] string moduleNam } } - catch (Exception e) + catch (Exception) { return StatusCode(StatusCodes.Status500InternalServerError, $"Error while invoking function: {method.DisplayName}."); } diff --git a/src/Moryx.Runtime.Endpoints/Modules/Request/SaveConfigRequest.cs b/src/Moryx.Runtime.Endpoints/Modules/Request/SaveConfigRequest.cs index 9ee49d77a6..11a84635a8 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Request/SaveConfigRequest.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Request/SaveConfigRequest.cs @@ -19,4 +19,4 @@ public class SaveConfigRequest /// Update mode how the config will be applied /// public ConfigUpdateMode UpdateMode { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/Modules/Serialization/AdvancedEntrySerializeSerialization.cs b/src/Moryx.Runtime.Endpoints/Modules/Serialization/AdvancedEntrySerializeSerialization.cs index b82b6c2414..90b1d8838a 100644 --- a/src/Moryx.Runtime.Endpoints/Modules/Serialization/AdvancedEntrySerializeSerialization.cs +++ b/src/Moryx.Runtime.Endpoints/Modules/Serialization/AdvancedEntrySerializeSerialization.cs @@ -9,7 +9,7 @@ namespace Moryx.Runtime.Endpoints.Modules.Serialization; /// -internal class AdvancedEntrySerializeSerialization : PossibleValuesSerialization +internal sealed class AdvancedEntrySerializeSerialization : PossibleValuesSerialization { private readonly EntrySerializeSerialization _entrySerializeSerialization; @@ -21,4 +21,4 @@ public AdvancedEntrySerializeSerialization(IContainer container, IServiceProvide /// public override IEnumerable GetMethods(Type sourceType) => _entrySerializeSerialization.GetMethods(sourceType); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Endpoints/RuntimePermissions.cs b/src/Moryx.Runtime.Endpoints/RuntimePermissions.cs index 9e2c4886c4..73b36ac762 100644 --- a/src/Moryx.Runtime.Endpoints/RuntimePermissions.cs +++ b/src/Moryx.Runtime.Endpoints/RuntimePermissions.cs @@ -24,4 +24,4 @@ public static class RuntimePermissions public const string ModulesCanConfigure = _modulesPrefix + "CanConfigure"; public const string ModulesCanConfirmNotifications = _modulesPrefix + "CanConfirmNotifications"; public const string ModulesCanInvoke = _modulesPrefix + "CanInvoke"; -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Configuration/ConfigLiveUpdater.cs b/src/Moryx.Runtime.Kernel/Configuration/ConfigLiveUpdater.cs index c9c98eab0c..f22d13eeaa 100644 --- a/src/Moryx.Runtime.Kernel/Configuration/ConfigLiveUpdater.cs +++ b/src/Moryx.Runtime.Kernel/Configuration/ConfigLiveUpdater.cs @@ -17,11 +17,13 @@ public void UpdateLive(Type sharedType, ConfigBase activeConfig, ConfigBase modi private bool UpdateObject(Type sharedType, object target, object source) { var modifiedProperties = (from propertyInfo in sharedType.GetProperties() - where UpdateProperty(propertyInfo, target, source) - select propertyInfo.Name).ToList(); + where UpdateProperty(propertyInfo, target, source) + select propertyInfo.Name).ToList(); if (modifiedProperties.Any() & target is IUpdatableConfig) + { ((IUpdatableConfig)target).RaiseConfigChanged(modifiedProperties.ToArray()); + } return modifiedProperties.Any(); } @@ -45,11 +47,15 @@ private bool UpdateProperty(PropertyInfo prop, object target, object source) var targetValue = prop.GetValue(target); var sourceValue = prop.GetValue(source); if (targetValue != null && targetValue.Equals(sourceValue) || sourceValue == null) + { return false; + } if (prop.PropertyType.IsClass && prop.PropertyType != typeof(string) && (targetValue != null && targetValue.GetType() == sourceValue.GetType())) + { return UpdateObject(GetSharedType(prop.PropertyType, targetValue, sourceValue), targetValue, sourceValue); + } prop.SetValue(target, sourceValue); return true; @@ -60,13 +66,20 @@ private static Type GetSharedType(Type sharedType, object target, object source) // Check if both objects are identical or have the same type Type targetType = target.GetType(), sourceType; if (target == source || target.GetType() == (sourceType = source.GetType())) + { return targetType; + } // Check if they are are direct relatives if (targetType.IsInstanceOfType(source)) + { return targetType; + } + if (sourceType.IsInstanceOfType(targetType)) + { return sourceType; + } // Check if their inheritance trees meet somewhere var targetsBases = GetBaseTypes(targetType); diff --git a/src/Moryx.Runtime.Kernel/Configuration/ValueProvider/SharedConfigProvider.cs b/src/Moryx.Runtime.Kernel/Configuration/ValueProvider/SharedConfigProvider.cs index 7e1aff87ad..fbd2cabc97 100644 --- a/src/Moryx.Runtime.Kernel/Configuration/ValueProvider/SharedConfigProvider.cs +++ b/src/Moryx.Runtime.Kernel/Configuration/ValueProvider/SharedConfigProvider.cs @@ -20,7 +20,9 @@ public ValueProviderResult Handle(object parent, PropertyInfo property) { var sharedAtt = property.GetCustomAttribute(); if (sharedAtt == null || !typeof(ConfigBase).IsAssignableFrom(property.PropertyType)) + { return ValueProviderResult.Skipped; + } var sharedConf = _configManager.GetConfiguration(property.PropertyType, sharedAtt.UseCopy); property.SetValue(parent, sharedConf); @@ -40,11 +42,15 @@ private static void ScanType(object instance, List foundShared) { var sharedAtt = property.GetCustomAttribute(); if (sharedAtt == null || sharedAtt.UseCopy) + { continue; + } var config = (ConfigBase)property.GetValue(instance); if (!foundShared.Contains(config)) + { foundShared.Add(config); + } } } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Modules/BehaviourAccess.cs b/src/Moryx.Runtime.Kernel/Modules/BehaviourAccess.cs index 34ae77e21e..bd6b5fefaa 100644 --- a/src/Moryx.Runtime.Kernel/Modules/BehaviourAccess.cs +++ b/src/Moryx.Runtime.Kernel/Modules/BehaviourAccess.cs @@ -12,10 +12,14 @@ internal static class ABehaviourAccess public static ABehaviourAccess Create(ModuleManagerConfig config, IConfigManager configManager, IModule module) { if (typeof(T) == typeof(ModuleStartBehaviour)) + { return new StartBehaviorAccess(config, configManager, module) as ABehaviourAccess; + } if (typeof(T) == typeof(FailureBehaviour)) + { return new FailureBehaviourAccess(config, configManager, module) as ABehaviourAccess; + } return null; } diff --git a/src/Moryx.Runtime.Kernel/Modules/Components/IModuleDependencyManager.cs b/src/Moryx.Runtime.Kernel/Modules/Components/IModuleDependencyManager.cs index b5fed27d5b..0289f945ef 100644 --- a/src/Moryx.Runtime.Kernel/Modules/Components/IModuleDependencyManager.cs +++ b/src/Moryx.Runtime.Kernel/Modules/Components/IModuleDependencyManager.cs @@ -27,4 +27,4 @@ internal interface IModuleDependencyManager /// Get all start dependencies of this plugin /// IModuleDependency GetDependencyBranch(IServerModule module); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Modules/Components/MissingFacadeException.cs b/src/Moryx.Runtime.Kernel/Modules/Components/MissingFacadeException.cs index 16c728bb19..0c1bf9970a 100644 --- a/src/Moryx.Runtime.Kernel/Modules/Components/MissingFacadeException.cs +++ b/src/Moryx.Runtime.Kernel/Modules/Components/MissingFacadeException.cs @@ -23,4 +23,4 @@ public MissingFacadeException(string moduleName, string propName, Type facadeTyp PropName = propName; FacadeType = facadeType; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Modules/Components/ModuleDependencyManager.cs b/src/Moryx.Runtime.Kernel/Modules/Components/ModuleDependencyManager.cs index c2c42c17e5..67ce992461 100644 --- a/src/Moryx.Runtime.Kernel/Modules/Components/ModuleDependencyManager.cs +++ b/src/Moryx.Runtime.Kernel/Modules/Components/ModuleDependencyManager.cs @@ -102,9 +102,13 @@ private IReadOnlyList FillDependencies(IEnumerable { var propType = importingProperty.Property.PropertyType; if (typeof(Array).IsAssignableFrom(propType)) + { FillArray(propType, importingProperty, module, facadeProviders); + } else + { FillFacade(propType, importingProperty, module, facadeProviders); + } } satisfiedModules.Add(module); } @@ -172,7 +176,9 @@ private IReadOnlyList Convert(IReadOnlyList converted.All(con => con.RepresentedModule != dep) && dep.GetType() != typeof(MissingServerModule))) + { continue; // Unconverted dependency + } var branch = new ModuleDependencyBranch(module); _cache[module] = branch; @@ -192,7 +198,9 @@ private IReadOnlyList Convert(IReadOnlyList d.GetType() == typeof(MissingServerModule)).ToList(); if (nullDependencies != null && nullDependencies.Count > 0) + { branch.Dependencies.AddRange(nullDependencies.Select(nd => new MissingModuleDependency((MissingServerModule)nd))); + } remaining.Remove(module); } @@ -208,19 +216,28 @@ private static IReadOnlyList StartDependencies(IServerModule modu foreach (var importingProperty in GetImportingProperties(module)) { if (!importingProperty.Attribute.IsStartDependency) + { continue; + } var propType = importingProperty.Property.PropertyType; if (propType.IsArray) + { propType = propType.GetElementType(); + } + var dependencyProviders = facadeProviders.Where(facadePair => propType.IsInstanceOfType(facadePair.Key)).ToArray(); foreach (var dependencyProvider in dependencyProviders) + { dependencyServices.Add(dependencyProvider.Value); + } // when there is no facade provider for the dependency, // add a missing dependency for the property type if (dependencyProviders.Length == 0) + { dependencyServices.Add(new MissingServerModule(propType, importingProperty.Attribute.IsOptional)); + } } return dependencyServices; @@ -229,9 +246,9 @@ private static IReadOnlyList StartDependencies(IServerModule modu private static IReadOnlyList GetImportingProperties(IServerModule plugin) { var dependencyAttributes = from prop in plugin.GetType().GetProperties() - let att = prop.GetCustomAttribute() - where att != null - select new ImportingProperty { Property = prop, Attribute = att }; + let att = prop.GetCustomAttribute() + where att != null + select new ImportingProperty { Property = prop, Attribute = att }; return dependencyAttributes.ToList(); } #endregion diff --git a/src/Moryx.Runtime.Kernel/Modules/MissingModuleDependency.cs b/src/Moryx.Runtime.Kernel/Modules/MissingModuleDependency.cs index 783dc781be..35af2d557a 100644 --- a/src/Moryx.Runtime.Kernel/Modules/MissingModuleDependency.cs +++ b/src/Moryx.Runtime.Kernel/Modules/MissingModuleDependency.cs @@ -20,4 +20,4 @@ public MissingModuleDependency(IServerModule representedModule) public IReadOnlyList Dependencies => throw new NotImplementedException(); public IReadOnlyList Dependents => throw new NotImplementedException(); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Modules/MissingServerModule.cs b/src/Moryx.Runtime.Kernel/Modules/MissingServerModule.cs index b926f2cd73..2e7d2bb370 100644 --- a/src/Moryx.Runtime.Kernel/Modules/MissingServerModule.cs +++ b/src/Moryx.Runtime.Kernel/Modules/MissingServerModule.cs @@ -38,8 +38,13 @@ private string GetName() RepresentedService.IsInterface; if (isInterfaceAndHasIasFirstCharacter) + { return RepresentedService.Name.Remove(0, 1); // remove "i" in the interface name - else return RepresentedService.Name; + } + else + { + return RepresentedService.Name; + } } public void AcknowledgeNotification(IModuleNotification notification) @@ -66,4 +71,4 @@ public Task StopAsync(CancellationToken cancellationToken = default) public IContainer Container => throw new NotImplementedException(); public bool Optional { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/Modules/ModuleManagerConfig.cs b/src/Moryx.Runtime.Kernel/Modules/ModuleManagerConfig.cs index 77b20b1c3c..ae9a60addd 100644 --- a/src/Moryx.Runtime.Kernel/Modules/ModuleManagerConfig.cs +++ b/src/Moryx.Runtime.Kernel/Modules/ModuleManagerConfig.cs @@ -71,4 +71,4 @@ public class ManagedModuleConfig /// [DataMember] public FailureBehaviour FailureBehaviour { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime.Kernel/MoryxHost.cs b/src/Moryx.Runtime.Kernel/MoryxHost.cs index cfd4c56f93..88d5b3c2ce 100644 --- a/src/Moryx.Runtime.Kernel/MoryxHost.cs +++ b/src/Moryx.Runtime.Kernel/MoryxHost.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Runtime.InteropServices; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Moryx.Runtime.Modules; -using System.Runtime.InteropServices; namespace Moryx.Runtime.Kernel; diff --git a/src/Moryx.Runtime/Configuration/ModuleStrategyAttribute.cs b/src/Moryx.Runtime/Configuration/ModuleStrategyAttribute.cs index 4c58fa12a3..775e917168 100644 --- a/src/Moryx.Runtime/Configuration/ModuleStrategyAttribute.cs +++ b/src/Moryx.Runtime/Configuration/ModuleStrategyAttribute.cs @@ -20,4 +20,4 @@ public ModuleStrategyAttribute(Type strategy) /// Strategy configured with this property /// public Type Strategy { get; private set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Configuration/SharedConfigAttribute.cs b/src/Moryx.Runtime/Configuration/SharedConfigAttribute.cs index 115335015c..bc5deecd5d 100644 --- a/src/Moryx.Runtime/Configuration/SharedConfigAttribute.cs +++ b/src/Moryx.Runtime/Configuration/SharedConfigAttribute.cs @@ -24,4 +24,4 @@ public SharedConfigAttribute(bool useCopy) /// Flag if the injected object shall be a copy /// public bool UseCopy { get; private set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/ConfigParser.cs b/src/Moryx.Runtime/Modules/ConfigParser.cs index 7ac30836d8..75b7504474 100644 --- a/src/Moryx.Runtime/Modules/ConfigParser.cs +++ b/src/Moryx.Runtime/Modules/ConfigParser.cs @@ -24,7 +24,9 @@ private static void ParseEntry(object instance, IDictionary contai // Check for class properties if (!propType.IsClass) + { continue; + } // Check for plugin config and strategy attribute ModuleStrategyAttribute attribute; @@ -38,7 +40,9 @@ private static void ParseEntry(object instance, IDictionary contai // Now filter strings if (propType == typeof(string)) + { continue; + } // Check for collection if (typeof(IEnumerable).IsAssignableFrom(propType)) @@ -54,4 +58,4 @@ private static void ParseEntry(object instance, IDictionary contai } } } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/FacadeBase.cs b/src/Moryx.Runtime/Modules/FacadeBase.cs index 268a8a8364..fc3d99b307 100644 --- a/src/Moryx.Runtime/Modules/FacadeBase.cs +++ b/src/Moryx.Runtime/Modules/FacadeBase.cs @@ -44,7 +44,10 @@ public bool IsActivated set { if (field == value) + { return; + } + field = value; RaiseActivatedStateChanged(field); } @@ -57,4 +60,4 @@ private void RaiseActivatedStateChanged(bool newActivatedState) { StateChanged?.Invoke(this, newActivatedState); } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/IFacadeContainer.cs b/src/Moryx.Runtime/Modules/IFacadeContainer.cs index c259a88889..4150498315 100644 --- a/src/Moryx.Runtime/Modules/IFacadeContainer.cs +++ b/src/Moryx.Runtime/Modules/IFacadeContainer.cs @@ -16,4 +16,4 @@ public interface IFacadeContainer /// The hard-coded name of this property is also used in Moryx.Runtime.Kernel\ModuleManagement\Components\ModuleDependencyManager.cs /// TFacade Facade { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/IFacadeControl.cs b/src/Moryx.Runtime/Modules/IFacadeControl.cs index 84d0b00a4c..831bdd1bde 100644 --- a/src/Moryx.Runtime/Modules/IFacadeControl.cs +++ b/src/Moryx.Runtime/Modules/IFacadeControl.cs @@ -22,4 +22,4 @@ public interface IFacadeControl /// Module is stopping and facade deactivates /// void Deactivate(); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/ILifeCycleBoundFacade.cs b/src/Moryx.Runtime/Modules/ILifeCycleBoundFacade.cs index c9e3c2fab9..26a0abb6a8 100644 --- a/src/Moryx.Runtime/Modules/ILifeCycleBoundFacade.cs +++ b/src/Moryx.Runtime/Modules/ILifeCycleBoundFacade.cs @@ -27,4 +27,4 @@ public interface ILifeCycleBoundFacade /// Event is called when a Activated changed occurs /// event EventHandler StateChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/IServerModule.cs b/src/Moryx.Runtime/Modules/IServerModule.cs index c6bcf04a7f..64b008da9d 100644 --- a/src/Moryx.Runtime/Modules/IServerModule.cs +++ b/src/Moryx.Runtime/Modules/IServerModule.cs @@ -62,4 +62,4 @@ public class ModuleStateChangedEventArgs /// New state of the module /// public ServerModuleState NewState { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/IServerModuleConsole.cs b/src/Moryx.Runtime/Modules/IServerModuleConsole.cs index 386358d74b..7a48535e97 100644 --- a/src/Moryx.Runtime/Modules/IServerModuleConsole.cs +++ b/src/Moryx.Runtime/Modules/IServerModuleConsole.cs @@ -9,4 +9,4 @@ namespace Moryx.Runtime.Modules; public interface IServerModuleConsole { -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/Management/HealthStateException.cs b/src/Moryx.Runtime/Modules/Management/HealthStateException.cs index 59b44ab7ed..bad322d271 100644 --- a/src/Moryx.Runtime/Modules/Management/HealthStateException.cs +++ b/src/Moryx.Runtime/Modules/Management/HealthStateException.cs @@ -34,4 +34,4 @@ public HealthStateException(ServerModuleState current) /// Gets a message that describes the current exception. /// public override string Message => $"Current HealthState {Current} of service does not allow requested operation."; -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/Management/IModuleDependencyTree.cs b/src/Moryx.Runtime/Modules/Management/IModuleDependencyTree.cs index 3fbc64ffc2..e3399f754e 100644 --- a/src/Moryx.Runtime/Modules/Management/IModuleDependencyTree.cs +++ b/src/Moryx.Runtime/Modules/Management/IModuleDependencyTree.cs @@ -33,4 +33,4 @@ public interface IModuleDependency /// All modules that depend on this module /// IReadOnlyList Dependents { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/Management/IModuleManager.cs b/src/Moryx.Runtime/Modules/Management/IModuleManager.cs index 302045a6fd..08830fa024 100644 --- a/src/Moryx.Runtime/Modules/Management/IModuleManager.cs +++ b/src/Moryx.Runtime/Modules/Management/IModuleManager.cs @@ -87,4 +87,4 @@ public interface IBehaviourAccess /// Get or set the modules behaviour /// T Behaviour { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/Management/RequiredModuleApiAttribute.cs b/src/Moryx.Runtime/Modules/Management/RequiredModuleApiAttribute.cs index 2ad4887c44..c764ee5e66 100644 --- a/src/Moryx.Runtime/Modules/Management/RequiredModuleApiAttribute.cs +++ b/src/Moryx.Runtime/Modules/Management/RequiredModuleApiAttribute.cs @@ -36,4 +36,4 @@ public class RequiredModuleApiAttribute : Attribute /// leave the property null if no host was found. /// public bool IsOptional { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/ModuleNotification.cs b/src/Moryx.Runtime/Modules/ModuleNotification.cs index 6dc3b3a4b5..af48adfdcb 100644 --- a/src/Moryx.Runtime/Modules/ModuleNotification.cs +++ b/src/Moryx.Runtime/Modules/ModuleNotification.cs @@ -69,4 +69,4 @@ public static void AddFromLogStream(this INotificationCollection collection, Log { collection.Add(ModuleNotification.FromLogStream(logLevel, message, exception)); } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/ModuleStartBehaviour.cs b/src/Moryx.Runtime/Modules/ModuleStartBehaviour.cs index 3eff33a465..e696545c82 100644 --- a/src/Moryx.Runtime/Modules/ModuleStartBehaviour.cs +++ b/src/Moryx.Runtime/Modules/ModuleStartBehaviour.cs @@ -22,4 +22,4 @@ public enum ModuleStartBehaviour /// Server module is only started as dependency of other modules /// OnDependency -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/ServerModuleBase.cs b/src/Moryx.Runtime/Modules/ServerModuleBase.cs index 6ee2dd0c6c..5668a6d97e 100644 --- a/src/Moryx.Runtime/Modules/ServerModuleBase.cs +++ b/src/Moryx.Runtime/Modules/ServerModuleBase.cs @@ -154,11 +154,8 @@ async Task IServerModuleStateContext.StopAsync(CancellationToken cancellationTok void IServerModuleStateContext.Destruct() { // Destroy local container - if (Container != null) - { - Container.Destroy(); - Container = null; - } + Container?.Destroy(); + Container = null; Logger.Log(LogLevel.Information, "{0} destructed!", Name); } @@ -187,7 +184,9 @@ protected void ActivateFacade(IFacadeControl facade) protected void DeactivateFacade(IFacadeControl facade) { if (!_activeFacades.Remove(facade)) + { return; + } facade.Deactivate(); FillProperties(facade, (a, b) => null); @@ -205,10 +204,14 @@ private void FillProperties(object instance, Func Missing = 0x5 -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/FailureState.cs b/src/Moryx.Runtime/Modules/States/FailureState.cs index 437336e3e4..ef6388145c 100644 --- a/src/Moryx.Runtime/Modules/States/FailureState.cs +++ b/src/Moryx.Runtime/Modules/States/FailureState.cs @@ -72,4 +72,4 @@ public override Task Stop(CancellationToken cancellationToken) { return NextStateAsync(StateStopped, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/IServerModuleStateContext.cs b/src/Moryx.Runtime/Modules/States/IServerModuleStateContext.cs index f563fc1c3b..4ab89a0fc5 100644 --- a/src/Moryx.Runtime/Modules/States/IServerModuleStateContext.cs +++ b/src/Moryx.Runtime/Modules/States/IServerModuleStateContext.cs @@ -45,4 +45,4 @@ internal interface IServerModuleStateContext : IAsyncStateContext /// Adds a notification to the module /// > void LogNotification(IModuleNotification notification); -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/InitializingState.cs b/src/Moryx.Runtime/Modules/States/InitializingState.cs index d01ae45dda..ffe5b47b90 100644 --- a/src/Moryx.Runtime/Modules/States/InitializingState.cs +++ b/src/Moryx.Runtime/Modules/States/InitializingState.cs @@ -41,4 +41,4 @@ public override Task Stop(CancellationToken cancellationToken) // Nothing to do here return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/MissingState.cs b/src/Moryx.Runtime/Modules/States/MissingState.cs index 414b739d18..4b90a67e31 100644 --- a/src/Moryx.Runtime/Modules/States/MissingState.cs +++ b/src/Moryx.Runtime/Modules/States/MissingState.cs @@ -33,4 +33,4 @@ public override Task Stop(CancellationToken cancellationToken) // Nothing to do here return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/ReadyState.cs b/src/Moryx.Runtime/Modules/States/ReadyState.cs index 5021544c69..9368d2a058 100644 --- a/src/Moryx.Runtime/Modules/States/ReadyState.cs +++ b/src/Moryx.Runtime/Modules/States/ReadyState.cs @@ -27,4 +27,4 @@ public override Task Stop(CancellationToken cancellationToken) { return NextStateAsync(StateReadyStopping, cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/RunningState.cs b/src/Moryx.Runtime/Modules/States/RunningState.cs index ea851d916a..1becde09c9 100644 --- a/src/Moryx.Runtime/Modules/States/RunningState.cs +++ b/src/Moryx.Runtime/Modules/States/RunningState.cs @@ -45,4 +45,4 @@ public override void ValidateHealthState() { // Health state should be okay! } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/ServerModuleStateBase.cs b/src/Moryx.Runtime/Modules/States/ServerModuleStateBase.cs index 393963d2ab..5fe089de4c 100644 --- a/src/Moryx.Runtime/Modules/States/ServerModuleStateBase.cs +++ b/src/Moryx.Runtime/Modules/States/ServerModuleStateBase.cs @@ -59,4 +59,4 @@ public virtual void ValidateHealthState() [StateDefinition(typeof(InitializedFailureState))] protected const int StateInitializedFailure = 65; -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/StartingState.cs b/src/Moryx.Runtime/Modules/States/StartingState.cs index 35e0f2361d..e871181db5 100644 --- a/src/Moryx.Runtime/Modules/States/StartingState.cs +++ b/src/Moryx.Runtime/Modules/States/StartingState.cs @@ -43,4 +43,4 @@ public override Task Stop(CancellationToken cancellationToken) // Nothing to do here return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/StoppedState.cs b/src/Moryx.Runtime/Modules/States/StoppedState.cs index 0902ec26c6..9d73088212 100644 --- a/src/Moryx.Runtime/Modules/States/StoppedState.cs +++ b/src/Moryx.Runtime/Modules/States/StoppedState.cs @@ -22,4 +22,4 @@ public override Task Stop(CancellationToken cancellationToken) // Stop again does not matter return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Modules/States/StoppingState.cs b/src/Moryx.Runtime/Modules/States/StoppingState.cs index 9fae31a6c5..64f0089676 100644 --- a/src/Moryx.Runtime/Modules/States/StoppingState.cs +++ b/src/Moryx.Runtime/Modules/States/StoppingState.cs @@ -82,4 +82,4 @@ public override Task Stop(CancellationToken cancellationToken) // We are already stopping return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Moryx.Runtime/Properties/AssemblyInfo.cs b/src/Moryx.Runtime/Properties/AssemblyInfo.cs index 3aad010086..b7a892c96d 100644 --- a/src/Moryx.Runtime/Properties/AssemblyInfo.cs +++ b/src/Moryx.Runtime/Properties/AssemblyInfo.cs @@ -1,3 +1,6 @@ -using System.Runtime.CompilerServices; +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 + +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Moryx.Runtime.Tests")] diff --git a/src/Moryx.Shifts.Endpoints/Models/Extensions.cs b/src/Moryx.Shifts.Endpoints/Models/Extensions.cs index 25419e890d..010cc041c5 100644 --- a/src/Moryx.Shifts.Endpoints/Models/Extensions.cs +++ b/src/Moryx.Shifts.Endpoints/Models/Extensions.cs @@ -43,4 +43,4 @@ public static ShiftTypeCreationContext FromModel(this ShiftTypeCreationContextMo public static ShiftAssignementCreationContext FromModel(this ShiftAssignementCreationContextModel model, Shift shift, IResource resource, Operator @operator) => new(shift, resource, @operator) { Priority = model.Priority, Note = model.Note, AssignedDays = model.AssignedDays }; -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementCreationContextModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementCreationContextModel.cs index 3cf222a287..eb4f1ed5e4 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementCreationContextModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementCreationContextModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using System.Runtime.Serialization; @@ -46,4 +46,4 @@ public class ShiftAssignementCreationContextModel /// [DataMember] public AssignedDays AssignedDays { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementModel.cs index 7b0fb14faa..3f1cc24f8f 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftAssignementModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using System.Runtime.Serialization; @@ -52,4 +52,4 @@ public class ShiftAssignementModel /// [DataMember] public AssignedDays AssignedDays { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftCreationContextModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftCreationContextModel.cs index c7619a2344..ebd3637c89 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftCreationContextModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftCreationContextModel.cs @@ -23,4 +23,4 @@ public class ShiftCreationContextModel [DataMember] //[DataType(DataType.Date)] public DateOnly Date { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftCriteria.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftCriteria.cs index 7c3a9ceeeb..3d5af21235 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftCriteria.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftCriteria.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using System.Runtime.Serialization; @@ -14,4 +14,4 @@ public class ShiftCriteria [DataMember] public DateOnly? LatestDate { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftModel.cs index e84693ac13..2b0fcbbeb5 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftModel.cs @@ -29,4 +29,4 @@ public class ShiftModel [DataMember] //[DataType(DataType.Date)] public DateOnly Date { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftTypeCreationContextModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftTypeCreationContextModel.cs index c911b9c019..37e53ad85b 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftTypeCreationContextModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftTypeCreationContextModel.cs @@ -36,4 +36,4 @@ public class ShiftTypeCreationContextModel /// [DataMember] public byte Periode { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/Models/ShiftTypeModel.cs b/src/Moryx.Shifts.Endpoints/Models/ShiftTypeModel.cs index b4a47e0592..ab395132e1 100644 --- a/src/Moryx.Shifts.Endpoints/Models/ShiftTypeModel.cs +++ b/src/Moryx.Shifts.Endpoints/Models/ShiftTypeModel.cs @@ -42,4 +42,4 @@ public class ShiftTypeModel /// [DataMember] public byte Periode { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Endpoints/ShiftManagementController.cs b/src/Moryx.Shifts.Endpoints/ShiftManagementController.cs index 06f7c32c5e..534b544b93 100644 --- a/src/Moryx.Shifts.Endpoints/ShiftManagementController.cs +++ b/src/Moryx.Shifts.Endpoints/ShiftManagementController.cs @@ -79,7 +79,9 @@ public ActionResult CreateShift(ShiftCreationContextModel context) { var type = _shiftManagement.GetShiftType(context.TypeId); if (type is null) + { return UnprocessableEntity($"No {nameof(ShiftType)} could be found for provided {nameof(context.TypeId)}"); + } var result = _shiftManagement.CreateShift(context.FromModel(type)).ToModel(); return Ok(result); @@ -101,7 +103,9 @@ public ActionResult UpdateShift(ShiftModel model) { var type = _shiftManagement.GetShiftType(model.TypeId); if (type is null) + { return UnprocessableEntity($"No {nameof(ShiftType)} could be found for provided {nameof(model.TypeId)}"); + } _shiftManagement.UpdateShift(model.FromModel(type)); return NoContent(); @@ -162,7 +166,9 @@ public ActionResult CreateShiftType(ShiftTypeCreationContextMode try { if (context.Name is null) + { return UnprocessableEntity($"{nameof(context.Name)} must not be null"); + } var result = _shiftManagement.CreateShiftType(context.FromModel()).ToModel(); return base.Ok(result); @@ -262,18 +268,26 @@ public ActionResult CreateShiftAssignement(ShiftAssigneme { var shift = _shiftManagement.GetShift(context.ShiftId); if (shift is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(Shift), nameof(context.ShiftId))); + } var resource = _resourceManagement.GetResource(context.ResourceId); if (resource is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(IResource), nameof(context.ResourceId))); + } if (context.OperatorIdentifier is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_NotNull, nameof(context.OperatorIdentifier))); + } var @operator = _operatorManagement.Operators.FirstOrDefault(x => x.Identifier == context.OperatorIdentifier); if (@operator is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(Operator), nameof(context.OperatorIdentifier))); + } var result = _shiftManagement.CreateShiftAssignement(context.FromModel(shift, resource, @operator)).ToModel(); return Ok(result); @@ -295,18 +309,26 @@ public ActionResult UpdateShiftAssignement(ShiftAssignementModel shiftAssignemen { var shift = _shiftManagement.GetShift(shiftAssignement.ShiftId); if (shift is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(Shift), nameof(shiftAssignement.ShiftId))); + } var resource = _resourceManagement.GetResource(shiftAssignement.ResourceId); if (resource is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(IResource), nameof(shiftAssignement.ResourceId))); + } if (shiftAssignement.OperatorIdentifier is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_NotNull, nameof(shiftAssignement.OperatorIdentifier))); + } var @operator = _operatorManagement.Operators.FirstOrDefault(x => x.Identifier == shiftAssignement.OperatorIdentifier); if (@operator is null) + { return UnprocessableEntity(string.Format(CultureInfo.CurrentCulture, Strings.ShiftManagementController_IdNotFound, nameof(Operator), nameof(shiftAssignement.OperatorIdentifier))); + } _shiftManagement.UpdateShiftAssignement(shiftAssignement.FromModel(shift, resource, @operator)); return NoContent(); diff --git a/src/Moryx.Shifts.Management/Implementation/IShiftManager.cs b/src/Moryx.Shifts.Management/Implementation/IShiftManager.cs index b758a1d33a..8a72ce60a3 100644 --- a/src/Moryx.Shifts.Management/Implementation/IShiftManager.cs +++ b/src/Moryx.Shifts.Management/Implementation/IShiftManager.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Modules; @@ -25,4 +25,4 @@ internal interface IShiftManager : IPlugin event EventHandler ShiftsChanged; event EventHandler ShiftTypesChanged; event EventHandler ShiftAssignementsChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Implementation/IShiftStorage.cs b/src/Moryx.Shifts.Management/Implementation/IShiftStorage.cs index 60ed18032c..9dd6eebe52 100644 --- a/src/Moryx.Shifts.Management/Implementation/IShiftStorage.cs +++ b/src/Moryx.Shifts.Management/Implementation/IShiftStorage.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Modules; @@ -22,4 +22,4 @@ internal interface IShiftStorage : IPlugin ShiftAssignement Create(ShiftAssignementCreationContext context); void Update(ShiftAssignement assignement); void Delete(ShiftAssignement assignement); -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Implementation/ShiftManager.cs b/src/Moryx.Shifts.Management/Implementation/ShiftManager.cs index be38b11893..633a76d363 100644 --- a/src/Moryx.Shifts.Management/Implementation/ShiftManager.cs +++ b/src/Moryx.Shifts.Management/Implementation/ShiftManager.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Runtime.CompilerServices; using Microsoft.Extensions.Logging; using Moryx.Container; using Moryx.Logging; -using Moryx.Tools; -using System.Runtime.CompilerServices; using Moryx.Shifts.Management.Model; +using Moryx.Tools; [assembly: InternalsVisibleTo("Moryx.Shift.Management.IntegrationTests")] @@ -162,4 +162,4 @@ public void UpdateShiftAssignement(ShiftAssignement assignement) } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Implementation/ShiftStorage.cs b/src/Moryx.Shifts.Management/Implementation/ShiftStorage.cs index 7d70ee90cd..7fd39dfc86 100644 --- a/src/Moryx.Shifts.Management/Implementation/ShiftStorage.cs +++ b/src/Moryx.Shifts.Management/Implementation/ShiftStorage.cs @@ -158,4 +158,4 @@ public void Delete(ShiftAssignement assignement) uow.SaveChanges(); } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/API/IShiftAssignementRepository.cs b/src/Moryx.Shifts.Management/Model/API/IShiftAssignementRepository.cs index acc4289987..e021b17d8c 100644 --- a/src/Moryx.Shifts.Management/Model/API/IShiftAssignementRepository.cs +++ b/src/Moryx.Shifts.Management/Model/API/IShiftAssignementRepository.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Model.Repositories; @@ -29,4 +29,4 @@ private static ShiftAssignementEntity From(ShiftAssignementCreationContext conte AssignedDays = context.AssignedDays, }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/API/IShiftRepository.cs b/src/Moryx.Shifts.Management/Model/API/IShiftRepository.cs index 1caa954eb1..49cdcf1f3b 100644 --- a/src/Moryx.Shifts.Management/Model/API/IShiftRepository.cs +++ b/src/Moryx.Shifts.Management/Model/API/IShiftRepository.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Model.Repositories; @@ -25,4 +25,4 @@ private static ShiftEntity From(ShiftCreationContext context) Date = context.Date, }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/API/IShiftTypeRepository.cs b/src/Moryx.Shifts.Management/Model/API/IShiftTypeRepository.cs index d896c47dd1..0a1d75f821 100644 --- a/src/Moryx.Shifts.Management/Model/API/IShiftTypeRepository.cs +++ b/src/Moryx.Shifts.Management/Model/API/IShiftTypeRepository.cs @@ -27,4 +27,4 @@ private static ShiftTypeEntity From(ShiftTypeCreationContext context) Periode = context.Periode, }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Entities/EntityExtensions.cs b/src/Moryx.Shifts.Management/Model/Entities/EntityExtensions.cs index d4ca725de9..a3aacf949e 100644 --- a/src/Moryx.Shifts.Management/Model/Entities/EntityExtensions.cs +++ b/src/Moryx.Shifts.Management/Model/Entities/EntityExtensions.cs @@ -110,4 +110,4 @@ public ShiftAssignement ToAssignement(IEnumerable shifts, }; } } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Entities/ShiftAssignementEntity.cs b/src/Moryx.Shifts.Management/Model/Entities/ShiftAssignementEntity.cs index 51869e0c28..e4e51b93ab 100644 --- a/src/Moryx.Shifts.Management/Model/Entities/ShiftAssignementEntity.cs +++ b/src/Moryx.Shifts.Management/Model/Entities/ShiftAssignementEntity.cs @@ -41,4 +41,4 @@ public override long Id public virtual ShiftEntity Shift { get; set; } #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Entities/ShiftEntity.cs b/src/Moryx.Shifts.Management/Model/Entities/ShiftEntity.cs index 9ee54e99c2..e6af5d1a33 100644 --- a/src/Moryx.Shifts.Management/Model/Entities/ShiftEntity.cs +++ b/src/Moryx.Shifts.Management/Model/Entities/ShiftEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -37,4 +37,4 @@ public enum ShiftState New, Released, Obsolete -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Entities/ShiftTypeEntity.cs b/src/Moryx.Shifts.Management/Model/Entities/ShiftTypeEntity.cs index 10957be3fd..0da0713d02 100644 --- a/src/Moryx.Shifts.Management/Model/Entities/ShiftTypeEntity.cs +++ b/src/Moryx.Shifts.Management/Model/Entities/ShiftTypeEntity.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -29,4 +29,4 @@ public override long Id [Required] public byte Periode { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20240613104936_InitialCreate.cs b/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20240613104936_InitialCreate.cs index 27cbd3b9f8..5765f7f451 100644 --- a/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20240613104936_InitialCreate.cs +++ b/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20240613104936_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -117,4 +117,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "ShiftTypeEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20251030111003_TableNames.cs b/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20251030111003_TableNames.cs index 5625c9acc6..de0b7a9e30 100644 --- a/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20251030111003_TableNames.cs +++ b/src/Moryx.Shifts.Management/Model/Migrations/Npgsql/20251030111003_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -203,4 +203,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20240613105036_InitialCreate.cs b/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20240613105036_InitialCreate.cs index b43802153c..b301dbdad7 100644 --- a/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20240613105036_InitialCreate.cs +++ b/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20240613105036_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -116,4 +116,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "ShiftTypeEntities", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20251030111012_TableNames.cs b/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20251030111012_TableNames.cs index 0c8a628c1e..87beceb819 100644 --- a/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20251030111012_TableNames.cs +++ b/src/Moryx.Shifts.Management/Model/Migrations/Sqlite/20251030111012_TableNames.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -203,4 +203,4 @@ protected override void Down(MigrationBuilder migrationBuilder) principalColumn: "Id", onDelete: ReferentialAction.Cascade); } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/NpgsqlShiftsContext.cs b/src/Moryx.Shifts.Management/Model/NpgsqlShiftsContext.cs index 25aa41dbb4..26e1cd7e8c 100644 --- a/src/Moryx.Shifts.Management/Model/NpgsqlShiftsContext.cs +++ b/src/Moryx.Shifts.Management/Model/NpgsqlShiftsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; @@ -19,4 +19,4 @@ public NpgsqlShiftsContext() public NpgsqlShiftsContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/ShiftsContext.cs b/src/Moryx.Shifts.Management/Model/ShiftsContext.cs index df40544508..118e5dc02b 100644 --- a/src/Moryx.Shifts.Management/Model/ShiftsContext.cs +++ b/src/Moryx.Shifts.Management/Model/ShiftsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; @@ -48,4 +48,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) public virtual DbSet ShiftTypes { get; set; } public virtual DbSet ShiftAssignements { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/Model/SqliteShiftsContext.cs b/src/Moryx.Shifts.Management/Model/SqliteShiftsContext.cs index 0b991fdf91..dfdfaf6af5 100644 --- a/src/Moryx.Shifts.Management/Model/SqliteShiftsContext.cs +++ b/src/Moryx.Shifts.Management/Model/SqliteShiftsContext.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore; @@ -19,4 +19,4 @@ public SqliteShiftsContext() public SqliteShiftsContext(DbContextOptions options) : base(options) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/ModuleController/ModuleConfig.cs b/src/Moryx.Shifts.Management/ModuleController/ModuleConfig.cs index 5d7dd608f4..2ae60aa47d 100644 --- a/src/Moryx.Shifts.Management/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Shifts.Management/ModuleController/ModuleConfig.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using System.Runtime.Serialization; @@ -12,4 +12,4 @@ namespace Moryx.Shifts.Management; [DataContract] public class ModuleConfig : ConfigBase { -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts.Management/ModuleController/ModuleConsole.cs b/src/Moryx.Shifts.Management/ModuleController/ModuleConsole.cs index cb68ffc9c3..df8423a0ec 100644 --- a/src/Moryx.Shifts.Management/ModuleController/ModuleConsole.cs +++ b/src/Moryx.Shifts.Management/ModuleController/ModuleConsole.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moryx.Runtime.Modules; @@ -8,4 +8,4 @@ namespace Moryx.Shifts.Management; [ServerModuleConsole] internal class ModuleConsole : IServerModuleConsole { -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/AssignedDays.cs b/src/Moryx.Shifts/AssignedDays.cs index 118e0c6f76..11d5887384 100644 --- a/src/Moryx.Shifts/AssignedDays.cs +++ b/src/Moryx.Shifts/AssignedDays.cs @@ -41,4 +41,4 @@ public enum AssignedDays TwentyNinth = 1 << 28, Thirtieth = 1 << 29, ThirtyFirst = 1 << 30 -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/IShiftManagement.cs b/src/Moryx.Shifts/IShiftManagement.cs index 21a20c6c07..749f5ce562 100644 --- a/src/Moryx.Shifts/IShiftManagement.cs +++ b/src/Moryx.Shifts/IShiftManagement.cs @@ -83,4 +83,4 @@ public interface IShiftManagement /// Event triggered when a shift assignment is changed. /// event EventHandler AssignementsChanged; -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/Shift.cs b/src/Moryx.Shifts/Shift.cs index ef9c197db5..94ac4a250f 100644 --- a/src/Moryx.Shifts/Shift.cs +++ b/src/Moryx.Shifts/Shift.cs @@ -27,4 +27,4 @@ public class Shift : IPersistentObject /// The date of the shift. /// public DateOnly Date { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftAssignement.cs b/src/Moryx.Shifts/ShiftAssignement.cs index e1865c49fd..793dbde9c4 100644 --- a/src/Moryx.Shifts/ShiftAssignement.cs +++ b/src/Moryx.Shifts/ShiftAssignement.cs @@ -55,4 +55,4 @@ public ShiftAssignement(IResource resource, Operator @operator, Shift shift) Operator = @operator; Shift = shift; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftAssignementChange.cs b/src/Moryx.Shifts/ShiftAssignementChange.cs index 42d4629f57..3e50521e75 100644 --- a/src/Moryx.Shifts/ShiftAssignementChange.cs +++ b/src/Moryx.Shifts/ShiftAssignementChange.cs @@ -11,4 +11,4 @@ public enum ShiftAssignementChange Creation, Update, Deletion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftAssignementCreationContext.cs b/src/Moryx.Shifts/ShiftAssignementCreationContext.cs index f5093c3c01..1a1e9d7bcf 100644 --- a/src/Moryx.Shifts/ShiftAssignementCreationContext.cs +++ b/src/Moryx.Shifts/ShiftAssignementCreationContext.cs @@ -51,4 +51,4 @@ public ShiftAssignementCreationContext(Shift shift, IResource resource, Operator Resource = resource; Operator = @operator; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftAssignementsChangedEventArgs.cs b/src/Moryx.Shifts/ShiftAssignementsChangedEventArgs.cs index 5f97edaa3f..a54ede5c3a 100644 --- a/src/Moryx.Shifts/ShiftAssignementsChangedEventArgs.cs +++ b/src/Moryx.Shifts/ShiftAssignementsChangedEventArgs.cs @@ -26,4 +26,4 @@ public ShiftAssignementsChangedEventArgs(ShiftAssignementChange change, ShiftAss Change = change; Assignement = assignement; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftChange.cs b/src/Moryx.Shifts/ShiftChange.cs index a50986c781..65f23289e2 100644 --- a/src/Moryx.Shifts/ShiftChange.cs +++ b/src/Moryx.Shifts/ShiftChange.cs @@ -11,4 +11,4 @@ public enum ShiftChange Creation, Update, Deletion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftCreationContext.cs b/src/Moryx.Shifts/ShiftCreationContext.cs index 9adeb9d62b..929621c252 100644 --- a/src/Moryx.Shifts/ShiftCreationContext.cs +++ b/src/Moryx.Shifts/ShiftCreationContext.cs @@ -25,4 +25,4 @@ public ShiftCreationContext(ShiftType type) { Type = type; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftManagementExtensions.cs b/src/Moryx.Shifts/ShiftManagementExtensions.cs index 360474bbfd..369bdc6386 100644 --- a/src/Moryx.Shifts/ShiftManagementExtensions.cs +++ b/src/Moryx.Shifts/ShiftManagementExtensions.cs @@ -12,7 +12,10 @@ public static class ShiftManagementExtensions public IEnumerable GetShifts(DateOnly? earliestDate, DateOnly? latestDate) { IEnumerable shifts = source.Shifts; - if (!earliestDate.HasValue && !latestDate.HasValue) return shifts; + if (!earliestDate.HasValue && !latestDate.HasValue) + { + return shifts; + } if (earliestDate.HasValue) { @@ -29,10 +32,13 @@ public IEnumerable GetShifts(DateOnly? earliestDate, DateOnly? latestDate public IEnumerable GetShiftAssignements(DateOnly? earliestDate, DateOnly? latestDate) { - if (!earliestDate.HasValue && !latestDate.HasValue) return source.ShiftAssignements; + if (!earliestDate.HasValue && !latestDate.HasValue) + { + return source.ShiftAssignements; + } IEnumerable shifts = source.GetShifts(earliestDate, latestDate); return source.ShiftAssignements.Where(a => shifts.Contains(a.Shift)); } } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftType.cs b/src/Moryx.Shifts/ShiftType.cs index 2ec17ba289..29ea74da88 100644 --- a/src/Moryx.Shifts/ShiftType.cs +++ b/src/Moryx.Shifts/ShiftType.cs @@ -40,4 +40,4 @@ public ShiftType(string name) { Name = name; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftTypeChange.cs b/src/Moryx.Shifts/ShiftTypeChange.cs index 26a273895e..dd043895aa 100644 --- a/src/Moryx.Shifts/ShiftTypeChange.cs +++ b/src/Moryx.Shifts/ShiftTypeChange.cs @@ -11,4 +11,4 @@ public enum ShiftTypeChange Creation, Update, Deletion -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftTypeCreationContext.cs b/src/Moryx.Shifts/ShiftTypeCreationContext.cs index f5178b16a2..463c247797 100644 --- a/src/Moryx.Shifts/ShiftTypeCreationContext.cs +++ b/src/Moryx.Shifts/ShiftTypeCreationContext.cs @@ -35,4 +35,4 @@ public ShiftTypeCreationContext(string name) { Name = name; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftTypesChangedEventArgs.cs b/src/Moryx.Shifts/ShiftTypesChangedEventArgs.cs index 4415664718..09f472d1d0 100644 --- a/src/Moryx.Shifts/ShiftTypesChangedEventArgs.cs +++ b/src/Moryx.Shifts/ShiftTypesChangedEventArgs.cs @@ -26,4 +26,4 @@ public ShiftTypesChangedEventArgs(ShiftTypeChange change, ShiftType type) Change = change; Type = type; } -} \ No newline at end of file +} diff --git a/src/Moryx.Shifts/ShiftsChangedEventArgs.cs b/src/Moryx.Shifts/ShiftsChangedEventArgs.cs index 3bff701954..a5abbbb752 100644 --- a/src/Moryx.Shifts/ShiftsChangedEventArgs.cs +++ b/src/Moryx.Shifts/ShiftsChangedEventArgs.cs @@ -26,4 +26,4 @@ public ShiftsChangedEventArgs(ShiftChange change, Shift shift) Change = change; Shift = shift; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Controllers/TestController.cs b/src/Moryx.TestModule/Controllers/TestController.cs index 88e851405b..aea283b010 100644 --- a/src/Moryx.TestModule/Controllers/TestController.cs +++ b/src/Moryx.TestModule/Controllers/TestController.cs @@ -16,4 +16,4 @@ public class TestController : ControllerBase public class Foo { public int Value { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Facades/ITestModule.cs b/src/Moryx.TestModule/Facades/ITestModule.cs index 5e4bcec3dd..12c6c5e02d 100644 --- a/src/Moryx.TestModule/Facades/ITestModule.cs +++ b/src/Moryx.TestModule/Facades/ITestModule.cs @@ -11,4 +11,4 @@ public interface ITestModule int Bla { get; } int Foo(int a, int b); -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Facades/TestModuleFacade.cs b/src/Moryx.TestModule/Facades/TestModuleFacade.cs index 21fa433a44..2a041b2bb2 100644 --- a/src/Moryx.TestModule/Facades/TestModuleFacade.cs +++ b/src/Moryx.TestModule/Facades/TestModuleFacade.cs @@ -10,4 +10,4 @@ public class TestModuleFacade : FacadeBase, ITestModule public int Bla => ++field; public int Foo(int a, int b) => a + b; -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/JsonTest.cs b/src/Moryx.TestModule/JsonTest.cs index 4fd5da680b..cef0eb2284 100644 --- a/src/Moryx.TestModule/JsonTest.cs +++ b/src/Moryx.TestModule/JsonTest.cs @@ -167,7 +167,7 @@ private long[] TestLoop(ModuleConfig config, JsonSerializerSettings jsonSettings stopWatch.Restart(); foreach (var id in ids) { - var result = ReadLoop(uow, id, jsonSettings); + _ = ReadLoop(uow, id, jsonSettings); } stopWatch.Stop(); } @@ -187,8 +187,8 @@ private static long WriteLoop(IUnitOfWork uow, ModuleConfig config, JsonSerializ private static ConfigBase ReadLoop(IUnitOfWork uow, long id, JsonSerializerSettings settings) { var json = (from e in uow.GetRepository().Linq - where e.Id == id - select e.JsonData).FirstOrDefault(); + where e.Id == id + select e.JsonData).FirstOrDefault(); return JsonConvert.DeserializeObject(json, settings); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/ModuleController/ModuleConfig.cs b/src/Moryx.TestModule/ModuleController/ModuleConfig.cs index 171daf15e0..103ac75244 100644 --- a/src/Moryx.TestModule/ModuleController/ModuleConfig.cs +++ b/src/Moryx.TestModule/ModuleController/ModuleConfig.cs @@ -68,4 +68,4 @@ public class ModuleConfig : ConfigBase [DataMember] [DefaultValue(2000)] public int SleepTime { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/ModuleController/ModuleConsole.cs b/src/Moryx.TestModule/ModuleController/ModuleConsole.cs index 50deef1915..de7c24c6db 100644 --- a/src/Moryx.TestModule/ModuleController/ModuleConsole.cs +++ b/src/Moryx.TestModule/ModuleController/ModuleConsole.cs @@ -2,9 +2,9 @@ // Licensed under the Apache License, Version 2.0 using System.ComponentModel; +using Moryx.Container; using Moryx.Runtime.Modules; using Moryx.Serialization; -using Moryx.Container; using IContainer = Moryx.Container.IContainer; namespace Moryx.TestModule; @@ -62,19 +62,19 @@ internal class ModuleConsole : IServerModuleConsole public IContainer Container { get; set; } [EntrySerialize, Description("Returns the string that was sent.")] - public string Echo(string message) + public static string Echo(string message) { return $"Echo: {message}"; } [EntrySerialize, Description("Some short information about the server.")] - public ShortServerInfo ServerInfo() + public static ShortServerInfo ServerInfo() { return new ShortServerInfo().Fill(); } [EntrySerialize, Description("Echos short information about the server.")] - public ShortServerInfo EchoServerInfo(ShortServerInfo shortServerInfo) + public static ShortServerInfo EchoServerInfo(ShortServerInfo shortServerInfo) { return shortServerInfo; } @@ -86,7 +86,7 @@ public ModuleConfig CurrentModuleConfig() } [EntrySerialize, Description("Echos a module config.")] - public ModuleConfig EchoModuleConfig(ModuleConfig moduleConfig) + public static ModuleConfig EchoModuleConfig(ModuleConfig moduleConfig) { return moduleConfig; } @@ -99,8 +99,8 @@ public void JsonTest() } [EntrySerialize, Description("Executes the async method")] - public Task TestAsync() + public static Task TestAsync() { return Task.FromResult("Test"); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/ModuleController/ModuleController.cs b/src/Moryx.TestModule/ModuleController/ModuleController.cs index 0913d8ec38..264ecbd710 100644 --- a/src/Moryx.TestModule/ModuleController/ModuleController.cs +++ b/src/Moryx.TestModule/ModuleController/ModuleController.cs @@ -75,4 +75,4 @@ protected override async Task OnStopAsync(CancellationToken cancellationToken) ITestModule IFacadeContainer.Facade => _testModule; #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/AnotherPlugin.cs b/src/Moryx.TestModule/Plugin/AnotherPlugin.cs index a24b990401..7b9b01b26b 100644 --- a/src/Moryx.TestModule/Plugin/AnotherPlugin.cs +++ b/src/Moryx.TestModule/Plugin/AnotherPlugin.cs @@ -82,4 +82,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/AnotherPluginConfig.cs b/src/Moryx.TestModule/Plugin/AnotherPluginConfig.cs index 7c7c35d880..dce2485013 100644 --- a/src/Moryx.TestModule/Plugin/AnotherPluginConfig.cs +++ b/src/Moryx.TestModule/Plugin/AnotherPluginConfig.cs @@ -40,4 +40,4 @@ public class AnotherSubConfig2 : AnotherSubConfig { [DataMember] public int Value { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/IAnotherPlugin.cs b/src/Moryx.TestModule/Plugin/IAnotherPlugin.cs index 2df8b6ecbf..dd98e77959 100644 --- a/src/Moryx.TestModule/Plugin/IAnotherPlugin.cs +++ b/src/Moryx.TestModule/Plugin/IAnotherPlugin.cs @@ -13,4 +13,4 @@ public interface IAnotherPlugin : IConfiguredPlugin public interface IAnotherSubPlugin : IConfiguredPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/ITestPlugin.cs b/src/Moryx.TestModule/Plugin/ITestPlugin.cs index 3f7cb061b9..5a168cbe84 100644 --- a/src/Moryx.TestModule/Plugin/ITestPlugin.cs +++ b/src/Moryx.TestModule/Plugin/ITestPlugin.cs @@ -8,4 +8,4 @@ namespace Moryx.TestModule; public interface ITestPlugin : IConfiguredPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/ITestSubPlugin.cs b/src/Moryx.TestModule/Plugin/ITestSubPlugin.cs index 6573736a9b..58f7f27902 100644 --- a/src/Moryx.TestModule/Plugin/ITestSubPlugin.cs +++ b/src/Moryx.TestModule/Plugin/ITestSubPlugin.cs @@ -8,4 +8,4 @@ namespace Moryx.TestModule; public interface ITestSubPlugin : IConfiguredPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPlugin.cs b/src/Moryx.TestModule/Plugin/TestPlugin.cs index 490f798a47..27f3c91368 100644 --- a/src/Moryx.TestModule/Plugin/TestPlugin.cs +++ b/src/Moryx.TestModule/Plugin/TestPlugin.cs @@ -27,4 +27,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPlugin1.cs b/src/Moryx.TestModule/Plugin/TestPlugin1.cs index 5091c0a8a0..1418bdab67 100644 --- a/src/Moryx.TestModule/Plugin/TestPlugin1.cs +++ b/src/Moryx.TestModule/Plugin/TestPlugin1.cs @@ -23,4 +23,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPlugin2.cs b/src/Moryx.TestModule/Plugin/TestPlugin2.cs index 6d647350d6..b744c2db72 100644 --- a/src/Moryx.TestModule/Plugin/TestPlugin2.cs +++ b/src/Moryx.TestModule/Plugin/TestPlugin2.cs @@ -23,4 +23,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPluginConfig.cs b/src/Moryx.TestModule/Plugin/TestPluginConfig.cs index a3c8beaa85..d5f469e88d 100644 --- a/src/Moryx.TestModule/Plugin/TestPluginConfig.cs +++ b/src/Moryx.TestModule/Plugin/TestPluginConfig.cs @@ -49,4 +49,4 @@ public class TestPluginConfig : IPluginConfig [PluginConfigs(typeof(ITestSubPlugin), false)] public List SubPlugins { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPluginConfig1.cs b/src/Moryx.TestModule/Plugin/TestPluginConfig1.cs index 6ac3db9633..921586aa04 100644 --- a/src/Moryx.TestModule/Plugin/TestPluginConfig1.cs +++ b/src/Moryx.TestModule/Plugin/TestPluginConfig1.cs @@ -30,4 +30,4 @@ public TestPluginConfig1() /// [DataMember] public List OrderSources { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestPluginConfig2.cs b/src/Moryx.TestModule/Plugin/TestPluginConfig2.cs index db4447eb75..0bdb7b230a 100644 --- a/src/Moryx.TestModule/Plugin/TestPluginConfig2.cs +++ b/src/Moryx.TestModule/Plugin/TestPluginConfig2.cs @@ -16,4 +16,4 @@ public class TestPluginConfig2 : TestPluginConfig [PluginNameSelector(typeof(ITestPlugin))] [DefaultValue(TestPlugin2.ComponentName)] public override string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPlugin.cs b/src/Moryx.TestModule/Plugin/TestSubPlugin.cs index 10c9f4cd98..c67c270006 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPlugin.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPlugin.cs @@ -27,4 +27,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPlugin1.cs b/src/Moryx.TestModule/Plugin/TestSubPlugin1.cs index d2fb6bfa37..3087376c61 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPlugin1.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPlugin1.cs @@ -23,4 +23,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPlugin2.cs b/src/Moryx.TestModule/Plugin/TestSubPlugin2.cs index 89b6c5b7da..04f0a45ae3 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPlugin2.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPlugin2.cs @@ -27,4 +27,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPluginConfig.cs b/src/Moryx.TestModule/Plugin/TestSubPluginConfig.cs index c1beb5c6ad..bbba8bd005 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPluginConfig.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPluginConfig.cs @@ -10,4 +10,4 @@ namespace Moryx.TestModule; public class TestSubPluginConfig : IPluginConfig { public virtual string PluginName { get { return TestSubPlugin.ComponentName; } } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPluginConfig1.cs b/src/Moryx.TestModule/Plugin/TestSubPluginConfig1.cs index 77f535277e..e1bb2ee504 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPluginConfig1.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPluginConfig1.cs @@ -59,4 +59,4 @@ public override string ToString() { return "Source: '" + (!string.IsNullOrWhiteSpace(SourceName) ? SourceName : string.Empty) + "' ID: '" + SourceId + "'"; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestModule/Plugin/TestSubPluginConfig2.cs b/src/Moryx.TestModule/Plugin/TestSubPluginConfig2.cs index 465bd3bccc..ad5aec7900 100644 --- a/src/Moryx.TestModule/Plugin/TestSubPluginConfig2.cs +++ b/src/Moryx.TestModule/Plugin/TestSubPluginConfig2.cs @@ -10,4 +10,4 @@ public class TestSubPluginConfig2 : TestSubPluginConfig { public override string PluginName { get { return TestSubPlugin2.ComponentName; } } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.IntegrationTest/MoryxTestEnvironment.cs b/src/Moryx.TestTools.IntegrationTest/MoryxTestEnvironment.cs index c3111a03ab..496887cc63 100644 --- a/src/Moryx.TestTools.IntegrationTest/MoryxTestEnvironment.cs +++ b/src/Moryx.TestTools.IntegrationTest/MoryxTestEnvironment.cs @@ -2,12 +2,12 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.Configuration; -using Moryx.Model.InMemory; using Moryx.Model; +using Moryx.Model.InMemory; using Moryx.Runtime.Kernel; using Moryx.Runtime.Modules; using Moryx.TestTools.UnitTest; @@ -44,7 +44,9 @@ public MoryxTestEnvironment(Type serverModuleType, IEnumerable dependencyM _moduleType = serverModuleType; if (!serverModuleType.IsAssignableTo(typeof(IServerModule))) + { throw new ArgumentException("Provided parameter is no server module.", nameof(serverModuleType)); + } var dependencyTypes = serverModuleType.GetProperties() .Where(p => p.GetCustomAttribute() is not null) @@ -105,7 +107,9 @@ public async Task StartTestModuleAsync(CancellationToken cancella var strategies = module.GetType().GetProperty(nameof(ServerModuleBase.Strategies)).GetValue(module) as Dictionary; if (strategies is not null && !strategies.Any(s => s.Value == nameof(NotSoParallelOps))) + { strategies.Add(typeof(IParallelOperations), nameof(NotSoParallelOps)); + } await module.StartAsync(cancellationToken); return module; diff --git a/src/Moryx.TestTools.Test.Model/API/IAnotherEntityRepository.cs b/src/Moryx.TestTools.Test.Model/API/IAnotherEntityRepository.cs index c2746ed8c2..58716f25d3 100644 --- a/src/Moryx.TestTools.Test.Model/API/IAnotherEntityRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/IAnotherEntityRepository.cs @@ -7,4 +7,4 @@ namespace Moryx.TestTools.Test.Model; public interface IAnotherEntityRepository : IRepository { -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/ICarEntityRepository.cs b/src/Moryx.TestTools.Test.Model/API/ICarEntityRepository.cs index e73ef537ec..eb8c4d51f3 100644 --- a/src/Moryx.TestTools.Test.Model/API/ICarEntityRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/ICarEntityRepository.cs @@ -38,4 +38,4 @@ public interface ICarEntityRepository : IRepository ICollection GetAllByName(string name); // postfix does not change behavior ICollection GetAllContainsName(string name); // postfix does not change behavior ICollection GetAllByNameAndPrice(string name, int price); // postfix does not change behavior -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/IHouseEntityRepository.cs b/src/Moryx.TestTools.Test.Model/API/IHouseEntityRepository.cs index 0f8815e07d..d867d4ca98 100644 --- a/src/Moryx.TestTools.Test.Model/API/IHouseEntityRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/IHouseEntityRepository.cs @@ -17,4 +17,4 @@ public virtual ICollection GetMethLabratories() // This method should not be proxied return DbSet.Where(h => h.IsMethLabratory).ToList(); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/IHugePocoRepository.cs b/src/Moryx.TestTools.Test.Model/API/IHugePocoRepository.cs index e00a6e62f8..91055c2cbc 100644 --- a/src/Moryx.TestTools.Test.Model/API/IHugePocoRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/IHugePocoRepository.cs @@ -17,4 +17,4 @@ public interface IHugePocoRepository : IRepository HugePocoEntity GetBy(double float2, string name2, int number2); IEnumerable GetAllBy(double float3, string name3, int number3); -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/IJsonEntityRepository.cs b/src/Moryx.TestTools.Test.Model/API/IJsonEntityRepository.cs index 30a271fee3..5b5574df86 100644 --- a/src/Moryx.TestTools.Test.Model/API/IJsonEntityRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/IJsonEntityRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.TestTools.Test.Model; public interface IJsonEntityRepository : IRepository { JsonEntity Create(string jsonData); -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/ISportCarRepository.cs b/src/Moryx.TestTools.Test.Model/API/ISportCarRepository.cs index b17b1ca649..9964bac0a7 100644 --- a/src/Moryx.TestTools.Test.Model/API/ISportCarRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/ISportCarRepository.cs @@ -16,4 +16,4 @@ public virtual SportCarEntity GetSingleBy(string name) { throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/API/IWheelEntityRepository.cs b/src/Moryx.TestTools.Test.Model/API/IWheelEntityRepository.cs index ebd2538dd5..809d50eef5 100644 --- a/src/Moryx.TestTools.Test.Model/API/IWheelEntityRepository.cs +++ b/src/Moryx.TestTools.Test.Model/API/IWheelEntityRepository.cs @@ -10,4 +10,4 @@ public interface IWheelEntityRepository : IRepository WheelEntity Create(WheelType wheelType); WheelEntity Create(WheelType wheelType, CarEntity car); -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/AnotherEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/AnotherEntity.cs index 3240dac39c..0259a5ed77 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/AnotherEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/AnotherEntity.cs @@ -8,4 +8,4 @@ namespace Moryx.TestTools.Test.Model; public class AnotherEntity : ModificationTrackedEntityBase { -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/CarEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/CarEntity.cs index c23487d407..3201e7a90a 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/CarEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/CarEntity.cs @@ -20,4 +20,4 @@ public class CarEntity : ModificationTrackedEntityBase public DateTime ReleaseDateUtc { get; set; } public virtual ICollection Wheels { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/HouseEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/HouseEntity.cs index 711d4a0db7..0d2ae8c1dc 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/HouseEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/HouseEntity.cs @@ -16,4 +16,4 @@ public class HouseEntity : ModificationTrackedEntityBase public virtual bool IsBurnedDown { get; set; } public virtual bool ToRent { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/HugePocoEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/HugePocoEntity.cs index 7836a0f80b..d7f2dc6368 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/HugePocoEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/HugePocoEntity.cs @@ -36,4 +36,4 @@ public class HugePocoEntity : EntityBase public virtual string Name5 { get; set; } public virtual int Number5 { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/JsonEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/JsonEntity.cs index 6bf6840999..f198dae865 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/JsonEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/JsonEntity.cs @@ -8,4 +8,4 @@ namespace Moryx.TestTools.Test.Model; public class JsonEntity : EntityBase { public virtual string JsonData { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/SportCarEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/SportCarEntity.cs index 30a48ddc61..a99ea606d5 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/SportCarEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/SportCarEntity.cs @@ -6,4 +6,4 @@ namespace Moryx.TestTools.Test.Model; public class SportCarEntity : CarEntity { public virtual int Performance { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Entities/WheelEntity.cs b/src/Moryx.TestTools.Test.Model/Entities/WheelEntity.cs index 65efb4359b..ba1dcab39c 100644 --- a/src/Moryx.TestTools.Test.Model/Entities/WheelEntity.cs +++ b/src/Moryx.TestTools.Test.Model/Entities/WheelEntity.cs @@ -18,4 +18,4 @@ public class WheelEntity : EntityBase public virtual CarEntity Car { get; set; } public virtual WheelType WheelType { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Migrations/Npgsql/20251030141744_InitialCreate.cs b/src/Moryx.TestTools.Test.Model/Migrations/Npgsql/20251030141744_InitialCreate.cs index 580d8ba8b5..ee742c5f60 100644 --- a/src/Moryx.TestTools.Test.Model/Migrations/Npgsql/20251030141744_InitialCreate.cs +++ b/src/Moryx.TestTools.Test.Model/Migrations/Npgsql/20251030141744_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -154,4 +154,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Cars", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Migrations/SqlServer/20251030141638_InitialCreate.cs b/src/Moryx.TestTools.Test.Model/Migrations/SqlServer/20251030141638_InitialCreate.cs index 89f57ebbfd..e77cfee075 100644 --- a/src/Moryx.TestTools.Test.Model/Migrations/SqlServer/20251030141638_InitialCreate.cs +++ b/src/Moryx.TestTools.Test.Model/Migrations/SqlServer/20251030141638_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -153,4 +153,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Cars", schema: "resources"); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Migrations/Sqlite/20251030141720_InitialCreate.cs b/src/Moryx.TestTools.Test.Model/Migrations/Sqlite/20251030141720_InitialCreate.cs index 5b752f082d..ca683a469d 100644 --- a/src/Moryx.TestTools.Test.Model/Migrations/Sqlite/20251030141720_InitialCreate.cs +++ b/src/Moryx.TestTools.Test.Model/Migrations/Sqlite/20251030141720_InitialCreate.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Microsoft.EntityFrameworkCore.Migrations; @@ -153,4 +153,4 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Cars", schema: "public"); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Setups/AnySetup.cs b/src/Moryx.TestTools.Test.Model/Setups/AnySetup.cs index 702e5ad2f4..1823f17f5a 100644 --- a/src/Moryx.TestTools.Test.Model/Setups/AnySetup.cs +++ b/src/Moryx.TestTools.Test.Model/Setups/AnySetup.cs @@ -63,4 +63,4 @@ async Task CreateWheel(WheelType wheelType) var allContains = carRepo.Linq.Where(c => c.Name.Contains("Car")); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.Test.Model/Setups/DisposedObjectSetup.cs b/src/Moryx.TestTools.Test.Model/Setups/DisposedObjectSetup.cs index 1a9a0f30f6..0380af6e8e 100644 --- a/src/Moryx.TestTools.Test.Model/Setups/DisposedObjectSetup.cs +++ b/src/Moryx.TestTools.Test.Model/Setups/DisposedObjectSetup.cs @@ -29,4 +29,4 @@ public async Task ExecuteAsync(IUnitOfWork openContext, string setupData, Cancel await Task.Delay(50, cancellationToken); await openContext.DbContext.Database.ExecuteSqlRawAsync("SELECT * FROM \"Cars\"", cancellationToken: cancellationToken); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.UnitTest/BasicInterceptorInstaller.cs b/src/Moryx.TestTools.UnitTest/BasicInterceptorInstaller.cs index 906d804d0e..65864eeea4 100644 --- a/src/Moryx.TestTools.UnitTest/BasicInterceptorInstaller.cs +++ b/src/Moryx.TestTools.UnitTest/BasicInterceptorInstaller.cs @@ -18,4 +18,4 @@ public static void Install(this IContainer container) container.Register(typeof(EmptyInterceptor)); container.Register(typeof(NullLoggerFactory), [typeof(ILoggerFactory)]); } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.UnitTest/EmptyInterceptor.cs b/src/Moryx.TestTools.UnitTest/EmptyInterceptor.cs index 11da47464a..75d91fed55 100644 --- a/src/Moryx.TestTools.UnitTest/EmptyInterceptor.cs +++ b/src/Moryx.TestTools.UnitTest/EmptyInterceptor.cs @@ -19,4 +19,4 @@ public class EmptyInterceptor : IInterceptor public void Intercept(IInvocation invocation) { } -} \ No newline at end of file +} diff --git a/src/Moryx.TestTools.UnitTest/NotSoParallelOps.cs b/src/Moryx.TestTools.UnitTest/NotSoParallelOps.cs index 3b3a74ec7c..e91014d808 100644 --- a/src/Moryx.TestTools.UnitTest/NotSoParallelOps.cs +++ b/src/Moryx.TestTools.UnitTest/NotSoParallelOps.cs @@ -5,7 +5,7 @@ namespace Moryx.TestTools.UnitTest; -internal class TimerInfo +internal sealed class TimerInfo { public int TimerId { get; set; } public Timer Timer { get; set; } @@ -227,4 +227,4 @@ public void Dispose() _timers.Clear(); } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/Components/IVisualInstructionsController.cs b/src/Moryx.VisualInstructions.Controller/Components/IVisualInstructionsController.cs index ce78c3cf66..dfa0d70b8b 100644 --- a/src/Moryx.VisualInstructions.Controller/Components/IVisualInstructionsController.cs +++ b/src/Moryx.VisualInstructions.Controller/Components/IVisualInstructionsController.cs @@ -7,4 +7,4 @@ namespace Moryx.VisualInstructions.Controller; internal interface IVisualInstructionsController : IVisualInstructions, IPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/Components/InstructionProcessor.cs b/src/Moryx.VisualInstructions.Controller/Components/InstructionProcessor.cs index 393dad69ae..358dbbdfb5 100644 --- a/src/Moryx.VisualInstructions.Controller/Components/InstructionProcessor.cs +++ b/src/Moryx.VisualInstructions.Controller/Components/InstructionProcessor.cs @@ -18,10 +18,14 @@ public InstructionProcessor(InstructionProcessorConfig config) _config = config; if (!string.IsNullOrEmpty(config.ContentPattern)) + { _contentRegex = new Regex(config.ContentPattern); + } if (!string.IsNullOrEmpty(config.PreviewPattern)) + { _previewRegex = new Regex(config.PreviewPattern); + } } public void ProcessItem(VisualInstruction item) @@ -34,10 +38,14 @@ public void ProcessItem(VisualInstruction item) { // Fill content with content regex if (_contentRegex != null && !string.IsNullOrEmpty(item.Content)) + { item.Content = _contentRegex.Replace(content, _config.ContentReplacement); + } // If replacement was configured but no regex, we apply the preview regex else if (_previewRegex != null && !string.IsNullOrEmpty(item.Preview)) + { item.Content = _previewRegex.Replace(preview, _config.ContentReplacement); + } } // Apply preview pattern @@ -45,10 +53,14 @@ public void ProcessItem(VisualInstruction item) { // Fill preview with preview regex if (_previewRegex != null && !string.IsNullOrEmpty(item.Preview)) + { item.Preview = _previewRegex.Replace(preview, _config.PreviewReplacement); + } // Fill preview with content regex and content else if (_contentRegex != null && !string.IsNullOrEmpty(item.Content)) + { item.Preview = _contentRegex.Replace(content, _config.PreviewReplacement); + } } } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/Components/VisualInstructionsController.cs b/src/Moryx.VisualInstructions.Controller/Components/VisualInstructionsController.cs index cf0344de51..22448bcd55 100644 --- a/src/Moryx.VisualInstructions.Controller/Components/VisualInstructionsController.cs +++ b/src/Moryx.VisualInstructions.Controller/Components/VisualInstructionsController.cs @@ -75,7 +75,7 @@ public void Stop() Logger?.Log(LogLevel.Information, "Stopped worker support controller"); } - public void Dispose() + public static void Dispose() { } @@ -101,21 +101,28 @@ public IReadOnlyList GetInstructions(string identifier) // Load instructions from sources if (_instructionSources.TryGetValue(identifier, out var source)) + { instructions.AddRange(source.Instructions); + } // Include external instructions if (_facadeInstructions.TryGetValue(identifier, out var instruction)) + { instructions.AddRange(instruction); + } return instructions; } public void AddInstruction(string identifier, ActiveInstruction instruction) { - if (!_facadeInstructions.ContainsKey(identifier)) - _facadeInstructions[identifier] = new List(); + if (!_facadeInstructions.TryGetValue(identifier, out var value)) + { + value = new List(); + _facadeInstructions[identifier] = value; + } - _facadeInstructions[identifier].Add(instruction); + value.Add(instruction); ProcessInstructionItems(instruction); @@ -125,7 +132,9 @@ public void AddInstruction(string identifier, ActiveInstruction instruction) public void ClearInstruction(string identifier, ActiveInstruction instruction) { if (_facadeInstructions.TryGetValue(identifier, out var facadeInstruction)) + { facadeInstruction.Remove(instruction); + } InstructionCleared(this, new InstructionEventArgs(identifier, instruction)); } diff --git a/src/Moryx.VisualInstructions.Controller/Facades/VisualInstructionsFacade.cs b/src/Moryx.VisualInstructions.Controller/Facades/VisualInstructionsFacade.cs index e68262971e..87baf620ea 100644 --- a/src/Moryx.VisualInstructions.Controller/Facades/VisualInstructionsFacade.cs +++ b/src/Moryx.VisualInstructions.Controller/Facades/VisualInstructionsFacade.cs @@ -88,4 +88,4 @@ private void InitialValidateHealthState() public event EventHandler InstructionAdded; public event EventHandler InstructionCleared; -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConfig.cs b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConfig.cs index 90fb2df94c..6fd8942575 100644 --- a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConfig.cs +++ b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConfig.cs @@ -48,4 +48,4 @@ public class InstructionProcessorConfig /// [DataMember] public string PreviewReplacement { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConsole.cs b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConsole.cs index dfe019d24d..4fb6118cfc 100644 --- a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConsole.cs +++ b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleConsole.cs @@ -8,7 +8,7 @@ namespace Moryx.VisualInstructions.Controller; [ServerModuleConsole] internal class ModuleConsole : IServerModuleConsole { - public void ExecuteCommand(string[] args, Action outputStream) + public static void ExecuteCommand(string[] args, Action outputStream) { } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleController.cs b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleController.cs index cecc337e98..54a1488110 100644 --- a/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleController.cs +++ b/src/Moryx.VisualInstructions.Controller/ModuleController/ModuleController.cs @@ -87,4 +87,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) IVisualInstructions IFacadeContainer.Facade => _visualInstructionsFacade; #endregion -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/Converter.cs b/src/Moryx.VisualInstructions.Endpoints/Models/Converter.cs index 824688d404..46bf33460f 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/Converter.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/Converter.cs @@ -6,7 +6,7 @@ namespace Moryx.VisualInstructions.Endpoints; -internal class Converter(ICustomSerialization serialization) +internal sealed class Converter(ICustomSerialization serialization) { internal ICustomSerialization _serialization = serialization; @@ -26,7 +26,9 @@ public InstructionModel ToModel(ActiveInstruction instruction) { InstructionResultModel[] results = []; if (instruction.Results?.Count > 0) + { results = instruction.Results.Select(i => new InstructionResultModel { Key = i.Key, DisplayValue = i.DisplayValue }).ToArray(); + } var model = new InstructionModel { @@ -46,7 +48,7 @@ public InstructionModel ToModel(ActiveInstruction instruction) return model; } - internal class EmptyValueProvider : IEmptyPropertyProvider + internal sealed class EmptyValueProvider : IEmptyPropertyProvider { public void FillEmpty(object obj) { diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionItemModel.cs b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionItemModel.cs index c03af9f915..fcc86559d6 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionItemModel.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionItemModel.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Runtime.Serialization; -using Moryx.VisualInstructions; namespace Moryx.VisualInstructions.Endpoints; @@ -29,4 +28,4 @@ public class InstructionItemModel /// [DataMember] public string Preview { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionModel.cs b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionModel.cs index 9383815d73..8ea5db9731 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionModel.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionModel.cs @@ -47,4 +47,4 @@ public class InstructionModel /// [DataMember] public InstructionResultModel[] Results { get; set; } = []; -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResponseModel.cs b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResponseModel.cs index fe243003cc..7c03c53096 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResponseModel.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResponseModel.cs @@ -35,4 +35,4 @@ public class InstructionResponseModel /// [DataMember] public InstructionResultModel SelectedResult { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResultModel.cs b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResultModel.cs index 8b439241d9..56a4a65a82 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResultModel.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionResultModel.cs @@ -19,4 +19,4 @@ public class InstructionResultModel /// [DataMember] public string DisplayValue { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionType.cs b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionType.cs index c293687561..09d1f014fa 100644 --- a/src/Moryx.VisualInstructions.Endpoints/Models/InstructionType.cs +++ b/src/Moryx.VisualInstructions.Endpoints/Models/InstructionType.cs @@ -17,4 +17,4 @@ public enum InstructionType /// Execute complete process /// Execute, -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions.Endpoints/VisualInstructionsPermissions.cs b/src/Moryx.VisualInstructions.Endpoints/VisualInstructionsPermissions.cs index de2574b055..b63e57ac41 100644 --- a/src/Moryx.VisualInstructions.Endpoints/VisualInstructionsPermissions.cs +++ b/src/Moryx.VisualInstructions.Endpoints/VisualInstructionsPermissions.cs @@ -10,4 +10,4 @@ public static class VisualInstructionsPermissions public const string CanComplete = Prefix + "CanComplete"; public const string CanAdd = Prefix + "CanAdd"; public const string CanClear = Prefix + "CanClear"; -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/ActiveInstruction.cs b/src/Moryx.VisualInstructions/ActiveInstruction.cs index 920f1f9cc7..86e3c06bed 100644 --- a/src/Moryx.VisualInstructions/ActiveInstruction.cs +++ b/src/Moryx.VisualInstructions/ActiveInstruction.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.VisualInstructions; - namespace Moryx.VisualInstructions; /// @@ -34,4 +32,4 @@ public class ActiveInstruction /// Possible results of the instruction /// public IReadOnlyList Results { get; set; } = Array.Empty(); -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/ActiveInstructionResponse.cs b/src/Moryx.VisualInstructions/ActiveInstructionResponse.cs index cc6be46adc..ab29f32a58 100644 --- a/src/Moryx.VisualInstructions/ActiveInstructionResponse.cs +++ b/src/Moryx.VisualInstructions/ActiveInstructionResponse.cs @@ -22,4 +22,4 @@ public class ActiveInstructionResponse /// Selected result option by the user /// public InstructionResult SelectedResult { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/EnumInstructionAttribute.cs b/src/Moryx.VisualInstructions/EnumInstructionAttribute.cs index 80955e7435..582c6d338b 100644 --- a/src/Moryx.VisualInstructions/EnumInstructionAttribute.cs +++ b/src/Moryx.VisualInstructions/EnumInstructionAttribute.cs @@ -21,4 +21,4 @@ public EnumInstructionAttribute() { } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/EnumInstructionResult.cs b/src/Moryx.VisualInstructions/EnumInstructionResult.cs index 585650ab41..a6a5397b90 100644 --- a/src/Moryx.VisualInstructions/EnumInstructionResult.cs +++ b/src/Moryx.VisualInstructions/EnumInstructionResult.cs @@ -37,10 +37,14 @@ public static int ResultToEnumValue(Type resultEnum, InstructionResult result) public static int ResultToEnumValue(Type resultEnum, ActiveInstructionResponse response) { if (response.SelectedResult != null) + { return ResultToEnumValue(resultEnum, response.SelectedResult); + } if (response.SelectedResult != null) + { return ResultToEnumValue(resultEnum, response.SelectedResult); + } throw new ArgumentException("No result found on response.", nameof(response)); } diff --git a/src/Moryx.VisualInstructions/IVisualInstructionSource.cs b/src/Moryx.VisualInstructions/IVisualInstructionSource.cs index 9bcc3bd464..969d0de459 100644 --- a/src/Moryx.VisualInstructions/IVisualInstructionSource.cs +++ b/src/Moryx.VisualInstructions/IVisualInstructionSource.cs @@ -34,4 +34,4 @@ public interface IVisualInstructionSource : IResource /// Instruction was cleared /// event EventHandler Cleared; -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/IVisualInstructions.cs b/src/Moryx.VisualInstructions/IVisualInstructions.cs index 34af9f4c93..41c8a90494 100644 --- a/src/Moryx.VisualInstructions/IVisualInstructions.cs +++ b/src/Moryx.VisualInstructions/IVisualInstructions.cs @@ -42,4 +42,4 @@ public interface IVisualInstructions /// Get a list of all available instructors /// public IReadOnlyList GetInstructors(); -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/IVisualInstructor.cs b/src/Moryx.VisualInstructions/IVisualInstructor.cs index 8d15bf4a95..bb3a0fd7a1 100644 --- a/src/Moryx.VisualInstructions/IVisualInstructor.cs +++ b/src/Moryx.VisualInstructions/IVisualInstructor.cs @@ -34,4 +34,4 @@ public interface IVisualInstructor : IResource /// Clears specified Instruction from UI. /// void Clear(long instructionId); -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/InstructionEventArgs.cs b/src/Moryx.VisualInstructions/InstructionEventArgs.cs index 6755f3b0fb..b15733bd25 100644 --- a/src/Moryx.VisualInstructions/InstructionEventArgs.cs +++ b/src/Moryx.VisualInstructions/InstructionEventArgs.cs @@ -26,4 +26,4 @@ public InstructionEventArgs(string identifier, ActiveInstruction instruction) /// Referenced instruction /// public ActiveInstruction Instruction { get; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/InstructionResult.cs b/src/Moryx.VisualInstructions/InstructionResult.cs index b756aa962a..9b42d73d10 100644 --- a/src/Moryx.VisualInstructions/InstructionResult.cs +++ b/src/Moryx.VisualInstructions/InstructionResult.cs @@ -17,4 +17,4 @@ public class InstructionResult /// Human readable value of the result /// public string DisplayValue { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/VisualInstruction.cs b/src/Moryx.VisualInstructions/VisualInstruction.cs index fabfa89cc8..9f15ce01be 100644 --- a/src/Moryx.VisualInstructions/VisualInstruction.cs +++ b/src/Moryx.VisualInstructions/VisualInstruction.cs @@ -47,4 +47,4 @@ public class VisualInstruction /// [DataMember, EntrySerialize] public string Preview { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/VisualInstructionBinder.cs b/src/Moryx.VisualInstructions/VisualInstructionBinder.cs index ecdbfb2ad0..40ecaded93 100644 --- a/src/Moryx.VisualInstructions/VisualInstructionBinder.cs +++ b/src/Moryx.VisualInstructions/VisualInstructionBinder.cs @@ -27,12 +27,14 @@ public VisualInstruction[] ResolveInstructions(object source) { var instructions = new VisualInstruction[_instructionResolvers.Length]; for (var index = 0; index < _instructionResolvers.Length; index++) + { instructions[index] = _instructionResolvers[index].Resolve(source); + } return instructions; } - private class InstructionResolver + private sealed class InstructionResolver { public InstructionResolver(VisualInstruction instruction, IBindingResolverFactory resolverFactory) { @@ -40,7 +42,9 @@ public InstructionResolver(VisualInstruction instruction, IBindingResolverFactor _contentResolver = TextBindingResolverFactory.Create(instruction.Content ?? string.Empty, resolverFactory); if (!string.IsNullOrEmpty(instruction.Preview)) + { _previewResolver = TextBindingResolverFactory.Create(instruction.Preview, resolverFactory); + } } private readonly VisualInstruction _instruction; @@ -59,4 +63,4 @@ public VisualInstruction Resolve(object source) }; } } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/VisualInstructionParameters.cs b/src/Moryx.VisualInstructions/VisualInstructionParameters.cs index d502977f61..3737ab4fa9 100644 --- a/src/Moryx.VisualInstructions/VisualInstructionParameters.cs +++ b/src/Moryx.VisualInstructions/VisualInstructionParameters.cs @@ -37,13 +37,17 @@ protected override void Populate(Process process, Parameters instance) // No instructions, no binding! if (Instructions == null || Instructions.Length == 0) + { return; + } // Create binder for our instructions if (InstructionBinder == null) + { InstructionBinder = new VisualInstructionBinder(Instructions, ResolverFactory); + } // Resolve instructions parameters.Instructions = InstructionBinder.ResolveInstructions(process) ?? Instructions; } -} \ No newline at end of file +} diff --git a/src/Moryx.VisualInstructions/VisualInstructorExtensions.cs b/src/Moryx.VisualInstructions/VisualInstructorExtensions.cs index 18ad86bf5e..f2df15eaad 100644 --- a/src/Moryx.VisualInstructions/VisualInstructorExtensions.cs +++ b/src/Moryx.VisualInstructions/VisualInstructorExtensions.cs @@ -138,4 +138,4 @@ public static VisualInstruction AsInstruction(this string text) Type = InstructionContentType.Text, }; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Components/IWorkplanEditingSession.cs b/src/Moryx.Workplans.Editing/Components/IWorkplanEditingSession.cs index f5393fa13f..7418d09b51 100644 --- a/src/Moryx.Workplans.Editing/Components/IWorkplanEditingSession.cs +++ b/src/Moryx.Workplans.Editing/Components/IWorkplanEditingSession.cs @@ -49,4 +49,4 @@ internal interface IWorkplanEditingSession /// Auto layout a session /// void AutoLayout(); -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Components/IWorkplanEditor.cs b/src/Moryx.Workplans.Editing/Components/IWorkplanEditor.cs index a7614fcfca..ab036f7aa4 100644 --- a/src/Moryx.Workplans.Editing/Components/IWorkplanEditor.cs +++ b/src/Moryx.Workplans.Editing/Components/IWorkplanEditor.cs @@ -26,4 +26,4 @@ internal interface IWorkplanEditor : IPlugin /// Close the session /// void CloseSession(string token); -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Facade/WorkplanFacade.cs b/src/Moryx.Workplans.Editing/Facade/WorkplanFacade.cs index 3d5d1c765a..1fbe4d4c84 100644 --- a/src/Moryx.Workplans.Editing/Facade/WorkplanFacade.cs +++ b/src/Moryx.Workplans.Editing/Facade/WorkplanFacade.cs @@ -89,4 +89,4 @@ public void AutoLayout(string sessionToken) ValidateHealthState(); Editor[sessionToken].AutoLayout(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Implementation/Extensions.cs b/src/Moryx.Workplans.Editing/Implementation/Extensions.cs index 4eb94c511a..613ccf3512 100644 --- a/src/Moryx.Workplans.Editing/Implementation/Extensions.cs +++ b/src/Moryx.Workplans.Editing/Implementation/Extensions.cs @@ -25,4 +25,4 @@ public static IEnumerable FilterAlreadyRepositionedSteps(this IEn public static IEnumerable GetNextSteps(this Workplan workplan, IConnector from) => workplan.Steps.Where(s => s.Inputs.Any(i => i.Id == from.Id)); -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Implementation/InvolvedSteps.cs b/src/Moryx.Workplans.Editing/Implementation/InvolvedSteps.cs index 52854f7ab8..32b64cd94f 100644 --- a/src/Moryx.Workplans.Editing/Implementation/InvolvedSteps.cs +++ b/src/Moryx.Workplans.Editing/Implementation/InvolvedSteps.cs @@ -30,4 +30,4 @@ public InvolvedSteps(IWorkplanStep source, IWorkplanStep target, IConnector conn /// Connector of the connection /// public IConnector Connector { get; private set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Implementation/WorkplanEditingSession.cs b/src/Moryx.Workplans.Editing/Implementation/WorkplanEditingSession.cs index 30c5481a87..372c88372b 100644 --- a/src/Moryx.Workplans.Editing/Implementation/WorkplanEditingSession.cs +++ b/src/Moryx.Workplans.Editing/Implementation/WorkplanEditingSession.cs @@ -28,7 +28,9 @@ public WorkplanEditingSession(Workplan workplan) public void AddStep(IWorkplanStep step) { if (step is ISubworkplanStep stepSubWorkplan && _workplan.Id == stepSubWorkplan.Workplan.Id) + { throw new ArgumentException(Strings.WorkplanEditingSession_SameWorkplanReference); + } _workplan.Add(step); } @@ -50,10 +52,14 @@ public bool RemoveStep(long stepId) { var step = _workplan.Steps.FirstOrDefault(s => s.Id == stepId); if (step == null) + { return false; + } if (!_workplan.Remove(step)) + { return false; + } // Check for each connector if another step uses it in the same role // Otherwise all remaining usages no longer represent a connection and can be deleted @@ -61,7 +67,9 @@ public bool RemoveStep(long stepId) { var otherInput = _workplan.Steps.Any(s => s.Inputs.Contains(input)); if (otherInput) + { continue; + } // If no other input uses it, we can remove all output references foreach (var otherStep in _workplan.Steps) @@ -69,13 +77,17 @@ public bool RemoveStep(long stepId) for (int i = 0; i < otherStep.Outputs.Length; i++) { if (otherStep.Outputs[i] == input) + { otherStep.Outputs[i] = null; + } } } // Now we can remove the connector if (input.Classification == NodeClassification.Intermediate) + { _workplan.Remove(input); + } } // The same logic applied to outputs @@ -83,7 +95,9 @@ public bool RemoveStep(long stepId) { var otherOutput = _workplan.Steps.Any(s => s.Outputs.Contains(output)); if (otherOutput) + { continue; + } // If no other output uses it, we can remove all input references foreach (var otherStep in _workplan.Steps) @@ -91,13 +105,17 @@ public bool RemoveStep(long stepId) for (int i = 0; i < otherStep.Inputs.Length; i++) { if (otherStep.Inputs[i] == output) + { otherStep.Inputs[i] = null; + } } } // Now we can remove the connector if (output.Classification == NodeClassification.Intermediate) + { _workplan.Remove(output); + } } return true; @@ -113,7 +131,9 @@ public bool RemoveConnector(long connectorId) // Get the connector var connector = _workplan.Connectors.FirstOrDefault(c => c.Id == connectorId); if (connector == null) + { return false; + } // All references to this connector foreach (var step in _workplan.Steps) @@ -121,12 +141,16 @@ public bool RemoveConnector(long connectorId) for (var i = 0; i < step.Inputs.Length; i++) { if (step.Inputs[i] == connector) + { step.Inputs[i] = null; + } } for (var i = 0; i < step.Outputs.Length; i++) { if (step.Outputs[i] == connector) + { step.Outputs[i] = null; + } } } @@ -139,10 +163,14 @@ public void Connect(IWorkplanNode sourceNode, int sourceIndex, IWorkplanNode tar if (sourceNode is IConnector start) { if (targetNode is IConnector) + { throw new InvalidOperationException("Cannot connect start to End or Failed."); + } if (start == ((IWorkplanStep)targetNode).Inputs[targetIndex]) + { return; + } var targetStep = (IWorkplanStep)targetNode; var targetConnector = targetStep.Inputs[targetIndex]; @@ -154,7 +182,9 @@ public void Connect(IWorkplanNode sourceNode, int sourceIndex, IWorkplanNode tar step.Outputs[sourceIndex] = end; } else + { ConnectTwoSteps(sourceNode, sourceIndex, targetNode, targetIndex); + } } private void ConnectStart(int targetIndex, IConnector start, IWorkplanStep targetStep, IConnector targetConnector) @@ -178,7 +208,9 @@ private void ConnectStart(int targetIndex, IConnector start, IWorkplanStep targe _workplan.Remove(targetConnector); } else + { targetStep.Inputs[targetIndex] = start; + } } private void ReplaceConnector(IConnector source, IConnector replacement) @@ -188,12 +220,16 @@ private void ReplaceConnector(IConnector source, IConnector replacement) for (var i = 0; i < workplanStep.Outputs.Length; i++) { if (workplanStep.Outputs[i] == source) + { workplanStep.Outputs[i] = replacement; + } } for (var i = 0; i < workplanStep.Inputs.Length; i++) { if (workplanStep.Inputs[i] == source) + { workplanStep.Inputs[i] = replacement; + } } } } @@ -254,7 +290,9 @@ public void Disconnect(IWorkplanNode sourceNode, int sourceIndex, IWorkplanNode // Check if any other step uses this connector as output var others = _workplan.Steps.Where(s => s.Outputs.Contains(start)).ToList(); if (!others.Any()) + { return; + } // That means it was a loop and we need to replace the connection var replacement = new Connector { Classification = NodeClassification.Intermediate }; @@ -264,7 +302,9 @@ public void Disconnect(IWorkplanNode sourceNode, int sourceIndex, IWorkplanNode for (var i = 0; i < other.Outputs.Length; i++) { if (other.Outputs[i] == start) + { other.Outputs[i] = replacement; + } } } step.Inputs[targetIndex] = replacement; diff --git a/src/Moryx.Workplans.Editing/Implementation/WorkplanEditor.cs b/src/Moryx.Workplans.Editing/Implementation/WorkplanEditor.cs index 49d9d79119..d87b939411 100644 --- a/src/Moryx.Workplans.Editing/Implementation/WorkplanEditor.cs +++ b/src/Moryx.Workplans.Editing/Implementation/WorkplanEditor.cs @@ -29,7 +29,9 @@ private bool StepFilter(Type stepType) { // Some step types are always allowed in editor because they will be used as template if (stepType == typeof(SubworkplanStep) || stepType == typeof(SplitWorkplanStep) || stepType == typeof(JoinWorkplanStep)) + { return true; + } // Find match in settings var settings = Config.StepSettings.FirstOrDefault(ts => ts.StepType == stepType.FullName); @@ -50,7 +52,9 @@ public void CloseSession(string token) { var session = this[token]; if (session == null) + { return; + } _sessions.Remove(session); } @@ -67,4 +71,4 @@ public IWorkplanEditingSession EditWorkplan(Workplan workplan, bool duplicate) _sessions.Add(session); return session; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/ModuleController/ModuleConfig.cs b/src/Moryx.Workplans.Editing/ModuleController/ModuleConfig.cs index b19f1400ec..2806734cf7 100644 --- a/src/Moryx.Workplans.Editing/ModuleController/ModuleConfig.cs +++ b/src/Moryx.Workplans.Editing/ModuleController/ModuleConfig.cs @@ -46,4 +46,4 @@ public class StepConfig /// [DataMember] public bool Enabled { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/ModuleController/ModuleController.cs b/src/Moryx.Workplans.Editing/ModuleController/ModuleController.cs index 2dfe63ecbf..e12504bf6f 100644 --- a/src/Moryx.Workplans.Editing/ModuleController/ModuleController.cs +++ b/src/Moryx.Workplans.Editing/ModuleController/ModuleController.cs @@ -64,4 +64,4 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) private readonly WorkplanFacade _facade = new(); Workplans.IWorkplanEditing IFacadeContainer.Facade => _facade; -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Editing/Properties/AssemblyInfo.cs b/src/Moryx.Workplans.Editing/Properties/AssemblyInfo.cs index 3b94032615..b3e9ef8af5 100644 --- a/src/Moryx.Workplans.Editing/Properties/AssemblyInfo.cs +++ b/src/Moryx.Workplans.Editing/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -[assembly: InternalsVisibleTo("Moryx.Workplans.Editing.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Moryx.Workplans.Editing.Tests")] diff --git a/src/Moryx.Workplans.Samples/Activities/TestActivity.cs b/src/Moryx.Workplans.Samples/Activities/TestActivity.cs index f7b23767e5..81d3ff17eb 100644 --- a/src/Moryx.Workplans.Samples/Activities/TestActivity.cs +++ b/src/Moryx.Workplans.Samples/Activities/TestActivity.cs @@ -22,4 +22,4 @@ protected override ActivityResult CreateResult(long resultNumber) { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Samples/Activities/TestParameters.cs b/src/Moryx.Workplans.Samples/Activities/TestParameters.cs index 89c87ed7f7..ebdc6427a4 100644 --- a/src/Moryx.Workplans.Samples/Activities/TestParameters.cs +++ b/src/Moryx.Workplans.Samples/Activities/TestParameters.cs @@ -18,4 +18,4 @@ protected override void Populate(Process process, Parameters instance) { } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Samples/Activities/TestTask.cs b/src/Moryx.Workplans.Samples/Activities/TestTask.cs index 1348b0ad41..05d246fedc 100644 --- a/src/Moryx.Workplans.Samples/Activities/TestTask.cs +++ b/src/Moryx.Workplans.Samples/Activities/TestTask.cs @@ -32,4 +32,4 @@ public class TestTaskWithoutConstructor : TaskStep [Display(Name = "Test String Property", Description = "This is a Description of an String Property, which cannot be set by a constructor")] public string TestString { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Web/Models/ModelConverter.cs b/src/Moryx.Workplans.Web/Models/ModelConverter.cs index fee51fa287..5981fefa0f 100644 --- a/src/Moryx.Workplans.Web/Models/ModelConverter.cs +++ b/src/Moryx.Workplans.Web/Models/ModelConverter.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Text; using Moryx.Serialization; using Moryx.Workplans.Validation; using Moryx.Workplans.WorkplanSteps; @@ -19,11 +18,15 @@ public static WorkplanNodeClassification ToClassification(Type type) // Split and join are recognized explicitly if (type == typeof(SplitWorkplanStep) || type == typeof(JoinWorkplanStep)) + { classification = WorkplanNodeClassification.ControlFlow; + } // And subworkpans are another exception else if (typeof(ISubworkplanStep).IsAssignableFrom(type)) + { classification = WorkplanNodeClassification.Subworkplan; + } return classification; } @@ -123,13 +126,17 @@ public static WorkplanNodeModel ConvertWorkplanStep(IWorkplanStep step, List s.Outputs.Where(o => o == connector) .Select(o => new NodeConnector { NodeId = s.Id, Index = Array.IndexOf(s.Outputs, connector) }))); if (connector.Classification != NodeClassification.Intermediate) + { connections[i].Connections.Add(new NodeConnector { NodeId = connector.Id, Index = 0 }); + } } nodeModel.Inputs = connections; @@ -139,13 +146,17 @@ public static WorkplanNodeModel ConvertWorkplanStep(IWorkplanStep step, List s.Inputs.Where(i => i == connector) .Select(o => new NodeConnector { NodeId = s.Id, Index = Array.IndexOf(s.Inputs, connector) }))); if (connector.Classification != NodeClassification.Intermediate) + { connections[i].Connections.Add(new NodeConnector { NodeId = connector.Id, Index = 0 }); + } } nodeModel.Outputs = connections; diff --git a/src/Moryx.Workplans.Web/Models/WorkplanNodeModel.cs b/src/Moryx.Workplans.Web/Models/WorkplanNodeModel.cs index 24f00d63a4..b54fd610a3 100644 --- a/src/Moryx.Workplans.Web/Models/WorkplanNodeModel.cs +++ b/src/Moryx.Workplans.Web/Models/WorkplanNodeModel.cs @@ -76,4 +76,4 @@ public sealed class WorkplanNodeModel /// [DataMember] public long SubworkplanId { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Web/Models/WorkplanSessionModel.cs b/src/Moryx.Workplans.Web/Models/WorkplanSessionModel.cs index 8840c50434..83aa1291d8 100644 --- a/src/Moryx.Workplans.Web/Models/WorkplanSessionModel.cs +++ b/src/Moryx.Workplans.Web/Models/WorkplanSessionModel.cs @@ -42,4 +42,4 @@ public class WorkplanSessionModel /// [DataMember] public WorkplanNodeModel[] Nodes { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Web/Models/WorkplanStepRecipe.cs b/src/Moryx.Workplans.Web/Models/WorkplanStepRecipe.cs index a429efc87b..6900e65bf8 100644 --- a/src/Moryx.Workplans.Web/Models/WorkplanStepRecipe.cs +++ b/src/Moryx.Workplans.Web/Models/WorkplanStepRecipe.cs @@ -66,9 +66,13 @@ public static WorkplanStepRecipe FromStepType(Type step) var consturctors = step.GetConstructors().ToList(); MethodEntry constructor; if (consturctors.Count == 1 && step.GetConstructor([]) != null) + { constructor = null; + } else + { constructor = EntryConvert.EncodeConstructors(step).First(); + } var recipe = new WorkplanStepRecipe { @@ -81,4 +85,4 @@ public static WorkplanStepRecipe FromStepType(Type step) return recipe; } -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans.Web/Models/WorkplanStepSerialization.cs b/src/Moryx.Workplans.Web/Models/WorkplanStepSerialization.cs index 2aec9f4468..6ce610a667 100644 --- a/src/Moryx.Workplans.Web/Models/WorkplanStepSerialization.cs +++ b/src/Moryx.Workplans.Web/Models/WorkplanStepSerialization.cs @@ -11,7 +11,7 @@ namespace Moryx.Workplans.Web.Models; /// /// Implementation of for types derived from /// -internal class WorkplanStepSerialization : PossibleValuesSerialization +internal sealed class WorkplanStepSerialization : PossibleValuesSerialization { public WorkplanStepSerialization() : base(null, null, new EmptyValueProvider()) { @@ -27,7 +27,7 @@ public override IEnumerable GetProperties(Type sourceType) : new EntrySerializeSerialization().GetProperties(sourceType); } - private class EmptyValueProvider : IEmptyPropertyProvider + private sealed class EmptyValueProvider : IEmptyPropertyProvider { public void FillEmpty(object obj) { diff --git a/src/Moryx.Workplans.Web/WorkplanEditingController.cs b/src/Moryx.Workplans.Web/WorkplanEditingController.cs index dc49ef5833..154c8e5044 100644 --- a/src/Moryx.Workplans.Web/WorkplanEditingController.cs +++ b/src/Moryx.Workplans.Web/WorkplanEditingController.cs @@ -5,13 +5,11 @@ using System.Drawing; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; using Moryx.AbstractionLayer.Products.Endpoints; using Moryx.AbstractionLayer.Workplans; using Moryx.AspNetCore; using Moryx.Serialization; -using Moryx.Workplans.Validation; using Moryx.Workplans.Web.Models; using Moryx.Workplans.Web.Properties; diff --git a/src/Moryx.Workplans/IWorkplanEditing.cs b/src/Moryx.Workplans/IWorkplanEditing.cs index 26031cc01b..7bfd19730b 100644 --- a/src/Moryx.Workplans/IWorkplanEditing.cs +++ b/src/Moryx.Workplans/IWorkplanEditing.cs @@ -67,4 +67,4 @@ public interface IWorkplanEditing /// Close a session /// void CloseSession(string sessionToken); -} \ No newline at end of file +} diff --git a/src/Moryx.Workplans/WorkplanSession.cs b/src/Moryx.Workplans/WorkplanSession.cs index 893a33ec6a..e8d1f5e878 100644 --- a/src/Moryx.Workplans/WorkplanSession.cs +++ b/src/Moryx.Workplans/WorkplanSession.cs @@ -17,4 +17,4 @@ public class WorkplanSession /// Workplan that is edited /// public Workplan Workplan { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Attributes/ForceAssemblyReferenceAttribute.cs b/src/Moryx/Attributes/ForceAssemblyReferenceAttribute.cs index c910bfd318..290c31a580 100644 --- a/src/Moryx/Attributes/ForceAssemblyReferenceAttribute.cs +++ b/src/Moryx/Attributes/ForceAssemblyReferenceAttribute.cs @@ -27,4 +27,4 @@ public ForceAssemblyReferenceAttribute(Type forcedType) Action noop = _ => { }; noop(forcedType); } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/BindingResolverBase.cs b/src/Moryx/Bindings/BindingResolverBase.cs index 0b7ad8d4f1..4f306f4970 100644 --- a/src/Moryx/Bindings/BindingResolverBase.cs +++ b/src/Moryx/Bindings/BindingResolverBase.cs @@ -21,7 +21,9 @@ object IBindingResolver.Resolve(object source) var result = Resolve(source); if (NextResolver == null || result == null) + { return result; + } return NextResolver.Resolve(result); } @@ -37,11 +39,15 @@ bool IBindingResolver.Update(object source, object value) { // We can not proceed without a source object if (source == null) + { return false; + } // We have reached the end of the chain if (NextResolver == null) + { return Update(source, value); + } source = Resolve(source); return NextResolver.Update(source, value); @@ -51,4 +57,4 @@ bool IBindingResolver.Update(object source, object value) /// Set the value on the souce object /// protected abstract bool Update(object source, object value); -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/BindingResolverExtension.cs b/src/Moryx/Bindings/BindingResolverExtension.cs index c6b28f12dc..4451d326ee 100644 --- a/src/Moryx/Bindings/BindingResolverExtension.cs +++ b/src/Moryx/Bindings/BindingResolverExtension.cs @@ -44,7 +44,9 @@ public IBindingResolverChain Insert(IBindingResolverChain insertedResolver) var next = resolver.NextResolver; resolver.Extend(insertedResolver); if (next != null) + { insertedResolver.Extend(next); + } return insertedResolver; } diff --git a/src/Moryx/Bindings/BindingResolverFactory.cs b/src/Moryx/Bindings/BindingResolverFactory.cs index 0436b6f811..cccdffdf06 100644 --- a/src/Moryx/Bindings/BindingResolverFactory.cs +++ b/src/Moryx/Bindings/BindingResolverFactory.cs @@ -32,7 +32,9 @@ public IBindingResolver Create(string binding) // First we need a BaseKeyResolver to extract the base value var baseResolver = CreateBaseResolver(baseKey); if (baseResolver == null || properties.Count == 0) + { return baseResolver; + } var resolver = baseResolver; for (int index = 0; index < properties.Count; index++) @@ -70,4 +72,4 @@ protected virtual IBindingResolverChain AddToChain(IBindingResolverChain resolve return resolver; } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/DelegateResolver.cs b/src/Moryx/Bindings/DelegateResolver.cs index b65ffeb9f6..23c29384b7 100644 --- a/src/Moryx/Bindings/DelegateResolver.cs +++ b/src/Moryx/Bindings/DelegateResolver.cs @@ -37,9 +37,11 @@ protected sealed override object Resolve(object source) protected sealed override bool Update(object source, object value) { if (_assignmentExpression == null) + { return false; + } _assignmentExpression(source, value); return true; } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/FormatBindingResolver.cs b/src/Moryx/Bindings/FormatBindingResolver.cs index 48efe63e12..839c4ee4db 100644 --- a/src/Moryx/Bindings/FormatBindingResolver.cs +++ b/src/Moryx/Bindings/FormatBindingResolver.cs @@ -33,4 +33,4 @@ protected sealed override bool Update(object source, object value) { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/IBindingResolver.cs b/src/Moryx/Bindings/IBindingResolver.cs index cbbd64b905..2cc7d34749 100644 --- a/src/Moryx/Bindings/IBindingResolver.cs +++ b/src/Moryx/Bindings/IBindingResolver.cs @@ -18,4 +18,4 @@ public interface IBindingResolver /// using the binding string. /// bool Update(object source, object value); -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/IBindingResolverChain.cs b/src/Moryx/Bindings/IBindingResolverChain.cs index 7e4e7a3708..2bdf7d3c92 100644 --- a/src/Moryx/Bindings/IBindingResolverChain.cs +++ b/src/Moryx/Bindings/IBindingResolverChain.cs @@ -17,4 +17,4 @@ public interface IBindingResolverChain : IBindingResolver /// Next resolver as part of a chain of responsibility /// IBindingResolverChain NextResolver { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/IBindingResolverFactory.cs b/src/Moryx/Bindings/IBindingResolverFactory.cs index 3780722c9f..126f0e3cc8 100644 --- a/src/Moryx/Bindings/IBindingResolverFactory.cs +++ b/src/Moryx/Bindings/IBindingResolverFactory.cs @@ -13,4 +13,4 @@ public interface IBindingResolverFactory /// Create a property resolver for a binding string /// IBindingResolver Create(string bindingString); -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/ITextBindingResolver.cs b/src/Moryx/Bindings/ITextBindingResolver.cs index 8ff34b7e30..fb32c02cd2 100644 --- a/src/Moryx/Bindings/ITextBindingResolver.cs +++ b/src/Moryx/Bindings/ITextBindingResolver.cs @@ -12,4 +12,4 @@ public interface ITextBindingResolver /// Resolve all bindings in the text and return a new object /// string Resolve(object source); -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/IndexResolver.cs b/src/Moryx/Bindings/IndexResolver.cs index 19f275aa9d..c881add13a 100644 --- a/src/Moryx/Bindings/IndexResolver.cs +++ b/src/Moryx/Bindings/IndexResolver.cs @@ -51,7 +51,7 @@ private IIndexStrategy CreateResolver(object source) { IIndexStrategy resolver = null; - var numericIndex = 0; + int numericIndex; if (int.TryParse(_index, out numericIndex)) { var dict = source as IDictionary; @@ -170,4 +170,4 @@ public bool Update(object source, object value) return true; } } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/NullResolver.cs b/src/Moryx/Bindings/NullResolver.cs index 3a0dbc4547..c09c2d0b34 100644 --- a/src/Moryx/Bindings/NullResolver.cs +++ b/src/Moryx/Bindings/NullResolver.cs @@ -19,4 +19,4 @@ protected sealed override bool Update(object source, object value) { throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Bindings/TextBindingResolverFactory.cs b/src/Moryx/Bindings/TextBindingResolverFactory.cs index 6cab3ea601..12d8ccfd24 100644 --- a/src/Moryx/Bindings/TextBindingResolverFactory.cs +++ b/src/Moryx/Bindings/TextBindingResolverFactory.cs @@ -23,14 +23,18 @@ public static ITextBindingResolver Create(string parameterWithBindings, IBinding { //null check to make sure the parameterWithBinding is not null if (parameterWithBindings == null) + { return new NullResolver(parameterWithBindings); + } // Parse bindings var matches = Regex.Matches(parameterWithBindings, BindingRegex); // No bindings, no resolver if (matches.Count == 0) + { return new NullResolver(parameterWithBindings); + } // Otherwise use the awesome regex resolver return BuildRegexResolver(matches, parameterWithBindings, resolverFactory); @@ -70,7 +74,9 @@ private static RegexResolver BuildRegexResolver(MatchCollection matches, string var resolver = (IBindingResolverChain)resolverFactory.Create(binding); if (resolver == null) // Could not be resolved, just keep for later + { continue; + } if (match.Groups["hasFormat"].Success) { @@ -114,4 +120,4 @@ public string Resolve(object source) return result; } } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/DelayQueue.cs b/src/Moryx/Collections/DelayQueue/DelayQueue.cs index 229b0acc11..8824ee24c5 100644 --- a/src/Moryx/Collections/DelayQueue/DelayQueue.cs +++ b/src/Moryx/Collections/DelayQueue/DelayQueue.cs @@ -86,14 +86,18 @@ public void Start(int queueDelay) public void Stop() { lock (_stateLock) + { _state.Stop(); + } } /// public void Enqueue(T obj) { lock (_stateLock) + { _state.Enqueue(obj); + } } /// @@ -139,4 +143,4 @@ private void DelayedExecute(object obj) /// public event EventHandler Dequeued; -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/IDelayQueue.cs b/src/Moryx/Collections/DelayQueue/IDelayQueue.cs index 0d49f0825b..a90a20d022 100644 --- a/src/Moryx/Collections/DelayQueue/IDelayQueue.cs +++ b/src/Moryx/Collections/DelayQueue/IDelayQueue.cs @@ -29,4 +29,4 @@ public interface IDelayQueue /// Removes and returns the item at the beginning of the Queue. /// event EventHandler Dequeued; -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/States/IDelayQueueContext.cs b/src/Moryx/Collections/DelayQueue/States/IDelayQueueContext.cs index 3fa1a2c56f..31315fb963 100644 --- a/src/Moryx/Collections/DelayQueue/States/IDelayQueueContext.cs +++ b/src/Moryx/Collections/DelayQueue/States/IDelayQueueContext.cs @@ -20,4 +20,4 @@ internal interface IDelayQueueContext : IStateContext void DequeueDelayed(object next, int queueDelay); void ExecuteDequeueParallel(object item); -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/States/QueueIdleState.cs b/src/Moryx/Collections/DelayQueue/States/QueueIdleState.cs index b1433478ff..ee345fe234 100644 --- a/src/Moryx/Collections/DelayQueue/States/QueueIdleState.cs +++ b/src/Moryx/Collections/DelayQueue/States/QueueIdleState.cs @@ -34,4 +34,4 @@ public override void Enqueue(object item) Context.DequeueDelayed(item, (int)remainingDelay); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/States/QueuePendingState.cs b/src/Moryx/Collections/DelayQueue/States/QueuePendingState.cs index 0aee750394..6f81ac9a33 100644 --- a/src/Moryx/Collections/DelayQueue/States/QueuePendingState.cs +++ b/src/Moryx/Collections/DelayQueue/States/QueuePendingState.cs @@ -43,4 +43,4 @@ public override void MessageSent(object item) Context.DequeueDelayed(next, Context.QueueDelay); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/States/QueueStateBase.cs b/src/Moryx/Collections/DelayQueue/States/QueueStateBase.cs index ba57c1ab48..fe36209fca 100644 --- a/src/Moryx/Collections/DelayQueue/States/QueueStateBase.cs +++ b/src/Moryx/Collections/DelayQueue/States/QueueStateBase.cs @@ -39,4 +39,4 @@ public virtual void MessageSent(object item) [StateDefinition(typeof(QueueStoppedState), IsInitial = true)] public const int StoppedState = 30; -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/DelayQueue/States/QueueStoppedState.cs b/src/Moryx/Collections/DelayQueue/States/QueueStoppedState.cs index f3400f7245..5e2426c279 100644 --- a/src/Moryx/Collections/DelayQueue/States/QueueStoppedState.cs +++ b/src/Moryx/Collections/DelayQueue/States/QueueStoppedState.cs @@ -20,4 +20,4 @@ public override void Enqueue(object item) { throw new InvalidOperationException("The queue is not running."); } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/MergedCollection.cs b/src/Moryx/Collections/MergedCollection.cs index ecc0de8bb3..75f17e2a0b 100644 --- a/src/Moryx/Collections/MergedCollection.cs +++ b/src/Moryx/Collections/MergedCollection.cs @@ -73,4 +73,4 @@ public IEnumerator GetEnumerator() /// public event NotifyCollectionChangedEventHandler CollectionChanged; -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/MonitorEnumerator.cs b/src/Moryx/Collections/MonitorEnumerator.cs index 8756626233..5e6ddd3810 100644 --- a/src/Moryx/Collections/MonitorEnumerator.cs +++ b/src/Moryx/Collections/MonitorEnumerator.cs @@ -45,4 +45,4 @@ public virtual void Dispose() _innerEnumerator.Dispose(); Monitor.Exit(_syncRoot); } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/ProducerConsumerEnumerator.cs b/src/Moryx/Collections/ProducerConsumerEnumerator.cs index 1d6766c9c9..b0057f13f0 100644 --- a/src/Moryx/Collections/ProducerConsumerEnumerator.cs +++ b/src/Moryx/Collections/ProducerConsumerEnumerator.cs @@ -45,4 +45,4 @@ public virtual void Dispose() _innerEnumerator.Dispose(); _rwLock.ExitReadLock(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/SortableCollection.cs b/src/Moryx/Collections/SortableCollection.cs index 9cf1cfe69e..205902c875 100644 --- a/src/Moryx/Collections/SortableCollection.cs +++ b/src/Moryx/Collections/SortableCollection.cs @@ -118,7 +118,9 @@ public void MoveUp(T item) //Check if the given item is the first if (itemIndex == 0) + { return; + } //Move item up and return changed items Move(item, 1); @@ -131,7 +133,9 @@ public void MoveDown(T item) //Check if the given item is the last if (itemIndex == _items.Count - 1) + { return; + } //Move item down and return changed items Move(item, -1); @@ -228,7 +232,10 @@ private int GetItemIndex(T item) { var itemIndex = _items.IndexOf(item); if (itemIndex < 0) + { throw new ArgumentException("Item was not found in underlying collection.", nameof(item)); + } + return itemIndex; } diff --git a/src/Moryx/Collections/StringNumericComparer.cs b/src/Moryx/Collections/StringNumericComparer.cs index e715a01734..a00654a15f 100644 --- a/src/Moryx/Collections/StringNumericComparer.cs +++ b/src/Moryx/Collections/StringNumericComparer.cs @@ -21,13 +21,24 @@ public int Compare(string a, string b) { // First check for null or simple equality if (string.IsNullOrWhiteSpace(a) && string.IsNullOrWhiteSpace(b)) + { return 0; + } + if (string.IsNullOrWhiteSpace(a)) + { return -1; + } + if (string.IsNullOrWhiteSpace(b)) + { return 1; + } + if (a == b) + { return 0; + } // Now detect text and numeric part of the string var regex = new Regex(@"(?(?:[A-Za-z]+\s*)+)?(?\d+)?"); @@ -49,15 +60,26 @@ public int Compare(string a, string b) // Compare texts first var textCompare = string.Compare(textA, textB, StringComparison.OrdinalIgnoreCase); if (textCompare != 0) + { return textCompare; + } // Compare numeric suffix if (hasNumberA & hasNumberB) + { return numberA.CompareTo(numberB); + } + if (hasNumberA) + { return 1; + } + if (hasNumberB) + { return -1; + } + return 0; } // Only the first hast text @@ -67,8 +89,10 @@ public int Compare(string a, string b) } // Only the second has text if (hasTextB) + { return -1; + } // None has text return numberA.CompareTo(numberB); } -} \ No newline at end of file +} diff --git a/src/Moryx/Collections/WeakCollection.cs b/src/Moryx/Collections/WeakCollection.cs index ac20f470b2..706f755b7b 100644 --- a/src/Moryx/Collections/WeakCollection.cs +++ b/src/Moryx/Collections/WeakCollection.cs @@ -28,12 +28,16 @@ public List GetLiveItems() T item; if (!weakReference.TryGetTarget(out item)) + { continue; + } ret.Add(item); if (readIndex != writeIndex) + { _list[writeIndex] = _list[readIndex]; + } ++writeIndex; } @@ -65,7 +69,9 @@ public bool Remove(T item) T entry; if (!weakReference.TryGetTarget(out entry) || entry != item) + { continue; + } _list.RemoveAt(i); return true; @@ -73,4 +79,4 @@ public bool Remove(T item) return false; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Attributes/PayloadPositionAttribute.cs b/src/Moryx/Communication/Attributes/PayloadPositionAttribute.cs index fba6582caf..c584e12609 100644 --- a/src/Moryx/Communication/Attributes/PayloadPositionAttribute.cs +++ b/src/Moryx/Communication/Attributes/PayloadPositionAttribute.cs @@ -30,4 +30,4 @@ public PayloadPositionAttribute(int position) /// Maximum length - for strings or collections /// public int MaxLength { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/BinaryConnectionConfig.cs b/src/Moryx/Communication/Connection/BinaryConnectionConfig.cs index bc07631c77..d60843b7e7 100644 --- a/src/Moryx/Communication/Connection/BinaryConnectionConfig.cs +++ b/src/Moryx/Communication/Connection/BinaryConnectionConfig.cs @@ -12,4 +12,4 @@ public class BinaryConnectionConfig : IPluginConfig { /// public virtual string PluginName => "CommunicatorConfig"; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/BinaryConnectionState.cs b/src/Moryx/Communication/Connection/BinaryConnectionState.cs index 6c3d335a8c..1f663d1bef 100644 --- a/src/Moryx/Communication/Connection/BinaryConnectionState.cs +++ b/src/Moryx/Communication/Connection/BinaryConnectionState.cs @@ -22,4 +22,4 @@ public enum BinaryConnectionState /// Component is connected. Communication is possible /// Connected -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/ConnectionAttempt.cs b/src/Moryx/Communication/Connection/ConnectionAttempt.cs index 9fbc04881d..04d87d637b 100644 --- a/src/Moryx/Communication/Connection/ConnectionAttempt.cs +++ b/src/Moryx/Communication/Connection/ConnectionAttempt.cs @@ -34,10 +34,12 @@ public class ConnectionAttempt : DeviceCommunicationBase, IConnectionAttempt public override void Start(Func communicate) { if (_started) + { return; + } _execute = communicate - ?? throw new ArgumentException(nameof(communicate)); + ?? throw new ArgumentException(null, nameof(communicate)); _started = true; Start(); @@ -54,10 +56,12 @@ private void Start() { RaiseFailureEvent(result); if (RetryOnFailure) + { _timerId = ParallelOperations.ScheduleExecution( Start, TimeoutInMs, 0); + } } } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/IBinaryConnection.cs b/src/Moryx/Communication/Connection/IBinaryConnection.cs index 6fc34ecebb..c20e7ecc8a 100644 --- a/src/Moryx/Communication/Connection/IBinaryConnection.cs +++ b/src/Moryx/Communication/Connection/IBinaryConnection.cs @@ -33,4 +33,4 @@ public interface IBinaryConnection : IConfiguredPlugin, /// Occurs when a connection state has to be published. /// event EventHandler NotifyConnectionState; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/IBinaryConnectionFactory.cs b/src/Moryx/Communication/Connection/IBinaryConnectionFactory.cs index e1afb7d014..7a04d2e261 100644 --- a/src/Moryx/Communication/Connection/IBinaryConnectionFactory.cs +++ b/src/Moryx/Communication/Connection/IBinaryConnectionFactory.cs @@ -22,4 +22,4 @@ public interface IBinaryConnectionFactory /// Destroy the no longer required instance /// void Destroy(IBinaryConnection instance); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/IDeviceCommunication.cs b/src/Moryx/Communication/Connection/IDeviceCommunication.cs index d4cbe78b42..9f33a49903 100644 --- a/src/Moryx/Communication/Connection/IDeviceCommunication.cs +++ b/src/Moryx/Communication/Connection/IDeviceCommunication.cs @@ -34,4 +34,4 @@ public interface IDeviceCommunication /// during communication /// event EventHandler Failed; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Connection/StatusCheck.cs b/src/Moryx/Communication/Connection/StatusCheck.cs index 0aa490acdf..3deb1c3513 100644 --- a/src/Moryx/Communication/Connection/StatusCheck.cs +++ b/src/Moryx/Communication/Connection/StatusCheck.cs @@ -28,7 +28,9 @@ public class StatusCheck : DeviceCommunicationBase, IStatusCheck public override void Start(Func execute) { if (_started) + { return; + } _execute = execute; _started = true; @@ -60,4 +62,4 @@ private void CheckStatus() } } } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Interpreter/DelimitedMessageContext.cs b/src/Moryx/Communication/Interpreter/DelimitedMessageContext.cs index 6c080e9940..3abc357ca0 100644 --- a/src/Moryx/Communication/Interpreter/DelimitedMessageContext.cs +++ b/src/Moryx/Communication/Interpreter/DelimitedMessageContext.cs @@ -22,4 +22,4 @@ public class DelimitedMessageContext : ReadContext /// Flag if the message start was allready found /// public bool StartFound { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Interpreter/DelimitedMessageInterpreter.cs b/src/Moryx/Communication/Interpreter/DelimitedMessageInterpreter.cs index cbf63e1139..d71b55275a 100644 --- a/src/Moryx/Communication/Interpreter/DelimitedMessageInterpreter.cs +++ b/src/Moryx/Communication/Interpreter/DelimitedMessageInterpreter.cs @@ -82,7 +82,9 @@ public ByteReadResult ProcessReadBytes(IReadContext context, int readBytes, Acti { var segment = new ArraySegment(delimited.ReadBuffer, index, EndDelimiter.Length); if (!EndDelimiter.SequenceEqual(segment)) + { continue; + } // Wrap up message and publish delimited.MessageEnd = index + EndDelimiter.Length - 1; @@ -105,7 +107,9 @@ public ByteReadResult ProcessReadBytes(IReadContext context, int readBytes, Acti private bool FindStart(int readBytes, DelimitedMessageContext context) { if (StartDelimiter.Length == 0) + { return true; + } var searchStart = context.CurrentIndex > StartDelimiter.Length ? context.CurrentIndex - StartDelimiter.Length : 0; var searchEnd = (context.CurrentIndex + readBytes) - StartDelimiter.Length; @@ -114,7 +118,9 @@ private bool FindStart(int readBytes, DelimitedMessageContext context) { var segment = new ArraySegment(context.ReadBuffer, index, StartDelimiter.Length); if (!StartDelimiter.SequenceEqual(segment)) + { continue; + } context.MessageStart = index; return true; @@ -135,7 +141,9 @@ private static int ResetContext(int readBytes, DelimitedMessageContext context) // Entire read buffer Full first message var overlap = (readBytes + context.CurrentIndex) - (context.MessageEnd + 1); if (overlap > 0) + { Buffer.BlockCopy(context.ReadBuffer, context.MessageEnd + 1, context.ReadBuffer, 0, overlap); + } // Reset message context.StartFound = false; @@ -186,9 +194,26 @@ public bool Equals(IMessageInterpreter messageInterpreter) /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != GetType()) return false; + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + return Equals((DelimitedMessageInterpreter)obj); } -} \ No newline at end of file + + public override int GetHashCode() + { + throw new NotImplementedException(); + } +} diff --git a/src/Moryx/Communication/Interpreter/HeaderMessageContext.cs b/src/Moryx/Communication/Interpreter/HeaderMessageContext.cs index 79f3791b78..a879c5fe18 100644 --- a/src/Moryx/Communication/Interpreter/HeaderMessageContext.cs +++ b/src/Moryx/Communication/Interpreter/HeaderMessageContext.cs @@ -33,4 +33,4 @@ public class HeaderMessageContext : ReadContext /// Currrent parsing state /// public ParsingState State { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Interpreter/HeaderMessageInterpreter.cs b/src/Moryx/Communication/Interpreter/HeaderMessageInterpreter.cs index b781ef48c1..2c34cc40cf 100644 --- a/src/Moryx/Communication/Interpreter/HeaderMessageInterpreter.cs +++ b/src/Moryx/Communication/Interpreter/HeaderMessageInterpreter.cs @@ -86,7 +86,9 @@ public ByteReadResult ProcessReadBytes(IReadContext context, int readBytes, Acti // Prepare message for payload var payloadLength = headerContext.Header.PayloadLength + FooterSize; if (payloadLength > 0) + { PrepareContext(headerContext, payloadLength, ParsingState.ReadingPayload); + } else { publishCompleteMessage(ToMessage(headerContext)); @@ -120,7 +122,9 @@ private static void PrepareContext(HeaderMessageContext context, int si context.CurrentIndex = 0; context.ReadSize = size; if (context.ReadBuffer.Length < size) // Only increase read buffer if it is too small + { context.ReadBuffer = new byte[size]; + } context.State = nextState; } @@ -135,7 +139,9 @@ private static BinaryMessage ToMessage(HeaderMessageContext headerConte var payload = includesPayload ? new byte[payloadLength] : BinaryMessage.EmptyBytes; if (includesPayload) + { Buffer.BlockCopy(headerContext.ReadBuffer, 0, payload, 0, payloadLength); + } return new BinaryMessage(headerContext.Header, payload); } @@ -172,9 +178,26 @@ public bool Equals(IMessageInterpreter messageInterpreter) /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != GetType()) return false; + if (ReferenceEquals(null, obj)) + { + return false; + } + + if (ReferenceEquals(this, obj)) + { + return true; + } + + if (obj.GetType() != GetType()) + { + return false; + } + return Equals((HeaderMessageInterpreter)obj); } -} \ No newline at end of file + + public override int GetHashCode() + { + throw new NotImplementedException(); + } +} diff --git a/src/Moryx/Communication/Interpreter/ReadContext.cs b/src/Moryx/Communication/Interpreter/ReadContext.cs index 249be872ba..215b3f6764 100644 --- a/src/Moryx/Communication/Interpreter/ReadContext.cs +++ b/src/Moryx/Communication/Interpreter/ReadContext.cs @@ -22,4 +22,4 @@ public abstract class ReadContext : IReadContext /// Number of bytes to read /// public int ReadSize { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientConnectedState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientConnectedState.cs index 00eb8c2b2c..6666e0036b 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientConnectedState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientConnectedState.cs @@ -40,4 +40,4 @@ public override void ScheduledConnectTimerElapsed() { NextState(StateConnecting); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientConnectingState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientConnectingState.cs index 652c29abf5..5c8b9d6adb 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientConnectingState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientConnectingState.cs @@ -43,4 +43,4 @@ public override void Disconnect() NextState(StateDisconnected); Context.CloseClient(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectedState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectedState.cs index 0433fd3e7d..c7e07674f4 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectedState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectedState.cs @@ -30,4 +30,4 @@ public override void Connect() public override void Disconnect() { } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectingState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectingState.cs index 3ef2f68f55..b23f25e03b 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectingState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientDisconnectingState.cs @@ -18,4 +18,4 @@ public override void ConnectionClosed() { NextState(StateDisconnected); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientReconnectingState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientReconnectingState.cs index 565f252635..e55c611aa9 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientReconnectingState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientReconnectingState.cs @@ -35,4 +35,4 @@ public override void Disconnect() { NextState(StateDisconnected); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientRetryConnectState.cs b/src/Moryx/Communication/Sockets/Client/States/ClientRetryConnectState.cs index a957d70912..37794b758e 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientRetryConnectState.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientRetryConnectState.cs @@ -18,4 +18,4 @@ public override void Disconnect() { NextState(StateDisconnected); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/States/ClientStateBase.cs b/src/Moryx/Communication/Sockets/Client/States/ClientStateBase.cs index 0a74d69e94..3f0b2bf34f 100644 --- a/src/Moryx/Communication/Sockets/Client/States/ClientStateBase.cs +++ b/src/Moryx/Communication/Sockets/Client/States/ClientStateBase.cs @@ -67,4 +67,4 @@ public virtual void ScheduledConnectTimerElapsed() [StateDefinition(typeof(ClientReconnectingState))] protected const int StateReconnecting = 60; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/TcpClientConfig.cs b/src/Moryx/Communication/Sockets/Client/TcpClientConfig.cs index 9930421961..6947e833ee 100644 --- a/src/Moryx/Communication/Sockets/Client/TcpClientConfig.cs +++ b/src/Moryx/Communication/Sockets/Client/TcpClientConfig.cs @@ -45,4 +45,4 @@ public class TcpClientConfig : BinaryConnectionConfig [DataMember] [Description("The TCP KeepAlive configuration")] public TcpKeepAliveConfig KeepAliveConfig { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Client/TcpClientConnection.cs b/src/Moryx/Communication/Sockets/Client/TcpClientConnection.cs index 073ec517e0..5aa47354c6 100644 --- a/src/Moryx/Communication/Sockets/Client/TcpClientConnection.cs +++ b/src/Moryx/Communication/Sockets/Client/TcpClientConnection.cs @@ -91,14 +91,18 @@ public void Initialize(BinaryConnectionConfig config) public void Start() { lock (_stateLock) + { _state.Connect(); + } } /// public void Stop() { lock (_stateLock) + { _state.Disconnect(); + } } /// @@ -132,7 +136,9 @@ private static IPEndPoint GetIpEndpointFromHost(string hostName, int port) { var addresses = Dns.GetHostAddresses(hostName); if (addresses.Length == 0) + { throw new ArgumentException("Unable to retrieve address from specified host name.", nameof(hostName)); + } return new IPEndPoint(addresses[0], port); } @@ -147,7 +153,9 @@ public void Reconnect() public void Reconnect(int delayMs) { lock (_stateLock) + { _state.Reconnect(delayMs); + } } #region Connection and transmission @@ -164,7 +172,9 @@ internal void Connect() private void ConnectionCallback(IAsyncResult ar) { lock (_stateLock) + { _state.ConnectionCallback(ar, _tcpClient); + } } internal void Connected() @@ -186,7 +196,9 @@ private void OnTransmissionException(object sender, Exception e) private void ConnectionClosed(object sender, EventArgs eventArgs) { lock (_stateLock) + { _state.ConnectionClosed(); + } } internal void Disconnect() @@ -221,14 +233,18 @@ private void OnReconnectTimer(object state) ((Timer)state).Dispose(); lock (_stateLock) + { _state.ScheduledConnectTimerElapsed(); + } } /// public void Send(BinaryMessage message) { lock (_stateLock) + { _state.Send(message); + } } internal void ExecuteSend(BinaryMessage data) @@ -240,7 +256,9 @@ internal void ExecuteSend(BinaryMessage data) public Task SendAsync(BinaryMessage message, CancellationToken cancellationToken = default) { lock (_stateLock) + { return _state.SendAsync(message); + } } internal Task ExecuteSendAsync(BinaryMessage message) diff --git a/src/Moryx/Communication/Sockets/InvalidHeaderException.cs b/src/Moryx/Communication/Sockets/InvalidHeaderException.cs index 24b53f4d70..33246f4278 100644 --- a/src/Moryx/Communication/Sockets/InvalidHeaderException.cs +++ b/src/Moryx/Communication/Sockets/InvalidHeaderException.cs @@ -28,4 +28,4 @@ public InvalidHeaderException(string message) : base(message) { } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/PortMap.cs b/src/Moryx/Communication/Sockets/Server/PortMap.cs index e5afd86dad..87c076031b 100644 --- a/src/Moryx/Communication/Sockets/Server/PortMap.cs +++ b/src/Moryx/Communication/Sockets/Server/PortMap.cs @@ -50,16 +50,22 @@ public static bool Register(IPAddress address, int port, IMessageInterpreter pro { IEnumerable addressRelevant; if (IsAny(address)) + { // If this is a registration for all IPAddresses, we need to compare against all entries addressRelevant = _registrations; + } else + { // Find all registrations on the same or all addresses addressRelevant = _registrations.Where(r => IsAny(r._address) | r._address.Equals(address)); + } // Within relevant addresses find an entry with the same port var match = addressRelevant.FirstOrDefault(m => m._port == port); if (match != null && !match._interpreter.Equals(protocol)) + { return false; // Conflict + } // Create a registration _registrations.Add(new PortMap(address, port, protocol)); diff --git a/src/Moryx/Communication/Sockets/Server/States/ServerConnectedState.cs b/src/Moryx/Communication/Sockets/Server/States/ServerConnectedState.cs index 6deda8cefa..ac2f33eab5 100644 --- a/src/Moryx/Communication/Sockets/Server/States/ServerConnectedState.cs +++ b/src/Moryx/Communication/Sockets/Server/States/ServerConnectedState.cs @@ -47,4 +47,4 @@ public override void ConnectionLost() NextState(StateListening); Context.Register(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/States/ServerListeningState.cs b/src/Moryx/Communication/Sockets/Server/States/ServerListeningState.cs index e9e9c3b3b7..281c0416eb 100644 --- a/src/Moryx/Communication/Sockets/Server/States/ServerListeningState.cs +++ b/src/Moryx/Communication/Sockets/Server/States/ServerListeningState.cs @@ -14,7 +14,9 @@ public override void ConnectionAssigned(TcpTransmission transmission, BinaryMess Context.ExecuteAssignConnection(transmission); NextState(StateConnected); if (message != null) + { Context.PublishInitialMessage(message); + } } public override void Close() @@ -22,4 +24,4 @@ public override void Close() Context.Unregister(); NextState(StateNotListening); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/States/ServerNotListeningState.cs b/src/Moryx/Communication/Sockets/Server/States/ServerNotListeningState.cs index e8b44d2fd8..fd8ff33159 100644 --- a/src/Moryx/Communication/Sockets/Server/States/ServerNotListeningState.cs +++ b/src/Moryx/Communication/Sockets/Server/States/ServerNotListeningState.cs @@ -28,4 +28,4 @@ public override void Reconnect(int delayMs) Context.Register(); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/States/ServerReconnectingState.cs b/src/Moryx/Communication/Sockets/Server/States/ServerReconnectingState.cs index 225992c79f..00d3eba39e 100644 --- a/src/Moryx/Communication/Sockets/Server/States/ServerReconnectingState.cs +++ b/src/Moryx/Communication/Sockets/Server/States/ServerReconnectingState.cs @@ -19,4 +19,4 @@ public override void Close() { NextState(StateNotListening); } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/States/ServerStateBase.cs b/src/Moryx/Communication/Sockets/Server/States/ServerStateBase.cs index b0e8d54403..1d413c8e98 100644 --- a/src/Moryx/Communication/Sockets/Server/States/ServerStateBase.cs +++ b/src/Moryx/Communication/Sockets/Server/States/ServerStateBase.cs @@ -59,4 +59,4 @@ public virtual Task SendAsync(BinaryMessage message) [StateDefinition(typeof(ServerReconnectingState))] protected const int StateReconnecting = 40; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/TcpListenerConfig.cs b/src/Moryx/Communication/Sockets/Server/TcpListenerConfig.cs index 9568e5e60b..33f95d8888 100644 --- a/src/Moryx/Communication/Sockets/Server/TcpListenerConfig.cs +++ b/src/Moryx/Communication/Sockets/Server/TcpListenerConfig.cs @@ -52,4 +52,4 @@ public class TcpListenerConfig : BinaryConnectionConfig [DataMember] [Description("The TCP KeepAlive configuration")] public TcpKeepAliveConfig KeepAliveConfig { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/Server/TcpListenerConnection.cs b/src/Moryx/Communication/Sockets/Server/TcpListenerConnection.cs index 73d66e18f9..3a7bc04020 100644 --- a/src/Moryx/Communication/Sockets/Server/TcpListenerConnection.cs +++ b/src/Moryx/Communication/Sockets/Server/TcpListenerConnection.cs @@ -94,9 +94,13 @@ public void Initialize(BinaryConnectionConfig config) _config = (TcpListenerConfig)config; if (IPAddress.TryParse(_config.IpAddress, out var address)) + { Address = address; + } else + { throw new FormatException($"Failed to parse IPAddress: {_config.IpAddress}."); + } StateMachine.ForContext(this).With(); } @@ -107,14 +111,18 @@ public void Initialize(BinaryConnectionConfig config) public void Start() { lock (_stateLock) + { _state.Open(); + } } /// public void Stop() { lock (_stateLock) + { _state.Close(); + } } /// @@ -179,13 +187,17 @@ private void OnReconnectTimer(object state) ((Timer)state).Dispose(); lock (_stateLock) + { _state.ScheduledConnectTimerElapsed(); + } } internal void AssignConnection(TcpTransmission transmission, BinaryMessage message = null) { lock (_stateLock) + { _state.ConnectionAssigned(transmission, message); + } } /// @@ -228,14 +240,18 @@ internal void CleanupTransmission() private void Disconnected(object sender, EventArgs eventArgs) { lock (_stateLock) + { _state.ConnectionLost(); + } } /// public void Send(BinaryMessage message) { lock (_stateLock) + { _state.Send(message); + } } internal void ExecuteSend(BinaryMessage message) @@ -247,7 +263,9 @@ internal void ExecuteSend(BinaryMessage message) public Task SendAsync(BinaryMessage message, CancellationToken cancellationToken = default) { lock (_stateLock) + { return _state.SendAsync(message); + } } internal Task ExecuteSendAsync(BinaryMessage message) diff --git a/src/Moryx/Communication/Sockets/Server/TcpPortListener.cs b/src/Moryx/Communication/Sockets/Server/TcpPortListener.cs index d77d5bbb32..958de484c4 100644 --- a/src/Moryx/Communication/Sockets/Server/TcpPortListener.cs +++ b/src/Moryx/Communication/Sockets/Server/TcpPortListener.cs @@ -81,7 +81,9 @@ public bool TryUnregister(TcpListenerConnection listener) private void StartListening() { if (_listening) + { return; + } // Start tcp listener and accept clients _tcpListener ??= new TcpListener(new IPEndPoint(Address, Port)); @@ -122,7 +124,9 @@ private void ClientConnected(IAsyncResult ar) // If we have listners without a connection keep accepting clients if (_listeners.Count > 0) + { _tcpListener.BeginAcceptTcpClient(ClientConnected, null); + } } tcpTransmission.StartReading(); } @@ -170,4 +174,4 @@ private void CleanUp(TcpTransmission transmission) transmission.Disconnected -= TransmissionDisconnected; transmission.Received -= InitialReceive; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Sockets/TcpTransmission.cs b/src/Moryx/Communication/Sockets/TcpTransmission.cs index b3cf8fa6eb..73c75268b1 100644 --- a/src/Moryx/Communication/Sockets/TcpTransmission.cs +++ b/src/Moryx/Communication/Sockets/TcpTransmission.cs @@ -49,17 +49,25 @@ public TcpTransmission(TcpClient client, IMessageInterpreter interpreter, ILogge private void RaiseException(Exception ex) { if (ExceptionOccurred == null) + { _logger.Log(LogLevel.Error, ex, "TcpTransmission encountered an error"); + } else + { ExceptionOccurred(this, ex); + } } private void RaiseDisconnected() { if (Disconnected == null) + { _logger.Log(LogLevel.Warning, "Client disconnected, but listener already removed!"); + } else + { Disconnected(this, EventArgs.Empty); + } } /// @@ -71,7 +79,9 @@ private void RaiseDisconnected() public void ConfigureKeepAlive(TcpKeepAliveConfig config) { if (!config.UseKeepAlive) + { return; + } var socket = _client.Client; @@ -169,7 +179,9 @@ private void BeginRead(IReadContext transmission) try { if (_disconnected) + { return; + } _stream.BeginRead(transmission.ReadBuffer, transmission.CurrentIndex, transmission.ReadSize, ReadCallback, transmission); } @@ -194,7 +206,9 @@ private void ReadComplete(IAsyncResult ar) int read; if (_disconnected) + { return; + } try { @@ -223,7 +237,9 @@ private void ReadComplete(IAsyncResult ar) if (result == ByteReadResult.Failure) { if (_interpreter.ErrorResponse(transmission, out var lastWill)) + { _stream.Write(lastWill, 0, lastWill.Length); + } Disconnect(new InvalidHeaderException("Header invalid or no matching validator found!")); return; @@ -235,9 +251,13 @@ private void ReadComplete(IAsyncResult ar) private void PublishMessage(BinaryMessage message) { if (Received == null && _disconnected) // Still feels like a hack + { _logger.Log(LogLevel.Error, "Connection already closed, but a final message was received and can not be published!"); + } else + { Received.Invoke(this, message); + } } public event EventHandler Received; @@ -255,7 +275,10 @@ internal void Disconnect() lock (this) { if (_disconnected) + { return; + } + _disconnected = true; } diff --git a/src/Moryx/Communication/Transmission/BinaryMessage.cs b/src/Moryx/Communication/Transmission/BinaryMessage.cs index baac34af9b..ec571b3eb6 100644 --- a/src/Moryx/Communication/Transmission/BinaryMessage.cs +++ b/src/Moryx/Communication/Transmission/BinaryMessage.cs @@ -62,4 +62,4 @@ public BinaryMessage(THeader header, byte[] payload) : base(payload) /// Header of this message /// public THeader Header { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IBinaryHeader.cs b/src/Moryx/Communication/Transmission/IBinaryHeader.cs index 1d757f11f5..f98f271daa 100644 --- a/src/Moryx/Communication/Transmission/IBinaryHeader.cs +++ b/src/Moryx/Communication/Transmission/IBinaryHeader.cs @@ -12,4 +12,4 @@ public interface IBinaryHeader : IByteSerializable /// Length of the payload /// int PayloadLength { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IBinaryMessageHook.cs b/src/Moryx/Communication/Transmission/IBinaryMessageHook.cs index 3915cc4bdb..2ab7f2c441 100644 --- a/src/Moryx/Communication/Transmission/IBinaryMessageHook.cs +++ b/src/Moryx/Communication/Transmission/IBinaryMessageHook.cs @@ -33,4 +33,4 @@ public interface IBinaryMessageHook /// The payload that was read from the binary message. Hooks may replace this object /// True if the message shall be published, otherwise false bool PublishingMessage(ref object payload); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IBinaryPayload.cs b/src/Moryx/Communication/Transmission/IBinaryPayload.cs index e0bcfc4e3c..1efa98632a 100644 --- a/src/Moryx/Communication/Transmission/IBinaryPayload.cs +++ b/src/Moryx/Communication/Transmission/IBinaryPayload.cs @@ -18,4 +18,4 @@ public interface IBinaryPayload : IByteSerializable /// Returns itself for method chaining /// IBinaryPayload FromBytes(byte[] bytes, ref int index); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IBinaryRoot.cs b/src/Moryx/Communication/Transmission/IBinaryRoot.cs index c77849d9e1..ff01ce8366 100644 --- a/src/Moryx/Communication/Transmission/IBinaryRoot.cs +++ b/src/Moryx/Communication/Transmission/IBinaryRoot.cs @@ -13,4 +13,4 @@ public interface IBinaryRoot : IByteSerializable /// Generate header for this message /// THeader Header { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IBinaryTransmission.cs b/src/Moryx/Communication/Transmission/IBinaryTransmission.cs index 66c11807ba..e377376d2e 100644 --- a/src/Moryx/Communication/Transmission/IBinaryTransmission.cs +++ b/src/Moryx/Communication/Transmission/IBinaryTransmission.cs @@ -25,4 +25,4 @@ public interface IBinaryTransmission /// processing buffered bytes while adding this handler. /// event EventHandler Received; -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IByteSerializable.cs b/src/Moryx/Communication/Transmission/IByteSerializable.cs index a8010d5617..7c95e6b7f9 100644 --- a/src/Moryx/Communication/Transmission/IByteSerializable.cs +++ b/src/Moryx/Communication/Transmission/IByteSerializable.cs @@ -17,4 +17,4 @@ public interface IByteSerializable /// Read object from bytes /// void FromBytes(byte[] bytes); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IByteSerializer.cs b/src/Moryx/Communication/Transmission/IByteSerializer.cs index c8e447315a..b311223d9c 100644 --- a/src/Moryx/Communication/Transmission/IByteSerializer.cs +++ b/src/Moryx/Communication/Transmission/IByteSerializer.cs @@ -22,4 +22,4 @@ public interface IByteSerializer /// Binary message received over TCP /// Deserialized message IBinaryRoot Deserialize(BinaryMessage message); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IMessageInterpreter.cs b/src/Moryx/Communication/Transmission/IMessageInterpreter.cs index e455af1b5d..45eda62318 100644 --- a/src/Moryx/Communication/Transmission/IMessageInterpreter.cs +++ b/src/Moryx/Communication/Transmission/IMessageInterpreter.cs @@ -48,4 +48,4 @@ public interface IMessageInterpreter : IEquatable /// Create error response for a faulty message /// bool ErrorResponse(IReadContext context, out byte[] lastWill); -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Transmission/IReadContext.cs b/src/Moryx/Communication/Transmission/IReadContext.cs index 67888b0363..5ac56e1016 100644 --- a/src/Moryx/Communication/Transmission/IReadContext.cs +++ b/src/Moryx/Communication/Transmission/IReadContext.cs @@ -22,4 +22,4 @@ public interface IReadContext /// Number of bytes to read /// int ReadSize { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Communication/Validation/IMessageValidator.cs b/src/Moryx/Communication/Validation/IMessageValidator.cs index 18a6661825..98323d2441 100644 --- a/src/Moryx/Communication/Validation/IMessageValidator.cs +++ b/src/Moryx/Communication/Validation/IMessageValidator.cs @@ -17,4 +17,4 @@ public interface IMessageValidator /// Interpreter used by the protocol of this validator /// IMessageInterpreter Interpreter { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ConfigBase.cs b/src/Moryx/Configuration/ConfigBase.cs index 84e386c6eb..191428f175 100644 --- a/src/Moryx/Configuration/ConfigBase.cs +++ b/src/Moryx/Configuration/ConfigBase.cs @@ -3,7 +3,6 @@ using System.ComponentModel; using System.Runtime.Serialization; -using Moryx.Modules; namespace Moryx.Configuration; @@ -31,4 +30,4 @@ public class ConfigBase : UpdatableEntry, IConfig public virtual void Initialize() { } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ConfigState.cs b/src/Moryx/Configuration/ConfigState.cs index ff945b7733..35c9476b49 100644 --- a/src/Moryx/Configuration/ConfigState.cs +++ b/src/Moryx/Configuration/ConfigState.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Modules; - namespace Moryx.Configuration; /// @@ -26,4 +24,4 @@ public enum ConfigState /// generated config object. /// Error -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/Defaults/CpuCountAttribute.cs b/src/Moryx/Configuration/Defaults/CpuCountAttribute.cs index a1c4ed1e44..979a8ea8db 100644 --- a/src/Moryx/Configuration/Defaults/CpuCountAttribute.cs +++ b/src/Moryx/Configuration/Defaults/CpuCountAttribute.cs @@ -26,4 +26,4 @@ public CpuCountAttribute() : this(0) public CpuCountAttribute(int reserve) : base(Environment.ProcessorCount > reserve ? Environment.ProcessorCount - reserve : 1) { } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/Defaults/CurrentHostNameAttribute.cs b/src/Moryx/Configuration/Defaults/CurrentHostNameAttribute.cs index fe5376357b..fc6993238e 100644 --- a/src/Moryx/Configuration/Defaults/CurrentHostNameAttribute.cs +++ b/src/Moryx/Configuration/Defaults/CurrentHostNameAttribute.cs @@ -27,4 +27,4 @@ public CurrentHostNameAttribute() : base("localhost") // ignored -> default is "localhost" } } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/FileSystemPathAttribute.cs b/src/Moryx/Configuration/FileSystemPathAttribute.cs index 59b0cc65e9..95e3f1ed45 100644 --- a/src/Moryx/Configuration/FileSystemPathAttribute.cs +++ b/src/Moryx/Configuration/FileSystemPathAttribute.cs @@ -44,4 +44,4 @@ public FileSystemPathAttribute(FileSystemPathType type) /// Returns the selected path type /// public FileSystemPathType Type { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/IConfigManager.cs b/src/Moryx/Configuration/IConfigManager.cs index dbb1a4f6c1..b83788ba10 100644 --- a/src/Moryx/Configuration/IConfigManager.cs +++ b/src/Moryx/Configuration/IConfigManager.cs @@ -30,4 +30,4 @@ public interface IConfigManager /// Save any shared configs included in this partial config /// void SaveSharedConfigs(object partialConfig, bool liveUpdate); -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/IEmptyPropertyProvider.cs b/src/Moryx/Configuration/IEmptyPropertyProvider.cs index 1ecbb71a6b..63f44d47d7 100644 --- a/src/Moryx/Configuration/IEmptyPropertyProvider.cs +++ b/src/Moryx/Configuration/IEmptyPropertyProvider.cs @@ -12,4 +12,4 @@ public interface IEmptyPropertyProvider /// Fills the object /// void FillEmpty(object obj); -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/IUpdatableConfig.cs b/src/Moryx/Configuration/IUpdatableConfig.cs index 5e22807270..da558f62b9 100644 --- a/src/Moryx/Configuration/IUpdatableConfig.cs +++ b/src/Moryx/Configuration/IUpdatableConfig.cs @@ -50,4 +50,4 @@ public interface IUpdatableConfig /// /// Properties modified void RaiseConfigChanged(params string[] modifiedProperties); -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/InvalidConfigException.cs b/src/Moryx/Configuration/InvalidConfigException.cs index 446d447842..f874ce0a29 100644 --- a/src/Moryx/Configuration/InvalidConfigException.cs +++ b/src/Moryx/Configuration/InvalidConfigException.cs @@ -36,4 +36,4 @@ public InvalidConfigException(object faultyEntry, string propertyFailure) /// Failure description containing property name and cause of failure /// public string PropertyFailure { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/PossibleValuesSerialization.cs b/src/Moryx/Configuration/PossibleValuesSerialization.cs index 50f8087296..cbf0191792 100644 --- a/src/Moryx/Configuration/PossibleValuesSerialization.cs +++ b/src/Moryx/Configuration/PossibleValuesSerialization.cs @@ -44,7 +44,9 @@ public override EntryPrototype[] Prototypes(Type memberType, ICustomAttributePro var possibleValuesAtt = attributeProvider.GetCustomAttribute(); // We can not create prototypes for possible primitives if (possibleValuesAtt == null || IsPrimitiveCollection(memberType)) + { return base.Prototypes(memberType, attributeProvider); + } // Create prototypes from possible values var list = new List(); @@ -66,7 +68,9 @@ public override EntryPossible[] PossibleValues(Type memberType, ICustomAttribute var possibleValuesAttribute = attributeProvider.GetCustomAttribute(); // Possible values for primitive collections only apply to members if (possibleValuesAttribute == null || IsPrimitiveCollection(memberType)) + { return base.PossibleValues(memberType, attributeProvider); + } // Use attribute return GetEntryPossibles(possibleValuesAttribute, instance); @@ -93,7 +97,9 @@ private EntryPossible[] GetEntryPossibles(PossibleValuesAttribute possibleValues private static bool IsPrimitiveCollection(Type memberType) { if (!EntryConvert.IsCollection(memberType)) + { return false; + } var elementType = EntryConvert.ElementType(memberType); return EntryConvert.ValueOrStringType(elementType); @@ -132,11 +138,15 @@ public override object ConvertValue(Type memberType, ICustomAttributeProvider at var att = attributeProvider.GetCustomAttribute(); if (att == null || !att.OverridesConversion || value.Type == EntryValueType.Collection) + { return base.ConvertValue(memberType, attributeProvider, mappedEntry, currentValue); + } // If old and current type are identical, keep the object if (value.Type == EntryValueType.Class && currentValue != null && currentValue.GetType().Name == value.Current) + { return currentValue; + } var instance = att.Parse(Container, ServiceProvider, mappedEntry.Value.Current); if (mappedEntry.Value.Type == EntryValueType.Class) diff --git a/src/Moryx/Configuration/UpdatableEntry.cs b/src/Moryx/Configuration/UpdatableEntry.cs index 55d46ac597..75cb442052 100644 --- a/src/Moryx/Configuration/UpdatableEntry.cs +++ b/src/Moryx/Configuration/UpdatableEntry.cs @@ -23,4 +23,4 @@ void IUpdatableConfig.RaiseConfigChanged(params string[] modifiedProperties) { ConfigChanged?.Invoke(this, new ConfigChangedEventArgs(modifiedProperties)); } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/Filters/DefaultCanWriteValueProviderFilter.cs b/src/Moryx/Configuration/ValueProvider/Filters/DefaultCanWriteValueProviderFilter.cs index 3659d8afbc..92a34f7e78 100644 --- a/src/Moryx/Configuration/ValueProvider/Filters/DefaultCanWriteValueProviderFilter.cs +++ b/src/Moryx/Configuration/ValueProvider/Filters/DefaultCanWriteValueProviderFilter.cs @@ -15,4 +15,4 @@ public bool CheckProperty(PropertyInfo propertyInfo) { return propertyInfo.GetSetMethod() != null; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/IValueProviderFilter.cs b/src/Moryx/Configuration/ValueProvider/IValueProviderFilter.cs index 7595e71c09..03683350ad 100644 --- a/src/Moryx/Configuration/ValueProvider/IValueProviderFilter.cs +++ b/src/Moryx/Configuration/ValueProvider/IValueProviderFilter.cs @@ -16,4 +16,4 @@ public interface IValueProviderFilter /// Property to check /// True if the property should be set otherwise false bool CheckProperty(PropertyInfo propertyInfo); -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/PropertyValidationException.cs b/src/Moryx/Configuration/ValueProvider/PropertyValidationException.cs index 0b97438c96..c8a7666385 100644 --- a/src/Moryx/Configuration/ValueProvider/PropertyValidationException.cs +++ b/src/Moryx/Configuration/ValueProvider/PropertyValidationException.cs @@ -8,8 +8,8 @@ namespace Moryx.Configuration; [Serializable] internal class PropertyValidationException : Exception { - private PropertyInfo property; - private ValueProviderExecutorSettings settings; + private readonly PropertyInfo property; + private readonly ValueProviderExecutorSettings settings; public PropertyValidationException() { @@ -26,4 +26,4 @@ public PropertyValidationException(PropertyInfo property, ValueProviderExecutorS this.settings = settings; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/Providers/ActivatorValueProvider.cs b/src/Moryx/Configuration/ValueProvider/Providers/ActivatorValueProvider.cs index e6e9c0ea0b..6d921b5e9b 100644 --- a/src/Moryx/Configuration/ValueProvider/Providers/ActivatorValueProvider.cs +++ b/src/Moryx/Configuration/ValueProvider/Providers/ActivatorValueProvider.cs @@ -34,4 +34,4 @@ public ValueProviderResult Handle(object parent, PropertyInfo property) } return ValueProviderResult.Skipped; } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/Providers/DefaultValueAttributeProvider.cs b/src/Moryx/Configuration/ValueProvider/Providers/DefaultValueAttributeProvider.cs index 845e402ab2..0aaa3f2c32 100644 --- a/src/Moryx/Configuration/ValueProvider/Providers/DefaultValueAttributeProvider.cs +++ b/src/Moryx/Configuration/ValueProvider/Providers/DefaultValueAttributeProvider.cs @@ -20,12 +20,16 @@ public ValueProviderResult Handle(object parent, PropertyInfo property) var defaultValue = propertyType.IsValueType ? Activator.CreateInstance(propertyType) : null; // We only operate on properties currently having their system default if (!Equals(value, defaultValue)) + { return ValueProviderResult.Skipped; + } // No attribute, nothing we can do var attribute = property.GetCustomAttribute(false); if (attribute == null) + { return ValueProviderResult.Skipped; + } // Accept nulls for objects or nullable reference types if (attribute.Value == null && (propertyType.IsClass || Nullable.GetUnderlyingType(propertyType) != null)) @@ -54,4 +58,4 @@ public ValueProviderResult Handle(object parent, PropertyInfo property) } } -} \ No newline at end of file +} diff --git a/src/Moryx/Configuration/ValueProvider/ValueProviderExecutorSettings.cs b/src/Moryx/Configuration/ValueProvider/ValueProviderExecutorSettings.cs index 4518d110f9..5d1929654c 100644 --- a/src/Moryx/Configuration/ValueProvider/ValueProviderExecutorSettings.cs +++ b/src/Moryx/Configuration/ValueProvider/ValueProviderExecutorSettings.cs @@ -72,4 +72,4 @@ public ValueProviderExecutorSettings AddDefaultValueProvider() .AddProvider(new ActivatorValueProvider()); } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/ComponentAttribute.cs b/src/Moryx/Container/Attributes/ComponentAttribute.cs index 13c931d91a..f2cb6d8832 100644 --- a/src/Moryx/Container/Attributes/ComponentAttribute.cs +++ b/src/Moryx/Container/Attributes/ComponentAttribute.cs @@ -49,4 +49,4 @@ public enum LifeCycle /// Create a new instance for every request /// Transient -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/ComponentLoaderIgnoreAttribute.cs b/src/Moryx/Container/Attributes/ComponentLoaderIgnoreAttribute.cs index 55a5268ffb..fe26c9a5a3 100644 --- a/src/Moryx/Container/Attributes/ComponentLoaderIgnoreAttribute.cs +++ b/src/Moryx/Container/Attributes/ComponentLoaderIgnoreAttribute.cs @@ -10,4 +10,4 @@ namespace Moryx.Container; public class ComponentLoaderIgnoreAttribute : Attribute { -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/DependencyRegistrationAttribute.cs b/src/Moryx/Container/Attributes/DependencyRegistrationAttribute.cs index 27f880da4e..47bccc689f 100644 --- a/src/Moryx/Container/Attributes/DependencyRegistrationAttribute.cs +++ b/src/Moryx/Container/Attributes/DependencyRegistrationAttribute.cs @@ -71,4 +71,4 @@ public interface ISubInitializer /// Execute further initialization /// void Initialize(IContainer services); -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/NamedAttribute.cs b/src/Moryx/Container/Attributes/NamedAttribute.cs index 7190b25737..5035d9c0bb 100644 --- a/src/Moryx/Container/Attributes/NamedAttribute.cs +++ b/src/Moryx/Container/Attributes/NamedAttribute.cs @@ -22,4 +22,4 @@ public NamedAttribute(string name) /// Name of component to inject at this point /// public string ComponentName { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/PluginAttribute.cs b/src/Moryx/Container/Attributes/PluginAttribute.cs index fe048f33a1..f126869503 100644 --- a/src/Moryx/Container/Attributes/PluginAttribute.cs +++ b/src/Moryx/Container/Attributes/PluginAttribute.cs @@ -18,4 +18,4 @@ public PluginAttribute(LifeCycle lifeStyle, params Type[] services) : base(lifeStyle, services) { } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/Attributes/PluginFactoryAttribute.cs b/src/Moryx/Container/Attributes/PluginFactoryAttribute.cs index f8486d50af..2f902529ce 100644 --- a/src/Moryx/Container/Attributes/PluginFactoryAttribute.cs +++ b/src/Moryx/Container/Attributes/PluginFactoryAttribute.cs @@ -33,4 +33,4 @@ public PluginFactoryAttribute(Type selectorType) { Selector = selectorType; } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/ComponentSelectors/IConfigBasedComponentSelector.cs b/src/Moryx/Container/ComponentSelectors/IConfigBasedComponentSelector.cs index 0fab046674..aba5622517 100644 --- a/src/Moryx/Container/ComponentSelectors/IConfigBasedComponentSelector.cs +++ b/src/Moryx/Container/ComponentSelectors/IConfigBasedComponentSelector.cs @@ -8,4 +8,4 @@ namespace Moryx.Container; /// public interface IConfigBasedComponentSelector { -} \ No newline at end of file +} diff --git a/src/Moryx/Container/ComponentSelectors/INameBasedComponentSelector.cs b/src/Moryx/Container/ComponentSelectors/INameBasedComponentSelector.cs index 78ecb265e4..cda5eed7be 100644 --- a/src/Moryx/Container/ComponentSelectors/INameBasedComponentSelector.cs +++ b/src/Moryx/Container/ComponentSelectors/INameBasedComponentSelector.cs @@ -9,4 +9,4 @@ namespace Moryx.Container; public interface INameBasedComponentSelector { -} \ No newline at end of file +} diff --git a/src/Moryx/Container/ContainerLoadComponentsExtension.cs b/src/Moryx/Container/ContainerLoadComponentsExtension.cs index c4fcbe9606..540a7a8f33 100644 --- a/src/Moryx/Container/ContainerLoadComponentsExtension.cs +++ b/src/Moryx/Container/ContainerLoadComponentsExtension.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Tools; using System.Reflection; +using Moryx.Tools; namespace Moryx.Container; @@ -39,7 +39,9 @@ public void LoadFromAssembly(Assembly assembly, Predicate predicate) { // Register all we want if (ShallInstall(type) && predicate(type)) + { container.Register(type); + } } } } @@ -58,16 +60,22 @@ private static bool ShallInstall(Type foundType) private static bool TypeRequired(DependencyRegistrationAttribute att, Type foundType) { if (att.InstallerMode == InstallerMode.All) + { return true; + } // Check if interface was specified as required if (foundType.IsInterface && att.RequiredTypes.Contains(foundType)) + { return true; + } // Check if class exports required type var services = ContainerRegistrationExtensions.GetComponentServices(foundType); if (foundType.IsClass && att.RequiredTypes.Intersect(services).Any()) + { return true; + } return false; } @@ -106,10 +114,14 @@ public IContainer LoadComponents(Predicate condition) where T : class private static bool LoadComponentCandidate(Type type) { if (type.Assembly.GetCustomAttribute() != null) + { return false; + } if (type.GetCustomAttribute(true) == null) + { return false; + } return true; } @@ -118,15 +130,21 @@ private static void RegisterAdditionalDependencies(IContainer container, Type im { var att = implementation.GetCustomAttribute(); if (att == null) + { return; + } container.LoadFromAssembly(implementation.Assembly, att); if (att.Initializer == null) + { return; + } if (!typeof(ISubInitializer).IsAssignableFrom(att.Initializer)) + { throw new InvalidCastException($"SubInitializer {att.Initializer.Name} of component {implementation.Name} does not implement interface {nameof(ISubInitializer)}."); + } container.Register(att.Initializer, [typeof(ISubInitializer), att.Initializer], null, LifeCycle.Singleton); } diff --git a/src/Moryx/Container/ContainerRegistrationExtensions.cs b/src/Moryx/Container/ContainerRegistrationExtensions.cs index b7bce7ca45..4c2985e06a 100644 --- a/src/Moryx/Container/ContainerRegistrationExtensions.cs +++ b/src/Moryx/Container/ContainerRegistrationExtensions.cs @@ -64,7 +64,9 @@ public static Type[] GetComponentServices(Type type) { var att = type.GetCustomAttribute(); if (att != null) + { return att.Services.Any() ? att.Services : [type]; + } var interfaces = type.GetInterfaces(); return interfaces.Any() ? interfaces : [type]; diff --git a/src/Moryx/Container/ContainerResolveExtensions.cs b/src/Moryx/Container/ContainerResolveExtensions.cs index c8754ace1e..66c8ccfc61 100644 --- a/src/Moryx/Container/ContainerResolveExtensions.cs +++ b/src/Moryx/Container/ContainerResolveExtensions.cs @@ -48,4 +48,4 @@ public T[] ResolveAll() return (T[])container.ResolveAll(typeof(T)); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/IContainer.cs b/src/Moryx/Container/IContainer.cs index 8db047a7f1..292e058a8a 100644 --- a/src/Moryx/Container/IContainer.cs +++ b/src/Moryx/Container/IContainer.cs @@ -46,4 +46,4 @@ public interface IContainer /// Destroy the internal container and all registered objects /// void Destroy(); -} \ No newline at end of file +} diff --git a/src/Moryx/Container/IModuleContainerFactory.cs b/src/Moryx/Container/IModuleContainerFactory.cs index 597dfd7f62..85b8c7c2ee 100644 --- a/src/Moryx/Container/IModuleContainerFactory.cs +++ b/src/Moryx/Container/IModuleContainerFactory.cs @@ -15,4 +15,4 @@ public interface IModuleContainerFactory /// Creates a new container based on strategies and the module assembly /// IContainer Create(IDictionary strategies, Assembly moduleAssembly); -} \ No newline at end of file +} diff --git a/src/Moryx/Container/INamedChildContainer.cs b/src/Moryx/Container/INamedChildContainer.cs index cf42023c73..39bde84b5f 100644 --- a/src/Moryx/Container/INamedChildContainer.cs +++ b/src/Moryx/Container/INamedChildContainer.cs @@ -27,4 +27,4 @@ public interface IContainerChild where TParent : INamedChildContainer TParent Parent { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Container/UseChildAttribute.cs b/src/Moryx/Container/UseChildAttribute.cs index 6e798f8af0..8190e1761a 100644 --- a/src/Moryx/Container/UseChildAttribute.cs +++ b/src/Moryx/Container/UseChildAttribute.cs @@ -45,4 +45,4 @@ public UseChildAttribute(string childName, string parentName) : this(childName) { ParentName = parentName; } -} \ No newline at end of file +} diff --git a/src/Moryx/Logging/ILoggingComponent.cs b/src/Moryx/Logging/ILoggingComponent.cs index 347bfc995b..1228de50b6 100644 --- a/src/Moryx/Logging/ILoggingComponent.cs +++ b/src/Moryx/Logging/ILoggingComponent.cs @@ -12,4 +12,4 @@ public interface ILoggingComponent /// Logger of this component /// IModuleLogger Logger { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Logging/IModuleLogger.cs b/src/Moryx/Logging/IModuleLogger.cs index 2b490cdd9e..f88b7c6dc2 100644 --- a/src/Moryx/Logging/IModuleLogger.cs +++ b/src/Moryx/Logging/IModuleLogger.cs @@ -11,4 +11,4 @@ namespace Moryx.Logging; /// public interface IModuleLogger : ILogger, INamedChildContainer { -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/ExpectedConfigAttribute.cs b/src/Moryx/Modules/ExpectedConfigAttribute.cs index 0d92c3b364..209a32e05f 100644 --- a/src/Moryx/Modules/ExpectedConfigAttribute.cs +++ b/src/Moryx/Modules/ExpectedConfigAttribute.cs @@ -21,4 +21,4 @@ public ExpectedConfigAttribute(Type configType) { ExpectedConfigType = configType; } -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IAsyncConfiguredPlugin.cs b/src/Moryx/Modules/IAsyncConfiguredPlugin.cs index 7192bfd8d8..baca284734 100644 --- a/src/Moryx/Modules/IAsyncConfiguredPlugin.cs +++ b/src/Moryx/Modules/IAsyncConfiguredPlugin.cs @@ -11,4 +11,4 @@ public interface IAsyncConfiguredPlugin : IAsyncPlugin, IAsyncConfiguredIn where T : IPluginConfig { -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IAsyncInitializable.cs b/src/Moryx/Modules/IAsyncInitializable.cs index 960a6dda55..0b6e065bdd 100644 --- a/src/Moryx/Modules/IAsyncInitializable.cs +++ b/src/Moryx/Modules/IAsyncInitializable.cs @@ -18,4 +18,4 @@ public interface IAsyncInitializable /// /// The token to monitor for cancellation requests. The default value is None. Task InitializeAsync(CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IAsyncPlugin.cs b/src/Moryx/Modules/IAsyncPlugin.cs index b152bb35fa..2e9f6abbe1 100644 --- a/src/Moryx/Modules/IAsyncPlugin.cs +++ b/src/Moryx/Modules/IAsyncPlugin.cs @@ -23,4 +23,4 @@ public interface IAsyncPlugin /// /// The token to monitor for cancellation requests. The default value is None. Task StopAsync(CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IConfiguredInitializable.cs b/src/Moryx/Modules/IConfiguredInitializable.cs index 22b8288899..b0f0c62a37 100644 --- a/src/Moryx/Modules/IConfiguredInitializable.cs +++ b/src/Moryx/Modules/IConfiguredInitializable.cs @@ -15,4 +15,4 @@ public interface IConfiguredInitializable /// /// Config of this component void Initialize(T config); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IConfiguredPlugin.cs b/src/Moryx/Modules/IConfiguredPlugin.cs index b4b18ed697..9508bf676b 100644 --- a/src/Moryx/Modules/IConfiguredPlugin.cs +++ b/src/Moryx/Modules/IConfiguredPlugin.cs @@ -10,4 +10,4 @@ namespace Moryx.Modules; public interface IConfiguredPlugin : IPlugin, IConfiguredInitializable where T : IPluginConfig { -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IInitializable.cs b/src/Moryx/Modules/IInitializable.cs index 33c0ec79aa..40a72b5a89 100644 --- a/src/Moryx/Modules/IInitializable.cs +++ b/src/Moryx/Modules/IInitializable.cs @@ -17,4 +17,4 @@ public interface IInitializable /// any active functionality and/or periodic execution of logic. /// void Initialize(); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IInitializablePlugin.cs b/src/Moryx/Modules/IInitializablePlugin.cs index 898733ea1a..f413ec9aff 100644 --- a/src/Moryx/Modules/IInitializablePlugin.cs +++ b/src/Moryx/Modules/IInitializablePlugin.cs @@ -10,4 +10,4 @@ namespace Moryx.Modules; /// public interface IInitializablePlugin : IInitializable, IPlugin { -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IModule.cs b/src/Moryx/Modules/IModule.cs index 01268345d2..5cdca409d0 100644 --- a/src/Moryx/Modules/IModule.cs +++ b/src/Moryx/Modules/IModule.cs @@ -25,4 +25,4 @@ public interface IModule : IAsyncInitializable /// Acknowledge a notification /// void AcknowledgeNotification(IModuleNotification notification); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IModuleNotification.cs b/src/Moryx/Modules/IModuleNotification.cs index 85615a4292..407274f33b 100644 --- a/src/Moryx/Modules/IModuleNotification.cs +++ b/src/Moryx/Modules/IModuleNotification.cs @@ -37,4 +37,4 @@ public interface IModuleNotification /// public interface INotificationCollection : ICollection, INotifyCollectionChanged { -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IPlugin.cs b/src/Moryx/Modules/IPlugin.cs index 52fc168940..3047bb1820 100644 --- a/src/Moryx/Modules/IPlugin.cs +++ b/src/Moryx/Modules/IPlugin.cs @@ -21,4 +21,4 @@ public interface IPlugin /// Stops internal execution of active and/or periodic functionality. /// void Stop(); -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IPluginConfig.cs b/src/Moryx/Modules/IPluginConfig.cs index 84a3ebdda2..cefa498168 100644 --- a/src/Moryx/Modules/IPluginConfig.cs +++ b/src/Moryx/Modules/IPluginConfig.cs @@ -12,4 +12,4 @@ public interface IPluginConfig /// Name of the component represented by this entry /// string PluginName { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/IPriorizedInitializable.cs b/src/Moryx/Modules/IPriorizedInitializable.cs index 1989488026..dfe02c2645 100644 --- a/src/Moryx/Modules/IPriorizedInitializable.cs +++ b/src/Moryx/Modules/IPriorizedInitializable.cs @@ -87,7 +87,11 @@ public bool Equals(Priority other) /// public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(null, obj)) + { + return false; + } + return obj is Priority && Equals((Priority)obj); } @@ -144,4 +148,4 @@ public override int GetHashCode() { return a._priority >= b._priority; } -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/ModuleEventStreamAttribute.cs b/src/Moryx/Modules/ModuleEventStreamAttribute.cs index 1eec57ac92..04bc911327 100644 --- a/src/Moryx/Modules/ModuleEventStreamAttribute.cs +++ b/src/Moryx/Modules/ModuleEventStreamAttribute.cs @@ -20,4 +20,4 @@ public ModuleEventStreamAttribute(string eventStreamUrl) /// URL of the event stream /// public string EventStreamUrl { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/ModuleMenuCategory.cs b/src/Moryx/Modules/ModuleMenuCategory.cs index bde31f9cb3..fa84c8bb79 100644 --- a/src/Moryx/Modules/ModuleMenuCategory.cs +++ b/src/Moryx/Modules/ModuleMenuCategory.cs @@ -27,4 +27,4 @@ public enum ModuleCategory /// Module offers support and help /// Help = 30, -} \ No newline at end of file +} diff --git a/src/Moryx/Modules/WebModuleAttribute.cs b/src/Moryx/Modules/WebModuleAttribute.cs index aeafc06e26..a1c9d1693c 100644 --- a/src/Moryx/Modules/WebModuleAttribute.cs +++ b/src/Moryx/Modules/WebModuleAttribute.cs @@ -39,4 +39,4 @@ public WebModuleAttribute(string route, string icon) Route = route; Icon = icon; } -} \ No newline at end of file +} diff --git a/src/Moryx/Notifications/Severity.cs b/src/Moryx/Notifications/Severity.cs index a07cff09dc..2159ecca04 100644 --- a/src/Moryx/Notifications/Severity.cs +++ b/src/Moryx/Notifications/Severity.cs @@ -27,4 +27,4 @@ public enum Severity /// The notification shows an fatal error. /// Fatal -} \ No newline at end of file +} diff --git a/src/Moryx/Platform.cs b/src/Moryx/Platform.cs index 9daa88aa68..ce66de5225 100644 --- a/src/Moryx/Platform.cs +++ b/src/Moryx/Platform.cs @@ -62,4 +62,4 @@ public static void SetPlatform() ProductDescription = startAssembly.GetCustomAttribute()?.Description ?? "No Description provided!", }; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/ByteSerializer.cs b/src/Moryx/Serialization/ByteSerializer.cs index 971cd9f3f6..e48e6a9d98 100644 --- a/src/Moryx/Serialization/ByteSerializer.cs +++ b/src/Moryx/Serialization/ByteSerializer.cs @@ -40,4 +40,4 @@ public static BinaryMessage Serialize(IBinaryRoot message) /// Binary message received over TCP /// Deserialized message public abstract IBinaryRoot Deserialize(BinaryMessage message); -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/DefaultSerialization.cs b/src/Moryx/Serialization/DefaultSerialization.cs index 1b012d83da..9665450ae4 100644 --- a/src/Moryx/Serialization/DefaultSerialization.cs +++ b/src/Moryx/Serialization/DefaultSerialization.cs @@ -50,16 +50,24 @@ public virtual EntryPrototype[] Prototypes(Type memberType, ICustomAttributeProv else if (memberType.IsEnum) { foreach (Enum enumValue in Enum.GetValues(memberType)) + { prototypes.Add(new EntryPrototype(enumValue.ToString("G"), enumValue)); + } } else { // check if this member is abstract - if (memberType.IsAbstract) return prototypes.ToArray(); + if (memberType.IsAbstract) + { + return prototypes.ToArray(); + } var prototype = Activator.CreateInstance(memberType); if (memberType.IsClass) + { ValueProviderExecutor.Execute(prototype, new ValueProviderExecutorSettings().AddDefaultValueProvider()); + } + prototypes.Add(new EntryPrototype(memberType.Name, prototype)); } @@ -78,7 +86,9 @@ public virtual EntryPossible[] PossibleValues(Type memberType, ICustomAttributeP // Element type for collections var isCollection = EntryConvert.IsCollection(memberType); if (isCollection) + { memberType = EntryConvert.ElementType(memberType); + } // Enum names, member name for collections, allowed values or null if (memberType.IsEnum) @@ -116,7 +126,9 @@ public virtual EntryValidation CreateValidation(Type memberType, ICustomAttribut var validationAttributes = attributeProvider.GetCustomAttributes(); if (validationAttributes.Length == 0) + { return validation; + } // Iterate over attributes reading all validation rules foreach (var attribute in validationAttributes) @@ -173,12 +185,12 @@ public virtual IEnumerable WriteFilter(Type sourceType, IEnumera { // Return pairs where available return from entry in encoded - let property = sourceType.GetProperty(entry.Identifier) - select new MappedProperty - { - Entry = entry, - Property = property - }; + let property = sourceType.GetProperty(entry.Identifier) + select new MappedProperty + { + Entry = entry, + Property = property + }; } /// @@ -186,16 +198,22 @@ public virtual object DefaultValue(PropertyInfo property, object currentValue) { // No default is better than the current value if (currentValue != null) + { return currentValue; + } // Try to read default from attribute var defaultAtt = property.GetCustomAttribute(); if (defaultAtt != null) + { return defaultAtt.Value; + } // For arrays create empty element array if (property.PropertyType.IsArray) + { return Array.CreateInstance(property.PropertyType.GetElementType(), 0); + } // In all other cases use the activator return Activator.CreateInstance(property.PropertyType); @@ -226,7 +244,9 @@ public virtual object ConvertValue(Type memberType, ICustomAttributeProvider att if (currentStream != null && !createNewMemoryStream) { if (currentStream.CanSeek) + { currentStream.Seek(0, SeekOrigin.Begin); + } targetStream = currentStream; targetStream.Write(contentBytes, 0, contentBytes.Length); @@ -250,7 +270,9 @@ public virtual object ConvertValue(Type memberType, ICustomAttributeProvider att default: var value = mappedEntry.Value.Current; if (value is null) + { return null; + } try { @@ -259,7 +281,10 @@ public virtual object ConvertValue(Type memberType, ICustomAttributeProvider att catch (Exception e) { if (e is FormatException or OverflowException) + { throw new ArgumentException($"Invalid value {mappedEntry.Value.Current} for entry {mappedEntry.DisplayName ?? mappedEntry.Identifier}.", e); + } + throw; } } @@ -280,11 +305,15 @@ public EntryUnitType GetUnitTypeByAttributes(ICustomAttributeProvider property) var unitType = EntryUnitType.None; if (HasFlagsAttribute(property)) + { unitType = EntryUnitType.Flags; + } var passwordAttr = property.GetCustomAttribute(); if (passwordAttr != null) + { unitType = EntryUnitType.Password; + } var fileAttr = property.GetCustomAttribute(); if (fileAttr != null) @@ -348,7 +377,9 @@ protected static object CollectionBuilder(Type collectionType, object currentVal { // Use dictionary when interface where used if (collectionType.IsInterface) + { collectionType = typeof(Dictionary<,>).MakeGenericType(collectionType.GenericTypeArguments); + } // Reuse current object if available return currentValue ?? Activator.CreateInstance(collectionType); } @@ -358,7 +389,9 @@ protected static object CollectionBuilder(Type collectionType, object currentVal { // Use lists when interfaces where used if (collectionType.IsInterface) + { collectionType = typeof(List<>).MakeGenericType(collectionType.GenericTypeArguments); + } // Reuse current object if available return currentValue ?? Activator.CreateInstance(collectionType); } diff --git a/src/Moryx/Serialization/EntryConvert/Entry.cs b/src/Moryx/Serialization/EntryConvert/Entry.cs index a65fe1d737..8056e59ba7 100644 --- a/src/Moryx/Serialization/EntryConvert/Entry.cs +++ b/src/Moryx/Serialization/EntryConvert/Entry.cs @@ -74,10 +74,10 @@ public Entry() public Entry GetPrototype(string typeName) { return (from prototype in Prototypes - let value = prototype.Value - where value.Current == typeName - || value.Type.ToString("G") == typeName - select prototype).FirstOrDefault(); + let value = prototype.Value + where value.Current == typeName + || value.Type.ToString("G") == typeName + select prototype).FirstOrDefault(); } /// @@ -177,16 +177,24 @@ public static bool ValuesEqual(Entry left, Entry right, bool orderSensitive) // TODO: Remove this overload in the next major and make order-sensitive comparison the default if (left == null || right == null) + { return false; + } if (ReferenceEquals(left, right)) + { return true; + } if (left.Value.Current != right.Value.Current) + { return false; + } if (left.SubEntries.Count != right.SubEntries.Count) + { return false; + } for (var i = 0; i < left.SubEntries.Count; i++) { @@ -196,10 +204,14 @@ public static bool ValuesEqual(Entry left, Entry right, bool orderSensitive) : right.SubEntries.FirstOrDefault(p => p.Identifier == leftEntry.Identifier); if (rightEntry == null || leftEntry.Identifier != rightEntry.Identifier) + { return false; + } if (!ValuesEqual(leftEntry, rightEntry, orderSensitive)) + { return false; + } } return true; diff --git a/src/Moryx/Serialization/EntryConvert/EntryConvert.cs b/src/Moryx/Serialization/EntryConvert/EntryConvert.cs index ac8def54c7..84f467ad86 100644 --- a/src/Moryx/Serialization/EntryConvert/EntryConvert.cs +++ b/src/Moryx/Serialization/EntryConvert/EntryConvert.cs @@ -33,7 +33,9 @@ public static bool IsCollection(Type propertyType) public static bool IsDictionary(Type collectionType) { if (typeof(IDictionary).IsAssignableFrom(collectionType)) + { return true; + } return collectionType.IsGenericType && collectionType.GetGenericTypeDefinition() == typeof(IDictionary<,>); @@ -54,7 +56,9 @@ public static Type ElementType(Type collectionType) { // If it is a dictionary create a key value pair if (IsDictionary(collectionType)) + { return collectionType.GenericTypeArguments[1]; + } // otherwise create the element's type. List --> Test return collectionType.IsArray ? collectionType.GetElementType() : collectionType.GenericTypeArguments[0]; @@ -144,9 +148,13 @@ private static EntryValue CreateEntryValue(PropertyInfo property, ICustomSeriali // Get most basic default var defaultAttribute = property.GetCustomAttribute(); if (defaultAttribute != null) + { entryValue.Default = defaultAttribute.Value.ToString(); + } else if (entryValue.Possible != null && entryValue.Possible.Length >= 1) + { entryValue.Default = entryValue.Possible[0].Key; + } else if (property.PropertyType.IsValueType && entryValue.Type != EntryValueType.Struct) { var underlyingType = Nullable.GetUnderlyingType(property.PropertyType); @@ -155,7 +163,9 @@ private static EntryValue CreateEntryValue(PropertyInfo property, ICustomSeriali } // Value types should have the default value as current value (except decomposed structs) if (ValueOrStringType(property.PropertyType) && entryValue.Type != EntryValueType.Struct) + { entryValue.Current = ConvertToString(entryValue.Default, customSerialization.FormatProvider); + } return entryValue; } @@ -401,7 +411,9 @@ public static Entry EncodeObject(object instance, ICustomSerialization customSer //exclude property that can lead to self reference var propertyType = property.PropertyType; if (propertyType == instanceType) + { continue; + } var isFaulty = !TryGetValue(property, instance, out var value); @@ -416,14 +428,18 @@ public static Entry EncodeObject(object instance, ICustomSerialization customSer var convertedProperty = DefaultPropertyEncoding(property, customSerialization, instance); // Change type in case of exception if (isFaulty) + { convertedProperty.Value.Type = EntryValueType.Exception; + } switch (convertedProperty.Value.Type) { case EntryValueType.Collection: // Get collection and iterate if it has entries if (value == null) + { break; + } convertedProperty.SubEntries.AddRange(EncodeItems(value, propertyType, property, customSerialization, instance)); break; @@ -441,7 +457,9 @@ public static Entry EncodeObject(object instance, ICustomSerialization customSer if (value is Stream stream) { if (stream.CanSeek) + { stream.Seek(0, SeekOrigin.Begin); + } convertedProperty.Value.Current = ConvertToBase64(stream); } @@ -783,11 +801,15 @@ public static object UpdateInstance(object instance, Entry encoded, ICustomSeria // Do not operate on faulty properties or read-only properties // For security reasons read the flag from the property again if (mapped.Entry?.Value.Type == EntryValueType.Exception || property.GetCustomAttribute()?.IsReadOnly == true) + { continue; + } // Try to read the current value, skip properties with faulty getters if (!TryGetValue(property, instance, out var currentValue)) + { continue; + } // Encoders decode the complete entry, members without entry keep their current value var encoder = customSerialization.GetEncoder(propertyType, property); @@ -818,7 +840,9 @@ public static object UpdateInstance(object instance, Entry encoded, ICustomSeria UpdateCollection(currentValue, mapped.Property.PropertyType, mapped.Property, mapped.Entry, strategy, customSerialization, instance); if (strategy is ArrayIListStrategy) + { doNotUpdateProperty = true; + } } // Update class else if (propertyType.IsClass) @@ -1101,9 +1125,13 @@ private static object[] ConvertArguments(MethodBase method, MethodEntry encodedM else if (paramType.IsClass) { if (entry == null) + { UpdateInstance(argument, new Entry(), customSerialization); + } else + { UpdateInstance(argument, entry, customSerialization); + } } arguments[i] = argument; diff --git a/src/Moryx/Serialization/EntryConvert/EntryUnitType.cs b/src/Moryx/Serialization/EntryConvert/EntryUnitType.cs index ee84c8f7a6..aeedd05355 100644 --- a/src/Moryx/Serialization/EntryConvert/EntryUnitType.cs +++ b/src/Moryx/Serialization/EntryConvert/EntryUnitType.cs @@ -32,4 +32,4 @@ public enum EntryUnitType /// Unit is a base64 string /// Base64 -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/EntryConvert/EntryValidation.cs b/src/Moryx/Serialization/EntryConvert/EntryValidation.cs index 1359aebea5..2e69310361 100644 --- a/src/Moryx/Serialization/EntryConvert/EntryValidation.cs +++ b/src/Moryx/Serialization/EntryConvert/EntryValidation.cs @@ -74,4 +74,4 @@ public EntryValidation Clone(bool deep) }; return copy; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/EntryConvert/EntryValue.cs b/src/Moryx/Serialization/EntryConvert/EntryValue.cs index df1b1b8a15..56406d97ba 100644 --- a/src/Moryx/Serialization/EntryConvert/EntryValue.cs +++ b/src/Moryx/Serialization/EntryConvert/EntryValue.cs @@ -108,4 +108,4 @@ public EntryValue Clone(bool deep) return copy; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/EntryConvert/MethodEntry.cs b/src/Moryx/Serialization/EntryConvert/MethodEntry.cs index 891ac7fa7d..419ee6fb84 100644 --- a/src/Moryx/Serialization/EntryConvert/MethodEntry.cs +++ b/src/Moryx/Serialization/EntryConvert/MethodEntry.cs @@ -63,7 +63,7 @@ public MethodEntry Clone(bool deep) Name = Name, DisplayName = DisplayName, Description = Description, - IsAsync = IsAsync + IsAsync = IsAsync }; if (deep) @@ -81,4 +81,4 @@ public MethodEntry Clone(bool deep) return copy; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/EntrySerializeSerialization.cs b/src/Moryx/Serialization/EntrySerializeSerialization.cs index 246f39f803..c06612643e 100644 --- a/src/Moryx/Serialization/EntrySerializeSerialization.cs +++ b/src/Moryx/Serialization/EntrySerializeSerialization.cs @@ -39,9 +39,9 @@ public EntrySerializeSerialization(Type filterBaseType) public override IEnumerable GetConstructors(Type sourceType) { var constructors = from ctor in base.GetConstructors(sourceType) - let mode = EvaluateSerializeMode(ctor) - where mode.HasValue && mode.Value == EntrySerializeMode.Always - select ctor; + let mode = EvaluateSerializeMode(ctor) + where mode.HasValue && mode.Value == EntrySerializeMode.Always + select ctor; return constructors; } @@ -51,9 +51,9 @@ public override IEnumerable GetMethods(Type sourceType) { var methods = sourceType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(m => !m.IsSpecialName); methods = from method in methods - let mode = EvaluateSerializeMode(method) - where mode.HasValue && mode.Value == EntrySerializeMode.Always - select method; + let mode = EvaluateSerializeMode(method) + where mode.HasValue && mode.Value == EntrySerializeMode.Always + select method; return methods; } @@ -72,12 +72,12 @@ public override IEnumerable WriteFilter(Type sourceType, IEnumer // Ignore properties which are not mapped var properties = GetProperties(sourceType); var result = from entry in encoded - let property = properties.FirstOrDefault(x => x.Name.Equals(entry.Identifier)) - select new MappedProperty - { - Entry = entry, - Property = property - }; + let property = properties.FirstOrDefault(x => x.Name.Equals(entry.Identifier)) + select new MappedProperty + { + Entry = entry, + Property = property + }; return result.Where(mapped => mapped.Entry != null); } @@ -87,7 +87,9 @@ public override IEnumerable WriteFilter(Type sourceType, IEnumer private bool BasePropertyFilter(PropertyInfo prop) { if (_basePropertyFilter.Length == 0) + { return true; + } return !_basePropertyFilter.Contains(prop.Name); } @@ -98,7 +100,9 @@ private bool BasePropertyFilter(PropertyInfo prop) private bool ExplicitPropertyFilter(PropertyInfo prop) { if (!FilterExplicitProperties) + { return true; + } return !ReflectionTool.IsExplicitInterfaceImplementation(prop); } @@ -119,24 +123,32 @@ private static IEnumerable EntrySerializeAttributeFilter(Type sour // Class: Always // -> All properties except "Never" if (sourceTypeMode.HasValue && sourceTypeMode.Value == EntrySerializeMode.Always) + { return properties.Except(neverProperties); + } // Class: Never // -> Only "Always" properties if (sourceTypeMode.HasValue && sourceTypeMode.Value == EntrySerializeMode.Never) + { return alwaysProperties; + } // Class: Not defined // "Always" and "Never" properties, "Always" properties but no "Never" // Only "Never" properties if (alwaysProperties.Length > 0) + { return alwaysProperties; + } // No "Always" properties, but "Never" properties // -> Properties except "Never" if (neverProperties.Length > 0) + { return properties.Except(neverProperties); + } // No property mode defined, No "Always", No "Never" // -> All property @@ -184,4 +196,4 @@ private class PropertyMode public EntrySerializeMode? Mode { get; set; } } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/InlineConverter.cs b/src/Moryx/Serialization/InlineConverter.cs index 1effe7e69d..02f7e3f54b 100644 --- a/src/Moryx/Serialization/InlineConverter.cs +++ b/src/Moryx/Serialization/InlineConverter.cs @@ -16,7 +16,10 @@ public static class InlineConverter public static unsafe void Include(short value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((short*)(b + index)) = value; + } + index += 2; } @@ -26,7 +29,10 @@ public static unsafe void Include(short value, byte[] bytes, ref int index) public static unsafe void Include(ushort value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((ushort*)(b + index)) = value; + } + index += 2; } @@ -36,7 +42,10 @@ public static unsafe void Include(ushort value, byte[] bytes, ref int index) public static unsafe void Include(int value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((int*)(b + index)) = value; + } + index += 4; } @@ -46,7 +55,10 @@ public static unsafe void Include(int value, byte[] bytes, ref int index) public static unsafe void Include(uint value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((uint*)(b + index)) = value; + } + index += 4; } @@ -56,7 +68,10 @@ public static unsafe void Include(uint value, byte[] bytes, ref int index) public static unsafe void Include(long value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((long*)(b + index)) = value; + } + index += 8; } @@ -66,7 +81,10 @@ public static unsafe void Include(long value, byte[] bytes, ref int index) public static unsafe void Include(ulong value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((ulong*)(b + index)) = value; + } + index += 8; } @@ -76,7 +94,10 @@ public static unsafe void Include(ulong value, byte[] bytes, ref int index) public static unsafe void Include(float value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((float*)(b + index)) = value; + } + index += 4; } @@ -86,7 +107,10 @@ public static unsafe void Include(float value, byte[] bytes, ref int index) public static unsafe void Include(double value, byte[] bytes, ref int index) { fixed (byte* b = bytes) + { *((double*)(b + index)) = value; + } + index += 8; } @@ -103,7 +127,9 @@ public static string ReadString(bool padded, byte[] bytes, int index, int maxLen for (length = 0; length < maxLength; length++) { if (bytes[index + length] == 0) + { break; + } } } else @@ -113,4 +139,4 @@ public static string ReadString(bool padded, byte[] bytes, int index, int maxLen return Encoder.GetString(bytes, index, length); } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/MergedSerializer.cs b/src/Moryx/Serialization/MergedSerializer.cs index 52538ea3aa..d364189151 100644 --- a/src/Moryx/Serialization/MergedSerializer.cs +++ b/src/Moryx/Serialization/MergedSerializer.cs @@ -64,4 +64,4 @@ public override IBinaryRoot Deserialize(BinaryMessage message) return _serializers.Select(serializer => serializer.Deserialize(message)).FirstOrDefault(payload => payload != null); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/PossibleValues/IntegerStepsAttribute.cs b/src/Moryx/Serialization/PossibleValues/IntegerStepsAttribute.cs index e0ddd304fb..e492558a22 100644 --- a/src/Moryx/Serialization/PossibleValues/IntegerStepsAttribute.cs +++ b/src/Moryx/Serialization/PossibleValues/IntegerStepsAttribute.cs @@ -59,4 +59,4 @@ public override IEnumerable GetValues(IContainer container, IServiceProv /// public override bool UpdateFromPredecessor => false; -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/PossibleValues/PluginConfigsAttribute.cs b/src/Moryx/Serialization/PossibleValues/PluginConfigsAttribute.cs index 8c7fd6674d..34d3f2411b 100644 --- a/src/Moryx/Serialization/PossibleValues/PluginConfigsAttribute.cs +++ b/src/Moryx/Serialization/PossibleValues/PluginConfigsAttribute.cs @@ -85,11 +85,15 @@ private IEnumerable GetPossibleTypes(IContainer pluginContainer) var baseConfig = targetApi.GetGenericArguments()[0]; if (!baseConfig.IsAbstract) + { possibleValues.Add(baseConfig); + } } if (pluginContainer == null) + { return possibleValues; + } // Find better way to remove ExpectedConfigAttribute -> Tries: 3 var implementations = pluginContainer.GetRegisteredImplementations(StrategyService); @@ -97,4 +101,4 @@ private IEnumerable GetPossibleTypes(IContainer pluginContainer) .Where(attribute => attribute != null).Select(attribute => attribute.ExpectedConfigType)); return possibleValues; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/PossibleValues/PluginNameSelectorAttribute.cs b/src/Moryx/Serialization/PossibleValues/PluginNameSelectorAttribute.cs index d4ada7cb58..c17c864cfc 100644 --- a/src/Moryx/Serialization/PossibleValues/PluginNameSelectorAttribute.cs +++ b/src/Moryx/Serialization/PossibleValues/PluginNameSelectorAttribute.cs @@ -42,4 +42,4 @@ private static string GetComponentName(Type component) /// public override bool UpdateFromPredecessor => false; -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/PossibleValues/PossibleValuesContext.cs b/src/Moryx/Serialization/PossibleValues/PossibleValuesContext.cs index 268d345f87..472941656e 100644 --- a/src/Moryx/Serialization/PossibleValues/PossibleValuesContext.cs +++ b/src/Moryx/Serialization/PossibleValues/PossibleValuesContext.cs @@ -25,7 +25,7 @@ public class PossibleValuesContext(object instance, IServiceProvider provider, I /// Instance of the current class needed for the possible values. /// public object Instance { get; } = instance; - + /// /// See and . /// diff --git a/src/Moryx/Serialization/PossibleValues/RelativeDirectoriesAttribute.cs b/src/Moryx/Serialization/PossibleValues/RelativeDirectoriesAttribute.cs index 30eccfec69..cdef8a7e98 100644 --- a/src/Moryx/Serialization/PossibleValues/RelativeDirectoriesAttribute.cs +++ b/src/Moryx/Serialization/PossibleValues/RelativeDirectoriesAttribute.cs @@ -65,4 +65,4 @@ private static IEnumerable GetSubDirectories(string path) return dirs; } -} \ No newline at end of file +} diff --git a/src/Moryx/Serialization/PossibleValues/StateMachineKeysAttribute.cs b/src/Moryx/Serialization/PossibleValues/StateMachineKeysAttribute.cs index 7080d1c600..31d4d9f97c 100644 --- a/src/Moryx/Serialization/PossibleValues/StateMachineKeysAttribute.cs +++ b/src/Moryx/Serialization/PossibleValues/StateMachineKeysAttribute.cs @@ -45,4 +45,4 @@ private IEnumerable GetFields() /// public override bool UpdateFromPredecessor => false; -} \ No newline at end of file +} diff --git a/src/Moryx/StateMachines/AsyncStateBase.cs b/src/Moryx/StateMachines/AsyncStateBase.cs index 875e5f9b2c..4ddba7dd2a 100644 --- a/src/Moryx/StateMachines/AsyncStateBase.cs +++ b/src/Moryx/StateMachines/AsyncStateBase.cs @@ -75,14 +75,18 @@ internal virtual async Task ForceAsync(int state, bool exitCurrent, bool enterFo // If requested, exit current state if (exitCurrent) + { await OnExitAsync(cancellationToken); + } // Set next state await Context.SetStateAsync(nextState, cancellationToken); // If requested, enter forced state if (enterForced) + { await nextState.OnEnterAsync(cancellationToken); + } } /// @@ -92,11 +96,15 @@ internal virtual async Task ForceAsync(int state, bool exitCurrent, bool enterFo internal static async Task CreateAsync(Type stateBaseType, IAsyncStateContext context, int? initialKey, CancellationToken cancellationToken) { if (!typeof(AsyncStateBase).IsAssignableFrom(stateBaseType)) + { throw new InvalidOperationException($"Only states inherited from {nameof(AsyncStateBase)} are supported."); + } var initialState = CreateMapAndGetInitial(stateBaseType, context, initialKey) as AsyncStateBase; if (initialState == null) + { throw new ArgumentException($"Initial state does not inherit from {nameof(AsyncStateBase)}."); + } await context.SetStateAsync(initialState, cancellationToken); await initialState.OnEnterAsync(cancellationToken); diff --git a/src/Moryx/StateMachines/IStateContext.cs b/src/Moryx/StateMachines/IStateContext.cs index da59ec1526..282bdc44a0 100644 --- a/src/Moryx/StateMachines/IStateContext.cs +++ b/src/Moryx/StateMachines/IStateContext.cs @@ -12,4 +12,4 @@ public interface IStateContext /// Update state on context /// void SetState(StateBase state); -} \ No newline at end of file +} diff --git a/src/Moryx/StateMachines/StateDefinitionAttribute.cs b/src/Moryx/StateMachines/StateDefinitionAttribute.cs index e5cb234020..fb166943fa 100644 --- a/src/Moryx/StateMachines/StateDefinitionAttribute.cs +++ b/src/Moryx/StateMachines/StateDefinitionAttribute.cs @@ -27,4 +27,4 @@ public StateDefinitionAttribute(Type type) /// Defines whether the state is the initial state of the machine or not. /// public bool IsInitial { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/StateMachines/SyncStateBase.cs b/src/Moryx/StateMachines/SyncStateBase.cs index b3d4264bee..59e8e5f1a7 100644 --- a/src/Moryx/StateMachines/SyncStateBase.cs +++ b/src/Moryx/StateMachines/SyncStateBase.cs @@ -45,11 +45,15 @@ public virtual void OnExit() internal static void Create(Type stateBaseType, IStateContext context, int? initialKey) { if (!typeof(SyncStateBase).IsAssignableFrom(stateBaseType)) + { throw new InvalidOperationException($"Only states inherited from {nameof(SyncStateBase)} are supported."); + } var initialState = CreateMapAndGetInitial(stateBaseType, context, initialKey) as SyncStateBase; if (initialState == null) + { throw new ArgumentException($"Initial state does not inherit from {nameof(SyncStateBase)}."); + } context.SetState(initialState); initialState.OnEnter(); @@ -70,14 +74,18 @@ internal virtual void Force(int state, bool exitCurrent, bool enterForced) // If requested, exit current state if (exitCurrent) + { OnExit(); + } // Set next state Context.SetState(nextState); // If requested, enter forced state if (enterForced) + { nextState.OnEnter(); + } } /// diff --git a/src/Moryx/Threading/IParallelOperations.cs b/src/Moryx/Threading/IParallelOperations.cs index ffbc5ca452..709e40ab29 100644 --- a/src/Moryx/Threading/IParallelOperations.cs +++ b/src/Moryx/Threading/IParallelOperations.cs @@ -81,4 +81,4 @@ public interface IParallelOperations : IDisposable /// Target delegate that is removed as a listener /// The decoupling event listener EventHandler RemoveListener(EventHandler target); -} \ No newline at end of file +} diff --git a/src/Moryx/Threading/NonStackingTimerCallback.cs b/src/Moryx/Threading/NonStackingTimerCallback.cs index ca8f86f452..b917514a85 100644 --- a/src/Moryx/Threading/NonStackingTimerCallback.cs +++ b/src/Moryx/Threading/NonStackingTimerCallback.cs @@ -55,7 +55,10 @@ private void NonStackingCall(object state) lock (_syncLock) { if (_callbackExecuting) + { return; + } + _callbackExecuting = true; } @@ -95,4 +98,4 @@ public static TimerCallback StackProve(this TimerCallback callback) var callbackWrapper = new NonStackingTimerCallback(callback); return callbackWrapper.Callback; } -} \ No newline at end of file +} diff --git a/src/Moryx/Threading/ParallelOperations.cs b/src/Moryx/Threading/ParallelOperations.cs index c7f357c525..c864a252e9 100644 --- a/src/Moryx/Threading/ParallelOperations.cs +++ b/src/Moryx/Threading/ParallelOperations.cs @@ -158,7 +158,9 @@ public int ScheduleExecution(Action operation, T userState, int delayMs, i finally { if (periodMs <= 0) + { StopExecution(id); + } } }), userState, delayMs, periodMs); @@ -178,7 +180,10 @@ public void StopExecution(int timerId) lock (_runningTimers) { if (!_runningTimers.TryGetValue(timerId, out var timer)) + { return; + } + timer.Dispose(); _runningTimers.Remove(timerId); } @@ -212,7 +217,9 @@ private EventDecoupler CreateDecoupler(EventHandler(target, this, logger); lock (_eventDecouplers) + { _eventDecouplers.Add(target, decoupler); + } return decoupler; } @@ -240,7 +247,9 @@ private EventDecoupler RemoveDecoupler(EventHandler)_eventDecouplers[target]; _eventDecouplers.Remove(target); diff --git a/src/Moryx/Threading/ParallelOperationsQueue.cs b/src/Moryx/Threading/ParallelOperationsQueue.cs index 7f41dd96b8..6ba3f2c4d3 100644 --- a/src/Moryx/Threading/ParallelOperationsQueue.cs +++ b/src/Moryx/Threading/ParallelOperationsQueue.cs @@ -83,6 +83,8 @@ public void Enqueue(TElement element) _eventQueue.Enqueue(element); if (Interlocked.Increment(ref _pendingElements) == 1) + { ParallelOperations.ExecuteParallel(ProcessEventQueue); + } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/AppDomainBuilder.cs b/src/Moryx/Tools/AppDomainBuilder.cs index f680b362c0..567ae4c717 100644 --- a/src/Moryx/Tools/AppDomainBuilder.cs +++ b/src/Moryx/Tools/AppDomainBuilder.cs @@ -20,7 +20,9 @@ public static void LoadAssemblies() foreach (var assemblyFile in assemblies) { if (AppDomain.CurrentDomain.GetAssemblies().Any(loadedAssembly => NamesMatch(loadedAssembly, assemblyFile))) + { continue; + } try { @@ -47,4 +49,4 @@ private static bool NamesMatch(Assembly loadedAssembly, string assemblyFile) var assemblyName = loadedAssembly.GetName().Name; return assemblyName == Path.GetFileNameWithoutExtension(assemblyFile); } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/CollectionExtensions.cs b/src/Moryx/Tools/Extensions/CollectionExtensions.cs index dc3ab2d879..8bb52a08ed 100644 --- a/src/Moryx/Tools/Extensions/CollectionExtensions.cs +++ b/src/Moryx/Tools/Extensions/CollectionExtensions.cs @@ -14,7 +14,9 @@ public static class CollectionExtensions public static void AddRange(this ICollection source, IEnumerable items) where TSource : class { foreach (var item in items) + { source.Add(item); + } } /// @@ -24,11 +26,15 @@ public static void ReplaceItem(this IList list, Func(ICollection collection) where TSource : class @@ -40,7 +46,9 @@ public void RemoveRange(IEnumerable items) { var itemsArray = new List(items).ToArray(); for (var i = itemsArray.Length - 1; i >= 0; i--) + { collection.Remove(itemsArray[i]); + } } /// @@ -49,7 +57,9 @@ public void RemoveRange(IEnumerable items) public void AddIfNotExists(TSource item) { if (!collection.Contains(item)) + { collection.Add(item); + } } } @@ -63,7 +73,9 @@ public void RemoveBy(Func condition) for (var i = collection.Count - 1; i >= 0; i--) { if (condition(collection[i])) + { collection.RemoveAt(i); + } } } @@ -85,4 +97,4 @@ public void Shuffle() } } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/CustomAttributeProviderExtensions.cs b/src/Moryx/Tools/Extensions/CustomAttributeProviderExtensions.cs index a5000c4ac8..dd0e1f7b5b 100644 --- a/src/Moryx/Tools/Extensions/CustomAttributeProviderExtensions.cs +++ b/src/Moryx/Tools/Extensions/CustomAttributeProviderExtensions.cs @@ -68,7 +68,9 @@ public string GetDisplayName() var name = attributeProvider.GetCustomAttribute(false)?.GetName(); if (string.IsNullOrEmpty(name)) + { name = attributeProvider.GetCustomAttribute(false)?.DisplayName; + } return name; } @@ -84,9 +86,11 @@ public string GetDescription() var description = attributeProvider.GetCustomAttribute(false)?.GetDescription(); if (string.IsNullOrEmpty(description)) + { description = attributeProvider.GetCustomAttribute(false)?.Description; + } return description; } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/DateTimeExtensions.cs b/src/Moryx/Tools/Extensions/DateTimeExtensions.cs index ef43855a58..0d35c8d9af 100644 --- a/src/Moryx/Tools/Extensions/DateTimeExtensions.cs +++ b/src/Moryx/Tools/Extensions/DateTimeExtensions.cs @@ -126,4 +126,4 @@ public static int GetNumberOfCalendarWeeksForYear(int year) { return new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Thursday | (DateTime.IsLeapYear(year) & new DateTime(year, 1, 1).DayOfWeek == DayOfWeek.Wednesday) ? 53 : 52; } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/DictionaryExtensions.cs b/src/Moryx/Tools/Extensions/DictionaryExtensions.cs index 16f077cc00..a3c3eff408 100644 --- a/src/Moryx/Tools/Extensions/DictionaryExtensions.cs +++ b/src/Moryx/Tools/Extensions/DictionaryExtensions.cs @@ -18,4 +18,4 @@ public static bool ContainsKeys(this IDictionary dictionary, par { return dictionary.Any(entry => keys.Contains(entry.Key)); } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/EditableObjectExtensions.cs b/src/Moryx/Tools/Extensions/EditableObjectExtensions.cs index 72672e15ef..51984f42cc 100644 --- a/src/Moryx/Tools/Extensions/EditableObjectExtensions.cs +++ b/src/Moryx/Tools/Extensions/EditableObjectExtensions.cs @@ -20,7 +20,9 @@ public static class EditableObjectExtensions public void BeginEdit() { foreach (var editableObject in editableObjects) + { editableObject.BeginEdit(); + } } /// @@ -29,7 +31,9 @@ public void BeginEdit() public void CancelEdit() { foreach (var editableObject in editableObjects) + { editableObject.CancelEdit(); + } } /// @@ -38,7 +42,9 @@ public void CancelEdit() public void EndEdit() { foreach (var editableObject in editableObjects) + { editableObject.EndEdit(); + } } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/EnumerableExtensions.cs b/src/Moryx/Tools/Extensions/EnumerableExtensions.cs index 0051d2209d..dded90d204 100644 --- a/src/Moryx/Tools/Extensions/EnumerableExtensions.cs +++ b/src/Moryx/Tools/Extensions/EnumerableExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Collections.ObjectModel; -using Moryx.Serialization; namespace Moryx.Tools; @@ -56,4 +55,4 @@ public IEnumerable Intersect(ICollection compare, Func compare.Any(item => filter(entry, item))); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/Extensions/StringExtensions.cs b/src/Moryx/Tools/Extensions/StringExtensions.cs index 3fc0030338..397adbb935 100644 --- a/src/Moryx/Tools/Extensions/StringExtensions.cs +++ b/src/Moryx/Tools/Extensions/StringExtensions.cs @@ -26,7 +26,9 @@ public string ConvertToValidFileSystemName(string replacement = "") //Aggregate invalid with the replacement var result = str; foreach (var c in invalid) + { result = result.Replace(c.ToString(CultureInfo.InvariantCulture), replacement); + } return result.Replace(" ", "_"); } @@ -77,22 +79,30 @@ public bool IsAlphaNumeric() public string Reduce(int count, string endings) { if (count < endings.Length) + { throw new Exception("Failed to reduce to less then endings length."); + } int sLength = str.Length; int len = sLength; if (endings != null) + { len += endings.Length; + } if (count > sLength) + { return str; //it's too short to reduce + } str = str.Substring(0, sLength - len + count); if (endings != null) + { str += endings; + } return str; } } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/IPropertyAccessor.cs b/src/Moryx/Tools/IPropertyAccessor.cs index 78572667e3..629d630efb 100644 --- a/src/Moryx/Tools/IPropertyAccessor.cs +++ b/src/Moryx/Tools/IPropertyAccessor.cs @@ -29,4 +29,4 @@ public interface IPropertyAccessor /// Write the property on the instance /// void WriteProperty(TBase instance, TValue value); -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/ReferenceGroup.cs b/src/Moryx/Tools/ReferenceGroup.cs index c2c93e2137..90b61c6f7d 100644 --- a/src/Moryx/Tools/ReferenceGroup.cs +++ b/src/Moryx/Tools/ReferenceGroup.cs @@ -42,4 +42,4 @@ IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Tools/ReflectionTool.cs b/src/Moryx/Tools/ReflectionTool.cs index 09fec28b8c..e3602e7ab0 100644 --- a/src/Moryx/Tools/ReflectionTool.cs +++ b/src/Moryx/Tools/ReflectionTool.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.Linq.Expressions; using System.Reflection; -using Microsoft.Extensions.Logging; namespace Moryx.Tools; @@ -28,11 +27,11 @@ private static Assembly[] LoadAssemblies() // Fetch location of binaries from our assembly var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).ToLower(); var relevantAssemblies = (from assembly in AppDomain.CurrentDomain.GetAssemblies() - // Only load non-dynamic assemblies from our directory - where !assembly.IsDynamic && !string.IsNullOrEmpty(assembly.Location) - let path = Path.GetDirectoryName(assembly.Location).ToLower() - where TestMode || path == currentDir - select assembly).ToArray(); + // Only load non-dynamic assemblies from our directory + where !assembly.IsDynamic && !string.IsNullOrEmpty(assembly.Location) + let path = Path.GetDirectoryName(assembly.Location).ToLower() + where TestMode || path == currentDir + select assembly).ToArray(); return relevantAssemblies; } @@ -103,8 +102,8 @@ public static Type[] GetPublicClasses(Type baseType) public static Type[] GetPublicClasses(Type baseType, Predicate filter) { return (from publicClass in _publicClasses.Value - where baseType.IsAssignableFrom(publicClass) && filter(publicClass) - select publicClass).ToArray(); + where baseType.IsAssignableFrom(publicClass) && filter(publicClass) + select publicClass).ToArray(); } /// @@ -178,19 +177,25 @@ public static IPropertyAccessor PropertyAccessor(P Type accessorType; if (property.DeclaringType == typeof(TBase) && typeof(TValue) == property.PropertyType) + { accessorType = typeof(DirectAccessor<,>).MakeGenericType(typeof(TBase), typeof(TValue)); - + } else if (typeof(TBase).IsAssignableFrom(property.DeclaringType) && typeof(TValue) == property.PropertyType) + { accessorType = typeof(InstanceCastAccessor<,,>).MakeGenericType(property.DeclaringType, typeof(TBase), typeof(TValue)); - + } else if (typeof(TBase).IsAssignableFrom(property.DeclaringType) && typeof(TValue).IsAssignableFrom(property.PropertyType) && typeof(TValue) != typeof(object)) + { accessorType = typeof(ValueCastAccessor<,,,>).MakeGenericType(property.DeclaringType, typeof(TBase), property.PropertyType, typeof(TValue)); - + } else if (typeof(TBase).IsAssignableFrom(property.DeclaringType) && property.PropertyType.IsAssignableFrom(typeof(TValue)) && typeof(TValue) != typeof(object)) + { accessorType = typeof(PropertyCastAccessor<,,,>).MakeGenericType(property.DeclaringType, typeof(TBase), property.PropertyType, typeof(TValue)); - + } else + { accessorType = typeof(ConversionAccessor<,,,>).MakeGenericType(property.DeclaringType, typeof(TBase), property.PropertyType, typeof(TValue)); + } return (IPropertyAccessor)Activator.CreateInstance(accessorType, property); } @@ -231,8 +236,7 @@ public static IEnumerable> GetReferences @@ -252,17 +256,21 @@ public static bool IsExplicitInterfaceImplementation(MethodInfo methodInfo) // Only look at declaring types if (mapping.TargetType != declaringType) + { continue; + } for (var index = 0; index < mapping.TargetMethods.Length; index++) { // If mapped method and interface method name do not match, it is explicit if (mapping.TargetMethods[index] == methodInfo && mapping.InterfaceMethods[index]?.Name.Equals(methodInfo.Name, StringComparison.Ordinal) == false) + { return true; + } } } return false; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/IAttemptInvocation.cs b/src/Moryx/Workplans/API/IAttemptInvocation.cs index 7e92c3a076..53de51bf6d 100644 --- a/src/Moryx/Workplans/API/IAttemptInvocation.cs +++ b/src/Moryx/Workplans/API/IAttemptInvocation.cs @@ -13,4 +13,4 @@ public interface IAttemptInvocation /// the target and returns true, otherwise it returns false. /// bool TryInvoke(ITransition transition); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/IIndexResolver.cs b/src/Moryx/Workplans/API/IIndexResolver.cs index 1b9fcd8585..799b071cc0 100644 --- a/src/Moryx/Workplans/API/IIndexResolver.cs +++ b/src/Moryx/Workplans/API/IIndexResolver.cs @@ -12,4 +12,4 @@ public interface IIndexResolver /// Resolve index by mapping value /// int Resolve(long mappingValue); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/IPathPredictor.cs b/src/Moryx/Workplans/API/IPathPredictor.cs index f4ba551df9..52b92d1c4e 100644 --- a/src/Moryx/Workplans/API/IPathPredictor.cs +++ b/src/Moryx/Workplans/API/IPathPredictor.cs @@ -71,4 +71,4 @@ public PathPredictionEventArgs(IWorkplanEngine engineInstance, NodeClassificatio /// absolute certainty about the result. /// public double Probability { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/ITransitionMapper.cs b/src/Moryx/Workplans/API/ITransitionMapper.cs index 2c2c7dfdbb..788e77b122 100644 --- a/src/Moryx/Workplans/API/ITransitionMapper.cs +++ b/src/Moryx/Workplans/API/ITransitionMapper.cs @@ -24,4 +24,4 @@ public interface ITransitionMapper : IDisposable /// ITransitionMapper Map(Action transitionHandler) where T : class, ITransition; -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/IWorkplanEngine.cs b/src/Moryx/Workplans/API/IWorkplanEngine.cs index 3a72bdbb13..e8f9d1aa82 100644 --- a/src/Moryx/Workplans/API/IWorkplanEngine.cs +++ b/src/Moryx/Workplans/API/IWorkplanEngine.cs @@ -55,4 +55,4 @@ public interface IMonitoredEngine : IWorkplanEngine /// /// event EventHandler PlaceReached; -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/IWorkplans.cs b/src/Moryx/Workplans/API/IWorkplans.cs index c8189d6684..859b02342a 100644 --- a/src/Moryx/Workplans/API/IWorkplans.cs +++ b/src/Moryx/Workplans/API/IWorkplans.cs @@ -43,4 +43,4 @@ public interface IWorkplans /// Workplan id /// The token to monitor for cancellation requests. The default value is None. Task> LoadVersionsAsync(long workplanId, CancellationToken cancellationToken = default); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Instance/IPlace.cs b/src/Moryx/Workplans/API/Instance/IPlace.cs index 43765aefad..58a3e28eb3 100644 --- a/src/Moryx/Workplans/API/Instance/IPlace.cs +++ b/src/Moryx/Workplans/API/Instance/IPlace.cs @@ -32,4 +32,4 @@ public interface IPlace : ITokenHolder /// Event raised, when a token was removed /// event EventHandler TokenRemoved; -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Instance/IToken.cs b/src/Moryx/Workplans/API/Instance/IToken.cs index 71e7c15acb..b465ef92c3 100644 --- a/src/Moryx/Workplans/API/Instance/IToken.cs +++ b/src/Moryx/Workplans/API/Instance/IToken.cs @@ -12,4 +12,4 @@ public interface IToken /// Token name /// string Name { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Instance/ITokenHolder.cs b/src/Moryx/Workplans/API/Instance/ITokenHolder.cs index 61837f1d64..172ea8d9eb 100644 --- a/src/Moryx/Workplans/API/Instance/ITokenHolder.cs +++ b/src/Moryx/Workplans/API/Instance/ITokenHolder.cs @@ -33,4 +33,4 @@ public interface ITokenHolder /// Resume execution on this holder and process placed tokens /// void Resume(); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Instance/ITransition.cs b/src/Moryx/Workplans/API/Instance/ITransition.cs index ee2a452881..d048556fca 100644 --- a/src/Moryx/Workplans/API/Instance/ITransition.cs +++ b/src/Moryx/Workplans/API/Instance/ITransition.cs @@ -39,4 +39,4 @@ public interface IObservableTransition : ITransition /// Event raised, when the transition was triggered /// event EventHandler Triggered; -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Instance/IWorkplanInstance.cs b/src/Moryx/Workplans/API/Instance/IWorkplanInstance.cs index 8556d40aa1..5331204d55 100644 --- a/src/Moryx/Workplans/API/Instance/IWorkplanInstance.cs +++ b/src/Moryx/Workplans/API/Instance/IWorkplanInstance.cs @@ -22,4 +22,4 @@ public interface IWorkplanInstance /// All transitions of the . See also . /// IReadOnlyList Transitions { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/NodeClassification.cs b/src/Moryx/Workplans/API/NodeClassification.cs index 65ebcfef89..e637340924 100644 --- a/src/Moryx/Workplans/API/NodeClassification.cs +++ b/src/Moryx/Workplans/API/NodeClassification.cs @@ -49,4 +49,4 @@ public enum NodeClassification /// Reset and abort point for a normal workplan if an unrecoverable failure occurred. /// Failed = Exit | Failure -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/IConnector.cs b/src/Moryx/Workplans/API/Type/IConnector.cs index 2ee8394758..dfcfce6e49 100644 --- a/src/Moryx/Workplans/API/Type/IConnector.cs +++ b/src/Moryx/Workplans/API/Type/IConnector.cs @@ -17,4 +17,4 @@ public interface IConnector : IWorkplanNode /// Create a place instance /// IPlace CreateInstance(); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/ISubworkplanStep.cs b/src/Moryx/Workplans/API/Type/ISubworkplanStep.cs index 0d9e8e2cc4..ce8dd0d7c4 100644 --- a/src/Moryx/Workplans/API/Type/ISubworkplanStep.cs +++ b/src/Moryx/Workplans/API/Type/ISubworkplanStep.cs @@ -17,4 +17,4 @@ public interface ISubworkplanStep : IWorkplanStep /// Subworkplan referenced in this step /// IWorkplan Workplan { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/IWorkplan.cs b/src/Moryx/Workplans/API/Type/IWorkplan.cs index ed458a7aa2..04da3da167 100644 --- a/src/Moryx/Workplans/API/Type/IWorkplan.cs +++ b/src/Moryx/Workplans/API/Type/IWorkplan.cs @@ -37,4 +37,4 @@ public interface IWorkplan /// All steps of this workplan /// IEnumerable Steps { get; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/IWorkplanContext.cs b/src/Moryx/Workplans/API/Type/IWorkplanContext.cs index 3b9675a21c..93f61400ff 100644 --- a/src/Moryx/Workplans/API/Type/IWorkplanContext.cs +++ b/src/Moryx/Workplans/API/Type/IWorkplanContext.cs @@ -12,4 +12,4 @@ public interface IWorkplanContext /// Check if a step was disabled /// bool IsDisabled(IWorkplanStep step); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/IWorkplanNode.cs b/src/Moryx/Workplans/API/Type/IWorkplanNode.cs index c3c59eef1c..f9545cd40c 100644 --- a/src/Moryx/Workplans/API/Type/IWorkplanNode.cs +++ b/src/Moryx/Workplans/API/Type/IWorkplanNode.cs @@ -24,4 +24,4 @@ public interface IWorkplanNode /// Position of this in any visualization of the /// Point Position { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/IWorkplanStep.cs b/src/Moryx/Workplans/API/Type/IWorkplanStep.cs index 3099a7ccec..d5c4b770c8 100644 --- a/src/Moryx/Workplans/API/Type/IWorkplanStep.cs +++ b/src/Moryx/Workplans/API/Type/IWorkplanStep.cs @@ -27,4 +27,4 @@ public interface IWorkplanStep : IWorkplanNode /// Create transistion instance /// ITransition CreateInstance(IWorkplanContext context); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/Type/WorkplanState.cs b/src/Moryx/Workplans/API/Type/WorkplanState.cs index 0c7af7b64a..2dfbfe4279 100644 --- a/src/Moryx/Workplans/API/Type/WorkplanState.cs +++ b/src/Moryx/Workplans/API/Type/WorkplanState.cs @@ -22,4 +22,4 @@ public enum WorkplanState /// The workplan is revoked and must not be used anymore. /// Revoked = 2 -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/API/WorkplanSnapshot.cs b/src/Moryx/Workplans/API/WorkplanSnapshot.cs index 43be8113cb..a7d85f6913 100644 --- a/src/Moryx/Workplans/API/WorkplanSnapshot.cs +++ b/src/Moryx/Workplans/API/WorkplanSnapshot.cs @@ -38,4 +38,4 @@ public class WorkplanSnapshot /// All tokens and their position /// public HolderSnapshot[] Holders { get; set; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Connector.cs b/src/Moryx/Workplans/Implementation/Connector.cs index c250849fa7..39e10c8f90 100644 --- a/src/Moryx/Workplans/Implementation/Connector.cs +++ b/src/Moryx/Workplans/Implementation/Connector.cs @@ -37,4 +37,4 @@ public virtual IPlace CreateInstance() Classification = Classification }; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/EngineState.cs b/src/Moryx/Workplans/Implementation/Engine/EngineState.cs index 107b0ab873..987c04d241 100644 --- a/src/Moryx/Workplans/Implementation/Engine/EngineState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/EngineState.cs @@ -83,4 +83,4 @@ protected void ExecuteDestroy() [StateDefinition(typeof(PausedState))] protected const int StatePaused = 30; -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/IdleState.cs b/src/Moryx/Workplans/Implementation/Engine/IdleState.cs index c2770eda00..ff65957f08 100644 --- a/src/Moryx/Workplans/Implementation/Engine/IdleState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/IdleState.cs @@ -22,4 +22,4 @@ internal override void Destroy() { Context.ExecuteDispose(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/PausedState.cs b/src/Moryx/Workplans/Implementation/Engine/PausedState.cs index 89507a65a1..3b51c0670f 100644 --- a/src/Moryx/Workplans/Implementation/Engine/PausedState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/PausedState.cs @@ -20,7 +20,9 @@ internal override WorkplanSnapshot Pause() internal override void Restore(WorkplanSnapshot snapshot) { if (snapshot != Context.CurrentSnapshot) + { throw new InvalidOperationException("Can not restore paused engine with different snapshot. Create a new instance instead."); + } } internal override void Start() diff --git a/src/Moryx/Workplans/Implementation/Engine/ReadyState.cs b/src/Moryx/Workplans/Implementation/Engine/ReadyState.cs index ea2a2e5782..34dc763eae 100644 --- a/src/Moryx/Workplans/Implementation/Engine/ReadyState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/ReadyState.cs @@ -31,4 +31,4 @@ internal override void Destroy() { ExecuteDestroy(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/RestoredState.cs b/src/Moryx/Workplans/Implementation/Engine/RestoredState.cs index 96b8baddde..6a131791ef 100644 --- a/src/Moryx/Workplans/Implementation/Engine/RestoredState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/RestoredState.cs @@ -30,4 +30,4 @@ internal override void Destroy() { ExecuteDestroy(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/RunningState.cs b/src/Moryx/Workplans/Implementation/Engine/RunningState.cs index faa0be1428..8dd62dcf26 100644 --- a/src/Moryx/Workplans/Implementation/Engine/RunningState.cs +++ b/src/Moryx/Workplans/Implementation/Engine/RunningState.cs @@ -26,4 +26,4 @@ internal override void Destroy() Context.ExecutePause(); ExecuteDestroy(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Engine/WorkplanEngine.cs b/src/Moryx/Workplans/Implementation/Engine/WorkplanEngine.cs index a63e1d7a71..1f0222d298 100644 --- a/src/Moryx/Workplans/Implementation/Engine/WorkplanEngine.cs +++ b/src/Moryx/Workplans/Implementation/Engine/WorkplanEngine.cs @@ -44,7 +44,9 @@ internal void ExecuteInitialize(IWorkplanInstance workplanInstance) { transition.Initialize(); if (transition is IObservableTransition) + { ((IObservableTransition)transition).Triggered += OnTransitionTriggered; + } } // Register to events of exit places foreach (var place in ExecutedWorkplan.Places) @@ -126,14 +128,14 @@ internal void ExecutePause() // Extract snapshot from holders snapShot.Holders = (from holder in GetAllHolders() - let tokens = holder.Tokens.ToArray() - where tokens.Length > 0 - select new HolderSnapshot - { - HolderId = holder.Id, - Tokens = tokens, - HolderState = holder.InternalState - }).ToArray(); + let tokens = holder.Tokens.ToArray() + where tokens.Length > 0 + select new HolderSnapshot + { + HolderId = holder.Id, + Tokens = tokens, + HolderState = holder.InternalState + }).ToArray(); CurrentSnapshot = snapShot; } @@ -204,4 +206,4 @@ internal void ExecuteDispose() } ExecutedWorkplan = null; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/MainToken.cs b/src/Moryx/Workplans/Implementation/MainToken.cs index b8e6b35986..7b5c259ed4 100644 --- a/src/Moryx/Workplans/Implementation/MainToken.cs +++ b/src/Moryx/Workplans/Implementation/MainToken.cs @@ -12,4 +12,4 @@ internal class MainToken : IToken /// Token name /// public string Name => nameof(MainToken); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/NullContext.cs b/src/Moryx/Workplans/Implementation/NullContext.cs index 1013093dfb..8edbb03855 100644 --- a/src/Moryx/Workplans/Implementation/NullContext.cs +++ b/src/Moryx/Workplans/Implementation/NullContext.cs @@ -13,4 +13,4 @@ public bool IsDisabled(IWorkplanStep step) { return false; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/PathPredictor.cs b/src/Moryx/Workplans/Implementation/PathPredictor.cs index 7fd97ff152..2aee5e54f0 100644 --- a/src/Moryx/Workplans/Implementation/PathPredictor.cs +++ b/src/Moryx/Workplans/Implementation/PathPredictor.cs @@ -73,7 +73,9 @@ private void Analyze(IWorkplanNode currentNode, IConnector resultNode, IDictiona { // Continue recursively foreach (var input in reversedRelations[currentNode.Id]) + { Analyze(input, resultNode, reversedRelations); + } } } @@ -98,7 +100,9 @@ public bool Remove(IWorkplanEngine instance) var wasMonitored = _monitoredEngines.Remove(monitoredEngine); if (wasMonitored) + { UnregisterEvents(monitoredEngine); + } return wasMonitored; } @@ -140,7 +144,9 @@ public void Dispose() lock (_monitoredEngines) { foreach (var engine in _monitoredEngines) + { UnregisterEvents(engine); + } _monitoredEngines.Clear(); } @@ -198,9 +204,11 @@ public NodeClassification AggregatedClassification public bool AddResult(IConnector result) { if (_results.Contains(result)) + { return false; + } _results.Add(result); return true; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Place.cs b/src/Moryx/Workplans/Implementation/Place.cs index 0d09a1ac68..5cdb8701fc 100644 --- a/src/Moryx/Workplans/Implementation/Place.cs +++ b/src/Moryx/Workplans/Implementation/Place.cs @@ -62,7 +62,9 @@ public virtual void Add(IToken token) { _tokens.Add(token); if (_running) + { TokenAdded(this, token); + } } /// @@ -72,7 +74,9 @@ public virtual void Add(IToken token) public virtual void Remove(IToken token) { if (_tokens.Remove(token)) + { TokenRemoved?.Invoke(this, token); + } } /// @@ -83,4 +87,4 @@ public virtual void Remove(IToken token) #endregion -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/SimpleWorkplanInstance.cs b/src/Moryx/Workplans/Implementation/SimpleWorkplanInstance.cs index 3af9e3e42f..79e0edd2c6 100644 --- a/src/Moryx/Workplans/Implementation/SimpleWorkplanInstance.cs +++ b/src/Moryx/Workplans/Implementation/SimpleWorkplanInstance.cs @@ -48,4 +48,4 @@ public ITransition GetTransition(long id) return workplanInstance.Transitions.First(t => t.Id == id); } } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/SplitToken.cs b/src/Moryx/Workplans/Implementation/SplitToken.cs index 29fb8d582f..b2ce91dff6 100644 --- a/src/Moryx/Workplans/Implementation/SplitToken.cs +++ b/src/Moryx/Workplans/Implementation/SplitToken.cs @@ -17,4 +17,4 @@ public SplitToken(IToken original) { Original = original; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/TransitionMapper.cs b/src/Moryx/Workplans/Implementation/TransitionMapper.cs index 57fd8f1c93..64af44a7ab 100644 --- a/src/Moryx/Workplans/Implementation/TransitionMapper.cs +++ b/src/Moryx/Workplans/Implementation/TransitionMapper.cs @@ -43,7 +43,9 @@ public void TransitionTriggered(object sender, ITransition transition) foreach (var invocation in _delegateMaps) { if (invocation.TryInvoke(transition)) + { break; + } } } @@ -63,9 +65,13 @@ public ITransitionMapper Map(Action transitionHandler) where T : class, ITransition { if (_parallelOperations == null) + { Map(new AttemptInvocation(transitionHandler)); + } else + { Map(new AsyncAttemptInvocation(_parallelOperations, transitionHandler)); + } return this; } @@ -87,7 +93,9 @@ public bool TryInvoke(ITransition transition) { var casted = transition as T; if (casted == null) + { return false; + } _callback(casted); return true; @@ -112,7 +120,9 @@ public AsyncAttemptInvocation(IParallelOperations parallelOperations, Action public bool TryInvoke(ITransition transition) { if (!(transition is T casted)) + { return false; + } _parallelOperations.ExecuteParallel(_callback, casted); return true; @@ -126,4 +136,4 @@ public void Dispose() { _delegateMaps.Clear(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/Workplan.cs b/src/Moryx/Workplans/Implementation/Workplan.cs index 1ef9e39fac..c77ebf1031 100644 --- a/src/Moryx/Workplans/Implementation/Workplan.cs +++ b/src/Moryx/Workplans/Implementation/Workplan.cs @@ -71,9 +71,13 @@ public void Add(params IWorkplanNode[] nodes) { node.Id = ++MaxElementId; if (node is IConnector) + { _connectors.Add((IConnector)node); + } else + { _steps.Add((IWorkplanStep)node); + } } } /// @@ -91,4 +95,4 @@ public static Workplan Restore(List connectors, List { return new Workplan(connectors, steps); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Implementation/WorkplanExtensions.cs b/src/Moryx/Workplans/Implementation/WorkplanExtensions.cs index 7ca4f20200..8d74ffcafd 100644 --- a/src/Moryx/Workplans/Implementation/WorkplanExtensions.cs +++ b/src/Moryx/Workplans/Implementation/WorkplanExtensions.cs @@ -19,7 +19,9 @@ public IReadOnlyList ExtractPath() { var startConnector = workplan.Connectors.FirstOrDefault(c => c.Classification == NodeClassification.Start); if (startConnector == null) + { throw new ArgumentException("The workplan does not have any start connector."); + } return ExtractPath(workplan, startConnector, startConnector); } @@ -33,7 +35,9 @@ public IReadOnlyList ExtractPath(IConnector startConnector) { var endConnector = workplan.Connectors.FirstOrDefault(c => c.Classification == NodeClassification.End); if (endConnector == null) + { throw new ArgumentException("The workplan does not have any end connector."); + } return ExtractPath(workplan, startConnector, endConnector); } @@ -47,10 +51,14 @@ public IReadOnlyList ExtractPath(IConnector startConnector) public IReadOnlyList ExtractPath(IConnector startConnector, IConnector endConnector) { if (!workplan.Connectors.Contains(startConnector)) + { throw new ArgumentException("The start connector is not part of the workplan."); + } if (!workplan.Connectors.Contains(endConnector)) + { throw new ArgumentException("The end connector is not part of the workplan."); + } var path = new List(); @@ -62,7 +70,9 @@ public IReadOnlyList ExtractPath(IConnector startConnector, IConn var output = step.Outputs[0]; if (output == endConnector) + { break; + } currentConnector = output; } diff --git a/src/Moryx/Workplans/Implementation/WorkplanInstanceFactory.cs b/src/Moryx/Workplans/Implementation/WorkplanInstanceFactory.cs index 5ca21df7d9..dfaa590591 100644 --- a/src/Moryx/Workplans/Implementation/WorkplanInstanceFactory.cs +++ b/src/Moryx/Workplans/Implementation/WorkplanInstanceFactory.cs @@ -39,7 +39,9 @@ private static IPlace GetPlace(IConnector connector, IDictionary c { IPlace instance; if (cache.TryGetValue(connector.Id, out var connectorsPlace)) + { instance = connectorsPlace; + } else { instance = connector.CreateInstance(); diff --git a/src/Moryx/Workplans/Transitions/JoinTransition.cs b/src/Moryx/Workplans/Transitions/JoinTransition.cs index aa5f6c8147..b58ff5bcf8 100644 --- a/src/Moryx/Workplans/Transitions/JoinTransition.cs +++ b/src/Moryx/Workplans/Transitions/JoinTransition.cs @@ -14,7 +14,9 @@ internal sealed class JoinTransition : TransitionBase protected override void InputTokenAdded(object sender, IToken token) { lock (this) + { Executing(() => EvaluateTokens(sender, token)); + } } /// @@ -33,7 +35,9 @@ private void EvaluateTokens(object sender, IToken token) for (var i = 0; i < length; i++) { if (Inputs[i].Equals(sender)) + { _receivedTokens[i] = token; + } var splitToken = _receivedTokens[i] as SplitToken; if (splitToken == null) @@ -48,7 +52,9 @@ private void EvaluateTokens(object sender, IToken token) } if (allSet) + { TriggerTransition(original); + } } /// @@ -64,4 +70,4 @@ private void TriggerTransition(IToken original) Outputs[0].Add(original); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Transitions/NullTransition.cs b/src/Moryx/Workplans/Transitions/NullTransition.cs index d9fa996146..50d73a16c7 100644 --- a/src/Moryx/Workplans/Transitions/NullTransition.cs +++ b/src/Moryx/Workplans/Transitions/NullTransition.cs @@ -36,4 +36,4 @@ protected override void InputTokenAdded(object sender, IToken token) MoveToken((IPlace)sender, Outputs[_index], token); }); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Transitions/SplitTransition.cs b/src/Moryx/Workplans/Transitions/SplitTransition.cs index 2bc95733e4..828a17dc9e 100644 --- a/src/Moryx/Workplans/Transitions/SplitTransition.cs +++ b/src/Moryx/Workplans/Transitions/SplitTransition.cs @@ -20,4 +20,4 @@ protected override void InputTokenAdded(object sender, IToken token) } }); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Transitions/TransitionBase.cs b/src/Moryx/Workplans/Transitions/TransitionBase.cs index 2b99a1c50d..dd92cb2041 100644 --- a/src/Moryx/Workplans/Transitions/TransitionBase.cs +++ b/src/Moryx/Workplans/Transitions/TransitionBase.cs @@ -175,7 +175,9 @@ public int Resolve(long mappingValue) for (var i = 0; i < _descriptions.Length; i++) { if (_descriptions[i].MappingValue == mappingValue) + { return i; + } } throw new ArgumentOutOfRangeException(nameof(mappingValue)); } @@ -203,4 +205,4 @@ public override object InternalState get => State; set => State = (TInternalState)value; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Validation/DeadEndValidator.cs b/src/Moryx/Workplans/Validation/DeadEndValidator.cs index fd5ace4b6d..bace9852ca 100644 --- a/src/Moryx/Workplans/Validation/DeadEndValidator.cs +++ b/src/Moryx/Workplans/Validation/DeadEndValidator.cs @@ -21,15 +21,21 @@ public bool Validate(IWorkplan workplan, ICollection errors) { // Find a step using the connector as input if (workplan.Steps.Any(step => step.Inputs.Contains(connector))) + { continue; + } // or if it is the end connector if (connector.Classification.HasFlag(NodeClassification.Exit)) + { continue; + } // or if it is not used as an output anywhere and is not a start connector if (!workplan.Steps.Any(step => step.Outputs.Contains(connector)) && !connector.Classification.HasFlag(NodeClassification.Entry)) + { continue; + } errors.Add(new DeadEndValidationError(connector.Id)); } diff --git a/src/Moryx/Workplans/Validation/IWorkplanValidator.cs b/src/Moryx/Workplans/Validation/IWorkplanValidator.cs index f65133d857..4a91ab5310 100644 --- a/src/Moryx/Workplans/Validation/IWorkplanValidator.cs +++ b/src/Moryx/Workplans/Validation/IWorkplanValidator.cs @@ -17,4 +17,4 @@ internal interface IWorkplanValidator /// Validate the given workplan /// bool Validate(IWorkplan workplan, ICollection errors); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Validation/LoneWolfValidator.cs b/src/Moryx/Workplans/Validation/LoneWolfValidator.cs index d7695e6736..7ed5e02940 100644 --- a/src/Moryx/Workplans/Validation/LoneWolfValidator.cs +++ b/src/Moryx/Workplans/Validation/LoneWolfValidator.cs @@ -22,11 +22,15 @@ public bool Validate(IWorkplan workplan, ICollection errors) { // Check if the step has inputs that a are used somewhere else as outputs if (step.Inputs.Length > 0 && step.Inputs.All(input => workplan.Steps.Any(otherStep => otherStep.Outputs.Contains(input)))) + { continue; + } // If we are linked to the start place we can skip too if (step.Inputs.Any(input => input.Classification.HasFlag(NodeClassification.Entry))) + { continue; + } errors.Add(new LoneWolfValidationError(step.Id)); } diff --git a/src/Moryx/Workplans/Validation/ValidationAspect.cs b/src/Moryx/Workplans/Validation/ValidationAspect.cs index 097fe46226..189962d64e 100644 --- a/src/Moryx/Workplans/Validation/ValidationAspect.cs +++ b/src/Moryx/Workplans/Validation/ValidationAspect.cs @@ -28,4 +28,4 @@ public enum ValidationAspect /// Find any steps that is not linked to any other step and is unreachable /// LoneWolf = 8 -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Validation/ValidationResult.cs b/src/Moryx/Workplans/Validation/ValidationResult.cs index 7cd5021d07..e8f357b2e4 100644 --- a/src/Moryx/Workplans/Validation/ValidationResult.cs +++ b/src/Moryx/Workplans/Validation/ValidationResult.cs @@ -42,4 +42,4 @@ protected ValidationError(long positionId) /// Print error in readable format /// public abstract string Print(IWorkplan workplan); -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/Validation/WorkplanValidation.cs b/src/Moryx/Workplans/Validation/WorkplanValidation.cs index 62501c2d01..4f0d3a856f 100644 --- a/src/Moryx/Workplans/Validation/WorkplanValidation.cs +++ b/src/Moryx/Workplans/Validation/WorkplanValidation.cs @@ -33,7 +33,9 @@ public static ValidationResult Validate(IWorkplan workplan, ValidationAspect asp foreach (var validator in Validators) { if (aspects.HasFlag(validator.TargetAspect)) + { valid &= validator.Validate(workplan, errors); + } } return new ValidationResult @@ -42,4 +44,4 @@ public static ValidationResult Validate(IWorkplan workplan, ValidationAspect asp Errors = errors.ToArray() }; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/WorkplanInstance.cs b/src/Moryx/Workplans/WorkplanInstance.cs index e2d358898f..0f98f6b319 100644 --- a/src/Moryx/Workplans/WorkplanInstance.cs +++ b/src/Moryx/Workplans/WorkplanInstance.cs @@ -98,4 +98,4 @@ public static ValidationResult Validate(IWorkplan workplan, ValidationAspect asp { return WorkplanValidation.Validate(workplan, aspects); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/WorkplanSteps/JoinWorkplanStep.cs b/src/Moryx/Workplans/WorkplanSteps/JoinWorkplanStep.cs index e4fa7e11a9..2707851953 100644 --- a/src/Moryx/Workplans/WorkplanSteps/JoinWorkplanStep.cs +++ b/src/Moryx/Workplans/WorkplanSteps/JoinWorkplanStep.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Runtime.Serialization; -using Moryx.Workplans.Transitions; using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; using Moryx.Properties; +using Moryx.Workplans.Transitions; namespace Moryx.Workplans.WorkplanSteps; @@ -34,4 +34,4 @@ protected override TransitionBase Instantiate(IWorkplanContext context) { return new JoinTransition(); } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/WorkplanSteps/SplitWorkplanStep.cs b/src/Moryx/Workplans/WorkplanSteps/SplitWorkplanStep.cs index 79d4eb9cfd..c04b758f86 100644 --- a/src/Moryx/Workplans/WorkplanSteps/SplitWorkplanStep.cs +++ b/src/Moryx/Workplans/WorkplanSteps/SplitWorkplanStep.cs @@ -27,7 +27,9 @@ private SplitWorkplanStep() public SplitWorkplanStep([Display(Name = "Outputs", Description = "Number of parallel paths")] int outputs = 2) { if (outputs <= 1) + { throw new ArgumentException("Split must have at least two outputs."); + } Outputs = new IConnector[outputs]; OutputDescriptions = new OutputDescription[outputs]; diff --git a/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStep.cs b/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStep.cs index e0c5ac5995..2c18593a42 100644 --- a/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStep.cs +++ b/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStep.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Runtime.Serialization; -using Moryx.Workplans.Transitions; using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; using Moryx.Properties; +using Moryx.Workplans.Transitions; namespace Moryx.Workplans.WorkplanSteps; @@ -38,4 +38,4 @@ protected override TransitionBase Instantiate(IWorkplanContext context) var transition = new SubworkplanTransition(engine, indexResolver); return transition; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStepBase.cs b/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStepBase.cs index 15c9a24521..5d6cb59f38 100644 --- a/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStepBase.cs +++ b/src/Moryx/Workplans/WorkplanSteps/SubWorkplanStepBase.cs @@ -28,13 +28,13 @@ protected SubWorkplanStepBase(IWorkplan workplan) // Step outputs are created from all exits of the sub workplan OutputDescriptions = (from connector in workplan.Connectors - where connector.Classification.HasFlag(NodeClassification.Exit) - select new OutputDescription - { - Name = connector.Name, - MappingValue = connector.Id, - OutputType = connector.Classification == NodeClassification.End ? OutputType.Success : OutputType.Failure - }).ToArray(); + where connector.Classification.HasFlag(NodeClassification.Exit) + select new OutputDescription + { + Name = connector.Name, + MappingValue = connector.Id, + OutputType = connector.Classification == NodeClassification.End ? OutputType.Success : OutputType.Failure + }).ToArray(); Outputs = new IConnector[OutputDescriptions.Length]; } @@ -53,4 +53,4 @@ IWorkplan ISubworkplanStep.Workplan get => Workplan; set => Workplan = value; } -} \ No newline at end of file +} diff --git a/src/Moryx/Workplans/WorkplanSteps/WorkplanStepBase.cs b/src/Moryx/Workplans/WorkplanSteps/WorkplanStepBase.cs index dbe42c76b3..f12cb835b4 100644 --- a/src/Moryx/Workplans/WorkplanSteps/WorkplanStepBase.cs +++ b/src/Moryx/Workplans/WorkplanSteps/WorkplanStepBase.cs @@ -61,4 +61,4 @@ public ITransition CreateInstance(IWorkplanContext context) /// protected abstract TransitionBase Instantiate(IWorkplanContext context); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Products.Endpoints.Tests/ProductConverterTests.cs b/src/Tests/Moryx.AbstractionLayer.Products.Endpoints.Tests/ProductConverterTests.cs index 9c4b4410a3..01bab5c812 100644 --- a/src/Tests/Moryx.AbstractionLayer.Products.Endpoints.Tests/ProductConverterTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Products.Endpoints.Tests/ProductConverterTests.cs @@ -1,6 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Reflection; using Moq; using Moryx.AbstractionLayer.Identity; using Moryx.AbstractionLayer.Recipes; @@ -8,12 +9,6 @@ using Moryx.Tools; using Moryx.Workplans; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; namespace Moryx.AbstractionLayer.Products.Endpoints.Tests; @@ -59,11 +54,21 @@ internal static IEnumerable ProductForwardBackwardConversionTestCa // Create all possible combinations of input settings for the ConvertProduct method foreach (var identity in new IIdentity[] { null, new ProductIdentity("TestIdentifier", 1337) }) - foreach (ProductState state in Enum.GetValues(typeof(ProductState))) - foreach (var flat in new bool[] { true, false }) - foreach (var dummyType in dummyProductTypes) - foreach (var recipes in dummyRecipeLists) - yield return new TestCaseData(dummyType, state, identity, recipes, flat, testCaseCounter++); + { + foreach (ProductState state in Enum.GetValues(typeof(ProductState))) + { + foreach (var flat in new bool[] { true, false }) + { + foreach (var dummyType in dummyProductTypes) + { + foreach (var recipes in dummyRecipeLists) + { + yield return new TestCaseData(dummyType, state, identity, recipes, flat, testCaseCounter++); + } + } + } + } + } } /// /// Test if the conversion to and back from a ProductModel without modification of the model @@ -81,7 +86,10 @@ public async Task ForwardBackwardProductConversionWithoutInformationLoss(DummyPr originalProductType.Identity = identity; // - Expected behavior from the RecipeManagement if (recipes.Any()) + { ReflectionTool.TestMode = true; + } + _productManagerMock.Setup(rm => rm.LoadRecipesAsync(It.IsAny(), RecipeClassification.CloneFilter)) .ReturnsAsync(recipes); _productManagerMock.Setup(rm => rm.LoadRecipeAsync(It.IsAny(), It.IsAny())) @@ -108,7 +116,9 @@ public async Task ForwardBackwardProductConversionWithoutInformationLoss(DummyPr // Assert // - Non ProductIdentities will always be transformed into empty ProductIdentities in the Process if (identity is null) + { originalProductType.Identity = new ProductIdentity("", 0); + } // - Products originally converted with the flat flag will only affect certain properties if (flat) { @@ -128,18 +138,24 @@ public async Task ForwardBackwardProductConversionWithoutInformationLoss(DummyPr _productManagerMock.Verify(rm => rm.LoadRecipesAsync(originalProductType, RecipeClassification.CloneFilter)); _productManagerMock.Verify(rm => rm.SaveRecipeAsync(It.Is(recipe => !HasChangedProperties(recipe, recipes.LastOrDefault())))); if (recipes.First().Id != 0) + { _productManagerMock.Verify(rm => rm.LoadRecipeAsync(recipes.First().Id)); + } } // - If there are ProductPartLinks the ProductManagement should be called var targetDummyTypeWithParts = recoveredOriginal as DummyProductTypeWithParts; if (targetDummyTypeWithParts?.ProductPartLink?.Product is not null) + { _productManagerMock.Verify(pm => pm.LoadTypeAsync(targetDummyTypeWithParts.ProductPartLink.Product.Id)); + } } private static bool HasChangedProperties(object A, object B) { if (A is null || B is null) + { throw new ArgumentNullException("You need to provide 2 non-null objects."); + } var type = typeof(T); var allProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); @@ -156,8 +172,10 @@ from pi in allSimpleProperties private static bool IsSimpleType(Type type) { if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { // nullable type, check if the nested type is simple. return IsSimpleType(type.GetGenericArguments()[0]); + } return type.IsPrimitive || type.IsEnum @@ -187,16 +205,25 @@ public static IEnumerable RecipeForwardBackwardConversionTestCaseG // Create all possible combinations of input settings for the ConvertRecipe method foreach (var backupProductType in new List() { null, new() }) - foreach (RecipeState state in Enum.GetValues(typeof(RecipeState))) - foreach (var classification in classifications) - foreach (var dummyRecipe in dummyRecipes) { - //dummyRecipe.Classification = classification; - //dummyRecipe.State = state; - var workplanInTargetRecipe = (dummyRecipe as DummyProductWorkplanRecipe)?.Workplan; - if (workplanInTargetRecipe is not null) - yield return new TestCaseData(dummyRecipe, classification, state, backupProductType, new DummyWorkplan() { Id = 1 }, testCaseCounter++); - yield return new TestCaseData(dummyRecipe, classification, state, backupProductType, workplanInTargetRecipe, testCaseCounter++); + foreach (RecipeState state in Enum.GetValues(typeof(RecipeState))) + { + foreach (var classification in classifications) + { + foreach (var dummyRecipe in dummyRecipes) + { + //dummyRecipe.Classification = classification; + //dummyRecipe.State = state; + var workplanInTargetRecipe = (dummyRecipe as DummyProductWorkplanRecipe)?.Workplan; + if (workplanInTargetRecipe is not null) + { + yield return new TestCaseData(dummyRecipe, classification, state, backupProductType, new DummyWorkplan() { Id = 1 }, testCaseCounter++); + } + + yield return new TestCaseData(dummyRecipe, classification, state, backupProductType, workplanInTargetRecipe, testCaseCounter++); + } + } + } } } @@ -223,10 +250,14 @@ public async Task ForwardBackwardRecipeConversionWithoutInformationLoss(DummyPro var targetDummyRecipe = (DummyProductRecipe)Activator.CreateInstance(originalRecipe.GetType()); targetDummyRecipe.Id = 42; if (originalWorkplanRecipe is not null) + { ((DummyProductWorkplanRecipe)targetDummyRecipe).Workplan = workplanInTargetRecipe; + } // - No change of classification on clones should be possible, thereby preset it if (originalRecipe.Classification.HasFlag(RecipeClassification.Clone)) + { targetDummyRecipe.Classification = originalRecipe.Classification; + } // Act var convertedModel = _productConverter.ConvertRecipe(originalRecipe); @@ -235,14 +266,20 @@ public async Task ForwardBackwardRecipeConversionWithoutInformationLoss(DummyPro // Assert // - Backup products are used for recipes without products if (originalRecipe.Product is null) + { originalRecipe.Product = backupProductType; + } Assert.That(recoveredOriginal, Is.EqualTo(originalRecipe)); // - If there is a workplan and it changed, reload it at backward conversion if (originalWorkplanRecipe?.Workplan is not null && originalWorkplanRecipe.Workplan.Id != workplanInTargetRecipe.Id) + { _productManagerMock.Verify(wm => wm.LoadWorkplanAsync(originalWorkplanRecipe.Workplan.Id), Times.Once); + } else + { _productManagerMock.VerifyNoOtherCalls(); + } } #endregion @@ -250,7 +287,9 @@ public async Task ForwardBackwardRecipeConversionWithoutInformationLoss(DummyPro public static IEnumerable WorkplanForwardConversionTestCaseGenerator() { foreach (var wpState in Enum.GetValues(typeof(WorkplanState))) + { yield return new TestCaseData(wpState); + } } //Problem Entry Convert diff --git a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/IReferencedResource.cs b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/IReferencedResource.cs index 36dd734cad..a7f9bd65be 100644 --- a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/IReferencedResource.cs +++ b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/IReferencedResource.cs @@ -7,6 +7,6 @@ internal interface IReferencedResource : IResource { } -internal class ReferencedResource : Resource, IReferencedResource +internal sealed class ReferencedResource : Resource, IReferencedResource { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/ReferencingResource.cs b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/ReferencingResource.cs index 65f0227230..a3a6433361 100644 --- a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/ReferencingResource.cs +++ b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/Mocks/ReferencingResource.cs @@ -5,8 +5,8 @@ namespace Moryx.AbstractionLayer.Resources.Endpoints.Tests.Mocks; -internal class ReferencingResource : Resource +internal sealed class ReferencingResource : Resource { [ResourceReference(ResourceRelationType.Custom)] public ReferenceCollectionMock References { get; set; } = new(); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/ResourceModificationControllerTests.cs b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/ResourceModificationControllerTests.cs index 03229dc0cf..e2fff71e09 100644 --- a/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/ResourceModificationControllerTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Resources.Endpoints.Tests/ResourceModificationControllerTests.cs @@ -10,7 +10,7 @@ namespace Moryx.AbstractionLayer.Resources.Endpoints.Tests; [TestFixture] -internal class ResourceModificationControllerTests +internal sealed class ResourceModificationControllerTests { private Mock? _resourceManagementMock; private Mock? _resourceTypeTreeMock; diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ActivityResultLocalizationTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ActivityResultLocalizationTests.cs index 1491780b7c..2af572dbd6 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ActivityResultLocalizationTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ActivityResultLocalizationTests.cs @@ -3,7 +3,6 @@ using Moryx.AbstractionLayer.Tests.TestData; using NUnit.Framework; -using System.Linq; namespace Moryx.AbstractionLayer.Tests; @@ -30,4 +29,4 @@ public void ActivityResultDisplayName() Assert.That(expectedFailedDisplayName, Is.EqualTo(failedResultDescription.Name)); Assert.That(expectedSuccesDisplayName, Is.EqualTo(successResultDescription.Name)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/CapabilitiesTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/CapabilitiesTests.cs index 6f5b3cefe5..75f9a5618e 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/CapabilitiesTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/CapabilitiesTests.cs @@ -3,7 +3,6 @@ using Moryx.AbstractionLayer.Resources; using NUnit.Framework; -using System; namespace Moryx.AbstractionLayer.Tests; diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ExpressionConstraintTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ExpressionConstraintTests.cs index b5c17e9bd1..d27b8fc153 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ExpressionConstraintTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ExpressionConstraintTests.cs @@ -9,7 +9,7 @@ namespace Moryx.AbstractionLayer.Tests; [TestFixture] public class ExpressionConstraintTests { - private class DummyContext : IConstraintContext + private sealed class DummyContext : IConstraintContext { public int Foo { get; set; } } @@ -78,4 +78,4 @@ public void ExpressionGreater(int foo, int compareValue) // Arrange Assert.That(foo >= compareValue, Is.EqualTo(result), "Constraint failed to compare objects"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ParameterBindingTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ParameterBindingTests.cs index c2a75d99bc..b0ae24ccdc 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ParameterBindingTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ParameterBindingTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Products; @@ -96,7 +94,9 @@ protected override void Populate(Process process, Parameters instance) var parameters = (InsertPartParameters)instance; if (_resolver == null) + { _resolver = ResolverFactory.Create(Part); + } parameters.Target = (ProductType)_resolver.Resolve(process); } @@ -140,14 +140,14 @@ private static ProductionProcess DummyProcess() return process; } - private class DummyRecipe : ProductRecipe + private sealed class DummyRecipe : ProductRecipe { public string OrderNumber { get; set; } public Dictionary Config { get; set; } } - private class DummyType : ProductType + private sealed class DummyType : ProductType { public int Foo { get; set; } @@ -163,7 +163,7 @@ protected override ProductInstance Instantiate() public ProductPartLink Part { get; set; } } - private class DummyValue + private sealed class DummyValue { public DummyValue(DummyType type) { @@ -176,8 +176,8 @@ public DummyValue(DummyType type) public DummyType ProductType { get; } } - private class DummyInstance : ProductInstance + private sealed class DummyInstance : ProductInstance { public float Blah { get; set; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ProcessExtensionsTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ProcessExtensionsTests.cs index de9646e1cd..d4a4ce5807 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ProcessExtensionsTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ProcessExtensionsTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Products; @@ -205,16 +203,6 @@ public void LastActivityOfType_WhenExactFlagIsOmitted_IncludesDerivedActivities( : new TestRecipe() }; - private static Process CreateProcess(ProcessKind processKind) => processKind switch - { - ProcessKind.ProductionWithExpectedInstance => CreateProductionProcess(new DummyProductType()), - ProcessKind.ProductionWithOtherInstance => CreateProductionProcess(new OtherTestProductType()), - _ => new Process() - }; - - private static ProductionProcess CreateProductionProcess(ProductType productType) => - CreateProductionProcess(productType, productType.CreateInstance()); - private static ProductionProcess CreateProductionProcess(ProductType productType, ProductInstance productInstance) { return new() diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ProductConstraintTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ProductConstraintTests.cs index 3a325530bb..24e82ed656 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ProductConstraintTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ProductConstraintTests.cs @@ -1,9 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moq; using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Constraints; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Products; @@ -52,4 +50,4 @@ private static ProductionProcess CreateProcess() } }; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ProductIdentityTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ProductIdentityTests.cs index 01b6d63f9f..dee26afdbe 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ProductIdentityTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ProductIdentityTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Products; using NUnit.Framework; diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ProductTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ProductTests.cs index 4df3dee496..46f11def7c 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ProductTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ProductTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Moryx.AbstractionLayer.Products; using Moryx.Products.Samples; using NUnit.Framework; @@ -46,4 +45,4 @@ public void InstantiateProduct() Assert.That(watchInstance.WatchFace.Type, Is.EqualTo(watch.WatchFace.Product), "Wrong watchface product"); Assert.That(watch.Needles.ElementAt(0).Role, Is.EqualTo(NeedleRole.Hours), "Role not set on instance"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/ResourceExtensionsGetFirstRelatedResourceTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/ResourceExtensionsGetFirstRelatedResourceTests.cs index df9786e9d4..727c75ea3a 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/ResourceExtensionsGetFirstRelatedResourceTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/ResourceExtensionsGetFirstRelatedResourceTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; -using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Resources; using Moryx.Resources.Samples; using NUnit.Framework; diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/ResourceConstructorTestResources.cs b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/ResourceConstructorTestResources.cs index 0a551479e0..3e6341793e 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/ResourceConstructorTestResources.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/ResourceConstructorTestResources.cs @@ -11,7 +11,7 @@ internal class GeneralConstructorResource : Resource public virtual void ConstructGeneralResource() => throw new NotImplementedException(); } -internal class SpecificConstructorResource : GeneralConstructorResource +internal sealed class SpecificConstructorResource : GeneralConstructorResource { public override void ConstructGeneralResource() => throw new NotImplementedException(); diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestActivity.cs b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestActivity.cs index 44f3f70dbd..e8079ec60b 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestActivity.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestActivity.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Activities; +using Moryx.AbstractionLayer.Capabilities; namespace Moryx.AbstractionLayer.Tests.TestData; diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestResults.cs b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestResults.cs index 64c0de1d94..46899a9447 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestResults.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestResults.cs @@ -10,4 +10,4 @@ public enum TestResults Success = 1, [Display(Name = "This is a failed result")] Failed = 2 -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestTask.cs b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestTask.cs index c7f4beaceb..3ea6c33e12 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestTask.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/TestData/TestTask.cs @@ -8,4 +8,4 @@ namespace Moryx.AbstractionLayer.Tests.TestData; public class TestTask : TaskStep { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AbstractionLayer.Tests/TracingActivityTests.cs b/src/Tests/Moryx.AbstractionLayer.Tests/TracingActivityTests.cs index f61640a3f5..f9bf549cc8 100644 --- a/src/Tests/Moryx.AbstractionLayer.Tests/TracingActivityTests.cs +++ b/src/Tests/Moryx.AbstractionLayer.Tests/TracingActivityTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moq; using Moryx.AbstractionLayer.Activities; using NUnit.Framework; @@ -134,7 +133,7 @@ private enum FooProgress Done = 100 } - private class FooTracing : Tracing + private sealed class FooTracing : Tracing { public string FooName { get; set; } @@ -151,4 +150,4 @@ public void Processing() Progress = FooProgress.Running; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.AspNetCore.Mqtt.Tests/ManagedMqttClientTests.cs b/src/Tests/Moryx.AspNetCore.Mqtt.Tests/ManagedMqttClientTests.cs index 28527d30b1..1e7f51b6fd 100644 --- a/src/Tests/Moryx.AspNetCore.Mqtt.Tests/ManagedMqttClientTests.cs +++ b/src/Tests/Moryx.AspNetCore.Mqtt.Tests/ManagedMqttClientTests.cs @@ -1,12 +1,12 @@ -// Copyright (c) 2026, Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 using Moq; -using NUnit.Framework; +using Moryx.AspNetCore.Mqtt.Components; using MQTTnet; using MQTTnet.Diagnostics.Logger; using MQTTnet.Packets; -using Moryx.AspNetCore.Mqtt.Components; +using NUnit.Framework; namespace Moryx.AspNetCore.Mqtt.Tests; diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/BinaryConnectionFactoryMock.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/BinaryConnectionFactoryMock.cs index 8f682fa6f4..b8d1555af6 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/BinaryConnectionFactoryMock.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/BinaryConnectionFactoryMock.cs @@ -19,10 +19,14 @@ public IBinaryConnection Create(BinaryConnectionConfig config, IMessageValidator { IBinaryConnection connection = null; if (config is TcpClientConfig) + { connection = new TcpClientConnection(validator) { Logger = _logger }; + } if (config is TcpListenerConfig) + { connection = new TcpListenerConnection(validator) { Logger = _logger }; + } connection?.Initialize(config); @@ -32,4 +36,4 @@ public IBinaryConnection Create(BinaryConnectionConfig config, IMessageValidator public void Destroy(IBinaryConnection instance) { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTests.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTests.cs index 8fec2ed77f..ce75f6bc67 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTests.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTests.cs @@ -1,9 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Net; -using System.Threading; using Moryx.Communication.Sockets.IntegrationTests.DelimiterProtocol; using NUnit.Framework; @@ -128,4 +126,4 @@ public void SendEmptyMessages() WaitForConnectionState(0, new TimeSpan(0, 0, 0, 1), BinaryConnectionState.AttemptingConnection); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTestsBase.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTestsBase.cs index d428314074..a4cd7a2b5a 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTestsBase.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/CommunicationSocketsTestsBase.cs @@ -1,12 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Net; -using System.Threading; using NUnit.Framework; namespace Moryx.Communication.Sockets.IntegrationTests; @@ -67,7 +63,9 @@ protected void CloseServer() foreach (var s in ServerConnections) { if (s.Connection == null) + { return; + } s.Connection.Dispose(); Assert.That(s.Connection.CurrentState, Is.EqualTo(BinaryConnectionState.Disconnected), @@ -85,7 +83,9 @@ protected void CloseClients() foreach (var c in Clients) { if (c.Connection == null) + { return; + } c.Connection.Dispose(); // Client should be disconnected @@ -107,7 +107,9 @@ protected void WaitForConnectionState(int clientIdx, TimeSpan timeToWait, Binary stopWatch.Start(); while (!Clients[clientIdx].Connection.CurrentState.Equals(wantedState) && stopWatch.ElapsedMilliseconds < timeToWait.TotalMilliseconds) + { Thread.Sleep(new TimeSpan(0, 0, 0, 0, 100)); + } stopWatch.Stop(); @@ -348,4 +350,4 @@ private static TcpListenerConfig CreateServerConfig(IPAddress adress, int port) } }; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/ConnectionBuffer.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/ConnectionBuffer.cs index 5d7193c292..f8bbcc0e46 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/ConnectionBuffer.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/ConnectionBuffer.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; - namespace Moryx.Communication.Sockets.IntegrationTests; public class ConnectionBuffer where TMessage : BinaryMessage @@ -20,4 +18,4 @@ public ConnectionBuffer() public int Id { get; set; } public List LastStateChangeEvents { get; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterCommunicationSocketTests.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterCommunicationSocketTests.cs index 336d751425..0cbf92013a 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterCommunicationSocketTests.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterCommunicationSocketTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Net; using NUnit.Framework; @@ -66,4 +64,4 @@ public void SendDelimitedMessage() EndDelimiterOnlyInterpreter.TestEndDelimiter.Length; Assert.That(published.Payload.Length, Is.EqualTo(expectedMsgLenth)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterInterpreterTests.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterInterpreterTests.cs index 2134cee604..25a52af98f 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterInterpreterTests.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/DelimiterInterpreterTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; using NUnit.Framework; @@ -47,7 +44,9 @@ public void CheckIfBaseDelimiterParametersAreCorrect() public void ParsePartialDelimiterMessage(bool useStartDelimiter) { if (!useStartDelimiter) + { _interpreter = new EndDelimiterOnlyInterpreter(); + } var text = Encoding.Unicode.GetBytes("Wie passend, du kämpfst"); @@ -210,4 +209,4 @@ public void ParseHtmlMessageAndUseHtmlInterpreter() Assert.That(published, Is.Not.Null); Assert.That(Encoding.UTF8.GetBytes(Output), Is.EqualTo(published.Payload)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/EndDelimiterOnlyInterpreter.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/EndDelimiterOnlyInterpreter.cs index fc775ee0aa..bb56152962 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/EndDelimiterOnlyInterpreter.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/EndDelimiterOnlyInterpreter.cs @@ -23,4 +23,4 @@ public class EndDelimiterOnlyInterpreter : DelimitedMessageInterpreter /// Byte sequence for end of message /// protected override byte[] EndDelimiter => TestEndDelimiter; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/HtmlInterpreter.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/HtmlInterpreter.cs index 5595678124..817d744bcb 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/HtmlInterpreter.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/HtmlInterpreter.cs @@ -33,4 +33,4 @@ public class HtmlInterpreter : DelimitedMessageInterpreter /// Byte sequence for end of message /// protected override byte[] EndDelimiter => Encoding.UTF8.GetBytes(""); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterInterpreter.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterInterpreter.cs index bd414e4d57..e1a463942e 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterInterpreter.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterInterpreter.cs @@ -11,4 +11,4 @@ public class TestDelimiterInterpreter : EndDelimiterOnlyInterpreter /// Byte sequence for start of message /// protected override byte[] StartDelimiter => TestStartDelimiter; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterValidator.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterValidator.cs index da4be49dd1..6fe87f97c5 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterValidator.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/DelimiterProtocol/TestDelimiterValidator.cs @@ -8,4 +8,4 @@ public class TestDelimiterValidator : IMessageValidator public bool Validate(BinaryMessage message) => true; public IMessageInterpreter Interpreter => new TestDelimiterInterpreter(); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/HeaderedCommunicationSocketTests.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/HeaderedCommunicationSocketTests.cs index 2e5ee554ab..8366519002 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/HeaderedCommunicationSocketTests.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/HeaderedCommunicationSocketTests.cs @@ -1,11 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Diagnostics; -using System.Linq; using System.Net; -using System.Threading; using NUnit.Framework; namespace Moryx.Communication.Sockets.IntegrationTests; @@ -159,14 +156,21 @@ public void ReconnectAfterInvalidMessage(bool clientSendsMessage) var stopWatch = new Stopwatch(); stopWatch.Start(); while (server.Connection.CurrentState != BinaryConnectionState.Connected && stopWatch.ElapsedMilliseconds < 5000) + { Thread.Sleep(1); + } // Act var binMessage = CreateMessage(42, [1, 3, 3, 7, 42]); if (clientSendsMessage) + { client.Connection.Send(binMessage); + } else + { server.Connection.Send(binMessage); + } + Thread.Sleep(20); // Assert @@ -298,4 +302,4 @@ protected override BinaryMessage CreateMessage(int senderId, byte[] payload) return new BinaryMessage(header, payload); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeader.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeader.cs index cb0c7629fa..6770dc3988 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeader.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeader.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using System.Text; namespace Moryx.Communication.Sockets.IntegrationTests; @@ -64,4 +62,4 @@ public byte[] ToBytes() str.CopyTo(result, idx.Length + pl.Length); return result; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeaderInterpreter.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeaderInterpreter.cs index 6df00d6263..b405203758 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeaderInterpreter.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestHeaderInterpreter.cs @@ -17,4 +17,4 @@ public SystemTestMessageInterpreter() /// Size of the header /// protected override int HeaderSize { get; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestValidator.cs b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestValidator.cs index 5c7d4929ad..5c1086e3b2 100644 --- a/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestValidator.cs +++ b/src/Tests/Moryx.Communication.Sockets.IntegrationTests/HeaderProtocol/SystemTestValidator.cs @@ -26,4 +26,4 @@ public bool Validate(BinaryMessage message) /// Interpreter used by the protocol of this validator /// public IMessageInterpreter Interpreter => SystemTestMessageInterpreter.Instance; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestPlugin/ForeignComponent.cs b/src/Tests/Moryx.Container.TestPlugin/ForeignComponent.cs index 60320aa423..424ad22409 100644 --- a/src/Tests/Moryx.Container.TestPlugin/ForeignComponent.cs +++ b/src/Tests/Moryx.Container.TestPlugin/ForeignComponent.cs @@ -29,4 +29,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestRootPlugin/ForeignDefaultComponent.cs b/src/Tests/Moryx.Container.TestRootPlugin/ForeignDefaultComponent.cs index db2c067b70..60dade17df 100644 --- a/src/Tests/Moryx.Container.TestRootPlugin/ForeignDefaultComponent.cs +++ b/src/Tests/Moryx.Container.TestRootPlugin/ForeignDefaultComponent.cs @@ -32,4 +32,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestRootPlugin/ForeignRootClass.cs b/src/Tests/Moryx.Container.TestRootPlugin/ForeignRootClass.cs index 80e271c197..ce84704f39 100644 --- a/src/Tests/Moryx.Container.TestRootPlugin/ForeignRootClass.cs +++ b/src/Tests/Moryx.Container.TestRootPlugin/ForeignRootClass.cs @@ -29,4 +29,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestTools/ComponentConfig.cs b/src/Tests/Moryx.Container.TestTools/ComponentConfig.cs index 96a30488ab..a58e07392b 100644 --- a/src/Tests/Moryx.Container.TestTools/ComponentConfig.cs +++ b/src/Tests/Moryx.Container.TestTools/ComponentConfig.cs @@ -11,4 +11,4 @@ public class ComponentConfig : IPluginConfig /// Name of the component represented by this entry /// public string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestTools/IConfiguredComponent.cs b/src/Tests/Moryx.Container.TestTools/IConfiguredComponent.cs index b7b5350500..8a25cc9081 100644 --- a/src/Tests/Moryx.Container.TestTools/IConfiguredComponent.cs +++ b/src/Tests/Moryx.Container.TestTools/IConfiguredComponent.cs @@ -8,4 +8,4 @@ namespace Moryx.Container.TestTools; public interface IConfiguredComponent : IConfiguredPlugin { string GetName(); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestTools/IRootClass.cs b/src/Tests/Moryx.Container.TestTools/IRootClass.cs index 20e7bf2983..284e1422f0 100644 --- a/src/Tests/Moryx.Container.TestTools/IRootClass.cs +++ b/src/Tests/Moryx.Container.TestTools/IRootClass.cs @@ -10,4 +10,4 @@ public interface IRootClass : IConfiguredPlugin IConfiguredComponent ConfiguredComponent { get; set; } string GetName(); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestTools/IRootClassFactory.cs b/src/Tests/Moryx.Container.TestTools/IRootClassFactory.cs index 595eeb976e..75673b38dc 100644 --- a/src/Tests/Moryx.Container.TestTools/IRootClassFactory.cs +++ b/src/Tests/Moryx.Container.TestTools/IRootClassFactory.cs @@ -9,4 +9,4 @@ public interface IRootClassFactory IRootClass Create(RootClassFactoryConfig config); void Destroy(IRootClass instance); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.TestTools/RootClassFactoryConfig.cs b/src/Tests/Moryx.Container.TestTools/RootClassFactoryConfig.cs index c286ea0350..77a306ada5 100644 --- a/src/Tests/Moryx.Container.TestTools/RootClassFactoryConfig.cs +++ b/src/Tests/Moryx.Container.TestTools/RootClassFactoryConfig.cs @@ -8,4 +8,4 @@ namespace Moryx.Container.TestTools; public class RootClassFactoryConfig : IPluginConfig { public string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Local/ConfiguredComponent.cs b/src/Tests/Moryx.Container.Tests/Local/ConfiguredComponent.cs index 9069d6e39a..a0f057657c 100644 --- a/src/Tests/Moryx.Container.Tests/Local/ConfiguredComponent.cs +++ b/src/Tests/Moryx.Container.Tests/Local/ConfiguredComponent.cs @@ -82,4 +82,4 @@ public void Start() public void Stop() { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Local/LocalComponent.cs b/src/Tests/Moryx.Container.Tests/Local/LocalComponent.cs index 8a45b2df62..c3e6602d07 100644 --- a/src/Tests/Moryx.Container.Tests/Local/LocalComponent.cs +++ b/src/Tests/Moryx.Container.Tests/Local/LocalComponent.cs @@ -16,4 +16,4 @@ public class LocalComponent : ILocalComponent public interface ILocalFactory { ILocalComponent Create(); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Local/NamedComponents.cs b/src/Tests/Moryx.Container.Tests/Local/NamedComponents.cs index 85b6034b99..6eec29d84a 100644 --- a/src/Tests/Moryx.Container.Tests/Local/NamedComponents.cs +++ b/src/Tests/Moryx.Container.Tests/Local/NamedComponents.cs @@ -34,4 +34,4 @@ public string GetName() public interface INamedComponentFactory { INamedComponent Create(string name); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Local/ServiceProviderBridgeTests.cs b/src/Tests/Moryx.Container.Tests/Local/ServiceProviderBridgeTests.cs index 6ade49cefb..a57f477969 100644 --- a/src/Tests/Moryx.Container.Tests/Local/ServiceProviderBridgeTests.cs +++ b/src/Tests/Moryx.Container.Tests/Local/ServiceProviderBridgeTests.cs @@ -92,9 +92,9 @@ public class ComponentWithExternalDependency(TimeProvider timeProvider) : ICompo public TimeProvider TimeProvider { get; } = timeProvider; } - private class FakeTimeProvider : TimeProvider; + private sealed class FakeTimeProvider : TimeProvider; - private class ServiceProviderMock(Func resolver) : IServiceProvider + private sealed class ServiceProviderMock(Func resolver) : IServiceProvider { public object GetService(Type serviceType) => resolver(serviceType); } diff --git a/src/Tests/Moryx.Container.Tests/Local/StrategySelectionTest.cs b/src/Tests/Moryx.Container.Tests/Local/StrategySelectionTest.cs index 68fd1648e8..3c54a4e746 100644 --- a/src/Tests/Moryx.Container.Tests/Local/StrategySelectionTest.cs +++ b/src/Tests/Moryx.Container.Tests/Local/StrategySelectionTest.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using Moryx.Container.TestPlugin; using Moryx.Container.TestRootPlugin; using Moryx.Container.TestTools; @@ -131,4 +129,4 @@ private static IContainer CreateContainer(IDictionary strategies) return container; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Named/Component.cs b/src/Tests/Moryx.Container.Tests/Named/Component.cs index 4d193485c0..c496df3150 100644 --- a/src/Tests/Moryx.Container.Tests/Named/Component.cs +++ b/src/Tests/Moryx.Container.Tests/Named/Component.cs @@ -40,4 +40,4 @@ public string GetName() { return "DepB"; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Named/NamedComponentTest.cs b/src/Tests/Moryx.Container.Tests/Named/NamedComponentTest.cs index e06678567a..8d2fe42053 100644 --- a/src/Tests/Moryx.Container.Tests/Named/NamedComponentTest.cs +++ b/src/Tests/Moryx.Container.Tests/Named/NamedComponentTest.cs @@ -47,4 +47,4 @@ public void InjectDepB() Assert.That(comp.DepB, Is.Not.Null, "Container did not inject DependencyB"); Assert.That(comp.DepB.GetName(), Is.EqualTo("DepB"), "Container did not inject default implementation"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Registrator/NamedDummy.cs b/src/Tests/Moryx.Container.Tests/Registrator/NamedDummy.cs index 2ddf5517ad..92eb7a5414 100644 --- a/src/Tests/Moryx.Container.Tests/Registrator/NamedDummy.cs +++ b/src/Tests/Moryx.Container.Tests/Registrator/NamedDummy.cs @@ -12,4 +12,4 @@ public class NamedDummy public class UnnamedDummy { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/Registrator/RegistratorTest.cs b/src/Tests/Moryx.Container.Tests/Registrator/RegistratorTest.cs index 5c7a053a9d..0d91a205e3 100644 --- a/src/Tests/Moryx.Container.Tests/Registrator/RegistratorTest.cs +++ b/src/Tests/Moryx.Container.Tests/Registrator/RegistratorTest.cs @@ -30,4 +30,4 @@ public void DoubleRegistrationWithAutoInstaller() { Assert.DoesNotThrow(() => _container.LoadFromAssembly(GetType().Assembly)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/UseChild/Components.cs b/src/Tests/Moryx.Container.Tests/UseChild/Components.cs index e8962d8f21..8af591fe74 100644 --- a/src/Tests/Moryx.Container.Tests/UseChild/Components.cs +++ b/src/Tests/Moryx.Container.Tests/UseChild/Components.cs @@ -3,31 +3,31 @@ namespace Moryx.Container.Tests; -internal class ParentOnly +internal sealed class ParentOnly { public Parent Parent { get; set; } } -internal class NamedParentOnly +internal sealed class NamedParentOnly { [Named("Parent2")] public Parent Parent { get; set; } } -internal class TypedChild +internal sealed class TypedChild { [UseChild] public Child Child { get; set; } } -internal class NamedChild +internal sealed class NamedChild { [UseChild("Child")] public Child Child { get; set; } } -internal class NamedChildNamedParent +internal sealed class NamedChildNamedParent { [UseChild("Child", "Parent2")] public Child Child { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/UseChild/ParentAndChild.cs b/src/Tests/Moryx.Container.Tests/UseChild/ParentAndChild.cs index c4f4e1f0fd..aad178d32c 100644 --- a/src/Tests/Moryx.Container.Tests/UseChild/ParentAndChild.cs +++ b/src/Tests/Moryx.Container.Tests/UseChild/ParentAndChild.cs @@ -1,11 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; - namespace Moryx.Container.Tests; -internal class Parent : INamedChildContainer +internal sealed class Parent : INamedChildContainer { public string Name { get; set; } @@ -24,7 +22,7 @@ public Child GetChild(string name, Type target) } } -internal class Child : IContainerChild +internal sealed class Child : IContainerChild { public string Name { get; set; } public Type Target { get; set; } @@ -39,4 +37,4 @@ public Child(string name, Type target) /// Parent container of this child /// public Parent Parent { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Container.Tests/UseChild/UseChildTest.cs b/src/Tests/Moryx.Container.Tests/UseChild/UseChildTest.cs index baaf613c50..758b2237f1 100644 --- a/src/Tests/Moryx.Container.Tests/UseChild/UseChildTest.cs +++ b/src/Tests/Moryx.Container.Tests/UseChild/UseChildTest.cs @@ -114,4 +114,4 @@ public void InjectNamedChild() Assert.That(comp.Child.Parent, Is.EqualTo(_parent2), "Container did not fetch from the correct parent!"); Assert.That(comp.Child.Name, Is.EqualTo("Child"), "Container did not forward name correctly!"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Activities/AssembleParametersTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Activities/AssembleParametersTests.cs index d367da44b8..39995a0e6f 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Activities/AssembleParametersTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Activities/AssembleParametersTests.cs @@ -6,11 +6,11 @@ using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.TestTools; +using Moryx.ControlSystem.Assemble; using Moryx.ControlSystem.TestTools; +using Moryx.ControlSystem.TestTools.Identity; using Moryx.VisualInstructions; using NUnit.Framework; -using Moryx.ControlSystem.Assemble; -using Moryx.ControlSystem.TestTools.Identity; namespace Moryx.ControlSystem.ProcessEngine.Tests.Activities; @@ -66,8 +66,10 @@ private static ProductionProcess DummyProcess() }; process.ProductInstance.Id = 42; if (process.ProductInstance is IIdentifiableObject identifiableObject) + { identifiableObject.Identity = new TestNumberIdentity(0, "0816"); + } return process; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDataTestBase.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDataTestBase.cs index 01641e846c..25e3878825 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDataTestBase.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDataTestBase.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using Moq; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; @@ -218,4 +216,4 @@ internal static void ExecuteTransition(Transition transition, IJobData jobData) throw new ArgumentOutOfRangeException(nameof(transition), transition, "Transition should not be part in this case"); } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDispatcherTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDispatcherTests.cs index 7dcdfd39c9..9b72ff6bd7 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDispatcherTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobDispatcherTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using Moq; using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.ProcessEngine.Jobs; @@ -191,4 +189,4 @@ public void Stop() firstJob.Verify(j => j.Interrupt(), Times.Once); }); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobListTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobListTests.cs index 56e5f111ae..0b29087202 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobListTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobListTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Recipes; @@ -58,9 +55,13 @@ public void SetUp() _jobList.StateChanged += delegate (object sender, JobStateEventArgs args) { if (args.CurrentState.Classification < JobClassification.Completed) + { _receivedStateChanged = args.JobData; + } else + { _recievedJobCompleted = args.JobData; + } }; _jobList.StateChanged += delegate (object sender, JobStateEventArgs eventArgs) { @@ -358,7 +359,10 @@ private static IJobData CreateJobMock(long id = 0, long recipeId = 0) var jobMock = new Mock(); jobMock.SetupGet(j => j.Id).Returns(id); if (recipeId == 0 && id > 0) + { recipeId = id; + } + jobMock.SetupGet(j => j.Recipe).Returns(new ProductionRecipe { Id = recipeId }); var jobStateMock = new Mock(); jobStateMock.SetupGet(s => s.Classification).Returns(JobClassification.Idle); @@ -385,4 +389,4 @@ private static void RaiseProgressChanged(IJobData jobData) var jobDataMock = (Mock)((IMocked)jobData).Mock; jobDataMock.Raise(j => j.ProgressChanged += null, jobData, EventArgs.Empty); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobManagerTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobManagerTests.cs index ce845dc9da..b5138d38c2 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobManagerTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobManagerTests.cs @@ -1,18 +1,15 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs; using Moryx.Logging; -using NUnit.Framework; using Moryx.TestTools.UnitTest; +using NUnit.Framework; namespace Moryx.ControlSystem.ProcessEngine.Tests.Jobs; @@ -32,7 +29,7 @@ public void SetUp() _jobListMock = new Mock(); _jobStorageMock = new Mock(); - _jobStorageMock.Setup(j => j.GetAll()).Returns(() => Array.Empty()); + _jobStorageMock.Setup(j => j.GetAll()).Returns(Array.Empty); _jobListMock.Setup(j => j.GetEnumerator()).Returns(() => _jobList.GetEnumerator()); _jobListMock.As().Setup(j => j.GetEnumerator()).Returns(() => _jobList.GetEnumerator()); diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobStorageTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobStorageTests.cs index 3588239192..6a61e34909 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobStorageTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/JobStorageTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Moq; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; @@ -185,4 +182,4 @@ private List CreateJobDataMocks(int amount) return jobs; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ParallelSchedulerTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ParallelSchedulerTests.cs index 305b4c770d..63f15befc2 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ParallelSchedulerTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ParallelSchedulerTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs; using NUnit.Framework; @@ -61,4 +60,4 @@ public void ResumeJobsAfterRestart() { ResumeJobsAfterRestart(3); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ProductionJobDataTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ProductionJobDataTests.cs index ed6f61c788..dee3456d52 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ProductionJobDataTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/ProductionJobDataTests.cs @@ -55,9 +55,13 @@ public void CompleteWaitingJob(bool useAbort) // Act if (useAbort) + { jobData.Abort(); + } else + { jobData.Complete(); + } // Assert Assert.That(jobData.Classification, Is.EqualTo(JobClassification.Completed)); @@ -231,7 +235,7 @@ public void InterruptCompletingJob() // Assert Assert.That(jobData.Classification, Is.EqualTo(JobClassification.Idle)); - Assert.DoesNotThrow(() => jobData.Interrupt(), "Interrupt an interrupted job should be okay"); + Assert.DoesNotThrow(jobData.Interrupt, "Interrupt an interrupted job should be okay"); } [Test(Description = "A completing job will be interrupted")] @@ -447,4 +451,4 @@ private static void SetStateOnProcess(IJobData jobData, ProcessData processData, processData.State = state; jobData.ProcessChanged(processData, state); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SchedulerTestBase.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SchedulerTestBase.cs index a831eea250..71a2402647 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SchedulerTestBase.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SchedulerTestBase.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Moq; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; @@ -322,9 +319,13 @@ protected void ResumeJobsAfterRestart(int expectedSchedulable) JobScheduler.Scheduled += (sender, job) => { if (job == runningInterrupted) + { runningInterrupted.Classification = JobClassification.Running; + } else if (job == completingInterrupted) + { completingInterrupted.Classification = JobClassification.Completing; + } }; // Act diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SeamlessSchedulerTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SeamlessSchedulerTests.cs index 1622dc72ff..28b7684b9a 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SeamlessSchedulerTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SeamlessSchedulerTests.cs @@ -1,19 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; -using Moq; using Moryx.AbstractionLayer.Processes; -using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs; using Moryx.ControlSystem.Recipes; using Moryx.ControlSystem.Setups; using Moryx.ControlSystem.TestTools; using Moryx.Logging; -using Moryx.TestTools.UnitTest; using NUnit.Framework; namespace Moryx.ControlSystem.ProcessEngine.Tests.Jobs; diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SetupJobDataTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SetupJobDataTests.cs index 98de3a28ba..d5797789af 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SetupJobDataTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/SetupJobDataTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0 using Moq; +using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs; using Moryx.ControlSystem.ProcessEngine.Jobs.Setup; @@ -10,8 +11,6 @@ using Moryx.Notifications; using Moryx.Workplans; using NUnit.Framework; -using System.Linq; -using Moryx.AbstractionLayer.Processes; namespace Moryx.ControlSystem.ProcessEngine.Tests.Jobs; @@ -424,4 +423,4 @@ public void ShouldLogError(Transition calledTransition) // Assert Assert.That(LoggerMock.Invocations.Count, Is.EqualTo(1), message: $"An error should have been logged on the {nameof(calledTransition)}"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/WorkplanValidationTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/WorkplanValidationTests.cs index ffd5aae110..11c71dde82 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/WorkplanValidationTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Jobs/WorkplanValidationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.ProcessEngine.Jobs; @@ -54,4 +53,4 @@ protected override void Populate(Process process, Parameters instance) { } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityDispatcherTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityDispatcherTests.cs index 80a7fbd811..daefcc36dd 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityDispatcherTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityDispatcherTests.cs @@ -3,6 +3,9 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; +using Moryx.AbstractionLayer.Activities; +using Moryx.AbstractionLayer.Constraints; +using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Cells; @@ -12,10 +15,6 @@ using Moryx.Logging; using Moryx.TestTools.UnitTest; using NUnit.Framework; -using System.Collections.Generic; -using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Constraints; -using Moryx.AbstractionLayer.Processes; namespace Moryx.ControlSystem.ProcessEngine.Tests.Processes; @@ -385,9 +384,13 @@ public void ShouldCacheRTWWithoutDirectResponse(ReadyToWorkType rtwType, long? p DataPool.UpdateProcess(processData, processState); ReadyToWork readyToWork; if (processId is null) + { readyToWork = Session.StartSession(ActivityClassification.Production, rtwType); + } else + { readyToWork = Session.StartSession(ActivityClassification.Production, rtwType, processId.Value); + } // Act RaiseReadyToWork(_serialCellMock, readyToWork); diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityPoolTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityPoolTests.cs index a2ce8ba101..628892cc4f 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityPoolTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityPoolTests.cs @@ -1,10 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.ProcessEngine.Processes; using Moryx.ControlSystem.TestTools; @@ -215,7 +211,9 @@ private void DummyThread(object contextObj) // Keep a stable amount of 20 processes int procCount; lock (_allProcesses) + { procCount = _allProcesses.Count; + } if (procCount < 20) { @@ -239,7 +237,10 @@ private void DummyThread(object contextObj) var index = random.Next(procCount - 5); ProcessData someProcess; lock (_allProcesses) + { someProcess = _allProcesses[index]; + } + DataPool.AddActivity(someProcess, new ActivityData(new DummyActivity())); } @@ -260,4 +261,4 @@ private void DummyThread(object contextObj) context.Failed = true; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityProviderTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityProviderTests.cs index 8ef557ffc6..ea0985b751 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityProviderTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityProviderTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Activities; @@ -177,9 +175,13 @@ public void CompleteProcess(bool success, ProcessState expectedResult) do { if (success) + { activity.Activity.Complete(0); + } else + { activity.Activity.Fail(); + } DataPool.TryUpdateActivity(activity, ActivityState.ResultProcessed); // This call replaces the reference in ModifedActivity } while ((activity = process.Activities.Last()).State < ActivityState.EngineProceeded); // ModifedActivity is not replaced when last task was completed @@ -285,4 +287,4 @@ public void ResumeAndDelete() Assert.That(processEntity.TokenHolders.Count, Is.EqualTo(0)); } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityTimeoutObserverTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityTimeoutObserverTests.cs index 4ecc7cb763..570df7e5f2 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityTimeoutObserverTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ActivityTimeoutObserverTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moq; using Moryx.ControlSystem.ProcessEngine.Processes; using Moryx.ControlSystem.TestTools; @@ -113,4 +112,4 @@ private static DummyActivity CreateActivity(int timeout) }; return activity; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessArchiveTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessArchiveTests.cs index fefe8073fe..da85b68e2b 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessArchiveTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessArchiveTests.cs @@ -1,12 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Moq; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Processes; @@ -134,15 +129,24 @@ public async Task GetProcessesTest(string start, string end, // Assert Assert.That(chunks.Count, Is.EqualTo(expectedJobCount)); if (chunks.Count > 0) + { Assert.That(chunks[0].Count(), Is.EqualTo(expectedProcessCountJob1)); + } if (chunks.Count > 1) + { Assert.That(chunks[1].Count(), Is.EqualTo(expectedProcessCountJob2)); + } if (chunks.Count > 2) + { Assert.That(chunks[2].Count(), Is.EqualTo(0)); + } + if (chunks.Count > 3) + { Assert.That(chunks[3].Count(), Is.EqualTo(0)); + } } [Test] diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessControllerTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessControllerTests.cs index 2caf56638e..ce93de5303 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessControllerTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessControllerTests.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Collections.ObjectModel; -using System.Linq; using Moq; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; @@ -286,4 +285,4 @@ public enum RecipeType Production = 0, Setup = 1 } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessInterruptionTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessInterruptionTests.cs index 22d5abb29d..12cbdaa45d 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessInterruptionTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessInterruptionTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Processes; @@ -127,4 +124,4 @@ private ActivityData FillPool(Activity activity) return activityData; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessRemovalTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessRemovalTests.cs index 46d0ebcd00..5033a9b2fd 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessRemovalTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessRemovalTests.cs @@ -70,10 +70,12 @@ public void AwaitStableStateForAborting(bool currentlyRunningActivity) var process = Process(false); DataPool.AddProcess(process); if (currentlyRunningActivity) + { DataPool.AddActivity(process, new ActivityData(new AssignIdentityActivity { Process = process.Process, Id = 1 }) { State = ActivityState.Running }); + } // Act DataPool.UpdateProcess(process, ProcessState.Aborting); @@ -164,6 +166,7 @@ private static ProcessData Process(bool mounted) Recipe = new ProductRecipe() }; if (mounted) + { process.AddActivity(new ActivityData(new MountActivity()) { Result = new ActivityResult @@ -172,6 +175,8 @@ private static ProcessData Process(bool mounted) }, State = ActivityState.Completed }); + } + process.AddActivity(new ActivityData(new DummyActivity()) { Result = new ActivityResult @@ -182,4 +187,4 @@ private static ProcessData Process(bool mounted) }); return process; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessStorageTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessStorageTests.cs index a77db7dd5f..ee8e7abd48 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessStorageTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessStorageTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.Serialization; using Microsoft.Extensions.Logging.Abstractions; using Moryx.AbstractionLayer.Activities; @@ -100,9 +97,14 @@ public void TestLoadActivityProperties() processData = activityData.ProcessData = processData ?? activityData.ProcessData; activityData.Id = IdShiftGenerator.Generate(processId, ProcessTestsBase.NextId); if (i > 0) + { activityData.Task = task; + } else // Append another completed activity where the task is missing later + { activityData.Task = new TaskTransition(new MountingParameters(), null) { Id = 1337 }; + } + activityData.Resource = new CellReference(i * 100); activityData.State = ActivityState.Running; @@ -435,4 +437,4 @@ private void CreateDatabaseItems() } } #endregion -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessTestsBase.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessTestsBase.cs index 5372c23eb6..09dbe20aa6 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessTestsBase.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessTestsBase.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; -using System.Threading; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Activities; @@ -193,4 +191,4 @@ internal static void CreateProcessInDb(ProcessStorage storage, IUnitOfWork uow, uow.SaveChanges(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessesIntegrationTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessesIntegrationTests.cs index dce95fe8c1..acb30c7468 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessesIntegrationTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ProcessesIntegrationTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Products; @@ -249,4 +246,4 @@ private static void CompleteActivity(Mock cellMock, ActivityStart activit var activityResult = activity.CreateResult(result); cellMock.Raise(r => r.ActivityCompleted += null, cellMock.Object, activityResult); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ResourceAssignmentTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ResourceAssignmentTests.cs index b75994875e..e93c4c6370 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ResourceAssignmentTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/ResourceAssignmentTests.cs @@ -1,10 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Activities; @@ -193,10 +189,12 @@ public void CapabilitiesChanged(bool providedBefore, bool providedAfter) Assert.That(activityData.Targets.Count, Is.EqualTo(1)); Assert.That(activityData.Targets[0], Is.EqualTo(_mountCellMock.Object)); if (!providedBefore) + { Assert.DoesNotThrow(delegate { _notificationAdapterMock.Verify(na => na.AcknowledgeAll(It.IsAny(), activityData), Times.Once); }); + } } else { @@ -338,4 +336,4 @@ public void InvalidSelectorTest() Assert.That(ModifiedActivity.Targets.Count, Is.EqualTo(1)); Assert.That(ModifiedActivity.Targets[0], Is.EqualTo(_productionCellMock.Object)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/StorageTriggerTest.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/StorageTriggerTest.cs index 8c06c26efc..dd676e1970 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/StorageTriggerTest.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Processes/StorageTriggerTest.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading; using Moq; using Moryx.AbstractionLayer.Identity; using Moryx.AbstractionLayer.Processes; @@ -121,8 +119,9 @@ public void ProvideArticle(ProcessTypes processType, ProcessState triggerState, var instance = ((ProductionProcess)process.Process).ProductInstance; Assert.That(instance, Is.Not.Null); if (triggerState == ProcessState.Ready) + { _productManagementMock.Verify(p => p.SaveInstanceAsync(It.IsAny()), Times.Once, "There should be a SaveInstance call"); - + } } } @@ -180,7 +179,10 @@ public void SaveOnActivityChange(long articleId, ProcessTypes processType, Activ var activity = CreateActivityData(modification, process.Id); DataPool.AddProcess(process); if (processType > ProcessTypes.ProductionProcessWithInstance) + { ((ProductionProcess)process.Process).ProductInstance.Id = articleId; + } + DataPool.AddActivity(process, activity); // Act @@ -352,4 +354,4 @@ public enum ProcessTypes ProductionProcessWithInstanceUnsaved = 4, ProductionProcessWithInstanceReference = 5, } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/SetupHandlerTests.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/SetupHandlerTests.cs index a848d90a03..979352179c 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/SetupHandlerTests.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/SetupHandlerTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Capabilities; @@ -519,7 +516,10 @@ public void AbortSetupsUponJobCompletion(bool hasPrepare, bool needsCleanup) // Arrange var manager = CreateSetupManager(); if (!hasPrepare) + { AdjustCurrentResourceCapabilities(42); + } + var recipe = CreateRecipe(1783, 42); var jobData = CreateProductionJob("Ran-Tan-Plan", recipe); _jobList.Add(jobData.Object); @@ -545,9 +545,14 @@ public void AbortSetupsUponJobCompletion(bool hasPrepare, bool needsCleanup) _jobListMock.Raise(r => r.StateChanged += null, this, new JobStateEventArgs(jobData.Object, null, stateMock.Object)); // Now the clean-up ist started, which causes recipe update if (needsCleanup) + { AdjustCurrentResourceCapabilities(42); + } else + { AdjustCurrentResourceCapabilities(0); + } + var setup = _setupJobs[hasPrepare ? 1 : 0]; setup.SetupGet(j => j.RecipeRequired).Returns(true); var state = new Mock(); @@ -557,11 +562,18 @@ public void AbortSetupsUponJobCompletion(bool hasPrepare, bool needsCleanup) // Assert if (needsCleanup) + { _setupJobs[hasPrepare ? 1 : 0].Verify(j => j.UpdateSetup(It.IsNotNull()), Times.Once); + } else + { _setupJobs[hasPrepare ? 1 : 0].Verify(j => j.UpdateSetup(null), Times.Once); + } + if (hasPrepare) + { _setupJobs[0].Verify(j => j.Abort(), Times.Once); + } } [Test(Description = "A new Prepare is necessary if running jobs already executed their clean-up")] @@ -716,4 +728,4 @@ private static void AssertHelper(LinkedListNode currentNode, NodePosit } #endregion -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/TestTriggerBase.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/TestTriggerBase.cs index d6778a2167..59f923a3f6 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/TestTriggerBase.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/Setup/TestTriggerBase.cs @@ -54,4 +54,4 @@ protected override void Populate(Process process, Parameters instance) var parameters = (TestSetupParameters)instance; parameters.TargetCapabilities = TargetCapabilities; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/TestRecipe.cs b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/TestRecipe.cs index a447806658..e607c9685a 100644 --- a/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/TestRecipe.cs +++ b/src/Tests/Moryx.ControlSystem.ProcessEngine.Tests/TestRecipe.cs @@ -8,4 +8,4 @@ namespace Moryx.ControlSystem.ProcessEngine.Tests; internal class TestRecipe : ProductionRecipe { public int SetupState { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/MultiStepTrigger.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/MultiStepTrigger.cs index 0f8b6f1c93..ac5f59cde9 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/MultiStepTrigger.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/MultiStepTrigger.cs @@ -4,7 +4,6 @@ using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Setups; using Moryx.Workplans; -using System.Collections.Generic; namespace Moryx.ControlSystem.SetupProvider.Tests; @@ -27,4 +26,4 @@ public override IReadOnlyList CreateSteps(IProductRecipe recipe) CreateStepCalled = true; return [new TestSetupTask { Name = "P1" }, new TestSetupTask { Name = "P2" }]; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/SetupManagerTests.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/SetupManagerTests.cs index 93bad57376..7251c2e3ae 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/SetupManagerTests.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/SetupManagerTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Capabilities; diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestRecipe.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestRecipe.cs index 81647c9664..31fe2890ff 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestRecipe.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestRecipe.cs @@ -8,4 +8,4 @@ namespace Moryx.ControlSystem.SetupProvider.Tests; internal class TestRecipe : ProductionRecipe { public int SetupState { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerBase.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerBase.cs index bce37b7bf8..e555fda6bf 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerBase.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerBase.cs @@ -1,15 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; +using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Capabilities; +using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; +using Moryx.AbstractionLayer.Workplans; using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Setups; using Moryx.Workplans; -using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; -using Moryx.AbstractionLayer.Workplans; namespace Moryx.ControlSystem.SetupProvider.Tests; @@ -69,4 +68,4 @@ protected override void Populate(Process process, Parameters instance) var parameters = (TestSetupParameters)instance; parameters.TargetCapabilities = TargetCapabilities; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerCleanUp.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerCleanUp.cs index d0f4380d50..34c2fa6826 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerCleanUp.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerCleanUp.cs @@ -19,4 +19,4 @@ public override SetupEvaluation Evaluate(IProductRecipe recipe) SetupState = ((TestRecipe)recipe).SetupState }); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerPrepare.cs b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerPrepare.cs index 920e037db6..d3cd650936 100644 --- a/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerPrepare.cs +++ b/src/Tests/Moryx.ControlSystem.SetupProvider.Tests/TestTriggerPrepare.cs @@ -19,4 +19,4 @@ public override SetupEvaluation Evaluate(IProductRecipe recipe) SetupState = ((TestRecipe)recipe).SetupState }); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.cs b/src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.cs index 380a0ac895..98fe11ecf9 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel.DataAnnotations; using Moryx.VisualInstructions; using NUnit.Framework; -using System.ComponentModel.DataAnnotations; namespace Moryx.ControlSystem.Tests; @@ -134,4 +134,4 @@ public void UsesDisplayResultsWhereFound() Assert.That(instructionResult.Count, Is.EqualTo(1), "There should be two results, because one does not have the EnumInstruction attribute"); Assert.That(instructionResult[0].DisplayValue, Is.EqualTo("Value 1")); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivity.cs b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivity.cs index 5c207624b5..4f9ca4861d 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivity.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivity.cs @@ -28,4 +28,4 @@ protected override ActivityResult CreateFailureResult() public override ICapabilities RequiredCapabilities => new DummyCapabilities(); public override ProcessRequirement ProcessRequirement => ProcessRequirement.Required; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivityParameters.cs b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivityParameters.cs index cb0a5eb1cb..71400272c6 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivityParameters.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyActivityParameters.cs @@ -14,4 +14,4 @@ public class DummyActivityParameters : Parameters, IActivityTimeoutParameters protected override void Populate(Process process, Parameters instance) { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyCapabilities.cs b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyCapabilities.cs index 5dd8bd74d0..f87f8530c1 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyCapabilities.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyCapabilities.cs @@ -11,4 +11,4 @@ protected override bool ProvidedBy(ICapabilities provided) { return provided is DummyCapabilities; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyRecipe.cs b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyRecipe.cs index 36a52b7eed..4a68753d12 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyRecipe.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyRecipe.cs @@ -1,4 +1,5 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Recipes; @@ -13,4 +14,4 @@ public class DummyRecipe : ProductionRecipe, IOrderBasedRecipe public DummyRecipe() { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyResult.cs b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyResult.cs index 84445b07eb..1b05a1f5f0 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyResult.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/Mocks/DummyResult.cs @@ -19,4 +19,4 @@ public enum DummyResult /// The activity could not be started at all. /// TechnicalFailure -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/ProcessExtensionsTest.cs b/src/Tests/Moryx.ControlSystem.Tests/ProcessExtensionsTest.cs index 5febef5922..3c59b92640 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/ProcessExtensionsTest.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/ProcessExtensionsTest.cs @@ -1,4 +1,5 @@ -// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG +// Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.Processes; @@ -23,7 +24,7 @@ public void ShouldReturnOrderNumber() // Assert Assert.That(orderNumber, Is.EqualTo(recipe.OrderNumber)); } - + [Test] public void ShouldReturnOperationNumber() { @@ -37,4 +38,4 @@ public void ShouldReturnOperationNumber() // Assert Assert.That(operationNumber, Is.EqualTo(recipe.OperationNumber)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs index 2fcd03ecfb..eef396a552 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/ProductionSessionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.Activities; using Moryx.ControlSystem.Cells; @@ -153,4 +152,4 @@ public void TestUnknownActivityAborted() Assert.That(session.AbortedActivity, Is.EqualTo(activity)); Assert.That(session.Reference.Matches(process)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs b/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs index 53f9a6dc71..ebce22e3d8 100644 --- a/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs +++ b/src/Tests/Moryx.ControlSystem.Tests/VisualInstructions/VisualInstructorExtensionsTests.cs @@ -99,4 +99,4 @@ private static ActivityStart CreateActivityStart() var session = Session.StartSession(ActivityClassification.Production, ReadyToWorkType.Push); return session.StartActivity(activity); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttChannelFunctions.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttChannelFunctions.cs index e5e01ee411..24baabec03 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttChannelFunctions.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttChannelFunctions.cs @@ -1,12 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Globalization; -using System.Linq; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Products; @@ -112,7 +108,7 @@ private async Task SetupTopic(MqttTopic topic) topic.Logger = new ModuleLogger("Dummy", new NullLoggerFactory()); _driver.Channels.Add(topic); await ((IAsyncInitializable)topic).InitializeAsync(); - await((IAsyncPlugin)topic).StartAsync(); + await ((IAsyncPlugin)topic).StartAsync(); } [Test(Description = "Find Channel with one parameter")] diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttIByteSerializable.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttIByteSerializable.cs index 3b89d62192..17589a10d4 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttIByteSerializable.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttIByteSerializable.cs @@ -1,11 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Buffers; using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.TestTools; @@ -93,7 +90,7 @@ public void Send_UsingDriver_IIdentifierMessage_Topic_QOS_Message() //Arrange _mockClient.Setup(m => m.PublishAsync( It.IsAny(), It.IsAny())) - .Callback((sentMsg, token) => SendMessageBoolMqttMessage(sentMsg, token)); + .Callback(SendMessageBoolMqttMessage); //Act _driver.Send(new BoolMqttMessage { Message = MESSAGE_VALUE, Identifier = _topicBoolMqtt.Identifier }); @@ -108,8 +105,7 @@ public void Send_UsingTopic_IIdentifierMessage_Topic_QOS_Message() //Arrange _mockClient.Setup(m => m.PublishAsync( It.IsAny(), It.IsAny())) - .Callback((sentMsg, token) - => SendMessageBoolMqttMessage(sentMsg, token)); + .Callback(SendMessageBoolMqttMessage); //Act _topicBoolMqtt.Send(new BoolMqttMessage { Message = MESSAGE_VALUE, Identifier = _topicBoolMqtt.Identifier }); @@ -138,8 +134,7 @@ public void Send_UsingTopic_IByteSerializableMessage_Topic_QOS_Message() //Arrange _mockClient.Setup(m => m.PublishAsync( It.IsAny(), It.IsAny())) - .Callback((sentMsg, token) - => SendMessageBoolIByteSerializableMessage(sentMsg, token)); + .Callback(SendMessageBoolIByteSerializableMessage); //Act _topicBoolIByteSerializable.Send(new BoolByteSerializableMessage { Message = MESSAGE_VALUE }); diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttJsonTopic.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttJsonTopic.cs index 02bb84ae2a..7c3c14a2b5 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttJsonTopic.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttJsonTopic.cs @@ -1,12 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Buffers; using System.Linq.Expressions; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.TestTools; diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttPrimitiveDatatypeTopic.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttPrimitiveDatatypeTopic.cs index a632be5167..3b02b9ce6e 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttPrimitiveDatatypeTopic.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverMqttPrimitiveDatatypeTopic.cs @@ -1,12 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Buffers; using System.Linq.Expressions; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.TestTools; @@ -95,8 +92,7 @@ public void SendInt_UsingMqttTopicPrimitive_Topic_QOS_Message() //Arrange _mockClient.Setup(m => m.PublishAsync( It.IsAny(), It.IsAny())) - .Callback((sentMsg, token) - => SendMessagIntIConvertible(sentMsg, token)); + .Callback(SendMessagIntIConvertible); //Act _mqttTopicInt.Send(MESSAGE_VALUE_INT); @@ -125,8 +121,7 @@ public void SendString_UsingMqttTopicPrimitive_Topic_QOS_Message() //Arrange _mockClient.Setup(m => m.PublishAsync( It.IsAny(), It.IsAny())) - .Callback((sentMsg, token) - => SendMessagStringIConvertible(sentMsg, token)); + .Callback(SendMessagStringIConvertible); //Act _mqttTopicString.Send(MESSAGE_VALUE_STRING); diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverStateMachine.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverStateMachine.cs index 3e22317047..0b6eabb62a 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverStateMachine.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestDriverStateMachine.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Globalization; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Drivers; @@ -80,4 +77,4 @@ public async Task Start_AfterStop_LeadsToConnectingToBrokerState() //Assert I Assert.That(_driver.CurrentState.Classification, Is.EqualTo(StateClassification.Initializing)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolByteSerializableMessage.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolByteSerializableMessage.cs index cfea87c692..3d25121b8f 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolByteSerializableMessage.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolByteSerializableMessage.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Communication; namespace Moryx.Drivers.Mqtt.Tests.TestMessages; @@ -18,4 +17,4 @@ public void FromBytes(byte[] bytes) { Message = BitConverter.ToBoolean(bytes, 0); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolMqttMessage.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolMqttMessage.cs index 99c3e47450..edd0309333 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolMqttMessage.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/BoolMqttMessage.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Drivers.Message; using Moryx.Communication; @@ -21,4 +20,4 @@ public void FromBytes(byte[] bytes) public string Identifier { get; set; } public bool Message { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/MessageForPlaceholderMessages.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/MessageForPlaceholderMessages.cs index 4773cd1630..d05ba5fed7 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/MessageForPlaceholderMessages.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMessages/MessageForPlaceholderMessages.cs @@ -19,4 +19,4 @@ public class MessageForPlaceholderMessages public class TestClass { public string Test { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMqttTopic.cs b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMqttTopic.cs index b84be2da15..1cf93feeb5 100644 --- a/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMqttTopic.cs +++ b/src/Tests/Moryx.Drivers.Mqtt.Tests/TestMqttTopic.cs @@ -1,11 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Text; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moryx.AbstractionLayer.TestTools; using Moryx.Drivers.Mqtt.Tests.TestMessages; diff --git a/src/Tests/Moryx.Drivers.OpcUa.Tests/HandleContinuationPoint.cs b/src/Tests/Moryx.Drivers.OpcUa.Tests/HandleContinuationPoint.cs index 0cfd230722..143dc3764b 100644 --- a/src/Tests/Moryx.Drivers.OpcUa.Tests/HandleContinuationPoint.cs +++ b/src/Tests/Moryx.Drivers.OpcUa.Tests/HandleContinuationPoint.cs @@ -3,11 +3,11 @@ using Moq; using Moryx.Drivers.OpcUa.States; +using Moryx.Modules; using Moryx.Tools; using NUnit.Framework; -using Opc.Ua.Client; using Opc.Ua; -using Moryx.Modules; +using Opc.Ua.Client; namespace Moryx.Drivers.OpcUa.Tests; diff --git a/src/Tests/Moryx.Drivers.OpcUa.Tests/HandlingCyclicNodesTests.cs b/src/Tests/Moryx.Drivers.OpcUa.Tests/HandlingCyclicNodesTests.cs index c9b3051b23..5009962bd9 100644 --- a/src/Tests/Moryx.Drivers.OpcUa.Tests/HandlingCyclicNodesTests.cs +++ b/src/Tests/Moryx.Drivers.OpcUa.Tests/HandlingCyclicNodesTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections; using System.Text.Json; using Moq; using Moryx.AbstractionLayer.Drivers; diff --git a/src/Tests/Moryx.Drivers.OpcUa.Tests/Mocks/FakeSubscriptionFactory.cs b/src/Tests/Moryx.Drivers.OpcUa.Tests/Mocks/FakeSubscriptionFactory.cs index 32120416c9..18fb888916 100644 --- a/src/Tests/Moryx.Drivers.OpcUa.Tests/Mocks/FakeSubscriptionFactory.cs +++ b/src/Tests/Moryx.Drivers.OpcUa.Tests/Mocks/FakeSubscriptionFactory.cs @@ -6,7 +6,7 @@ namespace Moryx.Drivers.OpcUa.Tests.Mocks; -internal class FakeSubscriptionFactory : SubscriptionFactory +internal sealed class FakeSubscriptionFactory : SubscriptionFactory { public override Subscription CreateSubscription(Subscription fromSubscription) { diff --git a/src/Tests/Moryx.Drivers.OpcUa.Tests/NodeHandlingTests.cs b/src/Tests/Moryx.Drivers.OpcUa.Tests/NodeHandlingTests.cs index e294895994..ef855dc0e7 100644 --- a/src/Tests/Moryx.Drivers.OpcUa.Tests/NodeHandlingTests.cs +++ b/src/Tests/Moryx.Drivers.OpcUa.Tests/NodeHandlingTests.cs @@ -3,7 +3,6 @@ using Moq; using Moryx.AbstractionLayer.Drivers; -using Moryx.Drivers.OpcUa.States; using Moryx.Modules; using NUnit.Framework; using Opc.Ua; diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/BaseTest.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/BaseTest.cs index e4d71f794b..c1a6e5662b 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/BaseTest.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/BaseTest.cs @@ -1,14 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using Castle.Core.Logging; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Resources; using Moryx.AbstractionLayer.TestTools.Resources; using Moryx.ControlSystem.Cells; diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_BackgroundTest.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_BackgroundTest.cs index a8cc9b5f12..30baa01ee3 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_BackgroundTest.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_BackgroundTest.cs @@ -5,8 +5,6 @@ using Moq; using Moryx.AbstractionLayer.Resources; using NUnit.Framework; -using System; -using System.Threading.Tasks; namespace Moryx.FactoryMonitor.Endpoints.Tests; @@ -34,4 +32,4 @@ public async Task ChangeBackground_ShouldWork() _resourceManagementMock.Verify(rm => rm.ModifyUnsafeAsync((long)_manufactoringFactoryId, (Func>)It.IsAny>>()), Times.Once); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_CellOperationsTest.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_CellOperationsTest.cs index f4317cfd20..223b334efa 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_CellOperationsTest.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_CellOperationsTest.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Globalization; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Moq; using Moryx.AbstractionLayer.Resources; diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_RouteTest.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_RouteTest.cs index b5d6e3b55e..3b6eb5c390 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_RouteTest.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_RouteTest.cs @@ -7,9 +7,6 @@ using Moryx.Factory; using Moryx.Tools; using NUnit.Framework; -using System; -using System.Linq; -using System.Threading.Tasks; namespace Moryx.FactoryMonitor.Endpoints.Tests; @@ -88,4 +85,4 @@ public void GetRoutes() _solderingCellLocation.Destinations.Clear(); _assemblyCellLocation.Destinations.Clear(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_StateTest.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_StateTest.cs index 1b907e4a58..c99e8ab224 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_StateTest.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/FactoryMonitorController_StateTest.cs @@ -1,26 +1,20 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; using Moq; +using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Capabilities; +using Moryx.AbstractionLayer.Processes; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Processes; using Moryx.FactoryMonitor.Endpoints.Models; using NUnit.Framework; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Text.Json.Serialization; -using System.Threading; -using System.Threading.Tasks; -using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; -using Microsoft.Extensions.DependencyInjection; namespace Moryx.FactoryMonitor.Endpoints.Tests; @@ -64,8 +58,10 @@ public void GetInitialFactoryState() Assert.That(GetLocations().Length, Is.EqualTo(endpointResult.Value.ResourceChangedModels.Count)); foreach (var endpointCell in endpointResult.Value.ResourceChangedModels) + { //machine location matches Assert.That(GetLocations().Any(l => l.Id == endpointCell.Location.Id)); + } } [Test] @@ -116,7 +112,9 @@ public async Task FactoryStatesStream() { o.SerializerOptions.PropertyNamingPolicy = _serializerOptions.PropertyNamingPolicy; foreach (var c in _serializerOptions.Converters) + { o.SerializerOptions.Converters.Add(c); + } }) .BuildServiceProvider(); @@ -231,9 +229,13 @@ private static void ReadJsonData(MemoryStream memoryStream, List(data, _serializerOptions); - if (order != null) orders.Add(order); + if (order != null) + { + orders.Add(order); + } + break; - // resourceChangedModel is intentionally ignored in these tests + // resourceChangedModel is intentionally ignored in these tests } } } diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/Resources/DummyCell.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/Resources/DummyCell.cs index a514f448e7..d51fa08697 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/Resources/DummyCell.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/Resources/DummyCell.cs @@ -2,12 +2,8 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; -using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Cells; using Moryx.Factory; -using System; -using System.Collections.Generic; -using Moryx.AbstractionLayer.Activities; namespace Moryx.FactoryMonitor.Endpoints.Tests.Resources; @@ -40,4 +36,4 @@ public override void SequenceCompleted(SequenceCompleted completed) { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/ActivityParameters.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/ActivityParameters.cs index e52925c218..78e62d6190 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/ActivityParameters.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/ActivityParameters.cs @@ -12,7 +12,6 @@ public class ActivityParameters : VisualInstructionParameters protected override void Populate(Process process, Parameters instance) { - var parameters = (ActivityParameters)instance; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/AssemblyActivity.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/AssemblyActivity.cs index ccb21eb6f6..1ba5911547 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/AssemblyActivity.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/AssemblyActivity.cs @@ -22,4 +22,4 @@ protected override ActivityResult CreateResult(long resultNumber) { return Complete(resultNumber); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/MyRecipe.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/MyRecipe.cs index c5f4267bde..09369e6047 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/MyRecipe.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/MyRecipe.cs @@ -7,4 +7,4 @@ namespace Moryx.FactoryMonitor.Endpoints.Tests; public class MyRecipe : OrderBasedRecipe { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/SolderingActivity.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/SolderingActivity.cs index fd1176e494..7518f829af 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/SolderingActivity.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestActivities/SolderingActivity.cs @@ -22,4 +22,4 @@ protected override ActivityResult CreateResult(long resultNumber) { return Complete(resultNumber); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities1.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities1.cs index 85f2b5258f..a41d3408a4 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities1.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities1.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; -using System.Collections.Generic; namespace Moryx.FactoryMonitor.Endpoints.Tests; @@ -18,4 +17,4 @@ public IEnumerable GetAll() public bool ProvidedBy(ICapabilities provided) => provided is DummyCapabilities1; public bool Provides(ICapabilities required) => required is DummyCapabilities1; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities2.cs b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities2.cs index 34fd8c1f4c..cd5a1c3e03 100644 --- a/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities2.cs +++ b/src/Tests/Moryx.FactoryMonitor.Endpoints.Tests/TestCapabilities/DummyCapabilities2.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using Moryx.AbstractionLayer.Capabilities; -using System.Collections.Generic; namespace Moryx.FactoryMonitor.Endpoints.Tests; @@ -18,4 +17,4 @@ public IEnumerable GetAll() public bool ProvidedBy(ICapabilities provided) => provided is DummyCapabilities2; public bool Provides(ICapabilities required) => required is DummyCapabilities2; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Media.Endpoints.Tests/MediaServerControllerTests.cs b/src/Tests/Moryx.Media.Endpoints.Tests/MediaServerControllerTests.cs index bdf6cdac2b..a29ad1e64f 100644 --- a/src/Tests/Moryx.Media.Endpoints.Tests/MediaServerControllerTests.cs +++ b/src/Tests/Moryx.Media.Endpoints.Tests/MediaServerControllerTests.cs @@ -5,9 +5,6 @@ using Microsoft.AspNetCore.Mvc; using Moq; using NUnit.Framework; -using System; -using System.IO; -using System.Threading.Tasks; namespace Moryx.Media.Endpoints.Tests; @@ -54,7 +51,9 @@ public void ShouldGetContentById(string requestedGuid, string availableGuid, Typ } else + { Assert.That(actionResult.Result.GetType().IsAssignableTo(resultType)); + } } [TestCase("11111111-1111-1111-1111-111111111111", "11111111-1111-1111-1111-111111111111", typeof(OkResult), Description = "Variant successfully retrieved")] @@ -73,9 +72,13 @@ public void ShouldGetVariantByIdAndName(string requestedGuid, string availableGu // Assert if (actionResult.Result is null) + { Assert.That(actionResult.Value, Is.EqualTo(returnedVariant)); + } else + { Assert.That(actionResult.Result.GetType().IsAssignableTo(resultType)); + } } [TestCase("SomeFileHash", "image/jpeg", typeof(FileStreamResult), Description = "Successfully recieve FileStream")] @@ -272,4 +275,4 @@ public void ShouldRemoveVariantByIdAndName(string requestedGuid, string availabl // Assert Assert.That(actionResult.GetType().IsAssignableTo(resultType)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Media.Endpoints.Tests/UploadValidationTests.cs b/src/Tests/Moryx.Media.Endpoints.Tests/UploadValidationTests.cs index a96c07c9cf..b718d5f606 100644 --- a/src/Tests/Moryx.Media.Endpoints.Tests/UploadValidationTests.cs +++ b/src/Tests/Moryx.Media.Endpoints.Tests/UploadValidationTests.cs @@ -1,12 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Globalization; using Microsoft.AspNetCore.Http; using Moq; using NUnit.Framework; -using System; -using System.Globalization; -using System.IO; namespace Moryx.Media.Endpoints.Tests; @@ -221,4 +219,4 @@ internal static FormFile FromStream(Stream stream, string filename, string mimeT internal static class MimeTypeString { public const string ApplicationData = "application/data"; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Media.Server.Tests/ContentManagerTests.cs b/src/Tests/Moryx.Media.Server.Tests/ContentManagerTests.cs index 5bd7dd1a80..2ddc97a455 100644 --- a/src/Tests/Moryx.Media.Server.Tests/ContentManagerTests.cs +++ b/src/Tests/Moryx.Media.Server.Tests/ContentManagerTests.cs @@ -1,17 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Security.Cryptography; -using System.Threading.Tasks; -using Moryx.Media.Server.Previews; -using Moq; -using NUnit.Framework; using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Moryx.Logging; +using Moryx.Media.Server.Previews; +using NUnit.Framework; namespace Moryx.Media.Server.Tests; @@ -74,7 +69,7 @@ public async Task AddContentAddsNewContent(string fileName, string mimeType) using (var master = _contentManager.GetStream(descriptor.GetMaster())) { masterContent = new byte[master.Length]; - master.Read(masterContent, 0, masterContent.Length); + master.ReadExactly(masterContent); } // Assert @@ -217,13 +212,13 @@ public async Task AddVariantSucceeds() using (var master = _contentManager.GetStream(descriptor.GetMaster())) { masterContent = new byte[master.Length]; - master.Read(masterContent, 0, masterContent.Length); + master.ReadExactly(masterContent); } using (var variant = _contentManager.GetStream(variantDescriptor)) { variantContent = new byte[variant.Length]; - variant.Read(variantContent, 0, variantContent.Length); + variant.ReadExactly(variantContent); } // Assert @@ -298,4 +293,4 @@ private async Task AddMaster(string fileName) return addingInfo; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Media.Server.Tests/Properties/AssemblyInfo.cs b/src/Tests/Moryx.Media.Server.Tests/Properties/AssemblyInfo.cs index 91f1289496..7eeecf5e6c 100644 --- a/src/Tests/Moryx.Media.Server.Tests/Properties/AssemblyInfo.cs +++ b/src/Tests/Moryx.Media.Server.Tests/Properties/AssemblyInfo.cs @@ -3,4 +3,4 @@ using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/Tests/Moryx.Model.Tests/InMemoryTests.cs b/src/Tests/Moryx.Model.Tests/InMemoryTests.cs index 27c6e3ca8e..87b7103d25 100644 --- a/src/Tests/Moryx.Model.Tests/InMemoryTests.cs +++ b/src/Tests/Moryx.Model.Tests/InMemoryTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using Moryx.Model.InMemory; using Moryx.TestTools.Test.Model; @@ -61,4 +59,4 @@ public async Task TimeShouldAlwaysBeSavedAsUtc() Assert.That(reloadedCar.ReleaseDateUtc.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(reloadedCar.ReleaseDateLocal.Kind, Is.EqualTo(DateTimeKind.Local)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeEntity.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeEntity.cs index c6da1b8514..d5e3bfc7da 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeEntity.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeEntity.cs @@ -14,4 +14,4 @@ public class SomeEntity : EntityBase public int Value3 { get; set; } public int Value4 { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeModificationTrackedEntity.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeModificationTrackedEntity.cs index 6a2dd92cc0..55dc9d6d46 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeModificationTrackedEntity.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Entities/SomeModificationTrackedEntity.cs @@ -6,4 +6,4 @@ namespace Moryx.Model.Tests; public class SomeModificationTrackedEntity : ModificationTrackedEntityBase { public string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/InterfaceProxyTests.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/InterfaceProxyTests.cs index 531fdcb3f1..df69447728 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/InterfaceProxyTests.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/InterfaceProxyTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Model.Repositories; using Moryx.Model.Repositories.Proxy; using NUnit.Framework; @@ -135,4 +134,4 @@ public void CreateWithWrongParameterExcepionIsThrown() }); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateAllParamsRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateAllParamsRepository.cs index 02cd0b6cbd..2ca58a005d 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateAllParamsRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateAllParamsRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface ICreateAllParamsRepository : IRepository { SomeEntity Create(int value, string name, int value2, int value3, int value4); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateStringParamRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateStringParamRepository.cs index aaee9d8ae2..2a83eff781 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateStringParamRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateStringParamRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface ICreateStringParamRepository : IRepository { SomeEntity Create(string name); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateUnknownPropertyRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateUnknownPropertyRepository.cs index fa7dd8306a..eaf85b95a0 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateUnknownPropertyRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateUnknownPropertyRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface ICreateUnknownPropertyRepository : IRepository { SomeEntity Create(string unknown); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateValueParamRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateValueParamRepository.cs index 12bc3c9bbd..b19a0ac3bc 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateValueParamRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateValueParamRepository.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Model.Repositories; namespace Moryx.Model.Tests; @@ -9,4 +8,4 @@ namespace Moryx.Model.Tests; public interface ICreateValueParamRepository : IRepository { SomeEntity Create(Int32 value); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateWrongReturnTypeRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateWrongReturnTypeRepository.cs index be873ee953..92c93f2781 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateWrongReturnTypeRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/ICreateWrongReturnTypeRepository.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Model.Repositories; namespace Moryx.Model.Tests; @@ -9,4 +8,4 @@ namespace Moryx.Model.Tests; public interface ICreateWrongReturnTypeRepository : IRepository { Type Create(string wrong); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IEmptyRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IEmptyRepository.cs index 63a5764fba..4b61a86b3b 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IEmptyRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IEmptyRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface IEmptyRepository : IRepository { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IModificationTrackedRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IModificationTrackedRepository.cs index 45f2fd04b1..256b2e8ba8 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IModificationTrackedRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IModificationTrackedRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface IModificationTrackedRepository : IRepository { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWithoutIRepositoryRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWithoutIRepositoryRepository.cs index 011070f19e..e35ff40a87 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWithoutIRepositoryRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWithoutIRepositoryRepository.cs @@ -6,4 +6,4 @@ namespace Moryx.Model.Tests; public interface IWithoutIRepositoryRepository { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWrongParamTypeRepository.cs b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWrongParamTypeRepository.cs index 5b378f72cc..61393cd396 100644 --- a/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWrongParamTypeRepository.cs +++ b/src/Tests/Moryx.Model.Tests/RepositoryProxies/Interfaces/IWrongParamTypeRepository.cs @@ -8,4 +8,4 @@ namespace Moryx.Model.Tests; public interface IWrongParamTypeRepository : IRepository { SomeEntity Create(int value, string name, long value2); -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Model.Tests/SqliteTests.cs b/src/Tests/Moryx.Model.Tests/SqliteTests.cs index 43a5a4081b..389a546edd 100644 --- a/src/Tests/Moryx.Model.Tests/SqliteTests.cs +++ b/src/Tests/Moryx.Model.Tests/SqliteTests.cs @@ -2,10 +2,8 @@ // Licensed under the Apache License, Version 2.0 using Moryx.Model.Sqlite; -using NUnit.Framework; -using System.IO; -using System.Threading.Tasks; using Moryx.TestTools.Test.Model; +using NUnit.Framework; namespace Moryx.Model.Tests; @@ -61,7 +59,9 @@ public async Task SqliteDeleteDatabaseShouldWork() public void Destroy() { if (File.Exists(_dataSource)) + { //remove the database _configurator.DeleteDatabaseAsync(_dbConfig).Wait(); + } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Notifications.Tests/NotificationAdapterTests.cs b/src/Tests/Moryx.Notifications.Tests/NotificationAdapterTests.cs index 9aeb6aa78b..5330a6d287 100644 --- a/src/Tests/Moryx.Notifications.Tests/NotificationAdapterTests.cs +++ b/src/Tests/Moryx.Notifications.Tests/NotificationAdapterTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moq; using NUnit.Framework; diff --git a/src/Tests/Moryx.Notifications.Tests/NotificationProcessorTests.cs b/src/Tests/Moryx.Notifications.Tests/NotificationProcessorTests.cs index 82c4cc3587..5e3f2483d7 100644 --- a/src/Tests/Moryx.Notifications.Tests/NotificationProcessorTests.cs +++ b/src/Tests/Moryx.Notifications.Tests/NotificationProcessorTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using Moryx.Model.InMemory; using Moryx.Model.Repositories; using Moryx.Notifications.Publisher; @@ -162,4 +160,4 @@ private static Notification CreateTestNotification() Created = DateTime.UtcNow }; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Notifications.Tests/NotificationPublisherTests.cs b/src/Tests/Moryx.Notifications.Tests/NotificationPublisherTests.cs index dc26040a97..374e1c90e8 100644 --- a/src/Tests/Moryx.Notifications.Tests/NotificationPublisherTests.cs +++ b/src/Tests/Moryx.Notifications.Tests/NotificationPublisherTests.cs @@ -1,17 +1,16 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using Moryx.Notifications.Publisher; -using Moryx.TestTools.UnitTest; -using Moryx.Threading; +using Microsoft.Extensions.Logging.Abstractions; using Moq; +using Moryx.Logging; using Moryx.Model.InMemory; using Moryx.Model.Repositories; -using NUnit.Framework; -using Moryx.Logging; -using Microsoft.Extensions.Logging.Abstractions; +using Moryx.Notifications.Publisher; using Moryx.Notifications.Publisher.Model; +using Moryx.TestTools.UnitTest; +using Moryx.Threading; +using NUnit.Framework; namespace Moryx.Notifications.Tests; @@ -218,4 +217,4 @@ private static Notification CreateTestNotification(Guid identifier, string sourc notification.Source = sourceName; return notification; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/GlobalUsings.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/GlobalUsings.cs index a8532bbdfc..9384fa47a8 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/GlobalUsings.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/GlobalUsings.cs @@ -1,4 +1,4 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -global using NUnit.Framework; \ No newline at end of file +global using NUnit.Framework; diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/IAttendanceManagementTests.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/IAttendanceManagementTests.cs index efe1a96184..540f3e2876 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/IAttendanceManagementTests.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/IAttendanceManagementTests.cs @@ -6,7 +6,7 @@ namespace Moryx.Operators.Management.Tests; [TestFixture] -internal class IAttendanceManagementTests : TestsBase +internal sealed class IAttendanceManagementTests : TestsBase { private IAttendanceManagementExtended _facade; private readonly string _defaultOperatorIdentifier = "Default Operator Identifier"; @@ -112,12 +112,10 @@ public void SignIn_WithAssignedOperator_DoesNothing() var eventArgs = InvalidAssignableOperator; SignInStatusChangedArgs? signInStatusArgs = null; - _facade.SignIn(AssignableOperator, FirstResourceMock.Object); _facade.OperatorSignedIn += (sender, op) => eventArgs = op; _facade.SignInStatusChanged += (sender, args) => signInStatusArgs = args; - // Act // Assert Assert.Multiple(() => diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/IOperatorManagementTests.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/IOperatorManagementTests.cs index 960cfad5eb..beee7da66a 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/IOperatorManagementTests.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/IOperatorManagementTests.cs @@ -6,7 +6,7 @@ namespace Moryx.Operators.Management.Tests; [TestFixture] -internal class IOperatorManagementTests : TestsBase +internal sealed class IOperatorManagementTests : TestsBase { private IOperatorManagement _facade; diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/ISkillManagementTests.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/ISkillManagementTests.cs index 87ef98c6f9..fcf15644df 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/ISkillManagementTests.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/ISkillManagementTests.cs @@ -6,7 +6,7 @@ namespace Moryx.Operators.Management.Tests; [TestFixture] -internal class ISkillManagementTests : TestsBase +internal sealed class ISkillManagementTests : TestsBase { private ISkillManagement _facade; diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/ModuleTests.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/ModuleTests.cs index 3a1475dbc5..8c4de5b34a 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/ModuleTests.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/ModuleTests.cs @@ -8,7 +8,7 @@ namespace Moryx.Operators.Management.Tests; [TestFixture] -internal class ModuleTests : TestsBase +internal sealed class ModuleTests : TestsBase { private IOperatorManagement _operatorsFacade; private ISkillManagement _skillsFacade; diff --git a/src/Tests/Moryx.Operators.Management.Integration.Tests/TestsBase.cs b/src/Tests/Moryx.Operators.Management.Integration.Tests/TestsBase.cs index c5245b0833..c649686e92 100644 --- a/src/Tests/Moryx.Operators.Management.Integration.Tests/TestsBase.cs +++ b/src/Tests/Moryx.Operators.Management.Integration.Tests/TestsBase.cs @@ -211,9 +211,15 @@ public TestCapabilities() { } protected override bool ProvidedBy(ICapabilities provided) { if (provided is not TestCapabilities providedTestCapabilities) + { return false; + } + if (providedTestCapabilities.Number != Number) + { return false; + } + return true; } } diff --git a/src/Tests/Moryx.Orders.Endpoints.Tests/ConvertOperationCreationModel.cs b/src/Tests/Moryx.Orders.Endpoints.Tests/ConvertOperationCreationModel.cs index a10e191caa..87e8d9ddb4 100644 --- a/src/Tests/Moryx.Orders.Endpoints.Tests/ConvertOperationCreationModel.cs +++ b/src/Tests/Moryx.Orders.Endpoints.Tests/ConvertOperationCreationModel.cs @@ -3,9 +3,6 @@ using Moryx.Orders.Endpoints.Models; using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Linq; namespace Moryx.Orders.Endpoints.Tests; @@ -118,4 +115,4 @@ public void ConvertModel() public class DummyMaterialParameter : IMaterialParameter { public string Color { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/Advice/AdviceManagerTests.cs b/src/Tests/Moryx.Orders.Management.Tests/Advice/AdviceManagerTests.cs index 30b94f0caa..07fe9128e1 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/Advice/AdviceManagerTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/Advice/AdviceManagerTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; using Moq; using Moryx.Orders.Advice; using Moryx.Orders.Management.Advice; @@ -97,4 +95,4 @@ public void ExecutorShouldNotHandleOrderAdvice() _operationDataMock.Verify(o => o.Advice(It.IsAny()), Times.Once, "There should be an order advice at the OperationData"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/CountStrategy/DoNotReplaceScrapStrategyTests.cs b/src/Tests/Moryx.Orders.Management.Tests/CountStrategy/DoNotReplaceScrapStrategyTests.cs index e787f9d7d1..30ae75525f 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/CountStrategy/DoNotReplaceScrapStrategyTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/CountStrategy/DoNotReplaceScrapStrategyTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; @@ -111,4 +109,4 @@ private async Task CreateOperationData() operationData.Operation.Recipes.Add(new DummyRecipe()); return operationData; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/Integration/OperationFactoryMock.cs b/src/Tests/Moryx.Orders.Management.Tests/Integration/OperationFactoryMock.cs index ee7adc3c83..c4e35637ff 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/Integration/OperationFactoryMock.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/Integration/OperationFactoryMock.cs @@ -2,12 +2,11 @@ // Licensed under the Apache License, Version 2.0 using Moryx.Logging; -using Moryx.Notifications; using Moryx.Orders.Management.Assignment; namespace Moryx.Orders.Management.Tests; -internal class OperationFactoryMock : IOperationFactory +internal sealed class OperationFactoryMock : IOperationFactory { private readonly IModuleLogger _logger; private readonly IJobHandler _jobHandler; @@ -34,4 +33,4 @@ public IOperationData Create(IOperationSavingContext savingContext) public void Destroy(IOperationData operationData) { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/Integration/ProductionTests.cs b/src/Tests/Moryx.Orders.Management.Tests/Integration/ProductionTests.cs index ebef601339..4d9a4c2ae4 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/Integration/ProductionTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/Integration/ProductionTests.cs @@ -1,29 +1,23 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; using Moryx.AbstractionLayer.TestTools; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.TestTools; -using Moryx.StateMachines; -using Moryx.Threading; -using Moq; +using Moryx.Logging; using Moryx.Model.InMemory; using Moryx.Model.Repositories; -using Moryx.Notifications; using Moryx.Orders.Assignment; using Moryx.Orders.Management.Assignment; using Moryx.Orders.Management.Model; +using Moryx.StateMachines; +using Moryx.Threading; using Moryx.Users; using NUnit.Framework; -using Moryx.Logging; -using Microsoft.Extensions.Logging.Abstractions; namespace Moryx.Orders.Management.Tests; @@ -205,7 +199,9 @@ public async Task SimpleCompletedProduction() var readyCallback = new EventHandler(delegate (object _, OperationEventArgs args) { if (args.OperationData.State.Classification == OperationStateClassification.Ready) + { readyEvent.Set(); + } }); // Act @@ -341,4 +337,4 @@ private void AssertOperationEntity(IOperationData operationData) Assert.That(operationData.TotalAmount, Is.EqualTo(operationEntity.TotalAmount)); Assert.That(operationData.OrderData.Number, Is.EqualTo(operationEntity.Order.Number)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/NullOperationSavingContext.cs b/src/Tests/Moryx.Orders.Management.Tests/NullOperationSavingContext.cs index dd6a78ca8c..78a600d74f 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/NullOperationSavingContext.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/NullOperationSavingContext.cs @@ -1,11 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; - namespace Moryx.Orders.Management.Tests; -internal class NullOperationSavingContext : IOperationSavingContext +internal sealed class NullOperationSavingContext : IOperationSavingContext { public Task SaveOperation(IOperationData operationData) { diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/DocumentAssignStepTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/DocumentAssignStepTests.cs index e2625cccac..4b86c6da30 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/DocumentAssignStepTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/DocumentAssignStepTests.cs @@ -1,20 +1,15 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using System.Runtime.InteropServices; +using Moq; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.TestTools; using Moryx.Logging; -using Moq; using Moryx.Orders.Assignment; using Moryx.Orders.Documents; using Moryx.Orders.Management.Assignment; using NUnit.Framework; -using System.Runtime.InteropServices; -using System.Threading; namespace Moryx.Orders.Management.Tests; @@ -43,7 +38,9 @@ public void TestSetup() public void Setup() { if (Directory.Exists(_materialDataFolder)) + { Directory.Delete(_materialDataFolder, true); + } _documentLoaderMock = new Mock(); var documentProviderConfig = new DocumentsConfig @@ -142,4 +139,4 @@ public async Task RestoreDocuments() // Assert Assert.That(_operation.Documents.Count, Is.EqualTo(1)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/OperationAssignmentTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/OperationAssignmentTests.cs index 69df511b1f..120a86207a 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/OperationAssignmentTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/OperationAssignmentTests.cs @@ -1,15 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading; -using System.Threading.Tasks; -using Moryx.Logging; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Moq; +using Moryx.Logging; using Moryx.Orders.Management.Assignment; using NUnit.Framework; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Logging; namespace Moryx.Orders.Management.Tests; @@ -197,4 +194,4 @@ public void OperationLoggerShouldHoldLogMessages() Assert.That(logger, Is.Not.Null); Assert.That(logger.Messages.Count, Is.EqualTo(2)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/ProductRecipeAssignStepTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/ProductRecipeAssignStepTests.cs index 9ca78e7f3b..fa85c8beea 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/ProductRecipeAssignStepTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationAssignmet/ProductRecipeAssignStepTests.cs @@ -1,21 +1,16 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; using Moryx.AbstractionLayer.Products; using Moryx.AbstractionLayer.Recipes; using Moryx.AbstractionLayer.TestTools; -using Moryx.ControlSystem.TestTools; -using Moq; using Moryx.ControlSystem.Jobs; +using Moryx.ControlSystem.TestTools; +using Moryx.Logging; using Moryx.Orders.Management.Assignment; using NUnit.Framework; -using Moryx.Logging; -using Microsoft.Extensions.Logging.Abstractions; namespace Moryx.Orders.Management.Tests; @@ -298,4 +293,4 @@ public void ShouldInvokeRecipeChange(long templateId) // Assert runningOperationDataMock.Verify(o => o.RecipeChanged(recipe), Times.Once, "There should be an operation depending recipe change"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataAdviceTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataAdviceTests.cs index 8e30216e7d..dc9435dea7 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataAdviceTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataAdviceTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading.Tasks; using NUnit.Framework; namespace Moryx.Orders.Management.Tests; @@ -62,4 +60,4 @@ public async Task ShouldThrowExceptionForNegativeAmountToAdvice() Assert.Throws(() => operationData.Advice(advice), "Negative amount should not be adviced"); Assert.That(operationData.Operation.Advices.Count, Is.EqualTo(0), "There should be no stored advices"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataCreateTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataCreateTests.cs index f1705d6e62..a94198d6ab 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataCreateTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataCreateTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; using Moq; using Moryx.Users; using NUnit.Framework; @@ -55,4 +54,4 @@ public async Task ValidateBeginContextAfterCreation() Assert.That(beginContext.ScrapCount, Is.EqualTo(0)); Assert.That(beginContext.ResidualAmount, Is.EqualTo(amount)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataProductionTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataProductionTests.cs index f6830fcec6..b8c5d9c3ed 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataProductionTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataProductionTests.cs @@ -1,13 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; -using System.Threading.Tasks; -using Moryx.ControlSystem.Jobs; using Moq; using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Recipes; +using Moryx.ControlSystem.Jobs; using NUnit.Framework; namespace Moryx.Orders.Management.Tests; @@ -116,7 +113,7 @@ public async Task Adjust_WithCompletedOperationAndNegativeAmount_Throws() [Test(Description = "If an operation is running or interrupting the target " + "amount can be reduced. A new job with the residual amount should be dispatched.")] - public async Task Adjust_WithNegativeAmountToOneRemaining_CompletesJobAndDispatchesNewForRemaining() + public async Task Adjust_WithNegativeAmountToOneRemaining_CompletesJobAndDispatchesNewForRemaining() { // Arrange var operationData = await GetRunningOperation(10, false, 10, 10); @@ -137,7 +134,7 @@ public async Task Adjust_WithNegativeAmountToOneRemaining_CompletesJobAndDispat [TestCase(8, 6, 2, 2, 0, 8, 2, Description = "Validate begin context without replace scrap: In this case, rework is equal to failure.")] [TestCase(8, 6, 2, 0, 2, 8, 2, Description = "Validate begin context without replace scrap: In this case, rework is less than failure.")] [TestCase(8, 0, 4, 2, 2, 8, 2, Description = "Validate begin context without replace scrap: In this case, rework failed.")] - public async Task ValidateBeginContextWithoutReplaceScrap(int targetAmount, int success, int failure, int reworked, int expScrap, int expPartial, int expResidual) + public async Task ValidateBeginContextWithoutReplaceScrap(int targetAmount, int success, int failure, int reworked, int expScrap, int expPartial, int expResidual) { // Arrange var operationData = await GetReadyOperation(10, false, 10, 10); @@ -164,7 +161,7 @@ public async Task ValidateBeginContextWithoutReplaceScrap(int targetAmount, int [TestCase(9, 9, 2, 5, 0, 9, 1, Description = "Validate begin context with replace scrap: In this case, there are more rework than failure.")] [TestCase(8, 8, 2, 2, 0, 8, 2, Description = "Validate begin context with replace scrap: In this case, rework is equal to failure.")] [TestCase(8, 8, 2, 0, 2, 8, 2, Description = "Validate begin context with replace scrap: In this case, rework is less than failure.")] - public async Task ValidateBeginContextWithReplaceScrap(int amount, int success, int failure, int reworked, int expScrap, int expPartial, int expResidual) + public async Task ValidateBeginContextWithReplaceScrap(int amount, int success, int failure, int reworked, int expScrap, int expPartial, int expResidual) { // Arrange var operationData = await GetReadyOperation(10, true, 10, 10); @@ -226,7 +223,7 @@ public async Task ValidateBeginContextWithReplaceScrap(int amount, int success, [Test(Description = "Validate begin context without replace scrap: In this case a job will be completed prematurely " + "but should be considered in the begin context")] - public async Task ValidateBeginContextWithPrematurelyCompletedJob() + public async Task ValidateBeginContextWithPrematurelyCompletedJob() { // Arrange var operationData = await GetReadyOperation(10, false, 10, 10); @@ -249,7 +246,7 @@ public async Task ValidateBeginContextWithPrematurelyCompletedJob() [Test(Description = "If a operation is interrupting, the worker should have the possibility " + "to begin the operation again. A new job with the residual amount should be dispatched.")] - public async Task BeginOperationWhileInterrupting() + public async Task BeginOperationWhileInterrupting() { // Arrange var operationData = await GetInterruptingOperation(10, false, 10, 10); @@ -278,7 +275,7 @@ public async Task BeginOperationWhileInterrupting() [Test(Description = "If a operation is interrupted, the worker should have the possibility " + "to begin the operation again. A new job should be dispatched.")] - public async Task BeginOperationWhileInterrupted() + public async Task BeginOperationWhileInterrupted() { // Arrange var operationData = await GetInterruptedOperation(10, false, 10, 10); @@ -296,7 +293,7 @@ public async Task BeginOperationWhileInterrupted() [Test(Description = "If a operation is interrupted, the worker should have the possibility " + "to begin the operation with an amount of zero to start the operation.")] - public async Task BeginOperationWhileInterruptedWithAmountOfZero() + public async Task BeginOperationWhileInterruptedWithAmountOfZero() { // Arrange var operationData = await GetInterruptedOperation(10, false, 10, 10); @@ -370,7 +367,7 @@ public async Task ReachAmountWithFailureParts() [TestCase(3, 0, Description = "Will simulate replacing scrap if parts fail in completing job.")] [TestCase(0, 2, Description = "Will simulate replacing scrap if parts are predicted to fail in completing job.")] [TestCase(2, 1, Description = "Will simulate replacing scrap if parts failed and are predicted to fail in completing job.")] - public async Task ReplaceScrapWhileRunning(int failure, int predictedFailure) + public async Task ReplaceScrapWhileRunning(int failure, int predictedFailure) { var targetAmount = 10; // Arrange @@ -400,7 +397,7 @@ public async Task ReplaceScrapWhileRunning(int failure, int predictedFailure) } [Test(Description = "Will simulate replacing scrap if a part fails in completing scrap job.")] - public async Task ReplaceScrapOfScrapJobWhileRunning() + public async Task ReplaceScrapOfScrapJobWhileRunning() { // Arrange var operationData = await GetRunningOperation(10, true, 10, 10); @@ -446,7 +443,7 @@ public async Task ReplaceScrapOfScrapJobWhileRunning() } [Test(Description = "Will interrupt a running operation. Jobs should be complete.")] - public async Task InterruptWhileRunning() + public async Task InterruptWhileRunning() { // Arrange var operationData = await GetRunningOperation(10, false, 10, 10); @@ -465,7 +462,7 @@ public async Task InterruptWhileRunning() } [Test(Description = "Operation should be interrupted if all jobs are completed while interrupting.")] - public async Task JobCompletionWhileInterrupting() + public async Task JobCompletionWhileInterrupting() { // Arrange var operationData = await GetInterruptingOperation(10, false, 10, 10); @@ -481,4 +478,4 @@ public async Task JobCompletionWhileInterrupting() Assert.That(operationData.State.CanInterrupt, Is.False); Assert.ThrowsAsync(() => operationData.Interrupt(User)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataReportTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataReportTests.cs index 6304220f0a..834cd0b509 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataReportTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataReportTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; -using System.Threading.Tasks; using Moq; using Moryx.ControlSystem.Jobs; using NUnit.Framework; @@ -401,4 +398,4 @@ public async Task ValidateReportContextWithStartedJobAfterReport() Assert.That(reportContext.UnreportedSuccess, Is.EqualTo(0)); Assert.That(reportContext.UnreportedFailure, Is.EqualTo(0)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataRestoreTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataRestoreTests.cs index 487c4d547c..28bd235fc4 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataRestoreTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataRestoreTests.cs @@ -1,12 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Moryx.ControlSystem.Jobs; using Moq; +using Moryx.ControlSystem.Jobs; using Moryx.Model.InMemory; using Moryx.Model.Repositories; using Moryx.Orders.Management.Model; @@ -77,9 +73,15 @@ public async Task RestoreReady() Assert.That(operationData.State.CanAdvice); Assert.That(operationData.State.CanInterrupt, Is.False); if (operationData.Operation.Start != null) + { Assert.That(operationData.Operation.Start?.Kind, Is.EqualTo(DateTimeKind.Utc)); + } + if (operationData.Operation.End != null) + { Assert.That(operationData.Operation.End?.Kind, Is.EqualTo(DateTimeKind.Utc)); + } + Assert.That(operationData.Operation.PlannedStart.Kind, Is.EqualTo(DateTimeKind.Utc)); Assert.That(operationData.Operation.PlannedEnd.Kind, Is.EqualTo(DateTimeKind.Utc)); } @@ -311,4 +313,4 @@ private async Task ReloadFromDatabase(long operationId, bool rep return operationData; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataTestBase.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataTestBase.cs index ca359190e4..a124ec3565 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataTestBase.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationData/OperationDataTestBase.cs @@ -1,21 +1,16 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using Moryx.AbstractionLayer.Processes; +using Moryx.AbstractionLayer.Recipes; using Moryx.ControlSystem.Jobs; using Moryx.ControlSystem.TestTools; using Moryx.Logging; -using Moq; -using Moryx.AbstractionLayer.Recipes; -using Moryx.Notifications; using Moryx.Orders.Management.Assignment; using Moryx.Users; using NUnit.Framework; -using Microsoft.Extensions.Logging.Abstractions; -using Moryx.AbstractionLayer.Processes; namespace Moryx.Orders.Management.Tests; @@ -62,7 +57,7 @@ public virtual void SetUp() JobHandlerMock.Setup(d => d.Dispatch(It.IsAny(), It.IsAny>())).Callback(dispatchDelegate); } - internal class TestJob : Job, IPredictiveJob + internal sealed class TestJob : Job, IPredictiveJob { public TestJob(IRecipe recipe, int amount) : base(recipe, amount) { @@ -185,4 +180,4 @@ internal async Task GetCompletedOperation(int amount, bool repla return operationData; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationDispatcher/SingleJobOperationDispatcherTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationDispatcher/SingleJobOperationDispatcherTests.cs index eb3aed6434..ec506a67f9 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationDispatcher/SingleJobOperationDispatcherTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationDispatcher/SingleJobOperationDispatcherTests.cs @@ -1,10 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Recipes; @@ -190,4 +186,4 @@ public void RestoreAddsJobsToOperation() Assert.That(restored.SequenceEqual(jobs), "The job handler should restore the jobs for all given ids"); _jobManagementMock.Verify(j => j.Get(It.IsAny()), Times.Exactly(2), "The job management facade should be called once for each job"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationNotifications/OperationNotificationsTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationNotifications/OperationNotificationsTests.cs index 4684e107a9..493cdaca68 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationNotifications/OperationNotificationsTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationNotifications/OperationNotificationsTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; using Moq; using Moryx.Notifications; using Moryx.Orders.Management.Notifications; @@ -112,7 +109,9 @@ public void PublishAmountReachedNotificationOnStart(bool amountReachedInPool, in List operations = [otherOperationMock.Object]; if (amountReachedInPool) + { operations.Add(amountReachedOperationMock.Object); + } _operationDataPoolMock.Setup(p => p.GetAll(It.IsAny>())) .Returns((Func filter) => operations.Where(filter).ToArray()); diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationPool/OperationPoolTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationPool/OperationPoolTests.cs index 6f9466b530..33a9a48d1a 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationPool/OperationPoolTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationPool/OperationPoolTests.cs @@ -1,10 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.ControlSystem.Jobs; @@ -290,7 +286,9 @@ private async Task> InitializeOperation(string operationNum .Returns(mock.Object); if (startOperationPool) + { await operationDataPool.StartAsync(); + } await operationDataPool.Add(context, new NullOperationSource()); mock.SetupGet(op => op.State).Returns(new ReadyState(null, null)); @@ -371,4 +369,4 @@ public DummyMaterialParameter(string key, string value) public string Key { get; } public string Value { get; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/NullOperationValidationTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/NullOperationValidationTests.cs index 6078157c48..1cb592c3e3 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/NullOperationValidationTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/NullOperationValidationTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; using Moq; using Moryx.Orders.Assignment; using Moryx.Orders.Management.Assignment; @@ -44,4 +42,4 @@ public async Task ValidateCreationContextNull() // Assert Assert.That(result, "There should be a successful validation"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/RegexOperationValidationTests.cs b/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/RegexOperationValidationTests.cs index 91b2bc233a..dea6d2e5c1 100644 --- a/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/RegexOperationValidationTests.cs +++ b/src/Tests/Moryx.Orders.Management.Tests/OperationValidation/RegexOperationValidationTests.cs @@ -1,11 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Moryx.AbstractionLayer.Recipes; using Moq; +using Moryx.AbstractionLayer.Recipes; using Moryx.Orders.Management.Assignment; using NUnit.Framework; @@ -164,4 +161,4 @@ public async Task ValidateOrderCreationContextWithBadOperationContext(string num // Assert Assert.That(result, Is.False, "There should be an unsuccessful validation"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/InfluxDbListenerV2Test.cs b/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/InfluxDbListenerV2Test.cs index 5e83be2cfb..c6a3bd63a2 100644 --- a/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/InfluxDbListenerV2Test.cs +++ b/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/InfluxDbListenerV2Test.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using Moq; using Moryx.Logging; -using Moryx.ProcessData.Listener; using Moryx.TestTools.UnitTest; using Moryx.Tools; using WireMock.RequestBuilders; diff --git a/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/Usings.cs b/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/Usings.cs index a8532bbdfc..9384fa47a8 100644 --- a/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/Usings.cs +++ b/src/Tests/Moryx.ProcessData.InfluxDbListener.Tests/Usings.cs @@ -1,4 +1,4 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -global using NUnit.Framework; \ No newline at end of file +global using NUnit.Framework; diff --git a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/CsvStructureTest.cs b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/CsvStructureTest.cs index 1b74236381..80c2a235d5 100644 --- a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/CsvStructureTest.cs +++ b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/CsvStructureTest.cs @@ -1,19 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Logging; -using NUnit.Framework; -using System; -using System.Collections.Generic; using System.Globalization; -using System.IO; -using System.Linq; -using System.Threading.Tasks; using CsvHelper; using CsvHelper.Configuration; +using Moq; +using Moryx.Logging; using Moryx.Tools; +using NUnit.Framework; using NUnit.Framework.Interfaces; -using Moq; namespace Moryx.ProcessData.SpreadsheetsListener.Tests; @@ -53,15 +48,16 @@ public void SetUp() [TearDown] public void TearDown() { - if (_csvStructure != null) - { - _csvStructure.Close(); - _csvStructure = null; - } + _csvStructure?.Close(); + _csvStructure = null; if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed) + { foreach (var file in _files) + { File.Delete(file); + } + } } [Test] @@ -82,9 +78,13 @@ public void ShouldCreateEmptyCsvFile() public async Task ShouldWriteOnlyHeader([Values(true, false)] bool compareOrder) { if (compareOrder) + { await WriteMeasurementsTwiceToCsvCompare(numOfMeasurements: 0); + } else + { await WriteMeasurementsToCsvCheckContent(numOfMeasurements: 0); + } } [Test] @@ -92,9 +92,13 @@ public async Task ShouldWriteOnlyOneMeasurementToLastCsv([Values(true, false)] b { var numOfMeasurements = 1 + (maxNumOfRowsPerFile - 1) * (numOfFiles - 1); if (compareOrder) + { await WriteMeasurementsTwiceToCsvCompare(overwriteHeader, numOfMeasurements, numOfFiles); + } else + { await WriteMeasurementsToCsvCheckContent(overwriteHeader, numOfMeasurements, numOfFiles, maxNumOfRowsPerFile); + } } [Test] @@ -102,9 +106,13 @@ public async Task ShouldWriteMaxMinusOneMeasurementsToLastCsv([Values(true, fals { var numOfMeasurements = (maxNumOfRowsPerFile - 1) * numOfFiles - 1; if (compareOrder) + { await WriteMeasurementsTwiceToCsvCompare(overwriteHeader, numOfMeasurements, numOfFiles); + } else + { await WriteMeasurementsToCsvCheckContent(overwriteHeader, numOfMeasurements, numOfFiles, maxNumOfRowsPerFile); + } } [Test] @@ -112,19 +120,26 @@ public async Task ShouldWriteMaxMeasurementsToLastCsv([Values(true, false)] bool { var numOfMeasurements = (maxNumOfRowsPerFile - 1) * numOfFiles; if (compareOrder) + { await WriteMeasurementsTwiceToCsvCompare(overwriteHeader, numOfMeasurements, numOfFiles); + } else + { await WriteMeasurementsToCsvCheckContent(overwriteHeader, numOfMeasurements, numOfFiles, maxNumOfRowsPerFile); + } } [Test] public async Task ShouldWriteMeasurementsToCsv([Values(true, false)] bool compareOrder, [Values(true, false)] bool overwriteHeader, [Random(5000, 15000, 1)] int numOfMeasurements, [Values(1, 2, 3)] int numOfFiles) { if (compareOrder) + { await WriteMeasurementsTwiceToCsvCompare(overwriteHeader, numOfMeasurements, numOfFiles); + } else + { await WriteMeasurementsToCsvCheckContent(overwriteHeader, numOfMeasurements, numOfFiles); - + } } public async Task WriteMeasurementsTwiceToCsvCompare(bool addOrRemoveRandom = false, int numOfMeasurements = 0, int numOfFiles = 1, int maxNumOfRowsPerFile = -1) @@ -133,7 +148,10 @@ public async Task WriteMeasurementsTwiceToCsvCompare(bool addOrRemoveRandom = fa Measurement firstMeasurement = RandomMeasurement(_random.Next(0, 8), _random.Next(0, 8)); List randomMeasurements = [firstMeasurement]; if (maxNumOfRowsPerFile < 0) // unless maxNumOfRowsPerFile was specified, every file (except possibly the last one) has the same number of rows + { maxNumOfRowsPerFile = (int)Math.Ceiling(1 + (double)numOfMeasurements / numOfFiles); + } + _slConfig.MaxNumOfRows = maxNumOfRowsPerFile; // Act @@ -144,11 +162,16 @@ public async Task WriteMeasurementsTwiceToCsvCompare(bool addOrRemoveRandom = fa Measurement newRndMeasurement = RandomMeasurement(basedOn: firstMeasurement); await _csvStructure.AddMeasurement(newRndMeasurement); if (_random.NextDouble() < 0.1) // write rows at random and not after every measurement + { await _csvStructure.WriteRows(); + } + randomMeasurements.Add(newRndMeasurement); } if (numOfMeasurements > 0) + { await _csvStructure.WriteRows(); + } // Assert AssertFilesAreValid(); @@ -169,7 +192,9 @@ public async Task WriteMeasurementsTwiceToCsvCompare(bool addOrRemoveRandom = fa await _csvStructure.AddMeasurement(randomMeasurements[i]); } if (numOfMeasurements > 0) + { await _csvStructure.WriteRows(); + } // Assert AssertFilesAreValid(); @@ -190,7 +215,10 @@ private async Task WriteMeasurementsToCsvCheckContent(bool triggerOverwritingHea var headingsOfFirstMeasurement = GetNames(firstMeasurement); if (maxNumOfRowsPerFile < 0) // unless maxNumOfRowsPerFile was specified, every file (except possibly the last one) has the same number of rows + { maxNumOfRowsPerFile = (int)Math.Ceiling(1 + (double)numOfMeasurements / numOfFiles); + } + _slConfig.MaxNumOfRows = maxNumOfRowsPerFile; var expectedNumOfRows = maxNumOfRowsPerFile; @@ -214,10 +242,14 @@ private async Task WriteMeasurementsToCsvCheckContent(bool triggerOverwritingHea randomMeasurements.Add(newRndMeasurement); await _csvStructure.AddMeasurement(newRndMeasurement); if (_random.NextDouble() < 0.1) // write rows at random and not after every measurement + { await _csvStructure.WriteRows(); + } } if (numOfMeasurements > 0) + { await _csvStructure.WriteRows(); + } // Assert AssertFilesAreValid(); @@ -226,7 +258,9 @@ private async Task WriteMeasurementsToCsvCheckContent(bool triggerOverwritingHea for (var fileIndex = 0; fileIndex < _files.Length; fileIndex++) { if (fileIndex == _files.Length - 1) // last file is possibly not maxed out + { expectedNumOfRows = 1 + numOfMeasurements - numOfValidatedMeasurements; + } var actualWrittenCsv = ReadInCsv(_files[fileIndex]); var actualWrittenHeader = actualWrittenCsv[0]; @@ -248,7 +282,9 @@ private async Task WriteMeasurementsToCsvCheckContent(bool triggerOverwritingHea var expectedValues = GetValues(toBeTestedMeasurement); everyFieldAndTag = expectedValues.All(h => actualWrittenCsv[i].Contains(h)); if (!everyFieldAndTag) + { break; + } } Assert.That(everyFieldAndTag, "File does not contain every field or tag of at least one measurement"); @@ -268,13 +304,13 @@ private void AddOrRemoveRandomFieldOrTag(Measurement measurement) { // remove random field editedFields.RemoveAt(_random.Next(0, editedFields.Count)); editedFields.ForEach(f => editedMeasurement.Add(new DataField(f.Name, f.Value))); - measurement.Tags.ForEach(t => editedMeasurement.Add(t)); + measurement.Tags.ForEach(editedMeasurement.Add); } else if (editedTags.Count > 0) { // remove random tag editedTags.RemoveAt(_random.Next(0, editedTags.Count)); editedTags.ForEach(t => editedMeasurement.Add(new DataTag(t.Name, t.Value))); - measurement.Fields.ForEach(f => editedMeasurement.Add(f)); + measurement.Fields.ForEach(editedMeasurement.Add); } else { @@ -284,20 +320,31 @@ private void AddOrRemoveRandomFieldOrTag(Measurement measurement) measurement = editedMeasurement; } else + { AddRandomFieldOrTag(measurement, 0.5); + } } private void AddRandomFieldOrTag(Measurement measurement, double fieldProbability, string name = null, string value = null) { if (name == null) + { name = NewGuidString(); + } + if (value == null) + { value = NewGuidString(); + } if (_random.NextDouble() < fieldProbability) + { measurement.Add(new DataField(name, value)); + } else + { measurement.Add(new DataTag(name, value)); + } } public void AssertCsvIsValidResult(string[] originalFiles, string[] resultFiles, IList measurements) @@ -328,12 +375,18 @@ public void AssertCsvIsValidResult(string[] originalFiles, string[] resultFiles, { var valueInFirstCsv = firstWrittenCsv[row][col]; if (!string.IsNullOrEmpty(valueInSecondCsv)) // values in both CSV files should be the same in this case + { Assert.That(valueInFirstCsv, Is.EqualTo(valueInSecondCsv), $"Values in row {row + 1} column {col + 1} are not equal in both files"); + } else // value was removed before writing to second CSV, should not be empty in first CSV + { Assert.That(string.IsNullOrEmpty(valueInFirstCsv), Is.False, $"Value in row {row + 1} column {col + 1} is null or empty in file {originalFiles[fileIndex]}"); + } } else // value should be null because the header was overwritten but no corresponding value was inserted + { Assert.That(string.IsNullOrEmpty(valueInSecondCsv), $"Value in row {row + 1} column {col + 1} is not null or empty"); + } } else { @@ -376,7 +429,9 @@ private void AssertFilesAreValid() Assert.That(IsFileLocked(_fileInfo), Is.False, "Stream should be closed but file was not accessible"); } else + { Assert.That(IsFileLocked(_fileInfo), Is.False, "Stream should be closed after new file was created but file was not accessible"); + } } } @@ -403,7 +458,9 @@ private static bool IsFileLocked(FileInfo file) try { using (FileStream stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None)) + { stream.Close(); + } } catch (IOException) { return true; } return false; @@ -456,4 +513,4 @@ private List> ReadInCsv(string absolutePath) } return result; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/SpreadsheetsListenerTest.cs b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/SpreadsheetsListenerTest.cs index 22e72ad0ee..06dc751900 100644 --- a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/SpreadsheetsListenerTest.cs +++ b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/SpreadsheetsListenerTest.cs @@ -1,22 +1,18 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Logging; -using Moryx.TestTools.UnitTest; -using NUnit.Framework; -using System; -using System.Collections.Generic; using System.Globalization; -using System.IO; -using System.Linq; using CsvHelper; using CsvHelper.Configuration; using Microsoft.Extensions.Logging.Abstractions; +using Moryx.Logging; +using Moryx.TestTools.UnitTest; +using NUnit.Framework; namespace Moryx.ProcessData.SpreadsheetsListener.Tests; [TestFixture] -class SpreadsheetsListenerTest +sealed class SpreadsheetsListenerTest { private SpreadsheetsListener _spreadsheetsListener; private readonly string _path = Path.Combine(Path.GetTempPath(), nameof(CsvStructure)); @@ -120,7 +116,9 @@ public void ShouldWriteTwoFilesWithSameContent() Assert.That(firstFileContent, Has.Count.EqualTo(secondFileContent.Count), "Files do not have the same number of rows"); for (int i = 0; i < firstFileContent.Count; i++) + { Assert.That(firstFileContent[i].SequenceEqual(secondFileContent[i]), $"Row {i} was modified"); + } } [Test] @@ -173,7 +171,9 @@ public void ShouldOverwriteHeader() Assert.That(changedHdrFileContent[0].SequenceEqual(ogHeader.Concat(new List() { "A", "C" })), "Header was not changed properly"); for (int i = 1; i < ogFileContent.Count; i++) + { Assert.That(changedHdrFileContent[i].SequenceEqual(ogFileContent[i]), $"Row {i} was modified"); + } var lastRowValid = changedHdrFileContent[numOfMeasurements] .GetRange(ogHeader.Count - 2, 4) diff --git a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/TestDirectory.cs b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/TestDirectory.cs index 648dc7d680..cfc2f6df75 100644 --- a/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/TestDirectory.cs +++ b/src/Tests/Moryx.ProcessData.SpreadsheetsListener.Tests/TestDirectory.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.IO; -using System.Linq; - namespace Moryx.ProcessData.SpreadsheetsListener.Tests; internal static class TestDirectory @@ -14,4 +11,4 @@ internal static string[] GetOrderedFiles(string path, string searchPattern) .OrderBy(s => s) .ToArray(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ProcessData.Tests/MeasurementBindingProcessorTests.cs b/src/Tests/Moryx.ProcessData.Tests/MeasurementBindingProcessorTests.cs index d7ae887df4..a0227ae98d 100644 --- a/src/Tests/Moryx.ProcessData.Tests/MeasurementBindingProcessorTests.cs +++ b/src/Tests/Moryx.ProcessData.Tests/MeasurementBindingProcessorTests.cs @@ -1,11 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; +using Moq; using Moryx.Bindings; using Moryx.ProcessData.Bindings; using Moryx.ProcessData.Configuration; -using Moq; using NUnit.Framework; namespace Moryx.ProcessData.Tests; @@ -73,4 +72,4 @@ private static IEnumerable CreateBindingConfiguration() } ]; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.ProcessData.Tests/ProcessDataListenerTests.cs b/src/Tests/Moryx.ProcessData.Tests/ProcessDataListenerTests.cs index 280f50e594..83e93eecc8 100644 --- a/src/Tests/Moryx.ProcessData.Tests/ProcessDataListenerTests.cs +++ b/src/Tests/Moryx.ProcessData.Tests/ProcessDataListenerTests.cs @@ -1,12 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moq.Protected; +using Moryx.Logging; using Moryx.ProcessData.Listener; using NUnit.Framework; -using Moryx.Logging; -using Microsoft.Extensions.Logging.Abstractions; namespace Moryx.ProcessData.Tests; @@ -56,4 +56,4 @@ public void ConfiguredMeasurementShouldNotBeIgnored() // Assert _listenerMock.Protected().Verify("OnMeasurementAdded", Times.Once(), ItExpr.IsAny()); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Products.IntegrationTests/FloatColumnMapperTests.cs b/src/Tests/Moryx.Products.IntegrationTests/FloatColumnMapperTests.cs index c5f140fd5c..6750dd8fba 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/FloatColumnMapperTests.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/FloatColumnMapperTests.cs @@ -56,7 +56,7 @@ private static IGenericColumns CreateColumns() return mock.Object; } - private class TestObject(double value = 0) + private sealed class TestObject(double value = 0) { public double Value { get; set; } = value; } diff --git a/src/Tests/Moryx.Products.IntegrationTests/ProductStorageTests.cs b/src/Tests/Moryx.Products.IntegrationTests/ProductStorageTests.cs index e16fc40bef..0935845644 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/ProductStorageTests.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/ProductStorageTests.cs @@ -1,11 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; +using System.Numerics; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Identity; @@ -16,7 +12,6 @@ using Moryx.Model.Repositories; using Moryx.Products.Management; using Moryx.Products.Management.Model; -using System.Numerics; using Moryx.Products.Management.NullStrategies; using Moryx.Products.Samples; using Moryx.Products.Samples.Recipe; diff --git a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/RecipeStorageTests.cs b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/RecipeStorageTests.cs index a0119e6cc6..fa4ca10296 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/RecipeStorageTests.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/RecipeStorageTests.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Drawing; -using System.Linq; -using System.Threading.Tasks; using Moq; using Moryx.AbstractionLayer.Recipes; using Moryx.Model.InMemory; @@ -144,4 +142,4 @@ private static Workplan CreateWorkplan() return workplan; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskA.cs b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskA.cs index 0dc0ca3c77..4b473877f9 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskA.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskA.cs @@ -41,4 +41,4 @@ protected override ActivityResult CreateFailureResult() { throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskB.cs b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskB.cs index 281c3815e4..9752e11878 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskB.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/RecipeStorage/TaskB.cs @@ -48,4 +48,4 @@ protected override ActivityResult CreateFailureResult() { throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Products.IntegrationTests/StrategyConfigurationAttributeTests.cs b/src/Tests/Moryx.Products.IntegrationTests/StrategyConfigurationAttributeTests.cs index 8811de607f..e284b4c9a0 100644 --- a/src/Tests/Moryx.Products.IntegrationTests/StrategyConfigurationAttributeTests.cs +++ b/src/Tests/Moryx.Products.IntegrationTests/StrategyConfigurationAttributeTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Products.Management; using NUnit.Framework; @@ -37,7 +36,7 @@ private class SomeType { } - private class SomeInheritedType : SomeType + private sealed class SomeInheritedType : SomeType { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResource.cs index 98993c89ef..2fe8b30725 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResource.cs @@ -9,4 +9,4 @@ public override int MultiplyFoo(int factor) { return Foo *= factor + 1; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResourceWithNewProxy.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResourceWithNewProxy.cs index 7e2335f98a..2a08680a70 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResourceWithNewProxy.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/DerivedResourceWithNewProxy.cs @@ -16,4 +16,4 @@ public override int MultiplyFoo(int factor) { return Foo *= factor + 2; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ExplicitEventResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ExplicitEventResource.cs index 06b77a15c9..0a3ac65932 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ExplicitEventResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ExplicitEventResource.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Resources; namespace Moryx.Resources.Management.Tests; diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/InterferenceResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/InterferenceResource.cs index 45777e94cb..3d8281319a 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/InterferenceResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/InterferenceResource.cs @@ -15,4 +15,4 @@ public class InterferenceResource : Resource [ResourceReference(ResourceRelationType.CurrentExchangeablePart)] public DifferentResource Different { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/NonPublicResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/NonPublicResource.cs index 6728620da5..2c459a6f6c 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/NonPublicResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/NonPublicResource.cs @@ -11,4 +11,4 @@ public interface INonPublicResource : IResource public class NonPublicResource : Resource, INonPublicResource { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/OtherResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/OtherResource.cs index 000bb2499a..c4b3225a70 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/OtherResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/OtherResource.cs @@ -11,4 +11,4 @@ public class OtherResource : Resource public class DifferentResource : Resource { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ReferenceResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ReferenceResource.cs index 2a07620521..e4541fff7c 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ReferenceResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ReferenceResource.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Moryx.AbstractionLayer.Resources; namespace Moryx.Resources.Management.Tests; @@ -99,7 +96,9 @@ public void SetReference(ISimpleResource reference) public void SetMany(IReadOnlyList references) { foreach (var reference in references) + { References.Add(reference); + } } public INonPublicResource NonPublic { get; set; } @@ -113,4 +112,4 @@ public class BidirectionalReferenceResource : Resource { [ResourceReference(ResourceRelationType.Extension, ResourceReferenceRole.Source, nameof(SourceReference))] public ReferenceResource SourceReference { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithGenericMethod.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithGenericMethod.cs index 7e0f11bfc1..fc6a3e4938 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithGenericMethod.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithGenericMethod.cs @@ -3,8 +3,6 @@ using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Resources; -using System; -using System.Collections.Generic; namespace Moryx.Resources.Management.Tests; @@ -46,4 +44,4 @@ public interface IGenericBaseResourceInterface : IResource { } public class GenericBaseResource : Resource, IGenericBaseResourceInterface { } -public class InheritingFromGenericResource : GenericBaseResource { } \ No newline at end of file +public class InheritingFromGenericResource : GenericBaseResource { } diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithImplicitApi.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithImplicitApi.cs index b422e71ab8..bf873c3b2e 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithImplicitApi.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/ResourceWithImplicitApi.cs @@ -21,4 +21,4 @@ public int Add(int value) { return value + 10; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/SharedEventNameResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/SharedEventNameResource.cs index 74d9b330b9..0f679e8d63 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/SharedEventNameResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/SharedEventNameResource.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Resources; namespace Moryx.Resources.Management.Tests; diff --git a/src/Tests/Moryx.Resources.Management.Tests/Mocks/SimpleResource.cs b/src/Tests/Moryx.Resources.Management.Tests/Mocks/SimpleResource.cs index 11969ca802..7018032733 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/Mocks/SimpleResource.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/Mocks/SimpleResource.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Resources; diff --git a/src/Tests/Moryx.Resources.Management.Tests/ResourceEntityAccessorTests.cs b/src/Tests/Moryx.Resources.Management.Tests/ResourceEntityAccessorTests.cs index 5867c8df1e..392ce70a53 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/ResourceEntityAccessorTests.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/ResourceEntityAccessorTests.cs @@ -1,17 +1,15 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.ComponentModel; using System.Runtime.Serialization; -using Moryx.AbstractionLayer.Resources; -using Moryx.Serialization; using Moq; +using Moryx.AbstractionLayer.Resources; using Moryx.Model.Repositories; +using Moryx.Resources.Management.Model; +using Moryx.Serialization; using Newtonsoft.Json; using NUnit.Framework; -using System.ComponentModel; -using System.Threading.Tasks; -using Moryx.Resources.Management.Model; -using System.Collections.Generic; namespace Moryx.Resources.Management.Tests; @@ -53,8 +51,7 @@ public void InstantiateWithoutEntitySetsDefaults() Assert.That(resource.Enabled); Assert.That(resource.Number, Is.EqualTo(42)); } - - + [Test(Description = "Calling Instantiate on a type that holds ignored properties does not override these properties")] public void InstantiateWithoutEntityDoesNotOverrideIgnoredJsonProperties() { @@ -156,26 +153,26 @@ private class ExtensionDataTestBase #pragma warning restore CA1822 // Mark members as static } - private class ExtensionDataInherited : ExtensionDataTestBase + private sealed class ExtensionDataInherited : ExtensionDataTestBase { #pragma warning disable CA1822 // Mark members as static public long Value3 => 42; #pragma warning restore CA1822 // Mark members as static } - private class DefaultTestResource : Resource + private sealed class DefaultTestResource : Resource { [DataMember, DefaultValue(42)] public int Number { get; set; } [DataMember, DefaultValue(true)] public bool Enabled { get; set; } - - [DataMember, JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - public List InitializedProperty { get; set; } = []; + + [DataMember, JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public List InitializedProperty { get; set; } = []; } - private class TestResource : Resource + private sealed class TestResource : Resource { [DataMember] public ExtensionDataTestBase Data { get; set; } diff --git a/src/Tests/Moryx.Resources.Management.Tests/ResourceLinkerTests.cs b/src/Tests/Moryx.Resources.Management.Tests/ResourceLinkerTests.cs index 03e1076048..ceb797d18b 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/ResourceLinkerTests.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/ResourceLinkerTests.cs @@ -1,18 +1,14 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Moryx.AbstractionLayer.Resources; -using Moq; -using Moryx.Model.Repositories; -using NUnit.Framework; using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using Moryx.AbstractionLayer.Resources; using Moryx.Logging; +using Moryx.Model.Repositories; using Moryx.Resources.Management.Model; +using NUnit.Framework; namespace Moryx.Resources.Management.Tests; @@ -436,15 +432,24 @@ public void CheckRequiredReference(bool isNull, bool isEmpty) // Act if (!isNull) + { instance.Reference = reference; + } + if (!isEmpty) + { instance.References.Add(reference); + } // Assert if (isNull || isEmpty) + { Assert.ThrowsAsync(() => _linker.SaveReferencesAsync(dbMocks.Item1.Object, instance, new ResourceEntity())); + } else + { Assert.DoesNotThrowAsync(() => _linker.SaveReferencesAsync(dbMocks.Item1.Object, instance, new ResourceEntity())); + } } private static Tuple, Mock, Mock> SetupDbMocks(List relations) diff --git a/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerSqliteTests.cs b/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerSqliteTests.cs index 627e626696..9fc69ec25c 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerSqliteTests.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerSqliteTests.cs @@ -1,10 +1,10 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Model.Repositories; -using NUnit.Framework; using Moryx.AbstractionLayer.TestTools; +using Moryx.Model.Repositories; using Moryx.Resources.Management.Model; +using NUnit.Framework; namespace Moryx.Resources.Management.Tests; @@ -19,4 +19,4 @@ protected override UnitOfWorkFactory BuildUnitOfWorkFactory() return uowFactory; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerTests.cs b/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerTests.cs index eb57d5c506..4512997c41 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerTests.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/ResourceManagerTests.cs @@ -1,10 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.AbstractionLayer.Capabilities; @@ -13,7 +9,6 @@ using Moryx.Logging; using Moryx.Model.InMemory; using Moryx.Model.Repositories; -using Moryx.Notifications; using Moryx.Resources.Management.Model; using NUnit.Framework; @@ -52,8 +47,8 @@ public void Setup() .ReturnsAsync(Array.Empty()); _initializerMock = new Mock(); - _initializerMock.Setup(i => i.ExecuteAsync(It.IsAny(), It.IsAny(),It.IsAny())) - .ReturnsAsync(new ResourceInitializerResult { InitializedResources = [_resourceMock]}); + _initializerMock.Setup(i => i.ExecuteAsync(It.IsAny(), It.IsAny(), It.IsAny())) + .ReturnsAsync(new ResourceInitializerResult { InitializedResources = [_resourceMock] }); _linkerMock.Setup(l => l.SaveRootsAsync(It.IsAny(), It.IsAny>())) .ReturnsAsync([_resourceMock]); _linkerMock.Setup(l => l.SaveReferencesAsync(It.IsAny(), It.IsAny(), It.IsAny(), @@ -278,7 +273,6 @@ public async Task DontRaiseResourceChangesOnAdded() Assert.That(notifications, Is.EqualTo(0)); } - [Test(Description = "Adds a resource while the ResourceManager was initialized but not started")] public async Task AddResourceWhileInitializedDoesNotStartResource() { @@ -370,7 +364,7 @@ public void RaiseChanged() } } - private class PublicResourceMock : ResourceMockBase, IResource, IReferenceResource + private sealed class PublicResourceMock : ResourceMockBase, IResource, IReferenceResource { public ICapabilities Capabilities { get; private set; } @@ -384,12 +378,12 @@ protected override async Task OnInitializeAsync(CancellationToken cancellationTo } - private class ResourceMock : ResourceMockBase + private sealed class ResourceMock : ResourceMockBase { } - private class TestCapabilities : ICapabilities + private sealed class TestCapabilities : ICapabilities { public bool IsCombined => false; @@ -402,4 +396,4 @@ public IEnumerable GetAll() yield return this; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Resources.Management.Tests/TypeControllerTests.cs b/src/Tests/Moryx.Resources.Management.Tests/TypeControllerTests.cs index 2380a23c77..c5488c49fd 100644 --- a/src/Tests/Moryx.Resources.Management.Tests/TypeControllerTests.cs +++ b/src/Tests/Moryx.Resources.Management.Tests/TypeControllerTests.cs @@ -1,14 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; +using Moq; +using Moryx.AbstractionLayer.Capabilities; using Moryx.AbstractionLayer.Resources; using Moryx.Container; -using Moq; using NUnit.Framework; -using Moryx.AbstractionLayer.Capabilities; namespace Moryx.Resources.Management.Tests; @@ -304,7 +301,7 @@ public void ProxyUnwrapsTargetExceptions() var proxy = (ISimpleResource)_typeController.GetProxy(resource); // Act & Assert - Assert.Throws(() => proxy.ThrowingMethod()); + Assert.Throws(proxy.ThrowingMethod); } [Test] diff --git a/src/Tests/Moryx.Resources.VisualInstructions.Tests/VisualInstructorTests.cs b/src/Tests/Moryx.Resources.VisualInstructions.Tests/VisualInstructorTests.cs index 71f57490a5..3caaf7c2c7 100644 --- a/src/Tests/Moryx.Resources.VisualInstructions.Tests/VisualInstructorTests.cs +++ b/src/Tests/Moryx.Resources.VisualInstructions.Tests/VisualInstructorTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; using Microsoft.Extensions.Logging.Abstractions; using Moryx.Logging; using Moryx.Threading; @@ -131,4 +130,4 @@ private static VisualInstruction[] GetTextInstruction() new VisualInstruction {Content = "Hello World", Type = InstructionContentType.Text} ]; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Endpoints.IntegrationTests/Databases/Controller/ModelSetupTests.cs b/src/Tests/Moryx.Runtime.Endpoints.IntegrationTests/Databases/Controller/ModelSetupTests.cs index ba2dadfa26..8dc8db0c94 100644 --- a/src/Tests/Moryx.Runtime.Endpoints.IntegrationTests/Databases/Controller/ModelSetupTests.cs +++ b/src/Tests/Moryx.Runtime.Endpoints.IntegrationTests/Databases/Controller/ModelSetupTests.cs @@ -1,21 +1,18 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Model; -using Moryx.TestTools.Test.Model; -using NUnit.Framework; -using System.Threading.Tasks; using Moryx.AbstractionLayer.TestTools; -using System; -using System.Collections.Generic; +using Moryx.Model; using Moryx.Model.Sqlite; using Moryx.Runtime.Endpoints.Databases; using Moryx.Runtime.Endpoints.Databases.Models; using Moryx.Serialization; +using Moryx.TestTools.Test.Model; +using NUnit.Framework; namespace Moryx.Runtime.Endpoints.IntegrationTests.Databases.Controller; -internal class ModelSetupTests +internal sealed class ModelSetupTests { private IDbContextManager? _dbContextManager; private DatabaseController? _databaseController; @@ -70,4 +67,4 @@ public async Task ExecuteSetupDoesNotThrowDisposedObjectException() Assert.That(result?.Value?.Success, Is.True); Assert.That(0, Is.EqualTo(_exceptions.Count)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Endpoints.Tests/Databases/UpdateConfigTests.cs b/src/Tests/Moryx.Runtime.Endpoints.Tests/Databases/UpdateConfigTests.cs index 6be0d600ef..1f59907c76 100644 --- a/src/Tests/Moryx.Runtime.Endpoints.Tests/Databases/UpdateConfigTests.cs +++ b/src/Tests/Moryx.Runtime.Endpoints.Tests/Databases/UpdateConfigTests.cs @@ -2,19 +2,18 @@ // Licensed under the Apache License, Version 2.0 using Microsoft.Extensions.Logging; -using Moryx.Model; -using Moryx.Runtime.Kernel; -using Moryx.TestTools.Test.Model; -using System; using Moryx.Configuration; +using Moryx.Model; using Moryx.Model.Sqlite; using Moryx.Runtime.Endpoints.Databases.Services; +using Moryx.Runtime.Kernel; +using Moryx.TestTools.Test.Model; using Moryx.Tools; using NUnit.Framework; namespace Moryx.Runtime.Endpoints.Tests.Databases; -internal class UpdateConfigTests +internal sealed class UpdateConfigTests { private DbContextManager _dbContextManager; private DatabaseConfigUpdateService _databaseConfigUpdateService; @@ -71,4 +70,4 @@ private SqliteDatabaseConfig GetUpdatedConfig() var configurator = _dbContextManager.GetConfigurator(typeof(TestModelContext)); return (SqliteDatabaseConfig)configurator.Config; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/CachedConfigManagerTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/CachedConfigManagerTests.cs index 0bb716a465..968b5a71a6 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/CachedConfigManagerTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/CachedConfigManagerTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.IO; using Moryx.Configuration; using NUnit.Framework; @@ -66,4 +65,4 @@ public void TestSave() Assert.That(config2.DummyNumber, Is.EqualTo(config1.DummyNumber)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerTests.cs index fdbb4f251c..5fe40d6eeb 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.IO; -using System.Linq; using Moryx.Configuration; using NUnit.Framework; diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerWithConfigProviderTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerWithConfigProviderTests.cs index bf224e031b..7ecc70f32f 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerWithConfigProviderTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/ConfigManagerWithConfigProviderTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Text; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/MicrosoftExtensionConfigProviderTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/MicrosoftExtensionConfigProviderTests.cs index 10cab743a0..0851b552ec 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/MicrosoftExtensionConfigProviderTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/MicrosoftExtensionConfigProviderTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Runtime.Serialization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging.Abstractions; diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/RuntimeConfigManagerTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/RuntimeConfigManagerTests.cs index 9f373369bb..68161a2825 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/RuntimeConfigManagerTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/RuntimeConfigManagerTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.IO; -using System.Threading; using Moryx.Configuration; using Moryx.Runtime.Kernel.Tests.Dummies; using NUnit.Framework; @@ -189,8 +186,10 @@ private void CreateTempFolder() private void DeleteTempFolder() { if (Directory.Exists(_tempDirectory)) + { Directory.Delete(_tempDirectory, true); + } Assert.That(Directory.Exists(_tempDirectory), Is.False); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/TestConfig.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/TestConfig.cs index 0360542d82..29fc5ce202 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/TestConfig.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Configuration/TestConfig.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; using Moryx.Configuration; diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig1.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig1.cs index 17065a7406..b16882c674 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig1.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig1.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.ComponentModel; using System.Runtime.Serialization; using Moryx.Configuration; @@ -131,11 +130,13 @@ public class RuntimeConfigManagerTestConfig1 : ConfigBase, IUpdatableConfig public void RaiseConfigChanged(params string[] modifiedProperties) { if (ConfigChanged != null) + { ConfigChanged(this, new ConfigChangedEventArgs(modifiedProperties)); + } } /// /// Event raised when the config was modified /// public event EventHandler ConfigChanged; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig2.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig2.cs index ce02f8c380..c2b1684bee 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig2.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/Dummies/RuntimeConfigManagerTestConfig2.cs @@ -11,4 +11,4 @@ namespace Moryx.Runtime.Kernel.Tests.Dummies; public class RuntimeConfigManagerTestConfig2 : ConfigBase { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/KernelServiceCollectionExtensionsTests.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/KernelServiceCollectionExtensionsTests.cs index d834c576a0..435413235b 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/KernelServiceCollectionExtensionsTests.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/KernelServiceCollectionExtensionsTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.IO; -using System.Linq; -using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Moq; using Moryx.Container; diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeA.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeA.cs index 9a90457471..9b739f7fed 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeA.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeA.cs @@ -6,4 +6,4 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; public interface IFacadeA { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeB.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeB.cs index 0012dede0e..b86256c2e4 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeB.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeB.cs @@ -8,7 +8,7 @@ internal interface IFacadeB } -internal class FacadeB : IFacadeB +internal sealed class FacadeB : IFacadeB { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeC.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeC.cs index 3343f6a95f..945c72b3e1 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeC.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/IFacadeC.cs @@ -7,6 +7,6 @@ internal interface IFacadeC { } -internal class FacadeC : IFacadeC +internal sealed class FacadeC : IFacadeC { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/LifeCycleBoundFacadeTestModule.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/LifeCycleBoundFacadeTestModule.cs index 3606c19a8b..4fbe05d24a 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/LifeCycleBoundFacadeTestModule.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/LifeCycleBoundFacadeTestModule.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Moryx.Configuration; using Moryx.Container; @@ -51,8 +49,12 @@ protected override Task OnStopAsync(CancellationToken cancellationToken) private void OnFacadeActivated(object sender, bool activated) { if (activated) + { ++ActivatedCount; + } else + { ++DeactivatedCount; + } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleA.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleA.cs index a0ef697b76..a844b08f13 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleA.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleA.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleA : ModuleBase, IFacadeContainer +internal sealed class ModuleA : ModuleBase, IFacadeContainer { public ModuleA() { @@ -21,6 +21,6 @@ public ModuleA() public IFacadeA Facade { get; private set; } } -internal class FacadaA : IFacadeA +internal sealed class FacadaA : IFacadeA { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleADependent.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleADependent.cs index 4c8261361b..f9cdcd532e 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleADependent.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleADependent.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleADependent : ModuleBase, IFacadeContainer +internal sealed class ModuleADependent : ModuleBase, IFacadeContainer { [RequiredModuleApi(IsStartDependency = true)] public IFacadeA Dependency { get; set; } @@ -13,8 +13,8 @@ internal class ModuleADependent : ModuleBase, IFacadeContainer public IFacadeC Facade { get; set; } = new FacadeC(); } -internal class ModuleADependentTransient : ModuleBase +internal sealed class ModuleADependentTransient : ModuleBase { [RequiredModuleApi(IsStartDependency = true)] public IFacadeC Dependency { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB1.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB1.cs index a3acf13540..db676502e4 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB1.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB1.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleB1 : ModuleBase, IFacadeContainer +internal sealed class ModuleB1 : ModuleBase, IFacadeContainer { public ModuleB1() { @@ -21,7 +21,7 @@ public ModuleB1() public IFacadeB Facade { get; private set; } } -internal class FacadeB1 : IFacadeB +internal sealed class FacadeB1 : IFacadeB { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB2.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB2.cs index 2478cd4bea..873274ee7d 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB2.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB2.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleB2 : ModuleBase, IFacadeContainer +internal sealed class ModuleB2 : ModuleBase, IFacadeContainer { public ModuleB2() { @@ -19,4 +19,4 @@ public ModuleB2() /// The hard-coded name of this property is also used in Moryx.Runtime.Kernel\ModuleManagement\Components\ModuleDependencyManager.cs /// public IFacadeB Facade { get; private set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB3.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB3.cs index ec2fec85a8..1d9a329291 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB3.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleB3.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleB3 : ModuleBase, IFacadeContainer +internal sealed class ModuleB3 : ModuleBase, IFacadeContainer { public ModuleB3() { @@ -16,4 +16,4 @@ public ModuleB3() /// Facade controlled by this module /// public IFacadeB Facade { get; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBUsingA.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBUsingA.cs index 4b9ed1ebf1..19b5c27a51 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBUsingA.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBUsingA.cs @@ -5,7 +5,7 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleBUsingA : ModuleBase, IFacadeContainer +internal sealed class ModuleBUsingA : ModuleBase, IFacadeContainer { public ModuleBUsingA() { @@ -19,4 +19,4 @@ public ModuleBUsingA() /// Facade controlled by this module /// public IFacadeB Facade { get; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBase.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBase.cs index 92a1a2cdd2..57968a5c62 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBase.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleBase.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading; -using System.Threading.Tasks; using Moryx.Container; using Moryx.Modules; using Moryx.Runtime.Modules; @@ -60,4 +57,4 @@ public void AcknowledgeNotification(IModuleNotification notification) public event EventHandler StateChanged; #pragma warning restore 67 -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleC.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleC.cs index 1eda31ca0b..f1b47fa42e 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleC.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ModuleC.cs @@ -5,14 +5,14 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ModuleC : ModuleBase +internal sealed class ModuleC : ModuleBase { [RequiredModuleApi(IsStartDependency = true)] public IFacadeB[] Facades { get; set; } } -internal class ModuleCSingle : ModuleBase +internal sealed class ModuleCSingle : ModuleBase { [RequiredModuleApi(IsStartDependency = true)] public IFacadeB Facades { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ServerModuleADependent.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ServerModuleADependent.cs index 92aa29355f..76487a9cb0 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ServerModuleADependent.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/ServerModuleADependent.cs @@ -4,12 +4,11 @@ using Microsoft.Extensions.Logging; using Moryx.Configuration; using Moryx.Container; -using Moryx.Runtime.Kernel.Tests.Dummies; using Moryx.Runtime.Modules; namespace Moryx.Runtime.Kernel.Tests.ModuleMocks; -internal class ServerModuleADependent : MockServerModuleBase +internal sealed class ServerModuleADependent : MockServerModuleBase { public ServerModuleADependent( IModuleContainerFactory containerFactory, diff --git a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/TestFacade.cs b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/TestFacade.cs index 7ba2e9ca79..4f6e8ef096 100644 --- a/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/TestFacade.cs +++ b/src/Tests/Moryx.Runtime.Kernel.Tests/ModuleMocks/TestFacade.cs @@ -7,4 +7,4 @@ namespace Moryx.Runtime.Kernel.Tests.ModuleMocks.Facade; public class TestFacade : FacadeBase { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Tests/Helper.cs b/src/Tests/Moryx.Runtime.Tests/Helper.cs index 105f7ed63c..a06c1d0f26 100644 --- a/src/Tests/Moryx.Runtime.Tests/Helper.cs +++ b/src/Tests/Moryx.Runtime.Tests/Helper.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Runtime.Serialization; using Moryx.Configuration; using Moryx.Runtime.Configuration; @@ -35,4 +34,4 @@ public class TestConfig : ConfigBase public class TestException : Exception { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Tests/Mocks/TestLoggerMgmt.cs b/src/Tests/Moryx.Runtime.Tests/Mocks/TestLoggerMgmt.cs index 22eeffc7f0..4887d34170 100644 --- a/src/Tests/Moryx.Runtime.Tests/Mocks/TestLoggerMgmt.cs +++ b/src/Tests/Moryx.Runtime.Tests/Mocks/TestLoggerMgmt.cs @@ -1,12 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Microsoft.Extensions.Logging; namespace Moryx.Runtime.Tests.Mocks; -internal class TestLoggerMgmt : ILoggerFactory, ILogger +internal sealed class TestLoggerMgmt : ILoggerFactory, ILogger { public void AddProvider(ILoggerProvider provider) { @@ -34,4 +33,4 @@ public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) { } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Tests/ModuleBaseTest.cs b/src/Tests/Moryx.Runtime.Tests/ModuleBaseTest.cs index 0cb3febacf..864fd719f2 100644 --- a/src/Tests/Moryx.Runtime.Tests/ModuleBaseTest.cs +++ b/src/Tests/Moryx.Runtime.Tests/ModuleBaseTest.cs @@ -1,13 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; +using Moq; +using Moryx.Configuration; using Moryx.Runtime.Modules; using Moryx.Runtime.Tests.Mocks; using Moryx.Runtime.Tests.Modules; -using Moq; using NUnit.Framework; -using Moryx.Configuration; namespace Moryx.Runtime.Tests; @@ -41,4 +40,4 @@ public async Task StrategiesInConfigFound() Assert.That(containerConfig.ContainsKey(typeof(IStrategy)), "Wrong type!"); Assert.That(containerConfig[typeof(IStrategy)], Is.EqualTo("Test"), "Wrong implementation instance set!"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Tests/Modules/DelayedExceptionModule.cs b/src/Tests/Moryx.Runtime.Tests/Modules/DelayedExceptionModule.cs index 0eae227431..4a4b2b9784 100644 --- a/src/Tests/Moryx.Runtime.Tests/Modules/DelayedExceptionModule.cs +++ b/src/Tests/Moryx.Runtime.Tests/Modules/DelayedExceptionModule.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Moryx.Configuration; using Moryx.Container; @@ -12,7 +9,7 @@ namespace Moryx.Runtime.Tests.Modules; -internal class DelayedExceptionModule : ServerModuleBase +internal sealed class DelayedExceptionModule : ServerModuleBase { public DelayedExceptionModule(IModuleContainerFactory containerFactory, IConfigManager configManager, ILoggerFactory loggerFactory) : base(containerFactory, configManager, loggerFactory) diff --git a/src/Tests/Moryx.Runtime.Tests/Modules/TestModule.cs b/src/Tests/Moryx.Runtime.Tests/Modules/TestModule.cs index 7affc44228..8e67400fd0 100644 --- a/src/Tests/Moryx.Runtime.Tests/Modules/TestModule.cs +++ b/src/Tests/Moryx.Runtime.Tests/Modules/TestModule.cs @@ -8,7 +8,7 @@ namespace Moryx.Runtime.Tests.Modules; -internal class TestModule : ServerModuleBase +internal sealed class TestModule : ServerModuleBase { public TestModule(IModuleContainerFactory containerFactory, IConfigManager configManager, ILoggerFactory loggerManagement) : base(containerFactory, configManager, loggerManagement) diff --git a/src/Tests/Moryx.Runtime.Tests/ServerNotificationCollectionTests.cs b/src/Tests/Moryx.Runtime.Tests/ServerNotificationCollectionTests.cs index 237f6c37af..6303f725ea 100644 --- a/src/Tests/Moryx.Runtime.Tests/ServerNotificationCollectionTests.cs +++ b/src/Tests/Moryx.Runtime.Tests/ServerNotificationCollectionTests.cs @@ -5,81 +5,80 @@ using Moryx.Runtime.Modules; using NUnit.Framework; -namespace Moryx.Runtime.Tests +namespace Moryx.Runtime.Tests; + +[TestFixture] +public class ServerNotificationCollectionTests { - [TestFixture] - public class ServerNotificationCollectionTests + // The agreed maximum size of the `ServerNotificationCollection` which + // should provide an amount of notifications, that is large enough + // without hitting memory limits + private const int MaxCollectionSize = 2500; + private ServerNotificationCollection _serverNotificationCollection; + + [SetUp] + public void SetUp() { - // The agreed maximum size of the `ServerNotificationCollection` which - // should provide an amount of notifications, that is large enough - // without hitting memory limits - private const int MaxCollectionSize = 2500; - private ServerNotificationCollection _serverNotificationCollection; + _serverNotificationCollection = []; + } - [SetUp] - public void SetUp() - { - _serverNotificationCollection = []; - } + [Test] + public void NotificationIsAdded() + { + var notification = new ModuleNotification(Notifications.Severity.Info, "notification", null); - [Test] - public void NotificationIsAdded() - { - var notification = new ModuleNotification(Notifications.Severity.Info, "notification", null); + _serverNotificationCollection.Add(notification); - _serverNotificationCollection.Add(notification); + Assert.That(_serverNotificationCollection.Single().Message, Is.EqualTo("notification")); + } - Assert.That(_serverNotificationCollection.Single().Message, Is.EqualTo("notification")); - } + [Test] + public void NotificationCountDoesntExceedMaxSize() + { + var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); - [Test] - public void NotificationCountDoesntExceedMaxSize() + for (var i = 0; i < MaxCollectionSize + 1; i++) { - var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); - - for (var i = 0; i < MaxCollectionSize + 1; i++) - { - _serverNotificationCollection.Add(dummyNotification); - } - Assert.That(_serverNotificationCollection.Count, Is.EqualTo(MaxCollectionSize)); + _serverNotificationCollection.Add(dummyNotification); } + Assert.That(_serverNotificationCollection.Count, Is.EqualTo(MaxCollectionSize)); + } - [Test] - public void FirstItemGetsRemovedOnOverflow() - { - var firstNotification = new ModuleNotification(Notifications.Severity.Info, "first", null); - var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); - - _serverNotificationCollection.Add(firstNotification); - for (var i = 0; i < MaxCollectionSize; i++) - { - _serverNotificationCollection.Add(dummyNotification); - } + [Test] + public void FirstItemGetsRemovedOnOverflow() + { + var firstNotification = new ModuleNotification(Notifications.Severity.Info, "first", null); + var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); - Assert.That(_serverNotificationCollection.First().Message, Is.EqualTo("dummy")); + _serverNotificationCollection.Add(firstNotification); + for (var i = 0; i < MaxCollectionSize; i++) + { + _serverNotificationCollection.Add(dummyNotification); } - [Test] - public void CollectionChangedEventGetsInvokedForRemovedItem() - { - var firstNotification = new ModuleNotification(Notifications.Severity.Info, "first", null); - var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); - ModuleNotification removedNotification = null; - _serverNotificationCollection.CollectionChanged += (sender, e) => - { - if (e.Action == NotifyCollectionChangedAction.Remove) - { - removedNotification = (ModuleNotification)e.OldItems[0]; - } - }; + Assert.That(_serverNotificationCollection.First().Message, Is.EqualTo("dummy")); + } - _serverNotificationCollection.Add(firstNotification); - for (int i = 0; i < MaxCollectionSize; i++) + [Test] + public void CollectionChangedEventGetsInvokedForRemovedItem() + { + var firstNotification = new ModuleNotification(Notifications.Severity.Info, "first", null); + var dummyNotification = new ModuleNotification(Notifications.Severity.Info, "dummy", null); + ModuleNotification removedNotification = null; + _serverNotificationCollection.CollectionChanged += (sender, e) => + { + if (e.Action == NotifyCollectionChangedAction.Remove) { - _serverNotificationCollection.Add(dummyNotification); + removedNotification = (ModuleNotification)e.OldItems[0]; } + }; - Assert.That(removedNotification.Message, Is.EqualTo(firstNotification.Message)); + _serverNotificationCollection.Add(firstNotification); + for (int i = 0; i < MaxCollectionSize; i++) + { + _serverNotificationCollection.Add(dummyNotification); } + + Assert.That(removedNotification.Message, Is.EqualTo(firstNotification.Message)); } } diff --git a/src/Tests/Moryx.Runtime.Tests/StateTransitionTest.cs b/src/Tests/Moryx.Runtime.Tests/StateTransitionTest.cs index 6aa7d8ad10..36caa4d6fc 100644 --- a/src/Tests/Moryx.Runtime.Tests/StateTransitionTest.cs +++ b/src/Tests/Moryx.Runtime.Tests/StateTransitionTest.cs @@ -1,14 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; +using Moq; +using Moryx.Configuration; using Moryx.Runtime.Kernel; using Moryx.Runtime.Modules; using Moryx.Runtime.Tests.Mocks; using Moryx.Runtime.Tests.Modules; -using Moq; using NUnit.Framework; -using Moryx.Configuration; namespace Moryx.Runtime.Tests; @@ -132,4 +131,4 @@ public async Task FailureInStopped() await casted.StopAsync(); module.WaitEvent.Set(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Runtime.Tests/Strategy.cs b/src/Tests/Moryx.Runtime.Tests/Strategy.cs index ac0f10ee4b..19404c8ae3 100644 --- a/src/Tests/Moryx.Runtime.Tests/Strategy.cs +++ b/src/Tests/Moryx.Runtime.Tests/Strategy.cs @@ -15,4 +15,4 @@ public class StrategyConfig : IPluginConfig /// Name of the component represented by this entry /// public string PluginName { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Shifts.Management.IntegrationTests/FacadeTests.cs b/src/Tests/Moryx.Shifts.Management.IntegrationTests/FacadeTests.cs index 0ccb49b46e..ffbdfc554a 100644 --- a/src/Tests/Moryx.Shifts.Management.IntegrationTests/FacadeTests.cs +++ b/src/Tests/Moryx.Shifts.Management.IntegrationTests/FacadeTests.cs @@ -6,7 +6,7 @@ namespace Moryx.Shifts.Management.IntegrationTests; [TestFixture] -internal class FacadeTests : TestBase +internal sealed class FacadeTests : TestBase { [SetUp] public override Task SetUp() @@ -449,4 +449,4 @@ public void DeleteShiftAssignement_WithInvalidArgument_ThrowsException() } #endregion -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Shifts.Management.IntegrationTests/ModuleTests.cs b/src/Tests/Moryx.Shifts.Management.IntegrationTests/ModuleTests.cs index 248d9d876e..e7f2188c83 100644 --- a/src/Tests/Moryx.Shifts.Management.IntegrationTests/ModuleTests.cs +++ b/src/Tests/Moryx.Shifts.Management.IntegrationTests/ModuleTests.cs @@ -9,7 +9,7 @@ namespace Moryx.Shifts.Management.IntegrationTests; [TestFixture] -internal class ModuleTests : TestBase +internal sealed class ModuleTests : TestBase { [SetUp] public override Task SetUp() @@ -97,4 +97,4 @@ public async Task AnyMethod_WhenFacadeNotActivated_ThrowsHealthStateException() Assert.That(() => _facade.DeleteShiftAssignement(0), Throws.TypeOf()); }); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Shifts.Management.IntegrationTests/TestBase.cs b/src/Tests/Moryx.Shifts.Management.IntegrationTests/TestBase.cs index 0839be0f38..3309d9e46e 100644 --- a/src/Tests/Moryx.Shifts.Management.IntegrationTests/TestBase.cs +++ b/src/Tests/Moryx.Shifts.Management.IntegrationTests/TestBase.cs @@ -81,4 +81,4 @@ protected static bool ObjectsAreEqual(ShiftAssignement updatedAssignement, Shift updatedAssignement.Priority == result.Priority && updatedAssignement.AssignedDays == result.AssignedDays; #endregion -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/AssemblyActivity.cs b/src/Tests/Moryx.Simulation.Tests/AssemblyActivity.cs index d73b73c5ed..8670cca396 100644 --- a/src/Tests/Moryx.Simulation.Tests/AssemblyActivity.cs +++ b/src/Tests/Moryx.Simulation.Tests/AssemblyActivity.cs @@ -22,4 +22,4 @@ protected override ActivityResult CreateResult(long resultNumber) { return ActivityResult.Create((DefaultActivityResult)resultNumber); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/AssemblyCapabilities.cs b/src/Tests/Moryx.Simulation.Tests/AssemblyCapabilities.cs index c02b87e937..4537fae8d5 100644 --- a/src/Tests/Moryx.Simulation.Tests/AssemblyCapabilities.cs +++ b/src/Tests/Moryx.Simulation.Tests/AssemblyCapabilities.cs @@ -23,4 +23,4 @@ public bool Provides(ICapabilities required) { return required is AssemblyCapabilities; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/AssemblyTestCell.cs b/src/Tests/Moryx.Simulation.Tests/AssemblyTestCell.cs index 4cfb64b353..d18f2fd9b0 100644 --- a/src/Tests/Moryx.Simulation.Tests/AssemblyTestCell.cs +++ b/src/Tests/Moryx.Simulation.Tests/AssemblyTestCell.cs @@ -11,4 +11,4 @@ public void TestInit() { OnInitializeAsync(CancellationToken.None).GetAwaiter().GetResult(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/BaseTest.cs b/src/Tests/Moryx.Simulation.Tests/BaseTest.cs index 136d0c9c61..57cfdc3376 100644 --- a/src/Tests/Moryx.Simulation.Tests/BaseTest.cs +++ b/src/Tests/Moryx.Simulation.Tests/BaseTest.cs @@ -1,18 +1,18 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using Moq; +using Moryx.AbstractionLayer.Activities; +using Moryx.AbstractionLayer.Processes; using Moryx.AbstractionLayer.Resources; using Moryx.ControlSystem.Cells; using Moryx.ControlSystem.Processes; +using Moryx.ControlSystem.Simulation; using Moryx.ControlSystem.Simulator; -using Moq; -using Moryx.AbstractionLayer.Activities; -using Moryx.AbstractionLayer.Processes; -using NUnit.Framework; +using Moryx.ControlSystem.Simulator.Implementation; using Moryx.Logging; using Moryx.TestTools.UnitTest; -using Moryx.ControlSystem.Simulation; -using Moryx.ControlSystem.Simulator.Implementation; +using NUnit.Framework; namespace Moryx.Simulation.Tests; diff --git a/src/Tests/Moryx.Simulation.Tests/Builder.cs b/src/Tests/Moryx.Simulation.Tests/Builder.cs index ecf33fc603..2ef99ef64b 100644 --- a/src/Tests/Moryx.Simulation.Tests/Builder.cs +++ b/src/Tests/Moryx.Simulation.Tests/Builder.cs @@ -14,4 +14,4 @@ public static AssemblyTestCell CellBuilder(int id, SimulatedDummyTestDriver driv return cell; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/SimulatedDummyTestDriver.cs b/src/Tests/Moryx.Simulation.Tests/SimulatedDummyTestDriver.cs index 6223fc1d8d..3d9912d53d 100644 --- a/src/Tests/Moryx.Simulation.Tests/SimulatedDummyTestDriver.cs +++ b/src/Tests/Moryx.Simulation.Tests/SimulatedDummyTestDriver.cs @@ -1,15 +1,15 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.AbstractionLayer.Drivers.Message; +using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Drivers; +using Moryx.AbstractionLayer.Drivers.Message; using Moryx.AbstractionLayer.Resources; -using Moryx.AbstractionLayer.Activities; using Moryx.ControlSystem.Cells; -using Moryx.StateMachines; using Moryx.ControlSystem.Simulation; -using Moryx.Resources.Benchmarking.Messages; using Moryx.Resources.Benchmarking; +using Moryx.Resources.Benchmarking.Messages; +using Moryx.StateMachines; namespace Moryx.Simulation.Tests; @@ -52,10 +52,10 @@ public virtual void Send(object payload) { switch (payload) { - case AssembleProductMessage assemble: + case AssembleProductMessage: SimulatedState = SimulationState.Executing; break; - case ReleaseWorkpieceMessage release: + case ReleaseWorkpieceMessage: SimulatedState = SimulationState.Idle; break; } @@ -97,4 +97,4 @@ public void ForceState(StateClassification classification) { Classification = classification; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/SimulationActivitiesTests.cs b/src/Tests/Moryx.Simulation.Tests/SimulationActivitiesTests.cs index f63846b80d..114e2745a6 100644 --- a/src/Tests/Moryx.Simulation.Tests/SimulationActivitiesTests.cs +++ b/src/Tests/Moryx.Simulation.Tests/SimulationActivitiesTests.cs @@ -12,7 +12,7 @@ namespace Moryx.Simulation.Tests; -internal class SimulationActivitiesTests : BaseTest +internal sealed class SimulationActivitiesTests : BaseTest { private Mock _assemblyDriverMock; private Mock _anotherAssemblyDriverMock; diff --git a/src/Tests/Moryx.Simulation.Tests/SimulationDriverTests.cs b/src/Tests/Moryx.Simulation.Tests/SimulationDriverTests.cs index c78076e690..feeaced96b 100644 --- a/src/Tests/Moryx.Simulation.Tests/SimulationDriverTests.cs +++ b/src/Tests/Moryx.Simulation.Tests/SimulationDriverTests.cs @@ -10,7 +10,7 @@ namespace Moryx.Simulation.Tests; -internal class SimulationDriverTests : BaseTest +internal sealed class SimulationDriverTests : BaseTest { Mock _simulationDriverTestMock; @@ -118,4 +118,4 @@ public void Driver_Should_Receive_Result_message() _simulationDriverTestMock.Verify(dr => dr.Result(It.IsAny()), Times.Once); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Simulation.Tests/SimulationStatesTests.cs b/src/Tests/Moryx.Simulation.Tests/SimulationStatesTests.cs index 9ec8921c46..25572100d2 100644 --- a/src/Tests/Moryx.Simulation.Tests/SimulationStatesTests.cs +++ b/src/Tests/Moryx.Simulation.Tests/SimulationStatesTests.cs @@ -9,7 +9,7 @@ namespace Moryx.Simulation.Tests; -internal class SimulationStatesTests : BaseTest +internal sealed class SimulationStatesTests : BaseTest { [SetUp] public override void Setup() @@ -47,4 +47,4 @@ public async Task SimulationStates_Should_Simulate_ExecutingState() Assert.That(_assemblyCellDriver.SimulatedState, Is.EqualTo(SimulationState.Executing)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/BindingResolverExtensionTests.cs b/src/Tests/Moryx.Tests/Bindings/BindingResolverExtensionTests.cs index 57d92ffc31..b3dce28d9a 100644 --- a/src/Tests/Moryx.Tests/Bindings/BindingResolverExtensionTests.cs +++ b/src/Tests/Moryx.Tests/Bindings/BindingResolverExtensionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using Moryx.Bindings; using NUnit.Framework; @@ -217,4 +216,4 @@ private static SomeComplexClass CreateData() }; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/DelegateResolverTest.cs b/src/Tests/Moryx.Tests/Bindings/DelegateResolverTest.cs index 62e9bbcba8..b795c2e488 100644 --- a/src/Tests/Moryx.Tests/Bindings/DelegateResolverTest.cs +++ b/src/Tests/Moryx.Tests/Bindings/DelegateResolverTest.cs @@ -42,4 +42,4 @@ public void Updatevalue() // Assert Assert.That(foo.Branch.Name, Is.EqualTo("Howard")); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/Branch.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/Branch.cs index 1fe37125c3..02fcf95a94 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/Branch.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/Branch.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; - namespace Moryx.Tests.Bindings; public class Branch @@ -10,4 +8,4 @@ public class Branch public string Name { get; set; } public Dictionary Dictionary { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/Foo.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/Foo.cs index eb19bbaab7..eb8cb5e56a 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/Foo.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/Foo.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Bindings; public class Foo { public Branch Branch { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/ISomeInterface.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/ISomeInterface.cs index f84b0a68d0..de49994da1 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/ISomeInterface.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/ISomeInterface.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Bindings; public interface ISomeInterface { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeClass.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeClass.cs index 6c65492748..1704749479 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeClass.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeClass.cs @@ -11,4 +11,4 @@ public class SomeClass public ISomeInterface SomeObject { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeComplexClass.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeComplexClass.cs index 2899842dbe..7e1e232ba0 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeComplexClass.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeComplexClass.cs @@ -12,7 +12,7 @@ public class SomeComplexClass public SomeComplexClass OtherSubClass { get; set; } } -internal class SomeComplexClassResolver : BindingResolverBase +internal sealed class SomeComplexClassResolver : BindingResolverBase { protected override object Resolve(object source) { @@ -24,4 +24,4 @@ protected override bool Update(object source, object value) { throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeHiddenPropertyClass.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeHiddenPropertyClass.cs index 220bc106a9..508dd8acbf 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeHiddenPropertyClass.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeHiddenPropertyClass.cs @@ -10,4 +10,4 @@ public class SomeHiddenPropertyClass : SomeClass get { return (SomeImplementation)base.SomeObject; } set { base.SomeObject = value; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeImplementation.cs b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeImplementation.cs index 689e03484d..569159c699 100644 --- a/src/Tests/Moryx.Tests/Bindings/Dummies/SomeImplementation.cs +++ b/src/Tests/Moryx.Tests/Bindings/Dummies/SomeImplementation.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Bindings; public class SomeImplementation : ISomeInterface { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Bindings/ReflectionResolverTests.cs b/src/Tests/Moryx.Tests/Bindings/ReflectionResolverTests.cs index 3e1b253fc4..dd56f8bf4e 100644 --- a/src/Tests/Moryx.Tests/Bindings/ReflectionResolverTests.cs +++ b/src/Tests/Moryx.Tests/Bindings/ReflectionResolverTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Globalization; using System.Reflection; using Moryx.Bindings; diff --git a/src/Tests/Moryx.Tests/Bindings/UpdateValueTest.cs b/src/Tests/Moryx.Tests/Bindings/UpdateValueTest.cs index d48f9bf91a..4fe5bf0f5e 100644 --- a/src/Tests/Moryx.Tests/Bindings/UpdateValueTest.cs +++ b/src/Tests/Moryx.Tests/Bindings/UpdateValueTest.cs @@ -25,4 +25,4 @@ public void SetName() // Assert Assert.That(foo.Branch.Name, Is.EqualTo("Thomas")); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Collections/DelayQueueTests.cs b/src/Tests/Moryx.Tests/Collections/DelayQueueTests.cs index 81e661bd60..fdf078d017 100644 --- a/src/Tests/Moryx.Tests/Collections/DelayQueueTests.cs +++ b/src/Tests/Moryx.Tests/Collections/DelayQueueTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using Microsoft.Extensions.Logging.Abstractions; using Moryx.Collections; using Moryx.Threading; @@ -15,7 +12,7 @@ namespace Moryx.Tests.Collections; [TestFixture, Explicit] public class DelayQueueTests { - private class DummyMessage + private sealed class DummyMessage { } @@ -57,7 +54,9 @@ public void EnqueueAfterCreation(double delayFactor) // Arrange var delay = (int)(Delay * delayFactor); if (delay > 0) + { Thread.Sleep(delay); + } // Act _queue.Enqueue(new DummyMessage()); @@ -83,7 +82,9 @@ public void DoubleMessage(bool queueReady) // Arrange const int initalDelay = Delay + 100; if (queueReady) + { Thread.Sleep(initalDelay); + } // Act _queue.Enqueue(new DummyMessage()); @@ -113,7 +114,9 @@ public void EnqueueBurst(int initialDelay, int messageDelay) { // Arrange if (initialDelay > 0) + { Thread.Sleep(initialDelay); + } // Act const int loops = 4; @@ -165,4 +168,4 @@ public void InterruptQueue() Assert.That(preClear, Is.GreaterThanOrEqualTo(0)); Assert.That(_times.Count, Is.EqualTo(0)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Collections/SortObj.cs b/src/Tests/Moryx.Tests/Collections/SortObj.cs index 6e8ea30b09..547c5e4d2c 100644 --- a/src/Tests/Moryx.Tests/Collections/SortObj.cs +++ b/src/Tests/Moryx.Tests/Collections/SortObj.cs @@ -5,7 +5,7 @@ namespace Moryx.Tests.Collections; -internal class SortObj : ISortableObject +internal sealed class SortObj : ISortableObject { public SortObj(string name) { @@ -20,4 +20,4 @@ public override string ToString() { return $"Order: {SortOrder} - Name: {Name}"; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Collections/SortableCollectionTests.cs b/src/Tests/Moryx.Tests/Collections/SortableCollectionTests.cs index 5aa9adbff5..27ac9c609f 100644 --- a/src/Tests/Moryx.Tests/Collections/SortableCollectionTests.cs +++ b/src/Tests/Moryx.Tests/Collections/SortableCollectionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Collections; using NUnit.Framework; @@ -141,4 +140,4 @@ public void RemoveTest(int removeItemIndex, int changedItemsCount) Assert.That(changedItems.Count, Is.EqualTo(changedItemsCount)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Collections/StringNumericComparerTests.cs b/src/Tests/Moryx.Tests/Collections/StringNumericComparerTests.cs index e7206fdb24..9b46aecd09 100644 --- a/src/Tests/Moryx.Tests/Collections/StringNumericComparerTests.cs +++ b/src/Tests/Moryx.Tests/Collections/StringNumericComparerTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Moryx.Collections; using NUnit.Framework; @@ -63,4 +62,4 @@ public void CorrectlyOrderTrailingNumbers() Assert.That(ordered[5], Is.EqualTo("Dummy03")); Assert.That(ordered[6], Is.EqualTo("Dummy 10")); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Communication/PortMapTests.cs b/src/Tests/Moryx.Tests/Communication/PortMapTests.cs index 5acc4048ac..e6d72222cb 100644 --- a/src/Tests/Moryx.Tests/Communication/PortMapTests.cs +++ b/src/Tests/Moryx.Tests/Communication/PortMapTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Net; using Moryx.Communication; using Moryx.Communication.Sockets; @@ -30,9 +29,13 @@ public void AddressValidation(string address1, string address2, bool sameProtoco // Assert if (allowed) + { Assert.That(success, "Failed to register despite different address"); + } else + { Assert.That(success, Is.False, "Should not allow registration"); + } } [TestCase(13, 14, false, true)] @@ -50,12 +53,16 @@ public void PortValidation(int port1, int port2, bool sameProtocol, bool allowed // Assert if (allowed) + { Assert.That(success, "Failed to register despite different address"); + } else + { Assert.That(success, Is.False, "Should not allow registration"); + } } - private class DummyProtocol : IMessageInterpreter + private sealed class DummyProtocol : IMessageInterpreter { private int ProtocolId { get; } @@ -89,4 +96,4 @@ public bool ErrorResponse(IReadContext context, out byte[] lastWill) throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/Transformer/ModelTransformerTest.cs b/src/Tests/Moryx.Tests/Configuration/Transformer/ModelTransformerTest.cs index 4fdebae33d..5d1cd02aca 100644 --- a/src/Tests/Moryx.Tests/Configuration/Transformer/ModelTransformerTest.cs +++ b/src/Tests/Moryx.Tests/Configuration/Transformer/ModelTransformerTest.cs @@ -4,7 +4,6 @@ using System.Collections; using System.ComponentModel; using System.Globalization; -using System.Linq; using Moryx.Configuration; using Moryx.Serialization; using NUnit.Framework; @@ -46,7 +45,9 @@ public void ConvertTest() { // find the property in the generic object if (propertyInfo.Name != entry.Identifier) + { continue; + } found = true; var attr = propertyInfo.GetCustomAttributes(false); @@ -142,13 +143,22 @@ public void ConvertTest() var propertyValue = propertyInfo.GetValue(config); if (propertyValue == null) + { Assert.That(entry.Value.Current, Is.EqualTo(entry.Value.Default), "The current value do not match."); + } else if (typeof(IList).IsAssignableFrom(propertyInfo.PropertyType)) + { Assert.That(entry.SubEntries.Count, Is.EqualTo(((IList)propertyValue).Count)); + } else if (propertyInfo.PropertyType.IsClass && propertyInfo.PropertyType != typeof(string)) + { Assert.That(entry.Value.Current, Is.EqualTo(propertyInfo.PropertyType.Name)); + } else + { Assert.That(propertyValue.ToString(), Is.EqualTo(entry.Value.Current), "The current value do not match."); + } + break; } Assert.That(found, $"Property is missing: {propertyInfo.Name}"); diff --git a/src/Tests/Moryx.Tests/Configuration/Transformer/TransformerTestConfig.cs b/src/Tests/Moryx.Tests/Configuration/Transformer/TransformerTestConfig.cs index 0d470c54ec..d97696c397 100644 --- a/src/Tests/Moryx.Tests/Configuration/Transformer/TransformerTestConfig.cs +++ b/src/Tests/Moryx.Tests/Configuration/Transformer/TransformerTestConfig.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using Moryx.Configuration; @@ -31,7 +30,7 @@ internal enum TestConfig1Enum /// /// Test config /// -internal class TransformerTestConfig +internal sealed class TransformerTestConfig { /// /// Initializes a new instance of the class. @@ -95,7 +94,7 @@ public TransformerTestConfig() /// /// Gets the read only property. /// - public string ReadOnlyProperty => "Test"; + public static string ReadOnlyProperty => "Test"; /// /// Gets or sets a int value. @@ -143,7 +142,7 @@ public TransformerTestConfig() /// /// Test subconfig /// -internal class SubConfig +internal sealed class SubConfig { /// /// Gets or sets the int field. diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/DefaultCanWriteValueProviderFilterTests.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/DefaultCanWriteValueProviderFilterTests.cs index 6e28bfa4c7..5b3f36e6c1 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/DefaultCanWriteValueProviderFilterTests.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/DefaultCanWriteValueProviderFilterTests.cs @@ -33,4 +33,4 @@ public class PrivateSetterClass public bool NoSetterBool => false; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/NoStringValueProviderFilter.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/NoStringValueProviderFilter.cs index 52c66d1da2..8fc796986b 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/NoStringValueProviderFilter.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/NoStringValueProviderFilter.cs @@ -12,4 +12,4 @@ public bool CheckProperty(PropertyInfo propertyInfo) { return propertyInfo.PropertyType != typeof(string); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig1.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig1.cs index 9fb53dbcc5..6c50cb71a9 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig1.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig1.cs @@ -23,4 +23,4 @@ public class TestConfig1 : ConfigBase [DataMember] [DefaultValue(DefaultValues.Text)] public string DummyText { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig2.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig2.cs index 02e059f010..f8c1f34d1b 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig2.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig2.cs @@ -14,4 +14,4 @@ public class TestConfig2 [DataMember] [DefaultValue(DefaultValues.Number)] public int DummyNumber { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig3.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig3.cs index 3583d4bf2b..487042767f 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig3.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig3.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; @@ -15,4 +14,4 @@ public class TestConfig3 [DataMember] [DefaultValue(DefaultValues.Number)] public int DummyNumber { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig4.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig4.cs index 494bc28421..f6f47bf0d7 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig4.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig4.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using System.Runtime.Serialization; namespace Moryx.Tests.Configuration.ValueProvider; @@ -19,4 +18,4 @@ public class TestConfig4 [DataMember] public IEnumerable EnumerableNumbers { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig5.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig5.cs index 4591e27b9e..ed7ae7cded 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig5.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig5.cs @@ -1,12 +1,11 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.ComponentModel; namespace Moryx.Tests.Configuration.ValueProvider; -internal class ClassWithoutParamLessCtor +internal sealed class ClassWithoutParamLessCtor { public ClassWithoutParamLessCtor(string a) { @@ -14,11 +13,11 @@ public ClassWithoutParamLessCtor(string a) } } -internal class TestConfig5 +internal sealed class TestConfig5 { [DefaultValue(null)] public ClassWithoutParamLessCtor Field1 { get; set; } [DefaultValue(null)] public Func Field2 { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig6.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig6.cs index b4cb4a847d..1f22bbdc40 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig6.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/TestConfig6.cs @@ -5,7 +5,7 @@ namespace Moryx.Tests.Configuration.ValueProvider; -internal class TestConfig6 +internal sealed class TestConfig6 { public TestConfig6() { @@ -18,4 +18,4 @@ public TestConfig6() public int? WithDefaultValueNull { get; set; } public int? WithoutDefaultValue { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/ThreeProvider.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/ThreeProvider.cs index a395d01fe0..23a5d1e3f4 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/ThreeProvider.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/ThreeProvider.cs @@ -6,11 +6,11 @@ namespace Moryx.Tests.Configuration.ValueProvider; -internal class ThreeProvider : IValueProvider +internal sealed class ThreeProvider : IValueProvider { public ValueProviderResult Handle(object parent, PropertyInfo property) { property.SetValue(parent, 3); return ValueProviderResult.Handled; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Configuration/ValueProvider/ValueProviderTests.cs b/src/Tests/Moryx.Tests/Configuration/ValueProvider/ValueProviderTests.cs index 2952dadcd7..3cdd31b77c 100644 --- a/src/Tests/Moryx.Tests/Configuration/ValueProvider/ValueProviderTests.cs +++ b/src/Tests/Moryx.Tests/Configuration/ValueProvider/ValueProviderTests.cs @@ -151,4 +151,4 @@ public void NullableValueTypesHandledCorrectly() Assert.That(config.WithDefaultValueNull, Is.Null, "Did not respect default value null"); Assert.That(config.WithoutDefaultValue, Is.EqualTo(3), "DefaultValueProvider did handle the field without a DefaultValue Attribute"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/AbstractBaseClass.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/AbstractBaseClass.cs index 26d1d269b5..e986cbc662 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/AbstractBaseClass.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/AbstractBaseClass.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public abstract class AbstractBaseClass : ITestInterface { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/BaseClass.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/BaseClass.cs index de29d003d9..08dcabc989 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/BaseClass.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/BaseClass.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public class BaseClass : AbstractBaseClass { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass1.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass1.cs index c9e21a955a..ee485ad535 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass1.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass1.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public class ChildClass1 : BaseClass { public int Foo { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass2.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass2.cs index 8ea2798c42..e45d6da487 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass2.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/ChildClass2.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public class ChildClass2 : BaseClass { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass1.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass1.cs index d8165db49c..556842ba5c 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass1.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass1.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public class GranChildClass1 : ChildClass1 { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass2.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass2.cs index ad4e79ba49..f777b01b8d 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass2.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/GranChildClass2.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; public class GranChildClass2 : ChildClass1 { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/IBaseInterface.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/IBaseInterface.cs index 3c6d1e677a..bb2117fd17 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/IBaseInterface.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/IBaseInterface.cs @@ -6,4 +6,4 @@ namespace Moryx.Tests.Extensions; internal interface IBaseInterface { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/ITestInterface.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/ITestInterface.cs index 1cf659cbf0..047a56b208 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/ITestInterface.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/ITestInterface.cs @@ -5,4 +5,4 @@ namespace Moryx.Tests.Extensions; internal interface ITestInterface : IBaseInterface { -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/AppDomain/ReferenceClass.cs b/src/Tests/Moryx.Tests/Extensions/AppDomain/ReferenceClass.cs index c89214841b..bcfa1b58f1 100644 --- a/src/Tests/Moryx.Tests/Extensions/AppDomain/ReferenceClass.cs +++ b/src/Tests/Moryx.Tests/Extensions/AppDomain/ReferenceClass.cs @@ -1,11 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; - namespace Moryx.Tests.Extensions; -internal class ReferenceClass +internal sealed class ReferenceClass { public int Ignore { get; set; } @@ -22,4 +20,4 @@ internal class ReferenceClass public GranChildClass1[] EmptyArray { get; set; } public GranChildClass2[] NullArray { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/CustomAttributeProviderExtensionTests.cs b/src/Tests/Moryx.Tests/Extensions/CustomAttributeProviderExtensionTests.cs index d4fbcc9772..7711f035dd 100644 --- a/src/Tests/Moryx.Tests/Extensions/CustomAttributeProviderExtensionTests.cs +++ b/src/Tests/Moryx.Tests/Extensions/CustomAttributeProviderExtensionTests.cs @@ -1,29 +1,28 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using NUnit.Framework; using System.ComponentModel; +using System.ComponentModel.DataAnnotations; using System.Reflection; using Moryx.Tools; -using System.ComponentModel.DataAnnotations; +using NUnit.Framework; namespace Moryx.Tests.Extensions; -internal class TestConstants +internal sealed class TestConstants { public const string ClassDisplayName = "Some Display Name"; public const string ClassDescription = "Some Description"; } [Display(Name = TestConstants.ClassDisplayName, Description = TestConstants.ClassDescription)] -internal class ClassDisplayAttributeDummy +internal sealed class ClassDisplayAttributeDummy { } [DisplayName(TestConstants.ClassDisplayName)] [System.ComponentModel.Description(TestConstants.ClassDescription)] -internal class DotnetAttributesDummy +internal sealed class DotnetAttributesDummy { } @@ -79,4 +78,4 @@ public void GetInvalidCustomAttribute() // Assert Assert.That(attr, Is.Null); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/DateTimeExtensionTests.cs b/src/Tests/Moryx.Tests/Extensions/DateTimeExtensionTests.cs index 694819dfd2..9671dd0b82 100644 --- a/src/Tests/Moryx.Tests/Extensions/DateTimeExtensionTests.cs +++ b/src/Tests/Moryx.Tests/Extensions/DateTimeExtensionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.Tools; using NUnit.Framework; @@ -151,4 +150,4 @@ private static void AssertEqualDateTime(DateTime a, DateTime b) Assert.That(b.Minute, Is.EqualTo(a.Minute)); Assert.That(b.Millisecond, Is.EqualTo(a.Millisecond)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/EnumerableExtensionTests.cs b/src/Tests/Moryx.Tests/Extensions/EnumerableExtensionTests.cs index eea7a46d30..ee0f5c5eb3 100644 --- a/src/Tests/Moryx.Tests/Extensions/EnumerableExtensionTests.cs +++ b/src/Tests/Moryx.Tests/Extensions/EnumerableExtensionTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Collections.Generic; using Moryx.Tools; using NUnit.Framework; @@ -29,14 +28,11 @@ public void ForEachTest() var enumerated = new List(); // ReSharper disable once ConvertClosureToMethodGroup - _enumerable.ForEach(delegate (int i) - { - enumerated.Add(i); - }); + _enumerable.ForEach(enumerated.Add); foreach (var item in _enumerable) { Assert.That(enumerated.Contains(item)); } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Extensions/ReflectionToolTests.cs b/src/Tests/Moryx.Tests/Extensions/ReflectionToolTests.cs index 38ad0d38d6..89af1fd371 100644 --- a/src/Tests/Moryx.Tests/Extensions/ReflectionToolTests.cs +++ b/src/Tests/Moryx.Tests/Extensions/ReflectionToolTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using Moryx.Tools; using NUnit.Framework; @@ -145,7 +142,7 @@ public void PropertyAccessorIsFaster() var prop = childType.GetProperty(nameof(ChildClass1.Foo)); var accessor = ReflectionTool.PropertyAccessor(prop); // Run once for JIT - var value = prop.GetValue(new ChildClass1()); + _ = prop.GetValue(new ChildClass1()); prop.SetValue(new ChildClass1(), 1); accessor.ReadProperty(new ChildClass1()); accessor.WriteProperty(new ChildClass1(), 1); @@ -264,4 +261,4 @@ public void FilterReferencesWithPredicate() // Assert Assert.That(references.Length, Is.EqualTo(3), "Tool did not detect all references"); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Modules/PriorityTests.cs b/src/Tests/Moryx.Tests/Modules/PriorityTests.cs index 0b8dc3a199..09031caf34 100644 --- a/src/Tests/Moryx.Tests/Modules/PriorityTests.cs +++ b/src/Tests/Moryx.Tests/Modules/PriorityTests.cs @@ -34,4 +34,4 @@ public void PriorityCompare() Assert.That(pCustom < p3); Assert.That(pCustom <= p3); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Serialization/EntryConvert/Dummies/DictionaryClassDummy.cs b/src/Tests/Moryx.Tests/Serialization/EntryConvert/Dummies/DictionaryClassDummy.cs index 4aa0c4da98..dd2f7897d0 100644 --- a/src/Tests/Moryx.Tests/Serialization/EntryConvert/Dummies/DictionaryClassDummy.cs +++ b/src/Tests/Moryx.Tests/Serialization/EntryConvert/Dummies/DictionaryClassDummy.cs @@ -3,7 +3,7 @@ namespace Moryx.Tests.Serialization; -class DictionaryClassDummy +sealed class DictionaryClassDummy { public string Name { get; set; } diff --git a/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryConvertTests.cs b/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryConvertTests.cs index d7fd1558eb..10f5dacf23 100644 --- a/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryConvertTests.cs +++ b/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryConvertTests.cs @@ -40,14 +40,18 @@ public void ShouldCreateInstanceArray_WithIdentifier_ThatStart_With_CREATED() var boolEntry = encoded.SubEntry(nameof(ClassDummy.BoolArray)); for (var i = 0; i < 5; i++) + { boolEntry.SubEntries[i].Identifier = Entry.CreatedIdentifier + i; + } // Act var dummy = EntryConvert.CreateInstance(encoded); // Assert for (var i = 0; i < 5; i++) + { Assert.That(dummy.BoolArray[i], Is.True); + } } [Test] @@ -59,14 +63,18 @@ public void ShouldNotCreateInstanceArray_WithIdentifier_ThatEnd_With_CREATED() var boolEntry = encoded.SubEntry(nameof(ClassDummy.BoolArray)); for (var i = 0; i < 5; i++) + { boolEntry.SubEntries[i].Identifier = i + Entry.CreatedIdentifier; + } // Act var dummy = EntryConvert.CreateInstance(encoded); // Assert for (var i = 0; i < 5; i++) + { Assert.That(dummy.BoolArray[i], Is.Not.True); + } } [Test] @@ -79,10 +87,14 @@ public void CreateInstanceWithArray() var entry2 = encoded.SubEntry(nameof(ClassDummy.EnumArray)); for (var i = 1; i <= 5; i++) + { entry1.AddFromPrototype((i % 2 != 0).ToString()); + } for (var i = 1; i <= 5; i++) + { entry2.AddFromPrototype(entry2.Prototypes[0].Value.Possible[i % 3].Key); + } // Act var dummy = EntryConvert.CreateInstance(encoded); @@ -106,10 +118,14 @@ public void CreateInstanceWithDictionary() var entry2 = encoded.SubEntry(nameof(DictionaryClassDummy.EnumDictionary)); for (var i = 1; i <= 5; i++) + { entry1.AddFromPrototype((1 + i).ToString(CultureInfo.InvariantCulture)).DisplayName = "Key" + i; + } for (var i = 1; i <= 3; i++) + { entry2.AddFromPrototype(((EnumDummy)(i % 3)).ToString()).DisplayName = "Key_0121" + i; + } // Act var dummy = EntryConvert.CreateInstance(encoded); @@ -148,13 +164,17 @@ public void UpdateDictionary() var entry2 = encoded.SubEntry(nameof(DictionaryClassDummy.EnumDictionary)); for (var i = 1; i <= 2; i++) + { entry1.AddFromPrototype((1 + i).ToString(CultureInfo.InvariantCulture)).DisplayName = "Key" + i; + } entry1.SubEntries[0].Value.Current = "123"; entry1.SubEntries[0].DisplayName = "022"; for (var i = 1; i <= 3; i++) + { entry2.AddFromPrototype(((EnumDummy)(i % 3)).ToString()).DisplayName = "Key_0121" + i; + } entry2.SubEntries[0].Value.Current = nameof(EnumDummy.ValueA); entry2.SubEntries[0].DisplayName = "555"; @@ -222,7 +242,9 @@ public void CreateInstanceWithPrimitiveList() var ent = encoded.SubEntry(nameof(ListDummy.DoubleList)); for (var i = 1; i <= 5; i++) + { ent.AddFromPrototype((1 + i).ToString(CultureInfo.InvariantCulture)); + } // Act var listDummy = EntryConvert.CreateInstance(encoded); @@ -486,9 +508,14 @@ public void RemoveEntry(CollectionType type, int prefill, int[] removedIndexes) // Act var colEntry = CollectionEntry(encoded, type); if (type == CollectionType.Dictionary) + { colEntry.SubEntries.RemoveAll(e => removedIndexes.Contains(int.Parse(e.Identifier, CultureInfo.InvariantCulture) - 1)); + } else + { colEntry.SubEntries.RemoveAll(e => removedIndexes.Contains(int.Parse(e.Identifier, CultureInfo.InvariantCulture))); + } + EntryConvert.UpdateInstance(obj, encoded); // Assert @@ -502,7 +529,9 @@ public void RemoveEntry(CollectionType type, int prefill, int[] removedIndexes) for (var i = 0; i < prefill; i++) { if (removedIndexes.Contains(i)) + { continue; + } var match = array.FirstOrDefault(e => e.Key == i + 1); Assert.That(match, Is.Not.Null); @@ -514,7 +543,9 @@ public void RemoveEntry(CollectionType type, int prefill, int[] removedIndexes) for (var i = 0; i < prefill; i++) { if (removedIndexes.Contains(i)) + { continue; + } var match = array.FirstOrDefault(e => e.Foo == i + 1); Assert.That(match, Is.Not.Null); diff --git a/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryEncoderTests.cs b/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryEncoderTests.cs index 5429e69c7a..be3a8dc820 100644 --- a/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryEncoderTests.cs +++ b/src/Tests/Moryx.Tests/Serialization/EntryConvert/EntryEncoderTests.cs @@ -225,7 +225,7 @@ public void EncodeObject_WithItemsTargetButNoEncoderType_Throws() Assert.Throws(() => EntryConvert.EncodeObject(dummy)); } - private class MissingItemsEncoderDummy + private sealed class MissingItemsEncoderDummy { [EntrySerialize(EncoderTarget = EntryEncoderTarget.Items)] public List Items { get; set; } diff --git a/src/Tests/Moryx.Tests/Serialization/EntryConvert/PossibleValuesTests.cs b/src/Tests/Moryx.Tests/Serialization/EntryConvert/PossibleValuesTests.cs index f3f420a629..1f8c4b2485 100644 --- a/src/Tests/Moryx.Tests/Serialization/EntryConvert/PossibleValuesTests.cs +++ b/src/Tests/Moryx.Tests/Serialization/EntryConvert/PossibleValuesTests.cs @@ -38,7 +38,9 @@ public void PrimitiveCollectionPrototypes(bool possibleValues) Assert.That(enums.Value.Possible.Length, Is.EqualTo(3)); Assert.That(enums.Prototypes.Count, Is.EqualTo(3)); for (int i = 0; i < 3; i++) + { Assert.That(enums.Prototypes[i].Value.Current, Is.EqualTo(enums.Value.Possible[i].Key)); + } } [Test] diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncStateMachineTests.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncStateMachineTests.cs index fb4ffa7fab..f791bd97d6 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncStateMachineTests.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncStateMachineTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Threading.Tasks; using Moryx.StateMachines; using Moryx.Tests.AsyncTestMachine; using NUnit.Framework; @@ -74,7 +72,6 @@ public async Task CtoAState() Assert.That(context.CtoATriggered); } - [Test(Description = "Create a StateMachine with a specific initial state key.")] public async Task CreateWithSpecificInitialState() { diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/AAsyncState.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/AAsyncState.cs index 43714d328e..d379f872c9 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/AAsyncState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/AAsyncState.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; - namespace Moryx.Tests.AsyncTestMachine; internal sealed class AAsyncState : MyAsyncStateBase @@ -28,4 +25,4 @@ public override async Task AtoBAsync() await NextStateAsync(StateB); await Context.HandleAtoB(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/BAsyncState.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/BAsyncState.cs index b40a67452d..a310ddba28 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/BAsyncState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/BAsyncState.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; - namespace Moryx.Tests.AsyncTestMachine; internal sealed class BAsyncState : MyAsyncStateBase @@ -23,4 +20,4 @@ public override async Task BtoCAsync() await NextStateAsync(StateC); await Context.HandleBtoC(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/CAsyncState.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/CAsyncState.cs index f43308ec6d..4428043942 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/CAsyncState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/CAsyncState.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; - namespace Moryx.Tests.AsyncTestMachine; internal sealed class CAsyncState : MyAsyncStateBase @@ -16,4 +14,4 @@ public override async Task CtoAAsync() await NextStateAsync(StateA); await Context.HandleCtoA(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncContext.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncContext.cs index 69d862716c..8912f0243b 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncContext.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncContext.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading; -using System.Threading.Tasks; using Moryx.StateMachines; namespace Moryx.Tests.AsyncTestMachine; @@ -44,4 +42,4 @@ public Task SetStateAsync(StateBase state, CancellationToken cancellationToken) State = (MyAsyncStateBase)state; return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncStateBase.cs b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncStateBase.cs index 1860796b9d..1b53d5c767 100644 --- a/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncStateBase.cs +++ b/src/Tests/Moryx.Tests/StateMachines/AsyncTestMachine/MyAsyncStateBase.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Threading.Tasks; using Moryx.StateMachines; namespace Moryx.Tests.AsyncTestMachine; diff --git a/src/Tests/Moryx.Tests/StateMachines/StateMachineTests.cs b/src/Tests/Moryx.Tests/StateMachines/StateMachineTests.cs index b6ecee99e3..0f74700a29 100644 --- a/src/Tests/Moryx.Tests/StateMachines/StateMachineTests.cs +++ b/src/Tests/Moryx.Tests/StateMachines/StateMachineTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moryx.StateMachines; using NUnit.Framework; @@ -15,13 +14,10 @@ public void Initial() { //Arrange var context = CreateContext(); + // Act // Assert - Assert.DoesNotThrow(delegate - { - // Act - context.State.Initial(); - }); + Assert.DoesNotThrow(context.State.Initial); } [Test(Description = "Test transition from A to B state. This state is only possible in AState")] @@ -99,7 +95,7 @@ public void CreateWithSpecificInitialState() // Assert using var _ = Assert.EnterMultipleScope(); Assert.That(context.State.Key == bkey); - Assert.Throws(() => context.State.Initial()); + Assert.Throws(context.State.Initial); } [Test(Description = "Create a StateMachine with an unknown initial state key.")] @@ -127,7 +123,7 @@ public void ForceState() StateMachine.Force(context.State, MyStateBase.StateA); // Assert - Assert.DoesNotThrow(() => context.State.AtoB()); + Assert.DoesNotThrow(context.State.AtoB); } [Test(Description = "Brings the StateMachine to B and force to A with exiting the current state.")] diff --git a/src/Tests/Moryx.Tests/StateMachines/TestMachine/AState.cs b/src/Tests/Moryx.Tests/StateMachines/TestMachine/AState.cs index 06d3716cf6..52a6cfb5fc 100644 --- a/src/Tests/Moryx.Tests/StateMachines/TestMachine/AState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/TestMachine/AState.cs @@ -24,4 +24,4 @@ public override void AtoB() NextState(StateB); Context.HandleAtoB(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/TestMachine/BState.cs b/src/Tests/Moryx.Tests/StateMachines/TestMachine/BState.cs index 112a4b085f..96d8a4c653 100644 --- a/src/Tests/Moryx.Tests/StateMachines/TestMachine/BState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/TestMachine/BState.cs @@ -19,4 +19,4 @@ public override void BtoC() NextState(StateC); Context.HandleBtoC(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/TestMachine/CState.cs b/src/Tests/Moryx.Tests/StateMachines/TestMachine/CState.cs index 7faa7e0ec8..ba28c09865 100644 --- a/src/Tests/Moryx.Tests/StateMachines/TestMachine/CState.cs +++ b/src/Tests/Moryx.Tests/StateMachines/TestMachine/CState.cs @@ -14,4 +14,4 @@ public override void CtoA() NextState(StateA); Context.HandleCtoA(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyContext.cs b/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyContext.cs index cb1e8bf583..3b91ab2385 100644 --- a/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyContext.cs +++ b/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyContext.cs @@ -38,4 +38,4 @@ void IStateContext.SetState(StateBase state) { State = (MyStateBase)state; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyStateBase.cs b/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyStateBase.cs index d6491d1c9c..156333e03f 100644 --- a/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyStateBase.cs +++ b/src/Tests/Moryx.Tests/StateMachines/TestMachine/MyStateBase.cs @@ -40,4 +40,4 @@ public virtual void CtoA() [StateDefinition(typeof(CState))] public const int StateC = 30; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Threading/EventDecouplerTests.cs b/src/Tests/Moryx.Tests/Threading/EventDecouplerTests.cs index e46f0048a9..7884b83bf6 100644 --- a/src/Tests/Moryx.Tests/Threading/EventDecouplerTests.cs +++ b/src/Tests/Moryx.Tests/Threading/EventDecouplerTests.cs @@ -1,10 +1,7 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Diagnostics; -using System.Linq; -using System.Threading; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moryx.Logging; @@ -112,7 +109,7 @@ private void BlockingTarget(object sender, ManualResetEvent blockingEvent) #region ExceptionAndLogging - private class InvocationTarget : ILoggingComponent + private sealed class InvocationTarget : ILoggingComponent { public Tuple Message { get; set; } @@ -137,9 +134,13 @@ public void ExceptionInHandler(bool targetHasLogger) // Arrange var target = new InvocationTarget(); if (targetHasLogger) + { SimpleEventSource += _parallelOperations.DecoupleListener(target.FaultyListener); + } else + { SimpleEventSource += _parallelOperations.DecoupleListener(FaultyListener); + } // Act SimpleEventSource(this, EventArgs.Empty); while (target.Message == null && _message == null) @@ -199,7 +200,9 @@ public void WriteFromMultipleThreads() // Give the queue time to catch up var runFragment = MaxIndex / run; while (_count < (index > runFragment ? index : runFragment)) + { Thread.Sleep(1); + } } // Assert diff --git a/src/Tests/Moryx.Tests/Threading/NonStackingTimerCallbackTests.cs b/src/Tests/Moryx.Tests/Threading/NonStackingTimerCallbackTests.cs index a7d1eeee8c..b3dde6df19 100644 --- a/src/Tests/Moryx.Tests/Threading/NonStackingTimerCallbackTests.cs +++ b/src/Tests/Moryx.Tests/Threading/NonStackingTimerCallbackTests.cs @@ -56,4 +56,4 @@ private void SimpleCallback() { _counter++; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Threading/ParallelOperationTests.cs b/src/Tests/Moryx.Tests/Threading/ParallelOperationTests.cs index 89151e4c0e..a0d7ee904e 100644 --- a/src/Tests/Moryx.Tests/Threading/ParallelOperationTests.cs +++ b/src/Tests/Moryx.Tests/Threading/ParallelOperationTests.cs @@ -1,14 +1,12 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Diagnostics; -using System.Threading; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Moryx.Logging; using Moryx.Threading; using NUnit.Framework; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Logging; namespace Moryx.Tests.Threading; @@ -203,7 +201,7 @@ private void ExceptionCallback(StateObject state) } } - private class StateObject + private sealed class StateObject { public int Counter { get; set; } } @@ -218,4 +216,4 @@ private void AwaitLogMessage() Thread.Sleep(1); } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Tools/FunctionResultTestsBase.cs b/src/Tests/Moryx.Tests/Tools/FunctionResultTestsBase.cs index 621bdc6396..6cc979f3b8 100644 --- a/src/Tests/Moryx.Tests/Tools/FunctionResultTestsBase.cs +++ b/src/Tests/Moryx.Tests/Tools/FunctionResultTestsBase.cs @@ -10,4 +10,4 @@ public class FunctionResultTestsBase { protected const string Message = "Error occured!"; protected const string ExceptionMessage = "Exception Message"; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Tools/FunctionResultWithNothingTests.cs b/src/Tests/Moryx.Tests/Tools/FunctionResultWithNothingTests.cs index e176a20d01..31670b918c 100644 --- a/src/Tests/Moryx.Tests/Tools/FunctionResultWithNothingTests.cs +++ b/src/Tests/Moryx.Tests/Tools/FunctionResultWithNothingTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using Moq; using Moryx.Tools; using NUnit.Framework; diff --git a/src/Tests/Moryx.Tests/Tools/FunctionResultWithTypeTests.cs b/src/Tests/Moryx.Tests/Tools/FunctionResultWithTypeTests.cs index d40ae46c60..fd6dbbcfa9 100644 --- a/src/Tests/Moryx.Tests/Tools/FunctionResultWithTypeTests.cs +++ b/src/Tests/Moryx.Tests/Tools/FunctionResultWithTypeTests.cs @@ -1,7 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; using System.Globalization; using Moq; using Moryx.Tools; diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/DummyStep.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/DummyStep.cs index 16887f50b6..6e41f69089 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/DummyStep.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/DummyStep.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using System.Runtime.Serialization; using Moryx.Serialization; using Moryx.Workplans; @@ -55,13 +53,17 @@ protected override void InputTokenAdded(object sender, IToken token) StoredTokens.Add(token); Triggered(this, EventArgs.Empty); if (ResultOutput >= 0) // Resume directly + { PlaceToken(Outputs[ResultOutput], StoredTokens.First()); + } } public override void Resume() { if (StoredTokens.Any()) + { Triggered(this, EventArgs.Empty); + } } public void ResumeAsync(int result) @@ -70,4 +72,4 @@ public void ResumeAsync(int result) } public event EventHandler Triggered; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/DummyToken.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/DummyToken.cs index 1e3d5c639f..dd83daefa3 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/DummyToken.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/DummyToken.cs @@ -11,4 +11,4 @@ public class DummyToken : IToken /// Token name /// public string Name { get { return "DummyToken"; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/EmptyParametersStep.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/EmptyParametersStep.cs index 97c6c91a84..1e69537600 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/EmptyParametersStep.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/EmptyParametersStep.cs @@ -28,4 +28,4 @@ protected override TransitionBase Instantiate(IWorkplanContext context) { return null; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/InvalidStep.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/InvalidStep.cs index beb1ea3ab9..f964e70c58 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/InvalidStep.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/InvalidStep.cs @@ -19,4 +19,4 @@ protected override TransitionBase Instantiate(IWorkplanContext context) { return new DummyTransition(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/MoveTransition.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/MoveTransition.cs index 146c4ef93e..4d8a196bc3 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/MoveTransition.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/MoveTransition.cs @@ -6,7 +6,7 @@ namespace Moryx.Tests.Workplans; -internal class MoveTransition : TransitionBase +internal sealed class MoveTransition : TransitionBase { protected override void InputTokenAdded(object sender, IToken token) { diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/ParameterStep.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/ParameterStep.cs index 6e23352bee..0771c5702d 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/ParameterStep.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/ParameterStep.cs @@ -8,7 +8,7 @@ namespace Moryx.Tests.Workplans; -internal class ParameterStep : WorkplanStepBase, IParameterHolder +internal sealed class ParameterStep : WorkplanStepBase, IParameterHolder { public ParameterStep() { @@ -30,7 +30,7 @@ public DummyParameters Export() } } -internal class ParameterConstructorStep : WorkplanStepBase, IParameterHolder +internal sealed class ParameterConstructorStep : WorkplanStepBase, IParameterHolder { private readonly DummyParameters _parameters; @@ -57,11 +57,11 @@ internal interface IParameterHolder DummyParameters Export(); } -internal class DummyParameters +internal sealed class DummyParameters { [EntrySerialize] public int Number { get; set; } [EntrySerialize] public string Name { get; set; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/PausableStep.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/PausableStep.cs index 7ec21254b7..ca6ab60982 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/PausableStep.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/PausableStep.cs @@ -1,14 +1,13 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System.Linq; using Moryx.Workplans; using Moryx.Workplans.Transitions; using Moryx.Workplans.WorkplanSteps; namespace Moryx.Tests.Workplans; -internal class PausableStep : WorkplanStepBase +internal sealed class PausableStep : WorkplanStepBase { public PausableStep() { @@ -22,7 +21,7 @@ protected override TransitionBase Instantiate(IWorkplanContext context) } } -internal class PausableTransition : TransitionBase +internal sealed class PausableTransition : TransitionBase { /// protected override void InputTokenAdded(object sender, IToken token) @@ -48,4 +47,4 @@ public override void Resume() PlaceToken(Outputs[0], StoredTokens.First()); base.Resume(); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/Dummies/WorkplanDummy.cs b/src/Tests/Moryx.Tests/Workplans/Dummies/WorkplanDummy.cs index 2e90035b80..a88e6211c3 100644 --- a/src/Tests/Moryx.Tests/Workplans/Dummies/WorkplanDummy.cs +++ b/src/Tests/Moryx.Tests/Workplans/Dummies/WorkplanDummy.cs @@ -1,9 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 +using System.Drawing; using Moryx.Workplans; using Moryx.Workplans.WorkplanSteps; -using System.Drawing; namespace Moryx.Tests.Workplans; @@ -436,4 +436,4 @@ public static WorkplanDummy WithLoop() return workplan; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/EngineTests.cs b/src/Tests/Moryx.Tests/Workplans/EngineTests.cs index a6d83d5647..c963812dab 100644 --- a/src/Tests/Moryx.Tests/Workplans/EngineTests.cs +++ b/src/Tests/Moryx.Tests/Workplans/EngineTests.cs @@ -35,7 +35,7 @@ public void InstantiateWorkplan() Assert.That(workplanInstance.EndPlaces().First(), Is.EqualTo(transitions[2].Outputs[0])); } - private class FakeContext : IWorkplanContext + private sealed class FakeContext : IWorkplanContext { public bool IsDisabled(IWorkplanStep step) { @@ -58,7 +58,10 @@ public void ExecuteWorkplanInstance(ExecutionPath route, int expectedTransitions { var dummy = (DummyTransition)transition; if (route == ExecutionPath.Alternative) + { dummy.ResultOutput = dummy.Outputs.Length - 1; + } + triggerCount++; path += "->" + dummy.Name; }; diff --git a/src/Tests/Moryx.Tests/Workplans/PathPredictionTests.cs b/src/Tests/Moryx.Tests/Workplans/PathPredictionTests.cs index e96dabc853..5b28ab58b8 100644 --- a/src/Tests/Moryx.Tests/Workplans/PathPredictionTests.cs +++ b/src/Tests/Moryx.Tests/Workplans/PathPredictionTests.cs @@ -2,8 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Diagnostics; -using System.Linq; -using System.Threading; using Moryx.Tools; using Moryx.Workplans; using NUnit.Framework; @@ -63,7 +61,10 @@ public void PredictFailureBeforeCompletion() // Assert while (finalResult == NodeClassification.Intermediate) + { Thread.Sleep(1); // Await completion + } + stopWatch.Stop(); Assert.That(predictionTime, Is.LessThan(completionTime), "Engine was completed before a prediction was published."); Assert.That(prediction, Is.EqualTo(finalResult), "Predication was incorrect"); @@ -98,7 +99,10 @@ public void PublishPredictionAfterInterruption() // Assert while (finalResult == NodeClassification.Intermediate) + { Thread.Sleep(1); // Await completion + } + Assert.That(prediction, Is.EqualTo(finalResult), "Predication was incorrect"); } @@ -131,11 +135,14 @@ public void PredictorShouldSupportLoops() // Assert while (finalResult == NodeClassification.Intermediate) + { Thread.Sleep(1); // Await completion + } + Assert.That(prediction, Is.EqualTo(finalResult), "Predication was incorrect"); } - private class SingleLoopExecution + private sealed class SingleLoopExecution { private bool _loopTaken; @@ -144,7 +151,9 @@ public void ResumeAsync(object state) var transition = (DummyTransition)state; Thread.Sleep(100); if (_loopTaken || transition.Name != "Set pole") + { transition.ResumeAsync(0); + } else { transition.ResumeAsync(1); @@ -152,4 +161,4 @@ public void ResumeAsync(object state) } } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/PlacesTests.cs b/src/Tests/Moryx.Tests/Workplans/PlacesTests.cs index a0afb7015a..885f0212ba 100644 --- a/src/Tests/Moryx.Tests/Workplans/PlacesTests.cs +++ b/src/Tests/Moryx.Tests/Workplans/PlacesTests.cs @@ -21,14 +21,21 @@ public void AddToken(bool paused) // Act if (paused) + { place.Pause(); + } + place.Add(dummy); // Assert if (paused) + { Assert.That(raised, Is.Null); + } else + { Assert.That(raised, Is.EqualTo(dummy)); + } } [Test] @@ -58,11 +65,16 @@ public void Remove(bool exisiting, bool eventRaised) var place = new Place(); var dummy = new DummyToken(); if (eventRaised) + { place.TokenRemoved += (sender, token) => { }; + } // Act if (exisiting) + { place.Tokens = [dummy]; + } + place.Remove(dummy); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/SerializationTest.cs b/src/Tests/Moryx.Tests/Workplans/SerializationTest.cs index 44279f1481..f48f85e609 100644 --- a/src/Tests/Moryx.Tests/Workplans/SerializationTest.cs +++ b/src/Tests/Moryx.Tests/Workplans/SerializationTest.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0 using System.Drawing; -using System.Linq; using Moryx.Serialization; using Moryx.Workplans; using Newtonsoft.Json; @@ -41,4 +40,4 @@ public void JsonCycle() Assert.That(deserialized.Steps.First().Name, Is.EqualTo(workplan.Steps.First().Name)); Assert.That(deserialized.Steps.First().Position, Is.EqualTo(workplan.Steps.First().Position)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/StepTests.cs b/src/Tests/Moryx.Tests/Workplans/StepTests.cs index fcbf5cced1..744b6f97fb 100644 --- a/src/Tests/Moryx.Tests/Workplans/StepTests.cs +++ b/src/Tests/Moryx.Tests/Workplans/StepTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; using Moryx.Workplans; using Moryx.Workplans.Transitions; using Moryx.Workplans.WorkplanSteps; @@ -72,4 +70,4 @@ public void SubWorkplan() Assert.That(failed.OutputType, Is.EqualTo(OutputType.Failure)); Assert.That(failed.MappingValue, Is.EqualTo(exits[1].Id)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Tests/Workplans/TransitionTests.cs b/src/Tests/Moryx.Tests/Workplans/TransitionTests.cs index 03e1a44f47..26aba48c7f 100644 --- a/src/Tests/Moryx.Tests/Workplans/TransitionTests.cs +++ b/src/Tests/Moryx.Tests/Workplans/TransitionTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; using Moryx.Workplans; using Moryx.Workplans.Transitions; using NUnit.Framework; diff --git a/src/Tests/Moryx.VisualInstructions.Controller.Tests/InstructionProcessorTests.cs b/src/Tests/Moryx.VisualInstructions.Controller.Tests/InstructionProcessorTests.cs index 389add2297..9c94a73c2d 100644 --- a/src/Tests/Moryx.VisualInstructions.Controller.Tests/InstructionProcessorTests.cs +++ b/src/Tests/Moryx.VisualInstructions.Controller.Tests/InstructionProcessorTests.cs @@ -26,13 +26,25 @@ public void GuidReplacements(bool contentPattern, bool previewPattern, bool cont // Arrange var config = new InstructionProcessorConfig(); if (contentPattern) + { config.ContentPattern = GuidPattern; + } + if (previewPattern) + { config.PreviewPattern = GuidPattern; + } + if (contentReplacement) + { config.ContentReplacement = GuidContentReplacement; + } + if (previewReplacement) + { config.PreviewReplacement = GuidPreviewReplacement; + } + var processor = new InstructionProcessor(config); // Act @@ -45,8 +57,13 @@ public void GuidReplacements(bool contentPattern, bool previewPattern, bool cont // Assert if (contentReplacement) + { Assert.That(item.Content, Is.EqualTo(@"moryx://media/guid/35afe06d-8393-4559-b6d7-74d35ce131d8?v=Master")); + } + if (previewReplacement) + { Assert.That(item.Preview, Is.EqualTo(@"http://moryx-server/media/preview/35afe06d-8393-4559-b6d7-74d35ce131d8")); + } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.VisualInstructions.Controller.Tests/ParameterBindingTests.cs b/src/Tests/Moryx.VisualInstructions.Controller.Tests/ParameterBindingTests.cs index a4b6abe642..503c771c94 100644 --- a/src/Tests/Moryx.VisualInstructions.Controller.Tests/ParameterBindingTests.cs +++ b/src/Tests/Moryx.VisualInstructions.Controller.Tests/ParameterBindingTests.cs @@ -1,8 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; using Moryx.AbstractionLayer.Activities; using Moryx.AbstractionLayer.Identity; using Moryx.AbstractionLayer.Processes; @@ -257,7 +255,9 @@ public class InsertPartParameters : Parameters protected override void Populate(Process process, Parameters instance) { if (_resolver == null) + { _resolver = ResolverFactory.Create(Part); + } var parameters = (InsertPartParameters)instance; parameters.Target = (ProductType)_resolver.Resolve(process); @@ -311,14 +311,14 @@ private static ProductionProcess DummyProcess() return process; } - private class DummyRecipe : ProductionRecipe + private sealed class DummyRecipe : ProductionRecipe { public string OrderNumber { get; set; } public Dictionary Config { get; set; } } - private class DummyProduct : ProductType + private sealed class DummyProduct : ProductType { public int Foo { get; set; } @@ -334,7 +334,7 @@ protected override ProductInstance Instantiate() public ProductPartLink Part { get; set; } } - private class DummyValue + private sealed class DummyValue { public DummyValue(DummyProduct product) { @@ -347,10 +347,10 @@ public DummyValue(DummyProduct product) public DummyProduct Product { get; } } - private class DummyProductInstance : ProductInstance, IIdentifiableObject + private sealed class DummyProductInstance : ProductInstance, IIdentifiableObject { public IIdentity Identity { get; set; } public float Blah { get; set; } } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.VisualInstructions.Controller.Tests/VisualInstructionsControllerTests.cs b/src/Tests/Moryx.VisualInstructions.Controller.Tests/VisualInstructionsControllerTests.cs index d2d1b59a2f..d387d60938 100644 --- a/src/Tests/Moryx.VisualInstructions.Controller.Tests/VisualInstructionsControllerTests.cs +++ b/src/Tests/Moryx.VisualInstructions.Controller.Tests/VisualInstructionsControllerTests.cs @@ -90,4 +90,4 @@ public void ForwardMethodsToResource() // Assert _instructor.Verify(rm => rm.Completed(response), Times.Once); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsControllerTests.cs b/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsControllerTests.cs index 0f78cb7b0a..494dedff2f 100644 --- a/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsControllerTests.cs +++ b/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsControllerTests.cs @@ -1,9 +1,6 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Linq; -using Microsoft.Extensions.Logging.Abstractions; using Moq; using Moryx.Runtime.Modules; using NUnit.Framework; diff --git a/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsFacadeMock.cs b/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsFacadeMock.cs index b36b945910..11d0cc9e42 100644 --- a/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsFacadeMock.cs +++ b/src/Tests/Moryx.VisualInstructions.Endpoints.Tests/VisualInstructionsFacadeMock.cs @@ -1,13 +1,9 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; - namespace Moryx.VisualInstructions.Endpoints.Tests; -internal class VisualInstructionsFacadeMock : IVisualInstructions +internal sealed class VisualInstructionsFacadeMock : IVisualInstructions { private readonly Dictionary> _instructions; diff --git a/src/Tests/Moryx.VisualInstructions.Tests/VisualInstructorExtensionsTests.cs b/src/Tests/Moryx.VisualInstructions.Tests/VisualInstructorExtensionsTests.cs index 16aad5388d..cfde1ea872 100644 --- a/src/Tests/Moryx.VisualInstructions.Tests/VisualInstructorExtensionsTests.cs +++ b/src/Tests/Moryx.VisualInstructions.Tests/VisualInstructorExtensionsTests.cs @@ -19,4 +19,4 @@ public void ExtensionCreatesStringAsInstruction() Assert.That(instruction.Type, Is.EqualTo(InstructionContentType.Text)); Assert.That(instruction.Content, Is.EqualTo(str)); } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Workplans.Editing.Tests/DummyStep.cs b/src/Tests/Moryx.Workplans.Editing.Tests/DummyStep.cs index d4224f7e00..7f21c94993 100644 --- a/src/Tests/Moryx.Workplans.Editing.Tests/DummyStep.cs +++ b/src/Tests/Moryx.Workplans.Editing.Tests/DummyStep.cs @@ -39,4 +39,4 @@ protected override TransitionBase Instantiate(IWorkplanContext context) { return new DummyTransition { Context = context, Name = Name }; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Workplans.Editing.Tests/DummyTransition.cs b/src/Tests/Moryx.Workplans.Editing.Tests/DummyTransition.cs index 8dc861d367..c39f26df0f 100644 --- a/src/Tests/Moryx.Workplans.Editing.Tests/DummyTransition.cs +++ b/src/Tests/Moryx.Workplans.Editing.Tests/DummyTransition.cs @@ -26,13 +26,17 @@ protected override void InputTokenAdded(object sender, IToken token) StoredTokens.Add(token); Triggered?.Invoke(this, EventArgs.Empty); if (ResultOutput >= 0) // Resume directly + { PlaceToken(Outputs[ResultOutput], StoredTokens.First()); + } } public override void Resume() { if (StoredTokens.Any()) + { Triggered?.Invoke(this, EventArgs.Empty); + } } public void ResumeAsync(int result) @@ -41,4 +45,4 @@ public void ResumeAsync(int result) } public event EventHandler? Triggered; -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Workplans.Editing.Tests/DummyWorkplan.cs b/src/Tests/Moryx.Workplans.Editing.Tests/DummyWorkplan.cs index 67f207343d..5d6735d6f9 100644 --- a/src/Tests/Moryx.Workplans.Editing.Tests/DummyWorkplan.cs +++ b/src/Tests/Moryx.Workplans.Editing.Tests/DummyWorkplan.cs @@ -1,8 +1,8 @@ // Copyright (c) 2026 Phoenix Contact GmbH & Co. KG // Licensed under the Apache License, Version 2.0 -using Moryx.Workplans; using System.Drawing; +using Moryx.Workplans; namespace Moryx.Tests.Workplans; @@ -76,4 +76,4 @@ public WorkplanDummy() this.Add(StepC); StepC.Outputs[0] = StepC.Outputs[1] = EndConnector; } -} \ No newline at end of file +} diff --git a/src/Tests/Moryx.Workplans.Editing.Tests/WorkplanEditingSessionTests.cs b/src/Tests/Moryx.Workplans.Editing.Tests/WorkplanEditingSessionTests.cs index 91712ae9c1..46265cd9a1 100644 --- a/src/Tests/Moryx.Workplans.Editing.Tests/WorkplanEditingSessionTests.cs +++ b/src/Tests/Moryx.Workplans.Editing.Tests/WorkplanEditingSessionTests.cs @@ -3,8 +3,8 @@ #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. -using NUnit.Framework; using Moryx.Tests.Workplans; +using NUnit.Framework; namespace Moryx.Workplans.Editing.Tests; @@ -85,10 +85,15 @@ private static bool HasLoseConnectors(WorkplanDummy workplan) foreach (var connector in workplan.Connectors) { if (connector.Classification != NodeClassification.Intermediate) + { continue; + } + if (!workplan.Steps.Any(s => s.Outputs.Contains(connector)) && !workplan.Steps.Any(s => s.Inputs.Contains(connector))) + { return true; + } } return false; } -} \ No newline at end of file +} From 84b6dd7322e244b9d0433bb86958d1d9125ff205 Mon Sep 17 00:00:00 2001 From: Marcel Vielhaus Date: Sat, 7 Nov 2026 01:21:18 +0100 Subject: [PATCH 2/2] Add verify formatting action To reduce the need for PR discussions about formatting, at least the correct dotnet formatting can easily be verifies automatically. --- .github/workflows/build-and-test.yml | 15 +++++++++++++++ MORYX-Framework.slnx | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 75af3fc83e..0aef1335c6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -46,6 +46,21 @@ jobs: node_version: ${{ needs.EnvVar.outputs.node_version }} REPOSITORY_NAME: ${{ needs.EnvVar.outputs.REPOSITORY_NAME }} + FormatCheck: + name: Format check + needs: [EnvVar] + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ needs.EnvVar.outputs.dotnet_sdk_version }} + + - name: Verify formatting + run: dotnet format "${{ github.workspace }}/MORYX-Framework.slnx" --verify-no-changes --verbosity minimal + UnitTests: name: Unit Tests needs: [EnvVar, Build] diff --git a/MORYX-Framework.slnx b/MORYX-Framework.slnx index 59e3703ccb..cc2ff40f4e 100644 --- a/MORYX-Framework.slnx +++ b/MORYX-Framework.slnx @@ -101,6 +101,9 @@ + + + @@ -186,5 +189,5 @@ - + \ No newline at end of file