Sunflower Gantt Case 1: display parts processing tasks
Recently, I want to complete a project of the production management system of a mechanical processing plant. It is easy to use the sunflower Gantt Chart component. I will announce the actual process as follows.
My first task is to display the Gantt chart of the part task processing process and allow the user to adjust the scheduled time of the process.
Shows my technical routes.:
First, I want to establishWeb service,Used to extract data from the database to generate the Gantt chart componentXMLData.XMLFor more information about the data format requirements, see
Http://www.51diaodu.cn/sfgantt/docs/index.html
Use. NetReleaseWeb ServiceIt's easy. I will not repeat it here. However, pay special attention to the following points:
1Control serialization of task link objects
Because the task and the pre-task are one-to-many relationships Task Object exists Predecessorlinks Array. . Net Generated Web Service WSDL There will be an extra node Predecessorlinks , As required by the sunflower Gantt Chart XML The format is inconsistent.ProgramWe must use the following tag to control XML Serialization <System. xml. serialization. xmlelement (elementname: = "predecessorlink", isnullable: = false)> _ Public predlinks () as predecessorlink
2, Outline level
Outline level in task attributesOutlinenumberFor Gantt Chart Components
It controls the parent-child relationship between tasks.1,1.1, 1.1.1This method is defined.
3,XMLRoot task in Data
The sunflower Gantt chart must have a root task, itsOutlinenumber = 0, Plan start attributeStartIt is best to set the earliest scheduled time for all tasks,This facilitatesGanttDisplay of the figure initialization time.
4Display of task link types
Linktype = 0Indicates completion-CompleteFF
Linktype = 1Indicates completion-StartFS
Linktype = 2Start-CompleteFS
Linktype = 3Start-StartSS
WebAfter the service is created, we obtain the required data for the Gantt chart component to display. But this still doesn't work, becauseWeb ServiceDoneSoapProtocol encapsulation, the obtainedDomThe object cannot be directly used by the sunflower Gantt chart. The following statement must be used for conversion.:
VaR Doc = sfajax. createdocument ();
Doc.appendchild(loader.xmldoc.doc umentelement. firstchild); // firstchildThe series of changes as needed
Get what sunflower Gantt needsDomObject.GanttThe figure is initialized.
Because we want to implement production management software, the required attributes are of course different from those provided by sunflower Gantt Chart by default. First, expand the task object. The Sunflower Gantt Chart will automaticallyXMLTo obtain the corresponding node, such as extending the "Number of projects" attribute:
Adapter. addtaskproperty ("planqty", "planqty", sfdatarender. types. Float );
After the task attribute is extended, we need to define itGanttTask Domain
Sfganttfield. addtaskfield ("planqty", 50 ,'Number of projects', Sfganttfield. normalhead, sfganttfield. normalbody, sfganttfield. normalinput, "planqty", "planqty ");
In this way, the Gantt chart interface of a part task is formed, as shown in
Haha, the first step has been completed successfully. But I know the road is far away? After all, the production management system is too complicated.......