• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 8598528338

08 Apr 2024 10:28AM UTC coverage: 56.914% (+0.08%) from 56.837%
8598528338

push

github

web-flow
Move 8.1.5 to main for autoupdater (#1797)

* bump to net8

* add sqlcli

* Bump Autoupdater.NET.Official from 1.8.4 to 1.8.5

Bumps [Autoupdater.NET.Official](https://github.com/ravibpatel/AutoUpdater.NET) from 1.8.4 to 1.8.5.
- [Release notes](https://github.com/ravibpatel/AutoUpdater.NET/releases)
- [Commits](https://github.com/ravibpatel/AutoUpdater.NET/compare/v1.8.4...v1.8.5)

---
updated-dependencies:
- dependency-name: Autoupdater.NET.Official
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Delete .nuget/packages.config (#1758)

* Delete .nuget/packages.config

Remove  hopefully obsolete package list confusing dependency tracking

* Remove .nuget folder

---------

Co-authored-by: James A Sutherland <>

* Bump svenstaro/upload-release-action from 2.7.0 to 2.9.0 (#1759)

* Bump shogo82148/actions-setup-perl from 1.28.0 to 1.29.0 (#1751)

Bumps [shogo82148/actions-setup-perl](https://github.com/shogo82148/actions-setup-perl) from 1.28.0 to 1.29.0.
- [Release notes](https://github.com/shogo82148/actions-setup-perl/releases)
- [Commits](https://github.com/shogo82148/actions-setup-perl/compare/v1.28.0...v1.29.0)

---
updated-dependencies:
- dependency-name: shogo82148/actions-setup-perl
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Friel <jfriel001@dundee.ac.uk>

* Bump CsvHelper from 30.0.3 to 30.1.0 (#1737)

Bumps [CsvHelper](https://github.com/JoshClose/CsvHelper) from 30.0.3 to 30.1.0.
- [Commits](https://github.com/JoshClose/CsvHelper/compare/30.0.3...30.1.0)

---
updated-dependencies:
- dependency-name: CsvHelper
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

S... (continued)

10835 of 20509 branches covered (52.83%)

Branch coverage included in aggregate %.

99 of 176 new or added lines in 33 files covered. (56.25%)

10 existing lines in 7 files now uncovered.

30856 of 52744 relevant lines covered (58.5%)

7400.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewFileBasedProcessTask.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.IO;
9
using System.Linq;
10
using Rdmp.Core.Curation;
11
using Rdmp.Core.Curation.Data.DataLoad;
12
using Rdmp.Core.Icons.IconOverlays;
13
using Rdmp.Core.Icons.IconProvision;
14
using Rdmp.Core.Repositories;
15
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
16
using SixLabors.ImageSharp;
17
using SixLabors.ImageSharp.PixelFormats;
18

19
namespace Rdmp.Core.CommandExecution.AtomicCommands;
20

21
public class ExecuteCommandCreateNewFileBasedProcessTask : BasicCommandExecution
22
{
23
    private readonly ProcessTaskType _taskType;
24
    private readonly LoadMetadata _loadMetadata;
25
    private readonly LoadStage _loadStage;
26
    private readonly LoadDirectory _loadDirectory;
27
    private FileInfo _file;
28

29
    public ExecuteCommandCreateNewFileBasedProcessTask(IBasicActivateItems activator, ProcessTaskType taskType,
30
        LoadMetadata loadMetadata, LoadStage loadStage, FileInfo file = null) : base(activator)
×
31
    {
32
        _taskType = taskType;
×
33
        _loadMetadata = loadMetadata;
×
34
        _loadStage = loadStage;
×
35

36
        try
37
        {
38
            _loadDirectory = new LoadDirectory(_loadMetadata.LocationOfFlatFiles);
×
39
        }
×
40
        catch (Exception)
×
41
        {
42
            SetImpossible("Could not construct LoadDirectory");
×
43
        }
×
44

45
        ProcessTaskType[] AcceptedProcessTaskTypes = { ProcessTaskType.SQLFile, ProcessTaskType.Executable, ProcessTaskType.SQLBakFile };
×
46
        if (!AcceptedProcessTaskTypes.Contains(taskType))
×
47
            SetImpossible("Only SQLFile, SqlBakFile and Executable task types are supported by this command");
×
48

49
        if (!ProcessTask.IsCompatibleStage(taskType, loadStage))
×
50
            SetImpossible($"You cannot run {taskType} in {loadStage}");
×
51

52
        _file = file;
×
53
    }
×
54

55
    public override void Execute()
56
    {
57
        base.Execute();
×
58

59
        if (_file == null)
×
60
        {
61
            if (_taskType == ProcessTaskType.SQLBakFile)
×
62
            {
NEW
63
                _file = BasicActivator.SelectFile("Enter the .bak file's path", "*.bak", "*.bak");
×
64
            }
65
            else if (_taskType == ProcessTaskType.SQLFile)
×
66
            {
67
                if (!BasicActivator.TypeText("Enter a name for the SQL file", "File name", 100, "myscript.sql",
×
68
                        out var selected, false)) return;
×
69

70
                var target = Path.Combine(_loadDirectory.ExecutablesPath.FullName, selected);
×
71

72
                if (!target.EndsWith(".sql"))
×
73
                    target += ".sql";
×
74

75
                //create it if it doesn't exist
76
                if (!File.Exists(target))
×
77
                    File.WriteAllText(target, "/*todo Type some SQL*/");
×
78

79
                _file = new FileInfo(target);
×
80

81
            }
82
            else if (_taskType == ProcessTaskType.Executable)
×
83
            {
84
                _file = BasicActivator.SelectFile("Enter executable's path", "Executables", "*.exe");
×
85

86
                // they didn't pick one
87
                if (_file == null)
×
88
                    return;
×
89

90
                if (!_file.Exists)
×
91
                    throw new FileNotFoundException("File did not exist");
×
92
            }
93
            else
94
            {
95
                throw new ArgumentOutOfRangeException($"Unexpected _taskType:{_taskType}");
×
96
            }
97
        }
98

99
        var task = new ProcessTask((ICatalogueRepository)_loadMetadata.Repository, _loadMetadata, _loadStage)
×
100
        {
×
101
            ProcessTaskType = _taskType,
×
102
            Path = _file.FullName
×
103
        };
×
104
        SaveAndShow(task);
×
105
    }
×
106

107
    private void SaveAndShow(ProcessTask task)
108
    {
109
        task.Name = $"Run '{Path.GetFileName(task.Path)}'";
×
110
        task.SaveToDatabase();
×
111

112
        Publish(_loadMetadata);
×
113
        Activate(task);
×
114
    }
×
115

116
    public override string GetCommandName()
117
    {
118
        return _taskType switch
×
119
        {
×
120
            ProcessTaskType.Executable => "Add Run .exe File Task",
×
121
            ProcessTaskType.SQLFile => "Add Run SQL Script Task",
×
122
            ProcessTaskType.SQLBakFile => "Add SQL backup File Task",
×
123
            _ => throw new ArgumentOutOfRangeException()
×
124
        };
×
125
    }
126

127
    public override Image<Rgba32> GetImage(IIconProvider iconProvider)
128
    {
129
        return _taskType switch
×
130
        {
×
131
            ProcessTaskType.SQLFile => iconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Add),
×
132
            ProcessTaskType.SQLBakFile => iconProvider.GetImage(RDMPConcept.SQL, OverlayKind.Add), //todo maybe better
×
133
            ProcessTaskType.Executable => IconOverlayProvider.GetOverlayNoCache(
×
134
                Image.Load<Rgba32>(CatalogueIcons.Exe), OverlayKind.Add),
×
135
            _ => null
×
136
        };
×
137
    }
138
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc