Process Business Activity
Introduction
ProcessBusinessActivity is the base class for MES-specific nodes, inheriting from BusinessActivity. It provides common infrastructure for all process-related business nodes. This class encapsulates common functions such as recipe application, production record query, inspection task detection, and current user acquisition, simplifying the development of process nodes.
Inheritance Relationship
BusinessActivity (FlowManagement.Abstractions)
└── ProcessBusinessActivity (MesSuite.Activitys)
├── GenerateCodeActivity
├── InboundInitializeActivity
├── InboundDetectionActivity
│ ├── DuplicateCodeDetectionActivity
│ ├── ProductStateDetectionActivity
│ ├── MissingProcessDetectionActivity
│ └── ProductAutomaticRepairActivity
├── OutboundInitializeActivity
├── MaterialDetectionActivity
├── MaterialVerificationActivity
├── MaterialDeductionActivity
├── MaterialIntegrityDetectionActivity
├── QualificationJudgmentActivity
├── DistributeFormulaActivity
├── ParameterCollectActivity
├── PrintLabelActivity
└── ... (Other process nodes)
Provided Common Methods
1. InitFormulaApplyModel - Initialize Recipe Application Model
Gets recipe information applied to the current process.
protected virtual async Task<FormulaApplyModel> InitFormulaApplyModel(
ProcessModel processModel,
bool forceRefresh = false)
Description:
- Prioritizes getting cached recipe application from flow context.
- If not exists or forced refresh, queries from service.
- Query result is cached to flow context.
2. GetProductionAsync - Get Production Record
Queries production record, order, and product information based on product serial number.
protected virtual async Task<(
AssociationProductModel ProductModel,
OrderModel OrderModel,
ProductionRecordModel RecordModel)> GetProductionAsync(
ProcessModel processModel,
string serialNumber)
Return Value: Tuple containing:
ProductModel- Product Model InformationOrderModel- Order InformationRecordModel- Production Record Information
3. HasInspectionAsync - Detect Inspection Task
Detects if there is an executing inspection task for the current process.
protected virtual async Task<(
bool HasInspectionMark,
InspectionPointTaskModel InspectionPointTask)> HasInspectionAsync(
ProcessModel processModel)
4. GetCurrentUser - Get Current User
Gets the login user information for the current station.
protected string GetCurrentUser(ProcessModel processModel)
Return Value: string - User Name (multiple users separated by comma)
Flow Context Variables
Flow context variables used and set by this base class:
| Variable Name | Constant | Type | Description |
|---|---|---|---|
| FormulaApplyModel | FlowItemCollection.FormulaApplyModel | FormulaApplyModel | Recipe Application Model |
| InspectionPointTaskModel | FlowItemCollection.InspectionPointTaskModel | InspectionPointTaskModel | Inspection Task Model |
Usage Example
Create Custom Process Node
[Design("Custom Process", "Custom Process Step"), Category("Process Step")]
[Serializable]
public class CustomProcessActivity : ProcessBusinessActivity
{
public override async Task ProcessAsync(ProcessflowEventArgs args)
{
// Get process model
var processModel = Flow.DataItems.ApplicationData as ProcessModel;
// Use base class method to get recipe application
var formulaModel = await InitFormulaApplyModel(processModel);
// Check for inspection task
(var hasInspection, var task) = await HasInspectionAsync(processModel);
// Get current user
var currentUser = GetCurrentUser(processModel);
// Custom business logic
// ...
}
}