2016-12-01 17 views
0

AX2012 R3から特定のプリンタにテキストファイルを印刷する際に問題があります。私は、エラーメッセージにprocess.Start()内のすべての時間を取得AX2012プリンタへのtxtファイルの印刷

public void printToPrinter(str _text, str printerName) 
{ 
    #File 
    System.Diagnostics.ProcessStartInfo processInfo; 
    System.Diagnostics.Process   process; 
    System.Exception     interopException; 
    TextIo        textIo; 
    PrintPathTable      printPath = PrintPathTable::find(); 
    str         fileName, arguments; 
    FileIoPermission     perm; 

    try 
    { 
     // Get the path and name. 
     fileName = this.getGuid(); 
     fileName = strFmt(@'%1%2',printPath.PrintPath, fileName); 

     // Assert permission. 
     perm = new FileIoPermission(fileName,'RW'); 
     perm.assert(); 

     // Open file for writing. 
     textIo = new TextIo(fileName, #IO_WRITE);   
     textIo.write(_text); 
     // Close the file. 
     textIo = null; 

     arguments = '\"' + printerName + '\"'; 

     process = new System.Diagnostics.Process(); 
     processInfo = process.get_StartInfo(); 
     processInfo.set_Verb('printto'); 
     processInfo.set_UseShellExecute(true); 
     processInfo.set_Arguments(arguments); 
     processInfo.set_FileName(fileName); 
     processInfo.set_WindowStyle(System.Diagnostics.ProcessWindowStyle::Hidden); 
        process.set_StartInfo(processInfo); 
     process.Start();   

        // revert asserted permissions 
        CodeAccessPermission::revertAssert(); 
    } 
    catch(Exception::CLRError) 
    { 
        interopException = CLRInterop::getLastException(); 
        while (!CLRInterop::isNull(interopException.get_InnerException())) 
        { 
            interopException = interopException.get_InnerException(); 
        } 

        error(strFmt('Fehler Druck "%1", "%2"', fileName, CLRInterop::getAnyTypeForObject(interopException.get_Message()))); 
    }  
} 

: は、ここに私のソースで指定されたファイルは、アプリケーションに割り当てられていません。

また、拡張子.txtのAOSの割り当てを確認しました。メソッドはサーバー上で実行されます。

私は、以下の例に従って進めてきた

How to print any file in Dynamics AX

Performing File IO with the TextIo Class [AX 2012]

答えて

0

を[OK]を、私は、

を自分自身をだましてきた私は私の個人的なログインとファイルの割り当てをチェックしてAOS。ここでは、割り当ては正しいものの、ソースはAOSサービスユーザーで実行されます。割り当てはAOSサービスユーザーに対して設定されていませんでした。おそらく、サードパーティのソフトウェアをインストールすることによって。メモ帳に.txtの割り当てに応じて、それは必要に応じて実行されます。

考えていただいたすべての方

関連する問題