Code Monkey home page Code Monkey logo

logblotter-fsw-powershell's Introduction

LogBlotter

File System Watcher integrated with WPF GUI running in Powershell.

Feature

XAML in Powershell

We can use the C# library to read the XAML so that we can make a form using WPF. After we know that we can make a DataGrid to display all the data I store in an observable. This is only a lame DataGrid, just to demo the work.

File System Watching (FSW)

This is a brief introduction on what you can do with this File system watcher, for more information please read the documentation Written in MSDN

  • Filter : to filter the files you want to watch using regex, e.g. *.log, *.txt, *.abc
  • Path : the path which the file located, Network Path is also acceptable (To someone it may conern)
  • IncludeSubdirectories : whether you want to watch all the sub directories in that Path.
  • NotifyFilter : what property you want to watch for: LastAccess , LastWrite, FileName , DirectoryName...

I only use the FSW to watch the content changes in the log files, but we can monitor for the Create, Change, Delete of files and I register an event so it will update my internal object when something changes.

Communication between different Runspace

If you use a Dispatcher which is more or less a messager to the XAML Form, it would takes some time and it would be worse if it grows bigger so you have multiple runspace communication, which causes some runspace violation, if the communication is two different runspace.(not created)

To use dispatcher it may takes a lot of times to run only one small update (which will stuck the FSW Event, pipeline overflow eventually) so I use a Timer Dispatcher, which will run every specific amount of time you decide and if the action is small enough it will work smoother than the normal dispatcher.

(This is only my personal experience, this may not be always correct, but this is worth to take into account.) My default is 10s for every update

Reference

I am a new-joiner to the Powershell Family. I read a lot of googles, stack Overflows, ss64 to complete the whole program. The URL below is the one I found most useful and I reference some part of my code from them:

About Powershell: https://ss64.com/ps/

About the Runspace: https://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/

About the Runspace & Oberservable: https://learn-powershell.net/2012/12/08/powershell-and-wpf-listbox-part-2datatriggers-and-observablecollection/

About the File System Watcher: https://referencesource.microsoft.com/#system/services/io/system/io/FileSystemWatcher.cs

They are great, credits on them.

logblotter-fsw-powershell's People

Contributors

ivankwongtszfung avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.