public GenericListResponse <Producto> GetProduct(string nombre, string SKU) { GenericListResponse <Producto> response; BPM_SIEEntities BD = new BPM_SIEEntities(); try { var registro = BD.Producto.Where(x => x.nombre.Equals(nombre, StringComparison.CurrentCultureIgnoreCase) || x.SKU.Equals(SKU, StringComparison.CurrentCultureIgnoreCase)); response = new GenericListResponse <Producto> { Status = new ResponseStatus { HttpCode = HttpStatusCode.OK }, Items = registro.ToList() }; } catch (Exception ex) { response = new GenericListResponse <Producto> { Status = new ResponseStatus { HttpCode = HttpStatusCode.InternalServerError, Message = ex.Message }, Items = new List <Producto>() }; } return(response); }
private void SyncBlackListWithDedimania(object state) { RunCatchLog(() => { GenericListResponse <LoginResponse> getBlackListResponse = Context.RPCClient.Methods.GetBlackList(10000, 0); if (getBlackListResponse.Erroneous) { Logger.ErrorToUI(string.Format("Error while calling GetBlackList: {0}({1})", getBlackListResponse.Fault.FaultMessage, getBlackListResponse.Fault.FaultCode)); return; } HashSet <string> localBlackListLogins = new HashSet <string>(getBlackListResponse.Value.ConvertAll(x => x.Login)); HashSet <string> dedimaniaBlackListLogins = BlackListReader.GetBlackListedLogins(new Uri(Settings.DedimaniaBlackListUrl)); Logger.Debug(string.Format("Found {0} login(s) in local blacklist and {1} login(s) in dedimania blacklist.", localBlackListLogins.Count, dedimaniaBlackListLogins.Count)); dedimaniaBlackListLogins.ExceptWith(localBlackListLogins); Logger.Debug(string.Format("{0} login(s) in will be added to blacklist.", dedimaniaBlackListLogins.Count)); foreach (string login in dedimaniaBlackListLogins) { GenericResponse <bool> blackListResponse = Context.RPCClient.Methods.BlackList(login); if (blackListResponse.Erroneous) { Logger.Error(string.Format("Error while calling BlackList for login {0}: {1}({2})", login, blackListResponse.Fault.FaultMessage, blackListResponse.Fault.FaultCode)); continue; } if (blackListResponse.Value) { Logger.Debug(string.Format("Added login {0} to blacklist.", login)); } else { Logger.Debug(string.Format("Could not add login {0} to blacklist.", login)); } } if (dedimaniaBlackListLogins.Count > 0) { Logger.InfoToUI(string.Format("Added {0} login(s) from dedimania blacklist to local blacklist.", dedimaniaBlackListLogins.Count)); GenericResponse <bool> saveBlackListResponse = Context.RPCClient.Methods.SaveBlackList("blacklist.txt"); if (saveBlackListResponse.Erroneous) { Logger.Error(string.Format("Error while calling SaveBlackList: {0}({1})", saveBlackListResponse.Fault.FaultMessage, saveBlackListResponse.Fault.FaultCode)); return; } if (!saveBlackListResponse.Value) { Logger.Error("Could not save blacklist."); } } }, "Errror in SyncBlackListWithDedimania", true); }
private HashSet <string> GetBanList() { GenericListResponse <BanEntry> banListResponse = Context.RPCClient.Methods.GetBanList(1000, 0); HashSet <string> banList = new HashSet <string>(); if (!banListResponse.Erroneous) { banList = new HashSet <string>(banListResponse.Value.ConvertAll(x => x.Login)); } return(banList); }
private HashSet <string> GetGuestList() { GenericListResponse <LoginResponse> guestListResponse = Context.RPCClient.Methods.GetGuestList(1000, 0); HashSet <string> guestList = new HashSet <string>(); if (!guestListResponse.Erroneous) { guestList = new HashSet <string>(guestListResponse.Value.ConvertAll(x => x.Login)); } return(guestList); }
private List <string> GetUndrivenChallengeFilenames(HashSet <string> uniqueIDs) { GenericListResponse <ChallengeListSingleInfo> getChallGenericListResponse = Context.RPCClient.Methods.GetChallengeList(); if (getChallGenericListResponse.Erroneous) { return(new List <string>()); } List <ChallengeListSingleInfo> undrivenTracks = getChallGenericListResponse.Value.FindAll(c => !uniqueIDs.Contains(c.UId)); return(undrivenTracks.ConvertAll(c => c.FileName)); }
protected List <ChallengeListSingleInfo> GetChallengeList() { GenericListResponse <ChallengeListSingleInfo> challengeResponse = Context.RPCClient.Methods.GetChallengeList(10000, 0); if (challengeResponse.Erroneous) { Logger.Error("Error getting ChallengeList: " + challengeResponse.Fault.FaultMessage); Logger.ErrorToUI("An error occured during challenge list retrieval!"); return(null); } return(challengeResponse.Value); }
protected List <PlayerRank> GetCurrentRanking() { GenericListResponse <PlayerRank> rankingResponse = Context.RPCClient.Methods.GetCurrentRanking(); if (rankingResponse.Erroneous) { Logger.Error(string.Format("Error getting current ranking. : {0}", rankingResponse.Fault.FaultMessage)); Logger.ErrorToUI("Error getting current ranking."); return(null); } return(rankingResponse.Value); }
public GenericListResponse <Producto> GetAll([FromUri] PagingParameterModel pagingparametermodel) { BPM_SIEEntities BD = new BPM_SIEEntities(); var source = BD.Producto.ToList(); int count = source.Count(); int CurrentPage = pagingparametermodel.pageNumber; int PageSize = pagingparametermodel.pageSize; int TotalCount = count; int TotalPages = (int)Math.Ceiling(count / (double)PageSize); var items = source.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList(); var previousPage = CurrentPage > 1 ? "Yes" : "No"; var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; var paginationMetadata = new { totalCount = TotalCount, pageSize = PageSize, currentPage = CurrentPage, totalPages = TotalPages, previousPage, nextPage }; HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata)); GenericListResponse <Producto> response; try { response = new GenericListResponse <Producto> { Status = new ResponseStatus { HttpCode = HttpStatusCode.OK }, Items = items }; } catch (Exception ex) { response = new GenericListResponse <Producto> { Status = new ResponseStatus { HttpCode = HttpStatusCode.InternalServerError, Message = ex.Message }, Items = new List <Producto>() }; } return(response); }
private void SendBanListPageToLogin(string login, uint?pageIndex) { if (!LoginHasRight(login, true, Command.Ban)) { return; } const int MAX_BANLIST_SIZE = 1000; GenericListResponse <BanEntry> BanListResponse = Context.RPCClient.Methods.GetBanList(MAX_BANLIST_SIZE, 0); if (BanListResponse.Erroneous) { Logger.Error("Error retrieving BanList: " + BanListResponse.Fault.FaultMessage); return; } List <BanEntry> BanList = BanListResponse.Value; uint maxPageIndex = Convert.ToUInt32(Math.Max(0, Math.Ceiling((double)BanList.Count / BanListSettings.MaxEntriesPerPage) - 1)); if (!pageIndex.HasValue) { pageIndex = maxPageIndex; } pageIndex = Convert.ToUInt16(Math.Min(Math.Max(0, (int)pageIndex), maxPageIndex)); GetAreaSettings(login, (byte)Area.BanListArea).CurrentDialogPageIndex = (ushort)pageIndex; int entriesToSkip = Convert.ToInt32(pageIndex * BanListSettings.MaxEntriesPerPage); int startPosition = entriesToSkip + 1; List <PlayerListEntry> playerListEntriesToShow = BanList.Skip(entriesToSkip) .Take(Convert.ToInt32(BanListSettings.MaxEntriesPerPage)) .Select((l, i) => new PlayerListEntry((ushort)(startPosition + i), GetNickname(l.Login), l.Login)) .ToList(); Context.RPCClient.Methods.SendDisplayManialinkPageToLogin(login, GetBanListManiaLinkPage(pageIndex.Value + 1, maxPageIndex + 1, playerListEntriesToShow), 0, false); Dictionary <byte, string> rowSettings = new Dictionary <byte, string>(); byte rowIndex = 0; playerListEntriesToShow.ForEach(p => { rowSettings[rowIndex] = p.Login; rowIndex++; }); GetAreaSettings(login, (byte)Area.BanListArea).CustomData = rowSettings; }
private HashSet <string> GetSpectatorList(out List <PlayerInfo> playerList) { GenericListResponse <PlayerInfo> playerListResponse = Context.RPCClient.Methods.GetPlayerList(1000, 0); HashSet <string> guestList = new HashSet <string>(); playerList = new List <PlayerInfo>(); if (!playerListResponse.Erroneous) { playerList = playerListResponse.Value; playerList.Sort((x, y) => x.PlayerId - y.PlayerId); guestList = new HashSet <string>(playerList.Where(x => x.IsSpectator).Select(x => x.Login).ToList()); } return(guestList); }
protected static List <PlayerInfo> GetPlayerList(TMSPSPluginBase plugin) { GenericListResponse <PlayerInfo> playersResponse = plugin.Context.RPCClient.Methods.GetPlayerList(); if (playersResponse.Erroneous) { plugin.Logger.Error("Error getting PlayerList: " + playersResponse.Fault.FaultMessage); plugin.Logger.ErrorToUI("An error occured during player list retrieval!"); return(null); } foreach (PlayerInfo playerInfo in playersResponse.Value) { plugin.GetPlayerSettings(playerInfo.Login, true).UpdateFromPlayerInfo(playerInfo); } return(playersResponse.Value); }
private void FillPlayersTextBlock() { GenericResponse <CNPair <int> > maxPlayersResponse = RPCClient.Methods.GetMaxPlayers(); if (maxPlayersResponse.Erroneous) { return; // log here later } GenericListResponse <PlayerInfo> playerListResponse = RPCClient.Methods.GetPlayerList(); if (playerListResponse.Erroneous) { return; // log here later } PlayersCount = playerListResponse.Value.Count; MaxPlayersCount = maxPlayersResponse.Value.CurrentValue; FillPlayersTextBlock(PlayersCount, MaxPlayersCount); }