Exemplo n.º 1
0
        private void SetIndeterminate()
        {
            AggregatedValuesAvailable = false;
            LimitValuesAvailable      = false;

            _oracleNumberSum      = OracleDecimal.Zero;
            _oracleYearToMonthSum = OracleIntervalYM.Zero;
            _oracleDayToSecondSum = OracleIntervalDS.Zero;
            _typeValues.Clear();
            _isIndeterminate = true;
        }
Exemplo n.º 2
0
 private void TableDependency_Changed(object sender, RecordChangedEventArgs <DataTimeModel> e)
 {
     switch (e.ChangeType)
     {
     case ChangeType.Insert:
         dateColumReturned                  = e.Entity.DateColum;
         timeStampColumnReturned            = new OracleTimeStamp(e.Entity.TimeStampColumn);
         timeStampWithTimeZoneReturned      = e.Entity.TimeStampWithTimeZone;
         timeStampWithLocalTimeZoneReturned = new OracleTimeStampLTZ(e.Entity.TimeStampWithLocalTimeZone);
         intervalDayToSecondColumnReturned  = new OracleIntervalDS(e.Entity.IntervalDayToSecondColumn);
         intervalYearToMonthColumnReturned  = new OracleIntervalYM(e.Entity.IntervalYearToMonthColumn);
         break;
     }
 }
Exemplo n.º 3
0
        public static void ClassInitialize(TestContext testContext)
        {
            OracleHelper.DropTable(ConnectionString, TableName);

            using (var connection = new OracleConnection(ConnectionString))
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = $"CREATE TABLE {TableName}(DATECOLUM DATE,TIMESTAMPCOLUMN TIMESTAMP(6),TIMESTAMPWITHTIMEZONE TIMESTAMP WITH TIME ZONE,TIMESTAMPWITHLOCALTIMEZONE TIMESTAMP WITH LOCAL TIME ZONE, INTERVALDAYTOSECONDCOLUMN INTERVAL DAY(2) TO SECOND(6),INTERVALYEARTOMONTHCOLUMN INTERVAL YEAR(2) TO MONTH)";
                    command.ExecuteNonQuery();
                }
            }

            dateColum                  = DateTime.Now;
            timeStampColumn            = new OracleTimeStamp(DateTime.Now);
            timeStampWithLocalTimeZone = OracleTimeStampLTZ.GetSysDate();
            timeStampWithTimeZone      = DateTimeOffset.Now;
            intervalDayToSecondColumn  = new OracleIntervalDS(1);
            intervalYearToMonthColumn  = new OracleIntervalYM(2);
        }
Exemplo n.º 4
0
        private object GetValue(OracleDecimal number, OracleDate date, OracleTimeStamp timestamp, OracleTimeStampTZ timestampWithTimezone, OracleTimeStampLTZ timestampWithLocalTimeZone, OracleIntervalYM yearToMonth, OracleIntervalDS dayToSecond)
        {
            if (!LimitValuesAvailable)
            {
                return(null);
            }

            if (_valueType == typeof(OracleDecimal))
            {
                return(number.IsNull ? null : new OracleNumber(number));
            }

            if (_valueType == typeof(OracleDate))
            {
                return(date.IsNull ? null : new OracleDateTime(date));
            }

            if (_valueType == typeof(OracleTimeStamp))
            {
                return(timestamp.IsNull ? null : new OracleTimestamp(timestamp));
            }

            if (_valueType == typeof(OracleTimeStampTZ))
            {
                return(timestampWithTimezone.IsNull ? null : new OracleTimestampWithTimeZone(timestampWithTimezone));
            }

            if (_valueType == typeof(OracleTimeStampLTZ))
            {
                return(timestampWithLocalTimeZone.IsNull ? null : new OracleTimestampWithLocalTimeZone(timestampWithLocalTimeZone));
            }

            if (_valueType == typeof(OracleIntervalYM))
            {
                return(yearToMonth.IsNull ? null : new OracleIntervalYearToMonth(yearToMonth));
            }

            if (_valueType == typeof(OracleIntervalDS))
            {
                return(dayToSecond.IsNull ? null : new OracleIntervalDayToSecond(dayToSecond));
            }

            return(null);
        }
Exemplo n.º 5
0
        public void AddValue(object value)
        {
            if (value == null || value == DBNull.Value)
            {
                return;
            }

            if (value is IValue oracleValue && oracleValue.IsNull)
            {
                return;
            }

            Type valueType;

            var oracleNumber = value as OracleNumber;

            if (value is int || value is long || value is decimal || value is short || value is uint || value is ulong || value is ushort)
            {
                value = oracleNumber = new OracleNumber(new OracleDecimal(Convert.ToDecimal(value)));
            }

            var oracleDate = value as OracleDateTime;

            if (value is DateTime)
            {
                value = oracleDate = new OracleDateTime(new OracleDate(Convert.ToDateTime(value)));
            }

            Count++;

            _distinctValues.Add(value);

            var oracleTimestamp              = value as OracleTimestamp;
            var oracleTimestampTimezone      = value as OracleTimestampWithTimeZone;
            var oracleTimestampLocalTimezone = value as OracleTimestampWithLocalTimeZone;
            var oracleIntervalYearToMonth    = value as OracleIntervalYearToMonth;
            var oracleIntervalDayToSecond    = value as OracleIntervalDayToSecond;

            if (oracleNumber != null)
            {
                valueType = typeof(OracleDecimal);
                var typedValue = (OracleDecimal)oracleNumber.RawValue;
                _oracleNumberSum += typedValue;
            }
            else if (oracleDate != null)
            {
                valueType = typeof(OracleDate);
                AggregatedValuesAvailable = false;
            }
            else if (oracleTimestamp != null)
            {
                valueType = typeof(OracleTimeStamp);
                AggregatedValuesAvailable = false;
            }
            else if (oracleTimestampTimezone != null)
            {
                valueType = typeof(OracleTimeStampTZ);
                AggregatedValuesAvailable = false;
            }
            else if (oracleTimestampLocalTimezone != null)
            {
                valueType = typeof(OracleTimeStampLTZ);
                AggregatedValuesAvailable = false;
            }
            else if (oracleIntervalYearToMonth != null)
            {
                valueType = typeof(OracleIntervalYM);
                var typedValue = (OracleIntervalYM)oracleIntervalYearToMonth.RawValue;
                _oracleYearToMonthSum += typedValue;
            }
            else if (oracleIntervalDayToSecond != null)
            {
                valueType = typeof(OracleIntervalDS);
                var typedValue = (OracleIntervalDS)oracleIntervalDayToSecond.RawValue;
                _oracleDayToSecondSum += typedValue;
            }
            else
            {
                valueType = typeof(object);
                AggregatedValuesAvailable = false;
                LimitValuesAvailable      = false;
            }

            if (LimitValuesAvailable)
            {
                _typeValues.Add(Tuple.Create(valueType, value));
            }

            if (_valueType == null)
            {
                _valueType = valueType;
            }
            else if (_valueType != valueType)
            {
                SetIndeterminate();
            }
        }
Exemplo n.º 6
0
 public OracleIntervalDayToSecond(OracleIntervalDS intervalDayToSecond)
 {
     _value = intervalDayToSecond;
     IsNull = intervalDayToSecond.IsNull;
 }
Exemplo n.º 7
0
		private void SetIndeterminate()
		{
			AggregatedValuesAvailable = false;
			LimitValuesAvailable = false;

			_oracleNumberSum = OracleDecimal.Zero;
			_oracleYearToMonthSum = OracleIntervalYM.Zero;
			_oracleDayToSecondSum = OracleIntervalDS.Zero;
			_typeValues.Clear();
			_isIndeterminate = true;
		}
Exemplo n.º 8
0
		private object GetValue(OracleDecimal number, OracleDate date, OracleTimeStamp timestamp, OracleTimeStampTZ timestampWithTimezone, OracleTimeStampLTZ timestampWithLocalTimeZone, OracleIntervalYM yearToMonth, OracleIntervalDS dayToSecond)
		{
			if (!LimitValuesAvailable)
			{
				return null;
			}

			if (_valueType == typeof(OracleDecimal))
			{
				return number.IsNull ? null : new OracleNumber(number);
			}

			if (_valueType == typeof(OracleDate))
			{
				return date.IsNull ? null : new OracleDateTime(date);
			}

			if (_valueType == typeof(OracleTimeStamp))
			{
				return timestamp.IsNull ? null : new OracleTimestamp(timestamp);
			}

			if (_valueType == typeof(OracleTimeStampTZ))
			{
				return timestampWithTimezone.IsNull ? null : new OracleTimestampWithTimeZone(timestampWithTimezone);
			}

			if (_valueType == typeof(OracleTimeStampLTZ))
			{
				return timestampWithLocalTimeZone.IsNull ? null : new OracleTimestampWithLocalTimeZone(timestampWithLocalTimeZone);
			}

			if (_valueType == typeof(OracleIntervalYM))
			{
				return yearToMonth.IsNull ? null : new OracleIntervalYearToMonth(yearToMonth);
			}

			if (_valueType == typeof(OracleIntervalDS))
			{
				return dayToSecond.IsNull ? null : new OracleIntervalDayToSecond(dayToSecond);
			}

			return null;
		}
Exemplo n.º 9
0
		public void AddValue(object value)
		{
			if (value == null || value == DBNull.Value)
			{
				return;
			}

			var oracleValue = value as IValue;
			if (oracleValue != null && oracleValue.IsNull)
			{
				return;
			}

			Type valueType;

			var oracleNumber = value as OracleNumber;
			if (value is int || value is long || value is decimal || value is short || value is uint || value is ulong || value is ushort)
			{
				value = oracleNumber = new OracleNumber(new OracleDecimal(Convert.ToDecimal(value)));
			}

			var oracleDate = value as OracleDateTime;
			if (value is DateTime)
			{
				value = oracleDate = new OracleDateTime(new OracleDate(Convert.ToDateTime(value)));
			}

			Count++;

			_distinctValues.Add(value);

			var oracleTimestamp = value as OracleTimestamp;
			var oracleTimestampTimezone = value as OracleTimestampWithTimeZone;
			var oracleTimestampLocalTimezone = value as OracleTimestampWithLocalTimeZone;
			var oracleIntervalYearToMonth = value as OracleIntervalYearToMonth;
			var oracleIntervalDayToSecond = value as OracleIntervalDayToSecond;
			if (oracleNumber != null)
			{
				valueType = typeof(OracleDecimal);
				var typedValue = (OracleDecimal)oracleNumber.RawValue;
				_oracleNumberSum += typedValue;
			}
			else if (oracleDate != null)
			{
				valueType = typeof(OracleDate);
				AggregatedValuesAvailable = false;
			}
			else if (oracleTimestamp != null)
			{
				valueType = typeof(OracleTimeStamp);
				AggregatedValuesAvailable = false;
			}
			else if (oracleTimestampTimezone != null)
			{
				valueType = typeof(OracleTimeStampTZ);
				AggregatedValuesAvailable = false;
			}
			else if (oracleTimestampLocalTimezone != null)
			{
				valueType = typeof(OracleTimeStampLTZ);
				AggregatedValuesAvailable = false;
			}
			else if (oracleIntervalYearToMonth != null)
			{
				valueType = typeof(OracleIntervalYM);
				var typedValue = (OracleIntervalYM)oracleIntervalYearToMonth.RawValue;
				_oracleYearToMonthSum += typedValue;
			}
			else if (oracleIntervalDayToSecond != null)
			{
				valueType = typeof(OracleIntervalDS);
				var typedValue = (OracleIntervalDS)oracleIntervalDayToSecond.RawValue;
				_oracleDayToSecondSum += typedValue;
			}
			else
			{
				valueType = typeof(object);
				AggregatedValuesAvailable = false;
				LimitValuesAvailable = false;
			}

			if (LimitValuesAvailable)
			{
				_typeValues.Add(Tuple.Create(valueType, value));
			}

			if (_valueType == null)
			{
				_valueType = valueType;
			}
			else if (_valueType != valueType)
			{
				SetIndeterminate();
			}
		}