40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System;
|
|
using System.Configuration;
|
|
|
|
namespace HanvonF710XAttendanceService
|
|
{
|
|
internal static class MachineUserDeleteSettings
|
|
{
|
|
public const int DefaultBatchSize = 20;
|
|
public const int DefaultHttpTimeoutMs = 60000;
|
|
|
|
public static int GetBatchSize()
|
|
{
|
|
return GetPositiveInt("DEVICE_DELETE_BATCH_SIZE", DefaultBatchSize);
|
|
}
|
|
|
|
public static int GetHttpTimeoutMs()
|
|
{
|
|
return GetPositiveInt("DEVICE_HTTP_TIMEOUT_MS", DefaultHttpTimeoutMs);
|
|
}
|
|
|
|
private static int GetPositiveInt(string key, int defaultValue)
|
|
{
|
|
try
|
|
{
|
|
var raw = ConfigurationManager.AppSettings[key];
|
|
if (string.IsNullOrWhiteSpace(raw))
|
|
{
|
|
return defaultValue;
|
|
}
|
|
|
|
return int.TryParse(raw.Trim(), out int value) && value > 0 ? value : defaultValue;
|
|
}
|
|
catch
|
|
{
|
|
return defaultValue;
|
|
}
|
|
}
|
|
}
|
|
}
|