public GameRecord() { InitializeComponent(); rbtLists.IsChecked = true; datePickerStart.SelectedDate = DateTime.Now; datePickerEnd.SelectedDate = DateTime.Now; BindedLst = new List<long>(); RPageSum = new StatReport(); RPageSum.UserID = "本页合计"; RTotalSum = new StatReport(); RTotalSum.UserID = "总合计"; DPageSum = new ReportDetail(); DPageSum.RecordID = "本页合计"; DPageSum.IsWin = -1; DPageSum.Direction = -1; DPageSum.ResultStatus = -1; DTotalSum = new ReportDetail(); DTotalSum.RecordID = "总合计"; DTotalSum.IsWin = -1; DTotalSum.Direction = -1; DTotalSum.ResultStatus = -1; srv_GameRecord = WcfProxy.GetProxy; srv_GameRecord.GetStatReportCompleted += new EventHandler<GetStatReportCompletedEventArgs>(srv_GameRecord_GetStatReportCompleted); srv_GameRecord.GetReportDetailCompleted += new EventHandler<GetReportDetailCompletedEventArgs>(srv_GameRecord_GetReportDetailCompleted); TextBlock txtb = new TextBlock() { Text = "本级", Style = Resources["TextBlockStyle1"] as Style, Cursor = Cursors.Hand }; txtb.Tag = user.ID; BindedLst.Add(user.ID); txtb.MouseLeftButtonDown += new MouseButtonEventHandler(txtb_MouseLeftButtonDown); NavMenu.Children.Add(txtb); BindReportDetailList(user.UserId); }
private void srv_GameRecord_GetStatReportCompleted(object sender, GetStatReportCompletedEventArgs e) { obStatReport = e.Result; gridLoading.Visibility = Visibility.Collapsed; currentPos = 0; if (e.Result.Count != 0) { RTotalSum = new StatReport(); RTotalSum.UserID = "总合计"; RTotalSum.BetMoney = obStatReport.Sum(p => p.BetMoney); RTotalSum.WinMoney = obStatReport.Sum(p => p.WinMoney); if (e.Result.Count < 18) { obStatReport = e.Result; RPageSum = new StatReport(); RPageSum.UserID = "本页合计"; RPageSum.BetMoney = obStatReport.Take(18).Sum(p => p.BetMoney); RPageSum.WinMoney = obStatReport.Take(18).Sum(p => p.WinMoney); obStatReport.Add(RPageSum); obStatReport.Add(RTotalSum); currentPos = 0; PagedCollectionView pageView = new PagedCollectionView(obStatReport); pageView.PageSize = 20; dpList.PageSize = 20; dpList.Source = pageView; dgList.ItemsSource = pageView; } else { int page = int.Parse(Math.Ceiling(double.Parse(e.Result.Count.ToString()) / 18).ToString()); for (int i = 0; i < page; i++) { int stayNum = e.Result.Count - (i * 20); if (stayNum > 18) { RPageSum = new StatReport(); RPageSum.UserID = "本页合计"; RPageSum.BetMoney = obStatReport.Skip(i * 20).Take(18).Sum(p => p.BetMoney); RPageSum.WinMoney = obStatReport.Skip(i * 20).Take(18).Sum(p => p.WinMoney); obStatReport.Insert(i * 20 + 18, RPageSum); obStatReport.Insert(i * 20 + 19, RTotalSum); } else { RPageSum = new StatReport(); RPageSum.UserID = "本页合计"; RPageSum.BetMoney = obStatReport.Skip(i * 20).Take(stayNum).Sum(p => p.BetMoney); RPageSum.WinMoney = obStatReport.Skip(i * 20).Take(stayNum).Sum(p => p.WinMoney); obStatReport.Insert(i * 20 + stayNum, RPageSum); obStatReport.Insert(i * 20 + stayNum + 1, RTotalSum); } } currentPos = 0; PagedCollectionView pageView = new PagedCollectionView(obStatReport); pageView.PageSize = 20; dpList.PageSize = 20; dpList.Source = pageView; dgList.ItemsSource = pageView; } } }
public Task <StatReport> GetAsync(string selectedCountry, string selectedCountryCode, string ip) { dynamic country = new System.Dynamic.ExpandoObject(); if (selectedCountry != null) { country.label = selectedCountry; country.code = selectedCountryCode; } else { country = this.getVountryFromIp(ip); } if (country.label == "United States of America" || country.label == "United States") { country.label = "US"; } if (country.label == "Russian Federation") { country.label = "Russia"; } if (country.label == "Palestine, State of") { country.label = "occupied Palestinian territory"; } if (country.label == "Iran, Islamic Republic of") { country.label = "Iran"; } if (country.label == "Macedonia, the Former Yugoslav Republic of") { country.label = "North Macedonia"; } dynamic content = this.getJson($"https://covid19-api.weedmark.systems/api/v1/stats?country={country.label}"); List <StatReport> items = content.data.covid19Stats.ToObject <List <StatReport> >(); int sumConfirmed = 0; int sumRecovered = 0; int sumDeaths = 0; bool contains = (country.label).Contains(items[0].Country) || (country.label).IndexOf(items[0].Country) > -1; if (contains) { foreach (StatReport el in items) { sumConfirmed += el.Confirmed; sumRecovered += el.Recovered; sumDeaths += el.Deaths; } } StatReport report = new StatReport(); report.Deaths = sumDeaths; report.Confirmed = sumConfirmed; report.Recovered = sumRecovered; report.lastUpdate = content.data.lastChecked; report.Country = country; return(Task.FromResult(report)); }