【发布时间】:2013-02-15 14:49:29
【问题描述】:
我想运行 tabcmd.exe utility 在 tableau server 中发布视图。执行此操作的手动步骤如下,日志文件将针对位置中的每个步骤进行更新
“C:\Users[用户名]\AppData\Roaming\Tableau\tabcmd.log”
在同一会话中,我必须逐个手动执行此步骤
- 运行 cmd.exe
- 使用命令登录tabcmd login -s "http:/sales-server:8000" -t Sales -u administrator -p p@ssw0rd!
- 使用命令创建项目名称 tabcmd createproject -n "Quarterly_Reports" -d "显示季度销售报告的工作簿。"
- 使用命令发布视图 tabcmd publish "analysis.twbx" -n "Sales_Analysis" --db-user "jsmith" --db-password "p@ssw0rd"
- 使用命令刷新tabcmd refreshextracts --workbook "My Workbook"
- 使用命令 tabcmd logout 注销
现在我正在尝试从我的 .Net win 表单中自动执行这些步骤,因此我尝试使用下面的代码,但它不起作用。
String path = @"C:\Program Files (x86)\Tableau\Tableau Server\7.0\bin\tabcmd.exe"
ProcessStartInfo startInfo = new ProcessStartInfo ();
startInfo.FileName = "\""+path+ "\"";
startInfo.Arguments = String.Format("login -s http://Server1:8000 --db-user "jsmith" --db-password "p@ssw0rd");
startInfo.UseShellExecute = false ;
startInfo.CreateNoWindow = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
using (StreamWriter sw = p.StandardInput)
{
if (sw.BaseStream.CanWrite)
{
sw.WriteLine("createproject -n \"MyProject\" -d \"MyProjectWorkbook\"");
//sw.WriteLine("My next Command");
//sw.WriteLine("My next Command");
}
}
我能够成功登录,但我无法进一步执行后续步骤,我不知道如何进一步进行此操作,因此我期待一些帮助。 提前致谢!
【问题讨论】:
-
重定向输出但不实际读取它是一个坏主意。当程序的输出缓冲区已满并且由于您没有阅读它而无法清空时,该程序将挂起。速度也很快,通常约为 2 KB。
标签: c# winforms cmd tableau-api