3

tabcmd.exe ユーティリティを実行して、ビューを Tableau Server に公開したいと考えています。これを行うための手動の手順は次のとおりです。ログ ファイルは、その場所の手順ごとに更新されます。

"C:\Users[ユーザー名]\AppData\Roaming\Tableau\tabcmd.log"

同じセッションで、この手順を 1 つずつ手動で実行する必要があります

  1. cmd.exe を実行します。
  2. コマンドtabcmd login -s "http:/sales-server:8000" -t Sales -u administrator -pp@ssw0rd!を使用してログインします。
  3. コマンドtabcmd createproject -n "Quarterly_Reports" -d "Workbooks show Quarterly sales reports"を使用してプロジェクト名を作成します。
  4. コマンドtabcmd publish "analysis.twbx" -n "Sales_Analysis" --db-user "jsmith" --db-password "p@ssw0rd"を使用してビューを公開します。
  5. コマンドtabcmd refreshextracts --workbook "My Workbook"を使用して更新します
  6. コマンド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");
            }
        }  

正常にログインできましたが、次の手順に進むことができません。これをさらに進める方法がわかりません。そのため、これに関するヘルプを楽しみにしています。前もって感謝します!

4

1 に答える 1

5

これが役に立つかどうかはわかりませんが、これらすべてのコマンドを使用してバッチ ファイルを作成し、次のようにコマンド プロンプトからバッチ ファイルを実行してみてください:-

  //Build Commands - You may have to play with the syntax

    string[] cmdBuilder = new string[5] 
      { 
       @"tabcmd login -s 'http:/sales-server:8000' -t Sales -u administrator -p p@ssw0rd!",
       @"tabcmd createproject -n 'Quarterly_Reports' -d 'Workbooks showing quarterly sales reports.'",
       @"abcmd publish 'analysis.twbx' -n 'Sales_Analysis' --db-user 'jsmith' --db-password 'p@ssw0rd'", 
       @"tabcmd refreshextracts workbook 'My Workbook'",
       @"tabcmd logout"

      };


     //Create a File Path

    string BatFile = @"\YourLocation\tabcmd.bat";

    //Create Stream to write to file.

    StreamWriter sWriter = new StreamWriter(BatFile);

     foreach (string cmd in cmdBuilder) 
        { 
          sWriter.WriteLine(cmd); 
        }

       sWriter.Close();

    //Run your Batch File & Remove it when finished.


   Process p = new Process();
   p.StartInfo.CreateNoWindow = true;
   p.StartInfo.UseShellExecute = false;
   p.StartInfo.FileName = "C:\\cmd.exe";
   p.StartInfo.Arguments = @"\YourLocation\tabcmd.bat";
   p.Start();
   p.WaitForExit();
   File.Delete(@"\YourLocation\tabcmd.bat")

出力セクションは自分に任せます。これを試すことができます。完全にきれいではありませんが、主な手順を自動化します。これか、最後のプロセスが終了するときに各コマンドのプロセスを開くかのどちらかですか?

これが役に立てば幸いです。

于 2013-02-15T15:50:20.567 に答える