Docushare与windows商店应用程序的集成
本文关键字:应用程序 集成 windows Docushare | 更新日期: 2023-09-27 18:28:52
是否有将docushare与windows商店应用程序集成的方法?我想登录,获得一个文件/文件夹列表,并有可能下载和上传文件。
这里有一个简单的代码片段,可以很好地开始使用DocuShare。所有可能的请求都可以在文档中找到。
Collection-11对象的身份验证+获取属性
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;
}
您应该能够使用Docushare的HTML/XML API来实现这一点。有关Docushare API的详细信息,您可能需要注册Docushare开发者网络
一旦你知道Docushare的期望,你就可以通过HttpClient API从你的Windows应用商店应用程序连接到它。请参阅使用Windows.Web.HTTP.HttpClient(XAML)连接到HTTP服务器