/// <summary>Logs the specified message.</summary> /// <param name="message">The message.</param> public void Log(string message) { ThreadHelper.ThrowIfNotOnUIThread(); outputPane?.Activate(); outputPane?.OutputString(Environment.NewLine); outputPane?.OutputString(message); }
public static void AddMessage(string message, string prefix = null) { OutputWindowPane?.OutputString($"{(string.IsNullOrWhiteSpace(prefix) ? "" : prefix + ": ")}{message}{(message.EndsWith("\n") ? "" : "\n")}"); if (prefix == ERROR || prefix == WARNING) { OutputWindowPane?.Activate(); } }
private static void LogToOutputWindow(object message) { ThreadHelper.JoinableTaskFactory.RunAsync(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); OutputWindowPane?.OutputString(message + Environment.NewLine); }); }
private void MenuItemCallback(object sender, EventArgs e) { DTE2 dte = (DTE2)Package.GetGlobalService(typeof(DTE)); OutputWindow outputWindow = dte.ToolWindows.OutputWindow; OutputWindowPane outputWindowPane = outputWindow.OutputWindowPanes.Add("A New Pane"); outputWindowPane.OutputString("Some Text"); }
private void OutputString(string text) { System.Diagnostics.Debug.Write(text); if (_outputPane != null) { _outputPane.OutputString(text); } }
public void OnMessage(Log.Level level, string message, string formattedLine) { if (null == _outputWindowPane) { return; } _outputWindowPane.OutputString(formattedLine); }
public static void WriteToOutput(this DTE2 dte, string text) { InitializeVsPaneIfNeeded(dte); if (_outputWindowPane == null || string.IsNullOrEmpty(text)) { return; } ActivatePane(); _outputWindowPane.OutputString(text + Environment.NewLine); }
protected override void WriteLine(string message) { ThreadHelper.ThrowIfNotOnUIThread(); if (!message.EndsWith(Environment.NewLine)) { message += Environment.NewLine; } outputPane.OutputString(message); }
/// <summary> /// 输出日志 /// </summary> /// <param name="dte"></param> /// <param name="strs">输出字符串</param> public static void OutWindow(this DTE dte, string strs, string windowName) { if (null == _outPanel) { DTE2 dte2 = (DTE2)dte; _outPanel = dte2.ToolWindows.OutputWindow.OutputWindowPanes.Add(windowName); _outPanel.Activate(); } _outPanel.OutputString(strs + "\r\n"); }
/// <summary> /// 输出日志 /// </summary> /// <param name="dte"></param> /// <param name="strs">输出字符串</param> public static void OutWindow(this DTE dte, string strs) { if (null == _outPanel) { DTE2 dte2 = (DTE2)dte; _outPanel = dte2.ToolWindows.OutputWindow.OutputWindowPanes.Add("Entity2CodeTool Log"); _outPanel.Activate(); } _outPanel.OutputString(strs + "\r\n"); }
public void WriteLine(string format, params object[] par) { if (window != null) { lock (windowLock) { window.OutputString(string.Format(format, par) + "\r\n"); } } }
public static void WriteToOutput(this DTE dte, string text) { ClearOutputWindow(); if (_outputWindowPane == null || string.IsNullOrEmpty(text)) { return; } //_DxCoreTestPane.Activate(); _outputWindowPane.OutputString(text); }
public static void PrintMessage(this EnvDTE.DTE dte, string message) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); var panes = ((DTE2)dte).ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane outputPane = null; try { outputPane = panes.Item(paneName); } catch (ArgumentException) { panes.Add(paneName); outputPane = panes.Item(paneName); outputPane.OutputString(openMessage); } outputPane.OutputString(message); }
/// <summary> /// 在输出窗口和状态条中显示文本 /// </summary> /// <param name="Text">为要输出的文本内容</param> /// <param name="cCrlf">决定是不是要换行,默认为换行</param> /// <param name="bMustOut">决定该输出是不是必须输出的.</param> /// <remarks>如果不是重要的信息, 用户的不显示详细信息设置将过滤该输出信息</remarks> public static void ShowInfo(string Text, bool notime) { try { chOutWin.OutputString((notime ? "" : DateTime.Now.ToString("yyyyMMddHHmmss :")) + Text + System.Environment.NewLine); chDTE.StatusBar.Text = "KeelKit::" + Text; } catch (Exception) { } }
public void Log(string messageText) { try { outputWindowPane.OutputString(messageText + Environment.NewLine); } catch (Exception errorThrow) { MessageBox.Show(errorThrow.ToString()); } }
/// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary> /// <param name="application">Root object of the host application.</param> /// <param name='connectMode'>Describes how the Add-in is being loaded.</param> /// <param name='addInInst'>Object representing this Add-in.</param> /// <param name='custom'>Array of parameters that are host application specific.</param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; _outputWindowPane = _applicationObject.ToolWindows.OutputWindow.OutputWindowPanes.Add("SmartBackspace"); _outputWindowPane.OutputString("SmartBackspace loaded" + Environment.NewLine); _textDocumentKeyPressEvents = ((Events2)_applicationObject.Events).get_TextDocumentKeyPressEvents(null); _textDocumentKeyPressEvents.BeforeKeyPress += _OnTextDocumentBeforeKeyPress; }
/// <summary> /// Constructs the WebServer, starts the web server process. /// </summary> /// <param name="outputWindowPane">Existing output pane to send web server output to.</param> /// <param name="properties">PropertyManager that is set to a valid project/platform.</param> public WebServer(OutputWindowPane outputWindowPane, PropertyManager properties) { if (outputWindowPane == null) { throw new ArgumentNullException("outputWindowPane"); } if (properties == null) { throw new ArgumentNullException("properties"); } webServerOutputPane_ = outputWindowPane; // Read port from properties, if invalid port then set to default value. int webServerPort; if (!int.TryParse(properties.WebServerPort, out webServerPort)) { webServerPort = DefaultWebServerPort; } string webServerExecutable = "python.exe"; string httpd = Path.Combine(properties.SDKRootDirectory, "examples", "httpd.py"); if (!File.Exists(httpd)) httpd = Path.Combine(properties.SDKRootDirectory, "tools", "httpd.py"); string webServerArguments = httpd + " --no_dir_check " + webServerPort; webServerOutputPane_.Clear(); webServerOutputPane_.OutputString(Strings.WebServerStartMessage + "\n"); webServerOutputPane_.Activate(); // Start the web server process. try { webServer_ = new System.Diagnostics.Process(); webServer_.StartInfo.CreateNoWindow = true; webServer_.StartInfo.UseShellExecute = false; webServer_.StartInfo.RedirectStandardOutput = true; webServer_.StartInfo.RedirectStandardError = true; webServer_.StartInfo.FileName = webServerExecutable; webServer_.StartInfo.Arguments = webServerArguments; webServer_.StartInfo.WorkingDirectory = properties.ProjectDirectory; webServer_.OutputDataReceived += WebServerMessageReceive; webServer_.ErrorDataReceived += WebServerMessageReceive; webServer_.Start(); webServer_.BeginOutputReadLine(); webServer_.BeginErrorReadLine(); } catch (Exception e) { webServerOutputPane_.OutputString(Strings.WebServerStartFail + "\n"); webServerOutputPane_.OutputString("Exception: " + e.Message + "\n"); } }
public void OnMessage(Log.Level level, string message, string formattedLine) { OutputWindowPane pane = mPlugin.OutputPane; if (null == pane) { return; } pane.OutputString(formattedLine); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { FASTBuild.Initialize(this); base.Initialize(); m_dte = (DTE2)GetService(typeof(DTE)); OutputWindow outputWindow = m_dte.ToolWindows.OutputWindow; m_outputPane = outputWindow.OutputWindowPanes.Add("FASTBuild"); m_outputPane.OutputString("FASTBuild\r"); }
public List <TableRecord> ParseFileCodeModel() { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); List <TableRecord> tableList = new List <TableRecord>(); foreach (CodeElement2 codeElement in sourceItem.CodeElements) { /*Class*/ if (codeElement.Kind == vsCMElement.vsCMElementClass) { CodeClass2 classItem = codeElement as CodeClass2 ?? throw new ArgumentNullException(); List <TableRecord> classTRec = parseClass(classItem); tableList.AddRange(classTRec); } /*Parse struct functions*/ else if (codeElement.Kind == vsCMElement.vsCMElementStruct) { CodeStruct2 structItem = codeElement as CodeStruct2 ?? throw new ArgumentNullException(); debugPane.OutputString("Struct methods: " + structItem.FullName + "\n"); foreach (CodeElement2 field in structItem.Members) { if (field.Kind == vsCMElement.vsCMElementFunction) { TableRecord structTRec = parseFuntion(field as CodeFunction2); tableList.Add(structTRec); } } } /*Parse single functions*/ else if (codeElement.Kind == vsCMElement.vsCMElementFunction) { TableRecord funRec = parseFuntion(codeElement as CodeFunction2); tableList.Add(funRec); } } return(tableList); }
/// <summary> /// Updates the DBML information /// </summary> /// <param name="output">The output window to report status</param> public void DBUpdate(OutputWindowPane output) { using (SqlConnection conn = new SqlConnection(_connStr)) { conn.Open(); foreach (DBMLTable t in _tables) { output.OutputString(string.Format("Getting Table {0} information...\r\n", t.Name)); t.DBUpdate(conn); } } }
public void WriteToOutputWindow(string format, params object[] args) { var applicationObject = GetService(typeof(SDTE)) as DTE2; if (_outputWindow == null) { if (applicationObject != null) { var window = applicationObject.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}"); var outputWindow = (OutputWindow)window.Object; _outputWindow = outputWindow.OutputWindowPanes.Add("Web Resource Linker"); } } if (_outputWindow == null) { return; } _outputWindow.OutputString(string.Format(format, args)); _outputWindow.OutputString(Environment.NewLine); }
public void Write(string text) { if (outputWindowPane == null) { Init(); } if (outputWindowPane != null) { System.Diagnostics.Debug.Assert(outputWindowPane != null); outputWindowPane.OutputString(text); } }
public void StopTest(DTE2 applicationObject) { if (IsTestRunning) { _testRunner.Stop(); _testRunner.Dispose(); OutputWindowPane output = GetOutputPane(applicationObject); output.OutputString("Test stopped by user.\n"); output.Activate(); } }
private bool AttachProc(bool isLocal) { bool ret = false; EnvDTE80.Debugger2 dbg = (Debugger2)_app.Debugger; //get the active doc //make sure it is one of our test documents //attach to the process foreach (EnvDTE80.Process2 p in dbg.LocalProcesses) { if (p.Name.Contains("sqlservr.exe")) { proc = p; //attach to the managed code engine proc.Attach2("{449EC4CC-30D2-4032-9256-EE18EB41B62B}"); //p.Attach2("{1202F5B4-3522-4149-BAD8-58B2079D704F}"); owp.OutputString(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); //MessageBox.Show(string.Format("Attached to the SQL Server process, process Id: {0}", p.ProcessID.ToString())); ret = true; break; } } return(ret); }
internal void RunProcess(DTE dte, string command, string parameters) { Window win = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); OutputWindow comwin = (OutputWindow)win.Object; if (OWP == null) { foreach (OutputWindowPane w in comwin.OutputWindowPanes) { if (w.Name == "SPSF SharePoint Software Factory") { OWP = w; } } } if (OWP == null) { OWP = comwin.OutputWindowPanes.Add("SharePoint Software Factory"); } OWP.Clear(); OWP.Activate(); string dotnet = RuntimeEnvironment.GetRuntimeDirectory(); OWP.OutputString(command + " " + parameters + "\n"); Process snProcess = new Process(); snProcess.StartInfo.FileName = command; snProcess.StartInfo.Arguments = parameters; snProcess.StartInfo.CreateNoWindow = true; snProcess.StartInfo.UseShellExecute = false; snProcess.StartInfo.RedirectStandardOutput = true; snProcess.StartInfo.RedirectStandardError = true; snProcess.OutputDataReceived += new DataReceivedEventHandler(snProcess_OutputDataReceived); snProcess.ErrorDataReceived += new DataReceivedEventHandler(snProcess_ErrorDataReceived); snProcess.Start(); snProcess.BeginErrorReadLine(); snProcess.BeginOutputReadLine(); }
/// <summary> /// Writes string into current output pane. /// </summary> public void Write(string message) { if (canWrite) { outputPane.OutputString(message); } }
/// <summary> /// Will print a message to the web server output pane. /// </summary> /// <param name="dte">The main visual studio interface.</param> /// <param name="message">Message to print to the output pane.</param> public static void WebServerWriteLine(DTE2 dte, string message) { try { OutputWindowPane pane = dte.ToolWindows.OutputWindow.OutputWindowPanes.Item( Strings.WebServerOutputWindowTitle); pane.OutputString(message + "\n"); } catch (ArgumentException) { // This exception is expected if the window pane hasn't been created yet. } }
private void OnBuildDone(vsBuildScope scope, vsBuildAction action) { OutputWindowPane BuildOutputPane = null; foreach (OutputWindowPane pane in _dte2.ToolWindows.OutputWindow.OutputWindowPanes) { if (pane.Guid == VSConstants.OutputWindowPaneGuid.BuildOutputPane_string) { BuildOutputPane = pane; break; } } if (BuildOutputPane == null) { return; } if (ShowBuildReport) { BuildOutputPane.OutputString("\r\nProjects build report:\r\n"); BuildOutputPane.OutputString(" Status | Project [Config|platform]\r\n"); BuildOutputPane.OutputString(" -----------|---------------------------------------------------------------------------------------------------\r\n"); foreach (string ReportItem in _projectsBuildReport) { BuildOutputPane.OutputString(ReportItem + "\r\n"); } } if (ShowElapsedBuildTimeEnabled) { var elapsed = DateTime.Now - _buildStartTime; var time = elapsed.ToString(@"hh\:mm\:ss\.ff"); var text = string.Format("Time Elapsed {0}", time); BuildOutputPane.OutputString("\r\n" + text + "\r\n"); } }
internal void WriteOutput(string msg, bool clear = false, bool hide = false, string paneName = "Studio") { if (_outputWindowPane == null) { _outputWindowPane = GetOutputWindow(hide, paneName); } if (clear) { _outputWindowPane.Clear(); } _outputWindowPane.OutputString(msg); }
private void BuildAndProvisionMinecraftProject(object sender, EventArgs e) { DTE2 dte = (DTE2)GetService(typeof(SDTE)); OutputWindow outputWindow = (OutputWindow)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object; OutputWindowPane activePane = outputWindow.ActivePane; if (activePane == null) { activePane = outputWindow.OutputWindowPanes.Item("Build"); } OleMenuCmdEventArgs eventArgs = (OleMenuCmdEventArgs)e; if (eventArgs.InValue == null) { activePane.Activate(); activePane.OutputString("Missing parameter: requires the unique name of a project\n"); return; } string uniqueProjectName = eventArgs.InValue.ToString(); _targetProject = null; try { _targetProject = dte.Solution.Item(uniqueProjectName); } catch (Exception) { activePane.Activate(); activePane.OutputString("Invalid parameter: project not found\n"); return; } _buildEvents = dte.Events.BuildEvents; _buildEvents.OnBuildDone += buildEvents_OnBuildDone; dte.ExecuteCommand("Build.BuildSolution", ""); }
private static void GenerateDebugSymbols(string absoluteOutputPath, OutputWindowPane outputWindowPane) { FileInfo[] files = (new DirectoryInfo(absoluteOutputPath)).GetFiles(); foreach (FileInfo file in files) { if (file.Name.EndsWith(".dll") || file.Name.EndsWith(".exe")) { if (files.Any(x => x.Name.EndsWith(".mdb") && x.Name.Substring(0, x.Name.Length - 4) == file.Name)) { outputWindowPane.OutputString(string.Format("MonoHelper: Assembly {0}\r\n", file.Name)); string assemblyPath = file.FullName; AssemblyDefinition assemblyDefinition = AssemblyDefinition.ReadAssembly(assemblyPath, new ReaderParameters { SymbolReaderProvider = new MdbReaderProvider(), ReadSymbols = true }); CustomAttribute debuggableAttribute = new CustomAttribute( assemblyDefinition.MainModule.Import( typeof(DebuggableAttribute).GetConstructor(new[] { typeof(DebuggableAttribute.DebuggingModes) }))); debuggableAttribute.ConstructorArguments.Add( new CustomAttributeArgument(assemblyDefinition.MainModule.Import(typeof(DebuggableAttribute.DebuggingModes)), DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.DisableOptimizations)); if (assemblyDefinition.CustomAttributes.Any(x => x.AttributeType.Name == typeof(DebuggableAttribute).Name)) { // Replace existing attribute int indexOf = assemblyDefinition.CustomAttributes.IndexOf( assemblyDefinition.CustomAttributes.Single(x => x.AttributeType.Name == typeof(DebuggableAttribute).Name)); assemblyDefinition.CustomAttributes[indexOf] = debuggableAttribute; } else { assemblyDefinition.CustomAttributes.Add(debuggableAttribute); } assemblyDefinition.Write(assemblyPath, new WriterParameters { SymbolWriterProvider = new PdbWriterProvider(), WriteSymbols = true }); } } } }
public void OnCommand(DTE2 application, OutputWindowPane pane) { // Check if we've selected stuff in the solution explorer and we currently have this as the active window. if ("Tool" == application.ActiveWindow.Kind && application.ActiveWindow.Caption.StartsWith("Solution Explorer")) { int checkoutItems = 0; foreach (SelectedItem sel in application.SelectedItems) { if (null != sel.ProjectItem) { if (P4EditItem.EditItem(sel.ProjectItem, pane)) checkoutItems++; } if (null != sel.Project) { if (P4EditItem.EditProject(sel.Project, pane)) checkoutItems++; } } if (checkoutItems > 0) return; } // Finally, let's just see if the text editor is active if ("Document" == application.ActiveWindow.Kind && application.ActiveDocument != null) { string fullName = application.ActiveDocument.FullName; if( !application.ActiveDocument.ReadOnly ) { pane.OutputString( fullName + " is already opened for edit (is writeable on disk at least)\n" ); } else { P4Operations.EditFile(pane, fullName); } } }
private static System.Diagnostics.Process StartNet(DTE2 dte, OutputWindowPane outputWindowPane) { Project startupProject = dte.Solution.Item(((object[])dte.Solution.SolutionBuild.StartupProjects)[0]); Property startArguments = GetProperty(startupProject.ConfigurationManager.ActiveConfiguration.Properties, "StartArguments"); string fileName = GetProgramFileName(startupProject); string arguments = (string)startArguments.Value; outputWindowPane.OutputString(string.Format("MonoHelper: Running {0} {1}\r\n", fileName, arguments)); System.Diagnostics.Process process = new System.Diagnostics.Process { StartInfo = new ProcessStartInfo { FileName = string.Format(@"{0}", fileName), Arguments = string.Format(@"{0}", arguments), UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(fileName) } }; process.Start(); return process; }
private void AddReferenceToProject( Project targetProject, string referencePath, OutputWindowPane activePane) { dynamic javaProject = targetProject.Object; // Visual update dynamic jarReference = Activator.CreateInstance( "Tvl.VisualStudio.Language.Java", "Tvl.VisualStudio.Language.Java.Project.JarReferenceNode", false, 0, null, new Object[2] { javaProject, referencePath }, null, null).Unwrap(); dynamic referenceContainer = javaProject.GetReferenceContainer(); referenceContainer.AddChild(jarReference); // File update Microsoft.Build.Evaluation.Project msBuildProject = javaProject.BuildProject; var node = msBuildProject.Xml.AddItem("JarReference", referencePath); node.AddMetadata("IncludeInBuild", "true"); node.AddMetadata("Private", "false"); activePane.OutputString(referencePath + "\n"); }
void ProcessTest(OutputWindowPane pane) { string paneText; var success = _threading.BeginInvokeAndWait("Reading pane",()=> ReadTest(pane), out paneText, _unloading); if (!success) return; if (paneText == null || paneText.Length <= PluginManager.RESHARPER_TEST.Length) return; var methodName = paneText.Substring(PluginManager.RESHARPER_TEST.Length); pane.Clear(); Debug.WriteLine("Running test " + methodName); var runner = new ResharperTests(pane, _threading, _actionManager, _saManager, _solution); var result = typeof(ResharperTests).GetMethod(methodName).Invoke(runner, new object[0]); var msg = string.Format("!ReSharper{0}:{1}\r\n", methodName, result); _output.Write(msg); pane.OutputString(msg); }
/// <summary> /// Updates the statusbar and output window with the same message /// </summary> /// <param name="output">The output pane</param> /// <param name="status">The status bar</param> /// <param name="text">The message to send to both</param> private void UpdateStatus(OutputWindowPane output, StatusBar status, string text) { status.Text = text; output.OutputString(text + "\r\n"); }
private void WriteLineToPane(OutputWindowPane pane, string text) { pane.OutputString(text + Environment.NewLine); }
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { DTE2 dte2 = (DTE2)automationObject; Window win = dte2.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); OutputWindow outputWindow = (OutputWindow)win.Object; outputWindowPane = outputWindow.OutputWindowPanes.Add("Test"); outputWindowPane.OutputString("Start"); CommandBarControl addRef = null; foreach (CommandBar commandBar in (CommandBars)dte2.CommandBars) { outputWindowPane.OutputString("Command Bar = " + commandBar.Name + Environment.NewLine); foreach(CommandBarControl control in commandBar.Controls) { outputWindowPane.OutputString(control.Caption + Environment.NewLine); if (control.Caption.Equals("Add &Reference...")) { addRef = control; CommandBarButton ctl = (CommandBarButton) commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, control.Index, true); ctl.Click += new _CommandBarButtonEvents_ClickEventHandler(cbShowAddArtifactsForm_Click); //new _CommandBarButtonEvents_ClickEventHandler(ShowAddArtifactsForm); //new ClickEventHandler(); ctl.Caption = "Add Maven Artifact..."; ctl.Visible = true; } } } // dte2. += new EventHandler(ClearOutputWindowPane); // Window solutionExplorerWindow // = (Window) dte2.Windows.Item(Constants.vsWindowKindSolutionExplorer); // solutionExplorerWindow // Window w; UIHierarchy u; // UIHierarchyItem i; // dte2.Events. // ; // EnvDTE.s // DirectoryInfo projectDirectoryInfo = new FileInfo(dte2.Solution.Projects.Item(1).FullName).Directory; // dte2.Solution.Projects.Item(1).SaveAs(projectDirectoryInfo.FullName + @"\src\test.csproj"); try { // Display a form to the user. The form collects // input for the custom message. inputForm = new ArchetypeProjectForm(); String projectName = replacementsDictionary["$projectname$"]; inputForm.GroupId = (projectName.Contains(".")) ? projectName.Substring(0, projectName.LastIndexOf(".")) : projectName; inputForm.ArtifactId = projectName; inputForm.Version = "0.0.0.0-SNAPSHOT"; inputForm.ShowDialog(); String projectPath = @"src\main\csharp"; replacementsDictionary.Add("$artifactId$", inputForm.ArtifactId); replacementsDictionary.Add("$groupId$", inputForm.GroupId); replacementsDictionary.Add("$version$", inputForm.Version); replacementsDictionary.Add("$projectPath$", projectPath); replacementsDictionary.Add("$classPath$", projectPath + @"\" + inputForm.ArtifactId.Replace(".", @"\")); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Updates the DBML information /// </summary> /// <param name="output">The output window to report status</param> public void DBUpdate(OutputWindowPane output) { using(SqlConnection conn = new SqlConnection(_connStr)) { conn.Open(); foreach(DBMLTable t in _tables) { output.OutputString(string.Format("Getting Table {0} information...\r\n", t.Name)); t.DBUpdate(conn); } } }
/// <summary> /// Creates a new DBML file with the updates /// </summary> public void CreateDBML(string fileName, OutputWindowPane output) { _newDoc = new XmlDocument(); XmlDeclaration dec = _newDoc.CreateXmlDeclaration("1.0", "utf-8", null); _newDoc.AppendChild(dec); XmlNode den = _newDoc.ImportNode(_doc.DocumentElement, false); _newDoc.AppendChild(den); bool doneTables = false; foreach(XmlNode n in _doc.DocumentElement.ChildNodes) { XmlElement e = n as XmlElement; if(e != null && e.Name == "Table") { if(!doneTables) { foreach(DBMLTable t in _tables) { output.OutputString(string.Format("Adding table {0}...\r\n", t.Name)); den.AppendChild(t.CreateDBML(this)); } doneTables = true; } continue; } XmlNode un = _newDoc.ImportNode(n, true); den.AppendChild(un); } output.OutputString(string.Format("Writing file \"{0}\"...\r\n", fileName)); _newDoc.Save(fileName); }
private void ProvisionProject(DTE2 dte, OutputWindowPane activePane, Project targetProject) { string classpathFile = Path.GetDirectoryName(targetProject.FullName) + "\\.classpath"; if (!File.Exists(classpathFile)) { activePane.Activate(); activePane.OutputString("File not found: .classpath. A provisioning build needs to complete successfully first\n"); return; } var doc = new XmlDocument(); doc.Load(classpathFile); var entries = doc.GetElementsByTagName("classpathentry"); // filter entries by kind = "lib" for (int i = 0; i < entries.Count; ++i) { var node = entries.Item(i); var path = node.Attributes["path"]; var type = node.Attributes["kind"]; if (path != null) { if (type != null && type.Value.Equals("lib")) { AddReferenceToProject(targetProject, path.Value.EndsWith(".jar") ? path.Value : path.Value + "/", activePane); } } } targetProject.Save(); }
//one of the test methods for debugging, running against //sqlcmd - due to bug in S2K5, where we hang wen executing //this method causes hang as well bool ExecStmt2(string cmdText) { OutputWindow ow = _app.ToolWindows.OutputWindow; ow.Parent.Activate(); try { owp = ow.OutputWindowPanes.Item("Debug"); } catch { owp = ow.OutputWindowPanes.Add("Debug"); } try { _app.StatusBar.Text = "Debug started"; ow.Parent.Activate(); owp.Activate(); string buildPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); buildPath = Path.Combine(buildPath, "MSBUILD.exe"); owp.OutputString("Debug Started\n"); System.Diagnostics.Process p = new System.Diagnostics.Process(); string sqlFile = ""; //sqlcmd -d test2 -Q "select dbo.MyAdder99 sqlFile = Path.Combine(ProjectPath, "sql.proj"); //string paramString = string.Format("\"{0}\" /t:ExecDebug /p:CmdText=\"{1}\"", sqlFile, cmdText); //p.StartInfo = new ProcessStartInfo("cmd.exe", "/k " + buildPath + " \"" + sqlFile + "\" /t:ExecDebug /p:CmdText=\"" + cmdText + "\""); p.StartInfo = new ProcessStartInfo("sqlcmd.exe", "-d test2 -Q \"" + cmdText + "\""); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start(); p.BeginOutputReadLine(); //owp.OutputString(p.StandardOutput.ReadToEnd()); p.WaitForExit(); owp.Activate(); string statusMsg = "succeeded"; if (p.ExitCode != 0) statusMsg = "failed"; _app.StatusBar.Text = string.Format("Debug {0}", statusMsg); ow.Parent.Activate(); //ow.Parent.AutoHides = true; return true; } catch (Exception e) { _app.StatusBar.Text = "Debug failed"; string msg = string.Format("An unexpected exception occured.\n\nThe exception is: {0}", e.Message); owp.OutputString(msg); return false; } finally { } }
static private bool RunCommand(OutputWindowPane output, string executable, string commandline, string workingdir, int timeout) { try { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = executable; if( 0 == timeout ) { // We are not for these processes reading the stdout and thus they could if they wrote more // data on the output line hang. process.StartInfo.RedirectStandardOutput = false; process.StartInfo.RedirectStandardError = false; } else { process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; } process.StartInfo.CreateNoWindow = true; process.StartInfo.WorkingDirectory = workingdir; process.StartInfo.Arguments = commandline; Log.Debug("executableName : " + executable); Log.Debug("workingDirectory : " + workingdir); Log.Debug("command : " + commandline); if(!process.Start()) { Log.Error("{0}: {1} Failed to start. Is Perforce installed and in the path?\n", executable, commandline); return false; } if (0 == timeout) { // Fire and forget task. return true; } bool exited = false; string alloutput = ""; using (Process.Handler stderr = new Process.Handler(), stdout = new Process.Handler()) { process.OutputDataReceived += stdout.OnOutput; process.BeginOutputReadLine(); process.ErrorDataReceived += stderr.OnOutput; process.BeginErrorReadLine(); exited = process.WaitForExit(timeout); /* * This causes the plugin to unexpectedly crash, since it brings the entire thread down, and thus the entire environment?!? * if (0 != process.ExitCode) { throw new Process.Error("Failed to execute {0} {1}, exit code was {2}", executable, process.StartInfo.Arguments, process.ExitCode); }*/ stderr.sentinel.WaitOne(); stdout.sentinel.WaitOne(); alloutput = stdout.buffer + "\n" + stderr.buffer; } if(!exited) { Log.Info("{0}: {1} timed out ({2} ms)", executable, commandline, timeout); process.Kill(); return false; } else { if(null != output) { output.OutputString(executable + ": " + commandline + "\n"); output.OutputString(alloutput); } System.Diagnostics.Debug.WriteLine(commandline + "\n"); System.Diagnostics.Debug.WriteLine(alloutput); if(0 != process.ExitCode) { Log.Debug("{0}: {1} exit code {2}", executable, commandline, process.ExitCode); return false; } } return true; } catch(System.ComponentModel.Win32Exception e) { Log.Error("{0}: {1} failed to spawn: {2}", executable, commandline, e.ToString()); return false; } }
private void SetupOutputWindow(DTE2 applicationObject) { window = applicationObject.Windows.Item(Constants.vsWindowKindOutput); outputWindow = (OutputWindow)window.Object; owp = outputWindow.OutputWindowPanes.Add("new pane"); owp.OutputString("hello\n"); }