public void Commit(LogEntry entry) { var ignoreEntry = entry.Level < LogLevel; try { #if DEBUG if (isDebuggerAttached) { Debug.WriteLine(entry); return; } #endif if (ignoreEntry) { return; } writer?.WriteLine(entry); } finally { if (!ignoreEntry) { rwlock.EnterWriteLock(); try { entries.Add(entry); } finally { rwlock.ExitWriteLock(); } EntryAdded?.Invoke(this, entry); } } }
public void Add(string text, ushort hue, string name, bool isunicode = true) { if (Entries.Count >= Constants.MAX_JOURNAL_HISTORY_COUNT) { Entries.RemoveFromFront(); } byte font = (byte)(isunicode ? 0 : 9); if (ProfileManager.Current != null && ProfileManager.Current.OverrideAllFonts) { font = ProfileManager.Current.ChatFont; isunicode = ProfileManager.Current.OverrideAllFontsIsUnicode; } DateTime timeNow = DateTime.Now; JournalEntry entry = new JournalEntry(text, font, hue, name, isunicode, timeNow); if (ProfileManager.Current != null && ProfileManager.Current.ForceUnicodeJournal) { entry.Font = 0; entry.IsUnicode = true; } Entries.AddToBack(entry); EntryAdded.Raise(entry); if (_fileWriter == null && !_writerHasException) { CreateWriter(); } _fileWriter?.WriteLine($"[{timeNow:g}] {name}: {text}"); }
private void saveButton_Click(object sender, EventArgs e) { if (_mirType == 0) { _entry = new CrystalCredentials { FilePath = clientDirBox.Text, IsDebug = debugBox.Checked, ServerName = serverNameBox.Text, UserName = userNameBox.Text, Password = passwordBox.Text }; EntryAdded?.Invoke(this, _entry); } else if (_mirType == 1) { _entry = new ZirconCredentials { FilePath = clientDirBox.Text, IsDebug = debugBox.Checked, ServerName = serverNameBox.Text, UserName = userNameBox.Text, Password = passwordBox.Text }; EntryAdded?.Invoke(this, _entry); } }
private void OnEntryAdded(LogEvent logEvent) { EntryAdded?.Invoke(this.ApplicationName, logEvent); switch (logEvent.Severity) { case LogEventType.None: break; case LogEventType.Information: InfoEventOccurred?.Invoke(this.ApplicationName, logEvent); break; case LogEventType.Warning: WarnEventOccurred?.Invoke(this.ApplicationName, logEvent); break; case LogEventType.Error: ErrorEventOccurred?.Invoke(this.ApplicationName, logEvent); break; case LogEventType.Fatal: FatalEventOccurred?.Invoke(this.ApplicationName, logEvent); break; default: break; } }
public void Add(ErrorListEntry entry) { lock (_entries) { _entries.Add(entry); } EntryAdded?.Invoke(this, new LogEventArgs(entry)); }
internal static void Log(LogType type, DateTime time, string message) { var entry = new LogEntry(type, time, message); Application.Current.Dispatcher?.Invoke(() => { EntryAdded?.Invoke(null, entry); }); }
// public delegate void EventHandler(object sender, EventArgs e); // public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e); public void AddEntry(decimal amount) { Deposit += amount; if (EntryAdded != null) { EntryAdded.Invoke(this, new EventArgsExt(amount, Deposit)); } }
public void Add(string text, MessageFont font, Hue hue, string name, bool isunicode = true) { if (_entries.Count >= 100) { _entries.RemoveFromFront(); } JournalEntry entry = new JournalEntry(text, font, hue, name, isunicode); _entries.AddToBack(entry); EntryAdded.Raise(entry); }
public void Add(string text, Hue hue, string name, bool isunicode = true) { if (Entries.Count >= 100) { Entries.RemoveFromFront(); } JournalEntry entry = new JournalEntry(text, (byte)(isunicode ? 0 : 9), hue, name, isunicode); Entries.AddToBack(entry); EntryAdded.Raise(entry); _fileWriter?.WriteLine($"{name}: {text}"); }
public void UploadCompleted(FileExplorerEntry entry) { var parentFolderPath = Path.GetDirectoryName(entry.Path); if (parentFolderPath != null && TryGetCachedDirectory(parentFolderPath, out var cachedDirectory)) { entry.Parent = cachedDirectory.Directory; cachedDirectory.Directory.HasSubFolder = true; lock (cachedDirectory.EntriesLock) { cachedDirectory.Entries = cachedDirectory.Entries.Add(entry); } } EntryAdded?.Invoke(this, entry); }
private void DispatchEventsFromJournal() { lock (_journalLock) { JournalEntry entry; while ((entry = _journalReader.ReadEntry()) != null) { EntryAdded?.Invoke(this, entry); } if (_starting) { _starting = false; Started?.Invoke(this, EventArgs.Empty); } } }
public V this[K key] { get { return(dictionary[key]); } set { V oldValue; var removed = TryGetValue(key, out oldValue); if (removed) { EntryRemoved?.Invoke(this, new EntryRemovedEventArgs <K, V>(key, oldValue)); } dictionary[key] = value; EntryAdded?.Invoke(this, new EntryAddedEventArgs <K, V>(key, value)); if (removed) { EntryChanged?.Invoke(this, new EntryChangedEventArgs <K, V>(key, value, oldValue)); } } }
public void Add(string text, Hue hue, string name, bool isunicode = true) { if (Entries.Count >= 100) { Entries.RemoveFromFront(); } byte font = (byte)(isunicode ? 0 : 9); if (Engine.Profile.Current != null && Engine.Profile.Current.OverrideAllFonts) { font = Engine.Profile.Current.ChatFont; isunicode = Engine.Profile.Current.OverrideAllFontsIsUnicode; } JournalEntry entry = new JournalEntry(text, font, hue, name, isunicode, Engine.CurrDateTime); Entries.AddToBack(entry); EntryAdded.Raise(entry); _fileWriter?.WriteLine($"[{Engine.CurrDateTime:g}] {name}: {text}"); }
public override void Deactivation() { base.Deactivation(); foreach (RouteEntry Entry in EntryAdded.Values) { Entry.Remove(); } foreach (RouteEntry Entry in EntryRemoved.Values) { Entry.Add(); Engine.Instance.Logs.Log(LogType.Verbose, MessagesFormatter.Format(Messages.NetworkLockRouteRestored, Entry.ToString())); } DefaultGateway = ""; DefaultInterface = ""; EntryAdded.Clear(); EntryRemoved.Clear(); }
public void Add(string text, ushort hue, string name, TextType type, bool isunicode = true) { JournalEntry entry = Entries.Count >= Constants.MAX_JOURNAL_HISTORY_COUNT ? Entries.RemoveFromFront() : new JournalEntry(); byte font = (byte)(isunicode ? 0 : 9); if (ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.OverrideAllFonts) { font = ProfileManager.CurrentProfile.ChatFont; isunicode = ProfileManager.CurrentProfile.OverrideAllFontsIsUnicode; } DateTime timeNow = DateTime.Now; entry.Text = text; entry.Font = font; entry.Hue = hue; entry.Name = name; entry.IsUnicode = isunicode; entry.Time = timeNow; entry.TextType = type; if (ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.ForceUnicodeJournal) { entry.Font = 0; entry.IsUnicode = true; } Entries.AddToBack(entry); EntryAdded.Raise(entry); if (_fileWriter == null && !_writerHasException) { CreateWriter(); } _fileWriter?.WriteLine($"[{timeNow:g}] {name}: {text}"); }
public void AddEntry(object origin, string message, LogLevel logLevel = LogLevel.Info, Exception ex = null) { message = ex == null ? message : message + $", Exception: {ex}"; var entry = new LogEntry { FullMessage = $"[{DateTime.Now}]---LogLevel: {logLevel}, Type: {origin.GetType().FullName}, Message: {message}", LogLevel = logLevel, Message = message, Time = DateTime.Now, Type = origin.GetType().Name }; internalLog.Entries.Add(entry); if (internalLog.Entries.Count >= 2500) { SaveLog(); internalLog.Entries.Clear(); } Execute.OnUIThreadAsync(() => EntryAdded?.Invoke(this, new LogEntryEventArgs { LogLevel = logLevel, LogEntry = entry })); }
protected virtual void OnEntryAdded(string key, TValue value) { EntryAdded?.Invoke(this, new EntryAddedEventArgs <TValue>(key, value)); }
public override void Activation() { base.Activation(); List <RouteEntry> EntryList = Platform.Instance.RouteList(); DefaultGateway = ""; DefaultInterface = ""; EntryRemoved.Clear(); EntryAdded.Clear(); foreach (RouteEntry Entry in EntryList) { if (IsIP(Entry.Gateway)) { if (DefaultGateway.Valid == false) { DefaultGateway = Entry.Gateway; DefaultInterface = Entry.Interface; } else if (DefaultGateway != Entry.Gateway) { Failed = true; break; } } } if (DefaultGateway.Valid == false) { Failed = true; } if (Failed) { DefaultGateway = ""; DefaultInterface = ""; foreach (RouteEntry Entry in EntryList) { Engine.Instance.Logs.Log(LogType.Verbose, Entry.ToString()); } throw new Exception("error"); } /* * foreach (RouteEntry Entry in EntryList) * { * if (IsIP(Entry.Gateway)) * { * EntryRemoved[Entry.Key] = Entry; * Engine.Instance.Logs.Log(LogType.Verbose, Messages.Format(Messages.NetworkLockRouteRemoved, Entry.ToString())); * Entry.Remove(); * } * } */ IpAddress destinationHole = DefaultGateway; string interfaceHole = "1"; int routesHoleN = 4; for (int i = 0; i < routesHoleN; i++) { string maskHole = "192.0.0.0"; string ipHole = Conversions.ToString((256 / routesHoleN * i)) + ".0.0.0"; RouteAdd(ipHole, maskHole, destinationHole, interfaceHole); } }
private static void OnEntryAdded(LogEntry entry) { EntryAdded?.Invoke(entry); }
public AddEntryForm() { InitializeComponent(); addEntryControl1.saveButton.Click += SaveButtonOnClick; addEntryControl1.EntryAdded += (o, e) => EntryAdded?.Invoke(o, e); }
public void Add(DataEntry item) { entries.Add(item); EntryAdded?.Invoke(this, new UI.GenericEventArgs <UI.DataEntry>(item)); }
public void Insert(int index, DataEntry item) { entries.Insert(index, item); EntryAdded?.Invoke(this, new UI.GenericEventArgs <UI.DataEntry>(item)); }
public void Log(EnumLogType logType, string format, params object[] args) { LogImpl(logType, format, args); EntryAdded?.Invoke(logType, format, args); }
protected virtual void OnEntryAdded(ConsoleEntryAddedEventArgs e) { EntryAdded?.Invoke(this, e); }
/// <summary> /// Adds an entry to the dictionary. /// </summary> public void Add(K key, V value) { dictionary.Add(key, value); EntryAdded?.Invoke(this, new EntryAddedEventArgs <K, V>(key, value)); }
/// <summary> /// Adds an element with the provided key and value to the dictionary. /// </summary> public void Add(KeyValuePair <K, V> entry) { ((IDictionary <K, V>)dictionary).Add(entry); EntryAdded?.Invoke(this, new EntryAddedEventArgs <K, V>(entry.Key, entry.Value)); }
public void AddEntry() { storage.Add(null); EntryAdded?.Invoke(this, new StorageEntryEventArgs(storage.Count - 1)); }
protected void NotifyEntryAdded(Entry entry) { EntryAdded?.Invoke(this, new AddEntryEventArgs { Entry = entry }); }
private async Task <SetStatus> SetValueCoreAsyncCore(TKey key, Stream value) { ulong totalBytesRead = 0; const long bufferSize = 4096; var tmpFileName = Path.Combine(CachePath.FullName, Guid.NewGuid().ToString()); string hash = null; using (var shaHasher = new SHA256Managed()) { using (var writer = File.OpenWrite(tmpFileName)) { byte[] oldBuffer; int oldBytesRead; var buffer = new byte[bufferSize]; var bytesRead = await value.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); totalBytesRead += Convert.ToUInt32(bytesRead); do { oldBytesRead = bytesRead; oldBuffer = buffer; buffer = new byte[bufferSize]; bytesRead = await value.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false); totalBytesRead += Convert.ToUInt32(bytesRead); if (bytesRead == 0) { shaHasher.TransformFinalBlock(oldBuffer, 0, oldBytesRead); await writer.WriteAsync(oldBuffer, 0, oldBytesRead).ConfigureAwait(false); } else { shaHasher.TransformBlock(oldBuffer, 0, oldBytesRead, oldBuffer, 0); await writer.WriteAsync(oldBuffer, 0, oldBytesRead).ConfigureAwait(false); } }while (bytesRead != 0 && totalBytesRead <= MaximumStorageCapacity); } if (totalBytesRead > MaximumStorageCapacity) { File.Delete(tmpFileName); // remove the file, we can't keep it anyway return(SetStatus.DataTooLarge); } var shaHashBytes = shaHasher.Hash; hash = BitConverter.ToString(shaHashBytes).Replace("-", string.Empty); } var isNew = !await ContainsKeyAsync(key).ConfigureAwait(false); var cachePath = GetPath(hash); var cachePathDir = Path.GetDirectoryName(cachePath); if (!Directory.Exists(cachePathDir)) { Directory.CreateDirectory(cachePathDir); } File.Move(tmpFileName, cachePath); var cacheFileInfo = new FileInfo(cachePath); _fileLookup[key] = new FileEntry <TKey>(key, cachePath); //cachePath; var cacheEntry = new CacheEntry <TKey>(key, Convert.ToUInt64(cacheFileInfo.Length)); _entryLookup[key] = cacheEntry; if (isNew) { EntryAdded?.Invoke(this, cacheEntry); } else { EntryUpdated?.Invoke(this, cacheEntry); } ApplyCachePolicy(); return(SetStatus.Success); }