public static projectUnit getProjectUnitLength(int fedID) { projectUnit projectUnit = projectUnit.SIUnit_Length_Meter; string SqlStmt = "Select PROPERTYVALUE from " + DBOperation.formatTabName("BIMRL_PROPERTIES", fedID) + " P, " + DBOperation.formatTabName("BIMRL_ELEMENT", fedID) + " E" + " where P.ELEMENTID=E.ELEMENTID and E.ELEMENTTYPE='IFCPROJECT' AND PROPERTYGROUPNAME='IFCATTRIBUTES' AND PROPERTYNAME='LENGTHUNIT'"; string currStep = SqlStmt; OracleCommand command = new OracleCommand(SqlStmt, DBConn); try { object unitS = command.ExecuteScalar(); if (unitS != null) { string unitString = unitS as string; if (string.Compare(unitString, "MILLI METRE", true) == 0) { projectUnit = projectUnit.SIUnit_Length_MilliMeter; } else if (string.Compare(unitString, "INCH", true) == 0) { projectUnit = projectUnit.Imperial_Length_Inch; } else if (string.Compare(unitString, "FOOT", true) == 0) { projectUnit = projectUnit.Imperial_Length_Foot; } } } catch (OracleException e) { string excStr = "%%Error - " + e.Message + "\n\t" + currStep; refBIMRLCommon.StackPushError(excStr); command.Dispose(); } command.Dispose(); currModelProjectUnitLength = projectUnit; return(projectUnit); }
public static void regenSpatialIndexDict(int fedID, OctreeDict regenSpIndexTree) { BIMRLCommon refBIMRLCommon = new BIMRLCommon(); string sqlStmt = "SELECT ELEMENTID, CELLID FROM " + DBOperation.formatTabName("BIMRL_SPATIALINDEX", fedID); try { OracleCommand cmd = new OracleCommand(sqlStmt, DBOperation.DBConn); cmd.FetchSize = 100000; OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string elementid = reader.GetString(0); ElementID eID = new ElementID(elementid); string cellid = reader.GetString(1); CellID64 cell = new CellID64(cellid); SortedSet <int> cData = new SortedSet <int>(); cData.Add(getIndexForElementID(eID.ElementIDNo)); // the flag is no longer used, any value doesn't matter CellData data = new CellData { nodeType = 1, data = cData }; regenSpIndexTree.AddOrUpdate(cell.iCellID, data); } reader.Dispose(); cmd.Dispose(); } catch (OracleException e) { string excStr = "%%Read Error - " + e.Message + "\n\t" + sqlStmt; refBIMRLCommon.StackPushError(excStr); } catch (SystemException e) { string excStr = "%%Read Error - " + e.Message + "\n\t" + sqlStmt; refBIMRLCommon.StackPushError(excStr); throw; } }
public static int executeSingleStmt(string sqlStmt, bool commit = true) { int commandStatus = -1; OracleCommand command = new OracleCommand(sqlStmt, DBConn); DBOperation.beginTransaction(); try { commandStatus = command.ExecuteNonQuery(); if (commit) { DBOperation.commitTransaction(); } } catch (OracleException e) { string excStr = "%%Error - " + e.Message + "\n\t" + sqlStmt; refBIMRLCommon.StackPushError(excStr); command.Dispose(); } command.Dispose(); return(commandStatus); }
public static FedIDStatus getFederatedModel(string modelName, string projName, string projNumber, out FederatedModelInfo fedModel) { fedModel = new FederatedModelInfo(); FedIDStatus stat = FedIDStatus.FedIDExisting; string currStep = "Getting federated ID"; // Create separate connection with a short duration string SqlStmt = "Select FEDERATEDID federatedID, ModelName, ProjectNumber, ProjectName, WORLDBBOX, MAXOCTREELEVEL, LastUpdateDate, Owner, DBConnection from BIMRL_FEDERATEDMODEL where MODELNAME = '" + modelName + "' and PROJECTNAME = '" + projName + "' and PROJECTNUMBER = '" + projNumber + "'"; OracleCommand command = new OracleCommand(SqlStmt, DBConn); OracleDataReader reader = command.ExecuteReader(); try { if (!reader.Read()) { reader.Close(); // Create a new record command.CommandText = "Insert into BIMRL_FEDERATEDMODEL (MODELNAME, PROJECTNAME, PROJECTNUMBER) values ('" + modelName + "', '" + projName + "', '" + projNumber + "')"; DBOperation.beginTransaction(); command.ExecuteNonQuery(); DBOperation.commitTransaction(); stat = FedIDStatus.FedIDNew; } command.CommandText = SqlStmt; reader = command.ExecuteReader(); reader.Read(); fedModel.FederatedID = reader.GetInt32(0); fedModel.ModelName = reader.GetString(1); fedModel.ProjectNumber = reader.GetString(2); fedModel.ProjectName = reader.GetString(3); if (!reader.IsDBNull(4)) { SdoGeometry worldBB = reader.GetValue(4) as SdoGeometry; Point3D LLB = new Point3D(worldBB.OrdinatesArrayOfDoubles[0], worldBB.OrdinatesArrayOfDoubles[1], worldBB.OrdinatesArrayOfDoubles[2]); Point3D URT = new Point3D(worldBB.OrdinatesArrayOfDoubles[3], worldBB.OrdinatesArrayOfDoubles[4], worldBB.OrdinatesArrayOfDoubles[5]); fedModel.WorldBoundingBox = LLB.ToString() + " " + URT.ToString(); } if (!reader.IsDBNull(5)) { fedModel.OctreeMaxDepth = reader.GetInt16(5); } if (!reader.IsDBNull(6)) { fedModel.LastUpdateDate = reader.GetDateTime(6); } if (!reader.IsDBNull(7)) { fedModel.Owner = reader.GetString(7); } if (!reader.IsDBNull(8)) { fedModel.DBConnection = reader.GetString(8); } reader.Close(); } catch (OracleException e) { string excStr = "%%Error - " + e.Message + "\n\t" + currStep; refBIMRLCommon.StackPushError(excStr); command.Dispose(); throw; } command.Dispose(); return(stat); }