zoukankan      html  css  js  c++  java
  • SharePoint 2010中开发模式的改进 COM 客户端对象模型

    摘要: SharePoint Foundation 2010 中支持客户端对象模型,通过ClientObjectModel,可以很容易的访问服务器上的SharePoint数据,这样SharePoint 2010的开发就可以在32位机器进行了,我们还可以通过Client Object Model开发 ...
    SharePoint Foundation 2010 中支持客户端对象模型,通过ClientObjectModel,可以很容易的访问服务器上的SharePoint数据,这样SharePoint 2010的开发就可以在32位机器进行了,我们还可以通过Client Object Model开发SharePoint的客户端,实现旁客户端,下面是Client Object Model和Server Object Model 的对照图:
    Client-side classes and server-side equivalents
    Client Server
    ClientContext
    SPContext
    Site
    SPSite
    Web
    SPWeb
    List
    SPList
    ListItem
    SPListItem
    Field
    SPField

    SPWeb oWebsite = SPContext.Current.Web;

    using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
    {
        ...
    }
     

    using(SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
    {
        ...
    }

    using(SPSite oSiteCollection = new SPSite("http://Server_Name"))
    {
        using(SPWeb oWebsite = oSiteCollection.OpenWeb("Website_URL"))
        {
            using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
            {
               ...
            }
        }
    }

    SPList oListCur = SPContext.Current.List;
    SPWeb oWeb = SPContext.Current.Web;
    SPSite oSite = SPContext.Current.Site;
    SPWebApplication oWebApplicationCur = SPContext.Current.Site.WebApplication;

    using(SPWeb oWeb = SPContext.Current.Site.OpenWeb(guidWebsite))
    {
        SPUser oUser = SPContext.Current.Web.CurrentUser;
    }

    SPSiteDataQuery oSiteQuery = new SPSiteDataQuery();
    oSiteQuery.Query = "<Where><Gt><FieldRef Name=\"ID\" />" +
        "<Value Type = \"Number\">100</Value></Gt></Where>";
    oSiteQuery.ViewFields = "<FieldRef Name=\"Title\"/>";
    DataTable oQueryResults = SPContext.Current.Web.GetSiteData(oSiteQuery);
    oQueryResults.TableName = "queryTable";
    oQueryResults.WriteXml("C:\\queryTable.xml");

    SPListItem item = (SPListItem)SPContext.Current.Item;

    using (SPSite site = new SPSite("http://localhost"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        SPList list = web.Lists.TryGetList("Announcements");
                        if (list != null)
                        {
                            SPField fld = list.Fields[SPBuiltInFieldId.Expires];
                            fld.DefaultFormula = "=TODAY()+7";
                            fld.Update();
                        }
                    }
                }
                Console.Write("\nPress ENTER to continue....");
                Console.Read();

    A User field contains a string in the form ID;#User_Display_Name, where ID is the member identifier (ID) of the associated user. The following example parses the value of an Assigned To field to return an SPUser object.

    string strUserValue = oList["Assigned To"];
    int intIndex = strUserValue.IndexOf(';');
    int intID = Int32.Parse(strUserValue.Substring(0, intIndex));
    SPUser oUser = oWebsite.SiteUsers.GetByID(intID);

  • 相关阅读:
    Fragment使用具体解释
    2014百度之星第一题Energy Conversion
    HDU 2602 Bone Collector 0/1背包
    Angular 2 + 折腾记 :(7) 初步了解表单:模板驱动及数据驱动及脱坑要点
    《开源框架那点事儿25》:对框架模板引擎实现方式的改造实录
    ROS机器人程序设计(原书第2版)补充资料 (柒) 第七章 3D建模与仿真 urdf Gazebo V-Rep Webots Morse
    sql改写or 改成union不等价数据变多
    在GDAL中添加GDALRasterizeGeometriesBuf函数
    多时相地图瓦片简单设想
    记录一次使用VS2015编译错误的原因查找(boost+gdal)
  • 原文地址:https://www.cnblogs.com/IsNull/p/1892751.html
Copyright © 2011-2022 走看看