private void ImportCellMappings() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); }); }
public void CellMapping() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); var data = Context.CellMappings.First(); Assert.AreEqual(1, data.ColumnNumber); Assert.AreEqual("A", data.ColumnExcelNumber); Assert.AreEqual("建筑名称", data.ColumnName); }); }
public void GetFileId() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); var id = AddFile(); Context.CellMappings.SaveWithFileId(Context, id); var result = Context.CellMappings.GetFileId(); Assert.AreEqual(id, result); }); }
public void HasValue() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); var result = Context.CellMappings.HasFile(); Assert.IsFalse(result); var id = AddFile(); Context.CellMappings.SaveWithFileId(Context, id); result = Context.CellMappings.HasFile(); Assert.IsTrue(result); }); }
private static void ImportFromFolder() { var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ImportData"); ExcelDataImportBase importer = new CellMappingImport(Path.Combine(folder, "CellMapping.xlsx")); importer.Import(); importer = new ConstructionValueImport(Path.Combine(folder, "ConstructionValue.xlsx")); importer.Import(); importer = new BusinessValueImport(Path.Combine(folder, "BusinessValue.xlsx")); importer.Import(); importer = new BusinesFeatureImport(Path.Combine(folder, "BusinessFeature.xlsx")); importer.Import(); importer = new RiskLevelImport(Path.Combine(folder, "RiskLevel.xlsx")); importer.Import(); }
public void Save() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); var id = AddFile(); Context.CellMappings.SaveWithFileId(Context, id); var item = Context.CellMappings.FirstOrDefault(); Assert.IsNotNull(item); item.ColumnExcelNumber = "A%"; Context.CellMappings.Save(Context); var context = new ConstructionDataContext("Construction"); var actual = context.CellMappings.FirstOrDefault(); Assert.IsNotNull(actual); Assert.AreEqual(actual.ColumnExcelNumber, item.ColumnExcelNumber); }); }
public void SaveAs() { ImportAndValidate("CellMapping.xlsx", stream => { var importer = new CellMappingImport(stream); importer.Import(); var list = Context.CellMappings; var result = list.SaveAs(Context, FileName, out var report, Description); Assert.IsTrue(result); Assert.IsTrue(report == 0); var item = Context.CellMappings.First(); Assert.IsNotNull(item); Assert.IsTrue(item.FileId > 0); result = list.SaveAs(Context, FileName, out report, Description); Assert.IsFalse(result); Assert.IsTrue(report > 0); Console.WriteLine(report); });
private void BiImport_OnItemClick(object sender, ItemClickEventArgs e) { var ofd = new OpenFileDialog { DefaultExt = ".xlsx", Filter = "Excel Files (.xlsx)|*.xlsx" }; if (ofd.ShowDialog().Value) { var fileName = ofd.FileName; var importer = new CellMappingImport(fileName) { Print = this, ShowProgress = this }; var includeHeader = MessageBox.Show("Include header?", "Include header", MessageBoxButton.OKCancel) == MessageBoxResult.OK; importer.IncludeHeader = includeHeader; importer.Import(); var data = Context.CellMappings; GridControl.ItemsSource = data.ToList(); } }