コード例 #1
0
ファイル: Taiwan.cs プロジェクト: ghpdev2019/Rate
        public static DataMeta TaiwanBK_GetRate(this HtmlNodeCollection Node, EnumBank EnumBank)
        {
            DataMeta Table     = new DataMeta();
            RateData TempTable = new RateData();

            Table.CreateDate = MyTimeZone.Today;
            Table.Expire     = MyTimeZone.Today.AddMinutes(Expire);
            Table.Key        = EnumBank;

            //int LIndex = (int)EnumRate.幣別;
            foreach (var item in Node.Select((value, index) => new { index, value }))
            {
                Table.Data.Add(new RateData()
                {
                    Currencty = item.value.SelectNodes(@"//div[@class=""hidden-phone print_show""]")[item.index].InnerText
                                .Replace("\r\n", "")
                                .Replace("              ", "")
                                .Replace(" ", "")
                                .Replace("(", "")
                                .Replace(")", "")
                                .TrimStart(' ').TrimEnd(' ').Replace("\r\n", ""),
                    CashBuying  = item.value.SelectNodes(@"//td[@data-table=""本行現金買入""]")[item.index].InnerText,
                    CashSelling = item.value.SelectNodes(@"//td[@data-table=""本行現金賣出""]")[item.index].InnerText,
                    SpotBuying  = item.value.SelectNodes(@"//td[@data-table=""本行即期買入""]")[item.index].InnerText,
                    SpotSelling = item.value.SelectNodes(@"//td[@data-table=""本行即期賣出""]")[item.index].InnerText
                });
            }
            return(Table);
        }
コード例 #2
0
 public BankAccountBuilder()
 {
     this._id            = default(int);
     this._bank          = EnumBank.BANCO_BRASIL;
     this._agencyNumber  = string.Empty;
     this._agencyDigit   = string.Empty;;
     this._accountNumber = string.Empty;
     this._accountDigit  = string.Empty;
     this._type          = EnumBankAccountType.CONTA_CORRENTE;
     this._amount        = default(double);
 }
コード例 #3
0
 public BankAccount(EnumBank bank, string agencyNumber, string agencyDigit,
                    string accountNumer, string accountDigit, EnumBankAccountType type,
                    double amount)
 {
     this.Bank          = bank;
     this.AccountDigit  = accountDigit;
     this.AccountNumber = accountNumer;
     this.AgencyDigit   = agencyDigit;
     this.AgencyNumber  = agencyNumber;
     this.Type          = type;
     this.Amount        = amount;
 }
コード例 #4
0
        private static DataMeta XPathExpression(this string BankUrl, EnumBank EnumBank)
        {
            var HtmlNode = BankUrl.GetHtmlNode();

            var Result =
                EnumBank.台新銀行 == EnumBank?
                HtmlNode.SelectNodes(Taishin.XPathExpression).Taishin_GetRate(EnumBank) :
                    EnumBank.臺灣銀行 == EnumBank?
                    HtmlNode.SelectNodes(Taiwan.XPathExpression).TaiwanBK_GetRate(EnumBank) :
                        new DataMeta();

            return(Result);
        }
コード例 #5
0
ファイル: TaiShin.cs プロジェクト: hauserJr/Rate
        public static DataMeta Taishin_GetRate(this HtmlNodeCollection Node, EnumBank EnumBank)
        {
            DataMeta Table     = new DataMeta();
            RateData TempTable = new RateData();

            Table.CreateDate = DateTime.Now;
            Table.Expire     = DateTime.Now.AddMinutes(Expire);
            Table.Key        = EnumBank;

            int LIndex = (int)EnumRate.幣別;

            foreach (var item in Node)
            {
                if (LIndex == (int)EnumRate.幣別)
                {
                    TempTable = new RateData();
                }
                switch (LIndex)
                {
                case (int)EnumRate.幣別:
                    TempTable.Currencty = item.InnerText;
                    break;

                case (int)EnumRate.即期買入:
                    TempTable.SpotBuying = item.InnerText;
                    break;

                case (int)EnumRate.即期賣出:
                    TempTable.SpotSelling = item.InnerText;
                    break;

                case (int)EnumRate.現鈔買入:
                    TempTable.CashBuying = item.InnerText;
                    break;

                case (int)EnumRate.現鈔賣出:
                    TempTable.CashSelling = item.InnerText;
                    break;
                }
                if (LIndex == (int)EnumRate.現鈔賣出)
                {
                    Table.Data.Add(TempTable);
                }
                LIndex = LIndex == (int)EnumRate.現鈔賣出 ? (int)EnumRate.幣別 : LIndex + 1;
            }
            return(Table);
        }
コード例 #6
0
 /// <summary>
 /// 取得匯率
 /// </summary>
 /// <param name="BankUrl">匯率URL</param>
 /// <param name="EnumBank">銀行類別</param>
 /// <returns></returns>
 public static DataMeta GetRate(EnumBank EnumBank)
 {
     try
     {
         var IsSearch = Table.Expires(EnumBank);
         if (IsSearch)
         {
             var Result = GetRateUrl(EnumBank).XPathExpression(EnumBank);
             Table.Add(Result);
         }
     }
     catch
     {
         return(null);
     }
     return(Table.Where(o => o.Key == EnumBank).FirstOrDefault());
 }
コード例 #7
0
        /// <summary>
        /// 檢視資料是否過期
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="EnumBank"></param>
        /// <returns></returns>
        public static bool Expires(this List <DataMeta> Data, EnumBank EnumBank)
        {
            var Result = Data.Where(o => o.Key == EnumBank).FirstOrDefault();

            if (Result == null)
            {
                return(true);
            }

            if (Result.Expire <= MyTimeZone.Today)
            {
                Data.Remove(Result);
                return(true);
            }

            return(false);
        }
コード例 #8
0
        private static string GetRateUrl(this EnumBank EnumBank)
        {
            string UrlStr = string.Empty;

            switch (EnumBank)
            {
            case EnumBank.臺灣銀行:
                UrlStr = @"https://rate.bot.com.tw/xrt/all/day";
                break;

            case EnumBank.台新銀行:
                UrlStr = @"https://www.taishinbank.com.tw/TS/TS06/TS0605/TS060502/index.htm?urlPath1=TS02&urlPath2=TS0202";
                break;

            default:
                EnumBank = EnumBank.臺灣銀行;
                UrlStr   = @"https://rate.bot.com.tw/xrt/all/day";
                break;
            }
            return(UrlStr);
        }
コード例 #9
0
 public BankAccountBuilder WithBank(EnumBank bank)
 {
     this._bank = bank;
     return(this);
 }