Browse Source

Various fixes: can now add a ConnectionString to a DbModelInfo using the corresponding TreeNode, and SaveAll saves the content of each DbModelInfo to the user's home directory

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1693 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 20 years ago
parent
commit
4798d42751
  1. 10
      src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfo.cs
  2. 18
      src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfoService.cs
  3. 1
      src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

10
src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfo.cs

@ -37,7 +37,7 @@ namespace SharpDbTools.Model
public string Name { public string Name {
get { get {
DataTable table = this.Tables[TableNames.ConnectionInfo]; DataTable table = this.Tables[TableNames.ConnectionInfo];
string name = (string)table.Rows[0][ColumnNames.Name]; string name = table.Rows[0][ColumnNames.Name] as string;
return name; return name;
} }
} }
@ -45,12 +45,12 @@ namespace SharpDbTools.Model
public string InvariantName { public string InvariantName {
get { get {
DataTable table = this.Tables[TableNames.ConnectionInfo]; DataTable table = this.Tables[TableNames.ConnectionInfo];
string invariantName = (string)table.Rows[0][ColumnNames.InvariantName]; string invariantName = table.Rows[0][ColumnNames.InvariantName] as string;
return invariantName; return invariantName;
} }
set { set {
DataTable table = this.Tables[TableNames.ConnectionInfo]; DataTable table = this.Tables[TableNames.ConnectionInfo];
string invariantName = (string)table.Rows[0][ColumnNames.InvariantName]; string invariantName = table.Rows[0][ColumnNames.InvariantName] as string;
string name = this.Name; string name = this.Name;
string connectionString = this.ConnectionString; string connectionString = this.ConnectionString;
@ -72,12 +72,12 @@ namespace SharpDbTools.Model
public string ConnectionString { public string ConnectionString {
get { get {
DataTable table = this.Tables[TableNames.ConnectionInfo]; DataTable table = this.Tables[TableNames.ConnectionInfo];
string connectionString = (string)table.Rows[0][ColumnNames.ConnectionString]; string connectionString = table.Rows[0][ColumnNames.ConnectionString] as string;
return connectionString; return connectionString;
} }
set { set {
DataTable table = this.Tables[TableNames.ConnectionInfo]; DataTable table = this.Tables[TableNames.ConnectionInfo];
string invariantName = (string)table.Rows[0][ColumnNames.InvariantName]; string invariantName = table.Rows[0][ColumnNames.InvariantName] as string;
string name = this.Name; string name = this.Name;
string connectionString = this.ConnectionString; string connectionString = this.ConnectionString;

18
src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfoService.cs

@ -32,6 +32,7 @@ namespace SharpDbTools.Model
public static class DbModelInfoService public static class DbModelInfoService
{ {
static string saveLocation = null; static string saveLocation = null;
static object lockObject = new Object();
const string dbFilesDir = "DbTools"; const string dbFilesDir = "DbTools";
static SortedList<string, DbModelInfo> cache = new SortedList<string, DbModelInfo>(); static SortedList<string, DbModelInfo> cache = new SortedList<string, DbModelInfo>();
@ -124,7 +125,7 @@ namespace SharpDbTools.Model
string modelName = modelInfo.Name; string modelName = modelInfo.Name;
// write to a file in 'path' called <name>.metadata // write to a file in 'path' called <name>.metadata
// TODO: may want to consider ways of making this more resilient // TODO: may want to consider ways of making this more resilient
string filePath = @path + name + ".metadata"; string filePath = path + @"\" + name + ".metadata";
LoggingService.Debug("writing metadata to: " + filePath); LoggingService.Debug("writing metadata to: " + filePath);
if (File.Exists(filePath)) { if (File.Exists(filePath)) {
File.Delete(filePath); File.Delete(filePath);
@ -136,7 +137,13 @@ namespace SharpDbTools.Model
sw.Close(); sw.Close();
} }
} }
LoggingService.Debug("DbModelInfo with name: " + name + " not found"); }
public static void SaveAll()
{
foreach (string name in cache.Keys) {
SaveToFile(name);
}
} }
public static void LoadFromFiles() public static void LoadFromFiles()
@ -166,11 +173,14 @@ namespace SharpDbTools.Model
// append the path of the directory for saving Db files // append the path of the directory for saving Db files
if (saveLocation == null) { if (saveLocation == null) {
lock(saveLocation) { lock(lockObject) {
string configDir = PropertyService.ConfigDirectory; string configDir = PropertyService.ConfigDirectory;
saveLocation = configDir + dbFilesDir; saveLocation = configDir + @"\" + dbFilesDir;
} }
} }
if (!Directory.Exists(saveLocation)) {
Directory.CreateDirectory(@saveLocation);
}
return saveLocation; return saveLocation;
} }
} }

1
src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

@ -179,6 +179,7 @@ namespace SharpDbTools
public void SaveDbModelInfoClickHandler(object sender, EventArgs e) public void SaveDbModelInfoClickHandler(object sender, EventArgs e)
{ {
LoggingService.Debug("save all metadata clicked"); LoggingService.Debug("save all metadata clicked");
DbModelInfoService.SaveAll();
} }
public void SetConnectionStringOnDbModelInfoClickHandler(object sender, EventArgs e) public void SetConnectionStringOnDbModelInfoClickHandler(object sender, EventArgs e)

Loading…
Cancel
Save