1
我有一個關於Alfresco和dotCMIS庫的問題。基本上我想到一個特定的文件夾並創建一個文件。Alfresco以編程方式導航到正確的文件夾
這時我有以下代碼(我知道這是凌亂的,但它是用於測試):
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);
}
}
}
}
}
}
}
}
}
它只是打開一個根文件夾,這意味着我在「露天」的例如,然後我必須導航到另一個子文件夾,然後另一個,然後最後我得到: /Library,/ Groups,/ Newsgroups ...等 而在庫中,我可以打開「我的文件夾」,但有沒有更簡單的方法來打開/ Library/MyFolder,而不是真正通過所有層獲取正確的文件夾...?
我可以做類似的東西.. session.GetFolderByName("MyFolder")
我也不能依靠ID,例如在其他門戶網站,是隨機的文件夾中生成的ID可以是不同的,所以我不能說GetFolderById( ..);
那麼有什麼想法?