示例#1
0
        private static void DeleteOthers(FixtureBeingUsedAreaModel model, SQLiteConnection connection)
        {
            if (model != null)
            {
                DBPoint3D.DeleteRow(connection, model.file.ID);
                DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID);

                if (model.position != null)
                {
                    DBPoint3D.DeleteRow(connection, model.position.ID);
                }
                if (model.origin != null)
                {
                    DBPoint3D.DeleteRow(connection, model.origin.ID);
                }
                if (model.pointTop != null)
                {
                    DBPoint3D.DeleteRow(connection, model.pointTop.ID);
                }
                if (model.pointBottom != null)
                {
                    DBPoint3D.DeleteRow(connection, model.pointBottom.ID);
                }
                if (model.matrixTransform != null)
                {
                    DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID);
                }
            }
        }
 private static void DeleteOthers(FixtureDetailsModel model, SQLiteConnection connection)
 {
     if (model != null)
     {
         DBPoint3D.DeleteRow(connection, model.file.ID);
         DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID);
     }
 }
示例#3
0
 private static void DeleteOthers(InsertPointModel model, SQLiteConnection connection)
 {
     if (model != null)
     {
         DBPoint3D.DeleteRow(connection, model.position.ID);
         DBMatrix3d.DeleteRow(connection, model.matrixTransform.ID);
     }
 }
        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);
        }
示例#5
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));
            }
        }
示例#7
0
        public static void UpdateRow(SQLiteCommand command, InsertPointModel model)
        {
            DBPoint3D.UpdateRow(model.position, command.Connection);
            DBMatrix3d.Update(command.Connection, model.matrixTransform);

            List <List <object> > items = GetItemsList(model);

            Dictionary <string, string> variables  = new Dictionary <string, string>();
            Dictionary <string, string> conditions = new Dictionary <string, string> {
                { DBInsertPointName.ID, DBInsertPointName_AT.id }
            };
            Dictionary <string, object> paraDict = new Dictionary <string, object>();

            foreach (List <object> item in items)
            {
                variables.Add((string)item[0], (string)item[1]);
                paraDict.Add((string)item[1], item[2]);
            }

            paraDict.Add(DBBlockName_AT.id, model.ID);
            DBCommand.UpdateRow(DBInsertPointName.name, variables, conditions, paraDict, command);
        }
        public static void UpdateRow(FixtureDetailsModel model, SQLiteCommand command)
        {
            DBPoint3D.UpdateRow(model.position, command.Connection);
            DBMatrix3d.Update(command.Connection, model.matrixTransform);

            List <List <object> > items = getListItems(model);

            Dictionary <string, string> variables = new Dictionary <string, string>();
            Dictionary <string, string> conDict   = new Dictionary <string, string> {
                { DBFixtureDetailsNames.ID, DBFixtureDetailsNames_AT.id }
            };
            Dictionary <string, object> paraDict = new Dictionary <string, object>();

            foreach (List <object> item in items)
            {
                variables.Add((string)item[0], (string)item[1]);
                paraDict.Add((string)item[1], item[2]);
            }

            paraDict.Add(DBFixtureDetailsNames_AT.id, model.ID);

            DBCommand.UpdateRow(DBFixtureDetailsNames.name, variables, conDict, paraDict, command);
        }
示例#9
0
        public static void UpdateRow(SQLiteCommand command, FixtureBeingUsedAreaModel model)
        {
            DBPoint3D.UpdateRow(model.pointTop, command.Connection);
            DBPoint3D.UpdateRow(model.pointBottom, command.Connection);
            DBPoint3D.UpdateRow(model.origin, command.Connection);
            DBPoint3D.UpdateRow(model.position, command.Connection);
            DBMatrix3d.Update(command.Connection, model.matrixTransform);

            List <List <object> > items = GetItems(model);

            Dictionary <string, string> variables = new Dictionary <string, string>();
            Dictionary <string, string> conDict   = new Dictionary <string, string> {
                { DBFixtureBeingUsedAreaName.ID, DBFixtureBeingUsedAreaName_AT.id }
            };
            Dictionary <string, object> paraDict = new Dictionary <string, object>();

            foreach (List <object> item in items)
            {
                variables.Add((string)item[0], (string)item[1]);
                paraDict.Add((string)item[1], item[2]);
            }

            DBCommand.UpdateRow(DBFixtureBeingUsedAreaName.name, variables, conDict, paraDict, command);
        }
示例#10
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);
        }