public void Open(string serverName, string fullName, Urn urn, string text) { string key = urn.ToString(); IObjectExplorerService objExplorer = ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService)) as IObjectExplorerService; var test = ServiceCache.ServiceProvider.GetService(typeof(IObjectExplorerService)) as IObjectExplorerService; var node = objExplorer.FindNode(key); if (node != null) { objExplorer.SynchronizeTree(node); } Document existingDocument; if (_openedDocuments.TryGetValue(key, out existingDocument)) { existingDocument.Activate(); } else if (text != null) { var script = ServiceCache.ScriptFactory.CreateNewBlankScript(ScriptType.Sql) as SqlScriptEditorControl; script.EditorText = text; _openedDocuments[key] = _applicationObject.ActiveDocument; string fullPath = Properties.Settings.Default.ResolveProjectRoot(); if (!fullPath.EndsWith("\\")) { fullPath += '\\'; } fullPath += serverName + '\\' + fullName.Replace('.', '\\').Replace(':', '_') + ".sql"; _applicationObject.ActiveDocument.Save(fullPath); } }