本文整理汇总了C#中SPListItem.FormUrlDisplay方法的典型用法代码示例。如果您正苦于以下问题:C# SPListItem.FormUrlDisplay方法的具体用法?C# SPListItem.FormUrlDisplay怎么用?C# SPListItem.FormUrlDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPListItem
的用法示例。
在下文中一共展示了SPListItem.FormUrlDisplay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DuplicateValues
private object DuplicateValues(SPListItem item, DuplicatePluginConfig config)
{
if (item == null) throw new ArgumentNullException("item");
log.LogInfo("DUPLICATE on item " + item.FormUrlDisplay());
if (config.DuplicateFields == null) throw new Exception("Configuration has no values to duplicate");
//Teoreticky by nemelo nikdy nastat
if (!item.ParentList.ContainsFieldIntName(config.UsedFields))
{
throw new SPFieldNotFoundException(item.ParentList, config.UsedFields);
}
foreach (Dictionary<string, List<string>> dict in config.DuplicateFields)
{
SPField fromField = item.ParentList.OpenField(dict["FROM-FIELD"].First());
SPField toField = item.ParentList.OpenField(dict["TO-FIELD"].First());
Type fromType = fromField.GetType();
Type toType = toField.GetType();
bool toTypeIsText = ( toType == typeof (SPFieldText) || toType == typeof (SPFieldMultiLineText) );
object valueToStore = item[fromField.InternalName];
if (valueToStore != null)
{
valueToStore = item[fromField.InternalName].ToString();
//budou urcite zakazane typy do kterych nelze zapisovat
if (toType == typeof (SPFieldCalculated) || toType == typeof (SPFieldCalculated))
{
log.LogError("Cant copy value from field '" + fromField + "' to field '" + toField + "' of type " + toType);
continue;
}
if (fromType == typeof(SPFieldAttachments)) { }
if (fromType == typeof (SPFieldBoolean))
{
if (toType == typeof (SPFieldNumber)) valueToStore = valueToStore.ToBool() ? 1 : 0;
}
if (fromType == typeof(SPFieldAllDayEvent)) { }
if (fromType == typeof (SPFieldCalculated))
{
if (toTypeIsText)
{
valueToStore = ( (string) valueToStore ).GetLookupValues();
}
if (toType == typeof (SPFieldNumber))
{
valueToStore = ( (string) valueToStore ).GetLookupIndex();
}
}
if (fromType == typeof(SPFieldChoice)) { }
if (fromType == typeof(SPFieldComputed)) { }
if (fromType == typeof(SPFieldCrossProjectLink)) { }
if (fromType == typeof(SPFieldCurrency)) { }
if (fromType == typeof(SPFieldDateTime)) { }
if (fromType == typeof(SPFieldDecimal)) { }
if (fromType == typeof(SPFieldFile)) { }
if (fromType == typeof(SPFieldGeolocation)) { }
if (fromType == typeof(SPFieldIndex)) { }
if (fromType == typeof(SPFieldGuid)) { }
if (fromType == typeof(SPFieldLink)) { }
if (fromType == typeof (SPFieldLookup))
{
if (toTypeIsText)
{
valueToStore = ( (string) valueToStore ).GetLookupValues();
}
}
if (fromType == typeof (SPFieldMultiChoice))
{
if (toTypeIsText)
{
List<string> vals = ( valueToStore ?? "" ).ToString().Split(";#").Where(v => !string.IsNullOrEmpty(v)).ToList();
valueToStore = vals.JoinStrings("; ");
}
}
if (fromType == typeof(SPFieldMultiColumn)) { }
if (fromType == typeof(SPFieldMultiLineText)) { }
if (fromType == typeof(SPFieldNumber)) { }
if (fromType == typeof(SPFieldPageSeparator)) { }
if (fromType == typeof(SPFieldRecurrence)) { }
if (fromType == typeof(SPFieldText)) { }
if (fromType == typeof(SPFieldUrl)) { }
if (fromType == typeof (SPFieldUser))
{
if (toTypeIsText)
{
List<SPPrincipal> principals = item.Web.GetSPPrincipals(item[fromField.InternalName]);
valueToStore = principals.GetNames().JoinStrings(", ");
}
}
}
item[toField.InternalName] = valueToStore;
//.........这里部分代码省略.........
示例2: SetRightsForItem
private void SetRightsForItem(SPListItem item, List<RoleItem> roles, bool clear, bool expandUsers)
{
setRightsLog += item.FormUrlDisplay() + " | ClearRights:" + clear + " | ExpandUsers:" + expandUsers + "\n";
if (clear) item.RemoveRights();
foreach (RoleItem role in roles)
{
List<SPPrincipal> users = LoadUsers(item, role.For, expandUsers);
SPRoleDefinition spRole = item.Web.RoleDefinitions.Cast<SPRoleDefinition>().SingleOrDefault(r => r.Id == role.Role_Name);
if (spRole == null)
{
log.LogError("Could not find permisson level: '" + role + "'");
continue;
}
item.SetRights(users, spRole, false);
setRightsLog += spRole.Name + " : " + users.Select(l => l.LoginNameNormalized()).JoinStrings(", ") + "\n";
}
}