Example #1
0
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            this.lstFileList.Items.Clear();

            StandardParser parser = new StandardParser();

            parser.RuleList.AddRange(ChinaVoluntaryStandardRule.Rules);
            parser.RuleList.AddRange(ChinaCompulsoryStandardRule.Rules);
            parser.RuleList.AddRange(AmericanStandardRule.Rules);
            parser.RuleList.AddRange(JapanStandardRule.Rules);
            parser.RuleList.AddRange(GermanyStandardRule.Rules);
            parser.RuleList.AddRange(EuropeStandardRule.Rules);
            parser.RuleList.AddRange(IsoStandardRule.Rules);
            parser.RuleList.AddRange(UicStandardRule.Rules);
            parser.RuleList.AddRange(IecStandardRule.Rules);

            StandardFileEnumerator fileEnumerator = new StandardFileEnumerator(this.txtPath.Text);

            foreach (var file in fileEnumerator)
            {
                ListViewItem item = this.CreateItem(file);
                this.lstFileList.Items.Add(item);

                string         fileName = Path.GetFileNameWithoutExtension(file);
                StandardStruct standard = parser.Parse(fileName);
                if (standard != null)
                {
                    item.SubItems[1].Text = standard.StandardNumber;
                    item.SubItems[2].Text = standard.StandardName;
                }
            }
        }
Example #2
0
        private void btnOpenFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog standardDialog = this.CreateOpenStandardFileDialog();

            if (standardDialog.ShowDialog() == DialogResult.OK)
            {
                string fullName = standardDialog.FileName;
                string fileName = Path.GetFileName(fullName);

                this.txtFilePath.Text = fullName;
                this.txtFileName.Text = fileName;

                StandardParser parser   = this.CreateStandardParserWithAllRules();
                StandardStruct standard = parser.Parse(Path.GetFileNameWithoutExtension(fileName));
                if (standard != null)
                {
                    this.txtExtractiveStandardNo.Text   = standard.StandardNumber;
                    this.txtExtractiveStandardName.Text = standard.StandardName;

                    if (this.database != null)
                    {
                        DataTable table = this.database.QueryStandardsInfo(standard.StandardNumber, string.Empty);
                        this.ShowTableRowsToListView(this.lvMatched, table, null);
                    }
                }
            }
        }