Example #1
0
        public static void DeleteRow(SQLiteConnection connection, long ID)
        {
            FixtureBeingUsedAreaModel model = SelectRow(connection, ID);

            gBlock.DeleteRow(ID, connection);
            DeleteOthers(model, connection);
        }
Example #2
0
        public static void DeleteRow(SQLiteConnection connection, string handle, long fileID)
        {
            FixtureBeingUsedAreaModel model = SelectRow(connection, handle, fileID);

            gBlock.DeleteRow(handle, fileID, connection);
            DeleteOthers(model, connection);
        }
Example #3
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);
                }
            }
        }
Example #4
0
        private static List <List <object> > GetItems(FixtureBeingUsedAreaModel model)
        {
            List <List <object> > items = new List <List <object> > {
                new List <object> {
                    DBFixtureBeingUsedAreaName.HANDLE, DBFixtureBeingUsedAreaName_AT.handle, model.handle
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.POSITION_ID, DBFixtureBeingUsedAreaName_AT.position, model.position.ID
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.X, DBFixtureBeingUsedAreaName_AT.x, model.X
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.Y, DBFixtureBeingUsedAreaName_AT.y, model.Y
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.ORIGIN_ID, DBFixtureBeingUsedAreaName_AT.origin, model.origin.ID
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.POINT_TOP_ID, DBFixtureBeingUsedAreaName_AT.top, model.pointTop.ID
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.POINT_BOTTOM_ID, DBFixtureBeingUsedAreaName_AT.bottom, model.pointBottom.ID
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.MATRIX_ID, DBFixtureBeingUsedAreaName_AT.matrix, model.matrixTransform.ID
                },
                new List <object> {
                    DBFixtureBeingUsedAreaName.FILE_ID, DBFixtureBeingUsedAreaName_AT.file, model.file.ID
                },
            };

            return(items);
        }
Example #5
0
        public static void DeleteRow(SQLiteConnection connection, Dictionary <string, string> conDict, Dictionary <string, object> paraDict)
        {
            FixtureBeingUsedAreaModel model = SelectRow(connection, conDict, paraDict);

            gBlock.DeleteRow(conDict, paraDict, connection);
            DeleteOthers(model, connection);
        }
Example #6
0
        public static void DeleteRow(SQLiteConnection connection, string handle, string relPath)
        {
            FixtureBeingUsedAreaModel model = SelectRow(connection, handle, relPath);

            gBlock.DeleteRow(handle, relPath, connection);
            DeleteOthers(model, connection);
        }
Example #7
0
        public static void InsertRow(FixtureBeingUsedAreaModel model, SQLiteCommand command)
        {
            List <List <object> > items = GetItems(model);

            List <string> variables = new List <string>();
            Dictionary <string, object> paraDict = new Dictionary <string, object>();

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

            DBCommand.InsertCommand(DBFixtureBeingUsedAreaName.name, variables, paraDict, command);
        }
Example #8
0
 public static long InsertRow(SQLiteConnection connection, ref FixtureBeingUsedAreaModel model)
 {
     using (SQLiteCommand command = connection.CreateCommand())
     {
         DBFixtureBeingUsedAreaCommands.InsertRow(model, command);
         long check = command.ExecuteNonQuery();
         if (check == 1)
         {
             model.ID = connection.LastInsertRowId;
             return(model.ID);
         }
         else if (check == 0)
         {
             throw new Exception("DBFixtureBeingUsed -> insertRow -> No Row is inserted.");
         }
         throw new Exception("DBFixtureBeingUsed -> insertRow -> Row insertion not successful.");
     }
 }
Example #9
0
 public static long UpdateRow(SQLiteConnection connection, FixtureBeingUsedAreaModel model)
 {
     using (SQLiteCommand command = connection.CreateCommand())
     {
         DBFixtureBeingUsedAreaCommands.UpdateRow(command, model);
         long check = command.ExecuteNonQuery();
         if (check == 1)
         {
             model.ID = connection.LastInsertRowId;
             return(model.ID);
         }
         else if (check == 0)
         {
             //throw new Exception("FixtureBeingUsedAreaModel -> UpdateRow -> No Row is Updated.");
         }
         throw new Exception("FixtureBeingUsedAreaModel -> UpdateRow -> Insert Not Successful.");
     }
 }
        private void GetTopAndBottomPoint(BlockReference block)
        {
            model                 = new FixtureBeingUsedAreaModel();
            model.handle          = Goodies.ConvertHandleToString(block.Handle);
            model.position        = new Point3dModel(block.Position.ToArray());
            model.matrixTransform = new Matrix3dModel(block.BlockTransform.ToArray());

            DynamicBlockReferencePropertyCollection dynBlockPropCol = block.DynamicBlockReferencePropertyCollection;

            foreach (DynamicBlockReferenceProperty dynProp in dynBlockPropCol)
            {
                if (dynProp.PropertyName.Equals(DBFixtureBeingUsedAreaName.X))
                {
                    model.X = (double)dynProp.Value;
                }
                else if (dynProp.PropertyName.Equals(DBFixtureBeingUsedAreaName.Y))
                {
                    model.Y = (double)dynProp.Value;
                }
                else if (dynProp.PropertyName.Equals("Origin"))
                {
                    model.origin = new Point3dModel(((Point3d)dynProp.Value).ToArray());
                }
            }

            Point3d pointTop = new Point3d(model.origin.X, model.origin.Y, 0);

            //Use the regular X,Y coordinate, DO NOT use Game or Web coordinate
            Point3d pointBottom = new Point3d(model.origin.X + model.X, model.origin.Y - model.Y, 0);

            pointTop    = pointTop.TransformBy(block.BlockTransform);
            pointBottom = pointBottom.TransformBy(block.BlockTransform);

            model.pointBottom = new Point3dModel(pointBottom.ToArray());
            model.pointTop    = new Point3dModel(pointTop.ToArray());
        }
Example #11
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);
        }
Example #12
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);
        }
 public FixtureBeingUsedArea(FixtureBeingUsedAreaModel model)
 {
     this.model = model;
 }