public override bool Execute() { Dictionary <egtype, decimal> attributes = new Dictionary <egtype, decimal>(); attributes.Add(egtype.point, 65536); attributes.Add(egtype.linestring, 196608); attributes.Add(egtype.polygon, 262144); attributes.Add(egtype.multipoint, 65536); var avoidFields = AvoidFieldsCache.Instance.GetAvoidFields(Entity.GetType(), true).ToList(); List <Point> points = new List <Point>(); if (Entity.G3E_GEOMETRY is Point) { Point point = Entity.G3E_GEOMETRY as Point; points.Add(point); } else if (Entity.G3E_GEOMETRY is Multipoint) { Multipoint multipoint = Entity.G3E_GEOMETRY as Multipoint; points.Add(multipoint.Points.First()); } else if (Entity.G3E_GEOMETRY is LineString) { LineString lineString = Entity.G3E_GEOMETRY as LineString; points.AddRange(lineString.Points); //avoidFields.Add("G3E_ORIENTATION"); } else if (Entity.G3E_GEOMETRY is Polygon) { Polygon polygon = Entity.G3E_GEOMETRY as Polygon; points.AddRange(polygon.UniqueLineString.Points); //avoidFields.Add("G3E_ORIENTATION"); } points = MakeConnectPoints(points); avoidFields.Add("G3E_GEOMETRY"); int step = 4; var geometryQueryBuilder = new InsertPlainGeometryQueryBuilder(Entity, avoidFields, Mapping); var dbManager = (DbManager as OracleDBManager); var conn = Connection; //using (var conn = dbManager.RevealConnection()) //{ // conn.Open(); //dbManager.RevealedRunsurrounds(Surrounds, conn); //new ParametersBuilder(Entity,) string sql = geometryQueryBuilder.ToString(); using (DbTransaction transaction = conn.BeginTransaction()) { try { //if (Entity.G3E_GEOMETRY is LineString || Entity.G3E_GEOMETRY is Polygon) bool isLineString = Entity.G3E_GEOMETRY is LineString; if (isLineString) { var extCmd = conn.CreateCommand(); var extEntity = Entity.Clone(); var objectParameters = new ParametersBuilder(Entity, extCmd, geometryQueryBuilder.ObjectFields).Parameters; var geometryParamerters = GetGeometryParamerters(extCmd, new List <Point>()).ToList(); objectParameters.Single(o => o.ParameterName == ":G3E_ID").Value = OracleSequenceValueGenerator.Instance.GenerateTableId(Entity.GetType()); var seqParameter = extCmd.CreateParameter() as OracleParameter; seqParameter.ParameterName = ":SDO_SEQ"; seqParameter.Value = 0; var eseqParameter = extCmd.CreateParameter() as OracleParameter; eseqParameter.ParameterName = ":SDO_ESEQ"; eseqParameter.Value = 0; var etypeParameter = extCmd.CreateParameter() as OracleParameter; etypeParameter.ParameterName = ":SDO_ETYPE"; etypeParameter.Value = (decimal)10; var orientation = extCmd.CreateParameter() as OracleParameter; orientation.ParameterName = ":SDO_ORIENTATION"; var gdoAttributes = extCmd.CreateParameter() as OracleParameter; gdoAttributes.ParameterName = ":GDO_ATTRIBUTES"; gdoAttributes.Value = 655360;//attributes[Entity.G3E_GEOMETRY.GeometryType]; extCmd.Parameters.AddRange(objectParameters.Concat(geometryParamerters).ToArray()); extCmd.Parameters.Add(orientation); extCmd.Parameters.Add(seqParameter); extCmd.Parameters.Add(eseqParameter); extCmd.Parameters.Add(etypeParameter); extCmd.Parameters.Add(gdoAttributes); extCmd.CommandText = sql; extCmd.ExecuteNonQuery(); } var allPages = points.Count / step; if (points.Count % step != 0) { allPages++; } for (int page = 0; page < allPages; page++) { var geometryCmd = conn.CreateCommand(); var items = points.Skip(page * step).Take(step); var objectParameters = new ParametersBuilder(Entity, geometryCmd, geometryQueryBuilder.ObjectFields).Parameters; var geometryParamerters = GetGeometryParamerters(geometryCmd, items).ToList(); objectParameters.Single(o => o.ParameterName == ":G3E_ID").Value = OracleSequenceValueGenerator.Instance.GenerateTableId(Entity.GetType()); var seqParameter = geometryCmd.CreateParameter() as OracleParameter; seqParameter.ParameterName = ":SDO_SEQ"; seqParameter.Value = page; var eseqParameter = geometryCmd.CreateParameter() as OracleParameter; eseqParameter.ParameterName = ":SDO_ESEQ"; eseqParameter.Value = isLineString?1: 0; var etypeParameter = geometryCmd.CreateParameter() as OracleParameter; etypeParameter.ParameterName = ":SDO_ETYPE"; var type = (int)Entity.G3E_GEOMETRY.GeometryType; if (type == 2) { type = 1; } etypeParameter.Value = (decimal)type; var orientation = geometryCmd.CreateParameter() as OracleParameter; orientation.ParameterName = ":SDO_ORIENTATION"; var gdoAttributes = geometryCmd.CreateParameter() as OracleParameter; gdoAttributes.ParameterName = ":GDO_ATTRIBUTES"; gdoAttributes.Value = attributes[Entity.G3E_GEOMETRY.GeometryType]; if (Entity.G3E_GEOMETRY is Multipoint) { var normal = (Entity.G3E_GEOMETRY as Multipoint).Points.Last(); //orientation.Precision =15; //orientation.Scale = 15; orientation.Value = (Single)Math.Atan2(normal.Y, normal.X); } else { orientation.Value = null; } geometryCmd.Parameters.AddRange(objectParameters.Concat(geometryParamerters).ToArray()); geometryCmd.Parameters.Add(orientation); geometryCmd.Parameters.Add(seqParameter); geometryCmd.Parameters.Add(eseqParameter); geometryCmd.Parameters.Add(etypeParameter); geometryCmd.Parameters.Add(gdoAttributes); geometryCmd.CommandText = sql; geometryCmd.ExecuteNonQuery(); } transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } //dbManager.RevealedRunEnds(Surrounds, conn); return(true); //} }