我对 Alfresco 和 dotCMIS 库有疑问。基本上我想进入一个特定的文件夹并在那里创建一个文档。
此时我有以下代码(我知道它很乱,但它是用于测试):
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters[SessionParameter.BindingType] = BindingType.AtomPub;
parameters[SessionParameter.AtomPubUrl] = "http://webadress:2005/alfresco/service/cmis";
parameters[SessionParameter.User] = "amdin";
parameters[SessionParameter.Password] = "admpsw";
SessionFactory factory = SessionFactory.NewInstance();
IList<DotCMIS.Client.IRepository> repositories = factory.GetRepositories(parameters);
DotCMIS.Client.ISession session = repositories[0].CreateSession();
foreach (ICmisObject cmisObject in rootFolder.GetChildren())
{
Console.WriteLine(cmisObject.Name);
if (cmisObject.Name.Equals("AlfresCO"))
{
var type = cmisObject.GetType();
IFolder circabcfolder = cmisObject as IFolder;
foreach (ICmisObject obj in circabcfolder.GetChildren())
{
Console.WriteLine(obj.Name);
if (obj.Name.Equals("SubFolder1"))
{
IFolder circabcfolder2 = obj as IFolder;
foreach (ICmisObject obj2 in circabcfolder2.GetChildren())
{
Console.WriteLine(obj2.Name);
foreach (ICmisObject obj3 in (obj2 as IFolder).GetChildren())
{
Console.WriteLine(obj3.Name);
if (obj3.Name.Equals("Library"))
{
foreach (ICmisObject obj4 in (obj3 as IFolder).GetChildren())
{
Console.WriteLine(obj4.Name);
if (obj4.Name.Equals("MyFolder"))
{
IDictionary<string, object> properties2 = new Dictionary<string, object>();
properties2[PropertyIds.ObjectTypeId]= "cmis:folder";
properties2[PropertyIds.Name] = "Test Folder";
IFolder newFolder = (obj4 as IFolder).CreateFolder(properties2);
}
}
}
}
}
}
}
}
}
它只是打开一个根文件夹,例如,这意味着我在“alfresco”中,然后我必须导航到另一个子文件夹,然后是另一个子文件夹,最后我到达:/Library、/Groups、/Newsgroups .. . 等等。在库中我可以打开“我的文件夹”,但是有没有更简单的方法来打开 /Library/MyFolder 而不是真正遍历所有层以获得正确的文件夹......?
我可以做类似的事情吗..session.GetFolderByName("MyFolder")
我也不能依赖 ID,例如在其他门户中,为文件夹随机生成的 ID 可能不同,所以我不能说 GetFolderById(..);
那么有什么想法吗?