2009-12-17 7 views
3

저는 C#을 사용하여 작은 응용 프로그램을 작성하여 DMS 서버의 개인 '내 문서'폴더에 문서를 복사했습니다.IManExt ImportCmd trouble

'WorkSite SDK 8 : 새로운 문서 폴더를 작성하기 위해 IMANEXT2Lib.IManRefileCmd 활용'블로그에서 제공하는 목록의 코드를 사용했습니다.

WinForm 응용 프로그램에서이 코드를 사용하면 원본 폴더에서 사용자 DMS '내 문서'폴더로 파일을 복사 할 때 아무런 문제가 없습니다.

그러나 복사 프로세스 중에 명령 줄 응용 프로그램/.dll 또는 다른 형식의 응용 프로그램 (WinForm 이외)의 코드를 사용하면 오류 메시지가 나타납니다. 시도 이벤트를 기록 할 때

1.

오류가 발생했습니다!

IManExt : 이벤트를 기록하려고하면 오류가 발생했습니다!

액세스가 거부됩니다. 2.

문서

는 데이터베이스에 가져온하지만 폴더에 추가 할 수 없습니다.

IManExt : 문서를 데이터베이스로 가져 왔지만 폴더에 추가 할 수 없습니다.

IManExt.LogRuleEventsCmd.1 : 이벤트를 기록하려고 할 때 오류가 발생했습니다!

IManExt.LogRuleEventsCmd.1 : 액세스가 거부되었습니다.

이벤트를 기록 할 때 오류가 발생했습니다!

- % - 나는 문서를 복사 할 비 윈폼 응용 프로그램을 사용할 때 에러 메시지 '액세스 거부'수신 거라고 왜

사람이 알고 있나요? 이 문제를 해결하려면 무엇을해야합니까?

어떤 도움 놀라운 것입니다! 장소에

코드 : 이 다른 사람을 도움이 그냥 경우

public void moveToDMS(String servName, String dBName, String foldName) 
    { 
     const string SERVERNAME = servName; //Server name 
     const string DATABASENAME = dBName; //Database name 
     const string FOLDERNAME = foldName; //Matter alias of workspace 

     IManDMS dms = new ManDMSClass(); 
     IManSession sess = dms.Sessions.Add(SERVERNAME); 
     sess.TrustedLogin(); 

     //Get destination database. 
     IManDatabase db = sess.Databases.ItemByName(DATABASENAME); 

     //Get destination folder by folder and owner name. 
     IManFolderSearchParameters fparms = dms.CreateFolderSearchParameters(); 
     fparms.Add(imFolderAttributeID.imFolderOwner, sess.UserID); 
     fparms.Add(imFolderAttributeID.imFolderName, FOLDERNAME);   

     //Build a database list in which to search. 
     ManStrings dblist = new ManStringsClass(); 
     dblist.Add(db.Name); 

     IManFolders results = sess.WorkArea.SearchFolders(dblist, fparms); 

     if (results.Empty == true) 
     { 
      //No results returned based on the search criteria. 
      Console.WriteLine("NO RESULTS FOUND!"); 
     } 

     IManDocumentFolder fldr = null; 

     if (results.Empty == false) 
     { 
      //Assuming there is only one workspace returned from the results. 
      fldr = (IManDocumentFolder)results.ItemByIndex(1); 
     } 

     if (fldr != null) 
     { 
      // Import file path 
      string docPath = @"C:\Temp\"; 
      string docName = "MyWord.doc"; 

      // Create an instance of the ContextItems Collection Object. 
      ContextItems context = new ContextItemsClass(); 

      // Invoke ImportCmd to import a new document to WorkSite database. 
      ImportCmd impCmd = new ImportCmdClass(); 

      // The WorkSite object you pass in can be a database, session, or folder. 
      // Depends on in where you want the imported doc to be stored. 
      context.Add("IManDestinationObject", fldr); //The destination folder. 

      // Filename set here is used for easy example, a string variable is normally used here 
      context.Add("IManExt.Import.FileName", docPath + docName); 

      // Document Author 
      context.Add("IManExt.Import.DocAuthor", sess.UserID); //Example of a application type. 

      // Document Class 
      context.Add("IManExt.Import.DocClass", "BLANK"); //Example of a document class. 
      //context.Add("IManExt.Import.DocClass", "DOC"); //Example of a document class. 

      // Document Description (optional) 
      context.Add("IManExt.Import.DocDescription", docName); //Using file path as example of a description. 

      // Skip UI 
      context.Add("IManExt.NewProfile.ProfileNoUI", true); 

      impCmd.Initialize(context); 
      impCmd.Update(); 

      if (impCmd.Status == (int)CommandStatus.nrActiveCommand) 
      { 
       impCmd.Execute(); 

       bool brefresh = (bool)context.Item("IManExt.Refresh"); 
       if (brefresh == true) 
       { 
        //Succeeded in importing a document to WorkSite 
        IManDocument doc = (IManDocument)context.Item("ImportedDocument"); 

        //Succeeded in filing the new folder under the folder. 
        Console.WriteLine("New document number, " + doc.Number + ", is successfully filed to " + fldr.Name + " folder."); 
       } 

      } 


     } 

    } 

+0

는 잘 모르겠지만, 아마도 당신이 코드를 가지고 곳으로 날 지점 수있는 기대했다? iManage/Worksite와의 상호 작용을 시도하고 있지만 일부 성가신 기업 정치의 문서화 된 원인에 대한 액세스 권한이 없습니다. – JamesMLV

답변

2

.

내 문제는 스레딩 문제로 인한 것 같습니다.

내가 만든 C# winform 응용 프로그램은 'ApartmentState'스레드 ([STAThread])에서 자동으로 실행되도록 설정되었습니다.

반면 콘솔 응용 프로그램 & 클래스 라이브러리 스레드 상태 및 관리가 프로젝트 내에서 정의되지 않았으며 기본 .NET 구성으로 처리되고있었습니다.

것은이 작업을 효율적으로 활용하려면 다음 콘솔 응용 프로그램에서, 난 그냥 내 주요 메소드 호출 위의 줄에 [STAThread] 태그를 추가했습니다. 클래스 라이브러리

, 난 IMANxxx.dll을 참조하는 기능에 대한 스레드를 정의 ApartmentState 예컨대 세트 이 문제를 해결 것 세트를 구현 한 ' ApartmentState'스레드를 보장하는 두 가지 경우 모두

Thread t = new Thread(new ThreadStart(PerformSearchAndMove)); 
t.SetApartmentState(ApartmentState.STA); 
t.Start(); 

. 더 이상이 문제를 모니터링 할 경우