AnsweredAssumed Answered

Using Dotcmis How to download file and show child content of parent folder

Question asked by shivtechno on Oct 6, 2016
Latest reply on Oct 10, 2016 by kaynezhang

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["cmis:objectId"].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-4f9a-96be-bf2ee621c3e6";

                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("my:property"));

 

                IProperty myProperty = doc["my:property"];

                // 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.

Outcomes