#!/usr/bin/perl
use FindBin;
BEGIN { unshift @INC, "$FindBin::Bin/../lib" }

use v5.42;
use Moo;
use MooX::Options;
use Cwd;
use Mojo::Pg;

use feature 'say';
use feature 'signatures';
use Daje::Workflow::Activities::Files::Save;
use Daje::Workflow::Database::Model;
use Mojo::Pg;
use Daje::Workflow::Errors::Error;

use namespace::clean -except => [qw/_options_data _options_config/];

my $document = qq{package Daje::Controller::Super::SentinelTicket
use Mojo::Base 'Mojolicious::Controller', -signatures;
use v5.42;

# NAME
# ====
#
# Daje::Controller::Super::SentinelTicket - Model class
#
# SYNOPSIS
# ========
#
#       use Daje::Controller::Super::SentinelTicket##
#
# DESCRIPTION
# ===========
#
# Daje::Controller::SentinelTicket is a standard controller
#
# METHODS
# =======
#
#
# LICENSE
# =======
#
# Copyright (C) janeskil1525.
#
# This library is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# AUTHOR
# ======
#
#
# This file is generated automatically by Daje Tools .
# It will be re-generated by Daje Tools again.



1;

};

sub save_file() {

    my $pg = Mojo::Pg->new()->dsn(
        "dbi:Pg:dbname=daje;host=192.168.1.124;port=5432;user=daje;password=PV58nova64"
    );

    my $activity_data->{file}->{target_dir_tag} = "perl_dir";
    $activity_data->{file}->{filetype} = ".pm";
    $activity_data->{file}->{file_list_tag} = "perl";
    $activity_data->{file}->{path} =  1;
    my $model = Daje::Workflow::Database::Model->new(db => $pg->db);
    my $doc->{file} = "/home/jan/Project/Daje-Plugin-Sentinel/lib/Daje/Controller/Super/SentinelTicket.pm";
    $doc->{new_only} = 0;
    $doc->{data} = $document;
    $doc->{path} = 1;
    my $context;
    push @{$context->{context}->{payload}->{perl}}, $doc;

    my $generate = Daje::Workflow::Activities::Files::Save->new(
        db            => $pg->db,
        context       => $context,
        model         => $model,
        error         => Daje::Workflow::Errors::Error->new(),
        activity_data => $activity_data,
    );


    try {
        $generate->save();
    } catch ($e) {
        say $e;
    };

}

save_file();