Browse Source

More wip: ServerBrowserTool now loads and displays basic DbModelInfos using user's home dir

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1695 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 20 years ago
parent
commit
4d6221baad
  1. 9
      src/AddIns/Misc/SharpDbTools/Project/Src/Model/DbModelInfoService.cs
  2. 27
      src/AddIns/Misc/SharpDbTools/Project/Src/ServerBrowserTool.cs

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

@ -153,18 +153,16 @@ namespace SharpDbTools.Model
string[] files = Directory.GetFiles(saveLocation); string[] files = Directory.GetFiles(saveLocation);
cache.Clear(); cache.Clear();
for (int i = 0; i < files.Length; i++) { for (int i = 0; i < files.Length; i++) {
DbModelInfo nextModel = LoadFromFile(@saveLocation + files[i]); DbModelInfo nextModel = LoadFromFile(@files[i]);
cache.Add(nextModel.Name, nextModel); cache.Add(nextModel.Name, nextModel);
} }
} }
private static DbModelInfo LoadFromFile(string filePath) private static DbModelInfo LoadFromFile(string filePath)
{ {
StreamReader reader = File.OpenText(filePath); LoggingService.Debug("loading DbModelInfo from filePath: " + filePath);
string xml = reader.ReadToEnd();
reader.Close();
DbModelInfo nextModel = new DbModelInfo(); DbModelInfo nextModel = new DbModelInfo();
nextModel.ReadXml(xml); nextModel.ReadXml(filePath);
return nextModel; return nextModel;
} }
@ -176,6 +174,7 @@ namespace SharpDbTools.Model
lock(lockObject) { lock(lockObject) {
string configDir = PropertyService.ConfigDirectory; string configDir = PropertyService.ConfigDirectory;
saveLocation = configDir + @"\" + dbFilesDir; saveLocation = configDir + @"\" + dbFilesDir;
saveLocation = saveLocation.Replace("/", @"\");
} }
} }
if (!Directory.Exists(saveLocation)) { if (!Directory.Exists(saveLocation)) {

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

@ -78,7 +78,7 @@ namespace SharpDbTools
public ServerToolTreeView(): base() public ServerToolTreeView(): base()
{ {
dbNode = new TreeNode(); dbNode = new TreeNode();
dbNode.Text = "Database Connections"; dbNode.Text = "Database Explorer";
dbNode.Tag = "DatabaseConnections"; dbNode.Tag = "DatabaseConnections";
// create the context menu for the database server node // create the context menu for the database server node
@ -105,8 +105,14 @@ namespace SharpDbTools
); );
dbNode.ContextMenuStrip = cMenu; dbNode.ContextMenuStrip = cMenu;
// TODO: NEXT: put this and the Rebuild... behaviour into a view builder;
// this is the wrong place for this, but lets give it a go...
DbModelInfoService.LoadFromFiles();
this.BeginUpdate(); this.BeginUpdate();
this.Nodes.Add(dbNode); this.Nodes.Add(dbNode);
RebuildDbConnectionsNode();
this.EndUpdate(); this.EndUpdate();
} }
@ -140,6 +146,25 @@ namespace SharpDbTools
}); });
treeNode.ContextMenuStrip = cMenu; treeNode.ContextMenuStrip = cMenu;
// create sub TreeNodes for the connection string and invariant name if they exist
DbModelInfo modelInfo = DbModelInfoService.GetDbModelInfo(name);
string connectionString = modelInfo.ConnectionString;
string invariantName = modelInfo.InvariantName;
TreeNode attributesNode = new TreeNode("Connection Properties");
treeNode.Nodes.Add(attributesNode);
if (connectionString != null) {
TreeNode cstringNode = new TreeNode("Connection String: " + connectionString);
attributesNode.Nodes.Add(cstringNode);
}
if (invariantName != null) {
TreeNode invNameNode = new TreeNode("Invariant Name: " + invariantName);
attributesNode.Nodes.Add(invNameNode);
}
return treeNode; return treeNode;
} }

Loading…
Cancel
Save