private void CreateXML() { int index = 0; //DataTable row index int tableNumberRows = ds.Tables[0].Rows.Count; //counts number of rows in DataTable CreditTransferTransactionInformation10[] crdtTransTransacInfoTransactions = new CreditTransferTransactionInformation10[tableNumberRows]; foreach (DataRow row in ds.Tables[0].Rows) { CreditTransferTransactionInformation10 crdtTransTransacInfo = new CreditTransferTransactionInformation10(); PaymentIdentification1 paymentIndNum = new PaymentIdentification1(); paymentIndNum.EndToEndId = index.ToString(); EquivalentAmount2 eqvAmount = new EquivalentAmount2(); ActiveOrHistoricCurrencyAndAmount curAndAmnt = new ActiveOrHistoricCurrencyAndAmount(); curAndAmnt.Ccy = row[10].ToString();//Currency curAndAmnt.Value = decimal.Parse(row[9].ToString());//Transaction ammount eqvAmount.Amt = curAndAmnt; AmountType3Choice amntType = new AmountType3Choice(); amntType.Item = eqvAmount; crdtTransTransacInfo.PmtId = paymentIndNum; crdtTransTransacInfo.Amt = amntType; crdtTransTransacInfoTransactions[index] = crdtTransTransacInfo; index++; } PaymentInstructionInformation3[] pmntInstrInf = new PaymentInstructionInformation3[1]; PaymentInstructionInformation3 pmntInstrInfIteam = new PaymentInstructionInformation3(); pmntInstrInfIteam.CdtTrfTxInf = crdtTransTransacInfoTransactions; pmntInstrInf[0] = pmntInstrInfIteam; Authorisation1Choice[] authChoiceArray = new Authorisation1Choice[1]; Authorisation1Choice authChoice = new Authorisation1Choice(); authChoice.Item = "Sergei"; authChoiceArray[0] = authChoice; GroupHeader32 grpHdr = new GroupHeader32(); grpHdr.Authstn = authChoiceArray; CustomerCreditTransferInitiationV03 cctiv = new CustomerCreditTransferInitiationV03(); cctiv.GrpHdr = grpHdr; cctiv.PmtInf = pmntInstrInf; Document document = new Document(); document.CstmrCdtTrfInitn = cctiv; var data = document; var serializer = new XmlSerializer(typeof(Document)); using (var stream = new StreamWriter("C:\\Users\\yulya\\Desktop\\test.xml")) serializer.Serialize(stream, data); }
public static SEPABatchPayment CreateForOnePaymentBlock(string debtorName, IBANBIC debtorAccount, string messageID, string paymentBlockID, DateTime?paymentExecutionDate = null) { if (debtorAccount.NoBICprovided) { throw new ArgumentException("No BIC provided for debtor account", "debtorAccount"); } var b = new SEPABatchPayment(); b.document.CstmrCdtTrfInitn.GrpHdr.MsgId = Truncate(messageID, maxLengthID); b.document.CstmrCdtTrfInitn.GrpHdr.InitgPty = new PartyIdentification32 { Nm = Truncate(debtorName, maxLengthName), }; var pi = new PaymentInstructionInformation3 { PmtInfId = Truncate(paymentBlockID, maxLengthID), PmtMtd = PaymentMethod3Code.TRF, BtchBookg = false, ReqdExctnDt = paymentExecutionDate ?? DateTime.Now, Dbtr = new PartyIdentification32 { Nm = Truncate(debtorName, maxLengthName), // only debtorname is enough }, DbtrAcct = new CashAccount16 { Id = new AccountIdentification4Choice { Item = debtorAccount.IBAN, } }, DbtrAgt = new BranchAndFinancialInstitutionIdentification4 { FinInstnId = new FinancialInstitutionIdentification7 { BIC = debtorAccount.BIC.ToString(), } }, }; b.document.CstmrCdtTrfInitn.PmtInf = new[] { pi }; return(b); }
private void CreateXML() { int index = 0; //DataTable row index int tableNumberRows = ds.Tables[0].Rows.Count; //counts number of rows in DataTable CreditTransferTransactionInformation10[] crdtTransTransacInfoTransactions = new CreditTransferTransactionInformation10[tableNumberRows]; foreach (DataRow row in ds.Tables[0].Rows) { CreditTransferTransactionInformation10 crdtTransTransacInfo = new CreditTransferTransactionInformation10(); PaymentIdentification1 paymentIndNum = new PaymentIdentification1(); paymentIndNum.EndToEndId = index.ToString(); EquivalentAmount2 eqvAmount = new EquivalentAmount2(); ActiveOrHistoricCurrencyAndAmount curAndAmnt = new ActiveOrHistoricCurrencyAndAmount(); curAndAmnt.Ccy = row[10].ToString(); //Currency curAndAmnt.Value = decimal.Parse(row[9].ToString()); //Transaction ammount eqvAmount.Amt = curAndAmnt; AmountType3Choice amntType = new AmountType3Choice(); amntType.Item = eqvAmount; crdtTransTransacInfo.PmtId = paymentIndNum; crdtTransTransacInfo.Amt = amntType; crdtTransTransacInfoTransactions[index] = crdtTransTransacInfo; index++; } PaymentInstructionInformation3[] pmntInstrInf = new PaymentInstructionInformation3[1]; PaymentInstructionInformation3 pmntInstrInfIteam = new PaymentInstructionInformation3(); pmntInstrInfIteam.CdtTrfTxInf = crdtTransTransacInfoTransactions; pmntInstrInf[0] = pmntInstrInfIteam; Authorisation1Choice[] authChoiceArray = new Authorisation1Choice[1]; Authorisation1Choice authChoice = new Authorisation1Choice(); authChoice.Item = "Sergei"; authChoiceArray[0] = authChoice; GroupHeader32 grpHdr = new GroupHeader32(); grpHdr.Authstn = authChoiceArray; CustomerCreditTransferInitiationV03 cctiv = new CustomerCreditTransferInitiationV03(); cctiv.GrpHdr = grpHdr; cctiv.PmtInf = pmntInstrInf; Document document = new Document(); document.CstmrCdtTrfInitn = cctiv; var data = document; var serializer = new XmlSerializer(typeof(Document)); using (var stream = new StreamWriter("C:\\Users\\yulya\\Desktop\\test.xml")) serializer.Serialize(stream, data); }