10-06-2016 02:21 AM
I am using DotCmis for Integration of Alfresco with my asp.net mvc project and i am facing trouble to show listing child folder and document of parent folder and download file from any
kindly suggest how this kindly refer the below which i am trying to do ..
--Listing Child folder and document from parent folder --
IItemEnumerable<IQueryResult> qr = session.Query("SELECT * FROM cmis:folder WHERE cmis:createdBy LIKE '%" + UserName + "' ", false);// where cmis:createdBy='admin'
List<string> DirectoryNames = new List<string>();
List<string> ListofObjectIDs = new List<string>();
foreach (IQueryResult hit in qr)
{
DirectoryNames.Add(" " + hit["cmis:name"].FirstValue + " ");// +"(" + hit["cmis:createdBy"].FirstValue + ")"
ListofObjectIDs.Add("" + hit["cmisbjectId"].FirstValue + "");
}
ViewBag.DirectoryNames = DirectoryNames;
ViewBag.ListofObj = ListofObjectIDs;
---Download File from Alfresco--
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/content?id=57680df3-fe39-...";
parameters[DotCMIS.SessionParameter.User] = "admin";
parameters[DotCMIS.SessionParameter.Password] = "sept";
SessionFactory factory = SessionFactory.NewInstance();
ISession session = factory.GetRepositories(parameters)[0].CreateSession();
string FetchDocId = objectId;
IObjectId id = session.CreateObjectId(FetchDocId);
IDocument doc = session.GetObject(Session["value"].ToString()) as IDocument;
// properties
Console.WriteLine(doc.Paths);
string url = "http://127.0.0.1:8080" + doc.Paths[0];
WebClient webClient = new WebClient();
//webClient.DownloadFile(url, FetchDocName);
Console.WriteLine(doc.GetPropertyValue("myroperty"));
IProperty myProperty = doc["myroperty"];
// content
IContentStream contentStream = doc.GetContentStream();
Console.WriteLine("Filename: " + contentStream.FileName);
Console.WriteLine("MIME type: " + contentStream.MimeType);
Console.WriteLine("Has stream: " + (contentStream.Stream != null));
kindly suggest how i can perfom these two action in my c#.net application.
10-06-2016 03:41 AM
What exact version/build of Alfresco are you running ?
Can you please provide more details with regards to "I am facing trouble" ? What errors do you see ?
Have you also tried connecting via the OpenCMIS Workbench ?
Also, in the future, I would recommend that you post CMIS-related questions under the "Alfresco ECM" place (and also mark it with "Public API" category), thanks.
Regards,
Jan
ps. I see your are also cross-posting similar (related ?) questions here: Store_Type Field how to take from query?
10-06-2016 03:48 AM
Thank you Jane ,
I will post CMIS Related questions under the alfresco ECM.
and i am facing trouble means i fount 500 internal error after providing the url with object id parameter also i had mentioned code for review.
Regards,
Shiv Swamy
10-06-2016 04:11 AM
Thanks. If you see a 500 error then please also include the related stacktrace from the console / log.
Regards,
Jan
10-10-2016 10:09 AM
If you just want to get the children of a folder.
You can use following methods of IFolder
IItemEnumerable<ICmisObject> GetChildren();
IItemEnumerable<ICmisObject> GetChildren(IOperationContext context);
To download file from Alfresco,first get the document ,the use it's GetContentStream() method,like this
IObjectId id = session.CreateObjectId("5555555555");
IDocument doc = session.GetObject(id);
IContentStream contentStream = doc.GetContentStream();
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.