Template maintenance-template parsing and template maintenance Parsing

Source: Internet
Author: User

Template maintenance-template parsing and template maintenance Parsing

The template Parsing is mainly about the main template parsing.

First, let's talk about the business logic. First, click the node of the tree, pay the code of the tree to the material code, and then query the main template (including the main template ID and main template information) through the material code) and sub-templates (without {} information );

If there is information in the form of {}, we pay the master template ID and master template information to the String parameter and upload it to the foreground. At the front-end, first determine whether the passed String parameter is null. If it is null, there is no master template. Otherwise, the sub-template information is loaded.


Parse the main template:


Step 1:

The main template information obtained from the above logic is {: diesel locomotive, 0; electric locomotive, 1; passenger car, 2; freight car, 3; EMU, 4; to be decommissioned, 5; other obsolete materials, 9.

Step 2:


We split it.
Define a datatable and assign two fields to it: one ID and one Name.


Step 3:


Cut the string, first put the first two characters {: delete method: Substring (2, Smatlcate. Length-2)

The string is changed to a diesel locomotive, 0; electric locomotive, 1; passenger car, 2; freight car, 3; EMU, 4; to be decommissioned, 5; other obsolete materials, 9 ;}

Then we can remove the final} as follows:. Split ('}') [0]. Trim ()
 
The string is changed to a diesel locomotive, 0; electric locomotive, 1; passenger car, 2; freight car, 3; EMU, 4; to be decommissioned, 5; other obsolete materials, 9;
 
We will remove the last semicolon as follows: TrimEnd (';')
 
The string is changed to a diesel locomotive, 0; electric locomotive, 1; passenger car, 2; freight car, 3; EMU, 4; to be decommissioned, 5; other obsolete materials, 9

Step 3:


In this way, we can convert the array: string [] strArr = Smatlcate. Split (';'). This is an array conversion using a semicolon separator.

Step 4:
Finally, we can assign values to the previously defined able (including two sections) cyclically. The method is as follows:


DataRow dr = dt_ChildTemplets.NewRow ();
Dr ["ID"] = strArr [I]. Split (',') [1]. Trim ();
Dr ["NAME"] = "series:" + strArr [I]. split (',') [0]. trim () + "," + strArr [I]. split (',') [1]. trim ();

Finally, we successfully uploaded the array information to the able.


If you bind dt to the drop-down list, you can assign values.


There will be blog posts about subtemplate parsing and template testing in the future.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.