public override bool IsBlobType(IDbDataParameter idbparameter) { object otype = ClassLoader.GetPropValue(idbparameter, "IfxType"); object blobType = ClassLoader.GetEnumValue(IfxAssembly, InformixDbTypeEnum, "Byte"); return((int)otype == (int)blobType); }
public override bool IsBlobType(IDbDataParameter idbparameter) { object otype = ClassLoader.GetPropValue(idbparameter, "NpgsqlDbType"); object blobType = ClassLoader.GetEnumValue(NpgsqlAssembly, NpgsqlDbTypeEnum, "Bytea"); return((int)otype == (int)blobType); }
private void ParsePostgresException(Exception ex, String errorType) { if (errorType == "Npgsql.PostgresException") { m_sSqlState = (String)ClassLoader.GetPropValue(ex, "Code"); m_sErrorInfo = ex.Message.ToLower(); m_sDBMSErrorInfo = ex.Message.ToLower(); byte[] buf = BitConverter.GetBytes(ex.HResult); byte[] errCode = new byte[2]; Array.Copy(buf, 0, errCode, 0, 2); m_iErrorCode = BitConverter.ToInt16(errCode, 0); } else { m_sErrorInfo = ex.Message.ToLower(); m_sDBMSErrorInfo = ex.Message.ToLower(); byte[] buf = BitConverter.GetBytes(ex.HResult); byte[] errCode = new byte[2]; Array.Copy(buf, 0, errCode, 0, 2); m_iErrorCode = BitConverter.ToInt16(errCode, 0); } }
private void ParseOracleManagedException(Exception ex) { m_sErrorInfo = (String)ClassLoader.GetPropValue(ex, "Message"); m_sDBMSErrorInfo = (String)ClassLoader.GetPropValue(ex, "Message"); m_iErrorCode = (int)ClassLoader.GetPropValue(ex, "Number"); }
internal static double Lat(object instance) { return(((SqlDouble)ClassLoader.GetPropValue(instance, "Lat")).Value); }
public void FromString(String s) { if (IsGeoNull(s)) { geoText = EMPTY_GEOMETRY; } else { geoText = s.Trim(); } try { // Sql Server Text _innerValue = SQLGeographyWrapper.Parse(geoText); if ((!SQLGeographyWrapper.IsValid(_innerValue)) && _innerValue != null) { _innerValue = SQLGeographyWrapper.MakeValid(_innerValue); } this.srid = ((SqlInt32)ClassLoader.GetPropValue(_innerValue, "STSrid")).Value; this.setGXGeoType(SQLGeographyWrapper.STGeometryType(_innerValue).ToString()); if (GeographicType == GeoGraphicTypeValue.Point) { this.Point.Longitude = SQLGeographyWrapper.Long(_innerValue); this.Point.Latitude = SQLGeographyWrapper.Lat(_innerValue); } } catch (ArgumentException ex) { if (ex.ToString().Contains("24144")) // makevalid didn´t work { _innerValue = null; } if (ex.ToString().Contains("24200")) // Error code for invalid Geo. { _innerValue = SQLGeographyWrapper.STGeomFromText(geoText, srid); } else { // Cannot parse value this.InnerValue = SQLGeographyWrapper.NullSQLGeography; this.geoText = ""; this.Point.Longitude = 0; this.Point.Latitude = 0; } } catch (FormatException ex) { String exText = ex.ToString(); if (!String.IsNullOrEmpty(exText) && (ex.ToString().Contains("24114") || ex.ToString().Contains("24141"))) { if (GeographicType == GeoGraphicTypeValue.Point && !String.IsNullOrEmpty(geoText)) { int commas = geoText.Split(',').Length - 1; if ((commas == 1) && !geoText.Contains(" ")) { // has . as decimal separator and "," as value sep geoText = geoText.Replace(',', ' '); } else { if (geoText.Contains(",") && geoText.Contains(" ")) { geoText = geoText.Replace(',', '.'); } } try { String[] coord = geoText.Split(new char[] { ' ' }, 2); this.Point.Longitude = Convert.ToDouble(coord[1].Trim(), CultureInfo.InvariantCulture.NumberFormat); this.Point.Latitude = Convert.ToDouble(coord[0].Trim(), CultureInfo.InvariantCulture.NumberFormat); this.srid = 4326; // Latitude and Longitud parameters are reversed in the 'Point' constructor: _innerValue = ClassLoader.InvokeStatic(SQLGeographyWrapper.GeoAssembly, SQLGeographyWrapper.SqlGeographyClass, "Point", new object[] { this.Point.Latitude, this.Point.Longitude, this.Srid }); } catch (Exception) { // Can't convert to geography set as null. _innerValue = SQLGeographyWrapper.NullSQLGeography; this.geoText = ""; this.Point.Longitude = 0; this.Point.Latitude = 0; } } else { // Cannot parse value _innerValue = SQLGeographyWrapper.NullSQLGeography; this.geoText = ""; this.Point.Longitude = 0; this.Point.Latitude = 0; } } else { // Cannot parse value _innerValue = SQLGeographyWrapper.NullSQLGeography; this.geoText = ""; this.Point.Longitude = 0; this.Point.Latitude = 0; } } }