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


C# Web.GetFileAsString方法代码示例

本文整理汇总了C#中Web.GetFileAsString方法的典型用法代码示例。如果您正苦于以下问题:C# Web.GetFileAsString方法的具体用法?C# Web.GetFileAsString怎么用?C# Web.GetFileAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Web的用法示例。


在下文中一共展示了Web.GetFileAsString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SafeGetFileAsString

 private static string SafeGetFileAsString(Web web, string serverRelativeFilePath)
 {
     try
     {
         return web.GetFileAsString(serverRelativeFilePath);
     }
     catch (Exception ex)
     {
         Logger.LogErrorMessage(String.Format("SafeGetFileAsString() failed for File [{0}] of Web [{1}]: Error={2}", serverRelativeFilePath, web.Url, ex.Message), false);
         return String.Empty;
     }
 }
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:12,代码来源:PeoplePickerRemediation.cs

示例2: ExtractObjects

        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                web.EnsureProperties(w => w.ServerRelativeUrl, w => w.Url, w => w.Id);

                var serverRelativeUrl = web.ServerRelativeUrl;

                // For each list in the site
                var lists = web.Lists;

                web.Context.Load(lists,
                    lc => lc.IncludeWithDefaultProperties(
                        l => l.ContentTypes.IncludeWithDefaultProperties(
                            ct => ct.Parent,
                            ct => ct.Parent.StringId,
                            ct => ct.FieldLinks
                            ),
                        l => l.Id,
                        l => l.ParentWebUrl,
                        l => l.Views,
                        l => l.DefaultNewFormUrl,
                        l => l.DefaultDisplayFormUrl,
                        l => l.DefaultEditFormUrl,
                        l => l.BaseTemplate,
                        l => l.OnQuickLaunch,
                        l => l.RootFolder.ServerRelativeUrl,
                        l => l.Fields.IncludeWithDefaultProperties(
                            f => f.Id,
                            f => f.Title,
                            f => f.Hidden,
                            f => f.InternalName,
                            f => f.Required),
                        l => l.HasUniqueRoleAssignments));

                web.Context.ExecuteQueryRetry();

                // Let's see if there are workflow subscriptions
                Microsoft.SharePoint.Client.WorkflowServices.WorkflowSubscription[] workflowSubscriptions = null;
                try
                {
                    workflowSubscriptions = web.GetWorkflowSubscriptions();
                }
                catch (ServerException)
                {
                    // If there is no workflow service present in the farm this method will throw an error.
                    // Swallow the exception
                }

                // Retrieve all not hidden lists and the Workflow History Lists, just in case there are active workflow subscriptions
                var includeWorkflowSubscriptions = workflowSubscriptions != null && workflowSubscriptions.Length > 0;
                var allowedLists = lists.AsEnumerable().Where(l => !l.Hidden || includeWorkflowSubscriptions && l.BaseTemplate == 140);

                //Performance improvements: retrieve site columns for extract list fields
                var siteColumns = web.AvailableFields;
                web.Context.Load(siteColumns, scs => scs.Include(sc => sc.Id));
                web.Context.ExecuteQueryRetry();

                foreach (var siteList in allowedLists)
                {
                    ListInstance baseTemplateList = null;
                    if (creationInfo.BaseTemplate != null)
                    {
                        // Check if we need to skip this list...if so let's do it before we gather all the other information for this list...improves performance
                        var index = creationInfo.BaseTemplate.Lists.FindIndex(f => f.Url.Equals(siteList.RootFolder.ServerRelativeUrl.Substring(serverRelativeUrl.Length + 1)) &&
                                                                                   f.TemplateType.Equals(siteList.BaseTemplate));
                        if (index != -1)
                        {
                            baseTemplateList = creationInfo.BaseTemplate.Lists[index];
                            if (siteList.Hidden && !(includeWorkflowSubscriptions && siteList.BaseTemplate == 140))
                            {
                                continue;
                            }
                        }
                    }

                    if (!creationInfo.ExecutePreProvisionEvent<ListInstance, List>(Handlers.Lists, template, null, siteList))
                    {
                        continue;
                    }

                    string documentTemplateContent = string.Empty;
                    if (!String.IsNullOrEmpty(siteList.DocumentTemplateUrl)) {
                        documentTemplateContent = web.GetFileAsString(siteList.DocumentTemplateUrl);
                    }

                    var contentTypeFields = new List<FieldRef>();
                    var list = new ListInstance
                    {
                        Description = siteList.Description,
                        EnableVersioning = siteList.EnableVersioning,
                        TemplateType = siteList.BaseTemplate,
                        Title = siteList.Title,
                        Hidden = siteList.Hidden,
                        EnableFolderCreation = siteList.EnableFolderCreation,
                        DocumentTemplate = TokenizeUrl(siteList.DocumentTemplateUrl, parser),
                        DocumentTemplateContent = documentTemplateContent,
                        ContentTypesEnabled = siteList.ContentTypesEnabled,
                        Url = siteList.RootFolder.ServerRelativeUrl.Substring(serverRelativeUrl.Length).TrimStart('/'),
                        TemplateFeatureID = siteList.TemplateFeatureId,
//.........这里部分代码省略.........
开发者ID:skybow,项目名称:PnP-Sites-Core,代码行数:101,代码来源:ObjectListInstance.cs


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