@@ -70,6 +70,66 @@ public static void SPOtoSQLUpdate(bool daily)
7070 Console . WriteLine ( "SPOtoSQLUpdate: SPO to SQL update completed." ) ;
7171 }
7272
73+ /// <summary>
74+ /// Initiates the update process from SharePoint to SQL Server for all configured lists.
75+ /// </summary>
76+ /// <param name="daily">Indicates whether to perform a daily incremental update or a full current-time refresh.</param>
77+ public static void SPOtoSQLUpdateOLD ( bool daily )
78+ {
79+ Console . WriteLine ( "SPOtoSQLUpdate: Starting SPO to SQL update. Daily: " + daily ) ;
80+
81+ try
82+ {
83+ // Load SharePoint credentials from configuration (secure storage recommended)
84+ var ( username , password ) = ConfigurationReader . GetSharePointCredentials ( ) ;
85+ Console . WriteLine ( $ "SPOtoSQLUpdate: Username: { username } Password: { password } ") ;
86+
87+ // Establish SharePoint user context
88+ SPOUser user ;
89+ try
90+ {
91+ user = new SPOUser ( username , password ) ;
92+ }
93+ catch ( Exception ex )
94+ {
95+ // Fail fast if authentication cannot be created
96+ Console . WriteLine ( "SPOtoSQLUpdate: ERROR - Failed to create SPOUser." ) ;
97+ Console . WriteLine ( "Exception: " + ex . Message ) ;
98+ Console . WriteLine ( "Stack Trace: " + ex . StackTrace ) ;
99+ return ;
100+ }
101+
102+ // Iterate through each SharePoint list configured in AppSettings
103+ foreach ( string allKey in ConfigurationManager . AppSettings . AllKeys )
104+ {
105+ string listName = allKey ;
106+ string ctxURL = ConfigurationManager . AppSettings [ allKey ] ;
107+ Console . WriteLine ( $ "SPOtoSQLUpdate: Processing list: { listName } with URL: { ctxURL } ") ;
108+ try
109+ {
110+ // Delegate to RefreshListsSQL for per-list processing
111+ RefreshSQLLists . RefreshListsSQL ( listName , ctxURL , user , daily ) ;
112+ }
113+ catch ( Exception ex )
114+ {
115+ // Log and continue on individual list errors
116+ Console . WriteLine ( $ "SPOtoSQLUpdate: ERROR - Exception while updating list '{ listName } '.") ;
117+ Console . WriteLine ( "Exception: " + ex . Message ) ;
118+ Console . WriteLine ( "Stack Trace: " + ex . StackTrace ) ;
119+ }
120+ }
121+ }
122+ catch ( Exception ex )
123+ {
124+ // Catch-all for any unexpected failure in the orchestration
125+ Console . WriteLine ( "SPOtoSQLUpdate: FATAL ERROR - Exception during SPO to SQL update process." ) ;
126+ Console . WriteLine ( "Exception: " + ex . Message ) ;
127+ Console . WriteLine ( "Stack Trace: " + ex . StackTrace ) ;
128+ }
129+
130+ Console . WriteLine ( "SPOtoSQLUpdate: SPO to SQL update completed." ) ;
131+ }
132+
73133 /// <summary>
74134 /// Processes a specific SharePoint list: initializes context, builds SQL interaction, and performs the data transfer.
75135 /// </summary>
0 commit comments