1

Is there anyway to integrate docushare with a windows store app? I would like to login, get a file/folder list and have the possibility of downloading and uploading files.

Thought
  • 5,326
  • 7
  • 33
  • 69

2 Answers2

1

Here is simple code snippet which can be good start to play with DocuShare. All possible request can be found in documentation.

Authentication + fetching properties for Collection-11 object

    protected const string UsernameFormFieldName = "username";
    protected const string PasswordFormFieldName = "password";
    protected const string DomainFormFieldName = "domain";

    const string CookieName = "AmberUser";
    const string baseAdress = "http://host:port";
    const string container = "/docushare";

    static Uri CookieUrl = new Uri(new Uri(baseAdress), container);

    const string root = "/xcm/v1/shadow/xcmAPI/root";
    const string FolderInfoUri = "/xcm/v1/shadow/object/{0}/xcmAPI/properties";
    const string ObjectVersion = "/xcm/v1/shadow/object/{0}/xcmAPI/version";

    const string ObjectToTest = "Collection-11";

    const string suffix = "?properties=title,mimetype";

    static void Main(string[] args)
    {
        var token = Authenticate();
        var requestUri = string.Format(container + FolderInfoUri, ObjectToTest) + suffix;
        var response = GetResult(token, requestUri);
        var content = response.Content.ReadAsStringAsync().Result;
    }

    private static string Authenticate()
    {
        const string AuthenticationPath = container + "/dsweb/ApplyLogin";


        var form = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair<string, string>(UsernameFormFieldName, "login"),
            new KeyValuePair<string, string>(PasswordFormFieldName, "password"),
            new KeyValuePair<string, string>(DomainFormFieldName, "domain"),
        });

        string authToken = null;

        Execute((client, handler) =>
        {
            var task = client.PostAsync(AuthenticationPath, form, CancellationToken.None);
            var response = task.Result;
            var content = response.Content.ReadAsStringAsync().Result;
            var cookie = handler.CookieContainer.GetCookies(CookieUrl);
            authToken = cookie[CookieName].Value;
        });

        return authToken;
    }

    private static void Execute(Action<HttpClient, HttpClientHandler> request)
    {
        using (var handler = new HttpClientHandler())
        using (var client = new HttpClient(handler))
        {
            handler.UseCookies = true;
            handler.CookieContainer = new CookieContainer();
            client.BaseAddress = new Uri(baseAdress);

            request(client, handler);
        }
    }

    private static HttpResponseMessage GetResult(string token, string uri)
    {
        HttpResponseMessage response = null;

        Execute((client, handler) =>
        {
            handler.CookieContainer.Add(
                CookieUrl,
                new Cookie(CookieName, token));

            var responseTask = client.GetAsync(uri);
            response = responseTask.Result;
        });

        return response;
    }
lerthe61
  • 370
  • 1
  • 16
  • You mentioned "All possible request can be found in documentation" , where is this documentation? – Jaskier Nov 07 '18 at 17:53
  • 1
    @Symon you would need to have DSDN Subscription to get access to DocuShare API documentation. I do not have access anymore, so I would not be able to give a direct link or hint. – lerthe61 Nov 08 '18 at 14:01
  • Aye! That's enough of a hint for me! Thank you! – Jaskier Nov 08 '18 at 14:04
0

You should be able to do so with Docushare's HTML/XML API. For details on the Docushare API it looks like you'll need to register for the DocuShare Developer Network

Once you know what Docushare expects you should be able to connect to it from your Windows Store app with the HttpClient API. See Connecting to an HTTP server using Windows.Web.Http.HttpClient (XAML)

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • i registered and tried to read the documentation on html/xml api, but dindt quite get it :\ any chance you could show a example of a login or a list folders/files ? – Thought Nov 04 '14 at 15:16