MOSS自定义Application Page

本文介绍如何在Microsoft Office SharePoint Server (MOSS)中创建自定义ApplicationPage,包括添加菜单项和使用SPTreeView控件展示站点结构的方法。

在MOSS中后台管理的页面都是Application Page,比如网站设置的页面(settings.aspx)就是典型的Application Page,它不能被Sharepoint Desiger定制。如果我们要修改只能手动的使用其他工具来修改,我们也可以添加Application Page,必须放在C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS目录下,它对应的虚拟路径为_layouts。所有的Application Page都使用application.master这个母版页,我们自定义的Application Page也是一样,可以使用内嵌代码也可以使用后置代码。自定义的application page继承自LayoutsPageBase类,下面我们就来做两个自定义的Application Page,下面是项目的结构:

1

Feature.xml中代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="86689158-7048-4421-AD21-E0DEF0D67C81"
   Title="自定义ApplicationPage"
   Description="使用SPTreeViw演示自定义ApplicationPage"
   Version="1.0.0.0"
   Scope="Web"
   Hidden="FALSE"        
   ImageUrl="TPG\PithHelmet.gif"        
   xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml" />
</ElementManifests>
</Feature>

ApplicationPage1.aspx和ApplicationPage2.aspx就是我们自定义的Application Page,ApplicationPage1.aspx演示的是在一个列表库的列表项的编辑菜单里出现一个链接,统计该列表的信息,如下图:

2

要添加此菜单须在Elements.xml中填加如下代码:

<!--  出现在控件的编辑项中 -->
< CustomAction  Id ="CustomApplicationPage1"
RegistrationType
="List"
RegistrationId
="101"
ImageUrl
="/_layouts/images/GORTL.GIF"
Location
="EditControlBlock"
Sequence
="240"
Title
="此文档库信息"   >
< UrlAction  Url ="~site/_layouts/CustomApplicationPages/ApplicationPage1.aspx?ItemId={ItemId}&amp;ListId={ListId}" />
</ CustomAction >


RegistrationType="List":代表注册的类型是列表.
Location="EditControlBlock":代表菜单将出现在控件编辑项当中.
UrlAction 是它的链接,URL中的ItemId 和ListId是通过 QueryString得到的。


ApplicationPage1.cs中代码如下:

using  System;
using  System.Web;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  Microsoft.SharePoint;
using  Microsoft.SharePoint.WebControls;

namespace  CustomApplicationPages 
{
  
public   class  ApplicationPage1 : LayoutsPageBase 
 {
    
protected  Label lblSiteTitle;
    
protected  Label lblSiteID;
    
protected  Label lblSiteUrl;
    
protected  Label lblListID;
    
protected  Label lblListTile;
    
protected  Label lblRootFolderUrl;
    
protected  Label lblDocumentID;
    
protected  Label lblDocumentName;
    
protected  Label lblDocumentUrl;
    
protected  Label lblDocumentTemplateUrl;
    
protected  Label lblFileAuthor;
    
protected  Label lblFileSize;
    
protected  Label lblFileLastModified;
    
protected  Label lblFileCheckOutStatus;

    
protected   override   void  OnLoad(EventArgs e) 
   {
      SPSite siteCollection  =   this .Site;
      SPWeb site 
=   this .Web;
      lblSiteTitle.Text 
=  site.Title;
      lblSiteUrl.Text 
=  site.Url.ToLower();      
      
string  ListId  =  Request.QueryString[ " ListId " ];
      lblListID.Text 
=  ListId;
      SPList list 
=  site.Lists[ new  Guid(ListId)];
      lblListTile.Text 
=  list.Title;
      lblRootFolderUrl.Text 
=  list.RootFolder.Url;      
      
string  ItemId  =  Request.QueryString[ " ItemId " ];
      lblDocumentID.Text 
=  ItemId;
      SPListItem item 
=  list.Items.GetItemById(Convert.ToInt32(ItemId));
      lblDocumentName.Text 
=  item.Name;
      lblDocumentUrl.Text 
=  item.Url;

      
if  (list  is  SPDocumentLibrary)
    {
        SPDocumentLibrary documentLibrary 
=  (SPDocumentLibrary)list;
        lblDocumentTemplateUrl.Text 
=  documentLibrary.DocumentTemplateUrl;

        SPFile file 
=  site.GetFile(item.Url);
        lblFileAuthor.Text 
=  file.Author.Name;
        lblFileSize.Text 
=  file.TotalLength.ToString( " 0,### " +   "  bits " ;
        lblFileLastModified.Text 
=   " By  "   +  file.ModifiedBy.Name  +
                                   
"  on  "   +  file.TimeLastModified.ToLocalTime().ToString();
        lblFileCheckOutStatus.Text 
=  file.CheckOutStatus.ToString();
      }
    }
    
  }
}


结果如下图:

3

ApplicationPage2.aspx中我们使用控件SPTreeView来显示该站点的文件夹结构,我们将菜单添加到“网站操作“中,并且设置只有管理员权限才可以看到,如下图:

4

Elements.xml中填加如下代码:

 

<!--  有管理员权限才可以察看  -->
< CustomAction  Id ="CustomApplicationPage2"
GroupId
="SiteActions"
Location
="Microsoft.SharePoint.StandardMenu"
Sequence
="2006"
Title
="获取站点信息"
Description
="使用SPTreeView获取站点信息"
RequireSiteAdministrator
="True" >
< UrlAction  Url ="~site/_layouts/CustomApplicationPages/ApplicationPage2.aspx" />
</ CustomAction >


RequireSiteAdministrator="True":改属性说明该项操作只有拥有管理员权限的用户才可以操作

ApplicationPage2.cs中代码如下:

 

using  System;
using  System.Web;
using  System.Web.UI;
using  System.Web.UI.WebControls;

using  Microsoft.SharePoint;
using  Microsoft.SharePoint.WebControls;

namespace  CustomApplicationPages
{
  
public   class  ApplicationPage2 : LayoutsPageBase 
  {    
    
protected  SPTreeView treeSitesFiles;
    
const   string  siteImg  =   @" \_layouts\images\FPWEB16.GIF " ;
    
const   string  foloerImg  =   @" \_layouts\images\FOLDER16.GIF " ;
    
const   string  ghostedFileImg  =   @" \_layouts\images\NEWDOC.GIF " ;
    
const   string  unGhostedFileImg  =   @" \_layouts\images\RAT16.GIF " ;

    
protected   override   void  OnLoad(EventArgs e)
    {
      SPWeb site 
=  SPContext.Current.Web;
      SPFolder rootFolder 
=  site.RootFolder;
      TreeNode rootNode 
=   new  TreeNode(site.Url, site.Url, siteImg);
      LoadFolderNodes(rootFolder, rootNode);
      treeSitesFiles.Nodes.Add(rootNode);
      treeSitesFiles.ExpandDepth 
=   1 ;
    }

    
protected   void  LoadFolderNodes(SPFolder folder, TreeNode folderNode)
    {
      
foreach  (SPFolder childFolder  in  folder.SubFolders) 
      {
        TreeNode childFolderNode 
=   new  TreeNode(childFolder.Name, childFolder.Name, foloerImg);
        childFolderNode.NavigateUrl 
=  Site.MakeFullUrl(childFolder.Url);
        LoadFolderNodes(childFolder, childFolderNode);        
        folderNode.ChildNodes.Add(childFolderNode);
      }

      
foreach  (SPFile file  in  folder.Files) 
      {
        TreeNode fileNode;
        
if  (file.CustomizedPageStatus  ==  SPCustomizedPageStatus.Uncustomized) 
        {
            fileNode 
=   new  TreeNode(file.Name, file.Name, ghostedFileImg);          
        }
        
else  
        {
            fileNode 
=   new  TreeNode(file.Name, file.Name, unGhostedFileImg);
        }
        fileNode.NavigateUrl 
=  Site.MakeFullUrl(file.Url);
        folderNode.ChildNodes.Add(fileNode);
      }
    } 
  }
}


效果如下图:

5

如何调试:
1.修改当前web应用程序的配置文件如下:

 
< configuration >
  
< SharePoint >
    
< SafeMode  CallStack ="true"   />
   
</ SharePoint >
  
< system.web >
    
< customErrors  mode ="Off"   />
    
< compilation  debug ="true"   />
  
</ system.web >
</ configuration >
2.然后附加w3wp进程,设置断点即可调试了。

转载于:https://www.cnblogs.com/greeny/archive/2010/09/03/1816962.html

一、数据采集层:多源人脸数据获取 该层负责从不同设备 / 渠道采集人脸原始数据,为后续模型训练与识别提供基础样本,核心功能包括: 1. 多设备适配采集 实时摄像头采集: 调用计算机内置摄像头(或外接 USB 摄像头),通过OpenCV的VideoCapture接口实时捕获视频流,支持手动触发 “拍照”(按指定快捷键如Space)或自动定时采集(如每 2 秒采集 1 张),采集时自动框选人脸区域(通过Haar级联分类器初步定位),确保样本聚焦人脸。 支持采集参数配置:可设置采集分辨率(如 640×480、1280×720)、图像格式(JPG/PNG)、单用户采集数量(如默认采集 20 张,确保样本多样性),采集过程中实时显示 “已采集数量 / 目标数量”,避免样本不足。 本地图像 / 视频导入: 支持批量导入本地人脸图像文件(支持 JPG、PNG、BMP 格式),自动过滤非图像文件;导入视频文件(MP4、AVI 格式)时,可按 “固定帧间隔”(如每 10 帧提取 1 张图像)或 “手动选择帧” 提取人脸样本,适用于无实时摄像头场景。 数据集对接: 支持接入公开人脸数据集(如 LFW、ORL),通过预设脚本自动读取数据集目录结构(按 “用户 ID - 样本图像” 分类),快速构建训练样本库,无需手动采集,降低系统开发与测试成本。 2. 采集过程辅助功能 人脸有效性校验:采集时通过OpenCV的Haar级联分类器(或MTCNN轻量级模型)实时检测图像中是否包含人脸,若未检测到人脸(如遮挡、侧脸角度过大),则弹窗提示 “未识别到人脸,请调整姿态”,避免无效样本存入。 样本标签管理:采集时需为每个样本绑定 “用户标签”(如姓名、ID 号),支持手动输入标签或从 Excel 名单批量导入标签(按 “标签 - 采集数量” 对应),采集完成后自动按 “标签 - 序号” 命名文件(如 “张三
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值