예제 #1
0
        internal static byte[] GetBytesFromBuffer(NativeBuffer buffer, int valueOffset, int lengthOffset, MetaType metaType, OracleConnection connection)
        {
            uint num2;

            OCI.DATATYPE ociType = metaType.OciType;
            short        length  = buffer.ReadInt16(lengthOffset);

            OCI.DATATYPE datatype = ociType;
            if (datatype == OCI.DATATYPE.DATE)
            {
                num2 = 7;
            }
            else if (datatype == OCI.DATATYPE.INT_TIMESTAMP)
            {
                num2 = 11;
            }
            else if (datatype == OCI.DATATYPE.INT_TIMESTAMP_LTZ)
            {
                num2 = 13;
            }
            else
            {
                num2 = 13;
            }
            byte[] destination = new byte[num2];
            buffer.ReadBytes(valueOffset, destination, 0, length);
            if (OCI.DATATYPE.INT_TIMESTAMP_LTZ == ociType)
            {
                TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                destination[11] = (byte)(serverTimeZoneAdjustmentToUTC.Hours + 20);
                destination[12] = (byte)(serverTimeZoneAdjustmentToUTC.Minutes + 60);
                return(destination);
            }
            if ((OCI.DATATYPE.INT_TIMESTAMP_TZ == ociType) && (0x80 < destination[11]))
            {
                sbyte num3;
                sbyte num4;
                OciIntervalDescriptor reftz    = new OciIntervalDescriptor(connection.EnvironmentHandle);
                OciDateTimeDescriptor datetime = new OciDateTimeDescriptor(connection.EnvironmentHandle, OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ);
                int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, destination, num2, 0xbc, datetime, reftz, 0);
                if (rc != 0)
                {
                    connection.CheckError(connection.ErrorHandle, rc);
                }
                rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeGetTimeZoneOffset(connection.EnvironmentHandle, connection.ErrorHandle, datetime, out num4, out num3);
                if (rc != 0)
                {
                    connection.CheckError(connection.ErrorHandle, rc);
                }
                destination[11] = (byte)(num4 + 20);
                destination[12] = (byte)(num3 + 60);
            }
            return(destination);
        }
예제 #2
0
        internal static OciDateTimeDescriptor CreateDescriptor(OCI.DATATYPE ociType, OracleConnection connection, object value)
        {
            byte[]       buffer;
            OCI.DATATYPE tIMESTAMP;
            if (value is OracleDateTime)
            {
                buffer = ((OracleDateTime)value)._value;
            }
            else
            {
                DateTime       dt    = (DateTime)value;
                OracleDateTime time2 = new OracleDateTime(dt);
                buffer = time2._value;
            }
            switch (ociType)
            {
            case OCI.DATATYPE.INT_TIMESTAMP:
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP;
                break;

            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP_LTZ;
                break;

            default:
            {
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP_TZ;
                TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                if (buffer.Length < 13)
                {
                    byte[] dst = new byte[13];
                    Buffer.BlockCopy(buffer, 0, dst, 0, buffer.Length);
                    buffer     = dst;
                    buffer[11] = (byte)(20 + serverTimeZoneAdjustmentToUTC.Hours);
                    buffer[12] = (byte)(60 + serverTimeZoneAdjustmentToUTC.Minutes);
                }
                break;
            }
            }
            OciDateTimeDescriptor datetime = CreateEmptyDescriptor(ociType, connection);
            OciIntervalDescriptor reftz    = new OciIntervalDescriptor(connection.EnvironmentHandle);
            int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, buffer, (uint)buffer.Length, (byte)tIMESTAMP, datetime, reftz, 9);

            if (rc != 0)
            {
                connection.CheckError(connection.ErrorHandle, rc);
            }
            return(datetime);
        }
예제 #3
0
        internal static byte[] GetBytesFromDescriptor(OciDateTimeDescriptor dateTimeDescriptor, MetaType metaType, OracleConnection connection)
        {
            uint num2;

            OCI.DATATYPE ociType   = metaType.OciType;
            OCI.DATATYPE datatype2 = ociType;
            if (datatype2 == OCI.DATATYPE.INT_TIMESTAMP)
            {
                num2 = 11;
            }
            else if (datatype2 == OCI.DATATYPE.INT_TIMESTAMP_LTZ)
            {
                num2 = 13;
            }
            else
            {
                num2 = 13;
            }
            byte[] outarray             = new byte[num2];
            uint   len                  = num2;
            OciIntervalDescriptor reftz = new OciIntervalDescriptor(connection.EnvironmentHandle);
            int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeToArray(connection.EnvironmentHandle, connection.ErrorHandle, dateTimeDescriptor, reftz, outarray, ref len, 9);

            if (rc != 0)
            {
                connection.CheckError(connection.ErrorHandle, rc);
            }
            if (OCI.DATATYPE.INT_TIMESTAMP_LTZ == ociType)
            {
                TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                outarray[11] = (byte)(serverTimeZoneAdjustmentToUTC.Hours + 20);
                outarray[12] = (byte)(serverTimeZoneAdjustmentToUTC.Minutes + 60);
                return(outarray);
            }
            if (OCI.DATATYPE.INT_TIMESTAMP_TZ == ociType)
            {
                sbyte num3;
                sbyte num4;
                rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeGetTimeZoneOffset(connection.EnvironmentHandle, connection.ErrorHandle, dateTimeDescriptor, out num4, out num3);
                if (rc != 0)
                {
                    connection.CheckError(connection.ErrorHandle, rc);
                }
                outarray[11] = (byte)(num4 + 20);
                outarray[12] = (byte)(num3 + 60);
            }
            return(outarray);
        }
        internal static OciDateTimeDescriptor CreateDescriptor(OCI.DATATYPE ociType, OracleConnection connection, object value)
        {
            byte[] buffer;
            OCI.DATATYPE tIMESTAMP;
            if (value is OracleDateTime)
            {
                buffer = ((OracleDateTime) value)._value;
            }
            else
            {
                DateTime dt = (DateTime) value;
                OracleDateTime time2 = new OracleDateTime(dt);
                buffer = time2._value;
            }
            switch (ociType)
            {
                case OCI.DATATYPE.INT_TIMESTAMP:
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP;
                    break;

                case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP_LTZ;
                    break;

                default:
                {
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP_TZ;
                    TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                    if (buffer.Length < 13)
                    {
                        byte[] dst = new byte[13];
                        Buffer.BlockCopy(buffer, 0, dst, 0, buffer.Length);
                        buffer = dst;
                        buffer[11] = (byte) (20 + serverTimeZoneAdjustmentToUTC.Hours);
                        buffer[12] = (byte) (60 + serverTimeZoneAdjustmentToUTC.Minutes);
                    }
                    break;
                }
            }
            OciDateTimeDescriptor datetime = CreateEmptyDescriptor(ociType, connection);
            OciIntervalDescriptor reftz = new OciIntervalDescriptor(connection.EnvironmentHandle);
            int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, buffer, (uint) buffer.Length, (byte) tIMESTAMP, datetime, reftz, 9);
            if (rc != 0)
            {
                connection.CheckError(connection.ErrorHandle, rc);
            }
            return datetime;
        }
 internal static byte[] GetBytesFromBuffer(NativeBuffer buffer, int valueOffset, int lengthOffset, MetaType metaType, OracleConnection connection)
 {
     uint num2;
     OCI.DATATYPE ociType = metaType.OciType;
     short length = buffer.ReadInt16(lengthOffset);
     OCI.DATATYPE datatype = ociType;
     if (datatype == OCI.DATATYPE.DATE)
     {
         num2 = 7;
     }
     else if (datatype == OCI.DATATYPE.INT_TIMESTAMP)
     {
         num2 = 11;
     }
     else if (datatype == OCI.DATATYPE.INT_TIMESTAMP_LTZ)
     {
         num2 = 13;
     }
     else
     {
         num2 = 13;
     }
     byte[] destination = new byte[num2];
     buffer.ReadBytes(valueOffset, destination, 0, length);
     if (OCI.DATATYPE.INT_TIMESTAMP_LTZ == ociType)
     {
         TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
         destination[11] = (byte) (serverTimeZoneAdjustmentToUTC.Hours + 20);
         destination[12] = (byte) (serverTimeZoneAdjustmentToUTC.Minutes + 60);
         return destination;
     }
     if ((OCI.DATATYPE.INT_TIMESTAMP_TZ == ociType) && (0x80 < destination[11]))
     {
         sbyte num3;
         sbyte num4;
         OciIntervalDescriptor reftz = new OciIntervalDescriptor(connection.EnvironmentHandle);
         OciDateTimeDescriptor datetime = new OciDateTimeDescriptor(connection.EnvironmentHandle, OCI.HTYPE.OCI_DTYPE_TIMESTAMP_TZ);
         int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, destination, num2, 0xbc, datetime, reftz, 0);
         if (rc != 0)
         {
             connection.CheckError(connection.ErrorHandle, rc);
         }
         rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeGetTimeZoneOffset(connection.EnvironmentHandle, connection.ErrorHandle, datetime, out num4, out num3);
         if (rc != 0)
         {
             connection.CheckError(connection.ErrorHandle, rc);
         }
         destination[11] = (byte) (num4 + 20);
         destination[12] = (byte) (num3 + 60);
     }
     return destination;
 }
 internal static byte[] GetBytesFromDescriptor(OciDateTimeDescriptor dateTimeDescriptor, MetaType metaType, OracleConnection connection)
 {
     uint num2;
     OCI.DATATYPE ociType = metaType.OciType;
     OCI.DATATYPE datatype2 = ociType;
     if (datatype2 == OCI.DATATYPE.INT_TIMESTAMP)
     {
         num2 = 11;
     }
     else if (datatype2 == OCI.DATATYPE.INT_TIMESTAMP_LTZ)
     {
         num2 = 13;
     }
     else
     {
         num2 = 13;
     }
     byte[] outarray = new byte[num2];
     uint len = num2;
     OciIntervalDescriptor reftz = new OciIntervalDescriptor(connection.EnvironmentHandle);
     int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeToArray(connection.EnvironmentHandle, connection.ErrorHandle, dateTimeDescriptor, reftz, outarray, ref len, 9);
     if (rc != 0)
     {
         connection.CheckError(connection.ErrorHandle, rc);
     }
     if (OCI.DATATYPE.INT_TIMESTAMP_LTZ == ociType)
     {
         TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
         outarray[11] = (byte) (serverTimeZoneAdjustmentToUTC.Hours + 20);
         outarray[12] = (byte) (serverTimeZoneAdjustmentToUTC.Minutes + 60);
         return outarray;
     }
     if (OCI.DATATYPE.INT_TIMESTAMP_TZ == ociType)
     {
         sbyte num3;
         sbyte num4;
         rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeGetTimeZoneOffset(connection.EnvironmentHandle, connection.ErrorHandle, dateTimeDescriptor, out num4, out num3);
         if (rc != 0)
         {
             connection.CheckError(connection.ErrorHandle, rc);
         }
         outarray[11] = (byte) (num4 + 20);
         outarray[12] = (byte) (num3 + 60);
     }
     return outarray;
 }