Exemple #1
0
        /// <summary>
        /// TAN
        /// </summary>
        public static async Task <String> Send_TAN(FinTsClient client, string TAN)
        {
            Log.Write("Starting TAN process");
            var    connectionDetails = client.ConnectionDetails;
            string segments          = string.Empty;

            var HITANS = !string.IsNullOrEmpty(client.HITANS.Substring(0, 1)) ? int.Parse(client.HITANS.Substring(0, 1)) : 0;

            if (string.IsNullOrEmpty(client.HITAB)) // TAN Medium Name not set
            {
                // Version 2
                if (HITANS == 2)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N'";
                }
                // Version 3
                else if (HITANS == 3)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N'";
                }
                // Version 4
                else if (HITANS == 4)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N'";
                }
                // Version 5
                else if (HITANS == 5)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++++" + client.HITAN + "++N'";
                }
                // Version 6
                else if (HITANS == 6)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++++" + client.HITAN + "+N'";
                }
                else // default
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++++" + client.HITAN + "++N'";
                }
            }
            else
            {
                // Version 2
                if (HITANS == 2)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'";
                }
                // Version 3
                else if (HITANS == 3)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'";
                }
                // Version 4
                else if (HITANS == 4)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'";
                }
                // Version 5
                else if (HITANS == 5)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++++" + client.HITAN + "++N++++" + client.HITAB + "'";
                }
                // Version 6
                else if (HITANS == 6)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++++" + client.HITAN + "+N++++" + client.HITAB + "'";
                }
                else // default
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + client.HITANS.Substring(0, 1) + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'";
                }
            }

            client.SEGNUM = SEGNUM.SETInt(3);

            string message  = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS + ":" + TAN);
            string response = await FinTSMessage.Send(client, message);

            Helper.Parse_Message(client, response);

            return(response);
        }
Exemple #2
0
        /// <summary>
        /// Transactions
        /// </summary>
        public static string Init_HKKAZ(ConnectionDetails connectionDetails, string FromDate, string ToDate, string Startpoint)
        {
            Log.Write("Starting job HKKAZ: Request transactions");

            string segments = string.Empty;

            if (String.IsNullOrEmpty(FromDate))
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }
            }

            SEG.NUM = SEGNUM.SETInt(3);

            string message = FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);

            return(FinTSMessage.Send(connectionDetails.Url, message));
        }
Exemple #3
0
        /// <summary>
        /// Transactions
        /// </summary>
        public static string Init_HKKAZ(ConnectionDetails connectionDetails, string FromDate, string ToDate, string Startpoint)
        {
            Log.Write("Starting job HKKAZ: Request transactions");

            string segments = string.Empty;

            SEG.NUM = SEGNUM.SETInt(3);

            if (String.IsNullOrEmpty(FromDate))
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEG.NUM + ":" + Segment.HKKAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }
            }

            if (Helper.IsTANRequired("HKKAZ"))
            {
                SEG.NUM  = SEGNUM.SETInt(4);
                segments = HKTAN.Init_HKTAN(segments);
            }

            string message  = FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
            string response = FinTSMessage.Send(connectionDetails.Url, message);

            Segment.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

            Helper.Parse_Message(response);

            return(response);
        }
Exemple #4
0
        /// <summary>
        /// INI
        /// </summary>
        public static async Task <String> Init_INI(FinTsClient client)
        {
            var connectionDetails = client.ConnectionDetails;

            if (!client.Anonymous)
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    string segments;

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HbciVersion == 220)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + FinTsConfig.ProductId + "+" + FinTsConfig.Version + "'";

                        segments = segments_;
                    }
                    else if (connectionDetails.HbciVersion == 300)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + FinTsConfig.ProductId + "+" + FinTsConfig.Version + "'";

                        if (client.HITANS != null && client.HITANS.Substring(0, 3).Equals("6+4"))
                        {
                            client.SEGNUM = SEGNUM.SETInt(5);
                            segments_     = HKTAN.Init_HKTAN(client, segments_);
                        }
                        else
                        {
                            client.SEGNUM = SEGNUM.SETInt(4);
                        }

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    var message  = FinTSMessage.Create(client, "1", "0", segments, client.HIRMS);
                    var response = await FinTSMessage.Send(client, message);

                    Helper.Parse_Segment(client, response);

                    client.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN:", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

                    return(response);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    throw new Exception("Software error", ex);
                }
            }
            else
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation anonymous");

                    string segments;

                    if (connectionDetails.HbciVersion == 300)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + connectionDetails.BlzPrimary + "+" + "9999999999" + "+0+0'" +
                            "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + FinTsConfig.ProductId + "+" + FinTsConfig.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    client.SEGNUM = SEGNUM.SETInt(4);

                    string message  = FinTsMessageAnonymous.Create(connectionDetails.HbciVersion, "1", "0", connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, "0", segments, null, client.SEGNUM);
                    string response = await FinTSMessage.Send(client, message);

                    var messages = Helper.Parse_Segment(client, response);
                    var result   = new HBCIDialogResult(messages, response);
                    if (!result.IsSuccess)
                    {
                        Log.Write("Synchronisation anonymous failed. " + result);
                        return(response);
                    }

                    // Sync OK
                    Log.Write("Synchronisation anonymous ok");

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HbciVersion == 300)
                    {
                        string segments__ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + FinTsConfig.ProductId + "+" + FinTsConfig.Version + "'" +
                            "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                        segments = segments__;
                    }
                    else
                    {
                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    client.SEGNUM = SEGNUM.SETInt(5);

                    message  = FinTSMessage.Create(client, "1", "0", segments, client.HIRMS);
                    response = await FinTSMessage.Send(client, message);

                    Helper.Parse_Segment(client, response);

                    client.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN:", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

                    return(response);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    DEBUG.Write("Software error: " + ex.ToString());

                    throw new Exception("Software error: " + ex.ToString());
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Transactions in camt053 format
        /// </summary>
        public static string Init_HKCAZ(ConnectionDetails connectionDetails, string FromDate, string ToDate, string Startpoint, camtVersion camtVers)
        {
            string segments = string.Empty;

            SEG.NUM = SEGNUM.SETInt(3);

            switch (camtVers)
            {
            case camtVersion.camt052:
                Log.Write("Starting job HKCAZ: Request transactions in camt052 format");

                if (String.IsNullOrEmpty(FromDate))
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                SEG.NUM = SEGNUM.SETInt(3);
                break;

            case camtVersion.camt053:
                Log.Write("Starting job HKCAZ: Request transactions in camt053 format");

                if (String.IsNullOrEmpty(FromDate))
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEG.NUM + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                break;

            default:     // -> Will never happen, only for compiler
                return(string.Empty);
            }

            if (Helper.IsTANRequired("HKCAZ"))
            {
                SEG.NUM  = SEGNUM.SETInt(4);
                segments = HKTAN.Init_HKTAN(segments);
            }

            string message  = FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
            string response = FinTSMessage.Send(connectionDetails.Url, message);

            Segment.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

            Helper.Parse_Message(response);

            return(response);
        }
Exemple #6
0
        /// <summary>
        /// INI
        /// </summary>
        public static HBCIDialogResult Init_INI(ConnectionDetails connectionDetails, bool anonymous)
        {
            if (!anonymous)
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    // If there is no customer system ID available, perform sync to get one
                    if (connectionDetails.CustomerSystemId == null)
                    {
                        var BankCode   = Transaction.HKSYN(connectionDetails);
                        var syncResult = new HBCIDialogResult(Helper.Parse_BankCode(BankCode));
                        if (!syncResult.IsSuccess)
                        {
                            Log.Write("Synchronisation failed.");
                            return(syncResult);
                        }
                    }
                    else
                    {
                        Segment.HISYN = connectionDetails.CustomerSystemId;
                    }

                    string segments;

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HBCIVersion == 220)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(4);

                    var message  = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
                    var response = FinTSMessage.Send(connectionDetails.Url, message);

                    var bankMessages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);
                    var result       = new HBCIDialogResult(bankMessages);
                    if (!result.IsSuccess)
                    {
                        Log.Write("Initialisation failed: " + result);
                    }

                    return(result);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    throw new Exception("Software error", ex);
                }
            }
            else
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation anonymous");

                    string segments;

                    if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + connectionDetails.BlzPrimary + "+" + "9999999999" + "+0+0'" +
                                           "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + Program.Buildname + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(4);

                    string message  = FinTSMessageAnonymous.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, SYS.SETVal(0), segments, null, SEG.NUM);
                    string response = FinTSMessage.Send(connectionDetails.Url, message);

                    var messages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);
                    var result   = new HBCIDialogResult(messages);
                    if (!result.IsSuccess)
                    {
                        Log.Write("Synchronisation anonymous failed. " + result);
                        return(result);
                    }

                    // Sync OK
                    Log.Write("Synchronisation anonymous ok");

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments__ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                            "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                            "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                        segments = segments__;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(5);

                    message  = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
                    response = FinTSMessage.Send(connectionDetails.Url, message);

                    messages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);
                    result   = new HBCIDialogResult(messages);
                    if (!result.IsSuccess)
                    {
                        Log.Write("Initialisation failed.");
                    }

                    return(result);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    DEBUG.Write("Software error: " + ex.ToString());

                    throw new Exception("Software error: " + ex.ToString());
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// INI
        /// </summary>
        public static bool Init_INI(ConnectionDetails connectionDetails, bool anonymous)
        {
            if (!anonymous)
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation");

                    string segments;

                    if (connectionDetails.HBCIVersion == 220)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.Blz + "+" + connectionDetails.UserId + "+0+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                           "HKSYN:" + SEGNUM.SETVal(5) + ":2+0'";

                        segments = segments_;
                    }
                    else if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.Blz + "+" + connectionDetails.UserId + "+0+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                           "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(5);

                    if (Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion,
                                             FinTSMessage.Send(connectionDetails.Url, FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId,
                                                                                                          connectionDetails.Pin, SYS.SETVal(0), segments, null, SEG.NUM))))
                    {
                        // Sync OK
                        Log.Write("Synchronisation ok");

                        /// <summary>
                        /// INI
                        /// </summary>
                        if (connectionDetails.HBCIVersion == 220)
                        {
                            string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.Blz + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                               "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                            segments = segments_;
                        }
                        else if (connectionDetails.HBCIVersion == 300)
                        {
                            string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.Blz + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                               "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                            segments = segments_;
                        }
                        else
                        {
                            //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                            //connectionDetails.UserId = string.Empty;
                            //connectionDetails.Pin = null;

                            Log.Write("HBCI version not supported");

                            throw new Exception("HBCI version not supported");
                        }

                        SEG.NUM = SEGNUM.SETInt(4);

                        if (Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion,
                                                 FinTSMessage.Send(connectionDetails.Url, FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN,
                                                                                                              segments, Segment.HIRMS, SEG.NUM))))
                        {
                            return(true);
                        }
                        else
                        {
                            //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                            //connectionDetails.UserId = string.Empty;
                            //connectionDetails.Pin = null;

                            Log.Write("Initialisation failed");

                            throw new Exception("Initialisation failed");
                        }
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("Sync failed");

                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    throw new Exception("Software error");
                }
            }
            else
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation anonymous");

                    string segments;

                    if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + connectionDetails.Blz + "+" + "9999999999" + "+0+0'" +
                                           "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + Program.Buildname + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(4);

                    if (Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion,
                                             FinTSMessage.Send(connectionDetails.Url, FinTSMessageAnonymous.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz,
                                                                                                                   connectionDetails.UserId, connectionDetails.Pin, SYS.SETVal(0), segments, null, SEG.NUM))))
                    {
                        // Sync OK
                        Log.Write("Synchronisation anonymous ok");

                        /// <summary>
                        /// INI
                        /// </summary>
                        if (connectionDetails.HBCIVersion == 300)
                        {
                            string segments__ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.Blz + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                                                "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                                "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                            segments = segments__;
                        }
                        else
                        {
                            //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                            //connectionDetails.UserId = string.Empty;
                            //connectionDetails.Pin = null;

                            Log.Write("HBCI version not supported");

                            throw new Exception("HBCI version not supported");
                        }

                        SEG.NUM = SEGNUM.SETInt(5);

                        if (Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion,
                                                 FinTSMessage.Send(connectionDetails.Url, FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin,
                                                                                                              Segment.HISYN, segments, Segment.HIRMS, SEG.NUM))))
                        {
                            return(true);
                        }
                        else
                        {
                            //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                            //connectionDetails.UserId = string.Empty;
                            //connectionDetails.Pin = null;

                            Log.Write("Initialisation failed");

                            throw new Exception("Initialisation failed");
                        }
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("Sync failed");

                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    DEBUG.Write("Software error: " + ex.ToString());

                    throw new Exception("Software error: " + ex.ToString());
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Create RDH message
        /// </summary>
        /// <param name="Version"></param>
        /// <param name="MsgNum"></param>
        /// <param name="DialogID"></param>
        /// <param name="BLZ"></param>
        /// <param name="UserID"></param>
        /// <param name="SystemID"></param>
        /// <param name="Segments"></param>
        /// <param name="SegmentNum"></param>
        /// <returns></returns>
        public static string Create(int Version, string MsgNum, string DialogID, int BLZ, string UserID,
                                    string SystemID, string Segments, int SegmentNum)
        {
            if (String.IsNullOrEmpty(MsgNum))
            {
                MsgNum = "1";
            }

            MsgNum   += "";
            DialogID += "";

            var HEAD_LEN  = 29;
            var TRAIL_LEN = 11;

            Random Rnd   = new Random();
            int    RndNr = Rnd.Next();

            var encHead  = string.Empty;
            var sigHead  = string.Empty;
            var sigTrail = string.Empty;

            var secRef = Math.Round(Convert.ToDecimal(RndNr.ToString().Replace("-", "")) * 999999 + 1000000);

            string date = Convert.ToString(DateTime.Now.Year) + DateTime.Now.ToString("MM") + DateTime.Now.ToString("dd");
            string time = Convert.ToString(DateTime.Now.TimeOfDay).Substring(0, 8).Replace(":", "");

            if (Version != 300)
            {
                Log.Write("HBCI version not supported");

                throw new Exception("HBCI Version not supported");
            }

            sigHead = "HNSHK:" + SEGNUM.SETVal(2) + ":4+" + RDH_Profile.RDHPROFILE + "+2+" + secRef + "+1+1+1::" + SystemID + "+1+1:" + date + ":" + time +
                      "+1:" + Sig.HASHALG_SHA256_SHA256 + ":1+6:" + Sig.SIGALG_RSA + ":" + Sig.SIGMODE_PSS + "+" + SEG_Country.Germany + ":" + RDH_KEYSTORE.BLZ + ":" + RDH_KEYSTORE.UserID + ":" + Keytype.Sig + ":" + RDH_Profile.Version + ":1'";

            // TODO: Signature is revoked from bank -> Must be a mistake while implementing
            var signature = Sig.Sign(Segments);

            var v = Sig.Verify(Segments, signature);

            var signedsig = signature;

            sigTrail = "HNSHA:" + Convert.ToString(SegmentNum + 1) + ":2+" + secRef + "+" + "@" +
                       signedsig.Length + "@" + signedsig + "'";

            if (DEBUG.Enabled)
            {
                DEBUG.Write("sigTrail: " + sigTrail);
            }

            Segments = sigHead + Segments + sigTrail;

            byte[] encryptedSessionKey = null;
            byte[] encryptedMessage    = null;

            Crypt.Encrypt(Segments, out encryptedSessionKey, out encryptedMessage);

            encHead = "HNVSK:" + Enc.SECFUNC_ENC_PLAIN + ":3+" + RDH_Profile.RDHPROFILE + "+4+1+1::" + SystemID + "+1:" + date + ":" + time + "+2:2:" + Enc.ENCALG_2K3DES + ":@" +
                      encryptedSessionKey.Length + "@" + Encoding.GetEncoding("iso8859-1").GetString(encryptedSessionKey) + ":" + Enc.ENC_KEYTYPE_RSA + ":1+" + SEG_Country.Germany + ":" + RDH_KEYSTORE.BLZ + ":0:" +
                      Keytype.Enc + ":" + RDH_Profile.Version + ":1+0'";

            if (DEBUG.Enabled)
            {
                DEBUG.Write("encHead: " + encHead);
            }

            var payload = "HNVSD:999:1+@" + encryptedMessage.Length + "@" + Encoding.GetEncoding("iso8859-1").GetString(encryptedMessage) + "'";

            var msgLen = HEAD_LEN + TRAIL_LEN + MsgNum.Length + DialogID.Length + (payload.Length + 1) + encHead.Length; // (payload.Length + 1) = Add one digit for "abschließendes Trennzeichen"

            var paddedLen = ("000000000000").Substring(0, 12 - Convert.ToString(msgLen).Length) + Convert.ToString(msgLen);

            var msgHead = "HNHBK:" + SEGNUM.SETVal(1) + ":3+" + paddedLen + "+" + ("300") + "+" + DialogID + "+" + MsgNum + "'";

            if (DEBUG.Enabled)
            {
                DEBUG.Write("msgHead: " + msgHead);
            }

            var msgEnd = "HNHBS:" + Convert.ToString(SegmentNum + 2) + ":1+" + MsgNum + "'";

            if (DEBUG.Enabled)
            {
                DEBUG.Write("msgEnd: " + msgEnd);
            }

            return(msgHead + encHead + payload + msgEnd);
        }
Exemple #9
0
        /// <summary>
        /// TAN
        /// </summary>
        public static string Send_TAN(ConnectionDetails connectionDetails, string TAN)
        {
            Log.Write("Starting TAN process");

            string segments = string.Empty;

            var HITANS = !String.IsNullOrEmpty(Segment.HITANS.Substring(0, 1)) ? Int32.Parse(Segment.HITANS.Substring(0, 1)) : 0;

            if (String.IsNullOrEmpty(Segment.HITAB)) // TAN Medium Name not set
            {
                // Version 2
                if (HITANS == 2)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'";
                }
                // Version 3
                else if (HITANS == 3)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'";
                }
                // Version 4
                else if (HITANS == 4)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'";
                }
                // Version 5
                else if (HITANS == 5)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++++" + Segment.HITAN + "++N'";
                }
                else // default
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++++" + Segment.HITAN + "++N'";
                }
            }
            else
            {
                // Version 2
                if (HITANS == 2)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N++++" + Segment.HITAB + "'";
                }
                // Version 3
                else if (HITANS == 3)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N++++" + Segment.HITAB + "'";
                }
                // Version 4
                else if (HITANS == 4)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N++++" + Segment.HITAB + "'";
                }
                // Version 5
                else if (HITANS == 5)
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++++" + Segment.HITAN + "++N++++" + Segment.HITAB + "'";
                }
                else // default
                {
                    segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N++++" + Segment.HITAB + "'";
                }
            }

            SEG.NUM = SEGNUM.SETInt(3);

            string message = FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS + ":" + TAN, SEG.NUM);

            return(FinTSMessage.Send(connectionDetails.Url, message));
        }
Exemple #10
0
        /// <summary>
        /// Transactions
        /// </summary>
        public static string Init_HKKAZ(string Konto, int BLZ, string IBAN, string BIC, string URL, int HBCIVersion, string UserID, string PIN, string FromDate, string Startpoint)
        {
            Log.Write("Starting job HKKAZ: Request transactions");

            string segments = string.Empty;

            if (String.IsNullOrEmpty(FromDate))
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + Konto + "::280:" + BLZ + "+N'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + IBAN + ":" + BIC + ":" + Konto + "::280:" + BLZ + "+N'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + Konto + "::280:" + BLZ + "+N++++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + IBAN + ":" + BIC + ":" + Konto + "::280:" + BLZ + "+N++++" + Startpoint + "'";
                    }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + Konto + "::280:" + BLZ + "+N+" + FromDate + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + IBAN + ":" + BIC + ":" + Konto + "::280:" + BLZ + "+N+" + FromDate + "'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(Segment.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + Konto + "::280:" + BLZ + "+N+" + FromDate + "+++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKKAZ + "+" + IBAN + ":" + BIC + ":" + Konto + "::280:" + BLZ + "+N+" + FromDate + "+++" + Startpoint + "'";
                    }
                }
            }

            SEG.NUM = SEGNUM.SETInt(3);

            return(FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)));
        }
Exemple #11
0
        /// <summary>
        /// INI
        /// </summary>
        public static string Init_INI(ConnectionDetails connectionDetails, bool anonymous)
        {
            if (!anonymous)
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    string segments;

                    SEG.NUM = SEGNUM.SETInt(5);

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HBCIVersion == 220)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.ProductId + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.ProductId + "+" + Program.Version + "'";

                        if (Segment.HITANS != null && Segment.HITANS.Substring(0, 3).Equals("6+4"))
                        {
                            segments_ = HKTAN.Init_HKTAN(segments_);
                        }

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    var message  = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
                    var response = FinTSMessage.Send(connectionDetails.Url, message);

                    Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);

                    Segment.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN:", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

                    return(response);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    throw new Exception("Software error", ex);
                }
            }
            else
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation anonymous");

                    string segments;

                    if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments_ =
                            "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + connectionDetails.BlzPrimary + "+" + "9999999999" + "+0+0'" +
                            "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + Program.ProductId + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                        //connectionDetails.UserId = string.Empty;
                        //connectionDetails.Pin = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(4);

                    string message  = FinTSMessageAnonymous.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, SYS.SETVal(0), segments, null, SEG.NUM);
                    string response = FinTSMessage.Send(connectionDetails.Url, message);

                    var messages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);
                    var result   = new HBCIDialogResult(messages, response);
                    if (!result.IsSuccess)
                    {
                        Log.Write("Synchronisation anonymous failed. " + result);
                        return(response);
                    }

                    // Sync OK
                    Log.Write("Synchronisation anonymous ok");

                    /// <summary>
                    /// INI
                    /// </summary>
                    if (connectionDetails.HBCIVersion == 300)
                    {
                        string segments__ =
                            "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" +
                            "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.ProductId + "+" + Program.Version + "'" +
                            "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                        segments = segments__;
                    }
                    else
                    {
                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(5);

                    message  = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
                    response = FinTSMessage.Send(connectionDetails.Url, message);

                    Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response);

                    Segment.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN:", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

                    return(response);
                }
                catch (Exception ex)
                {
                    //Since connectionDetails is a re-usable object, this shouldn't be cleared.
                    //connectionDetails.UserId = string.Empty;
                    //connectionDetails.Pin = null;

                    Log.Write(ex.ToString());

                    DEBUG.Write("Software error: " + ex.ToString());

                    throw new Exception("Software error: " + ex.ToString());
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Transactions in camt053 format
        /// </summary>
        public static async Task <String> Init_HKCAZ(FinTsClient client, string FromDate, string ToDate, string Startpoint, CamtVersion camtVers)
        {
            string segments          = string.Empty;
            var    connectionDetails = client.ConnectionDetails;

            client.SEGNUM = SEGNUM.SETInt(3);

            switch (camtVers)
            {
            case CamtVersion.Camt052:
                Log.Write("Starting job HKCAZ: Request transactions in camt052 format");

                if (string.IsNullOrEmpty(FromDate))
                {
                    if (string.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                client.SEGNUM = SEGNUM.SETInt(3);
                break;

            case CamtVersion.Camt053:
                Log.Write("Starting job HKCAZ: Request transactions in camt053 format");

                if (string.IsNullOrEmpty(FromDate))
                {
                    if (string.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                break;

            default:     // -> Will never happen, only for compiler
                return(string.Empty);
            }

            if (Helper.IsTANRequired("HKCAZ"))
            {
                client.SEGNUM = SEGNUM.SETInt(4);
                segments      = HKTAN.Init_HKTAN(client, segments, "HKCAZ");
            }

            string message  = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS);
            string response = await FinTSMessage.Send(client, message);

            Helper.Parse_Message(client, response);

            return(response);
        }
Exemple #13
0
        /// <summary>
        /// Transactions
        /// </summary>
        public static async Task <String> Init_HKKAZ(FinTsClient client, string FromDate, string ToDate, string Startpoint)
        {
            Log.Write("Starting job HKKAZ: Request transactions");

            var                connectionDetails = client.ConnectionDetails;
            string             segments          = string.Empty;
            AccountInformation activeAccount;

            if (client.activeAccount != null)
            {
                activeAccount = client.activeAccount;
            }
            else
            {
                activeAccount = new AccountInformation()
                {
                    AccountNumber   = connectionDetails.Account,
                    AccountBankCode = connectionDetails.Blz.ToString(),
                    AccountIban     = connectionDetails.Iban,
                    AccountBic      = connectionDetails.Bic,
                }
            };

            client.SEGNUM = SEGNUM.SETInt(3);

            if (string.IsNullOrEmpty(FromDate))
            {
                if (string.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(client.HIKAZS) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(client.HIKAZS) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N++++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N++++" + Startpoint + "'";
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(client.HIKAZS) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(client.HIKAZS) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }
            }

            if (Helper.IsTANRequired("HKKAZ"))
            {
                client.SEGNUM = SEGNUM.SETInt(4);
                segments      = HKTAN.Init_HKTAN(client, segments, "HKKAZ");
            }

            string message  = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS);
            string response = await FinTSMessage.Send(client, message);

            Helper.Parse_Message(client, response);

            return(response);
        }
    }
Exemple #14
0
        /// <summary>
        /// INI
        /// </summary>
        public static bool Init_INI(int BLZ, string URL, int HBCIVersion, string UserID, string PIN, bool Anonymous)
        {
            if (!Anonymous)
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation");

                    string segments;

                    if (HBCIVersion == 220)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + BLZ + "+" + UserID + "+0+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                           "HKSYN:" + SEGNUM.SETVal(5) + ":2+0'";

                        segments = segments_;
                    }
                    else if (HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + BLZ + "+" + UserID + "+0+1'" +
                                           "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                           "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                        segments = segments_;
                    }
                    else
                    {
                        UserID = string.Empty;
                        PIN    = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(5);

                    if (Helper.Parse_Segment(UserID, BLZ, HBCIVersion,
                                             FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), BLZ, UserID,
                                                                                        PIN, SYS.SETVal(0), segments, null, SEG.NUM))))
                    {
                        // Sync OK
                        Log.Write("Synchronisation ok");

                        /// <summary>
                        /// INI
                        /// </summary>
                        if (HBCIVersion == 220)
                        {
                            string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + BLZ + "+" + UserID + "+" + Segment.HISYN + "+1'" +
                                               "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                            segments = segments_;
                        }
                        else if (HBCIVersion == 300)
                        {
                            string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + BLZ + "+" + UserID + "+" + Segment.HISYN + "+1'" +
                                               "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'";

                            segments = segments_;
                        }
                        else
                        {
                            UserID = string.Empty;
                            PIN    = null;

                            Log.Write("HBCI version not supported");

                            throw new Exception("HBCI version not supported");
                        }

                        SEG.NUM = SEGNUM.SETInt(4);

                        if (Helper.Parse_Segment(UserID, BLZ, HBCIVersion,
                                                 FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), BLZ, UserID, PIN, Segment.HISYN,
                                                                                            segments, Segment.HIRMS, SEG.NUM))))
                        {
                            return(true);
                        }
                        else
                        {
                            UserID = string.Empty;
                            PIN    = null;

                            Log.Write("Initialisation failed");

                            throw new Exception("Initialisation failed");
                        }
                    }
                    else
                    {
                        UserID = string.Empty;
                        PIN    = null;

                        Log.Write("Sync failed");

                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    UserID = string.Empty;
                    PIN    = null;

                    Log.Write(ex.ToString());

                    throw new Exception("Software error");
                }
            }
            else
            {
                /// <summary>
                /// Sync
                /// </summary>
                try
                {
                    Log.Write("Starting Synchronisation anonymous");

                    string segments;

                    if (HBCIVersion == 300)
                    {
                        string segments_ = "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + BLZ + "+" + "9999999999" + "+0+0'" +
                                           "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + Program.Buildname + "+" + Program.Version + "'";

                        segments = segments_;
                    }
                    else
                    {
                        UserID = string.Empty;
                        PIN    = null;

                        Log.Write("HBCI version not supported");

                        throw new Exception("HBCI version not supported");
                    }

                    SEG.NUM = SEGNUM.SETInt(4);

                    if (Helper.Parse_Segment(UserID, BLZ, HBCIVersion,
                                             FinTSMessage.Send(URL, FinTSMessageAnonymous.Create(HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), BLZ,
                                                                                                 UserID, PIN, SYS.SETVal(0), segments, null, SEG.NUM))))
                    {
                        // Sync OK
                        Log.Write("Synchronisation anonymous ok");

                        /// <summary>
                        /// INI
                        /// </summary>
                        if (HBCIVersion == 300)
                        {
                            string segments__ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + BLZ + "+" + UserID + "+" + Segment.HISYN + "+1'" +
                                                "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" +
                                                "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'";

                            segments = segments__;
                        }
                        else
                        {
                            UserID = string.Empty;
                            PIN    = null;

                            Log.Write("HBCI version not supported");

                            throw new Exception("HBCI version not supported");
                        }

                        SEG.NUM = SEGNUM.SETInt(5);

                        if (Helper.Parse_Segment(UserID, BLZ, HBCIVersion,
                                                 FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), BLZ, UserID, PIN,
                                                                                            Segment.HISYN, segments, Segment.HIRMS, SEG.NUM))))
                        {
                            return(true);
                        }
                        else
                        {
                            UserID = string.Empty;
                            PIN    = null;

                            Log.Write("Initialisation failed");

                            throw new Exception("Initialisation failed");
                        }
                    }
                    else
                    {
                        UserID = string.Empty;
                        PIN    = null;

                        Log.Write("Sync failed");

                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    UserID = string.Empty;
                    PIN    = null;

                    Log.Write(ex.ToString());

                    if (DEBUG.Enabled)
                    {
                        DEBUG.Write("Software error: " + ex.ToString());
                    }

                    throw new Exception("Software error: " + ex.ToString());
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Transactions
        /// </summary>
        public static async Task <String> Init_HKKAZ(FinTsClient client, string FromDate, string ToDate, string Startpoint)
        {
            Log.Write("Starting job HKKAZ: Request transactions");

            var    connectionDetails = client.ConnectionDetails;
            string segments          = string.Empty;

            client.SEGNUM = SEGNUM.SETInt(3);

            if (string.IsNullOrEmpty(FromDate))
            {
                if (string.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(client.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(client.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N++++" + Startpoint + "'";
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(Startpoint))
                {
                    if (Convert.ToInt16(client.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                }
                else
                {
                    if (Convert.ToInt16(client.HKKAZ) < 7)
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                    else
                    {
                        segments = "HKKAZ:" + client.SEGNUM + ":" + client.HKKAZ + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }
            }

            if (Helper.IsTANRequired("HKKAZ"))
            {
                client.SEGNUM = SEGNUM.SETInt(4);
                segments      = HKTAN.Init_HKTAN(client, segments);
            }

            string message  = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS);
            string response = await FinTSMessage.Send(client, message);

            client.HITAN = Helper.Parse_String(Helper.Parse_String(response, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

            Helper.Parse_Message(client, response);

            return(response);
        }
Exemple #16
0
        /// <summary>
        /// Transactions in camt053 format
        /// </summary>
        public static string Init_HKCAZ(ConnectionDetails connectionDetails, string FromDate, string ToDate, string Startpoint, camtVersion camtVers)
        {
            string segments = string.Empty;

            switch (camtVers)
            {
            case camtVersion.camt052:
                Log.Write("Starting job HKCAZ: Request transactions in camt052 format");

                if (String.IsNullOrEmpty(FromDate))
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt052 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                SEG.NUM = SEGNUM.SETInt(3);

                return(FinTSMessage.Send(connectionDetails.Url, FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)));

            case camtVersion.camt053:
                Log.Write("Starting job HKCAZ: Request transactions in camt053 format");

                if (String.IsNullOrEmpty(FromDate))
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N++++" + Startpoint + "'";
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(Startpoint))
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N+" + FromDate + "+" + ToDate + "'";
                    }
                    else
                    {
                        segments = "HKCAZ:" + SEGNUM.SETVal(3) + ":" + Segment.HKCAZ + "+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + Scheme.camt053 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'";
                    }
                }

                SEG.NUM = SEGNUM.SETInt(3);

                return(FinTSMessage.Send(connectionDetails.Url, FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)));

            default:     // -> Will never happen, only for compiler
                return(string.Empty);
            }
        }