Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }