当前位置: 首页>>代码示例>>C#>>正文


C# File.RefreshLoad方法代码示例

本文整理汇总了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();
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:97,代码来源:ModuleFileModelHandler.cs

示例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();
            }
//.........这里部分代码省略.........
开发者ID:Whoopsss,项目名称:spmeta2,代码行数:101,代码来源:ModuleFileModelHandler.cs

示例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
//.........这里部分代码省略.........
开发者ID:avishnyakov,项目名称:spmeta2,代码行数:101,代码来源:ModuleFileModelHandler.cs


注:本文中的File.RefreshLoad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。