private void OkButton_Click(object sender, EventArgs e) { _options.Connection = ConnectionStringTextBox.Text; _options.DbType = (DbEnum)Enum.Parse(typeof(DbEnum), DbTypeComboBox.Text); OptionsHelper.SaveOptions(_dte, _options); Close(); }
public ActionResult Save(OptionsModel options) { HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache); OptionsHelper.SaveOptions(options, this); return(new EmptyResult()); }
public static async Task <string> GetRepositoryRoot(string path = "") { try { // Override any logic with the solution specific Root Folder setting var options = await OptionsHelper.GetOptions(); if (!string.IsNullOrEmpty(options.RootFolder)) { return(options.RootFolder); } // Try to find the current working folder, either by open document or by open solution if (string.IsNullOrEmpty(path)) { var solution = await VS.Solutions.GetCurrentSolutionAsync(); var documentView = await VS.Documents.GetActiveDocumentViewAsync(); if (!string.IsNullOrEmpty(solution?.FullPath)) { path = Path.GetDirectoryName(solution.FullPath); } else if (!string.IsNullOrEmpty(documentView?.Document?.FilePath)) { path = Path.GetDirectoryName(documentView.Document.FilePath); } } // No solution or file open, we have no way of determining repository root. // Fail silently. if (string.IsNullOrEmpty(path)) { return(string.Empty); } var proc = new Process { StartInfo = new ProcessStartInfo { FileName = "cmd.exe", Arguments = $"/c cd /D \"{path}\" && \"{FileHelper.GetSvnExec()}\" info --show-item wc-root", UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; proc.Start(); var errors = string.Empty; while (!proc.StandardError.EndOfStream) { errors += await proc.StandardError.ReadLineAsync(); } while (!proc.StandardOutput.EndOfStream) { options.RootFolder = await proc.StandardOutput.ReadLineAsync(); } await OptionsHelper.SaveOptions(options); if (string.IsNullOrEmpty(options.RootFolder)) { await ShowMissingSolutionDirMessage(); } return(options.RootFolder); } catch (Exception e) { LogHelper.Log(e); } await ShowMissingSolutionDirMessage(); return(string.Empty); }
public static string GetRepositoryRoot(string path = "") { var svnInfo = string.Empty; try { // Override any logic with the solution specific Root Folder setting OptionsHelper.Dte = Dte; var rootFolder = OptionsHelper.GetOptions().RootFolder; if (!string.IsNullOrEmpty(rootFolder)) { return(rootFolder); } // Try to found the current working folder, either by open document or by open solution if (string.IsNullOrEmpty(path)) { if (!string.IsNullOrEmpty(Dte.Solution.FileName)) { path = Path.GetDirectoryName(Dte.Solution.FullName); } else if (Dte.ActiveDocument != null) { path = Path.GetDirectoryName(Dte.ActiveDocument.FullName); } } var proc = new Process { StartInfo = new ProcessStartInfo { FileName = "cmd.exe", Arguments = $"/c cd /D \"{path}\" && \"{FileHelper.GetSvnExec()}\" info", UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; proc.Start(); while (!proc.StandardOutput.EndOfStream) { var line = proc.StandardOutput.ReadLine(); LogHelper.Log($"SvnInfo: {line}"); svnInfo += line; if (line?.StartsWith("Working Copy Root Path:") ?? false) { rootFolder = line.Substring(24); } } while (!proc.StandardError.EndOfStream) { var line = proc.StandardError.ReadLine(); svnInfo += line; LogHelper.Log($"SvnInfo: {line}"); } var options = OptionsHelper.GetOptions(); options.RootFolder = rootFolder; OptionsHelper.SaveOptions(options); if (string.IsNullOrEmpty(rootFolder)) { ShowMissingSolutionDirMessage(); } return(rootFolder); } catch (Exception e) { LogHelper.Log(svnInfo, e); } ShowMissingSolutionDirMessage(); return(string.Empty); }