- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在使用 C# 编写一个小应用程序,将文档复制到我们 DMS 服务器上的个人“我的文档”文件夹中。
我已经围绕“WorkSite SDK 8: Utilize the IMANEXT2Lib.IManRefileCmd to File New Document Folders”博客中提供的列表编写了代码。
在 WinForm 应用程序中使用此代码,将文件从源文件夹复制到用户 DMS 的“我的文档”文件夹中没有问题。
但是,如果我在复制过程中在命令行应用程序/.dll 或任何其他类型的应用程序(WinForm 除外)中使用代码,则会收到错误消息;
1.
Error occurred when try to log the event!
IManExt: Error occurred when try to log the event!
Access is denied.
The document was imported to the database, but could not be added to the folder.
IManExt: The document was imported to the database, but could not be added to the folder.
IManExt.LogRuleEventsCmd.1: Error occurred when try to log the event!
IManExt.LogRuleEventsCmd.1: Access is 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]
标记在我的 Main 方法调用上方的行上。
在类库中,我为引用 IMANxxx.dll
的函数定义了一个线程。并设置 ApartmentState 例如
Thread t = new Thread(new ThreadStart(PerformSearchAndMove));
t.SetApartmentState(ApartmentState.STA);
t.Start();
ApartmentState
'线程已实现 set 将解决该问题。
关于c# - IManExt ImportCmd 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1923022/
我一直在使用 C# 编写一个小应用程序,将文档复制到我们 DMS 服务器上的个人“我的文档”文件夹中。 我已经围绕“WorkSite SDK 8: Utilize the IMANEXT2Lib.IM
我是一名优秀的程序员,十分优秀!