Skip to content

Commit

Permalink
General cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Jul 5, 2023
1 parent 846b99a commit 9aeb360
Show file tree
Hide file tree
Showing 83 changed files with 227 additions and 334 deletions.
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.CsvToJson/CsvToJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override TaskStatus Run()
{
Info("Converting CSV files to JSON files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.CsvToYaml/CsvToYaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override TaskStatus Run()
{
Info("Converting CSV files to YAML files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
12 changes: 2 additions & 10 deletions src/net/Wexflow.Tasks.FileContentMatch/FileContentMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override TaskStatus Run()
{
Info("Checking file...");

var success = true;
bool success;
TaskStatus status = null;

try
Expand Down Expand Up @@ -90,15 +90,7 @@ private bool CheckFile(ref TaskStatus status)
// Checking folders
foreach (var folder in FoldersToCheck)
{
var files = Array.Empty<string>();
if (Recursive)
{
files = Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories);
}
else
{
files = Directory.GetFiles(folder);
}
var files = Recursive ? Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) : Directory.GetFiles(folder);

foreach (var file in files)
{
Expand Down
11 changes: 2 additions & 9 deletions src/net/Wexflow.Tasks.FileExists/FileExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()
{
Info("Checking file...");

var success = false;
bool success;

try
{
Expand Down Expand Up @@ -73,14 +73,7 @@ private bool CheckFile()
{
var success = System.IO.File.Exists(File);

if (success)
{
InfoFormat("The file {0} exist.", File);
}
else
{
InfoFormat("The file {0} does not exist.", File);
}
InfoFormat(success ? "The file {0} exist." : "The file {0} does not exist.", File);

return success;
}
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FileMatch/FileMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override TaskStatus Run()
{
Info("Checking file...");

var success = false;
bool success;
TaskStatus status = null;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesConcat/FilesConcat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()
{
Info("Concatenating files...");

var success = true;
bool success;
var atLeastOneSucceed = false;

try
Expand Down
6 changes: 3 additions & 3 deletions src/net/Wexflow.Tasks.FilesCopier/FilesCopier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override TaskStatus Run()
{
Info("Copying files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down Expand Up @@ -85,7 +85,7 @@ private bool CopyFiles(ref bool atLeastOneSuccess)
if (!string.IsNullOrWhiteSpace(PreserveFolderStructFrom) &&
file.Path.StartsWith(PreserveFolderStructFrom, StringComparison.InvariantCultureIgnoreCase))
{
var preservedFolderStruct = Path.GetDirectoryName(file.Path);
var preservedFolderStruct = Path.GetDirectoryName(file.Path) ?? throw new InvalidOperationException();
preservedFolderStruct = preservedFolderStruct.Length > PreserveFolderStructFrom.Length
? preservedFolderStruct.Remove(0, PreserveFolderStructFrom.Length)
: string.Empty;
Expand All @@ -107,7 +107,7 @@ private bool CopyFiles(ref bool atLeastOneSuccess)
if (AllowCreateDirectory && !Directory.Exists(Path.GetDirectoryName(destPath)))
{
InfoFormat("Creating directory: {0}", Path.GetDirectoryName(destPath));
_ = Directory.CreateDirectory(Path.GetDirectoryName(destPath));
_ = Directory.CreateDirectory(Path.GetDirectoryName(destPath)??throw new InvalidOperationException());
}

File.Copy(file.Path, destPath, Overwrite);
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesDecryptor/FilesDecryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
Info("Decrypting files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesEncryptor/FilesEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
Info("Encrypting files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesEqual/FilesEqual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override TaskStatus Run()
{
Info("Checking...");

var success = true;
bool success;

try
{
Expand Down
6 changes: 5 additions & 1 deletion src/net/Wexflow.Tasks.FilesInfo/FilesInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ public class FilesInfo : Task

public FilesInfo(XElement xe, Workflow wf) : base(xe, wf)
{
SmbComputerName = GetSetting("smbComputerName");
SmbDomain = GetSetting("smbDomain");
SmbUsername = GetSetting("smbUsername");
SmbPassword = GetSetting("smbPassword");
}

public override TaskStatus Run()
{
Info("Generating files informations...");

var success = true;
bool success;
var atLeastOneSucceed = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesJoiner/FilesJoiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override TaskStatus Run()
{
Info("Concatenating files...");

var success = true;
bool success;
var atLeastOneSucceed = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesLoader/FilesLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override TaskStatus Run()
{
Info("Loading files...");

var success = true;
bool success;

try
{
Expand Down
6 changes: 3 additions & 3 deletions src/net/Wexflow.Tasks.FilesMover/FilesMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override TaskStatus Run()
{
Info("Moving files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down Expand Up @@ -90,7 +90,7 @@ private bool MoveFiles(ref bool atLeastOneSucceed)
if (!string.IsNullOrWhiteSpace(PreserveFolderStructFrom) &&
file.Path.StartsWith(PreserveFolderStructFrom, StringComparison.InvariantCultureIgnoreCase))
{
var preservedFolderStruct = Path.GetDirectoryName(file.Path);
var preservedFolderStruct = Path.GetDirectoryName(file.Path) ?? throw new InvalidOperationException();
preservedFolderStruct = preservedFolderStruct.Length > PreserveFolderStructFrom.Length
? preservedFolderStruct.Remove(0, PreserveFolderStructFrom.Length)
: string.Empty;
Expand Down Expand Up @@ -118,7 +118,7 @@ private bool MoveFiles(ref bool atLeastOneSucceed)
if (AllowCreateDirectory && !Directory.Exists(Path.GetDirectoryName(destFilePath)))
{
InfoFormat("Creating directory: {0}", Path.GetDirectoryName(destFilePath));
_ = Directory.CreateDirectory(Path.GetDirectoryName(destFilePath));
_ = Directory.CreateDirectory(Path.GetDirectoryName(destFilePath) ?? throw new InvalidOperationException());
}

if (File.Exists(destFilePath))
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesRemover/FilesRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override TaskStatus Run()
{
Info("Removing files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesRenamer/FilesRenamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override TaskStatus Run()
{
Info("Renaming files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.FilesSplitter/FilesSplitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
Info("Splitting files into chunks...");

var success = true;
bool success;
var atLeastOneSucceed = false;

try
Expand Down
11 changes: 2 additions & 9 deletions src/net/Wexflow.Tasks.FolderExists/FolderExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override TaskStatus Run()
{
Info("Checking folder...");

var success = false;
bool success;
TaskStatus status = null;

try
Expand Down Expand Up @@ -65,14 +65,7 @@ private bool CheckFolder(ref TaskStatus status)
{
success = System.IO.Directory.Exists(Folder);

if (success)
{
InfoFormat("The folder {0} exists.", Folder);
}
else
{
InfoFormat("The folder {0} does not exist.", Folder);
}
InfoFormat(success ? "The folder {0} exists." : "The folder {0} does not exist.", Folder);
}
catch (ThreadAbortException)
{
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.Ftp/Ftp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override TaskStatus Run()
{
Info("Processing files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.Ftp/PluginFTP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public override void Upload(FileInf file)
public static void UploadFile(FtpClient client, FileInf file)
{
using (Stream istream = File.Open(file.Path, FileMode.Open, FileAccess.Read))
using (var ostream = client.OpenWrite(file.RenameToOrName, FtpDataType.Binary))
using (var ostream = client.OpenWrite(file.RenameToOrName))
{
var buffer = new byte[BufferSize];
int r;
Expand Down
8 changes: 4 additions & 4 deletions src/net/Wexflow.Tasks.Ftp/PluginFTPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public override FileInf[] List()
client.Config.DataConnectionType = FtpDataConnectionType.PASV;
client.Config.EncryptionMode = _encryptionMode;
client.Config.ValidateAnyCertificate = true;
client.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
client.ValidateCertificate += OnValidateCertificate;
client.Connect();
client.SetWorkingDirectory(Path);

Expand All @@ -92,7 +92,7 @@ public override void Upload(FileInf file)
client.LegacyLogger = OnLogEvent;
}

client.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
client.ValidateCertificate += OnValidateCertificate;
client.Config.DataConnectionType = FtpDataConnectionType.PASV;
client.Config.EncryptionMode = _encryptionMode;

Expand Down Expand Up @@ -126,7 +126,7 @@ public override void Download(FileInf file)
client.LegacyLogger = OnLogEvent;
}

client.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
client.ValidateCertificate += OnValidateCertificate;
client.Connect();
client.SetWorkingDirectory(Path);

Expand All @@ -151,7 +151,7 @@ public override void Delete(FileInf file)
client.LegacyLogger = OnLogEvent;
}

client.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
client.ValidateCertificate += OnValidateCertificate;
client.Connect();
client.SetWorkingDirectory(Path);

Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.HtmlToPdf/HtmlToPdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override TaskStatus Run()
{
Info("Generating PDF files from HTML files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.HtmlToText/HtmlToText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
Info("Extracting text from HTML files...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.ImagesConcat/ImagesConcat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override TaskStatus Run()
{
Info("Concatenating images...");

var success = true;
bool success;

try
{
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.ImagesCropper/ImagesCropper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override TaskStatus Run()
{
Info("Cropping images...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.ImagesOverlay/ImagesOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ImagesOverlay(XElement xe, Workflow wf) : base(xe, wf)
public override TaskStatus Run()
{
Info("Overlaying images...");
var success = true;
bool success;

try
{
Expand Down
2 changes: 1 addition & 1 deletion src/net/Wexflow.Tasks.ImagesResizer/ImagesResizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override TaskStatus Run()
{
Info("Resizing images...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
15 changes: 1 addition & 14 deletions src/net/Wexflow.Tasks.ImagesTransformer/ImagesTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

namespace Wexflow.Tasks.ImagesTransformer
{
public enum ImgFormat
{
Bmp,
Emf,
Exif,
Gif,
Icon,
Jpeg,
Png,
Tiff,
Wmf
}

public class ImagesTransformer : Task
{
public string OutputFilePattern { get; }
Expand All @@ -44,7 +31,7 @@ public override TaskStatus Run()
{
Info("Transforming images...");

var success = true;
bool success;
var atLeastOneSuccess = false;

try
Expand Down
Loading

0 comments on commit 9aeb360

Please sign in to comment.