Summary of the invention
The technical problem to be solved in the present invention provides a kind of event notification method for processing business, overcomes the mode that prior art event notification method for processing business adopts the database lookup incident, can't satisfy the defective that the event notification real-time requires.
The present invention solves the problems of the technologies described above the technical scheme that is adopted to be:
A kind of event notification method for processing business comprises step:
A1, event data storage that the user is provided with are in the data of database table, and described event data comprises that the incident transmitting time stabs;
A2, the described event data that described incident transmitting time is stabbed greater than current system time are cached in the data structure of internal memory;
A3, the described data structure of timing scan, more current system time and described incident transmitting time are stabbed;
If the current system time of A4 is greater than or equal to described incident transmitting time and stabs, then described event data is sent to described user.
Described event notification method for processing business wherein also comprises steps A 5: described event data is carried out subsequent treatment.
Described event notification method for processing business, wherein said tables of data and described data structure have uniform data format, and described data layout comprises incident sequence number field, incident creator field, incident transmitting time stamp field, event content field, the person's of being alerted field and transmit status field.
Described event notification method for processing business, wherein said incident transmitting time stab and are made as the integer data.
Described event notification method for processing business wherein is provided with the main chain table in internal memory, described main chain table on time between span node is set, and derive from corresponding child list by each node, store described data structure by the node of described child list.
Described event notification method for processing business, the time sequencing that wherein said child list stabs by described incident transmitting time generates the child list node.
Described event notification method for processing business, wherein the subsequent treatment that described event data is carried out comprises and revises described tables of data, with described transmit status field identification for sending.
Described event notification method for processing business, wherein the subsequent treatment that described event data is carried out comprises deletion child list node, if the child list of this child list node correspondence is deleted the main chain table node of then deletion correspondence.
Beneficial effect of the present invention: event notification method for processing business of the present invention can improve the search efficiency of event data significantly, satisfies the real-time requirement of event notification, and does not influence the performance of system database.
Embodiment
With embodiment the present invention is described in further detail with reference to the accompanying drawings below:
The determinant attribute of event data
The incident that the user is provided with comprises following several determinant attribute:
The incident transmitting time: the general standard form is " YYYY-MM-DD HH24:MM:SS ", as " 2010-09-0108:00:00 ".
Event content: as calendar prompting meeting, content such as message is public.
The object of reception incident: can be that the sole user also can be that the user collects.
The incident person of setting.
According to the attribute characteristics of event data, for improving search efficiency, newly-increased attribute: the incident transmitting time is stabbed, and the time that is about to standard format converts the integer data to, and stabbing as " 2010-09-0108:00:00 " time corresponding is exactly 1283299200.
Thus, the establishment SQL script of design database tables of data is as follows:
CREATE?TABLE`t_event_info`(
‘ID`int(11)NOT?NULL,
`CreateUser`varchar(32)DEFAULT?NULL
`SendTime`datetime?DEFAULT?NULL,
`Content`varchar(254)DEFAULT?NULL,
`ReceiverUser`varchar(254)DEFAULT?NULL,
‘SendTmeStamp`int(11)NOT?NULL,
‘Status`int(2)NOT?NULL,
PRIMARY?KEY(`SendTmeStamp`))
Be described in detail as follows:
Id field only as the sequence number of incident, increases progressively with event data.
The CreateUser field, incident founder.
The SendTime field, the incident transmitting time.
The Content field will send the content of incident.
The ReceiveUser field, the user of reception incident.
The SendTimeStamp field, the incident transmitting time of incident transmitting time conversion is stabbed the integer data.
Status field, transmit status, value are 0 or 1,0 to be to send, and 1 for sending.
This tables of data is created in the system database with other business datum tables of system.
List structure according to this tables of data illustrates, and need notify Xiao Wang to have a meeting to meeting room in 9 o'clock sharps of the morning on September 1st, 2010 as Xiao Ming, and this notice will send to Xiao Wang in 8 o'clock sharps of the morning on September 1st, 2010.The form that is saved among the database table t_event_info of this incident is as shown in table 1 like this:
Table 1
According to this form, any newly-increased data can be inserted tables of data with reference to this data layout.
Overall process flow
The process flow diagram of processing events reminding business as shown in Figure 2,
Detailed process is described as follows:
1) operating system of user is provided with incident, and in the tables of data that is saved in system database of event data, data layout as previously mentioned.
2) starting a subsystem is cached to the event data of incident transmitting time stamp greater than current system time in the data structure of internal memory.
3) scan-data structure checks whether current system time reaches the triggered time of incident, and frequency is that per second starts single pass.
4) system time stabs more than or equal to the incident transmitting time, and incident is triggered.
5) send this event data to designated user.
6) data structure of this event data correspondence in the deletion buffer memory is revised in the database corresponding simultaneously
The state of transmit status field is for sending.
Be cached to the treatment scheme of the data structure of internal memory
As shown in Figure 3, the data structure generation strategy of the present invention's design is to add N bar child list composition with a main chain table, and the N here is any positive integer.The structural design of these two chained lists is as follows:
● main chain list structure (being described) with the C language
typedef?struct?m_node
{
Int?timestamp;
Int?timedifference;
struct?s_node*s_link;
struct?m_node*link;
}m_link;
Be described in detail as follows:
1) timestamp: the timestamp of start time some day is exactly that correspondent time is 1282492800 as " 2010-08-2300:00:00 ".
2) timedifference: the span of corresponding Event triggered time, promptly interval time difference fate, value is the integer greater than 0.For example value is 1 o'clock, and the Event triggered time on the then corresponding child list all took place in one day after main chain table zero-time timestamp; Value is 2 o'clock, and the Event triggered time on the then corresponding child list all took place in two days after main chain table zero-time timestamp.
3) s_link: corresponding child list pointer.
4) link: the pointer of next node.
5) timedifference of each node preservation is identical.
6) difference between the timestamp preserved of each node can both divide exactly one day total second number (24*3600), and the value that obtains after dividing exactly all is the integral multiple of attribute timedifference holding time span fate.
● child list structure (being described) with the C language
typedef?struct?s_node
{
Int?sendtimestamp;
Char?content[256];
Char?receiveuser[256];
Int?ID;
struct?s_node*link;
}s_link;
Be described in detail as follows:
1) sendtimestamp: the incident transmitting time is stabbed.
2) content: event content to be sent.
3) receiveuser: the user who receives incident.
4) ID: this event data record sequence number that Field ID is preserved among the corresponding data table t_event_info.
5) link: the pointer of next node.
In conjunction with above-mentioned list structure, data structure buffer memory product process figure of the present invention is described in detail as follows by number of steps among Fig. 4 as shown in Figure 4:
1) be condition with current system time after the system start-up, read event data to be sent from lane database, the incident transmitting time is stabbed and is greater than current system time.The incident transmitting time is stabbed the outdated data that belongs to before current system time.
2) traversal event data, stab each node that removes to travel through the main chain table according to the current event transmitting time, it should be noted that here if article one data, at this moment Dui Ying main chain table should have only a first node, and the timestamp that first node is preserved is the start time on the same day of current time correspondence.Such as, system time is at " 2010-08-2312:00:00 ", and then the incident transmitting time of main chain table subsequent node correspondence stamp all should be greater than " 2010-08-2300:00:00 ".
3) calculate the incident transmitting time and stab the difference of stabbing with each Node Events transmitting time of main chain table, with this difference divided by one day total second number (by 24
*60
*60 obtain), the smallest positive integral that the value that obtains is at last got greater than this value again just can obtain concrete interval fate.
4) fate of fate and main chain table nodal community Timedifference preservation carries out size relatively at interval
5) when fate that the interval fate is preserved less than main chain table nodal community Timedifference, this explanation incident transmitting time sends in this main chain table node time corresponding span, at this moment will further search the child list of this node correspondence.
6) each node in the traversal child list, the incident transmitting time that the contrast node is preserved is stabbed the size of stabbing with the current event transmitting time.
7) press the time from front to back, the incident transmitting time is stabbed ascending principle, in child list, generate a new node, the value that guarantees the incident transmitting time stamp of node is stabbed more than or equal to the incident transmitting time of previous node, and the incident transmitting time that is less than or equal to a back node is stabbed (if a back node is arranged).
8) node generates and finishes, and stops to travel through other nodes of chained list.
9) when fate that the interval fate is preserved greater than main chain table nodal community Timedifference, this explanation incident transmitting time does not send in this main chain table node time corresponding span, at this moment will further compare the incident transmitting time and stab the size of stabbing with the next node holding time.Exception if present node is exactly last node of main chain table, then will generate a node at the main chain table by the generation principle of node at last.
10) stab greater than the next node holding time when the incident transmitting time and stab, then repeat 3), 4) step.
11) when the incident transmitting time is stabbed the incident transmitting time stamp of preserving less than next node, need between these two nodes, generate principle and generate new node by node data.
12) newly-generated main chain table node also generates the child list of a correspondence simultaneously, event data is saved as the first node data of this child list.
13) node data generates and finishes, and stops to travel through other nodes of chained list.
14) generated data cached structure at last.
Inquiry and processing events data flow
After finishing the flow process that event data is cached to internal memory, all start p.s. once the scanning of this buffer memory event data, judge whether current system time reaches the trigger condition of incident, and treatment scheme is described in detail as follows as shown in Figure 5:
1) scanning main chain table data.
2) find corresponding child list address by main chain heading node.
3) obtain the value that incident transmitting time that subchain heading node preserves is stabbed.
4) size of contrast Node Events transmitting time stamp and current system time.
5) if being greater than or equal to described incident transmitting time, stabs current system time, promptly reach the trigger condition of the event data of node preservation, this event data is sent to designated user, and the value of transmit status field of revising correspondence database tables of data record simultaneously is for sending.
6) if the event data of this child list node storage all has been sent out away, just delete this node, if last node of this child list, the corresponding node of deletion main chain table when deleting this node.
7) if the Node Events transmitting time is stabbed greater than current system time, then stop ergodic data immediately, current system time does not satisfy the trigger condition of anything part.
Those skilled in the art do not break away from essence of the present invention and spirit, can there be the various deformation scheme to realize the present invention, the above only is the preferable feasible embodiment of the present invention, be not so limit to interest field of the present invention, the equivalent structure that all utilizations instructions of the present invention and accompanying drawing content are done changes, and all is contained within the interest field of the present invention.