namespace Microsoft.Adapters.SAP { static class SapDataTypesBehaviorDefaultValues { public const string DatsMinToDateTime = SapDataTypesBehavior.ERROR; public const string DatsMaxToDateTime = SapDataTypesBehavior.ERROR; public const string InvalidDatsToDateTime = SapDataTypesBehavior.ERROR; public const string EmptyDatsToDateTime = "0001-01-01T00:00:00"; public const string DateTimeMaxToDats = "99991231"; public const string DateTimeMinToDats = "00010101"; public const string TimsMaxToDateTime = SapDataTypesBehavior.ERROR; public const string InvalidTimsToDateTime = SapDataTypesBehavior.ERROR; public const string DateTimeMaxToTims = "235959"; public const string DateTimeMinToTims = "000000"; public const string InvalidNumcToInt = "0"; public const string DateTimeNullToDats = SapDataTypesBehavior.SKIP; public const string DateTimeNullToTims = SapDataTypesBehavior.SKIP; } static class SapDataTypesBehaviorConfig { public const string DatsMinToDateTime = "datsMinToDateTime"; public const string DatsMaxToDateTime = "datsMaxToDateTime"; public const string InvalidDatsToDateTime = "invalidDatsToDateTime"; public const string EmptyDatsToDateTime = "emptyDatsToDateTime"; public const string DateTimeMaxToDats = "dateTimeMaxToDats"; public const string DateTimeMinToDats = "dateTimeMinToDats"; public const string TimsMaxToDateTime = "timsMaxToDateTime"; public const string InvalidTimsToDateTime = "invalidTimsToDateTime"; public const string DateTimeMaxToTims = "dateTimeMaxToTims"; public const string DateTimeMinToTims = "dateTimeMinToTims"; public const string InvalidNumcToInt = "invalidNumcToInt"; public const string DateTimeNullToDats = "dateTimeNullToDats"; public const string DateTimeNullToTims = "dateTimeNullToTims"; } /// /// This class is used to control the behavior of the adapter when /// dealing with special values for the DATS, TIMS and NUMC data types. /// public sealed class SapDataTypesBehavior { internal const string ERROR = "ERROR"; internal const string NULL = "NULL"; internal const string SKIP = "SKIP"; #region Properties /// /// The behavior to follow when SAP sends a DATS.MIN value /// (i.e., 00000000). /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "ERROR". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DatsMinToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.DatsMinToDateTime)] public string DatsMinToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.DatsMinToDateTime]; } set { base[SapDataTypesBehaviorConfig.DatsMinToDateTime] = value; } } /// /// The behavior to follow when SAP sends a DATS.MAX value /// (i.e., 99999999). /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "ERROR". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DatsMaxToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.DatsMaxToDateTime)] public string DatsMaxToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.DatsMaxToDateTime]; } set { base[SapDataTypesBehaviorConfig.DatsMaxToDateTime] = value; } } /// /// The behavior to follow when SAP sends an /// invalid DATS value. /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "ERROR". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.InvalidDatsToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.InvalidDatsToDateTime)] public string InvalidDatsToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.InvalidDatsToDateTime]; } set { base[SapDataTypesBehaviorConfig.InvalidDatsToDateTime] = value; } } /// /// The behavior to follow when SAP sends an /// empty DATS value (all characters are spaces). /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "0001-01-01T00:00:00". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.EmptyDatsToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.EmptyDatsToDateTime)] public string EmptyDatsToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.EmptyDatsToDateTime]; } set { base[SapDataTypesBehaviorConfig.EmptyDatsToDateTime] = value; } } /// /// The behavior to follow for DATS /// when the user sends DateTime.MAX (i.e., "9999-12-31T23:59:59.9999999") /// "ERROR" ==> Adapter throws an exception. /// Else, the value specified here is sent to SAP. /// Default is "99991231" /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeMaxToDats, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeMaxToDats)] public string DateTimeMaxToDats { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeMaxToDats]; } set { base[SapDataTypesBehaviorConfig.DateTimeMaxToDats] = value; } } /// /// The behavior to follow for DATS /// when the user sends DateTime.MIN (i.e., "0001-01-01T00:00:00") /// "ERROR" ==> Adapter throws an exception. /// Else, the value specified here is sent to SAP. /// Default is "00010101" /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeMinToDats, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeMinToDats)] public string DateTimeMinToDats { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeMinToDats]; } set { base[SapDataTypesBehaviorConfig.DateTimeMinToDats] = value; } } /// /// The behavior to follow when SAP sends a TIMS.MAX value /// (i.e., 999999). /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "ERROR". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.TimsMaxToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.TimsMaxToDateTime)] public string TimsMaxToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.TimsMaxToDateTime]; } set { base[SapDataTypesBehaviorConfig.TimsMaxToDateTime] = value; } } /// /// The behavior to follow when SAP sends an /// invalid TIMS value. /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is parsed in /// XSD:DateTime format, and the corresponding /// DateTime value is given to the client. /// Default is "ERROR". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.InvalidTimsToDateTime, DefaultValue = SapDataTypesBehaviorDefaultValues.InvalidTimsToDateTime)] public string InvalidTimsToDateTime { get { return (string)base[SapDataTypesBehaviorConfig.InvalidTimsToDateTime]; } set { base[SapDataTypesBehaviorConfig.InvalidTimsToDateTime] = value; } } /// /// The behavior to follow for TIMS /// when the user sends DateTime.MAX (i.e., "9999-12-31T23:59:59.9999999") /// "ERROR" ==> Adapter throws an exception. /// Else, the value specified here is sent to SAP. /// Default is "235959" /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeMaxToTims, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeMaxToTims)] public string DateTimeMaxToTims { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeMaxToTims]; } set { base[SapDataTypesBehaviorConfig.DateTimeMaxToTims] = value; } } /// /// The behavior to follow for TIMS /// when the user sends DateTime.MIN (i.e., "0001-01-01T00:00:00") /// "ERROR" ==> Adapter throws an exception. /// Else, the value specified here is sent to SAP. /// Default is "000000" /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeMinToTims, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeMinToTims)] public string DateTimeMinToTims { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeMinToTims]; } set { base[SapDataTypesBehaviorConfig.DateTimeMinToTims] = value; } } /// /// The behavior to follow when SAP sends an /// invalid NUMC value. /// "ERROR" ==> Adapter throws an exception. /// "NULL" ==> Adapter returns null. /// Else, the value specified here is assumed to /// be a valid Int32/Int64, and that is /// given to the client. /// Default is "0" /// [ConfigurationProperty(SapDataTypesBehaviorConfig.InvalidNumcToInt, DefaultValue = SapDataTypesBehaviorDefaultValues.InvalidNumcToInt)] public string InvalidNumcToInt { get { return (string)base[SapDataTypesBehaviorConfig.InvalidNumcToInt]; } set { base[SapDataTypesBehaviorConfig.InvalidNumcToInt] = value; } } /// /// The behavior to follow if a NULL DateTime value is seen in the XML. /// "ERROR" ==> Adapter throws an exception. /// "SKIP" ==> The value is skipped /// Else, the value specified here is sent to SAP /// Default is "SKIP". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeNullToDats, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeNullToDats)] public string DateTimeNullToDats { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeNullToDats]; } set { base[SapDataTypesBehaviorConfig.DateTimeNullToDats] = value; } } /// /// The behavior to follow if a NULL DateTime value is seen in the XML. /// "ERROR" ==> Adapter throws an exception. /// "SKIP" ==> The value is skipped /// Else, the value specified here is sent to SAP /// Default is "SKIP". /// [ConfigurationProperty(SapDataTypesBehaviorConfig.DateTimeNullToTims, DefaultValue = SapDataTypesBehaviorDefaultValues.DateTimeNullToTims)] public string DateTimeNullToTims { get { return (string)base[SapDataTypesBehaviorConfig.DateTimeNullToTims]; } set { base[SapDataTypesBehaviorConfig.DateTimeNullToTims] = value; } } #endregion } }