Ejemplo n.º 1
0
        /// <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("");
            }
        }
Ejemplo n.º 2
0
        /// <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 "";
            }
        }
Ejemplo n.º 3
0
        public List<string> PerformBMImport(ModelImportStatus mos, Guid blockModelGUID, System.IO.Stream bmFileStream, System.IO.Stream ffFileStream, ImportDataMap importMap, double xOrigin, double yOrigin, double zOrigin, System.ComponentModel.BackgroundWorker worker, int approxNumLines, string NKDProjectID, string alias, Guid authorGuid, string connString)
        {
            this.currentWorker = worker;
            using (var entityObj = new NKDC(connString, null))
            {
                // talk to the import lib to do the import

                DateTime startTime = DateTime.Now;
                int batchSize = 1000;
                //UpdateStatus("Creating new NKD block model", 20.0);
                ImportUtils.BlockImport dbIm = null;
                try
                {
                    dbIm = new ImportUtils.BlockImport();
                    //ImportDataMap importMapLoaded = FormatSpecificationIO.ImportMapIO.LoadImportMap(ffFileStream);
                    BlockModel xAdd = new BlockModel();
                    xAdd.OriginX = (Decimal)xOrigin;                                   // TO-DO
                    xAdd.OriginY = (Decimal)yOrigin;                                   // TO-DO
                    xAdd.OriginZ = (Decimal)zOrigin;                                   // TO-DO
                    xAdd.Alias = alias;
                    // when on server, automatically pick up the author GUID and apply it to the model.
                    if (currentWorker == null)
                    {
                        xAdd.AuthorContactID = authorGuid;
                        xAdd.ResponsibleContactID = authorGuid;
                    }
                    xAdd.VersionUpdated = DateTime.UtcNow;

                    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.
                }
                catch (Exception ex)
                {
                    mos.AddErrorMessage("Error setting block model defintion data. " + ex.ToString());
                }
                List<string> domains = new List<string>();
                if (dbIm != null)
                {
                    try
                    {
                        List<BlockModelMetadata> blockColumnMetaData = dbIm.SetBlockModelMetaData(blockModelGUID, importMap, connString);
                    }
                    catch (Exception ex)
                    {
                        mos.AddErrorMessage("Error setting block model meta data:\n" + ex.ToString());
                    }
                    try
                    {
                        // 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(), blockModelGUID.ToString(), ImportDataMap.UNIT_NONE));
                        // add the individual blocks
                        domains = dbIm.AddBlockData(mos, bmFileStream, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, connString);
                        // run this only if in wonows client (determined by the status of the worker thread at this stage)
                        if (currentWorker != null)
                        {
                            List<Tuple<string, string>> doms = new List<Tuple<string, string>>();
                            string domainColumnName = "Domain";
                            foreach (string ss in domains)
                            {
                                doms.Add(new Tuple<string, string>(domainColumnName, ss));
                            }
                            dbIm.UpdateDomains(doms, blockModelGUID);
                        }
                    }
                    catch (Exception ex)
                    {
                        mos.AddErrorMessage("Error adding block data:\n" + ex.ToString());
                    }

                }
                return domains;
            }
        }
Ejemplo n.º 4
0
        public List <string> PerformBMImport(ModelImportStatus mos, Guid blockModelGUID, System.IO.Stream bmFileStream, System.IO.Stream ffFileStream, ImportDataMap importMap, double xOrigin, double yOrigin, double zOrigin, System.ComponentModel.BackgroundWorker worker, int approxNumLines, string NKDProjectID, string alias, Guid authorGuid, string connString)
        {
            this.currentWorker = worker;
            using (var entityObj = new NKDC(connString, null))
            {
                // talk to the import lib to do the import

                DateTime startTime = DateTime.Now;
                int      batchSize = 1000;
                //UpdateStatus("Creating new NKD block model", 20.0);
                ImportUtils.BlockImport dbIm = null;
                try
                {
                    dbIm = new ImportUtils.BlockImport();
                    //ImportDataMap importMapLoaded = FormatSpecificationIO.ImportMapIO.LoadImportMap(ffFileStream);
                    BlockModel xAdd = new BlockModel();
                    xAdd.OriginX = (Decimal)xOrigin;                                   // TO-DO
                    xAdd.OriginY = (Decimal)yOrigin;                                   // TO-DO
                    xAdd.OriginZ = (Decimal)zOrigin;                                   // TO-DO
                    xAdd.Alias   = alias;
                    // when on server, automatically pick up the author GUID and apply it to the model.
                    if (currentWorker == null)
                    {
                        xAdd.AuthorContactID      = authorGuid;
                        xAdd.ResponsibleContactID = authorGuid;
                    }
                    xAdd.VersionUpdated = DateTime.UtcNow;

                    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.
                }
                catch (Exception ex)
                {
                    mos.AddErrorMessage("Error setting block model defintion data. " + ex.ToString());
                }
                List <string> domains = new List <string>();
                if (dbIm != null)
                {
                    try
                    {
                        List <BlockModelMetadata> blockColumnMetaData = dbIm.SetBlockModelMetaData(blockModelGUID, importMap, connString);
                    }
                    catch (Exception ex)
                    {
                        mos.AddErrorMessage("Error setting block model meta data:\n" + ex.ToString());
                    }
                    try
                    {
                        // 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(), blockModelGUID.ToString(), ImportDataMap.UNIT_NONE));
                        // add the individual blocks
                        domains = dbIm.AddBlockData(mos, bmFileStream, importMap, blockModelGUID, batchSize, UpdateStatus, approxNumLines, connString);
                        // run this only if in wonows client (determined by the status of the worker thread at this stage)
                        if (currentWorker != null)
                        {
                            List <Tuple <string, string> > doms = new List <Tuple <string, string> >();
                            string domainColumnName             = "Domain";
                            foreach (string ss in domains)
                            {
                                doms.Add(new Tuple <string, string>(domainColumnName, ss));
                            }
                            dbIm.UpdateDomains(doms, blockModelGUID);
                        }
                    }
                    catch (Exception ex)
                    {
                        mos.AddErrorMessage("Error adding block data:\n" + ex.ToString());
                    }
                }
                return(domains);
            }
        }