Saigkills Toolbox Sascha Manns

  • Move Introduction
    Open Introduction

    Introduction

    This is a collection of my personal tools and libraries.

    • Firewall checker
    • DateOnlyConverter
    • DateTimeExtensions
    • IEnumerableExtensions
    • StringExtensions
    • DataTableGenerator
    • TemporaryDirectory Generator
    • Hash Generator
    • TemporaryFile Generator
    • Pipeline pattern support
    • Retry pattern support
    • CSV Service
    • Email Service
    • WebDav Service

    The project is splitted into several subprojects. Each subproject is a single NuGet package.

    Introduction 65 words
  • Move Checker
    Open Checker

    CheckIpAndPort

    That method checks, if a given IP and a given port is accesable.

    Usage

    bool isAvailable = Firewall.CheckIpAndPort("127.0.0.1", 80);
    

    The result value is a Ardalis.Result, what represents if its available or not.

    PingIp

    Checks if a given IP is pingable.

    Usage

    bool isAvailable = Firewall.PingIp("127.0.0.1");
    

    The result value is a Ardalis.Result, what represents if its available or not.

    Checker 67 words
  • Move Converter
    Open Converter

    DateOnlyConverter

    The DateOnlyConverter is an extension for any database context within the Entity Framework. If this is integrated, all DateOnly fields are mapped to DateTime.

    Converter 26 words
  • Move Extensions
    Open Extensions

    DateTimeExtensions

    ConvertDateToNumeric

    This method converts DateTime to a purely numeric value in the format "yyyyMMdd". Example: 20240112

    var dt = DateTime.Now;
    var myInt = dt.ConvertDateToNumeric(dt);
    

    ConvertDateTimeToString

    This method converts the DateTime object to the format "yyyy-MM-dd HH:mm:ssZ"

    var dt = DateTime.Now;
    var myInt = dt.ConvertDateTimeToString(dt);
    

    IsBetween

    This method checks if a given DateTime is between two other DateTime values. Returns true if the date is between the start and end dates, inclusive.

    var date = new DateTime(2023, 10, 15);
    var startDate = new DateTime(2023, 10, 1);
    var endDate = new DateTime(2023, 10, 31);
    
    var result = date.IsBetween(startDate, endDate);
    

    StartOfDay

    This method returns the start of the day for a given DateTime, setting the time to 00:00:00.

    var date = new DateTime(2023, 10, 15, 14, 30, 45);     
    var result = date.StartOfDay();
    
    Extensions 838 words
  • Move Generators
    Open Generators

    DataTableGenerator

    The DataTableGenerator is a generic class that creates a DataTable from any list model.

    Instantiation and call

    private void YourMethod()
    {
    List<SourceModel> yourModel = new();
    var logger = new ILogger<DataTableGenerator>();
    var dtg = new DataTableGenerator<SourceModel>(logger);
    var yourDataTable = dtg.GenerateDataTablleFromModelList(yourModel, false);
    }
    

    ID field

    The method offers two modes. In the "withId = true" mode, a DataTable with an ID field is created. If false is set, a table without an ID field is generated.

    Hash

    Simple hashing method. Just give him a string and it works for you.

    Temporary Directory

    This method creates a randomly generated directory and returns the path.

    Usage

    var tempDirectory = TempTools.GetTemporaryDirectory();
    

    TemporaryFile

    Generates and disposes a temporary file.

    Generators 125 words
  • Move Patterns
    Open Patterns

    Pipeline Pattern

    This is a behavioral pattern where the main goal is to split a complex job into multiple steps, each with a specific functionality. It�s really good for several types of architectures. For a system composed of various microservices with numerous components, this is a way to keep things easier to read and maintain. This pattern has several key concepts similar to the chain of responsibility one.

    IPipeline

    public interface IPipeline<T>
    {
        public string Name { get; set; }
        public IReadOnlyCollection<IStep> Steps { get; }
        void WithStep(IStep step);
        Task<T> StartAsync(IData data);
    }
    

    IStep

    public interface IStep
    {
        Task<IData> ExecuteAsync(IData data);
    }
    

    Pipeline generic

    public class Pipeline<T> : IPipeline<T> where T : IData
    {
        private readonly List<IStep> _steps = new();
        public string Name { get; set; }
        public IReadOnlyCollection<IStep> Steps => _steps;
    
        public Pipeline(strin
    
    Patterns 323 words
  • Move Untitled
    Open Untitled

    CsvService

    The CsvService offers the possibility to pass any list model in order to generate a CSV file from it.

    Usage

    DependencyInjection (Program.cs)

    Host.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration((hostingContext, configuration) =>
        {
            configuration.Sources.Clear();
            configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            IConfigurationRoot configurationRoot = configuration.Build();
            Configuration = configurationRoot;              
        }).ConfigureServices((services) =>
        {
            services.AddSingleton<IConfigurationRoot>(Configuration);        
            services.AddSingleton<ICsvWriterService, CsvWriterService>();
        });
    

    Usage after Dependency Injection

    private void DeineMethode()
    {
       var model = new SomeModel();
       await _service,Write(model, pathWithFilename);
    }
    

    EmailService

    A service for sending emails. This implementation is for usecases where t

    Untitled 685 words