public static void DeleteRow(SQLiteConnection connection, string handle, string relPath) { AreaBorderModel model = SelectRow(connection, handle, relPath); gBlock.DeleteRow(handle, relPath, connection); DeleteOthers(model, connection); }
public static void DeleteRow(SQLiteConnection connection, Dictionary <string, string> conDict, Dictionary <string, object> paraDict) { AreaBorderModel model = SelectRow(connection, conDict, paraDict); gBlock.DeleteRow(conDict, paraDict, connection); DeleteOthers(model, connection); }
public static void DeleteRow(SQLiteConnection connection, long ID) { AreaBorderModel model = SelectRow(connection, ID); gBlock.DeleteRow(ID, connection); DeleteOthers(model, connection); }
public static void DeleteRow(SQLiteConnection connection, string handle, long fileID) { AreaBorderModel model = SelectRow(connection, handle, fileID); gBlock.DeleteRow(handle, fileID, connection); DeleteOthers(model, connection); }
private static void DeleteOthers(AreaBorderModel 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 List <List <object> > GetItems(AreaBorderModel model) { List <List <object> > items = new List <List <object> > { new List <object> { DBAreaBorderNames.HANDLE, DBAreaBorderNames_AT.handle, model.handle }, new List <object> { DBAreaBorderNames.POSITION_ID, DBAreaBorderNames_AT.position, model.position.ID }, new List <object> { DBAreaBorderNames.X, DBAreaBorderNames_AT.x, model.X }, new List <object> { DBAreaBorderNames.Y, DBAreaBorderNames_AT.y, model.Y }, new List <object> { DBAreaBorderNames.ORIGIN_ID, DBAreaBorderNames_AT.origin, model.origin.ID }, new List <object> { DBAreaBorderNames.POINT_TOP_ID, DBAreaBorderNames_AT.top, model.pointTop.ID }, new List <object> { DBAreaBorderNames.POINT_BOTTOM_ID, DBAreaBorderNames_AT.bottom, model.pointBottom.ID }, new List <object> { DBAreaBorderNames.MATRIX_ID, DBAreaBorderNames_AT.matrix, model.matrixTransform.ID }, new List <object> { DBAreaBorderNames.FILE_ID, DBAreaBorderNames_AT.file, model.file.ID }, }; return(items); }
public static void InsertRow(AreaBorderModel 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(DBAreaBorderNames.name, variables, paraDict, command); }
private void GetTopAndBottomPoint(BlockReference block, Transaction tr) { model = new AreaBorderModel(); 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()); } } foreach (ObjectId id in block.AttributeCollection) { AttributeReference aRef = (AttributeReference)tr.GetObject(id, OpenMode.ForRead); if (aRef.Tag == AreaBroderModelName.type) { model.type = aRef.TextString; } else if (aRef.Tag == AreaBroderModelName.alias) { model.alias = aRef.TextString; } } 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()); }
public static long InsertRow(SQLiteConnection connection, ref AreaBorderModel model) { using (SQLiteCommand command = connection.CreateCommand()) { DBAreaBorderCommands.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."); } }
public static long UpdateRow(SQLiteConnection connection, AreaBorderModel model) { using (SQLiteCommand command = connection.CreateCommand()) { DBAreaBorderCommands.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."); } }
public static void UpdateRow(SQLiteCommand command, AreaBorderModel model) { List <List <object> > items = GetItems(model); Dictionary <string, string> variables = new Dictionary <string, string>(); Dictionary <string, string> conDict = new Dictionary <string, string> { { DBAreaBorderNames.ID, DBAreaBorderNames_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(DBAreaBorderNames.name, variables, conDict, paraDict, command); command.ExecuteNonQuery(); }
private static AreaBorderModel GetModelFromReader(SQLiteDataReader reader, SQLiteConnection connection) { AreaBorderModel model = new AreaBorderModel(); model.ID = (long)reader[DBAreaBorderNames.ID]; model.handle = (string)reader[DBAreaBorderNames.HANDLE]; model.position = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POSITION_ID]); model.pointTop = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POINT_TOP_ID]); model.pointBottom = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.POINT_BOTTOM_ID]); model.origin = DBPoint3D.SelectRow(connection, (long)reader[DBAreaBorderNames.ORIGIN_ID]); model.matrixTransform = DBMatrix3d.SelectRow(connection, (long)reader[DBAreaBorderNames.MATRIX_ID]); model.X = (double)reader[DBAreaBorderNames.X]; model.Y = (double)reader[DBAreaBorderNames.Y]; model.file = DBDwgFile.SelectRow(connection, (long)reader[DBAreaBorderNames.FILE_ID]); if (model.ID == ConstantName.invalidNum) { model = null; } return(model); }
public AreaBorder(AreaBorderModel model) { this.model = model; }