以下のコードはwinformsアプリケーションのものです。ボタンイベントでビジネスオブジェクト6.5のインスタンスを開き、レポートを更新してレポートのデータをcsvファイルにダンプし、ビジネス・オブジェクト・インスタンスを終了します。私は再びそれを実行した場合スタティッククラスとBusiness Objects COMライブラリ
私はそれが完璧に動作するコードを実行する最初の時間は、しかし、私はライン
boApp.LoginAs(userName, Password, false, null);
スローされた例外は、「無効なオブジェクト」である上、例外を取得します。
私はこれがboAppが再初期化されていないという事実を前提としていますが、それは問題の静的クラスに関する私の知識の欠如です。
呼び出すメソッドはこれです:
BO_Control.RefreshBusinessObjects(boReportsFolder, boExportsFolder, boReportName, exportFileName, startDate, endDate);
を、これは私がRefreshBusinessObjects法にBOAppのインスタンス化を移動BO_Controlクラス
static class BO_Control
{
static busobj.Application boApp = new busobj.Application();
static busobj.Document testDoc;
public static void RefreshBusinessObjects(string reportFolder, string exportFolder ,string boReportName, string exportFileName, string startDate, string endDate)
{
DateTime BoStart = DateTime.Now;
boApp.LoginAs(userName, Password, false, null);
boApp.Interactive = false;
boApp.Visible = false;
GetData(reportFolder, boReportName, startDate, endDate);
ExportData(exportFolder, exportFileName);
Console.WriteLine("BO_Export took {0} seconds.", DateTime.Now.Subtract(BoStart));
boApp.Quit();
}
static busobj.Document GetData(string reportFolder, string reportName, string startDate, string endDate)
{
Console.WriteLine(reportFolder + reportName);
testDoc = (busobj.Document)boApp.Documents.Open(reportFolder + reportName, true, false, null, null);
//Report Start Date
testDoc.Variables[1].Value = startDate;
//Report End Date
testDoc.Variables[2].Value = endDate;
//Area. Needs to be a semi-colon delimited string
testDoc.Variables[3].Value = "L;B;H;";
testDoc.Refresh();
return testDoc;
}
static void ExportData(string exportFolder, string exportFileName)
{
testDoc.Reports.get_Item(1).ExportAsText(exportFolder + exportFileName);
//2 = DoNotSaveChanges
testDoc.Close(2);
}
}
Blimey、これは過去からの爆発です。この行は、すべてのビジネスオブジェクトの相互作用を無効にするように設定する必要があります。boApp.Interactive = false;また、boApp.LoginAs(userName、Password、false、null)でユーザー名とパスワードが正しいことを確認していますか。方法? – MrBliz
私のユーザ名とパスワードが正しいと思う、下のリンクから私のコードを見て、私がBOログインdiaglogのokボタンをクリックすると、boアプリケーションはいつものように動く [コードはここをクリック] www.forumtopics.com/busobj/viewtopic.php?t=219784&sid=027f230af85e9b74e8fccff138288724) – user1994358
さらにお手伝いしたいと思いますが、テストするためにビジネスオブジェクト6.5にアクセスできなくなりました。 – MrBliz