2010-11-18 2 views
0

아래의 코드는 winforms 응용 프로그램의 코드입니다. 단추 이벤트에서 비즈니스 개체 6.5의 인스턴스가 열리고 보고서가 새로 고쳐지고 보고서의 데이터가 csv 파일로 덤프되며, 그런 다음 Business Object 인스턴스를 종료합니다. 내가 다시 실행하면정적 클래스 및 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); 
    } 

} 

답변

0

이며, 그 트릭을 할 것 같았다

0

또한이 로그인 코드를 사용하면 작동하지만 BO 로그인 대화 상자의 확인 버튼을 클릭해야합니다. 몇 가지 방법이 클릭 버튼 단계를 건너 뛸 수 있습니까?

+0

Blimey, 이것은 과거로부터의 폭발입니다. 이 줄을 설정하여 모든 비즈니스 개체 상호 작용을 해제합니다. boApp.Interactive = false; boApp.LoginAs (userName, Password, false, null);에서 사용자 이름과 비밀번호가 올바른지 확인하고 있습니까? 방법? – MrBliz

+0

내 사용자 이름과 암호가 맞다고 생각합니다. 아래 링크를 통해 코드를 볼 수 있습니다. BO 로그인 diaglog의 ok 버튼을 클릭하면 bo 응용 프로그램이 평소대로 실행됩니다. [코드를 보려면 여기를 클릭하십시오.] www.forumtopics.com/busobj/viewtopic.php?t=219784&sid=027f230af85e9b74e8fccff138288724) – user1994358

+0

더 이상 도울 수 있기를 바라지 만 더 이상 테스트를 위해 Business Objects 6.5에 액세스 할 수 없습니다. – MrBliz

관련 문제