NTP_V2/src/NTP.Application/Grains/Permits/GrainsPermitsOptions.cs

123 lines
5.8 KiB
C#

namespace NTP.Application.Grains.Permits;
/// <summary>
/// Configuration for the Grains permits slice (config section "Grains:Permits"). Replaces the legacy ColdFusion
/// application-scope variables that are NOT in the repository (application.GN_BadiyaSCAC, grnsOprationShft_*,
/// grnsdtrbutnshft_*, GN_ALLOWEDSTATUSES, PetWS, autoCallerIP, nafethApiKey). Defaults marked UNVERIFIED must be confirmed.
/// </summary>
public sealed class GrainsPermitsOptions
{
public const string SectionName = "Grains:Permits";
/// <summary>SCAC of the "owners / individuals" pseudo company (legacy application.GN_BadiyaSCAC; hard-coded 327 elsewhere in grains.cfc).</summary>
public long BadiyaScac { get; set; } = 327;
/// <summary>Stakeholder id of trucking companies (legacy session.stkid = 62): they only see their own permits.</summary>
public long CompanyStakeholderId { get; set; } = 62;
/// <summary>Operation window of shift 1/2 as [firstHour, lastHour] relative to the order date (legacy grnsOprationShft_1/2). UNVERIFIED defaults.</summary>
public int[] OperationShift1 { get; set; } = [6, 18];
public int[] OperationShift2 { get; set; } = [18, 30];
/// <summary>Distribution shifts [start, end] used to compute blacklist expiry (legacy grnsdtrbutnshft_N). UNVERIFIED defaults.</summary>
public int[] DistributionShift1 { get; set; } = [6, 18];
public int[] DistributionShift2 { get; set; } = [18, 30];
public int[] DistributionShift3 { get; set; } = [30, 42];
/// <summary>Statuses a truck/trailer/driver registration must have to be usable on a permit (legacy GN_ALLOWEDSTATUSES). UNVERIFIED.</summary>
public string[] AllowedStatuses { get; set; } = ["OPEN", "ACCPT"];
/// <summary>Initial value of the in-memory "absence" feature flag (legacy application.GNABSENCEFEATURE). UNVERIFIED.</summary>
public bool AbsenceFeatureEnabled { get; set; } = true;
/// <summary>MOT ownership codes allowed for owners / for companies (legacy GN_BadyahOwnership / GN_OthersOwnership).
/// Empty = the check is skipped (UNVERIFIED: the legacy values are not in the repository).</summary>
public string[] BadiyaOwnershipCodes { get; set; } = [];
public string[] OtherOwnershipCodes { get; set; } = [];
public TcsOptions Tcs { get; set; } = new();
public AutoCallOptions AutoCall { get; set; } = new();
public NotificationOptions Notifications { get; set; } = new();
public WeighbridgeSourceOptions WeighbridgeSource { get; set; } = new();
public JobOptions Jobs { get; set; } = new();
public int[] DistributionShift(long shift) => shift switch
{
2 => DistributionShift2,
3 => DistributionShift3,
_ => DistributionShift1
};
public int[] OperationShift(long shift) => shift == 1 ? OperationShift1 : OperationShift2;
}
/// <summary>Outbound TCS (petroleum permit web service, legacy application.PetWS) integration.</summary>
public sealed class TcsOptions
{
public bool Enabled { get; set; }
/// <summary>Endpoint of CreatePermitWS (legacy application.PetWS, ApplicationVariables.xml).</summary>
public string PermitServiceUrl { get; set; } = "http://192.168.1.90:8080/FDfolioWS/services/CreatePermitWS";
public int TimeoutSeconds { get; set; } = 60;
}
/// <summary>Outbound IVR / auto-dialer integration (GrainsFactoryWeb.autoCallService / autoCallService2, autoCallResponse.cfc).</summary>
public sealed class AutoCallOptions
{
public bool Enabled { get; set; }
/// <summary>Legacy application.autoCallerIP: receives {"TYPE":"TEST","FILE":"&lt;base64 csv&gt;"}.</summary>
public string SendUrl { get; set; } = string.Empty;
/// <summary>Legacy IVR web service (http://aqtcs.nafith.net/IVR/callivr.cfc) - callAPI.</summary>
public string IvrUrl { get; set; } = string.Empty;
/// <summary>Expected X-Api-Key of the dialer's callback (legacy application.nafethApiKey). Empty = callback disabled.</summary>
public string ApiKey { get; set; } = string.Empty;
public int TimeoutSeconds { get; set; } = 30;
/// <summary>How long the voice-call button waits for the IVR service before it reports "started" (the service answers only when it has dialed everybody).</summary>
public int IvrWaitSeconds { get; set; } = 20;
/// <summary>Longest time one IVR call may keep running in the background before it is abandoned.</summary>
public int IvrTimeoutMinutes { get; set; } = 15;
}
/// <summary>Mobile notifications (legacy NTP.components.MobileNotifications.PrepareNotificationMessage).</summary>
public sealed class NotificationOptions
{
public bool Enabled { get; set; }
public string Url { get; set; } = string.Empty;
public int TimeoutSeconds { get; set; } = 15;
}
/// <summary>External weighbridge database (legacy datasource GrainsWeighbridge, table CARGO).</summary>
public sealed class WeighbridgeSourceOptions
{
public string ConnectionString { get; set; } = string.Empty;
}
/// <summary>Scheduled jobs. Every job is disabled by default; set Enabled=true per job to run it inside the API process.</summary>
public sealed class JobOptions
{
public JobSchedule ActivateDestinations { get; set; } = new() { IntervalMinutes = 60 };
public JobSchedule GabanTimeout { get; set; } = new() { IntervalMinutes = 60 };
public JobSchedule WeighbridgeSync { get; set; } = new() { IntervalMinutes = 5 };
public JobSchedule AqabaWeighbridgeSync { get; set; } = new() { IntervalMinutes = 5 };
public JobSchedule PermitSeeding { get; set; } = new() { IntervalMinutes = 60 };
}
public sealed class JobSchedule
{
public bool Enabled { get; set; }
public int IntervalMinutes { get; set; } = 60;
}
/// <summary>Supplies the bound "Grains:Permits" settings (implemented in Infrastructure; registered by the *Service naming convention).</summary>
public interface IGrainsPermitsSettingsService
{
GrainsPermitsOptions Value { get; }
}