public BankAccountHistoryClaAccess(BankAccountHistory bankAccountHistory)
 {
     BankAccountHistoryId = bankAccountHistory.BankAccountHistoryId;
     BankAccount = BankAccountDetails.GetModelView(bankAccountHistory.BankAccount);
     Date = bankAccountHistory.Date;
     Ammount = bankAccountHistory.Ammount;
     AmmountView = bankAccountHistory.AmmountView;
     Currency = bankAccountHistory.Currency;
     Exchange = bankAccountHistory.Exchange;
     BankCode = bankAccountHistory.BankCode;
     BankName = bankAccountHistory.BankName;
     Ks = bankAccountHistory.Ks;
     Vs = bankAccountHistory.Vs;
     Ss = bankAccountHistory.Ss;
     Note = bankAccountHistory.Note;
 }
        public static BankAccountHistoryIndex[] GetModelView(BankAccountHistory[] bankAccountHistories)
        {
            if (bankAccountHistories == null)
                return null;

            BankAccountHistoryIndex[] accountHistoryIndices = bankAccountHistories.Select(bah => new BankAccountHistoryIndex(bah)).ToArray();
            return accountHistoryIndices;
        }
 public BankAccountHistoryIndex(BankAccountHistory bankAccountHistory)
 {
     BankAccountHistoryId = bankAccountHistory.BankAccountHistoryId;
     BankAccount = BankAccountDetails.GetModelView(bankAccountHistory.BankAccount);
     Date = bankAccountHistory.Date;
     Ammount = bankAccountHistory.Ammount;
     Currency = bankAccountHistory.Currency;
     Vs = bankAccountHistory.Vs;
     Ss = bankAccountHistory.Ss;
 }
        public static BankAccountHistoryEdit GetModelView(BankAccountHistory bankAccountHistory)
        {
            if (bankAccountHistory == null)
                return null;

            var bankAccountHistoryEdit = new BankAccountHistoryEdit(bankAccountHistory);
            return bankAccountHistoryEdit;
        }
        public static BankAccountHistoryDetails GetModelView(BankAccountHistory bankAccountHistory)
        {
            if (bankAccountHistory == null)
                return null;

            var bankAccountHistoryDetails = new BankAccountHistoryDetails(bankAccountHistory);
            return bankAccountHistoryDetails;
        }
        public static BankAccountHistoryDelete GetModelView(BankAccountHistory bankAccountHistory)
        {
            if (bankAccountHistory == null)
                return null;

            var bankAccountHistoryDelete = new BankAccountHistoryDelete(bankAccountHistory);
            return bankAccountHistoryDelete;
        }
 public BankAccountHistoryDelete(BankAccountHistory bankAccountHistory)
 {
     Date = bankAccountHistory.Date;
     Ammount = bankAccountHistory.Ammount;
     Currency = bankAccountHistory.Currency;
     Exchange = bankAccountHistory.Exchange;
     BankCode = bankAccountHistory.BankCode;
     BankName = bankAccountHistory.BankName;
     Ks = bankAccountHistory.Ks;
     Vs = bankAccountHistory.Vs;
     Ss = bankAccountHistory.Ss;
     Note = bankAccountHistory.Note;
 }
        public static BankAccountHistoryClaAccess GetModelView(BankAccountHistory bankAccountHistory)
        {
            if (bankAccountHistory == null)
                return null;

            var bankAccountHistoryClaAccess = new BankAccountHistoryClaAccess(bankAccountHistory);
            return bankAccountHistoryClaAccess;
        }
 private bool IsAccess(BankAccountHistory newBankAccountHistory)
 {
     return newBankAccountHistory != null;
 }
 private bool IsAccess(Meeting meeting, BankAccountHistory bankAccountHistory)
 {
     bool isAccess = IsAccess(meeting);
     isAccess &= bankAccountHistory != null;
     return isAccess;
 }
Esempio n. 11
0
        /// <summary>
        /// Processes the transaction request.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="bankAccountId">The bank account id.</param>
        /// <param name="bankAccountHistories">The bank account histories.</param>
        /// <param name="lastDownloadId">The last download id.</param>
        /// <returns>HttpStatusCode.</returns>
        /// <exception cref="System.Exception"></exception>
        public static HttpStatusCode ProcessTransactionRequest(string url, int bankAccountId, out BankAccountHistory[] bankAccountHistories, out Int64? lastDownloadId)
        {
            bankAccountHistories = new BankAccountHistory[0];
            lastDownloadId = null;

            try
            {
                InternetResponse internetResponse = InternetRequest.SendRequest(url, InternetRequestType.ProcessXDocument);
                if (internetResponse.XDocument == null)
                    return internetResponse.HttpStatusCode;

                bankAccountHistories = internetResponse.XDocument
                    .Descendants("AccountStatement")
                    .Descendants("TransactionList")
                    .Descendants("Transaction")
                    .Select(t =>
                    {
                        XElement transactionId = t.Element("column_22");
                        XElement date = t.Element("column_0");
                        XElement ammount = t.Element("column_1");
                        XElement currency = t.Element("column_14");

                        if (transactionId == null || date == null || ammount == null || currency == null)
                            throw new Exception("Communication XML structure corrupted.");

                        var bankAccountHistory = new BankAccountHistory
                        {
                            BankAccountId = bankAccountId,
                            TransactionId = Convert.ToInt64(transactionId.Value),
                            Date = DateTime.ParseExact(date.Value, "yyyy-MM-ddzzz", CultureInfo.InvariantCulture),
                            Ammount = Convert.ToDecimal(ammount.Value, new CultureInfo("en-US")),
                            Currency = currency.Value
                        };

                        XElement xElementOptional = t.Element("column_2");
                        if (xElementOptional != null)
                            bankAccountHistory.Exchange = xElementOptional.Value;

                        xElementOptional = t.Element("column_3");
                        if (xElementOptional != null)
                            bankAccountHistory.BankCode = xElementOptional.Value;

                        xElementOptional = t.Element("column_12");
                        if (xElementOptional != null)
                            bankAccountHistory.BankName = xElementOptional.Value;

                        xElementOptional = t.Element("column_4");
                        int tempNumber;
                        if (xElementOptional != null && Int32.TryParse(xElementOptional.Value, out tempNumber))
                            bankAccountHistory.Ks = tempNumber;

                        xElementOptional = t.Element("column_5");
                        Int64 tempDwordNumber;
                        if (xElementOptional != null && Int64.TryParse(xElementOptional.Value, out tempDwordNumber))
                            bankAccountHistory.Vs = tempDwordNumber;

                        xElementOptional = t.Element("column_6");
                        if (xElementOptional != null && Int32.TryParse(xElementOptional.Value, out tempNumber))
                            bankAccountHistory.Ss = tempNumber;

                        xElementOptional = t.Element("column_16");
                        if (xElementOptional != null)
                            bankAccountHistory.Note = xElementOptional.Value;

                        return bankAccountHistory;
                    }).ToArray();

                long[] lastDownloadIds;
                if (bankAccountHistories.Length == 0)
                {
                    lastDownloadIds = internetResponse.XDocument
                    .Descendants("AccountStatement")
                    .Descendants("Info")
                    .Select(t =>
                    {
                        XElement idLastDownload = t.Element("idLastDownload");

                        if (idLastDownload == null)
                            throw new Exception("Communication XML structure corrupted.");

                        return Convert.ToInt64(idLastDownload.Value);
                    }).ToArray();
                }
                else
                {
                    lastDownloadIds = internetResponse.XDocument
                    .Descendants("AccountStatement")
                    .Descendants("Info")
                    .Select(t =>
                    {
                        XElement idTo = t.Element("idTo");

                        if (idTo == null)
                            throw new Exception("Communication XML structure corrupted.");

                        return Convert.ToInt64(idTo.Value);
                    }).ToArray();
                }

                if (lastDownloadIds.Length != 1)
                    return HttpStatusCode.ServiceUnavailable;

                lastDownloadId = lastDownloadIds[0];

                return HttpStatusCode.OK;
            }
            catch (Exception e)
            {
                Logger.SetLog(e, new Logger.LogParameter { AdditionalMessage = String.Format("Url: {0}", url) });
                return HttpStatusCode.Conflict;
            }
        }