imanext importcmd 문제
문제
C#을 사용하여 작은 응용 프로그램을 작성하여 문서를 DMS 서버의 개인 '내 문서'폴더에 복사했습니다.
'WorkSite SDK 8 : IMANEXT2LIB.IMANREFILECMD를 활용하여 새 문서 폴더 블로그를 제출합니다.
Winform 응용 프로그램 에서이 코드를 사용하여 소스 폴더에서 파일을 사용자 dms '내 문서 폴더로 복사하는 데 아무런 문제가 없습니다.
그러나 사본 프로세스 중에 명령 줄 응용 프로그램/.dll 또는 기타 유형의 응용 프로그램 (winform 이외)에서 코드를 사용하는 경우 오류 메시지를받습니다.
1.
이벤트를 기록하려고 할 때 오류가 발생했습니다!
imanext : 이벤트를 기록하려고 할 때 오류가 발생했습니다!
접근이 불가합니다.
2.
문서는 데이터베이스로 가져 왔지만 폴더에 추가 할 수 없었습니다.
imanext : 문서는 데이터베이스로 가져 왔지만 폴더에 추가 할 수 없었습니다.
imanext.logruleeeventscmd.1 : 이벤트를 기록하려고 할 때 오류가 발생했습니다!
imanext.logruleeventscmd.1 : 액세스가 거부됩니다.
이벤트를 기록하려고 할 때 오류가 발생했습니다!
-%-
비 승인 신청서를 사용하여 문서를 복사 할 때 왜 'Access Denied'오류 메시지를받는 이유를 아는 사람이 있습니까? 이 문제를 해결하려면 어떻게해야합니까?
어떤 도움이든 놀랍습니다!
제자리에 코드 :
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.");
}
}
}
}
해결책
이것이 다른 사람을 돕는 경우를 대비하여.
내 문제는 스레딩 문제의 결과 인 것 같습니다.
내가 만든 C# winform 앱이 자동으로 단일에서 실행되도록 설정되어 있음을 알았습니다.ApartmentState
' 실 ([STAThread]
).
반면 콘솔 응용 프로그램 및 클래스 라이브러리 스레드 상태 및 관리는 프로젝트 내에서 정의되지 않았으며 기본 .NET 구성으로 처리되었습니다.
이 작업을 수행하려면 : 콘솔 응용 프로그램에서 방금 추가했습니다. [STAThread]
메인 메소드 호출 위의 줄에 태그가 있습니다.
클래스 라이브러리에서 나는 참조하는 함수의 스레드를 정의했다. IMANxxx.dll
ApartmentState를 설정합니다
Thread t = new Thread(new ThreadStart(PerformSearchAndMove));
t.SetApartmentState(ApartmentState.STA);
t.Start();
두 경우 모두 독신을 보장합니다.ApartmentState
'스레드가 구현되어 세트가 문제를 해결할 것입니다.