Page 1 of 1

How to just download a document from the OKM Repo

PostPosted:Tue Feb 08, 2011 5:36 am
by rocabu
Hi people, I have a question to make.

I am trying to complete the whole process for documents on the OKM Repository (create, check-out and check-in) from another application I have running on a server (Microsoft CRM)

I have completed the creation process, and thought I finished the checkout + document update + checkin cycle back again on the okm repository. But when I published the code on the server I realized that the download process was not going to work because obviously the server is unable to create content on the client side.

Honestly I have no idea about how to download content directly from the OKM and into the client, is there any example that might help? Here is the code I have for the checkout-checkin process. I know the checkin process will work when solving this issue, but in the meantime I am hands-tied. I know I have to use some other actions like documentService.setContent and documentService.checkin
Code: Select all
        private void checkoutDocumentFromOpenKm(String username, String password)
        {
            try
            {
                // OpenKM authentication
                token = authService.login(username, password);

                //Gets the content from the file and builds a new one locally, then does the checkout so nobody can edit it.
                //documentService.cancelCheckout(token, "/okm:root/Proposals System/Base Components/test.txt");
                byte[] localFile = documentService.getContent(token, okmPath, false);
                writeByteArrayToFile(localFile, Constants.LOCAL_FILE_LOCALIZATION + okmFileName + okmFileExtension);
                documentService.checkout(token, okmPath);

                // Logout OpenKM
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.SUCCESS_MESSAGE_DOWNLOAD + okmFileName + okmFileExtension;
            }
            catch (Exception ex)
            {
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.ERROR_MESSAGE_DOWNLOAD + ex.ToString();
            }

        }

//Checkin

        private void checkinDocumentToOpenKm(String username, String password)
        {
            try
            {
                //string localFilePath = Server.MapPath(Constants.LOCAL_TEMPORAL_FOLDER) + FileUpload.FileName;
                //string localFilePath = FileUpload1.Attributes["Value"];
                FileUpload1.PostedFile.SaveAs(Constants.LOCAL_TEMPORAL_FOLDER);

                // OpenKM authentication
                token = authService.login(username, password);

                // Upload a document to OKM
                byte[] localFile = readFile(Constants.LOCAL_TEMPORAL_FOLDER);
                documentService.setContent(token, okmPath, localFile);
                documentService.checkin(token, okmPath, "");

                // Logout OpenKM
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.SUCCESS_MESSAGE_UPLOAD;

                // Deleting the temp file
                //File.Delete(Constants.LOCAL_TEMPORAL_FOLDER);
            }
            catch (Exception ex)
            {
                logOutOpenKm(token);
                lblUploadStatus.Text = Constants.ERROR_MESSAGE_UPLOAD + ex.ToString();
            }
        }
Thanks a lot for your help.

Re: How to just download a document from the OKM Repo

PostPosted:Tue Feb 08, 2011 6:24 am
by rocabu
Oh! Yes, I forgot to say that I already checked on the OpenWordAddIn code but could'nt find anything useful (at least something I recognize I can use). I am not an expert with this... as you can see.....

Thanks!

Re: How to just download a document from the OKM Repo

PostPosted:Tue Feb 08, 2011 9:38 am
by jllort
You've not investigated too much the source code and you've not downloaded the package librares MSOpenKMCore for all ms office addins

Take a look here : http://openkm.svn.sourceforge.net/viewv ... ore/logic/

Re: How to just download a document from the OKM Repo

PostPosted:Mon Feb 14, 2011 4:02 pm
by pavila
The posted checkout example should works, what it the problem?

Re: How to just download a document from the OKM Repo

PostPosted:Thu Feb 17, 2011 6:43 pm
by rocabu
It worked, I just need to add some code for the file process. Nothing different.

Thanks a lot!!!!