static void Main() { LogMessageQueue.Initialize(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainWindow()); }
private void Button_Click_RESET_ALL(object sender, RoutedEventArgs e) { ResetAllLoggerConfigCommand logCommand = new ResetAllLoggerConfigCommand(); LogMessageQueue.getInstance().sendCommand(logCommand); LogMessageQueue.getInstance().ModifiedLoggerList.Clear(); }
private void probe() { DateTime now = DateTime.Now; if (lastProbeTime.AddSeconds(10) >= now) { MessageBox.Show("正在探测中,请稍后...", "", MessageBoxButton.OK); return; } string contextName = this.AllServiceComboBox.Text; if (String.IsNullOrEmpty(contextName)) { MessageBox.Show("必须选择服务!", "", MessageBoxButton.OK); return; } LogMessageQueue.getInstance().clearLoggerList(); LogMessageQueue.getInstance().clearModifiedProbeLoggerList(); lastProbeTime = now; ProbeLoggerCommand2 probeLogCommand = new ProbeLoggerCommand2(); probeLogCommand.contextName = contextName; probeLogCommand.loggerName = this.FilterLoggerNameTextBox.Text; LogMessageQueue.getInstance().sendCommand(probeLogCommand); }
// // Public methods // #region Public methods // Constructor public LogConsumerActivity(int cThreadsNum, LogMessageQueue cLogMessageQueue, CancellationToken cCancToken) { // Initialize members mLogMessageQueue = cLogMessageQueue; mConsoleLogger = new ConsoleLogger(cThreadsNum); mCancToken = cCancToken; }
protected LogDestinationBase() { Id = Guid.NewGuid(); _destinationQueue = new LogMessageQueue() { IsBlocking = true }; //default all log destinations to block _destinationQueue.MessagesDropped += MessagesDropped; _destinationQueue.MessagesBlocked += MessagesBlocked; }
// // Public methods // #region Public methods // Constructor public PasswordConsumerActivity(string cFileName, int cIndex, TaskCompletionSource <string> cPasswordRes, PasswordQueue cPasswordQueue, LogMessageQueue cMessageLogQueue) { // Initialize members mFileName = cFileName; mPasswordRes = cPasswordRes; mPasswordQueue = cPasswordQueue; mPasswordChecker = new PasswordChecker(cFileName); mLogMessageQueue = cMessageLogQueue; mIndex = cIndex; }
private void probeService() { DateTime now = DateTime.Now; if (lastProbeService.AddSeconds(10) >= now) { MessageBox.Show("正在探测中,请稍后...", "", MessageBoxButton.OK); return; } lastProbeService = now; ProbeServiceCommand probeLogCommand = new ProbeServiceCommand(); LogMessageQueue.getInstance().sendCommand(probeLogCommand); }
public ConfigLoggerWindow() { InitializeComponent(); AllServiceComboBox.ItemsSource = LogMessageQueue.getInstance().ServicesList; allLoggerListCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(LogMessageQueue.getInstance().LoggerList); allLoggerListCollectionView.CustomSort = new LoggerSorter(); allLoggerListCollectionView.Filter = (logger) => { Logger probeLogger = logger as Logger; if (!String.IsNullOrWhiteSpace(filterServiceName)) { if (!String.Equals(filterServiceName, probeLogger.contextName)) { return(false); } } if (!String.IsNullOrWhiteSpace(filterLoggerName)) { if (String.IsNullOrWhiteSpace(probeLogger.loggerName)) { return(false); } if (probeLogger.loggerName.IndexOf(filterLoggerName) == -1) { return(false); } } return(true); }; allLoggerListView.ItemsSource = allLoggerListCollectionView; // modifiedLoggerListCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(LogMessageQueue.getInstance().ModifiedLoggerList); modifiedLoggerListCollectionView.CustomSort = new LoggerSorter(); modifiedLoggerListView.ItemsSource = modifiedLoggerListCollectionView; probeService(); }
public static void Run([QueueTrigger("LogMessageQueue")] string myQueueItem , [StorageAccount("AzureWebJobsStorage")] CloudStorageAccount storageAccount , ILogger log) { log.LogInformation($"C# Queue trigger function processed: {myQueueItem}"); LogMessageQueue _logMessageQueue = new LogMessageQueue("LogMessageQueue", Guid.NewGuid().ToString()); _logMessageQueue.Message = myQueueItem; _logMessageQueue.CreatedDate = DateTime.Now; CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable table = tableClient.GetTableReference("LogMessages"); table.CreateIfNotExistsAsync().GetAwaiter().GetResult(); TableOperation insertOperation = TableOperation.Insert(_logMessageQueue); table.ExecuteAsync(insertOperation).GetAwaiter().GetResult(); log.LogInformation("Completed logging the message to the table"); }
private void SetLoggerButton_Click(object sender, RoutedEventArgs e) { Logger item = ((Button)sender).DataContext as Logger; if (item == null) { return; } LogMessageQueue.getInstance().addToModifiedProbeLoggerList(item); ConfigLoggerCommand logCommand = new ConfigLoggerCommand(); logCommand.contextName = item.contextName; Logger probeLogger = new Logger(); probeLogger.loggerLevel = item.setLoggerLevel; probeLogger.loggerName = item.loggerName; logCommand.probeLoggers = new List <Logger>() { probeLogger }; LogMessageQueue.getInstance().sendCommand(logCommand); }
// // Private methods // #region Private methods // Crack password private void DoCrackPassword(int cThreadsNum, string cInitialPassword) { // Create cancellation token using (CancellationTokenSource token_src = new CancellationTokenSource()) { // Create task list List <Task> task_list = new List <Task>(); // Create queues var log_msg_queue = new LogMessageQueue(); var password_queue = new PasswordQueue(); // Create and add password producer var pwd_producer = new PasswordProducerActivity(cInitialPassword, password_queue, token_src.Token); task_list.Add(pwd_producer.Run()); // Create and add log consumer var log_consumer = new LogConsumerActivity(cThreadsNum, log_msg_queue, token_src.Token); task_list.Add(log_consumer.Run()); // Start stopwatch Stopwatch stop_watch = new Stopwatch(); stop_watch.Start(); // Create and add password consumers TaskCompletionSource <string> password_src = new TaskCompletionSource <string>(); for (int i = 1; i <= cThreadsNum; i++) { var pwd_consumer = new PasswordConsumerActivity(mFileName, i, password_src, password_queue, log_msg_queue); task_list.Add(pwd_consumer.Run()); } try { // Wait for password to be found Task <string> password_res = password_src.Task; password_res.Wait(); // Log password LogPassword(password_res.Result); } catch (Exception ex) { // Re-throw exception if cannot be handled if (!HandleException(ex)) { throw; } } finally { // Stop stopwatch stop_watch.Stop(); // Cancel the other tasks (log consumer and password producer) token_src.Cancel(); // Wait for all to finish Task.WaitAll(task_list.ToArray()); // Print elapsed time Console.WriteLine(String.Format("Elapsed time: {0}", stop_watch.Elapsed)); } } }
private void Application_Exit(object sender, ExitEventArgs e) { LogMessageQueue.getInstance().deinit(); }
private void Button_Click_Confirm(object sender, RoutedEventArgs e) { LogMessageQueue.getInstance(); ConfigLoggerWindow.showWindow(); this.Close(); }