Workflow, from a business perspective, is the audit process, its performance is to control the different roles to see different data, different operations make the data flow different, generally there will be application, review, approval, approval and other steps; From a technical perspective, it is by controlling the different states of a field in a table, At the same time with role control to achieve.
Ii. our work
Our main task is to configure a workflow, add a background page, and then all the steps in the process call this page, and then control the specific steps in each step of the page needs to display and do not need to display the data, control.
Iii. Configuring a Workflow binding table in general, each of our workflows corresponds to a table, and each of the data in the table corresponds to an application form, which records the status and display status of the requisition (the status is used to query the display data, and the display state is used for the implementation of the page). Also has the application number, the applicant, the application time, the purpose, the note information, according to the different process to add the different field; Special description of the application number, the general will set this field as the primary key, and this field will also do the corresponding encoding processing, such as the date and time when the application will be added The following begins with an example of a sample application for food, to do a general introduction:
1. Workflow Main Table
In the System settings------Workflow settings on the left of the main interface, configure the workflow as shown, first add the workflow code in the DataGrid above, this code is unique, this is an important parameter, which will be passed to the page; The Workflow Name field is the name of the related business. For example, inventory picking application, the Workflow Description field is a description of this workflow, reference form, is the page where we draw the application, the table field is created Inventory_apply, The Status field and the Status Display field are the status and dispstatus in the table we created, which is not necessarily the status and dispstatus, but it is customary to use the Status field, and the return field is a flag field. He was trying to satisfy the need: If the list has been returned throughout the process, change the tag so that the color of the returned list can be modified;
2. Workflow Steps
At the bottom left of the workflow step is all the steps in the workflow, each step has a state, when the above approval workflow is added, there will be a number of default workflow steps added, this is just for the convenience of everyone, no further step to add, you can delete all of these, and then step by step to add;
⑴ sort: is to see more clearly and sort of use, we will from negative to positive, from small to big walk process;
⑵ Step Code: The code for the current step, which uniquely identifies this step, usually we will have the same value as the Status field
⑶ Status: This is the value to be saved to the Inventory_apply table Status field, and our process is to control the different values of this field and show the different processes
(4) Display status, this is the value to be saved to the Inventory_apply table Dispstatus field, which corresponds to the Status field and is used to display the Chinese
(5) Form title: The name of the form
(6) Role: Can filter data by role
(7) Job Description: Is the position, through the position can filter the data
(8) User: Can filter data by user
(9) Signature type : This field is used to control whether the signature box requires a user name password
(10) Remark title: Remark Label name
(11) Electronic Signature code: Additional client code can be added
3. Action Information
The above is the information of the step, the following describes each step on the different tab page information:
To check the corresponding action for specimen collar application to control the whereabouts of the process
(1) Action code: Unique identification action
(2) Action name: the name of the action, generally is the audit pass and audit rejection of two
(3) Next: This field is important, after this step is submitted, if passed, the Status field of the current requisition form in Inventory_apply becomes Approve2, and if rejected, it becomes draft
(4) Execute script: Pass or reject when the script is executed simultaneously, this script can take two parameters, one is the origrec of the current list, the other is the reason of filling;
(5) Return: Whether it can be returned, when the application is only passed, no refusal
(6) Display: whether an electronic signature is displayed
(7) Action classification:
(8) The reason is required: E-Signature notes are required
(9) Whether it is necessary to sign a multi-person signature at the same time
4. Client Execution Script
For specimen collar application audit the corresponding client execution script to control the initialization of the page and control calls to different code
(1) Name, this field is the current client execution script unique identifier, in the background code according to the name of the loading of the following specific code
(2) Description, description of the current script
(3) Type of control, type of control in the page
(4) Control ID, name of the control
(5) Action type: Control the different situations show the action is different, is empty is displayed
(6) Replacement, whether the current script is a medical checkup, deferred, or overwrites the code in the background with the same name
5. Console Script
For specimen collar Application The corresponding console script is used to control the menu displayed on the left and right sides of the main page; ⑴ console selection, main menu is the System main page to the left menu, life Cycle options for the system home side menu
⑵ Group Name: The main Page left and right menu under the two level menu code
⑶ Project Name: The code of the current menu to be displayed, this is globally unique, that is, all the steps in all processes corresponding to the project name is different, preferably the current process code + step code, so as to ensure uniqueness; First fill in the project name and then create, if you click on the creation after the discovery of a lot of things, That must be the name of the same name;
⑷ English: English display Name
⑸ Chinese: Chinese display name, menu name
⑹ Sequence Number: Under the Level two menu, the default will be to the bottom of the menu
⑺ Counter: Displays the number of lists in the current menu, calculates the number of data in the inventory_apply that are equal to the current step, is 0, is not displayed, and is a positive integer that displays
⑻ Pictures: Menu icons
⑼ Type: Menu type, typically application (automatically default)
⑽ window: Displays the location of this window, the default is Application tab, that is, the tab page opens a new page (will automatically default)
⑾ form: The page that is called, like the form in the DataGrid above (automatically default)
⑿ SET Command parameters: This is passed to the page parameters, there will be three parameters passed in, the first is the current workflow code, the second is the current step code, the third is the where condition, to query the current step corresponding to the conditions of the application order
⒀ to the right of the multi-box: is the role of control, the specific object can see the current menu;
5. Signature
For the specimen to receive the application to review the corresponding transfer page, to control the transfer of people who want to audit together, this process does not require a signature, so no editing users.
Iv. issues and additions to be aware of
A. Forminit
Executeforminit (); This sentence is written in the Form1_oninit event, so that you can invoke the Forminit event of the client execution script in the workflow step, and get the parameters passed to the page and write to the form. variables["Workflowcode"],form. variables["Stepcode"],
Form. variables["Strwhere"],form. variables["Strparams"], the client execution script can not use return, can not comment code, if you want to set the flag condition, can only use global variables, all steps to use the things, such as attachments, audit process, dynamic Link report, these are written in form1_ In the OnInit event
B. Form1_onload
In the Form1_onload event, you need to set up a data source for the DataGrid and set the flag, where the flag is set to invoke the OnRowChange event that requests the DataGrid when the data is loaded, and if loading all the data is slow, set the flag , only refresh the current tab page data, the user to change the tab page and then brush the corresponding tab data, improve the speed, set the number of flag group, you need to see the corresponding tab page Association number; There are two tabs in the sample application process, so set up two sets of flags
C. Commit_onclick
Executewfaction (form. variables["Workflowcode"],form. variables["Stepcode"], "beforesubmit");
This sentence is written in the commit, so that you can invoke the Beforesubmit event of the client execution script in the workflow step
D. Refresh
When refreshing the data, consider two cases, the first is to add the deletion of the request to the corresponding sub-data to update; the second is to completely delete the request for DataGrid data to clear all the child data
At this point, the configuration of the workflow is almost complete, the following work is written to invoke the form of the background code and different steps of initialization and submission of events, as far as possible to submit data, control control written in the workflow configuration page We just explained, so in the later maintenance and modification, it will be very convenient and logic is clear.
V. Principles of Workflow
In the configuration described above, we know how to configure a workflow, so that he works normally, and how the workflow is specifically implemented, the following will be a gradual introduction.
A. Electronic signature Form⒈ electronic signature form picture
This is what we have been using the digital signature called form, but also control the flow of data interface, the interface is very simple, without too much introduction, no more than the case of the transfer, the people and the following control is not displayed, if there is a check, the corresponding control will be displayed.
2.commit_onclick Commit function
In the Commit_onclick commit function, the Var returnvalues =form is called. ShowModalDialog (LIMS). Getformsource ("Generalworkflowactions.audit"), [form. variables["Workflowcode"],status, Origrec, form. variables["Stepdettype"]);
The function is to summon a digital signature form and pass in the necessary parameters;
⑴form. variables["Workflowcode"]: Workflow Code, the unique identifier for this workflow;
⑵Status: the state of the current requisition, which is the value of the Status field in the Workflow binding table, Note: This is the same as the step code for the workflow;
⑶Origrec: Unique identification field for the current application form
⑷form. variables["Stepdettype"]: Action classification code
3.Form initialization
function Frmmain_onload (sender, EventArgs)
{
User name. Text = Current user user name;
if (the incoming parameter is not empty)
{
Global variables ["Wfcode"]= the workflow code;
global variable ["stepcode"] = step code;
global variable ["SID"] = Application single identifier;
The General_workflow_steps table is queried for the signature type esign and the memo name commentname through the workflow code and step code parameters;
if (signature type esign not equal to ' Esig ')
{
User name password. visibility = not visible;
}
if (note name Commentname! = "")
{
Remark. name = Commentname;
}
define STEPDETCAT = null;
if (incoming parameter length is greater than 3)
{
Stepdetcat = Fourth parameter
}
Find the action code of the current step in General_workflowstepdet through the workflow code and the Step code and STEPDETCAT;
If (the action code is not empty)
{
The first action is selected; OK button can be used;
}
}
Otherwise
{
Global variables ["wfcode"] = "";
global variable ["SID"] = "";
Global variables ["Esign"] = "Silent";
}
Lbldate.text = current date;
Lbltime.text = current time;
}
Through the analysis of the electronic signature page initialization, we know that the initialization time, will determine whether to require user signature, action, note name of the three configuration;
4. Whether or not to remit a visa
The OnSelectionChanged event is triggered when the page is initialized to the action drop-down box, which determines whether a check is required
Functioncbooperation_onselectionchanged (sender, EventArgs)
{
Query out the current workflow steps in the General_workflowstepdet table by the workflow code and the value of the step code and the current action drop-down box whether the action notes are required, whether to remit the check, the next code, whether the sender is required;
Check the user name and full name of the sender in the General_workflow_audit table through the workflow code and the Step code;
If (requires a remittance)
{
Sinks the person control. visibility = visible;
}
Otherwise
{
Sinks the person control. visibility = not visible;
}
Assigns the queried user name and full name to the Combox and text display;
}
5. Determine the button action
function Btnok_onclick (sender, EventArgs)
{
The action notes for the current workflow are queried in the General_workflowstepdet table by the workflow code and the Step code and the value of the current action drop-down box, whether or not it is required;
if (note required = = True && Note is empty)
{
Prompt user, cursor lock note, End Function;
}
if (signature type esign = = "Esig")
{
Gets the current user name and the password entered by the book, if the validation does not pass, prompt the user, the End function;
}
If (requires a signature and the sender cannot be empty)
{
Prompts the user, the cursor locks the check box, the End function;
}
Finally, the workflow main SSL function is called:
Lims. CallServer ("Generalworkflowactions.audit",
[Workflow code, step Code, action code, application single identifier, remark, sender user name]);
Page return comment, operation Code, operation name; close form;
}
6. Workflow Main SSL function
Lims. CallServer ("Generalworkflowactions.audit",
[Form. variables["Wfcode"],form. variables["Stepcode"],operationcode,form. variables["SID"],reason,auditusrnam]);
- Through the workflow code in the General_workflows table query out the workflow binding table, the Status field, status Display field, whether to return the field;
- Query the step name in the General_workflow_steps table with the workflow code and the step code to use when writing the General_workflow_history table record
- Through the workflow code and the Step Code and the action code in the General_workflowstepdet table to find out the next code, action name, execute the script name, whether to return;
- The next state and display status are queried in the General_workflow_steps table by the workflow code and the next code that has been queried.
- By executing the script name in the Calcs_actions table to find out the specific steps to perform, the parameters passed in Origrec and comments, the script is the last to be executed, this is clear;
- Query the Origrec in the General_workflow_record table through the workflow code and the Step code and the current user name;
7. According to the number of incoming application form Origrec the following operation:
if (the number of Origrec is greater than 0)
{
(1) Update the current workflow in the General_workflow_record table, current step, current user, current request form ORIGREC, current binding table, current status of the data for the next state;
(2) by querying the current workflow in the General_workflow_record table, the current step, the current binding table, the current application form Origrec, the current status of the number of data to determine whether to update the status of the requisition, if the number is greater than 0, it means that the people who have not signed the signature, If it is equal to 0, the sign is finished, you can update the status of the application form;
}
Otherwise
{
(1) According to the application form Origrec update the status of the application form to the next state;
(2) If the return field is not empty and the return flag is "Y", the return flag is "Y" according to the Origrec of the application form;
If (the signer is not empty)
{
(1) Delete the current workflow from the General_workflow_record table, the next step, the current binding table, the current application number of data, to ensure the correctness of the signing;
(2) Write data to the General_workflow_record table, there are several sinks to write a few data, data for the current workflow, the next step, the binding table, the request for a single ID, the next state, the next display status;
(3) Write workflow operation Records to General_workflow_history;
(4) if (the current step executes the script is not empty)
{
Execute script (incoming parameters are current requisition origrec and notes)
}
}
}
Workflow Awareness