SharePoint ワークフローから Word ドキュメントを開き、特定のプリンター トレイに印刷する必要があります。最初に Word.Interop を使用して Word アプリ インスタンスを作成しようとしましたが、doc オブジェクトは常に null を返しました。これは WordInterop のサポートされた使用法ではないことを読みました。だから今、私は代替品を探しています
Word ドキュメント、プリンター名、およびトレイ番号をパラメーターとして受け入れる単純なコンソール アプリを作成しました。コンソール アプリはコマンド プロンプトでうまく機能しますが、SharePoint ワークフロー CodeActivity からの呼び出しに問題があります。
string urlWord = GetwordDocument(printType);
System.Diagnostics.Process prcs = new System.Diagnostics.Process();
prcs.StartInfo.FileName = @"c:\DocxPrint2Tray.exe";
prcs.StartInfo.Arguments = String.Format(" \"{0}\" \"{1}\" \"{2}\" ",urlWord, printerName, printerTray);
prcs.StartInfo.UseShellExecute = false;
prcs.StartInfo.RedirectStandardOutput = true;
prcs.Start();
string prcsOut = prcs.StandardOutput.ReadToEnd();
prcs.WaitForExit();
コードがprcs.StandardOutput.ReadToEnd()行でハングしているように見えます。SharePoint ワークフローは外部プロセスの呼び出しをサポートしていますか? コードの提案と代替ソリューションを受け入れます。
前もって感謝します