/// <summary> /// /// </summary> /// <param name="bmDataFile"></param> /// <param name="selectedFormatBMFile"></param> /// <param name="importMap"></param> /// <param name="xOrigin"></param> /// <param name="yOrigin"></param> /// <param name="zOrigin"></param> /// <param name="worker"></param> /// <param name="approxNumLines"></param> /// <param name="NKDProjectID"></param> /// <param name="units"></param> /// <param name="connString"></param> /// <returns></returns> public string PerformBMImport(string bmDataFile, string selectedFormatBMFile, ImportDataMap importMap, double xOrigin, double yOrigin, double zOrigin, System.ComponentModel.BackgroundWorker worker, int approxNumLines, string NKDProjectID, string units, string connString) { this.currentWorker = worker; UpdateStatus("Connecting to NKD", 10.0); using (var entityObj = new NKDC(connString, null)) { // talk to the import lib to do the import var query = from BlockModel in entityObj.BlockModels select new { BlockModel.BlockModelID, BlockModel.OriginX, BlockModel.OriginY, BlockModel.OriginZ, BlockModel.ProjectID }; List <string> cn = new List <string>(); //For each field in the database (or property in Linq object) BlockModel ob = new BlockModel(); foreach (PropertyInfo pi in ob.GetType().GetProperties()) { Type ty = pi.GetType(); String name = pi.Name; cn.Add(name); } DateTime startTime = DateTime.Now; int batchSize = 100; UpdateStatus("Creating new NKD block model", 20.0); ImportUtils.BlockImport dbIm = new ImportUtils.BlockImport(); Guid blockModelGUID = Guid.NewGuid(); BlockModel xAdd = new BlockModel(); xAdd.OriginX = (Decimal)xOrigin; // TO-DO xAdd.OriginY = (Decimal)yOrigin; // TO-DO xAdd.OriginZ = (Decimal)zOrigin; // TO-DO xAdd.BlockModelID = blockModelGUID; xAdd.ProjectID = new Guid(NKDProjectID); // TODO - allow user to pick size entityObj.BlockModels.AddObject(xAdd); entityObj.SaveChanges(); UpdateStatus("Setting model meta data", 25.0); // add the meta data to identify all of the oclumns etc. List <BlockModelMetadata> blockColumnMetaData = dbIm.SetBlockModelMetaData(blockModelGUID, importMap, connString); // add the new BM guid to the column map as a default so that it is always entered importMap.columnMap.Add(new ColumnMap("", -1, "BlockModelBlock", "BlockModelID", ImportDataMap.TEXTDATATYPE, blockModelGUID.ToString(), null, units)); // add the individual blocks dbIm.AddBlockData(bmDataFile, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, connString); //dbIm.AddBlockDataNorm(bmDataFile, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, blockColumnMetaData); DateTime endTime = DateTime.Now; long compVal = (endTime.Ticks - startTime.Ticks) / 1000; string message = "" + startTime.ToShortTimeString() + " Ended: " + endTime.ToShortTimeString(); long xval = compVal; return(""); } }
/// <summary> /// /// </summary> /// <param name="bmDataFile"></param> /// <param name="selectedFormatBMFile"></param> /// <param name="importMap"></param> /// <param name="xOrigin"></param> /// <param name="yOrigin"></param> /// <param name="zOrigin"></param> /// <param name="worker"></param> /// <param name="approxNumLines"></param> /// <param name="NKDProjectID"></param> /// <param name="units"></param> /// <param name="connString"></param> /// <returns></returns> public string PerformBMImport(string bmDataFile, string selectedFormatBMFile, ImportDataMap importMap, double xOrigin, double yOrigin, double zOrigin, System.ComponentModel.BackgroundWorker worker, int approxNumLines, string NKDProjectID, string units, string connString) { this.currentWorker = worker; UpdateStatus("Connecting to NKD", 10.0); using (var entityObj = new NKDC(connString, null)) { // talk to the import lib to do the import var query = from BlockModel in entityObj.BlockModels select new { BlockModel.BlockModelID, BlockModel.OriginX, BlockModel.OriginY, BlockModel.OriginZ, BlockModel.ProjectID }; List<string> cn = new List<string>(); //For each field in the database (or property in Linq object) BlockModel ob = new BlockModel(); foreach (PropertyInfo pi in ob.GetType().GetProperties()) { Type ty = pi.GetType(); String name = pi.Name; cn.Add(name); } DateTime startTime = DateTime.Now; int batchSize = 100; UpdateStatus("Creating new NKD block model", 20.0); ImportUtils.BlockImport dbIm = new ImportUtils.BlockImport(); Guid blockModelGUID = Guid.NewGuid(); BlockModel xAdd = new BlockModel(); xAdd.OriginX = (Decimal)xOrigin; // TO-DO xAdd.OriginY = (Decimal)yOrigin; // TO-DO xAdd.OriginZ = (Decimal)zOrigin; // TO-DO xAdd.BlockModelID = blockModelGUID; xAdd.ProjectID = new Guid(NKDProjectID); // TODO - allow user to pick size entityObj.BlockModels.AddObject(xAdd); entityObj.SaveChanges(); UpdateStatus("Setting model meta data", 25.0); // add the meta data to identify all of the oclumns etc. List<BlockModelMetadata> blockColumnMetaData = dbIm.SetBlockModelMetaData(blockModelGUID, importMap, connString); // add the new BM guid to the column map as a default so that it is always entered importMap.columnMap.Add(new ColumnMap("", -1, "BlockModelBlock", "BlockModelID", ImportDataMap.TEXTDATATYPE, blockModelGUID.ToString(), null, units)); // add the individual blocks dbIm.AddBlockData(bmDataFile, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, connString); //dbIm.AddBlockDataNorm(bmDataFile, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, blockColumnMetaData); DateTime endTime = DateTime.Now; long compVal = (endTime.Ticks - startTime.Ticks) / 1000; string message = "" + startTime.ToShortTimeString() + " Ended: " + endTime.ToShortTimeString(); long xval = compVal; return ""; } }