diff --git a/.gitignore b/.gitignore index 10016f0..1c53dfa 100644 --- a/.gitignore +++ b/.gitignore @@ -125,7 +125,7 @@ publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings +# TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj @@ -181,4 +181,4 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ -/.vs +.vs/ diff --git a/NSF2SQL.sln b/NSF2SQL.sln index 6f583f9..b915e97 100644 --- a/NSF2SQL.sln +++ b/NSF2SQL.sln @@ -15,10 +15,10 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|x86.ActiveCfg = Release|x86 - {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|x86.Build.0 = Release|x86 - {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|Any CPU.ActiveCfg = Release|x86 - {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|Any CPU.Build.0 = Release|x86 + {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|x86.ActiveCfg = Debug|x86 + {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Debug|x86.Build.0 = Debug|x86 + {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|Any CPU.Build.0 = Release|Any CPU {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|x86.ActiveCfg = Release|x86 {3AD3A009-FC65-4067-BFF1-6CE1378BA75A}.Release|x86.Build.0 = Release|x86 EndGlobalSection diff --git a/NSF2SQL/Form1.cs b/NSF2SQL/Form1.cs index ff949fa..add3a79 100644 --- a/NSF2SQL/Form1.cs +++ b/NSF2SQL/Form1.cs @@ -396,47 +396,71 @@ private void bExportDocuments_Click(object sender, EventArgs ea) e.Cancel = true; return; } - if (doc.HasItem("Form") && ((string[])doc.GetItemValue("Form"))[0] != "") + + //get form + object formObj = doc.HasItem("Form") ? doc.GetItemValue("Form") : null; + string form = formObj is string ? (string)formObj : (formObj is string[] ? ((string[])formObj)[0] : "table"); + + if (!tables.ContainsKey(form)) { - //get form - string form = ((string[])doc.GetItemValue("Form"))[0]; + tables.Add(form, new Table(form)); + } + int row = tables[form].AddRow(); + //get fields + //set multiple values + foreach (NotesItem item in (NotesItem[])doc.Items) + { + //check if cancelled + if (pDialog.IsCancelled) + { + e.Cancel = true; + return; + } + string field = item.Name; + //exclude fields that start with $ and the Form field and Readers field + if (field == null || excludeField.IsMatch(field)) + { + continue; + } + string type = ""; + switch (item.type) + {//TODO: get more types + case IT_TYPE.NUMBERS: + type = "decimal(20,10)"; + break; + case IT_TYPE.DATETIMES: + type = "datetime"; + break; + default: + type = "text"; + break; + } + object values = item.Values; + bool multiple = ((object[])item.Values).Length > 1; - if (!tables.ContainsKey(form)) + if (!tables[form].Columns.ContainsKey(field)) { - tables.Add(form, new Table(form)); + tables[form].Columns.Add(field, new Column(field, type)); } - int row = tables[form].AddRow(); - //get fields - //set multiple values - foreach (NotesItem item in (NotesItem[])doc.Items) + + if (multiple && !tables[form].Columns[field].MultipleValues) { - //check if cancelled - if (pDialog.IsCancelled) - { - e.Cancel = true; - return; - } - string field = item.Name; - //exclude fields that start with $ and the Form field and Readers field - if (field == null || excludeField.IsMatch(field)) + tables[form].Columns[field].MultipleValues = multiple; + } + + if (!tables[form].Columns[field].Values.ContainsKey(row)) + { + tables[form].Columns[field].Values.Add(row, values); + } + else + { + int j = 1; + while (tables[form].Columns.ContainsKey(field + j) && tables[form].Columns[field + j].Values.ContainsKey(row)) { - continue; - } - string type = ""; - switch (item.type) - {//TODO: get more types - case IT_TYPE.NUMBERS: - type = "decimal(20,10)"; - break; - case IT_TYPE.DATETIMES: - type = "datetime"; - break; - default: - type = "text"; - break; + j++; } - object values = item.Values; - bool multiple = ((object[])item.Values).Length > 1; + + field += j; if (!tables[form].Columns.ContainsKey(field)) { @@ -448,32 +472,7 @@ private void bExportDocuments_Click(object sender, EventArgs ea) tables[form].Columns[field].MultipleValues = multiple; } - if (!tables[form].Columns[field].Values.ContainsKey(row)) - { - tables[form].Columns[field].Values.Add(row, values); - } - else - { - int j = 1; - while (tables[form].Columns.ContainsKey(field + j) && tables[form].Columns[field + j].Values.ContainsKey(row)) - { - j++; - } - - field += j; - - if (!tables[form].Columns.ContainsKey(field)) - { - tables[form].Columns.Add(field, new Column(field, type)); - } - - if (multiple && !tables[form].Columns[field].MultipleValues) - { - tables[form].Columns[field].MultipleValues = multiple; - } - - tables[form].Columns[field].Values.Add(row, values); - } + tables[form].Columns[field].Values.Add(row, values); } } //update progress diff --git a/NSF2SQL/NSF2SQL.csproj b/NSF2SQL/NSF2SQL.csproj index b8a8a78..87024df 100644 --- a/NSF2SQL/NSF2SQL.csproj +++ b/NSF2SQL/NSF2SQL.csproj @@ -143,19 +143,19 @@ 1.8.9 - 3.25.2 + 3.27.1 1.0.0 - 1.3.6 + 1.3.8 - 8.3.0 + 8.4.0 - 2023.0.1 + 2024.0.0 7.0.0-preview.2.22152.2