zoukankan      html  css  js  c++  java
  • SharePoint2010的Client Object Mode 之站点操作

    public static Web CreateSite(ClientContext clientCtx, string title, string url, string description)
    {
    try
    {
    WebCreationInformation webCreateInfo
    = new WebCreationInformation();
    webCreateInfo.Description
    = description;
    webCreateInfo.Language
    = 1033;
    webCreateInfo.Title
    = title;
    webCreateInfo.Url
    = url;
    webCreateInfo.UseSamePermissionsAsParentSite
    = true;
    webCreateInfo.WebTemplate
    = "STS#1";

    Web oNewWebsite
    = clientCtx.Web.Webs.Add(webCreateInfo);

    clientCtx.Load(oNewWebsite);

    clientCtx.ExecuteQuery();

    return oNewWebsite;
    }
    catch (ServerUnauthorizedAccessException suaex)
    {
    Console.WriteLine(suaex.Message);
    }
    catch (ServerException sex)
    {
    Console.WriteLine(sex.Message);
    }

    return null;
    }

    public static WebTemplate GetTemplate(ClientContext clientCtx, string title)
    {
    WebTemplateCollection templates
    = clientCtx.Web.GetAvailableWebTemplates(1033, true);

    IEnumerable
    <WebTemplate> filteredTemplates = clientCtx.LoadQuery(templates.Where(t => t.Title == title));

    clientCtx.ExecuteQuery();

    if (filteredTemplates != null && filteredTemplates.Count() > 0)
    return filteredTemplates.First();
    else
    return null;
    }

    注意:其中“STS#1”为空白站点模板,“STS#0”为团队站点模板

  • 相关阅读:
    Java/IO流
    Java实现IO通信(服务器篇)
    利用哈夫曼二叉树实现文件的压缩
    关于字符串构建,连接,查找
    线程小球
    准备造一个轮子,关于图片浏览器的
    IOS之循环引用
    ARC
    构造方法与快速创建对象
    autorelease
  • 原文地址:https://www.cnblogs.com/wengnet/p/1941111.html
Copyright © 2011-2022 走看看