本文整理汇总了C#中File.RefreshLoad方法的典型用法代码示例。如果您正苦于以下问题:C# File.RefreshLoad方法的具体用法?C# File.RefreshLoad怎么用?C# File.RefreshLoad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File.RefreshLoad方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithSafeFileOperation
public static void WithSafeFileOperation(List list, File file, Func<File, File> action, Action<File> onCreated)
{
var context = list.Context;
context.Load(list, l => l.EnableMinorVersions);
context.Load(list, l => l.EnableModeration);
context.Load(list, l => l.BaseType);
context.ExecuteQueryWithTrace();
if (file != null)
{
context.Load(file, f => f.Exists);
context.ExecuteQueryWithTrace();
if (file.Exists)
{
context.Load(file, f => f.CheckOutType);
context.Load(file, f => f.CheckedOutByUser);
context.Load(file, f => f.Level);
context.ExecuteQueryWithTrace();
}
}
var shouldRefreshLoad = false;
// are we inside ocument libary, so that check in stuff is needed?
var isDocumentLibrary = list != null && list.BaseType == BaseType.DocumentLibrary;
if (isDocumentLibrary)
{
if (list != null && file != null && (file.Exists && file.CheckOutType != CheckOutType.None))
{
file.UndoCheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (list.EnableMinorVersions) &&
(file.Exists && file.Level == FileLevel.Published))
{
file.UnPublish("Provision");
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (file.Exists && file.CheckOutType == CheckOutType.None))
{
file.CheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
}
var spFile = action(file);
context.ExecuteQueryWithTrace();
context.Load(spFile, f => f.Exists);
context.ExecuteQueryWithTrace();
if (spFile.Exists)
{
if (isDocumentLibrary)
{
spFile.ListItemAllFields.Update();
}
context.ExecuteQueryWithTrace();
if (onCreated != null)
onCreated(spFile);
context.Load(spFile, f => f.CheckOutType);
context.Load(spFile, f => f.Level);
context.ExecuteQueryWithTrace();
}
if (isDocumentLibrary)
{
if (list != null && spFile != null && (spFile.Exists && spFile.CheckOutType != CheckOutType.None))
spFile.CheckIn("Provision", CheckinType.MajorCheckIn);
if (list != null && spFile != null && (list.EnableMinorVersions))
spFile.Publish("Provision");
if (list != null && spFile != null && (list.EnableModeration))
spFile.Approve("Provision");
}
context.ExecuteQueryWithTrace();
}
示例2: WithSafeFileOperation
public static void WithSafeFileOperation(List list, File file,
Func<File, File> action, Action<File> onCreated,
bool doesFileHasListItem)
{
var context = list.Context;
context.Load(list, l => l.EnableMinorVersions);
context.Load(list, l => l.EnableModeration);
context.Load(list, l => l.BaseType);
context.ExecuteQueryWithTrace();
if (file != null)
{
context.Load(file, f => f.Exists);
context.ExecuteQueryWithTrace();
if (file.Exists)
{
context.Load(file);
context.Load(file, f => f.CheckOutType);
context.Load(file, f => f.CheckedOutByUser);
context.Load(file, f => f.Level);
context.ExecuteQueryWithTrace();
}
}
var shouldRefreshLoad = false;
// are we inside ocument libary, so that check in stuff is needed?
var isDocumentLibrary = list != null && list.BaseType == BaseType.DocumentLibrary;
if (isDocumentLibrary && doesFileHasListItem)
{
if (list != null && file != null && (file.Exists && file.CheckOutType != CheckOutType.None))
{
file.UndoCheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (list.EnableMinorVersions) &&
(file.Exists && file.Level == FileLevel.Published))
{
file.UnPublish("Provision");
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (file.Exists && file.CheckOutType == CheckOutType.None))
{
file.CheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
}
var spFile = action(file);
context.ExecuteQueryWithTrace();
context.Load(spFile);
context.Load(spFile, f => f.Exists);
context.ExecuteQueryWithTrace();
if (spFile.Exists)
{
// super hack with doesFileHasListItem
// once filed under Forms folder
// CanDeploy_WebpartTo_ListForm_InLibrary / CanDeploy_WebpartTo_ListForm_InLibrary
if (isDocumentLibrary && doesFileHasListItem)
{
if (spFile.ListItemAllFields != null)
{
// weird issues while deployin in a row for wiki
if (list.BaseTemplate != 119)
{
spFile.ListItemAllFields.Update();
}
}
}
context.ExecuteQueryWithTrace();
if (onCreated != null)
onCreated(spFile);
context.Load(spFile);
context.Load(spFile, f => f.CheckOutType);
context.Load(spFile, f => f.Level);
context.ExecuteQueryWithTrace();
}
//.........这里部分代码省略.........
示例3: WithSafeFileOperation
public static void WithSafeFileOperation(List list, File file,
Func<File, File> action, Action<File> onCreated,
bool doesFileHasListItem)
{
var context = list.Context;
context.Load(list, l => l.EnableMinorVersions);
context.Load(list, l => l.EnableModeration);
context.Load(list, l => l.BaseType);
context.ExecuteQueryWithTrace();
if (file != null)
{
context.Load(file, f => f.Exists);
context.ExecuteQueryWithTrace();
if (file.Exists)
{
context.Load(file);
context.Load(file, f => f.CheckOutType);
context.Load(file, f => f.CheckedOutByUser);
context.Load(file, f => f.Level);
context.ExecuteQueryWithTrace();
}
}
// are we inside ocument libary, so that check in stuff is needed?
var isDocumentLibrary = list != null && list.BaseType == BaseType.DocumentLibrary;
if (isDocumentLibrary && doesFileHasListItem)
{
if (list != null && file != null && (file.Exists && file.CheckOutType != CheckOutType.None))
{
file.UndoCheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (list.EnableMinorVersions) &&
(file.Exists && file.Level == FileLevel.Published))
{
file.UnPublish("Provision");
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
if (list != null && file != null && (file.Exists && file.CheckOutType == CheckOutType.None))
{
file.CheckOut();
file.RefreshLoad();
context.ExecuteQueryWithTrace();
}
}
var spFile = action(file);
context.ExecuteQueryWithTrace();
context.Load(spFile);
context.Load(spFile, f => f.Exists);
context.ExecuteQueryWithTrace();
if (spFile.Exists)
{
// super hack with doesFileHasListItem
// once filed under Forms folder
// CanDeploy_WebpartTo_ListForm_InLibrary / CanDeploy_WebpartTo_ListForm_InLibrary
if (isDocumentLibrary && doesFileHasListItem)
{
if (spFile.ListItemAllFields != null)
{
// weird issues while deployin in a row for wiki
if (list.BaseTemplate != 119)
{
spFile.ListItemAllFields.Update();
}
}
}
context.ExecuteQueryWithTrace();
if (onCreated != null)
onCreated(spFile);
context.Load(spFile);
context.Load(spFile, f => f.CheckOutType);
context.Load(spFile, f => f.Level);
context.ExecuteQueryWithTrace();
}
// super hack with doesFileHasListItem
//.........这里部分代码省略.........