Checkin/Checkout documents, Sharepoint, Web services
时间:2010-11-04 来源:小师傅
public static void CheckInAllMyCheckedOutDocuments()
{
string query = "<mylistitemrequest><Query><Where><Eq><FieldRef Name=\"CheckoutUser\" /><Value Type=\"User\">basesmcdev2\\steve.curran</Value></Eq></Where><OrderBy><FieldRef Name=\"Title\"/></OrderBy></Query><ViewFields><FieldRef Name=\"Title\"/></ViewFields><QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions></mylistitemrequest>";
XmlDocument doc = new XmlDocument();
doc.LoadXml(query);
listservice.Lists listProxy = new listservice.Lists();
listProxy.Url = "http://basesmcdev2/sites/tester1/_vti_bin/lists.asmx";
listProxy.UseDefaultCredentials = true;
XmlNode queryNode = doc.SelectSingleNode("//Query");
XmlNode viewNode = doc.SelectSingleNode("//ViewFields");
XmlNode optionNode = doc.SelectSingleNode("//QueryOptions");
try
{
XmlNode retNode = listProxy.GetListItems("tester2", null, queryNode, viewNode, string.Empty, optionNode, null);
XElement e = XElement.Parse(retNode.InnerXml);
var uniqueValues = (from t in e.Descendants().Attributes("ows_FileRef") select t.Value.ToString()).Distinct();
foreach (string fileRef in uniqueValues)
{
UpdateListItemCheckIn("http://basesmcdev2/" + fileRef.Substring(fileRef.IndexOf("#")+1));
}
}
catch (Exception ex)
{
string msg = ex.Message;
}
}
public static void UpdateListItemCheckIn(string fileRef)
{
listservice.Lists listProxy = new listservice.Lists();
listProxy.Url = "http://basesmcdev2/sites/tester1/_vti_bin/lists.asmx";
listProxy.UseDefaultCredentials = true;
bool success = listProxy.CheckInFile(fileRef, string.Empty, "0");
}
相关阅读 更多 +










