Message Engine
1. Message Type
2. Implementation Method
Message Type
The system has two built-in implementation types: workflow message and custom message.
The workflow message comes from the settings of the workflow. Different messages are generated in different flows. For example, after the project changes are processed, notify the relevant persons in charge of the engineering department and Production Department. This function can be directly set in the workflow.
Another type of workflow message comes from built-in messages. For example, after the MRP operation is generated, a large amount of requirements prompt information is generated. After posting a sales order, you can also send an email to the warehouse group to arrange delivery.
The interface is as follows: workflow message and custom message.
Custom message is a message directly input here, which is equivalent to an internal communication box. When the notified person logs on to the ERP system, the notification message can be viewed. As shown in
In the workflow, the Message setting interface is as follows. The message here requires two key points.
1. The message can accept macro, that is, the user can define a macro, set the macro value rules, or from the database, or from the system environment variables, when a message is displayed in front of a user, it is dynamically assigned a value.
As shown in, security_level is macro. At runtime, the environment gives the variable value.
2. For a conditional message, for example, if condition A is met, send the message "got it"; otherwise, send the message "Understood". The conditional expression is as follows:
The difficulty of implementing this message mechanism is to parse conditional expressions.
Implementation Method
1. directly use native SQL + ADO. net, which is the safest way to create a new message table message and user table, and then save, send, and create a new table, and provide enough interface encapsulation for use in various situations.
Messages may be generatedProgramIs Not A. Net program. When web services is provided for other types of programs to call. The basic principle is that external programs have no knowledge about database tables and can only operate interfaces to achieve stability and unification.
If the server is temporarily unavailable, the message can be cached locally and sent again when it is connected to the server.
2. SQL Server services Broker Implementation
SQL Server 2005 imports services broker technology, which is another Implementation of message communication. In addition, there are a lot of built-in features, and the functions will certainly be better than the self-developed ADO. NET must be strong. The only regret may be that the services broker can only be on the SQL server platform and cannot be transplanted to other database platforms. In addition, it is only supported by SQL Server 05, A large number of users are using SQL Server 2000 ,. In terms of availability, it is worse than ADO. net.
Create queue inspectionqueue
Create service inspectionservice on queue inspectionqueue
Send message
Begin tran
Declare @ workrequest uniqueidentifier;
Begin dialog conversation @ workrequest
From Service inspectionservice
To service 'centralmaintenanceservice ';
Select @ workrequest;
Declare @ workrequest uniqueidentifier;
Set @ workrequest = '6af33b51-EE4A-DA11-91C9-00904B8B6392 ';
Send on conversation @ workrequest
('<Workrequest>
<Action> ECN posting </equipment>
<DATA> ecn00612001 </reason>
</Workrequest>'
);
Commit tran
3. Message Queue. Windows built-in mechanism message queue.
String queuename = @ ". \ private $ MSMQ ";
If (! System. messaging. messagequeue. exists (queuename ))
{
Messagequeue queue = system. messaging. messagequeue. Create (queuename, true );
}
Asynchronous receiving
Queue. receivecompleted + = new receivecompletedeventhandler (queuereceivecompleted );
Queue. beginreceive ();
Endreceive (asyncresult. asyncresult );