private void DoRollBack(Dictionary <BE.UserBet, BE.BaseWalletResponseData> userBets) { List <BE.BaseRequest> operations = new List <BE.BaseRequest>(); BE.BaseRequest req = null; foreach (var userbet in userBets) { if (userbet.Key.LinkedCode == null || (userbet.Key.LinkedCode != null && userbet.Key.Amount > 0)) { req = new BE.BaseRequest(); req.SessionToken = userbet.Value.SessionToken; req.UserUID = userbet.Value.UserUID; req.TransactionID = userbet.Value.TransactionID; req.Amount = userbet.Key.Amount; bool responseOK = false; int i = 1; while (responseOK || i > 3) { var resp = UserWalletFacade.ProcessRollback(req); if (resp.Status.Equals(BE.ResponseStatus.OK)) { responseOK = true; } if (!responseOK) { Thread.Sleep(30000); } } } } }
public List <SportDTO> GetActiveSports(BE.BaseRequest req) { SportEventsAccess seax = new SportEventsAccess(); var successLogin = true; if (!string.IsNullOrEmpty(req.LaunchToken) && string.IsNullOrEmpty(RequestContextHelper.SessionToken)) { var response = UserWalletFacade.ProcessLogin(req); if (response.Status.Equals(BE.ResponseStatus.OK)) { //RequestContextHelper.SessionToken = response.GetData().SessionToken; //RequestContextHelper.UserBalance = response.GetData().Balance; //RequestContextHelper.UserName = response.GetData().NickName; UserAccess ua = new UserAccess(); BE.User user = new BE.User(); user.LaunchToken = req.LaunchToken; user.SessionToken = response.GetData().SessionToken; user.UID = response.GetData().UserUID; user.Balance = response.GetData().Balance; user.NickName = response.GetData().NickName; ua.LoginUser(user); this.UpdateCurrentUserData(user); } else { successLogin = false; RequestContextHelper.LastError = response.Message; } } if (successLogin) { List <BE.Sport> sports = seax.GetActiveSports(); List <SportDTO> sportsDto = new List <SportDTO>(); string lastCode = null, lastRegion = null, lastCountry = null; foreach (var sport in sports.OrderBy(s => s.Code).ThenBy(s => s.RegionName).ThenBy(s => s.CountryName).ThenBy(s => s.Name)) { if (lastCode != sport.Code) { lastCode = sport.Code; SportDTO viewSport = new SportDTO(); List <RegionDTO> regions = new List <RegionDTO>(); viewSport.Code = lastCode; viewSport.Name = sport.Name; foreach (var region in sports.Where(s => s.Code == lastCode).OrderBy(s => s.RegionName).ThenBy(s => s.CountryName).ThenBy(s => s.Name)) { if (lastRegion != region.RegionID) { lastRegion = region.RegionID; RegionDTO newRegion = new RegionDTO(); List <CountryDTO> countries = new List <CountryDTO>(); newRegion.Name = region.RegionName; newRegion.Code = region.RegionID; #region paises foreach (var pais in sports.Where(s => s.Code == lastCode && s.RegionID == lastRegion).OrderBy(s => s.CountryName).ThenBy(s => s.TournamentName)) { if (lastCountry != pais.Country) { CountryDTO country = new CountryDTO(); List <LeagueDTO> leagues = new List <LeagueDTO>(); lastCountry = pais.Country; country.Code = pais.Country; country.Flag = pais.MenuFlagKey; country.Name = pais.CountryName; #region Ligas foreach (var liga in sports.Where(s => s.Code == lastCode && s.RegionID == lastRegion && s.Country == lastCountry).OrderBy(s => s.TournamentName)) { LeagueDTO league = new LeagueDTO(); league.Code = liga.TournamentID; league.Name = liga.TournamentName == "" ? liga.InternalName : liga.TournamentName; leagues.Add(league); } #endregion country.Leagues = leagues; countries.Add(country); } } #endregion newRegion.Countries = countries; regions.Add(newRegion); } } viewSport.Regions = regions; sportsDto.Add(viewSport); } } return(sportsDto); } return(new List <SportDTO>()); }