Files
HLib/Batch/Cleanup/CleanupStepHandlerUxer.cs
T
2026-06-01 13:23:34 +09:00

52 lines
1.8 KiB
C#

using KssSmaPlaLib.Batch.Interface;
using KssSmaPlaLib.Cleanup;
using KssSmaPlaLib.Commons;
using KssSmaPlaLib.Ini;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static KssSmaPlaLib.Batch.Sftp.SftpStepHandlerUxer;
namespace KssSmaPlaLib.Batch.Cleanup
{
public class CleanupStepHandlerUxer
{
public FuncCleanupByIniResultDto TryFuncCleanupByIni(
string iniFilePath,
string secsionName)
{
const string KEY_FOLDER_PATH = "FolderPath";
var result = new FuncCleanupByIniResultDto();
var cuDic = IniReferenceResolveUxer.ReadSectionWithReference(iniFilePath, secsionName);
var folderPath = DictionaryUxer.GetValueOrDefault(cuDic, KEY_FOLDER_PATH, string.Empty);
if (string.IsNullOrEmpty(folderPath))
{
LoggerUxer.Info($"フォルダパスが未指定のため、クリーンアップ機能をスキップしました。[キー:{KEY_FOLDER_PATH}]");
result.Succeeded = true;
return result;
}
if (!FileCleanupUxer.TryFileCleanupByDic(cuDic, out var messageForMe))
{
result.ResultMessage = $"ファイルのクリーンナップに失敗しました。[エラー内容:{messageForMe}]";
result.ExitCode = (int)RetCodeUxer.RetCode.CleanupError;
result.Succeeded = false;
return result;
}
result.Succeeded = true;
return result;
}
public class FuncCleanupByIniResultDto : IFuncResultDto
{
public bool Succeeded { get; set; } = false;
public int ExitCode { get; set; } = 0;
public string ResultMessage { get; set; } = string.Empty;
}
}
}