Compare commits
3 Commits
d177a25c3d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f467ebb99e | ||
|
|
8a9951335a | ||
|
|
5b462d3898 |
@@ -309,5 +309,67 @@ namespace FsToolbox.Cli
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Public Method GetRosinenStoreMemberReportAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a report with all members for each configured Rosinen store.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpClient">The HTTP client used to perform the requests.</param>
|
||||||
|
public static async Task GetRosinenStoreMemberReportAsync(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
await AuthHelper.EnsureAuthenticationAsync(httpClient);
|
||||||
|
|
||||||
|
var storeIds = SettingsProvider.Current.CustomTasks.RosinenStoreMemberReport.StoreIds;
|
||||||
|
if (storeIds is not { Count: > 0 })
|
||||||
|
{
|
||||||
|
Logger.Info("No store IDs configured. Please set CustomTasks.RosinenStoreMemberReport.StoreIds in appsettings.json.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var report = new StringBuilder();
|
||||||
|
report.AppendLine("Rosinen Store Member Report");
|
||||||
|
report.AppendLine("Generated: " + DateTime.Now.ToString("dd.MM.yyyy HH:mm"));
|
||||||
|
report.AppendLine($"Configured stores: {storeIds.Count}");
|
||||||
|
report.AppendLine("============================");
|
||||||
|
report.AppendLine();
|
||||||
|
|
||||||
|
for (var index = 0; index < storeIds.Count; index++)
|
||||||
|
{
|
||||||
|
var storeId = storeIds[index];
|
||||||
|
Logger.Info("Fetching details and members for store {StoreId} ({Current}/{Total})", storeId, index + 1, storeIds.Count);
|
||||||
|
|
||||||
|
var storeDetails = await StoreTasks.GetStoreInformationAsync(httpClient, storeId);
|
||||||
|
await Task.Delay(200);
|
||||||
|
|
||||||
|
var members = await StoreTasks.GetStoreMembersAsync(httpClient, storeId);
|
||||||
|
|
||||||
|
var storeName = string.IsNullOrWhiteSpace(storeDetails?.Name) ? "Unknown Store" : storeDetails.Name;
|
||||||
|
report.AppendLine($"Store {storeName} ({storeId})");
|
||||||
|
report.AppendLine("----------------------------");
|
||||||
|
|
||||||
|
if (members.Count == 0)
|
||||||
|
{
|
||||||
|
report.AppendLine("No members found.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var member in members.OrderBy(x => x.Name, StringComparer.CurrentCultureIgnoreCase)) report.AppendLine($"- {member.Id} | {member.Name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
report.AppendLine();
|
||||||
|
|
||||||
|
if (index < storeIds.Count - 1)
|
||||||
|
await Task.Delay(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
var timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
|
||||||
|
var filename = $"RosinenStoreMembers_{timestamp}.txt";
|
||||||
|
await File.WriteAllTextAsync(filename, report.ToString());
|
||||||
|
|
||||||
|
Logger.Info("Report saved: {FileName}", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,9 @@ namespace FsToolbox.Cli
|
|||||||
|
|
||||||
public static string RegionStores => $"{ApiBase}/api/region/{{0}}/stores";
|
public static string RegionStores => $"{ApiBase}/api/region/{{0}}/stores";
|
||||||
|
|
||||||
public static string StoreMembers => $"{ApiBase}/api/stores/{{0}}/member";
|
public static string StoreMembers => $"{ApiBase}/api/stores/{{0}}/members";
|
||||||
|
|
||||||
public static string StoreInformation => $"{ApiBase}/api/stores/{{0}}/information";
|
public static string StoreDetails => $"{ApiBase}/api/stores/{{0}}/details";
|
||||||
|
|
||||||
public static string StorePickups => $"{ApiBase}/api/stores/{{0}}/pickups";
|
public static string StorePickups => $"{ApiBase}/api/stores/{{0}}/pickups";
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ namespace FsToolbox.Cli
|
|||||||
|
|
||||||
public static string UserCurrent => $"{ApiBase}/api/user/current";
|
public static string UserCurrent => $"{ApiBase}/api/user/current";
|
||||||
|
|
||||||
public static string UserLogin => $"{ApiBase}/api/user/login";
|
public static string UserLogin => $"{ApiBase}/api/login";
|
||||||
public static string StoreLog => $"{ApiBase}/api/stores/{{0}}/log/{{1}}/{{2}}/{{3}}";
|
public static string StoreLog => $"{ApiBase}/api/stores/{{0}}/log/{{1}}/{{2}}/{{3}}";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace FsToolbox.Cli.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CredentialsSettings Credentials { get; init; } = new();
|
public CredentialsSettings Credentials { get; init; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets settings related to custom tasks.
|
||||||
|
/// </summary>
|
||||||
|
public CustomTaskSettings CustomTasks { get; init; } = new();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +67,36 @@ namespace FsToolbox.Cli.Helper
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains configuration for custom task execution.
|
||||||
|
/// </summary>
|
||||||
|
public class CustomTaskSettings
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for generating the Rosinen store member report.
|
||||||
|
/// </summary>
|
||||||
|
public RosinenStoreMemberReportSettings RosinenStoreMemberReport { get; init; } = new();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains store IDs used by the Rosinen member report task.
|
||||||
|
/// </summary>
|
||||||
|
public class RosinenStoreMemberReportSettings
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Store IDs that should be queried for member reports.
|
||||||
|
/// </summary>
|
||||||
|
public List<int> StoreIds { get; init; } = [];
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to the current application settings loaded from configuration.
|
/// Provides access to the current application settings loaded from configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ logger.Info("1. Check Aldi Memberships");
|
|||||||
logger.Info("2. Confirm all Unconfirmed Pickups for Lindenberg");
|
logger.Info("2. Confirm all Unconfirmed Pickups for Lindenberg");
|
||||||
logger.Info("3. Analyze slot unregistrations for region Siegen");
|
logger.Info("3. Analyze slot unregistrations for region Siegen");
|
||||||
logger.Info("4. Analyze early slot registrations (calendar interval)");
|
logger.Info("4. Analyze early slot registrations (calendar interval)");
|
||||||
|
logger.Info("5. Get rosinen-store member report");
|
||||||
logger.Info("Enter the number of the task to execute (or any other key to exit): ");
|
logger.Info("Enter the number of the task to execute (or any other key to exit): ");
|
||||||
var choice = Console.ReadLine();
|
var choice = Console.ReadLine();
|
||||||
|
|
||||||
@@ -37,6 +38,9 @@ switch (choice)
|
|||||||
case "4":
|
case "4":
|
||||||
await CustomTasks.AnalyzeEarlySlotRegistrationsAsync(httpClient);
|
await CustomTasks.AnalyzeEarlySlotRegistrationsAsync(httpClient);
|
||||||
break;
|
break;
|
||||||
|
case "5":
|
||||||
|
await CustomTasks.GetRosinenStoreMemberReportAsync(httpClient);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
logger.Info("Exiting...");
|
logger.Info("Exiting...");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace FsToolbox.Cli.Tasks
|
|||||||
{
|
{
|
||||||
await AuthHelper.EnsureAuthenticationAsync(httpClient);
|
await AuthHelper.EnsureAuthenticationAsync(httpClient);
|
||||||
|
|
||||||
var uri = string.Format(Endpoints.StoreInformation, storeId);
|
var uri = string.Format(Endpoints.StoreDetails, storeId);
|
||||||
var response = await httpClient.GetAsync(uri);
|
var response = await httpClient.GetAsync(uri);
|
||||||
var responseBody = await response.Content.ReadAsStringAsync();
|
var responseBody = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,13 @@
|
|||||||
"Email": "demo@example.com",
|
"Email": "demo@example.com",
|
||||||
"Password": "demo-password",
|
"Password": "demo-password",
|
||||||
"TwoFactorEnabled": false
|
"TwoFactorEnabled": false
|
||||||
|
},
|
||||||
|
"CustomTasks": {
|
||||||
|
"RosinenStoreMemberReport": {
|
||||||
|
"StoreIds": [
|
||||||
|
12345,
|
||||||
|
67890
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user