public void AddUser(HueUser user) { if (!WhiteList.ContainsKey(user.Id)) { WhiteList.Add(user.Id, user); } }
public ModelInvokeResult <WhiteListPK> Update(string strId, WhiteList whiteList) { ModelInvokeResult <WhiteListPK> result = new ModelInvokeResult <WhiteListPK> { Success = true }; try { List <IBatisNetBatchStatement> statements = new List <IBatisNetBatchStatement>(); whiteList.Id = int.Parse(strId); statements.Add(new IBatisNetBatchStatement { StatementName = whiteList.GetUpdateMethodName(), ParameterObject = whiteList.ToStringObjectDictionary(false), Type = SqlExecuteType.UPDATE }); /***********************begin 自定义代码*******************/ /***********************此处添加自定义代码*****************/ /***********************end 自定义代码*********************/ BuilderFactory.DefaultBulder().ExecuteNativeSqlNoneQuery(statements); result.instance = new WhiteListPK { Id = int.Parse(strId) }; } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
public async Task <IActionResult> PutWhiteList(string id, WhiteList whiteList) { if (id != whiteList.MobileNumber) { return(BadRequest()); } _context.Entry(whiteList).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WhiteListExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static bool ParseModFile(string modFileData) { if (ModSystem.Singleton.ModControl == ModControlMode.DISABLED) { return(true); } ModSystem.Singleton.LastModFileData = modFileData; //Save mod file so we can recheck it. StringBuilder = new StringBuilder(); ParseRequired.Clear(); ParseOptional.Clear(); WhiteList.Clear(); BlackList.Clear(); PartsList.Clear(); SaveCurrentModConfigurationFile(); ReadModConfigurationFile(modFileData); CheckFiles(); if (!ModCheckOk) { ModSystem.Singleton.FailText = StringBuilder.ToString(); ModWindow.Singleton.Display = true; return(false); } ModSystem.Singleton.AllowedParts = PartsList; Debug.Log("[LMP]: Mod check passed!"); return(true); }
public static bool ParseModFile(string modFileData) { if (SystemsContainer.Get <ModSystem>().ModControl == ModControlMode.Disabled) { return(true); } SystemsContainer.Get <ModSystem>().LastModFileData = modFileData; //Save mod file so we can recheck it. StringBuilder = new StringBuilder(); ParseRequired.Clear(); ParseOptional.Clear(); WhiteList.Clear(); BlackList.Clear(); PartsList.Clear(); SaveCurrentModConfigurationFile(); ReadModConfigurationFile(modFileData); CheckFiles(); if (!ModCheckOk) { SystemsContainer.Get <ModSystem>().FailText = StringBuilder.ToString(); WindowsContainer.Get <ModWindow>().Display = true; return(false); } SystemsContainer.Get <ModSystem>().AllowedParts = PartsList; LunaLog.Log("[LMP]: Mod check passed!"); return(true); }
/// <summary> /// Initialize the WhiteList /// </summary> /// <param name="WhiteListLines">string[] with lines containing the extension names</param> public void Init_WhiteList(string[] WhiteListLines) { if (_whiteList.Count == 0 && _Languages.Count == 0) { WhiteList wl = new WhiteList(); _Languages.Add("All"); foreach (string s in WhiteListLines) { if (s.StartsWith("#") && !_Languages.Contains(s.Remove(0, 1))) { _Languages.Add(s.Remove(0, 1)); wl.Language = s.Remove(0, 1); } if (s.StartsWith(".")) { wl.Extension = s; _whiteList.Add(new WhiteList { Language = wl.Language, Extension = wl.Extension }); CurrentWhiteList.Add(new WhiteList { Language = wl.Language, Extension = wl.Extension }); } } } }
public MouseWatcher(IBeamgunSettings settings, WorkstationLocker locker, Action <string> report, Action <string> alarm, Func <bool> disabled) { var MouseQuery = new WqlEventQuery("__InstanceCreationEvent", new TimeSpan(0, 0, 1), "TargetInstance isa \"Win32_PointingDevice\""); _watcher = new ManagementEventWatcher(MouseQuery); _watcher.EventArrived += (caller, args) => { if (disabled()) { return; } var obj = (ManagementBaseObject)args.NewEvent["TargetInstance"]; alarm($"Alerting on mouse insertion: " + $"{obj["Name"]} " + $"{obj["Caption"]} " + $"{obj["Description"]} " + $"{obj["DeviceID"]}" + $"{obj["Manufacturer"]} " + $"{obj["PNPDeviceID"]}."); if (!settings.LockOnMouse) { return; } if (WhiteList.WhiteListed(obj)) { report($"Device is whitelisted, remove {obj["PNPDeviceID"]} from {WhiteList.WhiteFilename} if you've changed your mind."); return; } report(locker.Lock() ? "Successfully locked the workstation." : "Could not lock the workstation."); }; _watcher.Start(); }
/// <summary> /// Determines whether client is authorized to invoke the <see cref="T:Microsoft.AspNet.SignalR.Hubs.IHub" /> method. /// </summary> /// <param name="hubIncomingInvokerContext">An <see cref="T:Microsoft.AspNet.SignalR.Hubs.IHubIncomingInvokerContext" /> providing details regarding the <see cref="T:Microsoft.AspNet.SignalR.Hubs.IHub" /> method invocation.</param> /// <param name="appliesToMethod">Indicates whether the interface instance is an attribute applied directly to a method.</param> /// <returns> /// true if the caller is authorized to invoke the <see cref="T:Microsoft.AspNet.SignalR.Hubs.IHub" /> method; otherwise, false. /// </returns> public override bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod) { if (IsAnonymousEnabled) { return(true); } if (!base.AuthorizeHubMethodInvocation(hubIncomingInvokerContext, appliesToMethod)) { return(false); } if (appliesToMethod) { if (_authorizer == null) { return(true); } IPrincipal user = hubIncomingInvokerContext.Hub.Context.User; IEnumerable <string> keys = GetResourceKeys(hubIncomingInvokerContext); return(!keys.Any((key) => Blacklist.Contains(key)) && keys.All((key) => WhiteList.Contains(key) || _authorizer.HasClaim( new AuthorizationContext(user, key, PermissionType)))); } return(true); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if (FileId != null) { hashCode = hashCode * 59 + FileId.GetHashCode(); } if (PageRange != null) { hashCode = hashCode * 59 + PageRange.GetHashCode(); } hashCode = hashCode * 59 + Font.GetHashCode(); hashCode = hashCode * 59 + Context.GetHashCode(); if (WhiteList != null) { hashCode = hashCode * 59 + WhiteList.GetHashCode(); } hashCode = hashCode * 59 + RoiLeft.GetHashCode(); hashCode = hashCode * 59 + RoiTop.GetHashCode(); hashCode = hashCode * 59 + RoiWidth.GetHashCode(); hashCode = hashCode * 59 + RoiHeight.GetHashCode(); hashCode = hashCode * 59 + ExpectedSymbolsCount.GetHashCode(); return(hashCode); } }
public virtual bool IsWhitelisted(ClientRequestIdentity clientRequestIdentity, out RateLimitNameListPolicyMatchedResult result) { if (WhiteList != null) { string rule = null; if (!string.IsNullOrWhiteSpace(clientRequestIdentity.ClientId)) { if (WhiteList.Exists(m => m.LimitType == LimitType.Client && m.IsMatched(clientRequestIdentity.ClientId, out rule))) { result = new RateLimitNameListPolicyMatchedResult(LimitType.Client, rule); return(true); } } string requestEndpoint = clientRequestIdentity.RequestEndpoint(); if (WhiteList.Exists(m => m.LimitType == LimitType.Endpoint && m.IsMatched(requestEndpoint, out rule))) { result = new RateLimitNameListPolicyMatchedResult(LimitType.Endpoint, rule); return(true); } if (WhiteList.Exists(m => m.LimitType == LimitType.IP && m.IsMatched(clientRequestIdentity.ClientIp, out rule))) { result = new RateLimitNameListPolicyMatchedResult(LimitType.IP, rule); return(true); } } result = null; return(false); }
public void SetWhiteList(WhiteList whiteList) { var req = new RestRequest(WhiteListHandler, Method.PUT); req.AddObject(whiteList); _restClient.Execute(req); }
public MetricComputer(IClassRepository classRepository, Stream err, WhiteList whitelist, int recordingDepth) { this.classRepository = classRepository; this.err = err; this.whitelist = whitelist; this.recordingDepth = recordingDepth; }
/// <summary> /// 导出数据 /// </summary> /// <returns></returns> public static string Export() { var res = new DataModel(); res.devName = DeviceName.GetDeviceName(); res.devType = DeviceType.GetDeviceType(); res.whiteList = WhiteList.GetWhiteList(); return(JsonConvert.SerializeObject(res)); }
public static WhiteList Create(string xmlUri) { WhiteList whiteList = new WhiteList(); whiteList.Elements.AddRange(XElement.Load(xmlUri).Descendants("Kunder") .Where(xmlElement => xmlElement != null) .Select(xmlElement => WhiteListElement.Create(xmlElement))); return(whiteList); }
public void Allowed() { var policy = new WhiteList <string>(); policy.Add("a"); policy.Add("b"); Assert.IsTrue(policy.IsAllowed("a")); Assert.IsTrue(policy.IsAllowed("b")); Assert.IsFalse(policy.IsAllowed("c")); Assert.IsFalse(policy.IsAllowed("d")); }
public bool removeException(string exception) { bool removed = false; if (WhiteList.Contains(exception.Trim().ToLower())) { WhiteList.Remove(exception.Trim().ToLower()); removed = true; } return(removed); }
public static bool WhiteListContains(string type, string value) { if (!WhiteList.ContainsKey(type)) { return(false); } else { return(WhiteList[type] == value); } }
/// <summary> /// Returns true if ImageMICRParameters instances are equal /// </summary> /// <param name="input">Instance of ImageMICRParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(ImageMICRParameters input) { if (input == null) { return(false); } return (( FileId == input.FileId || (FileId != null && FileId.Equals(input.FileId)) ) && ( PageRange == input.PageRange || (PageRange != null && PageRange.Equals(input.PageRange)) ) && ( Font == input.Font || Font.Equals(input.Font) ) && ( Context == input.Context || Context.Equals(input.Context) ) && ( WhiteList == input.WhiteList || (WhiteList != null && WhiteList.Equals(input.WhiteList)) ) && ( RoiLeft == input.RoiLeft || RoiLeft.Equals(input.RoiLeft) ) && ( RoiTop == input.RoiTop || RoiTop.Equals(input.RoiTop) ) && ( RoiWidth == input.RoiWidth || RoiWidth.Equals(input.RoiWidth) ) && ( RoiHeight == input.RoiHeight || RoiHeight.Equals(input.RoiHeight) ) && ( ExpectedSymbolsCount == input.ExpectedSymbolsCount || ExpectedSymbolsCount.Equals(input.ExpectedSymbolsCount) )); }
/// <summary> /// 删除白名单 /// </summary> /// <param name="wl">白名单实体</param> /// <returns>业务操作结果</returns> public OperationResult Delete(WhiteList wl) { int rcount = WhiteListRepository.Delete(wl); if (rcount > 0) { return(new OperationResult(OperationResultType.Success, "删除白名单成功。", wl)); } else { return(new OperationResult(OperationResultType.Warning, "删除白名单失败。")); } }
/// <summary> /// 创建候选牵头单位 /// </summary> private void BuildWhiteList() { //删除所有记录 ConnectionManager.Context.table("WhiteList").delete(); //创建新的记录 WhiteList wl = new WhiteList(); wl.ID = Guid.NewGuid().ToString(); wl.ProjectID = PublicReporterLib.PluginLoader.getLocalPluginRoot <ProjectReporterPlugin.PluginRoot>().projectObj.ID; wl.UnitID = PublicReporterLib.PluginLoader.getLocalPluginRoot <ProjectReporterPlugin.PluginRoot>().projectObj.UnitID; wl.copyTo(ConnectionManager.Context.table("WhiteList")).insert(); }
/// <summary> /// 创建候选牵头单位 /// </summary> private void BuildWhiteList() { //删除所有记录 ConnectionManager.Context.table("WhiteList").delete(); //创建新的记录 WhiteList wl = new WhiteList(); wl.ID = Guid.NewGuid().ToString(); wl.ProjectID = MainForm.Instance.ProjectObj.ID; wl.UnitID = MainForm.Instance.ProjectObj.UnitID; wl.copyTo(ConnectionManager.Context.table("WhiteList")).insert(); }
private static void DownloadWhiteList() { try { var url = new Configer().WhiteListServer; WebClient client = new WebClient(); var listData = client.DownloadData(url); WhiteList.Write(listData); } catch (Exception ex) { Console.WriteLine("download whitelist failed:" + ex.Message); } }
public void addException(string exception, bool filter = false, int filterLength = -1) { if (!WhiteList.Contains(exception.Trim().ToLower())) { WhiteList.Add(exception.Trim().ToLower()); } if (filter) { if (filterLength == -1) { filterLength = exception.Length; } filterExceptions(filterLength); } }
/// <summary> /// Add the following Player to the WhiteList. /// </summary> /// <param name="Player">Player to whitelist.</param> /// <param name="Reason">Reason.</param> public static void AddWhiteList(this Player Player, string Reason) { if (Player.IsWhiteListed()) { WhiteList WhiteList = Player.GetWhiteList(); WhiteList.Name = Player.Name; WhiteList.Reason = Reason; Core.Setting.Save(); } else { Core.Setting.WhiteListData.Add(new WhiteList(Player.Name, Player.GameJoltID, Reason)); Core.Setting.Save(); } }
public bool Save() { if (File.Exists(FilePath)) { try { File.Delete(FilePath); } catch { return(false); } } File.WriteAllLines(FilePath, WhiteList.ToArray(typeof(String)) as String[]); return(true); }
public AnnotatedAssemblyHolder(AssemblyHolder sourceHolder, WhiteList whiteList) : base(sourceHolder) { this.aMethods = new Hashtable(); this.GraphProcessor = new GraphProcessor(); this.WhiteList = whiteList; foreach (MethodBase method in this.SourceHolder.getMethods()) { if (method.IsDefined(typeof(SpecializeAttribute), false)) { ControllingVisitor.AddAnnotatedMethodUser(this.AnnotateMethod(this.GetAnnotatedMethod(method))); } } this.GraphProcessor.Process(); }
/// <summary> /// Removes a single item from the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnWhiteListRemoveClick_Main(object sender, RoutedEventArgs e) { if (WhiteList_Grid.SelectedItems.Count != 0) { int count = 0; WhiteList row = (WhiteList)WhiteList_Grid.SelectedItems[0]; WhiteList temp = new WhiteList(); _viewModel.NotifyMessage = "Removed " + row.Extension + " from " + row.Language; foreach (WhiteList w in _viewModel.WhiteList) { if (w.Extension == row.Extension && w.Language == row.Language) { temp = w; } if (w.Language == row.Language) { count++; } } if (count <= 1) { _viewModel.Languages.Remove(row.Language); comboBox.ItemsSource = null; comboBox.ItemsSource = _viewModel.Languages; comboBox.SelectedIndex = 0; } _viewModel.WhiteList.Remove(temp);; _viewModel.CurrentWhiteList.Remove(row); _viewModel.FlyoutOpen = true; WhiteList_Grid.ItemsSource = null; WhiteList_Grid.ItemsSource = _viewModel.CurrentWhiteList; row = null; temp = null; } else { _viewModel.NotifyMessage = "No Item selected"; _viewModel.FlyoutOpen = true; } }
/// <summary> /// Constructs the server manager. /// </summary> /// <param name="netServer">The net server instance.</param> /// <param name="gameSettings">The server game settings.</param> /// <param name="packetManager">The packet manager instance.</param> protected ServerManager( NetServer netServer, Settings.GameSettings gameSettings, PacketManager packetManager ) { _netServer = netServer; GameSettings = gameSettings; _playerData = new ConcurrentDictionary <ushort, ServerPlayerData>(); CommandManager = new ServerCommandManager(); var eventAggregator = new EventAggregator(); var serverApi = new ServerApi(this, CommandManager, _netServer, eventAggregator); AddonManager = new ServerAddonManager(serverApi); // Load the lists _whiteList = WhiteList.LoadFromFile(); _authorizedList = AuthKeyList.LoadFromFile(AuthorizedFileName); _banList = BanList.LoadFromFile(); // Register packet handlers packetManager.RegisterServerPacketHandler <HelloServer>(ServerPacketId.HelloServer, OnHelloServer); packetManager.RegisterServerPacketHandler <ServerPlayerEnterScene>(ServerPacketId.PlayerEnterScene, OnClientEnterScene); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerLeaveScene, OnClientLeaveScene); packetManager.RegisterServerPacketHandler <PlayerUpdate>(ServerPacketId.PlayerUpdate, OnPlayerUpdate); packetManager.RegisterServerPacketHandler <EntityUpdate>(ServerPacketId.EntityUpdate, OnEntityUpdate); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDisconnect, OnPlayerDisconnect); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDeath, OnPlayerDeath); packetManager.RegisterServerPacketHandler <ServerPlayerTeamUpdate>(ServerPacketId.PlayerTeamUpdate, OnPlayerTeamUpdate); packetManager.RegisterServerPacketHandler <ServerPlayerSkinUpdate>(ServerPacketId.PlayerSkinUpdate, OnPlayerSkinUpdate); packetManager.RegisterServerPacketHandler <ChatMessage>(ServerPacketId.ChatMessage, OnChatMessage); // Register a timeout handler _netServer.ClientTimeoutEvent += OnClientTimeout; // Register server shutdown handler _netServer.ShutdownEvent += OnServerShutdown; // Register a handler for when a client wants to login _netServer.LoginRequestEvent += OnLoginRequest; }
/// <summary> /// 删除白名单 /// </summary> /// <param name="member">白名单信息</param> /// <returns>业务操作结果</returns> public OperationResult Delete(Guid guid) { try { WhiteList pmodel = WhiteListContract.WhiteLists.SingleOrDefault(m => m.Id == guid); if (pmodel == null) { return(new OperationResult(OperationResultType.Error, string.Format("不存在Id为{0}的白名单项", guid))); } return(WhiteListContract.Delete(pmodel)); } catch (Exception ex) { return(new OperationResult(OperationResultType.Error, ex.Message)); } }
static CreateEventWhiteList() { random = new Random(); whiteList = new WhiteList(); // Get skip regex whiteList.SkipPhrases = new Regex(CalendarCommonStrings.SkipPhrases); // Get default title whiteList.DefaultTitle = CalendarCommonStrings.DefaultTitle.Split("|"); // Get contact separator whiteList.ContactSeparator = CalendarCommonStrings.ContactSeparator.Split("|"); // Get nyself whiteList.Myself = new Regex(CalendarCommonStrings.Myself); }
public static bool ChekWhitelist(WhiteList obj) { try { string query = "select 1 from WhiteList where sellerNick = @sellerNick "; // 设置SQL参数 SqlParameter[] param = new SqlParameter[] { new SqlParameter("@sellerNick", obj.SellerNick) }; DataTable dt = DataBase.ExecuteDt(query, param, CommandType.Text); return(dt.Rows.Count > 0); } catch (Exception ex) { ExceptionReporter.WriteLog(ex, ExceptionPostion.TBApply_Data); return(false); } }