private void SelectTemplate_Click(object sender, MouseButtonEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "LQN File|*.lqn"; if (ofd.ShowDialog() == true) { listBox.Items.Clear(); try { ExtractFile eFile = new ExtractFile(ofd.FileName); eFile.ExtractTo(CacheFolder + "\\template.xml", 1); templateHXML = new HeadXMLFile(CacheFolder + "\\template.xml"); templateHXML.Read(); loadBlockCombo(); } catch { errorMessage("Failed to open :\r\n" + ofd.FileName); return; } (sender as TextBox).Text = ofd.FileName; workfolderTextbox.IsEnabled = true; } }
public void LoadFromLQNCFile(string LQNCFilepath) { LQNCFile = LQNCFilepath; ExtractFile EFile = new ExtractFile(LQNCFile); EFile.ExtractTo(LQNCFilepath + ".head.xml", 1); EFile.ExtractTo(LQNCFilepath + ".smry.xml", 0); SummaryXml = new XmlDocument(); SummaryXml.Load(LQNCFilepath + ".smry.xml"); TemplateHXML = new HeadXMLFile(LQNCFilepath + ".head.xml"); TemplateHXML.Read(); File.Delete(LQNCFilepath + ".head.xml"); File.Delete(LQNCFilepath + ".smry.xml"); }
private void StartCollecting_Click(object sender, MouseButtonEventArgs e) { ((sender as Label).Parent as Border).Opacity = 0.75; if (workfolderTextbox.Text != "" && WorkFolder != "") { progressBar.Visibility = Visibility.Visible; progressBar.Value = 0; PBSetValue(5); Thread thread = new Thread(() => { this.Dispatcher.Invoke(new Action(() => { listBox.Items.Clear(); string[] files = Directory.GetFiles(WorkFolder, "*.lqn"); ArrayList fileArray = new ArrayList(); HeadXMLFile tempHXML; PBSetValue(35); foreach (string path in files) { try { ExtractFile eFile = new ExtractFile(path); eFile.ExtractTo(CacheFolder + "\\temp.xml", 1);//Extract the editable xml. tempHXML = new HeadXMLFile(CacheFolder + "\\temp.xml"); tempHXML.Read(); if (templateHXML.CompareTo(ref tempHXML) == true)//Check if they are in the same template. { //Ensure the editable xml is able to be loaded. eFile.ExtractTo(CacheFolder + "\\temp.xml", 0); tempHXML = new HeadXMLFile(CacheFolder + "\\temp.xml"); tempHXML.Read(); fileArray.Add(path); } } catch { continue; } } PBSetValue(75); smryMng.TemplateHXML = templateHXML; smryMng.SummarizeFromFiles(fileArray); addToList(fileArray); loadItemContents(smryMng.GetInnerTexts(blockCombo.SelectedIndex + 1, itemCombo.SelectedIndex + 1)); PBSetValue(100); tipMessage(smryMng.Files.Count.ToString() + " Files found."); showCorrectButton(); progressBar.Visibility = Visibility.Hidden; })); }); thread.Start(); } }
private ArrayList GetSummaryArray() { ArrayList SummaryXML = new ArrayList(); SummaryXML.Add("<Summaries>"); SummaryXML.Add(""); int j = 0; //item index int i = 0; //block index foreach (string file in Files) { ExtractFile EFile = new ExtractFile(file); //Load the editable xml file. EFile.ExtractTo(file + "_temp", 0); HeadXMLFile tempXML = new HeadXMLFile(file + "_temp"); tempXML.Read(); File.Delete(file + "_temp"); SummaryXML.Add(" <Summary path=\"" + file + "\">"); foreach (block blk in tempXML.blocks) { i++; foreach (var item in blk.Contents) { j++; string ij = "Item Index=\"" + i.ToString() + "," + j.ToString() + "\"";//index string if (item is labelText) { SummaryXML.Add(" <" + ij + ">" + ((labelText)item).text + "</Item>"); } else if (item is textBox) { SummaryXML.Add(" <" + ij + ">" + ((textBox)item).text + "</Item>"); } else if (item is radioButton) { if (((radioButton)item).selected == true)//While true write its text. { SummaryXML.Add(" <" + ij + ">" + ((radioButton)item).text + "</Item>"); } else//While false write nothing(make it can be filtered by "BlankCheck"). { SummaryXML.Add(" <" + ij + ">" + "</Item>"); } } else if (item is checkBox) { if (((checkBox)item).selected == true) { SummaryXML.Add(" <" + ij + ">" + ((checkBox)item).text + "</Item>"); } else { SummaryXML.Add(" <" + ij + ">" + "</Item>"); } } else if (item is comboBox) { SummaryXML.Add(" <" + ij + ">" + ((comboBox)item).texts[((comboBox)item).selectedIndex].ToString()//Write text corresponding with the "selectedIndex". + "</Item>"); } else if (item is attachment) { SummaryXML.Add(" <" + ij + " FileIndex=\""//It has an extra attribute to show its file index in a lqn file. + ((attachment)item).fileIndex.ToString() + "\">" + ((attachment)item).filename + "</Item>"); } } j = 0; } SummaryXML.Add(" </Summary>"); SummaryXML.Add(""); i = 0; } SummaryXML.Add("</Summaries>"); return(SummaryXML); }