webdav portal owa edit fixes

This commit is contained in:
vfedosevich 2015-02-02 03:41:44 -08:00
parent aedc7ec08e
commit 9edf1f8d93
13 changed files with 133 additions and 21 deletions

View file

@ -337,6 +337,69 @@ namespace WebsitePanel.WebDav.Core
}
}
/// <summary>
/// Lock this item.
/// </summary>
public string Lock()
{
var credentials = (NetworkCredential)_credentials;
string lockToken = string.Empty;
string lockXml =string.Format( "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<D:lockinfo xmlns:D='DAV:'>" +
"<D:lockscope><D:exclusive/></D:lockscope>" +
"<D:locktype><D:write/></D:locktype>" +
"<D:owner>{0}</D:owner>" +
"</D:lockinfo>", WspContext.User.Login);
string auth = "Basic " +
Convert.ToBase64String(
Encoding.Default.GetBytes(credentials.UserName + ":" + credentials.Password));
WebRequest webRequest = WebRequest.Create(Href);
webRequest.Method = "LOCK";
webRequest.Credentials = credentials;
webRequest.Headers.Add("Authorization", auth);
webRequest.PreAuthenticate = true;
webRequest.ContentType = "application/xml";
// Retrieve the request stream.
using (Stream requestStream = webRequest.GetRequestStream())
{
// Write the lock XML to the destination.
requestStream.Write(Encoding.UTF8.GetBytes(lockXml), 0, lockXml.Length);
}
using (WebResponse webResponse = webRequest.GetResponse())
{
lockToken = webResponse.Headers["Lock-Token"];
}
return lockToken;
}
/// <summary>
/// Lock this item.
/// </summary>
public void UnLock()
{
WebRequest webRequest = WebRequest.Create(Href);
webRequest.Method = "UNLOCK";
webRequest.Credentials = _credentials;
webRequest.PreAuthenticate = true;
webRequest.Headers.Add(@"Lock-Token", Properties.First(x => x.Name.Name == "locktoken").StringValue);
using (WebResponse webResponse = webRequest.GetResponse())
{
//TODO unlock
}
}
public bool AllowWriteStreamBuffering { get; set; }
public bool SendChunked { get; set; }