private static void AddNewSportFilter(ICollection <SportFilter> filters, ESport newSport) { if (filters.FirstOrDefault <SportFilter>((Func <SportFilter, bool>)(x => x.Sport == newSport)) != null) { return; } filters.Add(SportFilter.GetSportFilter(newSport)); }
public static SportFilter GetSportFilter(ESport sport) { if (SportFilter._allsports.ContainsKey(sport)) { return(SportFilter._allsports[sport]); } throw new ArgumentException(string.Format("такой спорт {0} нам не извесен", (object)sport)); }
private static void AddNewSportInSetting(Settings settings, ESport newSport) { SettingVersionUpdater.AddNewBreackedSportFilter((ICollection <BreackedFilter>)settings.BreackedSport, newSport); SettingVersionUpdater.AddNewSportFilter((ICollection <SportFilter>)settings.MainFilters, newSport); foreach (Bookmaker bookmakers in settings.UserSettings.BookmakersList) { SettingVersionUpdater.AddNewSportFilter((ICollection <SportFilter>)bookmakers.SportFilters, newSport); } }
// 取得 Proxy 設定 public static List<string> GetProxy(ESport sportType, string section = null) { string xmlFile = string.Format(@"{0}\{1}.xml", Application.StartupPath, System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)); // 取得資料 if (System.IO.File.Exists(xmlFile)) { bool isSportType = false; try { if (sportType != ESport.None && string.IsNullOrEmpty(section)) { isSportType = true; section = "Section"; } if (string.IsNullOrEmpty(section)) return null; XDocument xDoc = XDocument.Load(xmlFile); if (xDoc != null) { foreach (XElement xelem in xDoc.Descendants(section)) { string sports = null, proxy = null, sDefault = null; if (xelem.Element("Proxy") != null) proxy = xelem.Element("Proxy").Value.Trim(); if (xelem.Element("default") != null) sDefault = xelem.Element("default").Value.Trim(); if (isSportType) { if (xelem.Element("Sports") != null) sports = xelem.Element("Sports").Value; if (string.IsNullOrEmpty(proxy) || string.IsNullOrEmpty(sports)) continue; foreach (string sport in sports.Split(',')) { if (Program.GetSportType(sport) == sportType) return GetProxyList(proxy, sDefault); } } else { if (!string.IsNullOrEmpty(proxy)) return GetProxyList(proxy, sDefault); } } } } catch { } } return null; }
private static void AddNewBreackedSportFilter( ICollection <BreackedFilter> filters, ESport newSport) { if (filters.FirstOrDefault <BreackedFilter>((Func <BreackedFilter, bool>)(x => x.Id == newSport.ToServerSportId())) != null) { return; } filters.Add(BreackedFilter.GetFilterForSport(newSport)); }
public LogFile(ESport? tmp = null, string fileType = null) { if(tmp != null) sport = (ESport)tmp; if (!string.IsNullOrEmpty(fileType)) FileType = fileType; if(string.IsNullOrEmpty(FileType)) FileType = "mainfile"; }
public static BreackedFilter GetFilterForSport(ESport sport) { if (!EnumsHelper.GetAllSports().ContainsKey(sport)) { throw new ArgumentException(string.Format("Нет такого спорта {0}", (object)sport)); } return(new BreackedFilter() { Id = sport.ToServerSportId(), Name = sport.ToNormalString() }); }
/// <summary> /// 建立。 /// </summary> /// <param name="sport">運動類型</param> public BasicFollow(ESport sport) { // 設定 this.Sport = sport; this.GameData = new Dictionary<string, BasicInfo>(); this.OldData = new Dictionary<string, BasicInfo>(); this.UpdataWriteLine = true; // 建立記錄檔操作 this.Logs = new LogFile(sport); this.FileWrite = true; this.UrlSetting = new UrlSetting(); //读取来源网 this.sWebUrl = UrlSetting.GetUrl(sport); }
private void CalculateSumWin() { this.TotalWin = this.CurrentForks.Select <ForkHistory, Decimal>((Func <ForkHistory, Decimal>)(x => x.TotalWinRub)).Sum(); List <Decimal> list1 = this.CurrentForks.Select <ForkHistory, Decimal>((Func <ForkHistory, Decimal>)(x => x.Profit)).ToList <Decimal>(); this.TotalPercent = list1.Count <= 0 ? Decimal.Zero : list1.Sum() / (Decimal)list1.Count; List <ESport> list2 = Enum.GetValues(typeof(ESport)).Cast <ESport>().ToList <ESport>(); List <SportWinWrapper> sportWinWrapperList = new List <SportWinWrapper>(); foreach (ESport esport in list2) { ESport sport = esport; Decimal totalWin = this.CurrentForks.Where <ForkHistory>((Func <ForkHistory, bool>)(x => x.Sport == sport)).Select <ForkHistory, Decimal>((Func <ForkHistory, Decimal>)(x => x.TotalWinRub)).Sum(); sportWinWrapperList.Add(new SportWinWrapper(sport, totalWin)); } this.SportsWin = sportWinWrapperList; }
public static string GetUrl(ESport sportType, string key = "Url", string section = "Section") { string xmlFile = string.Format(@"{0}\{1}.xml", Application.StartupPath, System.IO.Path.GetFileNameWithoutExtension(Application.ExecutablePath)); // 取得資料 if (System.IO.File.Exists(xmlFile)) { try { if (sportType == ESport.None) return null; if (string.IsNullOrWhiteSpace(section)) return null; XDocument xDoc = XDocument.Load(xmlFile); if (xDoc != null) { foreach (XElement xelem in xDoc.Descendants(section)) { string sports = null, url = null; if (xelem.Element(key) != null) url = xelem.Element(key).Value.Trim(); if (xelem.Element("Sports") != null) sports = xelem.Element("Sports").Value; if (string.IsNullOrWhiteSpace(url) || string.IsNullOrWhiteSpace(sports)) continue; foreach (string sport in sports.Split(',')) { if (Program.GetSportType(sport) == sportType) return url; } } } } catch { } } return null; }
public BasicDownload(ESport sport, string url, Encoding encoding, string fileType = null) { this.downloadTimer = new Timer(); this.downloadTimer.Interval = timeoutValue; this.downloadTimer.Tick += TimerEventProcessor; this.Logs = new LogFile(sport, fileType); // 建立 this.Sport = sport; this.Uri = new Uri(url); if (this.Uri.ToString().IndexOf("bet007.com") != -1)//奧訊來源 { this.UrlList = UrlSetting.GetBet007Url(); this.ProxyList = ProxySetting.GetBet007Proxy(); // 取得奧訊代理 } if (this.Uri.ToString().IndexOf("d.asiascore.com") != -1)//asiascore來源 this.ProxyList = ProxySetting.GetAsiascoreProxy(); // 取得asiascore代理 if (this.Uri.ToString().IndexOf("www8.spbo1.com") != -1 || this.Uri.ToString().IndexOf("www8.spbo.com") != -1)//足球走勢來源 this.ProxyList = ProxySetting.GetSpbo1Proxy(); // 取得足球走勢代理 if (this.ProxyList == null || this.ProxyList.Count <=0) this.ProxyList = ProxySetting.GetProxy(sport); // 取得代理 this.Client = new WebClientEx(); //this.Client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); this.Client.Encoding = encoding; this.Client.DownloadDataCompleted += this.Client_DownloadDataCompleted; this.Client.DownloadStringCompleted += this.Client_DownloadStringCompleted; // 建立記錄檔操作 this.FileWrite = true; //奧訊代理 使用順位 ProxyUsing = 0;//預設值0 }
public static string ToNormalString(this ESport sport) { switch (sport) { case ESport.Football: return("Футбол"); case ESport.Tennis: return("Теннис"); case ESport.Hockey: return("Хоккей"); case ESport.Basketball: return("Баскетбол"); case ESport.VoleyBall: return("Волейбол"); case ESport.Handball: return("Гандбол"); case ESport.TableTennis: return("Настольный теннис"); case ESport.Futsal: return("Футзал"); case ESport.Badminton: return("Бадминтон"); case ESport.Baseball: return("Бейсбол"); default: throw new ArgumentOutOfRangeException(nameof(sport), (object)sport, (string)null); } }
public static string GetSvgImagePath(this ESport sport) { switch (sport) { case ESport.Football: return("/ForksEvo;component/Images/sportsicon/svg/soccer.svg"); case ESport.Tennis: return("/ForksEvo;component/Images/sportsicon/svg/tennis2.svg"); case ESport.Hockey: return("/ForksEvo;component/Images/sportsicon/svg/hockey.svg"); case ESport.Basketball: return("/ForksEvo;component/Images/sportsicon/svg/basketball.svg"); case ESport.VoleyBall: return("/ForksEvo;component/Images/sportsicon/svg/volleyball.svg"); case ESport.Handball: return("/ForksEvo;component/Images/sportsicon/svg/handball.svg"); case ESport.TableTennis: return("/ForksEvo;component/Images/sportsicon/svg/tableTennis.svg"); case ESport.Futsal: return("/ForksEvo;component/Images/sportsicon/svg/futsal.svg"); case ESport.Badminton: return("/ForksEvo;component/Images/sportsicon/svg/badminton.svg"); case ESport.Baseball: return("/ForksEvo;component/Images/sportsicon/svg/baseball.svg"); default: throw new ArgumentOutOfRangeException(nameof(sport), (object)sport, (string)null); } }
// 建構式 public BkBFDownload(ESport sport, DateTime gameDate, string url, Encoding encoding, long ticks, bool IsUpdateData = false, string fileType = null) : base(sport, url, encoding, fileType) { this.GameDate = gameDate; this.IsUpdateData = IsUpdateData; this.ticks = ticks; }
public BasicDownload(ESport sport, string url, string fileType) : this(sport, url, Encoding.UTF8, fileType) { }
public BasicDownload(ESport sport, string url) : this(sport, url, Encoding.UTF8) { }
public BasicBasketball(ESport sport) : base(sport) { this.UpdataWriteLine = true; }
// 建構式 public IHDownload(ESport sport, DateTime gameDate, string url, string fileType) : base(sport, url, fileType) { this.GameDate = gameDate; }
// 建構式 public BkOSDownload(ESport sport, DateTime gameDate, string url, Encoding encoding, string fileType, int updateSecond = 60) : base(sport, url, encoding, fileType) { this.UpdateSecond = updateSecond; this.GameDate = gameDate; }
public static int ConvertToServerBetId(ESport sport, EBetType betType) { return(EnumsHelper._correctSportValue[sport][betType]); }
public static int ToServerSportId(this ESport sport) { return((int)(sport - 100)); }
public BasicIceHockey(ESport sport) : base(sport) { this.UpdataWriteLine = true; }
public BasicFB(ESport sport) : base(sport) { this.UpdataWriteLine = false; }
public BasicFbAf(ESport sport) : base(sport) { this.UpdataWriteLine = true; }