|
11 | 11 |
|
12 | 12 | namespace Bring.Sqlserver |
13 | 13 | { |
14 | | - internal class RefreshSQLLists |
15 | | - { |
16 | | - public static void SPOtoSQLUpdate(bool daily) |
| 14 | + internal class RefreshSQLLists |
17 | 15 | { |
18 | | - SPOUser user = new SPOUser("Guilherme.sales@bringglobal.com", "UtKid_3AV^r]H+"); // FJ -> APAGUEI AS CREDENCIAIS QUE ESTÂO EM USO |
19 | | - foreach (string allKey in ConfigurationManager.AppSettings.AllKeys) |
20 | | - RefreshSQLLists.RefreshListsSQL(allKey, ConfigurationManager.AppSettings[allKey], user, daily); |
21 | | - } |
| 16 | + public static void SPOtoSQLUpdate(bool daily) |
| 17 | + { |
| 18 | + Console.WriteLine("Starting SPO to SQL update. Daily: " + daily); |
22 | 19 |
|
23 | | - public static void RefreshListsSQL(string listName, string ctxURL, SPOUser user, bool daily) |
24 | | - { |
25 | | - try |
26 | | - { |
27 | | - SPOList spoList1 = new SPOList(); |
28 | | - spoList1.Site = ctxURL; |
29 | | - spoList1.SPOUser = user; |
30 | | - spoList1.Name = listName; |
31 | | - SPOList spoList2 = spoList1; |
32 | | - SQLInteraction sqlInteraction = new SQLInteraction() |
| 20 | + SPOUser user = new SPOUser("Guilherme.sales@bringglobal.com", "UtKid_3AV^r]H+"); // NOTE: Remove hardcoded credentials for security |
| 21 | + |
| 22 | + foreach (string allKey in ConfigurationManager.AppSettings.AllKeys) |
| 23 | + { |
| 24 | + string listName = allKey; |
| 25 | + string ctxURL = ConfigurationManager.AppSettings[allKey]; |
| 26 | + Console.WriteLine($"Processing list: {listName} with URL: {ctxURL}"); |
| 27 | + RefreshSQLLists.RefreshListsSQL(listName, ctxURL, user, daily); |
| 28 | + } |
| 29 | + |
| 30 | + Console.WriteLine("SPO to SQL update completed."); |
| 31 | + } |
| 32 | + |
| 33 | + public static void RefreshListsSQL(string listName, string ctxURL, SPOUser user, bool daily) |
33 | 34 | { |
34 | | - List = spoList2 |
35 | | - }; |
36 | | - sqlInteraction.Build(); |
37 | | - if (daily) |
38 | | - sqlInteraction.DailyUpdate(); |
39 | | - else |
40 | | - sqlInteraction.CurrentTimeUpdate(); |
41 | | - } |
42 | | - catch (Exception ex) |
43 | | - { |
44 | | - Console.WriteLine(ex.Message); |
45 | | - } |
| 35 | + try |
| 36 | + { |
| 37 | + Console.WriteLine($"Initializing SPO list for: {listName}"); |
| 38 | + |
| 39 | + SPOList spoList = new SPOList(); |
| 40 | + spoList.Site = ctxURL; |
| 41 | + spoList.SPOUser = user; |
| 42 | + spoList.Name = listName; |
| 43 | + |
| 44 | + Console.WriteLine("SPOList initialized:"); |
| 45 | + Console.WriteLine($" Site: {spoList.Site}"); |
| 46 | + Console.WriteLine($" Name: {spoList.Name}"); |
| 47 | + |
| 48 | + SQLInteraction sqlInteraction = new SQLInteraction() |
| 49 | + { |
| 50 | + List = spoList |
| 51 | + }; |
| 52 | + |
| 53 | + Console.WriteLine("Building SQL interaction..."); |
| 54 | + sqlInteraction.Build(); |
| 55 | + |
| 56 | + if (daily) |
| 57 | + { |
| 58 | + Console.WriteLine("Performing daily update..."); |
| 59 | + sqlInteraction.DailyUpdate(); |
| 60 | + } |
| 61 | + else |
| 62 | + { |
| 63 | + Console.WriteLine("Performing current time update..."); |
| 64 | + sqlInteraction.CurrentTimeUpdate(); |
| 65 | + } |
| 66 | + |
| 67 | + Console.WriteLine($"Update for list '{listName}' completed."); |
| 68 | + } |
| 69 | + catch (Exception ex) |
| 70 | + { |
| 71 | + Console.WriteLine($"Error updating list '{listName}': {ex.Message}"); |
| 72 | + } |
| 73 | + } |
46 | 74 | } |
47 | | - } |
48 | 75 | } |
0 commit comments