private void Load_MappingRules(object sender, RoutedEventArgs e) { XmlSerializer serializer = new XmlSerializer(typeof(MappingRules)); OpenFileDialog dialog = new OpenFileDialog(); string filename = ""; if (dialog.ShowDialog() == true) { filename = dialog.FileName; FileStream xmlStream = new FileStream(filename, FileMode.Open); object o = serializer.Deserialize(xmlStream); mr = o as MappingRules; xmlStream.Close(); settingMapping.DataContext = mr.settingMappings; settingmapping_rule_idx = mr.settingMappings.Count; testMapping.DataContext = mr.testMappings; testmapping_rule_idx = mr.testMappings.Count; testItem.DataContext = this; testStep1.DataContext = this; testStep2.DataContext = this; Property.DataContext = this; excelTestColumn.DataContext = mr; excelStartRow.DataContext = mr; excelEndRow.DataContext = mr; excelNote.DataContext = mr; excelNote1.DataContext = mr; excelFilename.DataContext = mr; highLimitCol.DataContext = mr; lowLimitCol.DataContext = mr; } }
public MainWindow() { InitializeComponent(); mr = new MappingRules(); TestStepList = new ObservableCollection <Tuple <string, string> >(); PropList = new ObservableCollection <Tuple <string, string, string> >(); TestItemList = new ObservableCollection <Tuple <string, int> >(); settingmapping_rule_idx = 0; testmapping_rule_idx = 0; var XmlFile = ConfigurationManager.AppSettings["TapStepFieldXml"]; InitializeTestList(XmlFile); settingMapping.DataContext = mr.settingMappings; testMapping.DataContext = mr.testMappings; testItem.DataContext = this; testStep1.DataContext = this; testStep2.DataContext = this; Property.DataContext = this; excelTestColumn.DataContext = mr; excelStartRow.DataContext = mr; excelEndRow.DataContext = mr; excelNote.DataContext = mr; excelNote1.DataContext = mr; excelFilename.DataContext = mr; highLimitCol.DataContext = mr; lowLimitCol.DataContext = mr; }
public ExcelParser(MappingRules mr) { this.mr = mr; if (mr == null) { throw new InvalidDataException("Mapping Rules is null!"); } if (!File.Exists(mr.excelFile)) { throw new FileNotFoundException("Excel File " + mr.excelFile + " Not Exist!"); } excelFile = mr.excelFile; sheetName = @"Sheet1"; }