-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (42 loc) · 1.69 KB
/
Program.cs
File metadata and controls
51 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Linq;
using System.Threading.Tasks;
using OrgUnitBulkUpdate.Services;
namespace OrgUnitBulkUpdate
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Program started...");
// Check if the required arguments are passed
if (args.Length < 2)
{
Console.WriteLine("Usage: OrgUnitBulkUpdate <ExcelFilePath> <DHIS2BaseUrl>");
return;
}
string excelFilePath = args[0];
string dhis2BaseUrl = args[1];
Console.WriteLine($"Excel File Path: {excelFilePath}");
Console.WriteLine($"DHIS2 Base URL: {dhis2BaseUrl}");
var excelReader = new ExcelDataReader();
try
{
var healthFacilities = excelReader.ReadHealthFacilities(excelFilePath);
Console.WriteLine($"Number of health facilities found: {healthFacilities.Count()}");
var dhis2Client = new DHIS2ApiClient(dhis2BaseUrl);
foreach (var facility in healthFacilities)
{
Console.WriteLine($"Updating facility: ID = {facility.ID}, Name = {facility.Name}, ShortName = {facility.ShortName}, ParentID = {facility.ParentID}");
var success = await dhis2Client.UpdateHealthFacilityAsync(facility);
Console.WriteLine($"Update result: {(success ? "Success" : "Failed")}");
}
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
Console.WriteLine("Program completed.");
}
}
}