Skip to content
Open
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
3 changes: 3 additions & 0 deletions DataScriptWriter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<Reference Include="DevExpress.XtraTreeList.v18.2, Version=18.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL">
<HintPath>packages\XtraEditor.Controls.18.2.4\lib\net45\DevExpress.XtraTreeList.v18.2.dll</HintPath>
</Reference>
<Reference Include="DotNetZip, Version=1.15.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>packages\DotNetZip.1.15.0\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.SqlServer.Types.14.0.1016.290\lib\net40\Microsoft.SqlServer.Types.dll</HintPath>
</Reference>
Expand Down
42 changes: 34 additions & 8 deletions frmMain.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;
using Ionic.Zip;

namespace DataScriptWriter
{
Expand All @@ -23,7 +25,10 @@ public frmMain()
Global.AppName = String.Format("{0} - ver. {1}", fileVersionInfo.ProductName, fileVersionInfo.ProductVersion);
this.Text = Global.AppName;

_OutputFolder = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
string strTempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(strTempPath);

_OutputFolder = strTempPath;
}

private void btnConnect_Click(object sender, EventArgs e)
Expand All @@ -47,6 +52,11 @@ private void Connect()

private void bbiExit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
Directory.Delete(_OutputFolder, true);
}
catch { }
this.Close();
}

Expand All @@ -65,15 +75,31 @@ private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.
private void bbiScript_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
int cnt = 0;
foreach (DataRowView item in _gen.SelectedItemView)
if (_gen == null || _gen.SelectedItemView == null)
{
ScriptObject so = new ScriptObject(item);
barStaticItem1.Caption = "Scripting: " + so.FullQuoted;
this.Refresh();
_gen.GenerateForTable(so);
cnt++;
barStaticItem1.Caption = "Incomplete connection to script";
}
else
{
foreach (DataRowView item in _gen.SelectedItemView)
{
ScriptObject so = new ScriptObject(item);
barStaticItem1.Caption = "Scripting: " + so.FullQuoted;
this.Refresh();
_gen.GenerateForTable(so);
cnt++;
}
barStaticItem1.Caption = String.Format("Done. {0} tables were scripted.", cnt);

string[] arrSqlFiles = Directory.GetFiles(_OutputFolder, "*.sql");
string strZipPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "DataScriptWriter");
Directory.CreateDirectory(strZipPath);

ZipFile zipFile = new ZipFile(_OutputFolder);
zipFile.AddFiles(arrSqlFiles, "/");
zipFile.Save(Path.Combine(strZipPath, string.Format("Export_{0}" + ".zip",DateTime.Now.ToString("yyyyMMdd HHmmss"))));
zipFile = null;
}
barStaticItem1.Caption = String.Format("Done. {0} tables were scripted.", cnt);
}

private void gridControl1_DoubleClick(object sender, EventArgs e)
Expand Down
1 change: 1 addition & 0 deletions packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetZip" version="1.15.0" targetFramework="net472" />
<package id="Microsoft.SqlServer.Types" version="14.0.1016.290" targetFramework="net472" />
<package id="XtraEditor.Controls" version="18.2.4" targetFramework="net472" />
</packages>