예제 #1
0
        public string GetTan(FinService aService)
        {
            if (m_vList.Count == 0)
            {
                throw new InvalidOperationException("Keine TAN-Nummern in Liste!");
            }

            FinTanProcessParameters aTanProc = aService.TanProcess;
            FinChallengeInfo aChallengeInfo = aService.ChallengeInfo;

            // If this is not a 2-step TAN procedure then we always just return the very first
            // TAN of the list.

            if ((aTanProc == null) || (aChallengeInfo == null))
            {
                Tan aTan = (Tan)m_vList[0];
                return aTan.TAN;
            }

            string sChallenge = aChallengeInfo.Challenge;
            int nIndex = GetIndexFromChallenge(sChallenge);
            if (nIndex >= 0)
            {
                string sTAN = FindTan(nIndex);
                if (sTAN != null)
                {
                    return sTAN;
                }
            }

            io.Write("Keine TAN für " + sChallenge + "in TAN-Datei gefunden!");
            return null;
        }
예제 #2
0
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinXmlOrder aXmlOrder = order as FinXmlOrder;

            if (aXmlOrder == null)
            {
                return null;
            }

            XmlDocument aResponseXml = aXmlOrder.ResponseXml;
            if (aResponseXml == null)
            {
                return null;
            }

            using (StringWriter aStringWriter = new StringWriter())
            {
                XmlTextWriter aXmlWriter = new XmlTextWriter(aStringWriter)
                                               {
                                                   Formatting = Formatting.Indented
                                               };
                aResponseXml.WriteContentTo(aXmlWriter);
                aXmlWriter.Flush();
                aStringWriter.Flush();
                return new ResponseData { Formatted = aStringWriter.ToString() };
            }
        }
예제 #3
0
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctMvmtsSpecifiedPeriod aAcctMvmts = order as FinAcctMvmtsSpecifiedPeriod;

            if (aAcctMvmts == null)
            {
                return(null);
            }

            switch (m_nFormat)
            {
            case OutputFormat.CSV:
                return(new ResponseData {
                    Formatted = _GetCsvResponseData(aAcctMvmts)
                });

            case OutputFormat.MT940:
                return(new ResponseData {
                    Formatted = _GetMT940ResponseData(aAcctMvmts)
                });

            case OutputFormat.MT942:
                return(new ResponseData {
                    Formatted = _GetMT942ResponseData(aAcctMvmts)
                });

            case OutputFormat.CSV942:
                return(new ResponseData {
                    Formatted = _GetCsv942ResponseData(aAcctMvmts)
                });

            default:
                return(null);
            }
        }
예제 #4
0
파일: Hbci.cs 프로젝트: sidiandi/sammy
        IList <Statement> DownloadStatement()
        {
            log.DebugFormat("Download {0}", AccountId);
            FinContact       contact = FinContactFolder.Default.FindContact(AccountId);
            List <Statement> s       = new List <Statement>();

            foreach (FinAcctInfo aAcctInfo in contact.UPD)
            {
                try
                {
                    FinAcct acct = aAcctInfo.Acct;
                    log.DebugFormat("Downloading account {0}/{1}", acct.BankCode, acct.AcctNo);
                    FinService service = new FinService(contact, acct.BankCode, acct.AcctNo, acct.Currency);
                    service.LogOn(Password);
                    FinAcctMvmtsSpecifiedPeriod aAcctMvmts = service.DownloadStatement(SwiftDate.NullDate);
                    service.LogOff();

                    if (aAcctMvmts != null)
                    {
                        s.Add(ToStatement(acct, aAcctMvmts.BookedTrans));
                    }
                }
                catch (Exception e)
                {
                    log.Error("Error while downloading " + AccountId, e);
                }
            }
            return(s);
        }
예제 #5
0
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinXmlOrder aXmlOrder = order as FinXmlOrder;

            if (aXmlOrder == null)
            {
                return(null);
            }

            XmlDocument aResponseXml = aXmlOrder.ResponseXml;

            if (aResponseXml == null)
            {
                return(null);
            }

            using (StringWriter aStringWriter = new StringWriter())
            {
                XmlTextWriter aXmlWriter = new XmlTextWriter(aStringWriter)
                {
                    Formatting = Formatting.Indented
                };
                aResponseXml.WriteContentTo(aXmlWriter);
                aXmlWriter.Flush();
                aStringWriter.Flush();
                return(new ResponseData {
                    Formatted = aStringWriter.ToString()
                });
            }
        }
예제 #6
0
        public string GetTan(FinService aService)
        {
            if (m_vList.Count == 0)
            {
                throw new InvalidOperationException("Keine TAN-Nummern in Liste!");
            }

            FinTanProcessParameters aTanProc       = aService.TanProcess;
            FinChallengeInfo        aChallengeInfo = aService.ChallengeInfo;

            // If this is not a 2-step TAN procedure then we always just return the very first
            // TAN of the list.

            if ((aTanProc == null) || (aChallengeInfo == null))
            {
                Tan aTan = (Tan)m_vList[0];
                return(aTan.TAN);
            }

            string sChallenge = aChallengeInfo.Challenge;
            int    nIndex     = GetIndexFromChallenge(sChallenge);

            if (nIndex >= 0)
            {
                string sTAN = FindTan(nIndex);
                if (sTAN != null)
                {
                    return(sTAN);
                }
            }

            io.Write("Keine TAN für " + sChallenge + "in TAN-Datei gefunden!");
            return(null);
        }
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctMvmtsSpecifiedPeriod aAcctMvmts = order as FinAcctMvmtsSpecifiedPeriod;
            if (aAcctMvmts == null)
            {
                return null;
            }

            return _GetResponseData(aAcctMvmts);
        }
예제 #8
0
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctMvmtsSpecifiedPeriod aAcctMvmts = order as FinAcctMvmtsSpecifiedPeriod;

            if (aAcctMvmts == null)
            {
                return(null);
            }

            return(_GetResponseData(aAcctMvmts));
        }
예제 #9
0
        public static FinService GetFinService(FinContact contact, FinDialog dialog, StringDictionary arguments)
        {
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }

            string acctBankCode = arguments[Arguments.AcctBankCode] ?? contact.BankCode;

            if (acctBankCode == null)
            {
                throw new ArgumentException("Bankleitzahl zu Konto fehlt!");
            }

            if (acctBankCode.Length != 8 || !FinUtil.IsDigits(acctBankCode))
            {
                throw new ArgumentException("Bankleitzahl zu Konto ist ungültig!");
            }

            string acctNo = arguments[Arguments.AcctNo];

            if (acctNo == null)
            {
                throw new ArgumentException("Kontonummer fehlt!");
            }

            if (acctNo == "" || acctNo.Length > 30)
            {
                throw new ArgumentException("Kontonummer ist ungültig!");
            }

            string acctCurrency = arguments["-acctcurrency"];

            if (acctCurrency == null)
            {
                acctCurrency = "EUR";
            }
            else if (acctCurrency.Length != 3 || !FinUtil.IsUpperAscii(acctCurrency))
            {
                throw new ArgumentException("Kontowährung ist ungültig!");
            }

            // Die Bankverbindung ist jetzt vollständig spezifiziert und wir können ein
            // FinService Objekt dafür anlegen.
            FinService aService = dialog != null ?
                                  new FinService(dialog, acctBankCode, acctNo, acctCurrency) :
                                  new FinService(contact, acctBankCode, acctNo, acctCurrency);

            return(aService);
        }
예제 #10
0
        public string GetTan(FinService aService)
        {
            FinTanProcessParameters tanProcess = aService.TanProcess;
            FinChallengeInfo aChallengeInfo = aService.ChallengeInfo;

            if ((tanProcess != null) && (aChallengeInfo != null))
            {
                io.Write(tanProcess.ChallengeLabel + ": ");
                io.Write(aChallengeInfo.Challenge);
            }

            io.Write("TAN:");

            string sTAN = io.Read();
            return !string.IsNullOrEmpty(sTAN) ? sTAN : null;
        }
예제 #11
0
        public string GetTan(FinService aService)
        {
            FinTanProcessParameters tanProcess     = aService.TanProcess;
            FinChallengeInfo        aChallengeInfo = aService.ChallengeInfo;

            if ((tanProcess != null) && (aChallengeInfo != null))
            {
                io.Write(tanProcess.ChallengeLabel + ": ");
                io.Write(aChallengeInfo.Challenge);
            }

            io.Write("TAN:");

            string sTAN = io.Read();

            return(!string.IsNullOrEmpty(sTAN) ? sTAN : null);
        }
예제 #12
0
        protected override FinOrder OnCreateOrder(FinService aService)
        {
            // Egal was der Aufrufer eingestellt hat. Als Auftragskonto stellen wir das Konto
            // der Bankverbindung ein.

            Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null");
            XmlElement xmlOrderingCustAcct = m_aXmlDocument.DocumentElement["OrderingCustAcct"];

            if (xmlOrderingCustAcct == null)
            {
                xmlOrderingCustAcct = m_aXmlDocument.CreateElement("OrderingCustAcct");
                Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null");
                m_aXmlDocument.DocumentElement.PrependChild(xmlOrderingCustAcct);
            }

            FinAcct aAcct = aService.GetAcct();

            XmlElement xml = m_aXmlDocument.CreateElement("AcctNo");

            xml.InnerText = aAcct.AcctNo;
            xmlOrderingCustAcct.AppendChild(xml);

            if (aAcct.SubAcctCharacteristic != null)
            {
                xml           = m_aXmlDocument.CreateElement("SubAcctCharacteristic");
                xml.InnerText = aAcct.SubAcctCharacteristic;
                xmlOrderingCustAcct.AppendChild(xml);
            }

            XmlElement xmlBankID = m_aXmlDocument.CreateElement("BankID");

            xmlOrderingCustAcct.AppendChild(xmlBankID);

            xml           = m_aXmlDocument.CreateElement("CountryCode");
            xml.InnerText = aAcct.CountryCode;
            xmlBankID.AppendChild(xml);

            xml           = m_aXmlDocument.CreateElement("BankCode");
            xml.InnerText = aAcct.BankCode;
            xmlBankID.AppendChild(xml);

            FinXmlOrderBuilder aXmlOrderBuilder = new FinXmlOrderBuilder(aService.Contact, m_aSyntax);

            return(aXmlOrderBuilder.Build(m_aXmlDocument.DocumentElement));
        }
예제 #13
0
        protected override FinOrder OnCreateOrder(FinService aService)
        {
            // Egal was der Aufrufer eingestellt hat. Als Auftragskonto stellen wir das Konto
            // der Bankverbindung ein.

            Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null");
            XmlElement xmlOrderingCustAcct = m_aXmlDocument.DocumentElement["OrderingCustAcct"];
            if (xmlOrderingCustAcct == null)
            {
                xmlOrderingCustAcct = m_aXmlDocument.CreateElement("OrderingCustAcct");
                Debug.Assert(m_aXmlDocument.DocumentElement != null, "m_aXmlDocument.DocumentElement != null");
                m_aXmlDocument.DocumentElement.PrependChild(xmlOrderingCustAcct);
            }

            FinAcct aAcct = aService.GetAcct();

            XmlElement xml = m_aXmlDocument.CreateElement("AcctNo");
            xml.InnerText = aAcct.AcctNo;
            xmlOrderingCustAcct.AppendChild(xml);

            if (aAcct.SubAcctCharacteristic != null)
            {
                xml = m_aXmlDocument.CreateElement("SubAcctCharacteristic");
                xml.InnerText = aAcct.SubAcctCharacteristic;
                xmlOrderingCustAcct.AppendChild(xml);
            }

            XmlElement xmlBankID = m_aXmlDocument.CreateElement("BankID");
            xmlOrderingCustAcct.AppendChild(xmlBankID);

            xml = m_aXmlDocument.CreateElement("CountryCode");
            xml.InnerText = aAcct.CountryCode;
            xmlBankID.AppendChild(xml);

            xml = m_aXmlDocument.CreateElement("BankCode");
            xml.InnerText = aAcct.BankCode;
            xmlBankID.AppendChild(xml);

            FinXmlOrderBuilder aXmlOrderBuilder = new FinXmlOrderBuilder(aService.Contact, m_aSyntax);
            return aXmlOrderBuilder.Build(m_aXmlDocument.DocumentElement);
        }
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctBal acctBal = order as FinAcctBal;

            if ((acctBal == null) || (acctBal.AcctBals == null))
            {
                return null;
            }

            StringBuilder sb = new StringBuilder(2000);

            sb.Append("BalanceType;BankCode;AcctNo;Date;Currency;Value");
            sb.Append(Environment.NewLine);

            foreach (FinAcctBalResp aBal in acctBal.AcctBals)
            {
                _AppendBalance(aBal, sb);
            }

            return new ResponseData {Formatted = sb.ToString() };
        }
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctMvmtsSpecifiedPeriod aAcctMvmts = order as FinAcctMvmtsSpecifiedPeriod;

            if (aAcctMvmts == null)
            {
                return null;
            }

            switch (m_nFormat)
            {
                case OutputFormat.CSV:
                    return new ResponseData { Formatted = _GetCsvResponseData(aAcctMvmts) };
                case OutputFormat.MT940:
                    return new ResponseData { Formatted = _GetMT940ResponseData(aAcctMvmts) };
                case OutputFormat.MT942:
                    return new ResponseData { Formatted = _GetMT942ResponseData(aAcctMvmts) };
                case OutputFormat.CSV942:
                    return new ResponseData { Formatted = _GetCsv942ResponseData(aAcctMvmts) };
                default:
                    return null;
            }
        }
예제 #16
0
        protected override ResponseData OnGetResponseData(FinService service, FinOrder order)
        {
            FinAcctBal acctBal = order as FinAcctBal;

            if ((acctBal == null) || (acctBal.AcctBals == null))
            {
                return(null);
            }

            StringBuilder sb = new StringBuilder(2000);

            sb.Append("BalanceType;BankCode;AcctNo;Date;Currency;Value");
            sb.Append(Environment.NewLine);

            foreach (FinAcctBalResp aBal in acctBal.AcctBals)
            {
                _AppendBalance(aBal, sb);
            }

            return(new ResponseData {
                Formatted = sb.ToString()
            });
        }
예제 #17
0
 protected abstract FinOrder OnCreateOrder(FinService aService);
예제 #18
0
 public virtual ResponseData GetResponseData(FinService aService)
 {
     return(OnGetResponseData(aService, order));
 }
예제 #19
0
        public virtual IActionResult Execute(FinService service, ITanSource tanSource)
        {
            order = OnCreateOrder(service);
            if (order == null)
            {
                return(new ActionResult(Status.CouldNotCreateOrder));
            }

            FinServiceResult result = service.SendOrder(order);

            if (result == FinServiceResult.NeedTan)
            {
                string tan = tanSource.GetTan(service);
                if (tan == null)
                {
                    return(new ActionResult(Status.CouldNotCreateOrder));
                }

                result = service.SendTan(tan);
            }

            if (result == FinServiceResult.NeedTanMediaName)
            {
                Io.Write("Bezeichnung des TAN-Mediums erforderlich!");
                FinTanMedia[] vTanMedias = service.TanMedias;
                if (vTanMedias != null)
                {
                    Io.Write("Bitte geben Sie einen der folgenden Parameter an:");
                    foreach (FinTanMedia t in vTanMedias)
                    {
                        Io.Write("-tanmedianame \"" + t.TanMediaName + "\"");
                    }
                }

                return(new ActionResult(Status.NeedTanMediaName));
            }

            if (result == FinServiceResult.Fatal)
            {
                return(new ActionResult(Status.FatalResult));
            }

            // Als Rückgabewert wird der höchste Rückmeldecode aus dem HIRMS genommen.
            // Wurde kein HIRMS übermittelt wird als Rückgabewert 0 eingesetzt.
            int orderStatusCode = 0;

            if (order.StatusSegment != null)
            {
                int nIndex = order.StatusSegment.FindMax();
                orderStatusCode = order.StatusSegment.GetStatusCode(nIndex);
            }

            if (result == FinServiceResult.Error)
            {
                return(new ActionResult(Status.ErrorResult, orderStatusCode));
            }

            if (result == FinServiceResult.Success)
            {
                return(new ActionResult(Status.Success, orderStatusCode));
            }

            throw new Exception("The enum FinServiceResult has been changed! " +
                                "Known states: NeedTan, NeedTanMediaName, Fatal, Error, Success " +
                                "New: " + result);
        }
예제 #20
0
 protected virtual ResponseData OnGetResponseData(FinService service, FinOrder order)
 {
     return(null);
 }
 public string GetTan(FinService aService)
 {
     return tan;
 }
예제 #22
0
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return(aService.CreateBalance(false));
 }
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return aService.CreateDownloadStatement(m_tFromDate);
 }
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return aService.CreateRemitt(m_aRemitt);
 }
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return aService.CreateBalance(false);
 }
예제 #26
0
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return(aService.CreateRemitt(m_aRemitt));
 }
예제 #27
0
 protected abstract FinOrder OnCreateOrder(FinService aService);
예제 #28
0
        protected override FinOrder OnCreateOrder(FinService aService)
        {
            FinAcct aAcct = aService.GetAcct();

            // Depending on the type of the SEPA document a suitable HBCI segment type is
            // determined. This is done with the help of a very convenient property of the
            // SepaDocument class.

            FinSepaOrderBuilder aSepaOrderBuilder = null;

            switch (m_aSepaDoc.HbciSegmentType)
            {
            case "HKCCS":
                aSepaOrderBuilder = new FinSepaSingRemittBuilder(aService.Contact);
                break;

            case "HKCSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedSingRemittBuilder(aService.Contact);
                break;

            case "HKCCM":
                aSepaOrderBuilder = new FinSepaMultRemittBuilder(aService.Contact);
                break;

            case "HKCME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedMultRemittBuilder(aService.Contact);
                break;

            case "HKDSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedSingDirDebBuilder(aService.Contact);
                break;

            case "HKDSC":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1SingDirDebBuilder(aService.Contact);
                break;

            case "HKBSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessSingDirDebBuilder(aService.Contact);
                break;

            case "HKDME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedMultDirDebBuilder(aService.Contact);
                break;

            case "HKDMC":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1MultDirDebBuilder(aService.Contact);
                break;

            case "HKBME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessMultDirDebBuilder(aService.Contact);
                break;
            }

            // If no suitable segment type could be determined, or the required segment type is
            // not supported by the bank, then bail out.

            if (aSepaOrderBuilder == null)
            {
                Io.Error.Write("Keine HBCI-Auftragsart für SEPA-Dokument bekannt!");
                return(null);
            }
            if (!aSepaOrderBuilder.IsSupported)
            {
                Io.Error.Write("HBCI-Auftragsart " + m_aSepaDoc.HbciSegmentType + " von Bank nicht unterstützt!");
                return(null);
            }

            if (aSepaOrderBuilder.FindSepaFormat(m_aSepaDoc.MessageInfo.PainIdentifier) == null)
            {
                Io.Error.Write("SEPA-Format " + m_aSepaDoc.MessageInfo.PainIdentifier + " von Bank nicht unterstützt!");
                return(null);
            }

            return(aSepaOrderBuilder.Build(aAcct, m_aSepaDoc));
        }
예제 #29
0
        public virtual IActionResult Execute(FinService service, ITanSource tanSource)
        {
            order = OnCreateOrder(service);
            if (order == null)
            {
                return new ActionResult(Status.CouldNotCreateOrder);
            }

            FinServiceResult result = service.SendOrder(order);

            if (result == FinServiceResult.NeedTan)
            {
                string tan = tanSource.GetTan(service);
                if (tan == null)
                {
                    return new ActionResult(Status.CouldNotCreateOrder);
                }

                result = service.SendTan(tan);
            }

            if (result == FinServiceResult.NeedTanMediaName)
            {
                Io.Write("Bezeichnung des TAN-Mediums erforderlich!");
                FinTanMedia[] vTanMedias = service.TanMedias;
                if (vTanMedias != null)
                {
                    Io.Write("Bitte geben Sie einen der folgenden Parameter an:");
                    foreach (FinTanMedia t in vTanMedias)
                    {
                        Io.Write("-tanmedianame \"" + t.TanMediaName + "\"");
                    }
                }

                return new ActionResult(Status.NeedTanMediaName);
            }

            if (result == FinServiceResult.Fatal)
            {
                return new ActionResult(Status.FatalResult);
            }

            // Als Rückgabewert wird der höchste Rückmeldecode aus dem HIRMS genommen.
            // Wurde kein HIRMS übermittelt wird als Rückgabewert 0 eingesetzt.
            int orderStatusCode = 0;
            if (order.StatusSegment != null)
            {
                int nIndex = order.StatusSegment.FindMax();
                orderStatusCode = order.StatusSegment.GetStatusCode(nIndex);
            }

            if (result == FinServiceResult.Error)
            {
                return new ActionResult(Status.ErrorResult, orderStatusCode);
            }

            if (result == FinServiceResult.Success)
            {
                return new ActionResult(Status.Success, orderStatusCode);
            }

            throw new Exception("The enum FinServiceResult has been changed! " +
                                "Known states: NeedTan, NeedTanMediaName, Fatal, Error, Success " +
                                "New: " + result);
        }
예제 #30
0
 protected virtual ResponseData OnGetResponseData(FinService service, FinOrder order)
 {
     return null;
 }
예제 #31
0
 protected override FinOrder OnCreateOrder(FinService aService)
 {
     return(aService.CreateDownloadStatement(m_tFromDate));
 }
예제 #32
0
 public string GetTan(FinService aService)
 {
     return(tan);
 }
예제 #33
0
파일: Hbci.cs 프로젝트: al-main/sammy
        IList<Statement> DownloadStatement()
        {
            log.DebugFormat("Download {0}", AccountId);
            FinContact contact = FinContactFolder.Default.FindContact(AccountId);
            List<Statement> s = new List<Statement>();
            foreach (FinAcctInfo aAcctInfo in contact.UPD)
            {
                try
                {
                    FinAcct acct = aAcctInfo.Acct;
                    log.DebugFormat("Downloading account {0}/{1}", acct.BankCode, acct.AcctNo);
                    FinService service = new FinService(contact, acct.BankCode, acct.AcctNo, acct.Currency);
                    service.LogOn(Password);
                    FinAcctMvmtsSpecifiedPeriod aAcctMvmts = service.DownloadStatement(SwiftDate.NullDate);
                    service.LogOff();

                    if (aAcctMvmts != null)
                    {
                        s.Add(ToStatement(acct, aAcctMvmts.BookedTrans));
                    }
                }
                catch (Exception e)
                {
                    log.Error("Error while downloading " + AccountId, e);
                }
            }
            return s;
        }
예제 #34
0
        protected override FinOrder OnCreateOrder(FinService aService)
        {
            FinAcct aAcct = aService.GetAcct();

            // Depending on the type of the SEPA document a suitable HBCI segment type is
            // determined. This is done with the help of a very convenient property of the
            // SepaDocument class.

            FinSepaOrderBuilder aSepaOrderBuilder = null;

            switch (m_aSepaDoc.HbciSegmentType)
            {
            case "HKCCS":
                aSepaOrderBuilder = new FinSepaSingRemittBuilder(aService.Contact);
                break;
            case "HKCSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedSingRemittBuilder(aService.Contact);
                break;
            case "HKCCM":
                aSepaOrderBuilder = new FinSepaMultRemittBuilder(aService.Contact);
                break;
            case "HKCME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedMultRemittBuilder(aService.Contact);
                break;
            case "HKDSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedSingDirDebBuilder(aService.Contact);
                break;
            case "HKDSC":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1SingDirDebBuilder(aService.Contact);
                break;
            case "HKBSE":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessSingDirDebBuilder(aService.Contact);
                break;
            case "HKDME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedMultDirDebBuilder(aService.Contact);
                break;
            case "HKDMC":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedCor1MultDirDebBuilder(aService.Contact);
                break;
            case "HKBME":
                aSepaOrderBuilder = new FinSepaSubmitPostdatedBusinessMultDirDebBuilder(aService.Contact);
                break;
            }

            // If no suitable segment type could be determined, or the required segment type is
            // not supported by the bank, then bail out.

            if (aSepaOrderBuilder == null)
            {
                Io.Error.Write("Keine HBCI-Auftragsart für SEPA-Dokument bekannt!");
                return null;
            }
            if (!aSepaOrderBuilder.IsSupported)
            {
                Io.Error.Write("HBCI-Auftragsart " + m_aSepaDoc.HbciSegmentType + " von Bank nicht unterstützt!");
                return null;
            }

            if (aSepaOrderBuilder.FindSepaFormat(m_aSepaDoc.MessageInfo.PainIdentifier) == null)
            {
                Io.Error.Write("SEPA-Format " + m_aSepaDoc.MessageInfo.PainIdentifier + " von Bank nicht unterstützt!");
                return null;
            }

            return aSepaOrderBuilder.Build(aAcct, m_aSepaDoc);
        }
예제 #35
0
        public IActionResult DoAction(string action, StringDictionary arguments)
        {
            // In jedem Fall wird die PIN oder der Dialogkontext zur Fortführung benötigt.
            string pin    = arguments[Arguments.Pin];
            string resume = arguments[Arguments.Resume];

            // Optional kann eine TAN oder eine TAN-Liste mitgegeben werden.
            // Wird beides nicht mitgegeben, so wird die TAN auf der Kommandozeile abgefragt.
            ITanSource tanSource = tanSourceFactory.GetTanSource(arguments);

            // Optional kann eine Datei für den HBCI-FinTsTrace angegeben werden.
            string traceFile = arguments[Arguments.Trace];

            // Wird der Schalter -suspend angegeben, so wird nach der Aktion keine
            // Dialogbeendigung durchgeführt, sondern einfach der Zustand in die angegebene Datei gespeichert.
            string suspend = arguments[Arguments.Suspend];

            // Die IAction Implementierung für die gewünschte Aktion erstellen.
            IAction cmd = actionFactory.GetAction(action);

            if (!cmd.Parse(action, arguments))
            {
                throw new ArgumentException("Wrong arguments for the given action!");
            }

            FinContact contact;
            FinDialog  dialog = null;

            if (resume != null)
            {
                dialog = new FinDialog();
                dialog.Load(resume);
                contact = dialog.Contact;
            }
            else
            {
                contact = FinContactCreator.GetFinContact(arguments);
            }

            FinService    service = FinServiceCreator.GetFinService(contact, dialog, arguments);
            IActionResult result  = new ActionResult(Status.Unknown);

            try
            {
                service.ClearDocket();

                if (!service.Online)
                {
                    // Hinweis: eine erforderliche Synchronisierung wird von LogOn immer automatisch durchführt.
                    if (!service.LogOn(pin))
                    {
                        result = new ActionResult(Status.CouldNotLogOn);
                        goto _done;
                    }
                }

                if (service.Online)
                {
                    result = cmd.Execute(service, tanSource);

                    if (suspend != null)
                    {
                        service.Dialog.SaveAs(suspend);
                    }
                    else
                    {
                        service.LogOff();
                    }
                }

_done:

                // Falls der Bankkontakt aus einer Datei geladen wurde, so muss diese nun noch
                // gespeichert werden, damit auch alle am Bankkontakt erfolgten Änderungen
                // erhalten bleiben.
                string sContactFile = arguments[Arguments.ContactFile];
                if (sContactFile != null)
                {
                    contact.SaveAs(sContactFile);
                }

                // Wurde eine Tracedatei angegeben, so wird der komplette HBCI FinTsTrace in diese
                // Datei geschrieben.
                if (traceFile != null)
                {
                    StreamWriter sw = File.CreateText(traceFile);
                    sw.Write(service.Trace);
                    sw.Close();
                }

                // Auftrag ausgeführt. Zuerst geben wir den gesammelten Laufzettel aus,
                // danach die Antwortdaten, sofern welche vorhanden sind.
                io.Write(service.Docket);

                if (result.Status != Status.CouldNotLogOn)
                {
                    ResponseData responseData = cmd.GetResponseData(service);
                    if (responseData.Formatted != null)
                    {
                        io.Write(responseData.Formatted);
                    }
                    result.Response = responseData;
                }
            }
            catch (Exception x)
            {
                throw new ActionException(x, service.Trace);
            }
            finally
            {
                service.Dispose();
            }

            return(result);
        }
예제 #36
0
 public virtual ResponseData GetResponseData(FinService aService)
 {
     return OnGetResponseData(aService, order);
 }