zoukankan      html  css  js  c++  java
  • 给InfoPath添加VSTA托管代码并从SharePoint列表查询数据

    在Loading事件中参加如下的代码:
          if (this.New) //假如是新的表单,就配置原始值 
          { 
            //取得当前用户在配置文件中FullName的值 
            using (SPSite site = new SPSite("http://oss")) //请把这个值换成你的SharePoint站点的URL 
            { 
              //以下根据当前用户登录名来取得用户的配置文件 
              ServerContext context = ServerContext.GetContext(site); 
              UserProfileManager profileManager = new UserProfileManager(context);       
              UserProfile u = profileManager.GetUserProfile(this.Application.User.LoginName); 
              string fullName = u[PropertyConstants.PreferredName].Value.ToString(); 
     
              windows xp athNavigator mainNavigator = this.MainDataSource.CreateNavigator();  //取得主数据源的检索游标 
     
              //配置申请人的节点值为用户名,即配置文件中PreferredName(名称)的属性          
              mainNavigator.SelectSingleNode("/my:myFields/my:申请人", this.NamespaceManager).SetValue(fullName);  
              
              //根据姓名从SharePoint的部门列表来查询部门 
              using (SPWeb web = site.AllWebs["/demo"]) //请把这个换成你的SharePoint站点的URL 
              { 
                SPQuery query = new SPQuery(); 
                //因为姓名字段,是从标题修改而来的,所以其内部名称为Title 
                query.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + fullName + "</Value></Eq></Where>"; 
                SPList list = web.Lists["部门人员"]; 
                SPListItemCollection items = list.GetItems(query); 
                if (items.Count > 0) //假如查找到了就配置部门的值 
                  mainNavigator.SelectSingleNode("/my:myFields/my:申请部门", this.NamespaceManager).SetValue(items[0]["部门"].ToString ());  
     
              } 
     
            } 
          } 
        }
  • 相关阅读:
    Android数据存储之File
    Openfiler使用说明
    nginx的upstream目前支持5种方式的分配
    centOS 6.5关闭防火墙步骤
    yum下载文件的存放位置
    ubuntu如何开启root,如何启用Ubuntu中root帐号
    ubuntu下的apt-get内网本地源的搭建
    [转]StarWind模拟iSCSI设备
    ORACLE删除某用户下所有对象
    [转]oracle导入提示“IMP-00010:不是有效的导出文件,头部验证失败”的解决方案
  • 原文地址:https://www.cnblogs.com/IsNull/p/1800925.html
Copyright © 2011-2022 走看看