示例#1
0
        public static DecimalField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetString(
                dataHandle: dataHandle,
                name: name,
                stringBuffer: Array.Empty <char>(),
                bufferLength: 0,
                stringLength: out uint stringLength,
                errorInfo: out RfcErrorInfo errorInfo);

            if (resultCode != RfcResultCodes.RFC_BUFFER_TOO_SMALL)
            {
                resultCode.ThrowOnError(errorInfo);
                return(new DecimalField(name, 0));
            }

            var buffer = new char[stringLength + 1];

            resultCode = interop.GetString(
                dataHandle: dataHandle,
                name: name,
                stringBuffer: buffer,
                bufferLength: (uint)buffer.Length,
                stringLength: out _,
                errorInfo: out errorInfo);

            resultCode.ThrowOnError(errorInfo);

            var decimalValue = decimal.Parse(new string(buffer, 0, (int)stringLength), CultureInfo.InvariantCulture);

            return(new DecimalField(name, decimalValue));
        }
示例#2
0
        public static StringField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetString(
                dataHandle: dataHandle,
                name: name,
                stringBuffer: Array.Empty <char>(),
                bufferLength: 0,
                stringLength: out uint stringLength,
                errorInfo: out RfcErrorInfo errorInfo);

            if (resultCode != RfcResultCodes.RFC_BUFFER_TOO_SMALL)
            {
                resultCode.ThrowOnError(errorInfo);
                return(new StringField(name, string.Empty));
            }

            var buffer = new char[stringLength + 1];

            resultCode = interop.GetString(
                dataHandle: dataHandle,
                name: name,
                stringBuffer: buffer,
                bufferLength: (uint)buffer.Length,
                stringLength: out _,
                errorInfo: out errorInfo);

            resultCode.ThrowOnError(errorInfo);

            return(new StringField(name, new string(buffer, 0, (int)stringLength)));
        }
示例#3
0
        public static DateField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            char[] buffer = EmptyRfcDateString.ToCharArray();

            RfcResultCodes resultCode = interop.GetDate(
                dataHandle: dataHandle,
                name: name,
                emptyDate: buffer,
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            string dateString = new string(buffer);

            if (dateString == EmptyRfcDateString || dateString == ZeroRfcDateString)
            {
                return(new DateField(name, null));
            }

            Match match = Regex.Match(dateString, "^(?<Year>[0-9]{4})(?<Month>[0-9]{2})(?<Day>[0-9]{2})$");

            if (!match.Success)
            {
                return(new DateField(name, null));
            }

            int year  = int.Parse(match.Groups["Year"].Value);
            int month = int.Parse(match.Groups["Month"].Value);
            int day   = int.Parse(match.Groups["Day"].Value);

            return(new DateField(name, new DateTime(year, month, day)));
        }
示例#4
0
        public static TimeField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            char[] buffer = EmptyRfcTimeString.ToCharArray();

            RfcResultCodes resultCode = interop.GetTime(
                dataHandle: dataHandle,
                name: name,
                emptyTime: buffer,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            var timeString = new string(buffer);

            if (timeString == EmptyRfcTimeString || timeString == ZeroRfcTimeString)
            {
                return(new TimeField(name, null));
            }

            Match match = Regex.Match(timeString, "^(?<Hours>[0-9]{2})(?<Minutes>[0-9]{2})(?<Seconds>[0-9]{2})$");

            if (!match.Success)
            {
                return(new TimeField(name, null));
            }

            int hours   = int.Parse(match.Groups["Hours"].Value);
            int minutes = int.Parse(match.Groups["Minutes"].Value);
            int seconds = int.Parse(match.Groups["Seconds"].Value);

            return(new TimeField(name, new TimeSpan(hours, minutes, seconds)));
        }
示例#5
0
        public static TOutput Extract <TOutput>(IRfcInterop interop, IntPtr dataHandle)
        {
            Type outputType = typeof(TOutput);
            Func <IRfcInterop, IntPtr, object> extractFunc = ExtractFuncsCache.GetOrAdd(outputType, BuildExtractFunc);

            return((TOutput)extractFunc(interop, dataHandle));
        }
示例#6
0
        private IRfcFunction CreateFromDescriptionHandle(IRfcInterop interop, IntPtr functionDescriptionHandle)
        {
            IntPtr functionHandle = interop.CreateFunction(functionDescriptionHandle, out RfcErrorInfo errorInfo);

            errorInfo.ThrowOnError();

            return(new RfcFunction(interop, _rfcConnectionHandle, functionHandle));
        }
示例#7
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            RfcResultCodes resultCode = interop.SetDate(
                dataHandle: dataHandle,
                name: Name,
                date: (Value?.ToString("yyyyMMdd") ?? ZeroRfcDateString).ToCharArray(),
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
        }
示例#8
0
        private IntPtr GetTransactionHandle(IRfcInterop interop)
        {
            RfcResultCodes resultCode = _interop.GetTransactionId(_rfcConnectionHandle, out var tid, out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
            IntPtr result = _interop.CreateTransaction(_rfcConnectionHandle, tid, null, out errorInfo);

            errorInfo.ThrowOnError();
            return(result);
        }
示例#9
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            RfcResultCodes resultCode = interop.SetFloat(
                dataHandle: dataHandle,
                name: Name,
                value: Value,
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
        }
示例#10
0
        public static void Apply(IRfcInterop interop, IntPtr dataHandle, object input)
        {
            if (input == null)
            {
                return;
            }

            Type inputType = input.GetType();
            Action <IRfcInterop, IntPtr, object> applyAction = ApplyActionsCache.GetOrAdd(inputType, BuildApplyAction);

            applyAction(interop, dataHandle, input);
        }
示例#11
0
        public static LongField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetInt8(
                dataHandle: dataHandle,
                name: name,
                out long value,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            return(new LongField(name, value));
        }
示例#12
0
        public static DoubleField Extract(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetFloat(
                dataHandle: dataHandle,
                name: name,
                out double value,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            return(new DoubleField(name, value));
        }
示例#13
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            RfcResultCodes resultCode = interop.GetStructure(
                dataHandle: dataHandle,
                name: Name,
                structHandle: out IntPtr structHandle,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            InputMapper.Apply(interop, structHandle, Value);
        }
示例#14
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            string stringValue = Value?.ToString("hhmmss") ?? ZeroRfcTimeString;

            RfcResultCodes resultCode = interop.SetTime(
                dataHandle: dataHandle,
                name: Name,
                time: stringValue.ToCharArray(),
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
        }
示例#15
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            var stringValue = Value.ToString(CultureInfo.InvariantCulture);

            RfcResultCodes resultCode = interop.SetString(
                dataHandle: dataHandle,
                name: Name,
                value: stringValue,
                valueLength: (uint)stringValue.Length,
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
        }
示例#16
0
        public static StructureField <T> Extract <T>(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetStructure(
                dataHandle: dataHandle,
                name: name,
                structHandle: out IntPtr structHandle,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            T structValue = OutputMapper.Extract <T>(interop, structHandle);

            return(new StructureField <T>(name, structValue));
        }
示例#17
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            if (Value == null)
            {
                return;
            }

            RfcResultCodes resultCode = interop.SetString(
                dataHandle: dataHandle,
                name: Name,
                value: Value,
                valueLength: (uint)Value.Length,
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);
        }
示例#18
0
        public static TableField <T> Extract <T>(IRfcInterop interop, IntPtr dataHandle, string name)
        {
            RfcResultCodes resultCode = interop.GetTable(
                dataHandle: dataHandle,
                name: name,
                tableHandle: out IntPtr tableHandle,
                errorInfo: out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            resultCode = interop.GetRowCount(
                tableHandle: tableHandle,
                out uint rowCount,
                out errorInfo);

            resultCode.ThrowOnError(errorInfo);

            var rows = new T[rowCount];

            for (int i = 0; i < rowCount; i++)
            {
                IntPtr rowHandle = interop.GetCurrentRow(
                    tableHandle: tableHandle,
                    errorInfo: out errorInfo);

                errorInfo.ThrowOnError();

                rows[i] = OutputMapper.Extract <T>(interop, rowHandle);

                resultCode = interop.MoveToNextRow(
                    tableHandle: tableHandle,
                    errorInfo: out errorInfo);

                if (resultCode == RfcResultCodes.RFC_TABLE_MOVE_EOF)
                {
                    return(new TableField <T>(name, rows.Take(i + 1).ToArray()));
                }

                resultCode.ThrowOnError(errorInfo);
            }

            return(new TableField <T>(name, rows));
        }
示例#19
0
        public override void Apply(IRfcInterop interop, IntPtr dataHandle)
        {
            RfcResultCodes resultCode = interop.GetTable(
                dataHandle: dataHandle,
                name: Name,
                out IntPtr tableHandle,
                out RfcErrorInfo errorInfo);

            resultCode.ThrowOnError(errorInfo);

            if (Value == null)
            {
                return;
            }

            foreach (TItem row in Value)
            {
                IntPtr lineHandle = interop.AppendNewRow(tableHandle, out errorInfo);
                errorInfo.ThrowOnError();
                InputMapper.Apply(interop, lineHandle, row);
            }
        }
示例#20
0
 public ReadBapi(IRfcInterop interop) : base(interop)
 {
 }
示例#21
0
 public RfcTransactionFunction(IRfcInterop interop, IntPtr transactionHandle, IntPtr functionHandle)
 {
     _interop           = interop;
     _transactionHandle = transactionHandle;
     _functionHandle    = functionHandle;
 }
示例#22
0
 public override void Apply(IRfcInterop interop, IntPtr dataHandle)
 {
     throw new NotImplementedException();
 }
示例#23
0
 public RfcFunction(IRfcInterop interop, IntPtr rfcConnectionHandle, IntPtr functionHandle)
 {
     _interop             = interop;
     _rfcConnectionHandle = rfcConnectionHandle;
     _functionHandle      = functionHandle;
 }
示例#24
0
 public RfcLibrary(IRfcInterop interop)
 {
     _interop = interop;
 }
示例#25
0
 public ReadTable(IPropertyCache cache, IRfcInterop interop) : base(interop)
 {
     _cache = cache;
 }
示例#26
0
 protected RfcConnectionBase(IRfcInterop interop, RfcConnectionOption options)
 {
     _interop = interop;
     _options = options;
 }
示例#27
0
 public abstract void Apply(IRfcInterop interop, IntPtr dataHandle);
示例#28
0
 public RfcConnection(IRfcInterop interop, string connectionString) : base(interop, new RfcConnectionOption().Parse(connectionString))
 {
 }
示例#29
0
 public RfcConnection(IRfcInterop interop, RfcConnectionOption options) : base(interop, options)
 {
 }
示例#30
0
 public RfcConnection(IRfcInterop interop, IOptionsSnapshot <RfcConnectionOption> options) : base(interop, options.Value)
 {
 }