private void InfectionDemon() { while (!IsDayOver) { Thread.Sleep(MagicTiming); var previous = new Patient(); previous.IsInfected = false; var keys = _queue.Keys.ToArray(); for (var i = 0; i < keys.Length; i++) { try { if (!_queue[keys[i]].IsInfected) { continue; } if (i > 0) { _queue[keys[i - 1]].IsInfected = true; LoggerEvent?.Invoke($"Infecting in queue patient {keys[i - 1]}\n"); } if (i < keys.Length - 1) { _queue[keys[i + 1]].IsInfected = true; LoggerEvent?.Invoke($"Infecting in queue patient {keys[i + 1]}\n"); } i++; } catch (KeyNotFoundException) { } } } }
/// <summary> /// Return IO Path of Location and folder name combination /// </summary> /// <param name="FolderName">Folder name</param> /// <param name="Location">Top level folder.</param> /// <returns></returns> public static string BulldDir(string FolderName, string Location) { LoggerEventArgs eventArgs = new LoggerEventArgs(); eventArgs.OriginName = name; eventArgs.LogMessage = "BulldDir"; LoggerEvent?.Invoke(null, eventArgs); return(System.IO.Path.Combine(Location, FolderName)); }
private void NewPatientDemon() { while (!IsDayOver) { var newId = _queue.Count == 0 ? 0 : _queue.Keys.Max() + 1; var p = new Patient(); _queue[newId] = p; LoggerEvent?.Invoke($"New patient IsInfected {p.IsInfected}\n"); Thread.Sleep(rnd.Next(MagicTiming)); } }
/// <summary> /// /// </summary> /// <param name="ts">List of PermissionsEngine object</param> /// <param name="SearchIndex">PermissionsEngine Object Index</param> public static void DeleteListItemByQuery(List <PermissionsEngine> ts, int SearchIndex) { LoggerEventArgs eventArgs = new LoggerEventArgs(); eventArgs.OriginName = name; eventArgs.LogMessage = "DeleteListItemByQuery operations Started"; LoggerEvent?.Invoke(null, eventArgs); var quesry = from PermissionsEngine a in ts where a.Index == SearchIndex select a; ts.Remove(quesry.FirstOrDefault()); }
/// <summary> /// Log the message. /// </summary> /// <param name="Message">Message to log.</param> public void Log(string Message) { lock (Lock) { try { Writer.WriteLine(Message); Writer.Flush(); LoggerEvent.Invoke(Message); } catch (Exception) { } } }
//Notice /// <summary> /// </summary> /// <param name="ts">List of PermissionsEngine object</param> /// <param name="SearchIndex">PermissionsEngine Object Index</param> public static void DeleteListItem(List <PermissionsEngine> ts, int SearchIndex) { LoggerEventArgs eventArgs = new LoggerEventArgs(); eventArgs.OriginName = name; eventArgs.LogMessage = "DeleteListItem operations Started"; LoggerEvent?.Invoke(null, eventArgs); foreach (var item in ts) { if ((int)item.Index == SearchIndex) { ts.Remove(item); break; } } }
/// <summary> /// Set Permissions into onto directory /// </summary> /// <param name="dir">Directory</param> /// <param name="user">Username Or Active Directory SG Name</param> //OROGINAL public void Set(string dir, string user) { LoggerEventArgs loggerEventArgs = new LoggerEventArgs { OriginName = name, OriginMessage = "Set Event started" }; LoggerEvent?.Invoke(this, loggerEventArgs); try { Debug.WriteLine("AclSet Started"); AddAccessControl per = new AddAccessControl(); if (Access) { FSAccess = AccessControlType.Allow; } else { FSAccess = AccessControlType.Deny; } if (Read) { per.AddDirectorySecurity(dir, user, FileSystemRights.ReadAndExecute, FSAccess); } else if (Write) { per.AddDirectorySecurity(dir, user, FileSystemRights.ReadAndExecute, FSAccess); per.AddDirectorySecurity(dir, user, FileSystemRights.Write, FSAccess); } else if (Modify) { per.AddDirectorySecurity(dir, user, FileSystemRights.Modify, FSAccess); } Debug.WriteLine("AclSet Finished"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// </summary> /// <param name="FolderName">Folder name</param> /// <param name="Location">Top level folder.</param> public static void CreateFolder(string Location) { LoggerEventArgs eventArgs = new LoggerEventArgs(); eventArgs.OriginName = name; eventArgs.LogMessage = "CreateFolder operations Started"; LoggerEvent?.Invoke(null, eventArgs); Debug.WriteLine("Create Folder Started"); try { System.IO.Directory.CreateDirectory(Location); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); } Debug.WriteLine("Create folder Finished"); }
/// <summary> /// Log the message. /// </summary> /// <param name="Message">Message to log.</param> /// <param name="LogType">Log type.</param> /// <param name="Client">Client.</param> public void Log(string Message, Logger.LogTypes LogType, TcpClient Client = null) { lock (Lock) { try { Logger Logger = new Logger(Message, LogType, Client); if (Logger.CanDisplay()) { Writer.WriteLine(Logger.ToString()); Writer.Flush(); Core.RCONPlayer.SendToAllPlayer(new Package(Package.PackageTypes.Logger, Logger.ToString(), null)); LoggerEvent.Invoke(Logger.ToString()); } } catch (Exception) { } } }
/// <summary> /// Get Active session user UPN (string), for future use /// </summary> private string LoadActiveDirectoryIdentity() { LoggerEventArgs loggerEventArgs = new LoggerEventArgs { OriginName = name, OriginMessage = "Log Event" }; LoggerEvent?.Invoke(this, loggerEventArgs); try { var user = UserPrincipal.Current.UserPrincipalName; if (user == null) { user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; } return((string)user); } catch (Exception ex) { MessageBox.Show(ex.Message); return(string.Empty); } }
public void EndInspection(string text) { LoggerEvent?.Invoke(text); }
private void HandleLogger(Package p) { LoggerEvent.Invoke(p.DataItems[0]); }
protected virtual void OnLogger(string name, Position pos) { var e = new LoggerEventArgs(name, pos); LoggerEvent?.Invoke(this, e); }