You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A console application to synchronize SharePoint Online lists with a SQL Server database, including data quality routines for common list inconsistencies.
7
-
Built with the SharePoint Client Side Object Model (CSOM) and .NET Framework 4.8.
A console application to synchronise SharePoint Online lists with a SQL Server database, including data quality routines for common list inconsistencies. Built with the SharePoint Client Side Object Model (CSOM) and .NET Framework 4.8.
11
8
12
-
Features
9
+
---
13
10
14
-
Prerequisites
11
+
## Table of Contents
15
12
16
-
Installation
13
+
-[Overview](#overview)
14
+
-[Features](#features)
15
+
-[Prerequisites](#prerequisites)
16
+
-[Installation](#installation)
17
+
-[Configuration](#configuration)
18
+
-[Usage](#usage)
19
+
-[Project Structure](#project-structure)
20
+
-[Troubleshooting](#troubleshooting)
21
+
-[License](#license)
17
22
18
-
Configuration
23
+
---
19
24
20
-
Usage
25
+
## Overview
21
26
22
-
Project Structure
27
+
This tool automates the transfer of data from SharePoint Online lists to SQL Server tables and performs targeted data quality fixes on specific lists (e.g. Activities, Invoice Request). It supports two sync modes — **daily** and **monthly** — and provides detailed logging for monitoring and debugging.
23
28
24
-
Troubleshooting
29
+
---
25
30
26
-
License
31
+
## Features
27
32
28
-
Português
29
-
30
-
Overview
31
-
This tool was developed to automate the transfer of data from SharePoint Online lists to SQL Server tables, as well as to perform targeted data quality fixes on specific lists (e.g., Activities, Invoice Request). It supports two sync modes (daily and monthly) and provides detailed logging for monitoring and debugging.
32
-
33
-
Features
34
-
SharePoint → SQL Synchronisation
33
+
**SharePoint → SQL Synchronisation**
35
34
Transfers data from configured SharePoint lists to corresponding SQL Server tables using either incremental (daily) or full (monthly) updates.
36
35
37
-
Data Quality Fixes
36
+
**Data Quality Fixes**
37
+
-*Activities* — Backfills the `_OpportunityID` field by copying from `OpportunityID` where null.
38
+
-*Invoice Request* — Updates approver fields (`Main_x0020_approver`, `Optional_x0020_approver`, `Financial_x0020_approver`) based on recent changes in the Unit list.
39
+
-*Timesheet* — Similar data quality logic, extendable as needed.
38
40
39
-
Activities: Backfills the _OpportunityID field by copying the value from OpportunityID where it is null.
41
+
**SQL Connection Testing**
42
+
Verifies connectivity to SQL Server and checks for necessary permissions (SELECT, CREATE TABLE, etc.) before any operation begins.
40
43
41
-
Invoice Request: Updates approver fields (Main_x0020_approver, Optional_x0020_approver, Financial_x0020_approver) based on recent changes in the Unit list.
44
+
**Configurable Logging**
45
+
Verbosity levels (0–3) control console output — run silently in production or in full debug mode during development.
42
46
43
-
Timesheet: (similar data quality logic – extend as needed)
47
+
**External Configuration**
48
+
All settings (SharePoint credentials, SQL connection string) are stored in an XML file, overridable via a command-line argument.
44
49
45
-
SQL Connection Testing
46
-
Before any operation, the tool verifies connectivity to the SQL Server and checks for necessary permissions (SELECT, CREATE TABLE, etc.).
50
+
---
47
51
48
-
Configurable Logging
49
-
Verbosity levels (0–3) control the amount of console output, making it easy to run silently or in debug mode.
52
+
## Prerequisites
50
53
51
-
External Configuration
52
-
All settings (SharePoint credentials, SQL connection string) are stored in an XML file, which can be overridden via command-line argument.
54
+
- Windows operating system (.NET Framework 4.8 target)
55
+
-[.NET Framework 4.8](https://dotnet.microsoft.com/download/dotnet-framework/net48) or later
56
+
- Visual Studio 2019 or 2022 (for building from source)
57
+
- Access to a SharePoint Online tenant with appropriate read/write permissions
58
+
- SQL Server (any edition) with a database where target tables will be created/updated
59
+
- VPN access if SharePoint or SQL Server is only reachable within a corporate network
53
60
54
-
Prerequisites
55
-
Windows operating system (the application targets .NET Framework 4.8)
61
+
---
56
62
57
-
.NET Framework 4.8 (or later) – Download
63
+
## Installation
58
64
59
-
Visual Studio 2019 or 2022 (for building from source)
Go to *Build → Build Solution*. The executable will be placed in `bin\Debug` or `bin\Release`.
74
85
75
-
Restore NuGet packages
76
-
The main package is Microsoft.SharePointOnline.CSOM (version 16.1).
77
-
Visual Studio should restore it automatically; if not, run:
86
+
**5. (Optional) Deploy**
78
87
79
-
text
80
-
Update-Package -reinstall
81
-
Build the solution (Build → Build Solution)
82
-
The executable will be placed in bin\Debug or bin\Release.
88
+
Copy the `bin\Release` folder to any Windows machine with .NET Framework 4.8 installed.
89
+
90
+
---
83
91
84
-
(Optional) Publish – you can copy the bin\Release folder to any Windows machine with .NET Framework 4.8 installed.
92
+
## Configuration
85
93
86
-
Configuration
87
-
All runtime settings are defined in an XML file. The default location is XmlConfig\UserConfig.xml (relative to the executable). You can specify a different file with the --config argument.
94
+
All runtime settings are defined in an XML file. The default location is `XmlConfig\UserConfig.xml` (relative to the executable). You can specify an alternative path with the `--config` argument.
Security Note: Storing passwords in plain text is not recommended for production. Consider using encrypted configuration sections or environment variables.
108
+
```
102
109
103
-
Configuration Elements
104
-
Element Description
105
-
SharePoint/Username The SharePoint Online user account (email format).
106
-
SharePoint/Password The password for that account.
107
-
SQL/ConnectionString A valid ADO.NET connection string to your SQL Server database.
108
-
The tool expects specific SharePoint site relative paths (e.g., seed, wolf, selfservice/invoicerequest) – these are hard-coded in the data quality classes. If your site structure differs, you will need to adjust the source code.
110
+
> ⚠️ **Security Note:** Storing passwords in plain text is not recommended for production. Consider using encrypted configuration sections or environment variables.
111
+
112
+
| Element | Description |
113
+
|---|---|
114
+
|`SharePoint/Username`| The SharePoint Online user account (email format) |
115
+
|`SharePoint/Password`| The password for that account |
116
+
|`SQL/ConnectionString`| A valid ADO.NET connection string to your SQL Server database |
117
+
118
+
> **Note:** The tool expects specific SharePoint site relative paths (e.g. `seed`, `wolf`, `selfservice/invoicerequest`). These are hard-coded in the data quality classes. If your site structure differs, adjust the source code accordingly.
119
+
120
+
---
121
+
122
+
## Usage
109
123
110
-
Usage
111
124
Run the executable from the command line:
112
125
113
-
text
126
+
```
114
127
ConsoleApp1.exe [arguments]
115
-
Arguments
116
-
Argument Description
117
-
daily Perform incremental sync (typically only new/changed items).
118
-
monthly Perform a full sync (all items).
119
-
diagnostic Enable diagnostic mode (sets verbosity to 1 if not otherwise specified).
120
-
--verbose=<0-3> Set verbosity level: 0 = quiet, 1 = normal, 2 = detailed, 3 = very detailed (debug).
121
-
--config=<path> Use an alternative configuration file.
# Just test SQL connection and exit (diagnostic mode)
149
+
#Test SQL connection and exit
131
150
ConsoleApp1.exe diagnostic
132
-
What happens during execution?
133
-
The tool parses command-line arguments and sets up logging.
134
-
135
-
It tests the SQL Server connection (including permission checks).
151
+
```
136
152
137
-
SharePoint credentials are retrieved from the configuration.
153
+
### What happens during execution?
138
154
139
-
Based on the mode (daily or monthly), it calls RefreshSQLLists.SPOtoSQLUpdate(...) which performs the actual data transfer.
155
+
1. Command-line arguments are parsed and logging is configured.
156
+
2. The SQL Server connection is tested (including permission checks).
157
+
3. SharePoint credentials are loaded from the configuration file.
158
+
4. Based on the mode (`daily` or `monthly`), `RefreshSQLLists.SPOtoSQLUpdate(...)` performs the data transfer.
159
+
5. Data quality routines (`ActivitiesDQ`, `InvoiceRequestDQ`, etc.) run as part of the sync.
160
+
6. All actions are logged to the console at the specified verbosity level.
140
161
141
-
Data quality routines (ActivitiesDQ, InvoiceRequestDQ, etc.) are executed as part of the sync process.
162
+
---
142
163
143
-
All actions are logged to the console according to the verbosity level.
164
+
## Project Structure
144
165
145
-
Project Structure
146
-
text
166
+
```
147
167
ConsoleApp1/
148
168
├── ConsoleApp1.csproj
149
169
├── packages.config
@@ -166,28 +186,33 @@ ConsoleApp1/
166
186
└── XmlConfig/
167
187
├── ConfigHelper.cs
168
188
└── UserConfig.xml
169
-
Key components:
189
+
```
170
190
171
-
RefreshSPOLists – main entry point (Main method), argument handling, SQL test, and orchestration.
191
+
| Component | Description |
192
+
|---|---|
193
+
|`RefreshSPOLists`| Main entry point — argument handling, SQL test, and orchestration |
194
+
|`SPOList` / `SPOUser`| Wrappers for SharePoint CSOM operations |
195
+
|`ActivitiesDQ` / `InvoiceRequestDQ`| Data quality fixes for specific lists |
196
+
|`RefreshSQLLists`| Handles the SharePoint → SQL data transfer |
197
+
|`ConfigHelper`| Reads the XML configuration file |
198
+
|`Logger`| Console logger with configurable verbosity levels |
172
199
173
-
SPOList / SPOUser – wrappers for SharePoint CSOM operations.
200
+
---
174
201
175
-
ActivitiesDQ / InvoiceRequestDQ – data quality fixes for specific lists.
202
+
## Troubleshooting
176
203
177
-
RefreshSQLLists – handles the actual SharePoint-to-SQL data transfer.
204
+
| Problem | Possible Solution |
205
+
|---|---|
206
+
| Cannot connect to SQL Server | Check VPN, firewall rules, and the connection string. Run `diagnostic` mode for more details. |
207
+
| SharePoint login fails | Verify username/password in the config file. Ensure the account has access to the specified site. |
208
+
| "Field not found" errors | Data quality classes expect specific field names (e.g. `OpportunityID`). If your lists differ, modify the source. |
209
+
| Throttling / slow performance | The tool batches updates (e.g. 80 items per batch) to avoid SharePoint limits. Adjust batch sizes if needed. |
210
+
| Missing tables in SQL | The tool assumes tables already exist with the correct schema. Review `SQLInteraction.cs` for table creation logic. |
178
211
179
-
ConfigHelper – reads the XML configuration file.
212
+
If you encounter unexpected behaviour, run with `--verbose=3` for full debug output and open an issue with the log attached.
180
213
181
-
Logger – simple console logger with verbosity levels.
214
+
---
182
215
183
-
Troubleshooting
184
-
Problem Possible Solution
185
-
Cannot connect to SQL Server Check VPN, firewall rules, and the connection string. Run diagnostic mode for more details.
186
-
SharePoint login fails Verify username/password in config. Ensure the account has access to the specified site.
187
-
"Field not found" errors The data quality classes expect specific field names (e.g., OpportunityID). If your lists use different names, you must modify the code.
188
-
Throttling / slow performance The tool batches updates (e.g., 80 items per batch) to avoid SharePoint limits. Adjust batch sizes if needed.
189
-
Missing tables in SQL The tool assumes tables already exist with the correct schema. Review SQLInteraction.cs for table creation logic.
190
-
If you encounter unexpected behaviour, run with --verbose=3 to get detailed debug output and open an issue with the log.
216
+
## License
191
217
192
-
License
193
-
This project is licensed under the MIT License – see the LICENSE file for details.
218
+
This project is licensed under the [MIT License](https://opensource.org/license/mit).
0 commit comments