CN107220043B - Method for generating report by using WPF interface and report engine - Google Patents

Method for generating report by using WPF interface and report engine Download PDF

Info

Publication number
CN107220043B
CN107220043B CN201710302976.8A CN201710302976A CN107220043B CN 107220043 B CN107220043 B CN 107220043B CN 201710302976 A CN201710302976 A CN 201710302976A CN 107220043 B CN107220043 B CN 107220043B
Authority
CN
China
Prior art keywords
report
class
calling
template
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.)
Expired - Fee Related
Application number
CN201710302976.8A
Other languages
Chinese (zh)
Other versions
CN107220043A (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

Images

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 invention provides a method for generating a report by using a WPF interface and a report engine, wherein the structure of the report engine comprises a report template base class and a report management module; the report template base class inherits the system, windows, controls, and user control classes, so that the public method of the report template is abstracted, and all report templates inherit the report template base class. The public method comprises the following steps: the method comprises the steps of primary loading operation, verification operation, statistical operation, searching operation and operation for obtaining report printing object; the report management module defines four basic operations abstracted aiming at common report functions, including: newly building a report, loading the report, serializing the report, and printing the report. The operation objects of the four operations are all objects of a report template base class, and the report template objects realize the multi-state of the operations after being transformed into the report template base class objects. The WPF interface is used as a uniform interface of the report, and the design effect of 'what you see is what you get' of the report is achieved.

Description

Method for generating report by using WPF interface and report engine
Technical Field
The invention relates to the technical field of report processing, in particular to a method for generating a report by using a WPF interface and a report engine.
Background
In WPF programs, there are often application scenarios that generate a large number of different forms. The current common methods for generating reports by the WPF program include two methods: one is to export the data into excel to generate a report; another is to generate reports using third party controls.
Exporting the data to the excel to generate the report, the method has the advantages that the report can be conveniently modified, but the method has the disadvantages that the modified data cannot be stored in the database, the modified report is not matched with the data in the database, in addition, the report is modified by self, and the statistical data of the report is possibly calculated wrongly.
The advantage of using the third-party control to generate the report is that the printed report is printed strictly according to the program setting, but the disadvantage is that the editing function of the third-party control is weak, the 'what you see is what you get' of report modification cannot be realized, and when the report does not meet the requirement, the report needs to be returned to the modification page for modification again; another disadvantage is that the database stores data for each field in the report, and the style of the report cannot be stored. When the report template in the software changes, the report style printed again in the software may be different from the original style.
Disclosure of Invention
In order to overcome the defects of the prior art, the invention provides a method for generating a report by using a WPF interface and a report engine, which abstract the common operations of report management and report management, and the WPF is used as a software project of the interface to create the report by using the method and the engine, so that the design effect of creating and modifying the report of 'what you see is what you get' can be realized, and the functions of creating, loading, editing, printing, counting and the like of the report are simpler and quicker.
In order to achieve the purpose, the invention adopts the following technical scheme:
the report engine structure comprises a report template base class and a report management module.
The report template base class inherits the system, windows, controls, and user control classes, so that the public method of the report template is abstracted, and all report templates inherit the report template base class. The public method comprises the following steps: the method comprises the steps of initial loading operation, verification operation, statistical operation, searching operation and operation for obtaining a report printing object.
The report template refers to a common method for creating a report class of a specific report object, the report template realizes the specific style and operation of the report aiming at different reports, the report template needs to be realized independently after inheriting a report template base class, and the base class is rewritten according to the actual requirement.
The four methods of 'primary loading operation', 'verification operation' and 'statistical operation' in the report template base class are all virtual methods, the method body is a hollow method body, and the method is mainly rewritten by the implementation class of the inheritance base class according to specific requirements; the initial loading operation is used for the report content filling initialization prompt operation and is called by the report management module only when a report is newly built for the first time; the loading operation is used for content initialization operation when the report is loaded, and the report is loaded each time and called by the report management module; the verification operation is used for judging whether the report filling content meets the report filling specification or not; the 'statistical operation' is used for counting and analyzing the filled report content, and displaying the statistical analysis result on the report or transmitting the statistical analysis result to the report management module.
The 'search operation' in the report template base class is a virtual method, which is used for searching the designated WPF control through the WPF element tag label in the report template, the method can be rewritten by subclasses, but a default implementation algorithm is provided in the method body of the method, the implementation algorithm is a recursive search algorithm, and the implementation steps are as follows:
1) setting the WPF element control c to be searched as a null value;
2) searching a tag of a designated WPF element control, if the tag value is a designated value, assigning the control to c, and finishing the search;
3) otherwise, judging whether the WPF element control is a container, if so, traversing the sub-controls in the container, calling a search operation for each sub-control, and if not, assigning the result of the sub-control to c; if the container is not the container, the search is finished;
4) and returning the WPF element control to be searched.
The operation of acquiring the object of the printed report in the report template base is a virtual method which is used for cloning the report and replacing the control which does not meet the printing requirement in the report with the control which meets the printing requirement according to a certain format, the method can be rewritten by subclasses, but a default realization algorithm is provided in the base, and the default realization algorithm comprises the following steps:
1) serializing and then deserializing the report by using a XamlReader class, a XamlWriter class and a XamlDesigners SerializationManager class in a System, Windows, Markup namespace, and completing cloning of the report;
2) recursively traversing all the controls in the report, if the controls are DatePicker, extracting dates in the controls, and replacing the dates with TextBlock; if the controls are checkBox and RadioButton, the option is replaced with TextBlock, and the symbol "√" is placed before the selected item; if the control is ComboBox, replacing the selected option with TextBlock; if the control is Button, then hide the control.
The report management module defines four basic operations abstracted aiming at common report functions, including: newly building a report, loading the report, serializing the report, and printing the report. The operation objects of the four operations are all objects of a report template base class, and the operation polymorphism is realized after the objects of the report template are converted into the report template base class objects.
The implementation steps of the new report in the report management module are as follows:
1) searching a definition type of a corresponding report template according to a report expected to be created;
2) a report object of a specified definition type report class is created by utilizing a type reflection technology in Net;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling the initial loading operation of the report object;
5) calling a 'loading operation' of a report object;
6) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
7) if the report contents are correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
The implementation steps of loading the report in the report management module are as follows:
1) reading an XAML file after the specified report is serialized;
2) resolving the XAML file by using a System, Windows, Markup, Xamlreader class, and deserializing into objects of report types;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling a 'loading operation' of a report object;
5) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
6) if the report content is correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
The realization steps of the serialized report form in the report form management module are as follows:
1) acquiring a report object needing serialization;
2) calling the 'verification operation' of the report object to verify whether the report content is normal, if so, continuing to execute the next step, otherwise, returning the reason that the content is not normal, and ending the serialization method;
3) calling a 'statistical operation' of a report object;
4) serializing the report object into an XAML type character string by using the objects of the XamlWriter class and the XamlDesigners SerializationManager class in the System, Windows, Markup namespace;
5) a string of XAML type is returned to the user calling the method.
The implementation steps of the 'report printing' in the report management module are as follows:
1) acquiring a report object to be printed;
2) calling 'verification operation' of the report object to verify whether the report content is standard, if so, continuing to execute the next step, otherwise, returning the reason that the content is not standard, and ending the printing method;
3) calling a 'statistical operation' of a report object;
4) calling the report object operation of acquiring the printed report object to acquire the printable object of the original report object;
5) invoking an object of a PrintDialog class in a namespace system. If the calling is successful, continuing the next step, otherwise throwing the printing exception, and ending the method;
6) calling a SaveAsXaml method of a System, Windows, Xps, Serialization, XpsSerialization manager type object, and converting a printable object into an XpsDocument type object;
7) converting the XpsDocument type object into a FlowDocument type object by using an IXpsFixedDocument sequence reader type object and an Xamlreader type object in a namespace System, Windows, Xps, packaging;
8) and calling the DocumentPaginator attribute of the FlowDocument type object to obtain a content paging object, transmitting the content paging object to a PrintDocument method of the PrintDialog type object, and executing printing operation.
The method for generating the report template by using the WPF interface of the report engine comprises the following steps:
1) creating a UserControl type class in a code integration development environment, and changing a base class into a report template base class, wherein the class is the report template class;
2) according to the requirements of the report, realizing a report style by using XAML or WPF control objects in a report template class;
3) and selecting a virtual method in the report template base class for rewriting according to the report requirement.
When the application program needs to generate the report, the report template class is transmitted to the report management module class object, and the report management module class object is responsible for completing various operations of the report.
Compared with the prior art, the invention has the beneficial effects that:
1. the method provided by the invention uses the WPF interface as a uniform interface for report creation, loading, editing, saving and printing, and realizes the 'what you see is what you get' design effect of the report.
2. The method provided by the invention abstracts the report forms and the main operation of report form management, and developers can standardize the report form development process and realize the rapid development of report form application by using the method provided by the invention.
3. The method provided by the invention uses the WPF interface as the layout template of the report, can use rich WPF layout controls, is convenient for the operation of a user, is convenient for developers to carry out control operations such as pattern layout, statistics, verification and the like on the report, and reduces the learning threshold of the developers.
4. According to the method provided by the invention, when the report is stored, not only the main data of the report is stored, but also the XAML file, namely the layout style of the report, can be stored, and after the report layout template is changed, the original report layout style cannot be changed, so that the complete storage of the report data and the report style is realized.
5. The serialized file after the report is stored is an XML file, has the characteristics of cross-platform and cross-system, and is convenient for system expansion and data exchange.
Drawings
FIG. 1 is a report engine class diagram of the present invention;
FIG. 2 is a flow diagram of a lookup operation of the present invention;
FIG. 3 is a flowchart illustrating the operation of obtaining a printed report object according to the present invention;
FIG. 4 is a flow chart of the new report of the present invention;
FIG. 5 is a flowchart of the load report process of the present invention;
FIG. 6 is a flow chart of a serialized report of the present invention;
FIG. 7 is a flow chart of the printed report of the present invention;
FIG. 8 is a flowchart of a method of the present invention for generating a reporting model using a WPF interface;
FIG. 9 is a table showing the effect of the embodiment of the present invention, "self-rating of construction unit".
Detailed Description
The following detailed description of the present invention will be made with reference to the accompanying drawings.
As shown in fig. 1, a report engine for generating a report using a WPF interface has a structure including two classes, a report template base class and a report management module.
The report template base class inherits the system, windows, controls, and user control classes, so that the public method of the report template is abstracted, and all report templates inherit the report template base class. The public method comprises the following steps: the method comprises the steps of initial loading operation, verification operation, statistical operation, searching operation and operation for obtaining a report printing object.
The report template refers to a report class for realizing a specific report, the report template realizes the specific style and operation of the report aiming at different reports, the report template is realized independently after inheriting the report template base class, and a common method of the base class can be rewritten according to the actual requirement.
The four methods of 'primary loading operation', 'verification operation' and 'statistical operation' in the report template base class are all virtual methods, the method is rewritten mainly by the implementation class of the inheritance base class according to specific requirements, and the method body of the base class is a hollow method body; the initial loading operation is used for the report content filling initialization prompt operation and is called by the report management module only when a report is newly built for the first time; the loading operation is used for content initialization operation when the report is loaded, and the report is loaded each time and called by the report management module; the verification operation is used for judging whether the report filling content meets the report filling specification or not; the 'statistical operation' is used for counting and analyzing the filled report content, and displaying the statistical analysis result on the report or transmitting the statistical analysis result to the report management module.
As shown in fig. 2, the "search operation" in the report template base class is a virtual method, which is used to search for a specific WPF control through a WPF element tag label in the report template, and the method may be rewritten by a subclass, but a default implementation algorithm is provided in the method body of the method, and the implementation algorithm is a recursive search algorithm and is implemented as follows:
1) setting the WPF element control c to be searched as a null value;
2) searching a tag of a designated WPF element control, if the tag value is a designated value, assigning the control to c, and finishing the search;
3) otherwise, judging whether the WPF element control is a container, if so, traversing the sub-controls in the container, calling a search operation for each sub-control, and if not, assigning the result of the sub-control to c; if the container is not the container, the search is finished;
4) and returning the WPF element control to be searched.
As shown in fig. 3, the "operation of obtaining a printed report object" in the report template base class is a virtual method for cloning a report and replacing a control in the report that does not meet the printing requirement with a control that meets the printing requirement according to a certain format, and the method can be rewritten by a subclass, but a default operation method is provided in the base class, and the default operation method includes the following steps:
1) serializing and then deserializing the report by using a XamlReader class, a XamlWriter class and a XamlDesigners SerializationManager class in a System, Windows, Markup namespace, and completing cloning of the report;
2) recursively traversing all the controls in the report, if the controls are DatePicker, extracting dates in the controls, and replacing the dates with TextBlock; if the controls are checkBox and RadioButton, the option is replaced with TextBlock, and the symbol "√" is placed before the selected item; if the control is ComboBox, replacing the selected option with TextBlock; if the control is Button, then hide the control.
The report management module defines four basic operations abstracted aiming at common report functions, including: newly building a report, loading the report, serializing the report, and printing the report. The operation objects of the four operations are all objects of a report template base class, and the report template objects realize the multi-state of the operations after being transformed into the report template base class objects.
As shown in fig. 4, the implementation steps of the "new report" in the report management module are as follows:
1) searching a definition type of a corresponding report template according to a report expected to be created;
2) a report object of a specified definition type report class is created by utilizing a type reflection technology in Net;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling the initial loading operation of the report object;
5) calling a 'loading operation' of a report object;
6) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
7) if the report contents are correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
As shown in fig. 5, the implementation steps of "loading report" in the report management module are as follows:
1) reading an XAML file after the specified report is serialized;
2) resolving the XAML file by using a System, Windows, Markup, Xamlreader class, and deserializing into objects of report types;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling a 'loading operation' of a report object;
5) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
6) if the report content is correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
As shown in fig. 6, the implementation steps of the "serialized report" in the report management module are as follows:
1) acquiring a report object needing serialization;
2) calling the 'verification operation' of the report object to verify whether the report content is normal, if so, continuing to execute the next step, otherwise, returning the reason that the content is not normal, and ending the serialization method;
3) calling a 'statistical operation' of a report object;
4) serializing the report object into an XAML type character string by using the objects of the XamlWriter class and the XamlDesigners SerializationManager class in the System, Windows, Markup namespace;
5) a string of XAML type is returned to the user calling the method.
As shown in fig. 7, the implementation steps of "printing report" in the report management module are as follows:
1) acquiring a report object to be printed;
2) calling 'verification operation' of the report object to verify whether the report content is standard, if so, continuing to execute the next step, otherwise, returning the reason that the content is not standard, and ending the printing method;
3) calling a 'statistical operation' of a report object;
4) calling the report object operation of acquiring the printed report object to acquire the printable object of the original report object;
5) invoking an object of a PrintDialog class in a namespace system. If the calling is successful, continuing the next step, otherwise throwing the printing exception, and ending the method;
6) calling a SaveAsXaml method of a System, Windows, Xps, Serialization, XpsSerialization manager type object, and converting a printable object into an XpsDocument type object;
7) converting the XpsDocument type object into a FlowDocument type object by using an IXpsFixedDocument sequence reader type object and an Xamlreader type object in a namespace System, Windows, Xps, packaging;
8) and calling the DocumentPaginator attribute of the FlowDocument type object to obtain a content paging object, transmitting the content paging object to a PrintDocument method of the PrintDialog type object, and executing printing operation.
As shown in FIG. 8, a method for generating report template classes by using the WPF interface by using the report engine comprises the following steps:
1) creating a UserControl type class in a code integration development environment, and changing a base class into a report template base class, wherein the class is the report template class;
2) according to the requirements of the report, realizing a report style by using XAML or WPF control objects in a report template class;
3) and selecting a virtual method in the report template base class for rewriting according to the report requirement.
And transmitting the report template class to a report management module class object, and finishing various operations of the report by the report management module class object.
Specific example 1: take the operations of the report "self-appraisal of construction units" as an example. The interface of the "construction unit self-rating table" is shown in FIG. 9.
The method comprises the following steps of newly building a report template of 'self-evaluation form of construction unit':
1) and creating a code file of a UserControl type in the code integration development environment, and changing the base class into a report template base class.
2) And realizing the report style according to the requirements of the report. And the report forms are subjected to segmentation layout on the page by using grid, and corresponding controls are placed in places where information needs to be input. And if the background code needs to call the control, inputting an identifier character string of the control in a tag label of the control. For example, a unit project name and a part project name are used for placing TextBox controls, a process number is used for placing TextBox controls, an identifier is 'txProcessID', a construction unit is used for placing ComboBox controls, an identifier is 'cmbConstructionUnit', two DatePicker controls are placed on construction dates, and the identifiers are 'dpStart' and 'dpEnd' respectively and represent start and end dates. The master project checkpoint qualification rate places the TextBox control with an identifier of "txtMain", and the general project checkpoint qualification rate places the TextBox control with an identifier of "txtCommon". And placing a TextBlock control at the engineering quality evaluation level, wherein the identifier is tbLevel.
And selecting a virtual method in the base class for rewriting according to the report requirement. Rewrite "initial load operation": and finding controls corresponding to the identifiers "dpStart" and "dpEnd" by using a finding operation, and setting the time as the current time. Rewrite "load operation": and searching the ComboBox control corresponding to the identifier "cmbContructionUnit" by using the search operation, finding the construction unit list from the database, and loading the construction unit list into a pull-down list of the ComboBox control. Rewrite "verify operation": searching an identifier 'txtProcessID' to verify whether the input process number is a six-digit number, returning a false value if the verification fails, and prompting error information; searching controls of identifiers 'txtMain' and 'txtCommon', verifying whether input characters are numbers within 0-100, if the verification fails, returning a false value, and prompting error information; if the verification is successful, a true value is returned. Rewriting the 'statistical operation', searching the controls of the identifiers 'txtMain' and 'txtCommon', extracting the qualification rates of the main item and the general item, and calculating the process quality grade according to the calculation formula transmitted in the form parameters. And searching the identifier 'tbLevel', assigning the process quality grade result to the 'tbLevel' control, and returning the rating result as a return value. The implementation steps of building a 'construction unit self-evaluation table' by using the objects of the report management module class are as follows:
1) and searching the type of the template of the construction unit self-evaluation table.
2) And (5) creating a report object of the construction unit self-evaluation table template by using the type reflection technology in Net.
3) And emptying a report container for displaying the report, and adding a report object into the container for displaying.
4) The 'initial loading operation' of the report object is called.
5) The "load operation" of the report object is invoked.
6) And calling the 'verification operation' of the report object, and judging whether the report content is correctly filled. Because the data in the report is not filled in due to the initial loading, the return value of the verification operation is a false value.
7) If the report contents are correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
The implementation steps of utilizing the objects of the report management module class to realize the self-evaluation table 'loading report' of the construction unit are as follows:
1) and searching the XAML file of the specified construction unit self-evaluation table to be loaded.
2) And resolving the XAML file by using a System, Windows, Markup, Xamlreader class, and deserializing into an object of a template type of a self-evaluation form of a construction unit.
3) And emptying a report container for displaying the report, and adding a report object into the container for displaying.
4) The "load operation" of the report object is invoked.
5) And calling the 'verification operation' of the report object, and judging whether the report content is correctly filled.
6) If the report content is correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
The method for realizing the 'serialized report' in the self-evaluation table of the construction unit by using the object of the report management module class comprises the following steps:
1) and acquiring a self-evaluation report object of a construction unit.
2) And calling the 'verification operation' of the report object to verify whether the report content is normal, if so, continuing to execute the next step, otherwise, returning the reason why the content is not normal, and ending the serialization method.
3) And calling the 'statistical operation' of the report object, and acquiring the rating of the report through the return value.
4) Objects of the XamlWriter class and the XAML designerserializationmanager class in the system.
5) And returning the character string of the XAML type to a user calling the method to complete serialization.
The implementation steps of utilizing the objects of the report management module class to realize the 'report printing' in the self-evaluation table of the construction unit are as follows:
1) and acquiring a self-evaluation report object of a construction unit.
2) And calling the 'verification operation' of the report object to verify whether the report content is normal, if so, continuing to execute the next step, otherwise, returning the reason why the content is not normal, and ending the serialization method.
3) And calling the 'statistical operation' of the report object, and calculating the process quality level.
4) And calling the report object operation of acquiring the printed report object to acquire the printable object of the original report object. In the get print report object operation, both the DatePicker and ComboBox controls are replaced with TextBlock controls for print operations.
5) Windows. controls calls the object of the PrintDialog class in the namespace system. If the calling is successful, continuing the next step, otherwise throwing the printing exception, and ending the method.
6) The printable object is converted to an XpsDocument type object by calling the SaveAsXaml method of System, Windows, Xps, Serialization, XpsSerialization manager type object.
7) The XpsFixedDocumentSequencereader type object and the XamlReader type object in the namespace System, Windows, Xps, packaging are used to convert the XpsDocumenttype object into the FlowDocumenttype object.
8) And calling the DocumentPaginator attribute of the FlowDocument type object to obtain a content paging object, transmitting the content paging object to a PrintDocument method of the PrintDialog type object, and executing printing operation.
The above embodiments are implemented on the premise of the technical solution of the present invention, and detailed embodiments and specific operation procedures are given, but the scope of the present invention is not limited to the above embodiments. The methods used in the above examples are conventional methods unless otherwise specified.

Claims (6)

1. A report engine for generating a report by using a WPF interface structurally comprises a report template base class and a report management module;
the report template base class inherits a system, Windows, controls, UserControl class, abstracts a public method of the report template, and inherits all report templates to the report template base class; the public method comprises the following steps: the method comprises the steps of primary loading operation, verification operation, statistical operation, searching operation and operation for obtaining report printing object;
the report template is a report type for realizing a specific report, the report template realizes the specific style and operation of the report aiming at different reports, the report template is realized independently after inheriting the report template base class, and a public method of the base class can be rewritten according to the actual requirement;
the four methods of 'primary loading operation', 'verification operation' and 'statistical operation' in the report template base class are all virtual methods, the method is rewritten mainly by the implementation class of the inheritance base class according to specific requirements, and the method body of the base class is a hollow method body; the initial loading operation is used for the report content filling initialization prompt operation and is called by the report management module only when a report is newly built for the first time; the loading operation is used for content initialization operation when the report is loaded, and the report is loaded each time and called by the report management module; the verification operation is used for judging whether the report filling content meets the report filling specification or not; the statistical operation is used for counting and analyzing the filled report content, and displaying the statistical analysis result on the report or transmitting the statistical analysis result to the report management module;
the report management module defines four basic operations abstracted aiming at common report functions, including: newly building a report, loading the report, serializing the report, and printing the report; the operation objects of the four operations are all objects of a report template base class, and the report template objects realize operation polymorphism after being transformed into report template base class objects;
the method is characterized in that the 'search operation' in the report template base class is a virtual method, and is used for searching for the specified WPF control through the WPF element tag label in the report template, the method can be rewritten by the subclass, but a default implementation algorithm is provided in the method body of the method, the implementation algorithm is a recursive search algorithm, and the implementation steps are as follows:
1) setting the WPF element control c to be searched as a null value;
2) searching a tag of a designated WPF element control, if the tag value is a designated value, assigning the control to c, and finishing the search;
3) otherwise, judging whether the WPF element control is a container, if so, traversing the sub-controls in the container, calling a search operation for each sub-control, and if not, assigning the result of the sub-control to c; if the container is not the container, the search is finished;
4) returning WPF element controls to be searched;
the operation of acquiring the object of the printed report in the report template base is a virtual method which is used for cloning the report and replacing the control which does not meet the printing requirement in the report with the control which meets the printing requirement according to a certain format, the method can be rewritten by subclasses, but a default operation method is provided in the base, and the default operation steps are as follows:
1) serializing and then deserializing the report by using a XamlReader class, a XamlWriter class and a XamlDesigners SerializationManager class in a System, Windows, Markup namespace, and completing cloning of the report;
2) recursively traversing all the controls in the report, if the controls are DatePicker, extracting dates in the controls, and replacing the dates with TextBlock; if the controls are checkBox and RadioButton, the option is replaced with TextBlock, and the symbol "√" is placed before the selected item; if the control is ComboBox, replacing the selected option with TextBlock; if the control is Button, then hide the control.
2. The reporting engine of claim 1, wherein the step of creating a new report in the report management module is as follows:
1) searching a definition type of a corresponding report template according to a report expected to be created;
2) a report object of a specified definition type report class is created by utilizing a type reflection technology in Net;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling the initial loading operation of the report object;
5) calling a 'loading operation' of a report object;
6) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
7) if the report contents are correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
3. The reporting engine using the WPF interface for generating reports as claimed in claim 1, wherein the implementation steps of "loading reports" in the report management module are as follows:
1) reading an XAML file after the specified report is serialized;
2) resolving the XAML file by using a System, Windows, Markup, Xamlreader class, and deserializing into objects of report types;
3) clearing a report container for displaying a report, and adding a report object into the container for displaying;
4) calling a 'loading operation' of a report object;
5) calling the 'verification operation' of the report object, and judging whether the report content is correctly filled;
6) if the report content is correctly filled, calling the 'statistical operation' of the report object, otherwise, not carrying out the statistical operation.
4. The reporting engine using the WPF interface to generate reports as claimed in claim 1, wherein the report management module implements "serialized reports" as follows:
1) acquiring a report object needing serialization;
2) calling the 'verification operation' of the report object to verify whether the report content is normal, if so, continuing to execute the next step, otherwise, returning the reason that the content is not normal, and ending the serialization method;
3) calling a 'statistical operation' of a report object;
4) serializing the report object into an XAML type character string by using the objects of the XamlWriter class and the XamlDesigners SerializationManager class in the System, Windows, Markup namespace;
5) a string of XAML type is returned to the user calling the method.
5. The reporting engine using the WPF interface for generating reports as claimed in claim 1, wherein the report management module performs the steps of "print report" as follows:
1) acquiring a report object to be printed;
2) calling 'verification operation' of the report object to verify whether the report content is standard, if so, continuing to execute the next step, otherwise, returning the reason that the content is not standard, and ending the printing method;
3) calling a 'statistical operation' of a report object;
4) calling the report object operation of acquiring the printed report object to acquire the printable object of the original report object;
5) invoking an object of a PrintDialog class in a namespace system. If the calling is successful, continuing the next step, otherwise throwing the printing exception, and ending the method;
6) calling a SaveAsXaml method of a System, Windows, Xps, Serialization, XpsSerialization manager type object, and converting a printable object into an XpsDocument type object;
7) converting the XpsDocument type object into a FlowDocument type object by using an IXpsFixedDocument sequence reader type object and an Xamlreader type object in a namespace System, Windows, Xps, packaging;
8) and calling the DocumentPaginator attribute of the FlowDocument type object to obtain a content paging object, transmitting the content paging object to a PrintDocument method of the PrintDialog type object, and executing printing operation.
6. The method for generating a reporting template using a reporting engine for generating reports using a WPF interface as claimed in claim 1, comprising the steps of:
1) creating a UserControl type class in a code integration development environment, and changing a base class of the UserControl class into a report template base class, wherein the class with the report template base class is a report template class;
2) according to the requirements of the report, realizing a report style by using XAML or WPF control objects in a report template class;
3) selecting a virtual method in a report template base class for rewriting according to report requirements;
and transmitting the report template class to a report management module class object, and finishing various operations of the report by the report management module class object.
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 CN107220043A (en) 2017-09-29
CN107220043B true 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)

Families Citing this family (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
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

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程序设计》;东北林业大学出版社;20170131;26-27 *
WPF中UserControl和DataTemplate;网友;《https://www.cnblogs.com/denghejun/p/3671061.html》;20140417;1-6 *

Also Published As

Publication number Publication date
CN107220043A (en) 2017-09-29

Similar Documents

Publication Publication Date Title
CN107220043B (en) Method for generating report by using WPF interface and report engine
EP3433732B1 (en) Converting visual diagrams into code
US8095570B2 (en) Decorated model architecture for efficient model-driven application development
EP3304286B1 (en) Data binding dependency analysis
US20070016829A1 (en) Test case generator
CN106528165A (en) Code generation method and code generation system
CN106648587A (en) Annotation-based Web application code generation method
CN110705237B (en) Automatic document generation method, data processing device and storage medium
CN111399853A (en) Templated deployment method of machine learning model and custom operator
CN110222318B (en) XML-based data generation tool development method
CN109145235B (en) Method and device for analyzing webpage and electronic equipment
CN112083919B (en) Target service code generation method and device based on YAML template
US20050108684A1 (en) Method and system for generating an application object repository from application framework metadata
CN111078555B (en) Test file generation method, system, server and storage medium
CN109840205A (en) Applied program testing method, device, readable storage medium storing program for executing and terminal device
US20080155519A1 (en) Code translator
CN108563431A (en) Software development methodology, device, computer readable storage medium and electronic equipment
CN100449484C (en) Method and system for generating artificial equipment panel
CN106874208A (en) The processing method of test script, device and electronic equipment
US7120618B2 (en) System and method for defining and using subclasses declaratively within markup
US8935657B2 (en) Model-to-model transformation by kind
CN109800776A (en) Material mask method, device, terminal and computer readable storage medium
CN117311683B (en) Code auxiliary system, code auxiliary processing method and device and electronic equipment
CN107423291A (en) A kind of data translating method and client device
CN113919158A (en) Simulation method and device for flight control panel and storage medium

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