!
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,14 +2,14 @@
|
|||||||
"Version": 1,
|
"Version": 1,
|
||||||
"WorkspaceRootPath": "C:\\Repos\\kmSqlReplicate\\",
|
"WorkspaceRootPath": "C:\\Repos\\kmSqlReplicate\\",
|
||||||
"Documents": [
|
"Documents": [
|
||||||
{
|
|
||||||
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\classobj\\clsreplicatebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
|
||||||
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:classobj\\clsreplicatebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\classobj\\clsreplicatebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
|
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:classobj\\clsreplicatebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\classobj\\servicemain.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
"AbsoluteMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|c:\\repos\\kmsqlreplicate\\classobj\\servicemain.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:classobj\\servicemain.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
"RelativeMoniker": "D:0:0:{364F9228-3601-4813-9E87-F042D9357580}|kmSqlReplicate.csproj|solutionrelative:classobj\\servicemain.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
"DocumentGroups": [
|
"DocumentGroups": [
|
||||||
{
|
{
|
||||||
"DockedWidth": 200,
|
"DockedWidth": 200,
|
||||||
"SelectedChildIndex": 12,
|
"SelectedChildIndex": 14,
|
||||||
"Children": [
|
"Children": [
|
||||||
{
|
{
|
||||||
"$type": "Bookmark",
|
"$type": "Bookmark",
|
||||||
@@ -74,13 +74,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 0,
|
"DocumentIndex": 1,
|
||||||
"Title": "ClsReplicateBase.cs",
|
"Title": "ClsReplicateBase.cs",
|
||||||
"DocumentMoniker": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
"DocumentMoniker": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
||||||
"RelativeDocumentMoniker": "ClassObj\\ClsReplicateBase.cs",
|
"RelativeDocumentMoniker": "ClassObj\\ClsReplicateBase.cs",
|
||||||
"ToolTip": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
"ToolTip": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
||||||
"RelativeToolTip": "ClassObj\\ClsReplicateBase.cs",
|
"RelativeToolTip": "ClassObj\\ClsReplicateBase.cs",
|
||||||
"ViewState": "AgIAAEIAAAAAAAAAAAAAAGEAAAAwAAAAAAAAAA==",
|
"ViewState": "AgIAAFsAAAAAAAAAAAAAAGYAAAAmAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:21:32.713Z",
|
"WhenOpened": "2025-08-29T11:21:32.713Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
@@ -95,18 +95,17 @@
|
|||||||
"RelativeToolTip": "ClassObj\\ServiceMain.cs",
|
"RelativeToolTip": "ClassObj\\ServiceMain.cs",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAADAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAADAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:19:38.123Z",
|
"WhenOpened": "2025-08-29T11:19:38.123Z"
|
||||||
"EditorCaption": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
"DocumentIndex": 1,
|
"DocumentIndex": 0,
|
||||||
"Title": "Program.cs",
|
"Title": "Program.cs",
|
||||||
"DocumentMoniker": "C:\\Repos\\kmSqlReplicate\\Program.cs",
|
"DocumentMoniker": "C:\\Repos\\kmSqlReplicate\\Program.cs",
|
||||||
"RelativeDocumentMoniker": "Program.cs",
|
"RelativeDocumentMoniker": "Program.cs",
|
||||||
"ToolTip": "C:\\Repos\\kmSqlReplicate\\Program.cs",
|
"ToolTip": "C:\\Repos\\kmSqlReplicate\\Program.cs*",
|
||||||
"RelativeToolTip": "Program.cs",
|
"RelativeToolTip": "Program.cs*",
|
||||||
"ViewState": "AgIAABgAAAAAAAAAAAAAACEAAAALAAAAAAAAAA==",
|
"ViewState": "AgIAAA4AAAAAAAAAAAAYwCAAAAAOAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:13:28.917Z",
|
"WhenOpened": "2025-08-29T11:13:28.917Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
"RelativeDocumentMoniker": "ClassObj\\ClsReplicateBase.cs",
|
"RelativeDocumentMoniker": "ClassObj\\ClsReplicateBase.cs",
|
||||||
"ToolTip": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
"ToolTip": "C:\\Repos\\kmSqlReplicate\\ClassObj\\ClsReplicateBase.cs",
|
||||||
"RelativeToolTip": "ClassObj\\ClsReplicateBase.cs",
|
"RelativeToolTip": "ClassObj\\ClsReplicateBase.cs",
|
||||||
"ViewState": "AgIAAF0AAAAAAAAAAAAAAHkAAABiAAAAAAAAAA==",
|
"ViewState": "AgIAAPgAAAAAAAAAAAAYwAwBAAAiAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:21:32.713Z",
|
"WhenOpened": "2025-08-29T11:21:32.713Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
@@ -95,8 +95,7 @@
|
|||||||
"RelativeToolTip": "ClassObj\\ServiceMain.cs",
|
"RelativeToolTip": "ClassObj\\ServiceMain.cs",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAADAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAABIAAAADAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:19:38.123Z",
|
"WhenOpened": "2025-08-29T11:19:38.123Z"
|
||||||
"EditorCaption": ""
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$type": "Document",
|
"$type": "Document",
|
||||||
@@ -106,7 +105,7 @@
|
|||||||
"RelativeDocumentMoniker": "Program.cs",
|
"RelativeDocumentMoniker": "Program.cs",
|
||||||
"ToolTip": "C:\\Repos\\kmSqlReplicate\\Program.cs",
|
"ToolTip": "C:\\Repos\\kmSqlReplicate\\Program.cs",
|
||||||
"RelativeToolTip": "Program.cs",
|
"RelativeToolTip": "Program.cs",
|
||||||
"ViewState": "AgIAABgAAAAAAAAAAAAAACEAAAALAAAAAAAAAA==",
|
"ViewState": "AgIAAA4AAAAAAAAAAAAYwCAAAAAOAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-08-29T11:13:28.917Z",
|
"WhenOpened": "2025-08-29T11:13:28.917Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
|
using Microsoft.SqlServer.Management.Sdk.Sfc;
|
||||||
using Microsoft.SqlServer.Management.Smo;
|
using Microsoft.SqlServer.Management.Smo;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -73,21 +74,39 @@ internal class ClsReplicateBase
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ScriptingOptions scrOptions1, scrOptions2, scrOptions3;
|
var dctOptions = new SortedDictionary<byte, ScriptingOptions>();
|
||||||
|
|
||||||
scrOptions1 = new ScriptingOptions() // Drop and Create
|
// Drops first
|
||||||
|
dctOptions.Add(0, new ScriptingOptions()
|
||||||
{
|
{
|
||||||
Default = true,
|
Default = true,
|
||||||
NoIdentities = true,
|
ScriptDrops = true,
|
||||||
DriAll = false,
|
//ScriptForCreateDrop = true,
|
||||||
|
//DriAllConstraints = true,
|
||||||
|
//DriForeignKeys = true,
|
||||||
|
IncludeIfNotExists = true,
|
||||||
|
//DriAllKeys = true,
|
||||||
|
//DriChecks = true,
|
||||||
|
//DriAll = true,
|
||||||
|
});
|
||||||
|
// Then CREATE
|
||||||
|
dctOptions.Add(1, new ScriptingOptions()
|
||||||
|
{
|
||||||
|
Default = true,
|
||||||
|
NoIdentities = false,
|
||||||
ScriptDrops = false,
|
ScriptDrops = false,
|
||||||
ScriptOwner = false,
|
ScriptOwner = false,
|
||||||
NoFileGroup = false,
|
NoFileGroup = false,
|
||||||
NoIndexPartitioningSchemes = true,
|
NoIndexPartitioningSchemes = true,
|
||||||
NoTablePartitioningSchemes = true,
|
NoTablePartitioningSchemes = true,
|
||||||
ScriptForCreateDrop = true
|
DriDefaults = true,
|
||||||
};
|
//DriForeignKeys = true,
|
||||||
scrOptions2 = new ScriptingOptions() // Get all keys and indexes
|
//ScriptForCreateDrop = true,
|
||||||
|
//Statistics = true,
|
||||||
|
//Triggers = true,
|
||||||
|
});
|
||||||
|
// Get all keys and indexes
|
||||||
|
dctOptions.Add(2, new ScriptingOptions()
|
||||||
{
|
{
|
||||||
Default = false,
|
Default = false,
|
||||||
DriPrimaryKey = true,
|
DriPrimaryKey = true,
|
||||||
@@ -97,12 +116,13 @@ internal class ClsReplicateBase
|
|||||||
NoIndexPartitioningSchemes = true,
|
NoIndexPartitioningSchemes = true,
|
||||||
NoTablePartitioningSchemes = true,
|
NoTablePartitioningSchemes = true,
|
||||||
ScriptForCreateDrop = true
|
ScriptForCreateDrop = true
|
||||||
};
|
});
|
||||||
scrOptions3 = new ScriptingOptions() // Get the permissions
|
// Get the permissions
|
||||||
|
dctOptions.Add(3, new ScriptingOptions()
|
||||||
{
|
{
|
||||||
Default = false,
|
Default = false,
|
||||||
Permissions = true
|
Permissions = true
|
||||||
};
|
});
|
||||||
|
|
||||||
using (var cnSrc = new SqlConnection(string.Format("Server={0};Database={1};Integrated Security=SSPI;TrustServerCertificate=True;", itm1.FromServer.ToString(), itm1.FromDatabase.ToString())))
|
using (var cnSrc = new SqlConnection(string.Format("Server={0};Database={1};Integrated Security=SSPI;TrustServerCertificate=True;", itm1.FromServer.ToString(), itm1.FromDatabase.ToString())))
|
||||||
{
|
{
|
||||||
@@ -113,16 +133,49 @@ internal class ClsReplicateBase
|
|||||||
|
|
||||||
foreach (DataRow dr in tbMain2.Rows)
|
foreach (DataRow dr in tbMain2.Rows)
|
||||||
{
|
{
|
||||||
Table T1;
|
Table T1 = D1.Tables[dr["TableName"].ToString(), dr["SchemaName"].ToString()];
|
||||||
var scrOutput = new StringCollection();
|
|
||||||
var txtSql = new StringBuilder();
|
var txtSql = new StringBuilder();
|
||||||
|
|
||||||
T1 = D1.Tables[dr["TableName"].ToString(), dr["SchemaName"].ToString()];
|
foreach (var kvp in dctOptions)
|
||||||
txtSql.AppendFormat("DROP TABLE IF EXISTS [{0}].[{1}]\nGO\n\n", dr["SchemaName"].ToString(), dr["TableName"].ToString());
|
{
|
||||||
txtSql.Append(string.Join("\n", T1.Script(scrOptions1).Cast<string>().ToArray()));
|
if (true)
|
||||||
txtSql.AppendLine("\nGO\n");
|
{
|
||||||
txtSql.Append(string.Join("\n", T1.Script(scrOptions2).Cast<string>().ToArray()));
|
txtSql.Append(string.Join("\n", T1.Script(kvp.Value).Cast<string>().ToArray()));
|
||||||
txtSql.AppendLine("\nGO\n");
|
txtSql.AppendLine("\nGO\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // need to figure out how to handle foreign table relationships first
|
||||||
|
var scr = new Scripter(S1) { Options = kvp.Value };
|
||||||
|
|
||||||
|
var dw = new DependencyWalker(S1);
|
||||||
|
var dwTree = dw.DiscoverDependencies(new Urn[] { T1.Urn }, true);
|
||||||
|
var ddd = dw.WalkDependencies(dwTree);
|
||||||
|
|
||||||
|
foreach (var d in ddd)
|
||||||
|
{
|
||||||
|
bool needGo = false;
|
||||||
|
foreach (var s in scr.EnumScript(new[] { d.Urn }))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(s))
|
||||||
|
{
|
||||||
|
txtSql.AppendLine(s.ToString() + "\n");
|
||||||
|
needGo = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needGo)
|
||||||
|
txtSql.AppendLine("\nGO\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//T1 = D1.Tables[dr["TableName"].ToString(), dr["SchemaName"].ToString()];
|
||||||
|
//txtSql.AppendFormat("DROP TABLE IF EXISTS [{0}].[{1}]\nGO\n\n", dr["SchemaName"].ToString(), dr["TableName"].ToString());
|
||||||
|
//txtSql.Append(string.Join("\n", T1.Script(scrOptions1).Cast<string>().ToArray()));
|
||||||
|
//txtSql.AppendLine("\nGO\n");
|
||||||
|
//txtSql.Append(string.Join("\n", T1.Script(scrOptions2).Cast<string>().ToArray()));
|
||||||
|
//txtSql.AppendLine("\nGO\n");
|
||||||
|
//txtSql.Append(string.Join("\n", T1.Script(scrOptions3).Cast<string>().ToArray()));
|
||||||
|
//txtSql.AppendLine("\nGO\n");
|
||||||
dr["Sql"] = txtSql.ToString();
|
dr["Sql"] = txtSql.ToString();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -139,7 +192,7 @@ internal class ClsReplicateBase
|
|||||||
if (D2.Tables.Contains(dr["TableName"].ToString(), dr["SchemaName"].ToString()))
|
if (D2.Tables.Contains(dr["TableName"].ToString(), dr["SchemaName"].ToString()))
|
||||||
{
|
{
|
||||||
Table T2 = D2.Tables[dr["TableName"].ToString(), dr["SchemaName"].ToString()];
|
Table T2 = D2.Tables[dr["TableName"].ToString(), dr["SchemaName"].ToString()];
|
||||||
sqlTablePermissions = string.Join("\n", T2.Script(scrOptions3).Cast<string>().ToArray());
|
sqlTablePermissions = string.Join("\n", T2.Script(dctOptions[3]).Cast<string>().ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
S2.ConnectionContext.BatchSeparator = "GO";
|
S2.ConnectionContext.BatchSeparator = "GO";
|
||||||
@@ -254,7 +307,7 @@ internal class ClsReplicateBase
|
|||||||
{
|
{
|
||||||
case "day":
|
case "day":
|
||||||
case "days":
|
case "days":
|
||||||
dtNextExecution=dtNextExecution.AddDays(IntervalNumber); break;
|
dtNextExecution = dtNextExecution.AddDays(IntervalNumber); break;
|
||||||
case "hour":
|
case "hour":
|
||||||
case "hours":
|
case "hours":
|
||||||
dtNextExecution = dtNextExecution.AddHours(IntervalNumber); break;
|
dtNextExecution = dtNextExecution.AddHours(IntervalNumber); break;
|
||||||
|
|||||||
+62
-62
@@ -30,9 +30,13 @@ internal class Program
|
|||||||
SetProgramVersion();
|
SetProgramVersion();
|
||||||
if (Debugger.IsAttached)
|
if (Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
var obj = new ClsReplicateBase();
|
if (true)
|
||||||
obj.Go();
|
{
|
||||||
//Test1();
|
var obj = new ClsReplicateBase();
|
||||||
|
obj.Go();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Test1();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -75,34 +79,24 @@ internal class Program
|
|||||||
|
|
||||||
internal static void Test1()
|
internal static void Test1()
|
||||||
{
|
{
|
||||||
ScriptingOptions scrOptions1, scrOptions2, scrOptions3, scrOptions4;
|
var dctOptions = new SortedDictionary<byte, ScriptingOptions>();
|
||||||
|
|
||||||
scrOptions1 = new ScriptingOptions() // Drops first
|
// Drops first
|
||||||
|
dctOptions.Add(0, new ScriptingOptions()
|
||||||
{
|
{
|
||||||
Default = true,
|
Default = true,
|
||||||
//NoIdentities = true,
|
|
||||||
ScriptDrops = true,
|
ScriptDrops = true,
|
||||||
//ScriptOwner = true,
|
//ScriptForCreateDrop = true,
|
||||||
//NoFileGroup = false,
|
//DriAllConstraints = true,
|
||||||
//NoIndexPartitioningSchemes = true,
|
//DriForeignKeys = true,
|
||||||
//NoTablePartitioningSchemes = true,
|
|
||||||
ScriptForCreateDrop = true,
|
|
||||||
DriAllConstraints = true,
|
|
||||||
//DriDefaults = true,
|
|
||||||
DriForeignKeys = true,
|
|
||||||
IncludeIfNotExists = true,
|
IncludeIfNotExists = true,
|
||||||
//EnforceScriptingOptions = true,
|
//DriAllKeys = true,
|
||||||
//AllowSystemObjects = false,
|
//DriChecks = true,
|
||||||
//Indexes = true,
|
//DriAll = true,
|
||||||
DriAllKeys = true,
|
//WithDependencies = false,
|
||||||
DriChecks = true,
|
});
|
||||||
//FullTextIndexes = true,
|
// Then CREATE
|
||||||
//Statistics = true,
|
dctOptions.Add(1, new ScriptingOptions()
|
||||||
//Triggers = true,
|
|
||||||
//WithDependencies = true,
|
|
||||||
DriAll = true,
|
|
||||||
};
|
|
||||||
scrOptions2 = new ScriptingOptions() // Then CREATE
|
|
||||||
{
|
{
|
||||||
Default = true,
|
Default = true,
|
||||||
NoIdentities = false,
|
NoIdentities = false,
|
||||||
@@ -111,11 +105,13 @@ internal class Program
|
|||||||
NoFileGroup = false,
|
NoFileGroup = false,
|
||||||
NoIndexPartitioningSchemes = true,
|
NoIndexPartitioningSchemes = true,
|
||||||
NoTablePartitioningSchemes = true,
|
NoTablePartitioningSchemes = true,
|
||||||
|
DriDefaults = true,
|
||||||
//ScriptForCreateDrop = true,
|
//ScriptForCreateDrop = true,
|
||||||
//Statistics = true,
|
//Statistics = true,
|
||||||
//Triggers = true,
|
//Triggers = true,
|
||||||
};
|
});
|
||||||
scrOptions3 = new ScriptingOptions() // Get all keys and indexes
|
// Get all keys and indexes
|
||||||
|
dctOptions.Add(2, new ScriptingOptions()
|
||||||
{
|
{
|
||||||
Default = false,
|
Default = false,
|
||||||
DriPrimaryKey = true,
|
DriPrimaryKey = true,
|
||||||
@@ -124,15 +120,14 @@ internal class Program
|
|||||||
NoFileGroup = false,
|
NoFileGroup = false,
|
||||||
NoIndexPartitioningSchemes = true,
|
NoIndexPartitioningSchemes = true,
|
||||||
NoTablePartitioningSchemes = true,
|
NoTablePartitioningSchemes = true,
|
||||||
ScriptForCreateDrop = true,
|
ScriptForCreateDrop = true
|
||||||
FullTextIndexes = true,
|
});
|
||||||
DriAll = true
|
// Get the permissions
|
||||||
};
|
dctOptions.Add(3, new ScriptingOptions()
|
||||||
scrOptions4 = new ScriptingOptions() // Get the permissions
|
|
||||||
{
|
{
|
||||||
Default = false,
|
Default = false,
|
||||||
Permissions = true
|
Permissions = true
|
||||||
};
|
});
|
||||||
|
|
||||||
using (var cnSrc = new SqlConnection(string.Format("Server={0};Database={1};Integrated Security=SSPI;TrustServerCertificate=True;", "BigMac", "MyCarHQ")))
|
using (var cnSrc = new SqlConnection(string.Format("Server={0};Database={1};Integrated Security=SSPI;TrustServerCertificate=True;", "BigMac", "MyCarHQ")))
|
||||||
{
|
{
|
||||||
@@ -143,47 +138,52 @@ internal class Program
|
|||||||
|
|
||||||
Server S1 = new Server(new Microsoft.SqlServer.Management.Common.ServerConnection(cnSrc));
|
Server S1 = new Server(new Microsoft.SqlServer.Management.Common.ServerConnection(cnSrc));
|
||||||
Database D1 = S1.Databases["MyCarHQ"];
|
Database D1 = S1.Databases["MyCarHQ"];
|
||||||
Table T1 = D1.Tables["SourceFiles", "appt"];
|
//Table T1 = D1.Tables["SourceFiles", "appt"];
|
||||||
|
Table T1 = D1.Tables["ConversationMaster", "conv"];
|
||||||
|
|
||||||
//foreach (var fk in T1.ForeignKeys)
|
//foreach (var fk in T1.ForeignKeys)
|
||||||
// Console.WriteLine("DROP " + fk.ToString());
|
// Console.WriteLine("DROP " + fk.ToString());
|
||||||
|
|
||||||
var scr = new Scripter(S1) { Options = scrOptions1 };
|
foreach (var kvp in dctOptions)
|
||||||
//scr.Options.IncludeIfNotExists = true;
|
|
||||||
//scr.Options.ScriptSchema = true;
|
|
||||||
//scr.Options.ScriptDrops = true;
|
|
||||||
//Console.WriteLine (scr.EnumScript(new Urn[] { T1.Urn }).ToString());
|
|
||||||
|
|
||||||
var dw = new DependencyWalker(S1);
|
|
||||||
var dwTree = dw.DiscoverDependencies(new Urn[] { T1.Urn }, true);
|
|
||||||
var ddd = dw.WalkDependencies(dwTree);
|
|
||||||
|
|
||||||
foreach (var d in ddd)
|
|
||||||
{
|
{
|
||||||
foreach (var s in scr.EnumScript(new[] { d.Urn }))
|
if (true)
|
||||||
{
|
{
|
||||||
Console.WriteLine(s);
|
txtSql.Append(string.Join("\n", T1.Script(kvp.Value).Cast<string>().ToArray()));
|
||||||
|
txtSql.AppendLine("\nGO\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var scr = new Scripter(S1) { Options = kvp.Value };
|
||||||
|
|
||||||
|
var dw = new DependencyWalker(S1);
|
||||||
|
var dwTree = dw.DiscoverDependencies(new Urn[] { T1.Urn }, true);
|
||||||
|
var ddd = dw.WalkDependencies(dwTree);
|
||||||
|
|
||||||
|
foreach (var d in ddd)
|
||||||
|
{
|
||||||
|
bool needGo = false;
|
||||||
|
|
||||||
|
foreach (var s in scr.EnumScript(new[] { d.Urn }))
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(s))
|
||||||
|
{
|
||||||
|
txtSql.AppendLine(s.ToString() + "\n");
|
||||||
|
needGo = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needGo)
|
||||||
|
txtSql.AppendLine("\nGO\n\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//foreach (string s in scr.EnumScript(new Urn[] { T1.Urn }))
|
//foreach (string s in scr.EnumScript(new Urn[] { T1.Urn }))
|
||||||
// Console.WriteLine(s + "\n\n");
|
// Console.WriteLine(s + "\n\n");
|
||||||
|
|
||||||
|
//Console.ReadLine();
|
||||||
|
|
||||||
|
Console.WriteLine(txtSql.ToString());
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
||||||
if (false)
|
|
||||||
{
|
|
||||||
txtSql.Append(string.Join("\n", T1.Script(scrOptions1).Cast<string>().ToArray()));
|
|
||||||
txtSql.AppendLine("\nGO\n\n\n\n");
|
|
||||||
txtSql.Append(string.Join("\n", T1.Script(scrOptions2).Cast<string>().ToArray()));
|
|
||||||
txtSql.AppendLine("\nGO\n\n\n\n");
|
|
||||||
txtSql.Append(string.Join("\n", T1.Script(scrOptions3).Cast<string>().ToArray()));
|
|
||||||
txtSql.AppendLine("\nGO\n");
|
|
||||||
|
|
||||||
Console.WriteLine(txtSql.ToString());
|
|
||||||
Console.ReadLine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("kmSqlReplicate")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("kmSqlReplicate")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+08240122f97b77a4990a95268adc05bfa2ed8798")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("kmSqlReplicate")]
|
[assembly: System.Reflection.AssemblyProductAttribute("kmSqlReplicate")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("kmSqlReplicate")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("kmSqlReplicate")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
7f611e62edce65adfad9b656e8935ba93f5b2589e121239c7fed8a37da642195
|
e3ce1bfb1365c8eef05874f183def1ce44657db0129037c0b84bd90a1405674b
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
is_global = true
|
is_global = true
|
||||||
build_property.TargetFramework = net9.0
|
build_property.TargetFramework = net9.0
|
||||||
|
build_property.TargetFrameworkIdentifier = .NETCoreApp
|
||||||
|
build_property.TargetFrameworkVersion = v9.0
|
||||||
build_property.TargetPlatformMinVersion =
|
build_property.TargetPlatformMinVersion =
|
||||||
build_property.UsingMicrosoftNETSdkWeb =
|
build_property.UsingMicrosoftNETSdkWeb =
|
||||||
build_property.ProjectTypeGuids =
|
build_property.ProjectTypeGuids =
|
||||||
build_property.InvariantGlobalization =
|
build_property.InvariantGlobalization =
|
||||||
build_property.PlatformNeutralAssembly =
|
build_property.PlatformNeutralAssembly =
|
||||||
build_property.EnforceExtendedAnalyzerRules =
|
build_property.EnforceExtendedAnalyzerRules =
|
||||||
|
build_property.EntryPointFilePath =
|
||||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
build_property.RootNamespace = kmSqlReplicate
|
build_property.RootNamespace = kmSqlReplicate
|
||||||
build_property.ProjectDir = C:\Repos\kmSqlReplicate\
|
build_property.ProjectDir = C:\Repos\kmSqlReplicate\
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// <auto-generated/>
|
// <auto-generated/>
|
||||||
global using global::System;
|
global using System;
|
||||||
global using global::System.Collections.Generic;
|
global using System.Collections.Generic;
|
||||||
global using global::System.IO;
|
global using System.IO;
|
||||||
global using global::System.Linq;
|
global using System.Linq;
|
||||||
global using global::System.Net.Http;
|
global using System.Net.Http;
|
||||||
global using global::System.Threading;
|
global using System.Threading;
|
||||||
global using global::System.Threading.Tasks;
|
global using System.Threading.Tasks;
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
2e17a1fbbc3fc86c0f9909b5fc23c8e1ae68e238fc5f86efe9473f548bc7c139
|
e2a3d1591c3b8817afd51ed75cb690f55da77c90e13a5bcecbe6a216a417bcf5
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -33,6 +33,7 @@
|
|||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net9.0": {
|
"net9.0": {
|
||||||
|
"framework": "net9.0",
|
||||||
"targetAlias": "net9.0",
|
"targetAlias": "net9.0",
|
||||||
"projectReferences": {}
|
"projectReferences": {}
|
||||||
}
|
}
|
||||||
@@ -47,10 +48,11 @@
|
|||||||
"auditLevel": "low",
|
"auditLevel": "low",
|
||||||
"auditMode": "direct"
|
"auditMode": "direct"
|
||||||
},
|
},
|
||||||
"SdkAnalysisLevel": "9.0.300"
|
"SdkAnalysisLevel": "10.0.300"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net9.0": {
|
"net9.0": {
|
||||||
|
"framework": "net9.0",
|
||||||
"targetAlias": "net9.0",
|
"targetAlias": "net9.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Dapper": {
|
"Dapper": {
|
||||||
@@ -98,7 +100,7 @@
|
|||||||
"privateAssets": "all"
|
"privateAssets": "all"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.301/PortableRuntimeIdentifierGraph.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\RDeck.KEYMTV\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\RDeck.KEYMTV\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
|
||||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.1</NuGetToolVersion>
|
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||||
<SourceRoot Include="C:\Users\RDeck.KEYMTV\.nuget\packages\" />
|
<SourceRoot Include="C:\Users\RDeck.KEYMTV\.nuget\packages\" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": 3,
|
"version": 4,
|
||||||
"targets": {
|
"targets": {
|
||||||
"net9.0": {
|
"net9.0": {
|
||||||
"Azure.Core/1.47.1": {
|
"Azure.Core/1.47.1": {
|
||||||
@@ -6051,6 +6051,7 @@
|
|||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net9.0": {
|
"net9.0": {
|
||||||
|
"framework": "net9.0",
|
||||||
"targetAlias": "net9.0",
|
"targetAlias": "net9.0",
|
||||||
"projectReferences": {}
|
"projectReferences": {}
|
||||||
}
|
}
|
||||||
@@ -6065,10 +6066,11 @@
|
|||||||
"auditLevel": "low",
|
"auditLevel": "low",
|
||||||
"auditMode": "direct"
|
"auditMode": "direct"
|
||||||
},
|
},
|
||||||
"SdkAnalysisLevel": "9.0.300"
|
"SdkAnalysisLevel": "10.0.300"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"net9.0": {
|
"net9.0": {
|
||||||
|
"framework": "net9.0",
|
||||||
"targetAlias": "net9.0",
|
"targetAlias": "net9.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Dapper": {
|
"Dapper": {
|
||||||
@@ -6116,7 +6118,7 @@
|
|||||||
"privateAssets": "all"
|
"privateAssets": "all"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.304/PortableRuntimeIdentifierGraph.json"
|
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\10.0.301/PortableRuntimeIdentifierGraph.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"dgSpecHash": "/WmZSgAk970=",
|
"dgSpecHash": "LtJHdaAaCaw=",
|
||||||
"success": true,
|
"success": true,
|
||||||
"projectFilePath": "C:\\Repos\\kmSqlReplicate\\kmSqlReplicate.csproj",
|
"projectFilePath": "C:\\Repos\\kmSqlReplicate\\kmSqlReplicate.csproj",
|
||||||
"expectedPackageFiles": [
|
"expectedPackageFiles": [
|
||||||
|
|||||||
Reference in New Issue
Block a user