如何使用 C# 访问共享点数据?

发布于 2024-08-11 12:03:03 字数 127 浏览 2 评论 0原文

我正在开发一个项目,我必须在 C# 中访问 SharePoint 数据。

我以前从未这样做过;并有以下问题?

如何从 C# 访问 SharePoint 数据?我使用什么 API?有没有任何教程可以帮助我入门?

I am working on project where I have to access SharePoint data in C#.

I've never done this before; and have the following questions?

How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

心如狂蝶 2024-08-18 12:03:03

您可以通过两种方式访问​​ Sharepoint 数据:

  1. 通过使用 Microsoft.Sharepoint.dll
    在这种情况下,您需要在同一台计算机(Windows 服务器)上进行编码。

  2. 第二种方法是使用 Sharepoint Web 服务。
    这将允许开发人员在不同的计算机上进行开发工作。

There two ways in which you can access Sharepoint data:

  1. By Using Microsoft.Sharepoint.dll
    In this case you need to do coding on same machine (windows server).

  2. Second way is to use Sharepoint Web Services.
    This will allow developer to do developement work on different machine.

梦中的蝴蝶 2024-08-18 12:03:03

SDK 是一个很好的起点。问题的真正关键在于您是否正在编写将在 SharePoint 环境中运行的代码,或者编写将在外部应用程序中使用 SharePoint 数据的代码。

对于前者,SharePoint 有自己的 API,您只需引用适当的 DLL 即可访问该 API。

对于后者,SharePoint 附带了一组 Web 服务,允许外部应用程序使用其数据。这些或一组自定义服务(在 SharePoint 环境中运行)将成为您进入 SharePoint 的入口点。

The SDK is a good place to start. The real crux of question lies in whether you are writing code which will live in a SharePoint environment, or writing code which will consume SharePoint data in an external application.

In the case of the former, SharePoint has its own API which you gain access to by simply referencing the appropriate DLL.

For the latter, SharePoint comes with a set of web services which allow external applications to consume its data. Either these or a set of custom services (running in the SharePoint environment) will be your entry point into SharePoint.

情仇皆在手 2024-08-18 12:03:03

这就是您在 PowerShell 中执行此操作的方式,这与您在 C# 中执行此操作的方式非常相似:

# Lets reference the assembly / GAC that we need for this
function getUsers
{
    param ([string] $verify_sitepath="https://extranet.something.com")
    $verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
        $verify_web=$verify_site.Rootweb
    $verify_web.site.url
    $verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
    foreach($verify_group in $verify_groups)
    {
        foreach($verify_user in $verify_group.users)
        {
            $verify_user = $verify_user -replace "WRKGRP\\",""
            Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
        }
    }
}

它的作用是从 SharePoint 获取文本文件中的所有用户。希望这至少能让您思考 SharePoint 是如何设置的。

包含所有功能的 MSDN 页面是一个很好的资源。他们提供了大量 C# 编程示例!

This is how you would do it in PowerShell which is very similar in how you would do it in in C#:

# Lets reference the assembly / GAC that we need for this
function getUsers
{
    param ([string] $verify_sitepath="https://extranet.something.com")
    $verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
        $verify_web=$verify_site.Rootweb
    $verify_web.site.url
    $verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
    foreach($verify_group in $verify_groups)
    {
        foreach($verify_user in $verify_group.users)
        {
            $verify_user = $verify_user -replace "WRKGRP\\",""
            Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
        }
    }
}

What this does is gets all the users from SharePoint that are in a text file. Hopefully this gets you at least thinking about how SharePoint is set up.

A great resource is the MSDN page with all the functions. They provide a lot of programming samples in C#!

ま柒月 2024-08-18 12:03:03

Sharepoint SDK 页面开始。下载SDK,并查看MSDN上的示例代码。

稍后添加:根据 MS 的说法,对所有人来说都是一个更好的网站与 Sharepoint 开发相关的事情。

Start at the Sharepoint SDK page. Download the SDK, and look at the sample code on MSDN.

Added later: according to MS, this is a better site for all things related to Sharepoint development.

习ぎ惯性依靠 2024-08-18 12:03:03

您必须安装 Sharepoint 的 VS 2005 或 VS 2008 扩展。在 XP 上安装它们可能会很棘手,此页面 应该可以帮助您。

You have to install VS 2005 or VS 2008 extensions for sharepoint. Intsllaing them on xp can be tricky and this page should hep you with that.

信愁 2024-08-18 12:03:03

您还应该CAML 查询,您应该知道从共享点查询数据列表

您可以使用这样的工具http://www.u2u.be /Res/Tools/CamlQueryBuilder.aspx

you should also CAML Query which you should know to query data from sharepoint lists

you can make use of such a tool http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx

梦巷 2024-08-18 12:03:03

对我来说,听起来您应该使用开箱即用的 SharePoint Web 服务。当您只需与 Web 服务交谈就可以轻松相处时,就没有必要学习整个 SharePoint API。

这个InfoQ 入门很好,但是在 SharePoint Web 上搜索一下服务,你会发现充足的资源

To me it sounds like you should use the Out Of The Box SharePoint web services. There is no reason why you should have to learn the entire SharePoint API when you could get along just talking to the web service.

This primer on InfoQ is good, but do a seach on SharePoint Web Services and you will find plenty of sources

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文