请参阅以下代码,其中List<order>
元数据包含我的SharePoint列/字段的值。我必须验证SharePoint站点中指定的Field.validationformula。有人可以帮我详细说明如何进行验证。
public bool UploadDocumentwithMetadata(string fileName, string filePath, string docLibraryName, bool overwrite,
List<Order> metadata, string subfoldername)
{
bool uploadStatus = false;
string fileurl;
try
{
// Create the new file
if (subfoldername == "")
fileurl = fileName;
else
fileurl = Path.Combine(docLibraryName + "/" + subfoldername, fileName);
var newFile = new FileCreationInformation
{
Content = System.IO.File.ReadAllBytes(filePath),
Url = fileurl,
Overwrite = overwrite
};
Microsoft.SharePoint.Client.ListItem item = null;
var docs = _site.Lists.GetByTitle(docLibraryName);
if (docs != null)
{
StringBuilder SB = new StringBuilder();
Microsoft.SharePoint.Client.File uploadFile = docs.RootFolder.Files.Add(newFile);
uploadStatus = true;
item = uploadFile.ListItemAllFields;field.Value.ToString();
foreach (var order in metadata)
{
Field fld = null;
foreach (var eachfield in docs.Fields)
{
if (eachfield.InternalName == order._InternalName)
{
fld = eachfield;
break;
}
}
string validationformula = fld.ValidationFormula;
item[order._InternalName] = order._Range;
}
/////
****/
//if columns satisfies fld.ValidationFormula;
//then upload
//else exist
/***
/////
}
return uploadStatus;
}