public static Pain00100103CtData Create(libfintx.pain_001_001_03.Document xml) { var result = new Pain00100103CtData(); result.Initiator = xml.CstmrCdtTrfInitn?.GrpHdr?.InitgPty?.Nm; result.NumberOfTransactions = Convert.ToInt32(xml.CstmrCdtTrfInitn?.GrpHdr?.NbOfTxs); result.ControlSum = xml.CstmrCdtTrfInitn?.GrpHdr?.CtrlSum; foreach (var pmtInf in xml.CstmrCdtTrfInitn.PmtInf) { if (result.Payments == null) { result.Payments = new List <PaymentInfo>(); } var paymentInfo = new PaymentInfo(); paymentInfo.RequestedExecutionDate = pmtInf.ReqdExctnDt; paymentInfo.Debtor = pmtInf.Dbtr?.Nm; paymentInfo.DebtorAccount = pmtInf.DbtrAcct?.Id?.Item?.ToString(); paymentInfo.DebtorAgent = pmtInf.DbtrAgt?.FinInstnId?.BIC; result.Payments.Add(paymentInfo); foreach (var cdtTrfTxInf in pmtInf.CdtTrfTxInf) { if (paymentInfo.CreditTxInfos == null) { paymentInfo.CreditTxInfos = new List <CreditTransferTransactionInfo>(); } var creditTxInfo = new CreditTransferTransactionInfo(); creditTxInfo.Amount = ((libfintx.pain_001_001_03.ActiveOrHistoricCurrencyAndAmount)cdtTrfTxInf.Amt?.Item).Value; creditTxInfo.Creditor = cdtTrfTxInf.Cdtr?.Nm; creditTxInfo.CreditorAccount = cdtTrfTxInf.CdtrAcct?.Id?.Item?.ToString(); creditTxInfo.CreditorAgent = cdtTrfTxInf.CdtrAgt?.FinInstnId?.BIC; if (cdtTrfTxInf.RmtInf?.Ustrd != null) { creditTxInfo.RemittanceInformation = string.Join(", ", cdtTrfTxInf.RmtInf?.Ustrd); } paymentInfo.CreditTxInfos.Add(creditTxInfo); } } return(result); }
/// <summary> /// Get terminated transfers /// </summary> /// <returns> /// Banker's orders /// </returns> public async Task <HBCIDialogResult <List <TerminatedTransfer> > > GetTerminatedTransfers(TANDialog tanDialog) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } // Success string BankCode = await Transaction.HKCSB(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } BankCode = result.RawData; int startIdx = BankCode.IndexOf("HICSB"); if (startIdx < 0) { return(result.TypedResult <List <TerminatedTransfer> >()); } var data = new List <TerminatedTransfer>(); string BankCode_ = BankCode.Substring(startIdx); for (; ;) { var match = Regex.Match(BankCode_, @"HICSB.+?(?<xml><\?xml.+?</Document>)\+(?<orderid>.*?)(\+(?<deleteable>j|n))?(\+(?<modifiable>j|n))?'", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (match.Success) { string xml = match.Groups["xml"].Value; // xml ist UTF-8 xml = Converter.ConvertEncoding(xml, Encoding.GetEncoding("ISO-8859-1"), Encoding.UTF8); string orderId = match.Groups["orderid"].Value; bool? deleteable = null; if (match.Groups["deleteable"].Success) { deleteable = match.Groups["deleteable"].Value.Equals("j", StringComparison.OrdinalIgnoreCase) ? true : false; } bool?modifiable = null; if (match.Groups["modifiable"].Success) { modifiable = match.Groups["modifiable"].Value.Equals("j", StringComparison.OrdinalIgnoreCase) ? true : false; } var painData = Pain00100103CtData.Create(xml); var item = new TerminatedTransfer(orderId, deleteable, modifiable, painData); data.Add(item); } int endIdx = BankCode_.IndexOf("'"); if (BankCode_.Length <= endIdx + 1) { break; } BankCode_ = BankCode_.Substring(endIdx + 1); startIdx = BankCode_.IndexOf("HICSB"); if (startIdx < 0) { break; } } // Success return(result.TypedResult(data)); }
/// <summary> /// Get banker's orders /// </summary> /// <param name="tanDialog">The TAN dialog</param> /// <returns> /// Banker's orders /// </returns> public async Task <HBCIDialogResult <List <BankersOrder> > > GetBankersOrders(TANDialog tanDialog) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } // Success string BankCode = await Transaction.HKCDB(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } BankCode = result.RawData; int startIdx = BankCode.IndexOf("HICDB"); if (startIdx < 0) { return(result.TypedResult <List <BankersOrder> >()); } var data = new List <BankersOrder>(); string BankCode_ = BankCode.Substring(startIdx); for (; ;) { var match = Regex.Match(BankCode_, @"HICDB.+?(?<xml><\?xml.+?</Document>)\+(?<orderid>.*?)\+(?<firstdate>\d*):(?<turnus>[MW]):(?<rota>\d+):(?<execday>\d+)(:(?<lastdate>\d+))?", RegexOptions.Singleline); if (match.Success) { string xml = match.Groups["xml"].Value; // xml ist UTF-8 xml = Converter.ConvertEncoding(xml, Encoding.GetEncoding("ISO-8859-1"), Encoding.UTF8); string orderId = match.Groups["orderid"].Value; string firstExecutionDateStr = match.Groups["firstdate"].Value; var firstExecutionDate = !string.IsNullOrWhiteSpace(firstExecutionDateStr) ? DateTime.ParseExact(firstExecutionDateStr, "yyyyMMdd", CultureInfo.InvariantCulture) : default(DateTime?); string timeUnitStr = match.Groups["turnus"].Value; var timeUnit = timeUnitStr == "M" ? TimeUnit.Monthly : TimeUnit.Weekly; string rota = match.Groups["rota"].Value; string executionDayStr = match.Groups["execday"].Value; int executionDay = Convert.ToInt32(executionDayStr); string lastExecutionDateStr = match.Groups["lastdate"].Value; var lastExecutionDate = !string.IsNullOrWhiteSpace(lastExecutionDateStr) ? DateTime.ParseExact(lastExecutionDateStr, "yyyyMMdd", CultureInfo.InvariantCulture) : default(DateTime?); var painData = Pain00100103CtData.Create(xml); if (firstExecutionDate.HasValue && executionDay > 0) { var item = new BankersOrder(orderId, painData, firstExecutionDate.Value, timeUnit, rota, executionDay, lastExecutionDate); data.Add(item); } } int endIdx = BankCode_.IndexOf("'"); if (BankCode_.Length <= endIdx + 1) { break; } BankCode_ = BankCode_.Substring(endIdx + 1); startIdx = BankCode_.IndexOf("HICDB"); if (startIdx < 0) { break; } } // Success return(result.TypedResult(data)); }