//Return all Dwgs relatives path, EXCEPT Note_Path file
        public static HashSet <DwgFileModel> GetDwgsPath(SQLiteConnection sqlConn)
        {
            HashSet <DwgFileModel> dwgsSet = new HashSet <DwgFileModel>();
            List <DwgFileModel>    files   = DBDwgFile.GetDwgFilesExceptPNote(sqlConn);

            foreach (DwgFileModel file in files)
            {
                dwgsSet.Add(file);
            }
            return(dwgsSet);
        }
        private static FixtureDetailsModel GetFixture(SQLiteDataReader reader, SQLiteConnection connection)
        {
            FixtureDetailsModel model;

            long   POSITION_ID  = (long)reader[DBFixtureDetailsNames.POSITION_ID];
            long   TRANSFORM_ID = (long)reader[DBFixtureDetailsNames.MATRIX_ID];
            string HANDLE       = (string)reader[DBFixtureDetailsNames.HANDLE];
            double INDEX        = (double)reader[DBFixtureDetailsNames.INDEXX];
            string FIXTURE_NAME = (string)reader[DBFixtureDetailsNames.FIXTURE_NAME];
            string TAG          = (string)reader[DBFixtureDetailsNames.TAG];
            string NUMBER       = (string)reader[DBFixtureDetailsNames.NUMBER];
            double CW_DIA       = (double)reader[DBFixtureDetailsNames.CW_DIA];
            double HW_DIA       = (double)reader[DBFixtureDetailsNames.HW_DIA];
            double WASTE_DIA    = (double)reader[DBFixtureDetailsNames.WASTE_DIA];
            double VENT_DIA     = (double)reader[DBFixtureDetailsNames.VENT_DIA];
            double STORM_DIA    = (double)reader[DBFixtureDetailsNames.STORM_DIA];
            double WSFU         = (double)reader[DBFixtureDetailsNames.WSFU];
            double CWSFU        = (double)reader[DBFixtureDetailsNames.CWSFU];
            double HWSFU        = (double)reader[DBFixtureDetailsNames.HWSFU];
            double DFU          = (double)reader[DBFixtureDetailsNames.DFU];
            string DESCRIPTION  = (string)reader[DBFixtureDetailsNames.DESCRIPTION];
            long   ID           = (long)reader[DBFixtureDetailsNames.ID];
            long   FILE_ID      = (long)reader[DBFixtureDetailsNames.FILE_ID];

            Matrix3dModel matrix   = DBMatrix3d.SelectRow(connection, TRANSFORM_ID);
            Point3dModel  position = DBPoint3D.SelectRow(connection, POSITION_ID);
            DwgFileModel  file     = DBDwgFile.SelectRow(connection, FILE_ID);

            model                 = new FixtureDetailsModel();
            model.position        = position;
            model.matrixTransform = matrix;
            model.handle          = HANDLE;
            model.INDEX           = INDEX;
            model.FIXTURENAME     = FIXTURE_NAME;
            model.TAG             = TAG;
            model.NUMBER          = NUMBER;
            model.CW_DIA          = CW_DIA;
            model.HW_DIA          = HW_DIA;
            model.WASTE_DIA       = WASTE_DIA;
            model.VENT_DIA        = VENT_DIA;
            model.STORM_DIA       = STORM_DIA;
            model.WSFU            = WSFU;
            model.CWSFU           = CWSFU;
            model.HWSFU           = HWSFU;
            model.DFU             = DFU;
            model.DESCRIPTION     = DESCRIPTION;
            model.ID              = ID;
            model.file            = file;

            return(model);
        }
Exemple #3
0
        private static InsertPointModel GetModel(SQLiteDataReader reader, SQLiteConnection connection)
        {
            string        alias   = (string)reader[DBInsertPointName.ALIAS];
            string        name    = (string)reader[DBInsertPointName.ANAME];
            long          ID      = (long)reader[DBInsertPointName.ID];
            Point3dModel  pos     = DBPoint3D.SelectRow(connection, (long)reader[DBInsertPointName.POSITION_ID]);
            string        handle1 = (string)reader[DBInsertPointName.HANDLE];
            DwgFileModel  file    = DBDwgFile.SelectRow(connection, (long)reader[DBInsertPointName.FILE_ID]);
            Matrix3dModel matrix  = DBMatrix3d.SelectRow(connection, (long)reader[DBInsertPointName.MATRIX_ID]);

            InsertPointModel model = new InsertPointModel(alias, name, ID, file, handle1, pos, matrix);

            return(model);
        }
        public static void InitTable(string databasePath)
        {
            SQLiteConnection sqliteConn = new SQLiteConnection(DBCommand.GetConnectionString(databasePath));

            try
            {
                sqliteConn.Open();
                SQLiteTransaction sqliteTrans = sqliteConn.BeginTransaction();

                DBMatrix3d.CreateTable(sqliteConn);
                DBPoint3D.CreateTable(sqliteConn);
                DBInsertPoint.CreateTable(sqliteConn);
                DBFixtureDetails.CreateTable(sqliteConn);
                DBFixtureBeingUsedArea.CreateTable(sqliteConn);
                DBDwgFile.CreateTable(sqliteConn);
                DBTable.CreateTable(sqliteConn);
                DBFixture_Unit.CreateTable(sqliteConn);
                DBAreaBorder.CreateTable(sqliteConn);

                if (projectElement.P_NOTE != null)
                {
                    projectElement.P_NOTE.WriteToDatabase(sqliteConn);
                }

                if (projectElement.Dwgs != null)
                {
                    foreach (DwgFileModel model in projectElement.Dwgs)
                    {
                        model.WriteToDatabase(sqliteConn);
                    }
                }

                sqliteTrans.Commit();
                sqliteTrans.Dispose();
                sqliteConn.Close();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception e)
            {
                DebugMessage(string.Format(@"Error opening Database: {0}, Error:{1}", databasePath, e.Message));
            }
        }
Exemple #5
0
        private static FixtureBeingUsedAreaModel GetModelFromReader(SQLiteDataReader reader, SQLiteConnection connection)
        {
            FixtureBeingUsedAreaModel model = new FixtureBeingUsedAreaModel();

            model.ID     = (long)reader[DBFixtureBeingUsedAreaName.ID];
            model.handle = (string)reader[DBFixtureBeingUsedAreaName.HANDLE];

            model.position    = DBPoint3D.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.POSITION_ID]);
            model.pointTop    = DBPoint3D.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.POINT_TOP_ID]);
            model.pointBottom = DBPoint3D.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.POINT_BOTTOM_ID]);
            model.origin      = DBPoint3D.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.ORIGIN_ID]);

            model.matrixTransform = DBMatrix3d.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.MATRIX_ID]);
            model.X    = (double)reader[DBFixtureBeingUsedAreaName.X];
            model.Y    = (double)reader[DBFixtureBeingUsedAreaName.Y];
            model.file = DBDwgFile.SelectRow(connection, (long)reader[DBFixtureBeingUsedAreaName.FILE_ID]);

            if (model.ID == ConstantName.invalidNum)
            {
                model = null;
            }

            return(model);
        }
        //SQL connection must be OPEN.
        //This function should be put between transaction.
        public static DwgFileModel GetNotePath(SQLiteConnection sqlConn)
        {
            DwgFileModel model = DBDwgFile.GetPNote(sqlConn);

            return(model);
        }