public static bool IsMatch(MyCubeBlockDefinition block, LimitItem item) { if (!item.BlockList.Any() || block == null) { return(false); } return(item.BlockList.Any(x => x.Equals(block.ToString().Substring(16), StringComparison.OrdinalIgnoreCase)) || item.BlockList.Any(x => x.Equals(block.Id.SubtypeId.ToString(), StringComparison.OrdinalIgnoreCase)) || item.BlockList.Any(x => x.Equals(block.Id.TypeId.ToString().Substring(16), StringComparison.OrdinalIgnoreCase)) || item.BlockList.Any(x => x.Equals(block.BlockPairName, StringComparison.OrdinalIgnoreCase))); }
public LimitItem GetItem(string ip) { LimitItem result = null; if (mHttpServer.Options.IPRpsLimit > 0) { mIpLimitTable.TryGetValue(ip, out result); } return(result); }
private LimitItem GetOrCreateItem(HttpRequest request) { string ip = request.RemoteIPAddress; if (mIpLimitTable.TryGetValue(ip, out LimitItem result)) { return(result); } LimitItem item = new LimitItem(ip, mHttpServer); if (!mIpLimitTable.TryAdd(ip, item)) { mIpLimitTable.TryGetValue(ip, out item); } return(item); }
public static bool IsGridType(MyObjectBuilder_CubeGrid grid, LimitItem item) { switch (item.GridTypeBlock) { case LimitItem.GridType.AllGrids: return(true); case LimitItem.GridType.SmallGridsOnly: return(grid.GridSizeEnum == MyCubeSize.Small); case LimitItem.GridType.LargeGridsOnly: return(grid.GridSizeEnum == MyCubeSize.Large); case LimitItem.GridType.StationsOnly: return(grid.IsStatic); case LimitItem.GridType.ShipsOnly: return(!grid.IsStatic); default: return(false); } }
public static bool IsExcepted(object target, LimitItem limit = null) { if (target == null) { return(false); } HashSet <string> allExceptions = new HashSet <string>(); if (limit != null) { allExceptions = new HashSet <string>(limit.Exceptions); } allExceptions.UnionWith(BlockLimiterConfig.Instance.GeneralException); if (allExceptions.Count == 0) { return(false); } MyIdentity identity = null; MyFaction faction = null; long identityId = 0; ulong playerSteamId = 0; string displayName = ""; HashSet <long> gridOwners = new HashSet <long>(); switch (target) { case HashSet <long> owners: gridOwners.UnionWith(owners); break; case ulong steamId: if (steamId == 0) { return(false); } playerSteamId = steamId; identityId = GetPlayerIdFromSteamId(steamId); identity = MySession.Static.Players.TryGetIdentity(identityId); displayName = identity.DisplayName; faction = MySession.Static.Factions.GetPlayerFaction(identityId); break; case string name: if (allExceptions.Contains(name)) { return(true); } if (TryGetPlayerByNameOrId(name, out identity)) { identityId = identity.IdentityId; faction = MySession.Static.Factions.GetPlayerFaction(identityId); displayName = identity.DisplayName; playerSteamId = GetSteamIdFromPlayerId(identityId); } break; case long id: if (id == 0) { return(false); } identityId = id; identity = MySession.Static.Players.TryGetIdentity(id); if (identity != null) { faction = MySession.Static.Factions.GetPlayerFaction(id); displayName = identity.DisplayName; playerSteamId = GetSteamIdFromPlayerId(id); } else { faction = (MyFaction)MySession.Static.Factions.TryGetFactionById(id); } if (MyEntities.TryGetEntityById(id, out var entity)) { if (allExceptions.Contains(entity.DisplayName)) { return(true); } } if (GridCache.TryGetGridById(id, out var foundGrid)) { gridOwners.UnionWith(GridCache.GetOwners(foundGrid)); if (allExceptions.Contains(foundGrid.DisplayName)) { return(true); } } break; case MyFaction targetFaction: if (allExceptions.Contains(targetFaction.Tag) || allExceptions.Contains(targetFaction.FactionId.ToString())) { return(true); } break; case MyPlayer player: playerSteamId = player.Character.ControlSteamId; if (playerSteamId == 0) { return(false); } if (allExceptions.Contains(playerSteamId.ToString())) { return(true); } identityId = GetPlayerIdFromSteamId(playerSteamId); if (identityId > 0) { if (allExceptions.Contains(identityId.ToString())) { return(true); } identity = MySession.Static.Players.TryGetIdentity(identityId); displayName = identity.DisplayName; } break; case MyCubeGrid grid: { if (allExceptions.Contains(grid.DisplayName) || allExceptions.Contains(grid.EntityId.ToString())) { return(true); } var owners = GridCache.GetOwners(grid); if (owners.Count == 0) { break; } gridOwners.UnionWith(owners); break; } } foreach (var owner in gridOwners) { if (owner == 0) { continue; } if (allExceptions.Contains(owner.ToString())) { return(true); } identity = MySession.Static.Players.TryGetIdentity(owner); playerSteamId = GetSteamIdFromPlayerId(owner); if (playerSteamId > 0 && allExceptions.Contains(playerSteamId.ToString())) { return(true); } if (identity != null) { if (allExceptions.Contains(identity.DisplayName)) { return(true); } } faction = MySession.Static.Factions.GetPlayerFaction(owner); if (faction != null && (allExceptions.Contains(faction.Tag) || allExceptions.Contains(faction.FactionId.ToString()))) { return(true); } } if (playerSteamId > 0 && allExceptions.Contains(playerSteamId.ToString())) { return(true); } if (identityId > 0 && allExceptions.Contains(identityId.ToString())) { return(true); } if (identity != null && allExceptions.Contains(identity.DisplayName)) { return(true); } if (faction != null && (allExceptions.Contains(faction.Tag) || allExceptions.Contains(faction.FactionId.ToString()))) { return(true); } if (!string.IsNullOrEmpty(displayName) && allExceptions.Contains(displayName)) { return(true); } return(false); }
private decimal ApplyPostponeOrder(ChinaPay.B3B.Service.Order.Domain.Order order, string passengers, string reason, string voyages) { string pid = ""; List <PNRPair> _pnrCode = new List <PNRPair>(); foreach (var item in passengers.Split('^')) { foreach (var o in order.PNRInfos) { var j = o.Passengers.FirstOrDefault(i => i.Name == item); if (j != null) { if (pid != "") { pid += "," + j.Id.ToString(); } else { pid += j.Id.ToString(); } _pnrCode.Add(o.Code); if (!_pnrCode.Contains(o.Code)) { InterfaceInvokeException.ThrowCustomMsgException("当前订单中存在不同的编码"); } break; } } } if (pid == "") { InterfaceInvokeException.ThrowCustomMsgException("当前订单中没有找到对应的乘机人信息"); } if (!_pnrCode.Any()) { InterfaceInvokeException.ThrowCustomMsgException("当前订单中没有找到对应的编码信息"); } var ids = ApplyOrder.getPassengers(pid); var applyformView = new PostponeApplyformView() { PNR = _pnrCode.FirstOrDefault(), Passengers = ids, Reason = reason }; var flightChangeLimit = SystemDictionaryService.Query(SystemDictionaryType.FlightChangeLimit); var limit = LimitItem.Parse(flightChangeLimit); foreach (var item in getPostponeVoyages(voyages, order)) { bool isTodayFlight = DateTime.Today == item.NewFlightDate.Date; foreach (LimitItem l in limit) { if (order.PNRInfos.First().Flights.First().Carrier.Code != l.Carrair.ToUpper()) { continue; } if (item.NewFlightDate >= l.LimitFrom && item.NewFlightDate <= l.LimitTo && (!isTodayFlight || !l.ToTodayEnable)) { var aline = FoundationService.Airlines.FirstOrDefault(p => p.Code.Value == l.Carrair); InterfaceInvokeException.ThrowCustomMsgException("由于[" + aline.ShortName + "]原因,该客票已被航空公司限制改期,无法改期,请让乘机人自行致电航空公司或到航空公司直营柜台办理改期"); } } applyformView.AddItem(item); } string lockErrorMsg = ""; Lock(order.Id, Service.Locker.LockRole.Purchaser, "申请退改签", out lockErrorMsg); if (!string.IsNullOrEmpty(lockErrorMsg)) { InterfaceInvokeException.ThrowCustomMsgException(lockErrorMsg); } var apply = Service.OrderProcessService.Apply(order.Id, applyformView, Employee, Guid.Empty); releaseLock(order.Id); return(apply.Id); }