CN107220043A - A kind of use WPF interfaces generate the method and Report Engine of form - Google Patents

A kind of use WPF interfaces generate the method and Report Engine of form Download PDF

Info

Publication number
CN107220043A
CN107220043A CN201710302976.8A CN201710302976A CN107220043A CN 107220043 A CN107220043 A CN 107220043A CN 201710302976 A CN201710302976 A CN 201710302976A CN 107220043 A CN107220043 A CN 107220043A
Authority
CN
China
Prior art keywords
report
class
called
wpf
base class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710302976.8A
Other languages
Chinese (zh)
Other versions
CN107220043B (en
Inventor
梁妍
吴杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Science and Technology Liaoning USTL
Original Assignee
University of Science and Technology Liaoning USTL
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Science and Technology Liaoning USTL filed Critical University of Science and Technology Liaoning USTL
Priority to CN201710302976.8A priority Critical patent/CN107220043B/en
Publication of CN107220043A publication Critical patent/CN107220043A/en
Application granted granted Critical
Publication of CN107220043B publication Critical patent/CN107220043B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present invention provides the method and Report Engine that a kind of use WPF interfaces generate form, and the structure of Report Engine includes report form template base class, two classes of statement management module;Wherein, described report form template base class is inherited in System.Windows.Controls.UserControl classes, and the abstract public method of report form template, all report form templates are all inherited in report form template base class.Public method includes:Very first load operation, loading operation, verification operation, statistical operation, search operation obtains printing reports Object Operations;Described statement management module, defines and takes out four kinds of basic operations for conventional report capability, including:Newly-built form, loads form, serializes form, printing reports.This four operation operation objects be all report form template base class object, report form template object it is upper be transformed into report form template base class sub-object after, realize operation it is polymorphic.Using WPF interfaces as the unified interface of form, the design effect of form " What You See Is What You Get " is realized.

Description

A kind of use WPF interfaces generate the method and Report Engine of form
Technical field
The present invention relates to report form processing technical field, the method and report of more particularly to a kind of use WPF interfaces generation form Table engine.
Background technology
In WPF programs, usually there are the application scenarios for generating the different forms of a large amount of forms.Current WPF Program Generating forms Common method have two kinds:One kind is to export to data to generate form in excel;Another generated using third party control Form.
Data are exported to form is generated in excel, advantage is can easily to change form, but a disadvantage is that modification Data can not be saved in database, cause the data in the form and database of modification to mismatch, in addition oneself modification form, Report form statistics data are possible to calculate mistake.
The advantage of form is generated using third party control to print in strict accordance with program setting for printing reports, but a disadvantage is that Third party control editting function is weak, it is impossible to realize " What You See Is What You Get " of report modification, when form is undesirable, it is necessary to The modification page is returned to remodify;Another has the disadvantage that what is preserved in database is the data of each field in form, form Pattern can not preserve.When the report form template in software changes, the report style printed again in software may be with original There is pattern different.
The content of the invention
In order to overcome the deficiencies in the prior art, the present invention provides the method and form of a kind of use WPF interfaces generation form Engine, the abstract conventional operation of form and Report Server Management, WPF uses this method and engine to create as the software project at interface Form, achievable form creates and changed the design effect of " What You See Is What You Get ", and realizes that form creates, loads, edits, beats The functions such as print, statistics are simpler quick.
In order to achieve the above object, the present invention is realized using following technical scheme:
A kind of use WPF interfaces generate the Report Engine of form, and the structure of Report Engine includes report form template base class, form Two classes of management module.
Wherein, described report form template base class is inherited in System.Windows.Controls.UserControl classes, is taken out As the public method of report form template, all report form templates are all inherited in report form template base class.Public method includes:First loading Operation, loading operation, verification operation, statistical operation, search operation obtains printing reports Object Operations.
Described report form template refers to the form class for creating specific REPORT-OBJECT, and report form template is real for each different form The distinctive pattern of existing form, operation, report form template need to be implemented separately after inheriting report form template base class, and weigh according to the actual requirements Write the publicly-owned method of base class.
" very first load operation " in report form template base class, " loading operation ", " verification operation ", " statistical operation " four sides Method is empty method and method body is short side body of laws, mainly realizes class according to real needs rewrite method by succession base class; " very first load operation " fills in initialization prompting operation for form content, only in newly-built form for the first time, by Report Server Management Module is called;" loading operation " is used to load content initialization operation during form, and loading form is all by Report Server Management mould every time Block is called;" verification operation " is used to judge whether filling report forms content meets filling report forms specification;" statistical operation " is used to count The form content filled in analysis, and statistic analysis result is included on form or passed to statement management module.
" search operation " in described report form template base class is empty method, for passing through the WPF elements in report form template Tag label lookups specify WPF controls, and this method can be rewritten by subclass, but one is provided in the method body of this method and is write from memory That recognizes realizes algorithm, and this realizes that algorithm is a recursive lookup algorithm, realizes that step is as follows:
1) it is null value to set the WPF element controls c to be searched;
2) the tag labels for specifying WPF element controls are searched, if tag values are the value specified, the control is assigned to c, Lookup terminates;
3) otherwise judge whether the WPF elements control is container, if container, then travel through the child control in container, it is right Each child control calls " search operation ", if lookup result is not sky, the result of child control is assigned into c;If not Container, then search and terminate;
4) the WPF element controls to be searched are returned.
" obtaining printing reports Object Operations " in described report form template base class is an empty method, for cloning report Table, and the control that printing requirement is not met in form is replaced with to the control for meeting printing requirement, this method according to certain form It can be rewritten by subclass, but a kind of algorithm of realizing of acquiescence is provided in base class, acquiescence realizes that algorithm steps are as follows:
1) using the XamlReader classes in System.Windows.Markup NameSpaces, XamlWriter classes and XamlDesignerSerializationManager classes by Statement sequence, then unserializing, complete the clone of form;
2) all controls in recursive traversal form, if control is DatePicker, extract the date therein, and use TextBlock is replaced;If control is CheckBox and RadioButton, option is replaced using TextBlock, and is being chosen Put in marks " √ " before;If control is ComboBox, the option chosen is replaced with TextBlock;If control is Button, then hide control.
Wherein, described statement management module, defines and takes out four kinds of basic operations for conventional report capability, wraps Include:Newly-built form, loads form, serializes form, printing reports.The operation object of this four operations is all report form template base class Object, the object of report form template it is upper be transformed into report form template base class sub-object after, realize the polymorphic of operation.
" newly-built form " realizes that step is as follows in described statement management module:
1) according to the form for wishing to create, the definition type of corresponding report form template is searched;
2) created using the type reflection technology in .Net and specify the REPORT-OBJECT for defining type form class;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " very first load operation " of REPORT-OBJECT is called;
5) " the loading operation " of REPORT-OBJECT is called;
6) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 7) form content is filled in correctly, " statistical operation " of REPORT-OBJECT is called, otherwise without statistical operation.
" loading form " realizes that step is as follows in described statement management module:
1) the XAML files specified after Statement sequence are read;
2) using System.Windows.Markup.XamlReader classes parsing XAML files, and it is deserialized as form The object of type;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " the loading operation " of REPORT-OBJECT is called;
5) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 6) whether form content fills in correctly, " statistical operation " of REPORT-OBJECT is called, is otherwise grasped without statistics Make.
" serializing form " realizes that step is as follows in described statement management module:
1) REPORT-OBJECT for needing to serialize is obtained;
2) call REPORT-OBJECT " verification operation " verify form content whether specification, if specification continues executing with next step Suddenly, otherwise returned content reason lack of standardization, sequencing method terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) using the XamlWriter classes in System.Windows.Markup NameSpaces and The object of XamlDesignerSerializationManager classes, REPORT-OBJECT sequence is turned to the character string of XAML types;
5) user of the character string of XAML types to call method is returned.
" printing reports " realizes that step is as follows in described statement management module:
1) REPORT-OBJECT for needing to print is obtained;
2) " verification operation " of REPORT-OBJECT is called if whether specification specification continues executing with next step to checking form content Suddenly, otherwise returned content reason lack of standardization, Method of printing terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) " the obtaining printing reports Object Operations " of REPORT-OBJECT is called to obtain the printable objects of former REPORT-OBJECT;
5) the object display printing of the PrintDialog classes in NameSpace System.Windows.Controls is called Dialog box;If calling success, continue next step, printing of otherwise dishing out is abnormal, and method terminates;
6) System.Windows.Xps.Serialization.XpsSerializationManager types pair are called Printable objects are switched to XpsDocument type objects by the SaveAsXaml methods of elephant;
7) using in NameSpace System.Windows.Xps.Packaging The object of IXpsFixedDocumentSequenceReader types and the object of XamlReader types, by XpsDocument Type object switchs to FlowDocument type objects;
8) the DocumentPaginator attributes of FlowDocument type objects are called to obtain content pagination object, will Content pagination object passes to the PrintDocument methods of PrintDialog class objects, performs printing.
The method and step for generating report form template using a kind of use WPF interfaces of described Report Engine is as follows:
1) class of UserControl types is created in code IDE, and base class is changed to report form template base Class, such is report form template class;
2) according to the demand of form, in report form template class, report style is realized using XAML or WPF control objects;
3) according to form demand, the empty method in selection report form template base class is rewritten.
When application program needs generation form, report form template class is passed into statement management module class object, by form Management module class object is responsible for completing the operations of form.
Compared with prior art, the beneficial effects of the invention are as follows:
1st, method proposed by the present invention using WPF interfaces as form it is newly-built, loading, editor, preserve and printing unified boundary Face, realizes the design effect of form " What You See Is What You Get ".
2nd, the abstract primary operational of form and Report Server Management of method proposed by the present invention, developer using the present invention, The quick exploitation of Report form application can be realized with specification form development process.
3rd, method proposed by the present invention uses WPF interfaces as the layout templates of form, and abundant WPF can be used to be laid out Control, not only facilitates the operation of user, and facilitates developer to carry out the control such as pattern layout and statistics, verification to form Operation, reduces the study threshold of developer.
4th, method proposed by the present invention, when form is preserved, not only saves the key data of form, can also preserve XAML The layout pattern of file, i.e. form, after Report layouts' template changes, original Report layouts' pattern will not change, and realize The complete preservation of report data and report style.
5th, the serializing file after form of the present invention is preserved is XML file, the characteristic with cross-platform cross system, convenient system The extension of system and the exchange of data.
Brief description of the drawings
Fig. 1 is the Report Engine class figure of the present invention;
Fig. 2 is the search operation flow chart of the present invention;
Fig. 3 is the acquisition printing reports Object Operations flow chart of the present invention;
Fig. 4 is the newly-built form flow chart of the present invention;
Fig. 5 is the loading form flow chart of the present invention;
Fig. 6 is the serializing form flow chart of the present invention;
Fig. 7 is the printing reports flow chart of the present invention;
Fig. 8 is that the use WPF interfaces of the present invention generate the method flow diagram of report form template;
Fig. 9 is the specific embodiment effect " unit in charge of construction's self-appraisal table " of the present invention.
Embodiment
The embodiment provided below in conjunction with accompanying drawing the present invention is described in detail.
As shown in figure 1, a kind of use WPF interfaces generate the Report Engine of form, the structure of Report Engine includes form mould Plate base class, two classes of statement management module.
Wherein, described report form template base class is inherited in System.Windows.Controls.UserControl classes, is taken out As the public method of report form template, all report form templates are all inherited in report form template base class.Public method includes:First loading Operation, loading operation, verification operation, statistical operation, search operation obtains printing reports Object Operations.
Described report form template refers to the form class for realizing specific form, and report form template realizes report for each different form The distinctive pattern of table, operation, report form template need to be implemented separately after inheriting report form template base class, it is possible to weigh according to the actual requirements Write the publicly-owned method of base class.
" very first load operation " in report form template base class, " loading operation ", " verification operation ", " statistical operation " four sides Method is empty method, mainly realizes class according to real needs rewrite method by succession base class, the method body of base class is short side method Body;" very first load operation " fills in initialization prompting operation for form content, only in newly-built form for the first time, by form pipe Reason module is called;" loading operation " is used to load content initialization operation during form, and loading form is all by Report Server Management every time Module is called;" verification operation " is used to judge whether filling report forms content meets filling report forms specification;" statistical operation " is used to unite The form content that meter and analysis are filled in, and statistic analysis result is included on form or passed to statement management module.
As shown in Fig. 2 " search operation " in described report form template base class is empty method, for by report form template WPF element tag label lookups specify WPF controls, this method can be rewritten by subclass, but be provided in the method body of this method One acquiescence realizes algorithm, and this realizes that algorithm is a recursive lookup algorithm, realizes that step is as follows:
1) it is null value to set the WPF element controls c to be searched;
2) the tag labels for specifying WPF element controls are searched, if tag values are the value specified, the control is assigned to c, Lookup terminates;
3) otherwise judge whether the WPF elements control is container, if container, then travel through the child control in container, it is right Each child control calls " search operation ", if lookup result is not sky, the result of child control is assigned into c;If not Container, then search and terminate;
4) the WPF element controls to be searched are returned.
As shown in figure 3, " the obtaining printing reports Object Operations " in described report form template base class is an empty method, use In clone's form, and the control that printing requirement is not met in form is replaced with to the control for meeting printing requirement according to certain form Part, this method can be rewritten by subclass, but a kind of operating method of acquiescence is provided in base class, and default action step is as follows:
1) using the XamlReader classes in System.Windows.Markup NameSpaces, XamlWriter classes and XamlDesignerSerializationManager classes by Statement sequence, then unserializing, complete the clone of form;
2) all controls in recursive traversal form, if control is DatePicker, extract the date therein, and use TextBlock is replaced;If control is CheckBox and RadioButton, option is replaced using TextBlock, and is being chosen Put in marks " √ " before;If control is ComboBox, the option chosen is replaced with TextBlock;If control is Button, then hide control.
Wherein, described statement management module, defines and takes out four kinds of basic operations for conventional report capability, wraps Include:Newly-built form, loads form, serializes form, printing reports.The operation object of this four operations is all report form template base class Object, report form template object it is upper be transformed into report form template base class sub-object after, realize operation it is polymorphic.
As shown in figure 4, " newly-built form " realizes that step is as follows in described statement management module:
1) according to the form for wishing to create, the definition type of corresponding report form template is searched;
2) created using the type reflection technology in .Net and specify the REPORT-OBJECT for defining type form class;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " very first load operation " of REPORT-OBJECT is called;
5) " the loading operation " of REPORT-OBJECT is called;
6) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 7) form content is filled in correctly, " statistical operation " of REPORT-OBJECT is called, otherwise without statistical operation.
As shown in figure 5, " loading form " realizes that step is as follows in described statement management module:
1) the XAML files specified after Statement sequence are read;
2) using System.Windows.Markup.XamlReader classes parsing XAML files, and it is deserialized as form The object of type;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " the loading operation " of REPORT-OBJECT is called;
5) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 6) whether form content fills in correctly, " statistical operation " of REPORT-OBJECT is called, is otherwise grasped without statistics Make.
As shown in fig. 6, " serializing form " realizes that step is as follows in described statement management module:
1) REPORT-OBJECT for needing to serialize is obtained;
2) call REPORT-OBJECT " verification operation " verify form content whether specification, if specification continues executing with next step Suddenly, otherwise returned content reason lack of standardization, sequencing method terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) using the XamlWriter classes in System.Windows.Markup NameSpaces and The object of XamlDesignerSerializationManager classes, REPORT-OBJECT sequence is turned to the character string of XAML types;
5) user of the character string of XAML types to call method is returned.
As shown in fig. 7, " printing reports " realize that step is as follows in described statement management module:
1) REPORT-OBJECT for needing to print is obtained;
2) " verification operation " of REPORT-OBJECT is called if whether specification specification continues executing with next step to checking form content Suddenly, otherwise returned content reason lack of standardization, Method of printing terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) " the obtaining printing reports Object Operations " of REPORT-OBJECT is called to obtain the printable objects of former REPORT-OBJECT;
5) the object display printing of the PrintDialog classes in NameSpace System.Windows.Controls is called Dialog box;If calling success, continue next step, printing of otherwise dishing out is abnormal, and method terminates;
6) System.Windows.Xps.Serialization.XpsSerializationManager types pair are called Printable objects are switched to XpsDocument type objects by the SaveAsXaml methods of elephant;
7) using in NameSpace System.Windows.Xps.Packaging The object of IXpsFixedDocumentSequenceReader types and the object of XamlReader types, by XpsDocument Type object switchs to FlowDocument type objects;
8) the DocumentPaginator attributes of FlowDocument type objects are called to obtain content pagination object, will Content pagination object passes to the PrintDocument methods of PrintDialog class objects, performs printing.
As shown in figure 8, generating the method and step of report form template class using a kind of use WPF interfaces of described Report Engine It is as follows:
1) class of UserControl types is created in code IDE, and base class is changed to report form template base Class, such is report form template class;
2) according to the demand of form, in report form template class, report style is realized using XAML or WPF control objects;
3) according to form demand, the empty method in selection report form template base class is rewritten.
Report form template class is passed into statement management module class object, is responsible for completing form by statement management module class object Operations.
Specific embodiment 1:By taking the operations of form " unit in charge of construction's self-appraisal table " as an example.The boundary of " unit in charge of construction's self-appraisal table " Face such as Fig. 9.
The step of newly-built " unit in charge of construction's self-appraisal table " report form template, is as follows:
1) code file of UserControl types is created in code IDE, and base class is changed to form Template base class.
2) according to the demand of form, report style is realized.Form carries out cutting layout to the page using grid, and is needing The place of typing information is put into corresponding control.If backstage code needs to call the control, control is inputted in the tag labels of control The identifier character string of part.Such as construction unit title, partitioned project title place TextBox controls, and process numbering is placed TextBox controls, identifier is " txtProcessID ", and ComboBox controls are placed by unit in charge of construction, and identifier is " cmbConstructionUnit ", commencement date place two DatePicker controls, identifier be respectively " dpStart " and " dpEnd ", represents the beginning and end date.Dominant item check point qualification rate places TextBox controls, and identifier is " txtMain ", general data point qualification rate places TextBox controls, and identifier is " txtCommon ".Evaluation of engineering quality etc. TextBlock controls are placed at level, identifier is " tbLevel ".
According to form demand, the empty method in selection base class is rewritten.Rewrite " very first load operation ":Use " search operation " Identifier " dpStart " and " dpEnd " corresponding control is searched, and is current time set of time.Rewrite " loading operation ": Use " search operation " to search the corresponding ComboBox controls of identifier " cmbConstructionUnit ", looked for from database To unit in charge of construction's list, and it is loaded into the drop-down list of ComboBox controls.Rewrite " verification operation ":Search identifier " txtProcessID ", whether the process numbering of checking input is six bit digitals, if authentication failed, returns to falsity, and point out Error message;The control of identifier " txtMain " and " txtCommon " is searched, whether the word of checking input is within 0-100 Numeral, if authentication failed, return to falsity, and point out error message;If be proved to be successful, true value is returned.Rewrite " statistics behaviour Make ":The control of identifier " txtMain " and " txtCommon " is searched, and takes out main project and the qualification rate of general data, According to the calculation formula transmitted in parameter, calculation process credit rating.Identifier " tbLevel " is searched, and by process quality etc. Level result is assigned to " tbLevel " control, and rating result is returned as return value.Utilize pair of statement management module class Step is realized as realize newly-built " unit in charge of construction's self-appraisal table ":
1) type of " unit in charge of construction's self-appraisal table " template is searched.
2) REPORT-OBJECT of " unit in charge of construction's self-appraisal table " template is created using the type reflection technology in .Net.
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing.
4) " very first load operation " of REPORT-OBJECT is called.
5) " the loading operation " of REPORT-OBJECT is called.
6) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly.Due to being first loading, report Data in table are not filled in, and therefore " verification operation " return value is falsity.
If 7) form content is filled in correctly, " statistical operation " of REPORT-OBJECT is called, otherwise without statistical operation.
Realize that step is as follows using the object implementatio8 unit in charge of construction self-appraisal table " loading form " of statement management module class:
1) the XAML files of the unit in charge of construction's self-appraisal table for the need loading specified are searched.
2) using System.Windows.Markup.XamlReader classes parsing XAML files, and it is deserialized as construction The object of unit self-appraisal table template type.
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing.
4) " the loading operation " of REPORT-OBJECT is called.
5) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly.
If 6) whether form content fills in correctly, " statistical operation " of REPORT-OBJECT is called, is otherwise grasped without statistics Make.
" serializing form " realizes step such as in the object implementatio8 unit in charge of construction self-appraisal table of statement management module class Under:
1) obtaining needs unit in charge of construction's self-appraisal statistical tables and reports table object.
2) call REPORT-OBJECT " verification operation " verify form content whether specification, if specification continues executing with next step Suddenly, otherwise returned content reason lack of standardization, sequencing method terminates.
3) " statistical operation " of REPORT-OBJECT is called, and passes through the rating of return value acquisition form.
4) using the XamlWriter classes in System.Windows.Markup NameSpaces and The object of XamlDesignerSerializationManager classes, REPORT-OBJECT sequence is turned to the character string of XAML types.
5) user of the character string of XAML types to call method is returned, serializing is completed.
" printing reports " realizes that step is as follows in the object implementatio8 unit in charge of construction self-appraisal table of statement management module class:
1) unit in charge of construction's self-appraisal statistical tables and reports table object is obtained.
2) call REPORT-OBJECT " verification operation " verify form content whether specification, if specification continues executing with next step Suddenly, otherwise returned content reason lack of standardization, sequencing method terminates.
3) " statistical operation " of REPORT-OBJECT, calculation process credit rating are called.
4) " the obtaining printing reports Object Operations " of REPORT-OBJECT is called to obtain the printable objects of former REPORT-OBJECT. In " obtaining printing reports Object Operations ", DatePicker and ComboBox controls are all replaced by TextBlock controls, for beating Print operation.
5) the object display printing of the PrintDialog classes in NameSpace System.Windows.Controls is called Dialog box.If calling success, continue next step, printing of otherwise dishing out is abnormal, and method terminates.
6) System.Windows.Xps.Serialization.XpsSerializationManager types pair are called Printable objects are switched to XpsDocument type objects by the SaveAsXaml methods of elephant.
7) using in NameSpace System.Windows.Xps.Packaging The object of IXpsFixedDocumentSequenceReader types and the object of XamlReader types, by XpsDocument Type object switchs to FlowDocument type objects.
8) the DocumentPaginator attributes of FlowDocument type objects are called to obtain content pagination object, will Content pagination object passes to the PrintDocument methods of PrintDialog class objects, performs printing.
Above example is implemented lower premised on technical solution of the present invention, gives detailed embodiment and tool The operating process of body, but protection scope of the present invention is not limited to the above embodiments.Method therefor is such as without spy in above-described embodiment It is conventional method not mentionlet alone bright.

Claims (8)

1. a kind of use WPF interfaces generate the Report Engine of form, it is characterised in that the structure of Report Engine includes report form template Base class, two classes of statement management module;
Wherein, described report form template base class is inherited in System.Windows.Controls.UserControl classes, abstract The public method of report form template, all report form templates are all inherited in report form template base class;Public method includes:First loading behaviour Make, loading operation, verification operation, statistical operation, search operation obtains printing reports Object Operations;
Described report form template refers to the form class for realizing specific form, and report form template realizes that form is special for each different form Some patterns, operation, report form template need to be implemented separately after inheriting report form template base class, it is possible to rewrite base according to the actual requirements The publicly-owned method of class;
" very first load operation " in report form template base class, " loading operation ", " verification operation ", " statistical operation " four methods are equal For empty method, class is mainly realized according to real needs rewrite method by succession base class, the method body of base class is short side body of laws; " very first load operation " fills in initialization prompting operation for form content, only in newly-built form for the first time, by Report Server Management Module is called;" loading operation " is used to load content initialization operation during form, and loading form is all by Report Server Management mould every time Block is called;" verification operation " is used to judge whether filling report forms content meets filling report forms specification;" statistical operation " is used to count The form content filled in analysis, and statistic analysis result is included on form or passed to statement management module;
Described statement management module, defines and takes out four kinds of basic operations for conventional report capability, including:Newly-built report Table, loads form, serializes form, printing reports;The operation object of this four operations is all the object of report form template base class, report Table template object it is upper be transformed into report form template base class sub-object after, realize operation it is polymorphic.
2. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " search operation " in report form template base class is empty method, for being specified by the WPF element tag label lookups in report form template WPF controls, this method can be rewritten by subclass, but in the method body of this method provide one acquiescence realize algorithm, should It is a recursive lookup algorithm to realize algorithm, realizes that step is as follows:
1) it is null value to set the WPF element controls c to be searched;
2) the tag labels for specifying WPF element controls are searched, if tag values are the value specified, the control is assigned to c, are searched Terminate;
3) otherwise judge whether the WPF elements control is container, if container, then the child control in container is traveled through, to each Individual child control calls " search operation ", if lookup result is not sky, the result of child control is assigned into c;If not container, Then search and terminate;
4) the WPF element controls to be searched are returned.
3. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " obtain printing reports Object Operations " in report form template base class is an empty method, for cloning form, and by form not The control for meeting printing requirement replaces with the control for meeting printing requirement according to certain form, and this method can be rewritten by subclass, But a kind of operating method of acquiescence is provided in base class, default action step is as follows:
1) using the XamlReader classes in System.Windows.Markup NameSpaces, XamlWriter classes and XamlDesignerSerializationManager classes by Statement sequence, then unserializing, complete the clone of form;
2) all controls in recursive traversal form, if control is DatePicker, extract the date therein, and use TextBlock is replaced;If control is CheckBox and RadioButton, option is replaced using TextBlock, and is being chosen Put in marks " √ " before;If control is ComboBox, the option chosen is replaced with TextBlock;If control is Button, then hide control.
4. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " newly-built form " realizes that step is as follows in statement management module:
1) according to the form for wishing to create, the definition type of corresponding report form template is searched;
2) created using the type reflection technology in .Net and specify the REPORT-OBJECT for defining type form class;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " very first load operation " of REPORT-OBJECT is called;
5) " the loading operation " of REPORT-OBJECT is called;
6) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 7) form content is filled in correctly, " statistical operation " of REPORT-OBJECT is called, otherwise without statistical operation.
5. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " loading form " realizes that step is as follows in statement management module:
1) the XAML files specified after Statement sequence are read;
2) using System.Windows.Markup.XamlReader classes parsing XAML files, and it is deserialized as report form type Object;
3) empty for showing the form container of form, and REPORT-OBJECT is added in container, for showing;
4) " the loading operation " of REPORT-OBJECT is called;
5) " verification operation " of REPORT-OBJECT is called, judges whether form content fills in correctly;
If 6) whether form content fills in correctly, " statistical operation " of REPORT-OBJECT is called, otherwise without statistical operation.
6. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " serializing form " realizes that step is as follows in statement management module:
1) REPORT-OBJECT for needing to serialize is obtained;
2) call REPORT-OBJECT " verification operation " verify form content whether specification, if specification continues executing with next step, Otherwise returned content reason lack of standardization, sequencing method terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) using the XamlWriter classes in System.Windows.Markup NameSpaces and The object of XamlDesignerSerializationManager classes, REPORT-OBJECT sequence is turned to the character string of XAML types;
5) user of the character string of XAML types to call method is returned.
7. a kind of use WPF interfaces according to claim 1 generate the Report Engine of form, it is characterised in that described " printing reports " realizes that step is as follows in statement management module:
1) REPORT-OBJECT for needing to print is obtained;
2) " verification operation " of REPORT-OBJECT is called if whether specification specification continues executing with next step to checking form content, it is no Then returned content reason lack of standardization, Method of printing terminates;
3) " statistical operation " of REPORT-OBJECT is called;
4) " the obtaining printing reports Object Operations " of REPORT-OBJECT is called to obtain the printable objects of former REPORT-OBJECT;
5) object of the PrintDialog classes in NameSpace System.Windows.Controls is called to show print dialog Frame;If calling success, continue next step, printing of otherwise dishing out is abnormal, and method terminates;
6) System.Windows.Xps.Serialization.XpsSerializationManager type objects are called Printable objects are switched to XpsDocument type objects by SaveAsXaml methods;
7) using in NameSpace System.Windows.Xps.Packaging The object of IXpsFixedDocumentSequenceReader types and the object of XamlReader types, by XpsDocument Type object switchs to FlowDocument type objects;
8) the DocumentPaginator attributes of FlowDocument type objects are called to obtain content pagination object, by content Paging object passes to the PrintDocument methods of PrintDialog class objects, performs printing.
8. using described Report Engine a kind of use WPF interfaces generate report form template method, it is characterised in that including with Lower step:
1) class of UserControl types is created in code IDE, and base class is changed to report form template base class, should Class is report form template class;
2) according to the demand of form, in report form template class, report style is realized using XAML or WPF control objects;
3) according to form demand, the empty method in selection report form template base class is rewritten;
Report form template class is passed into statement management module class object, is responsible for completing each of form by statement management module class object Item operation.
CN201710302976.8A 2017-05-03 2017-05-03 Method for generating report by using WPF interface and report engine Expired - Fee Related CN107220043B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710302976.8A CN107220043B (en) 2017-05-03 2017-05-03 Method for generating report by using WPF interface and report engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710302976.8A CN107220043B (en) 2017-05-03 2017-05-03 Method for generating report by using WPF interface and report engine

Publications (2)

Publication Number Publication Date
CN107220043A true CN107220043A (en) 2017-09-29
CN107220043B CN107220043B (en) 2020-07-03

Family

ID=59943741

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710302976.8A Expired - Fee Related CN107220043B (en) 2017-05-03 2017-05-03 Method for generating report by using WPF interface and report engine

Country Status (1)

Country Link
CN (1) CN107220043B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111079382A (en) * 2019-11-29 2020-04-28 苏宁云计算有限公司 Form rendering method and system based on MVVM (multifunction virtual machine) mode
CN111784108A (en) * 2020-05-29 2020-10-16 远光软件股份有限公司 Modeling method and device for main data management platform
CN113486230A (en) * 2021-07-28 2021-10-08 黄泽恒 Method for generating labeled message template
CN115841102A (en) * 2022-12-30 2023-03-24 深圳市金政软件技术有限公司 Method, device, equipment and storage medium for generating dynamic data report

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103164204A (en) * 2011-12-15 2013-06-19 北京新媒传信科技有限公司 Generation method and system of user interfaces based on Symbian system
CN105573972A (en) * 2014-10-10 2016-05-11 北大方正集团有限公司 Report check formula generation method and apparatus

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103164204A (en) * 2011-12-15 2013-06-19 北京新媒传信科技有限公司 Generation method and system of user interfaces based on Symbian system
CN105573972A (en) * 2014-10-10 2016-05-11 北大方正集团有限公司 Report check formula generation method and apparatus

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
李瑞改: "Page类常用属性与事件方法", 《ASP.NET程序设计》 *
网友: "WPF中UserControl和DataTemplate", 《HTTPS://WWW.CNBLOGS.COM/DENGHEJUN/P/3671061.HTML》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111079382A (en) * 2019-11-29 2020-04-28 苏宁云计算有限公司 Form rendering method and system based on MVVM (multifunction virtual machine) mode
CN111784108A (en) * 2020-05-29 2020-10-16 远光软件股份有限公司 Modeling method and device for main data management platform
CN111784108B (en) * 2020-05-29 2024-01-02 远光软件股份有限公司 Modeling method and device of main data management platform
CN113486230A (en) * 2021-07-28 2021-10-08 黄泽恒 Method for generating labeled message template
CN115841102A (en) * 2022-12-30 2023-03-24 深圳市金政软件技术有限公司 Method, device, equipment and storage medium for generating dynamic data report

Also Published As

Publication number Publication date
CN107220043B (en) 2020-07-03

Similar Documents

Publication Publication Date Title
CN107273117B (en) Programming-friendly agile code automatic generation system
CN107220043A (en) A kind of use WPF interfaces generate the method and Report Engine of form
CN107291450B (en) Programming-friendly agile code automatic generation method
CN106293664A (en) Code generating method and device
CN103744680B (en) Method and device for business process processing
CN106371829A (en) Modularization thinking-based template framework design method and system
CN111078555B (en) Test file generation method, system, server and storage medium
CN109062567A (en) Information management system quick development platform based on B/S structure
CN106469140A (en) A kind of report generating system and its method
CN103383645A (en) Code generation method and system
CN106648587A (en) Annotation-based Web application code generation method
CN105204860A (en) Method and device for rapidly generating user-defined static Web page
CN102023869A (en) Control input value checking method and system
CN101149737A (en) Method for quickly establishing web form and automatically establishing corresponding data table in database through Microsoft Word
CN112416337A (en) Software architecture development system for aerospace embedded system
CN111061475A (en) Software code generation method and device, computer equipment and storage medium
Steimann et al. Generic model assist
CN112083919A (en) YAML template-based target service code generation method and device
CN100449484C (en) Method and system for generating artificial equipment panel
CN103176778A (en) Method and device for webpage development
CN106293770A (en) The general of a kind of table data leads table system and method
US20070277165A1 (en) Debugging Interpreted Input
CN104063231B (en) Test resource rapid access method based on HIT-TENA
CN116974620A (en) Application program generation method, operation method and corresponding device
CN101201750B (en) Method of providing data for encoding/decoding using syntax lexical analysis tool

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200703

CF01 Termination of patent right due to non-payment of annual fee