Skip to content

use default table name if form doesn't exist #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -181,4 +181,4 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/
/.vs
.vs/
8 changes: 4 additions & 4 deletions NSF2SQL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
119 changes: 59 additions & 60 deletions NSF2SQL/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions NSF2SQL/NSF2SQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,19 @@
<Version>1.8.9</Version>
</PackageReference>
<PackageReference Include="Google.Protobuf">
<Version>3.25.2</Version>
<Version>3.27.1</Version>
</PackageReference>
<PackageReference Include="interop.domino.dll">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="K4os.Compression.LZ4">
<Version>1.3.6</Version>
<Version>1.3.8</Version>
</PackageReference>
<PackageReference Include="MySql.Data">
<Version>8.3.0</Version>
<Version>8.4.0</Version>
</PackageReference>
<PackageReference Include="SSH.NET">
<Version>2023.0.1</Version>
<Version>2024.0.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>7.0.0-preview.2.22152.2</Version>
Expand Down
Loading