Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用控制台应用程序从sharepoint列表提取数据_C#_Ssis_Console Application_Sharepoint 2013 - Fatal编程技术网

C# 使用控制台应用程序从sharepoint列表提取数据

C# 使用控制台应用程序从sharepoint列表提取数据,c#,ssis,console-application,sharepoint-2013,C#,Ssis,Console Application,Sharepoint 2013,我已经搜索了好几个小时,寻找最好的方法,我所发现的是大量相互冲突的信息,我已经快要崩溃了 我有一个sharepoint 2013网站,自然有一个列表 我希望连接到此列表并将信息提取到数据表中。应该没那么难吧 所以我试过了, 我最初计划在ssis上提取信息并在其最终目的地之前进行转换。 显然有一个很好的小适配器,sharepoint列表适配器。。。不适用于SSIS 13!!!当然没有,这是我唯一能用的版本 然后我阅读了一个名为lists.asmx的Web服务,当调用和查询它时,它应该返回表的xml

我已经搜索了好几个小时,寻找最好的方法,我所发现的是大量相互冲突的信息,我已经快要崩溃了

我有一个sharepoint 2013网站,自然有一个列表

我希望连接到此列表并将信息提取到数据表中。应该没那么难吧

所以我试过了, 我最初计划在ssis上提取信息并在其最终目的地之前进行转换。 显然有一个很好的小适配器,sharepoint列表适配器。。。不适用于SSIS 13!!!当然没有,这是我唯一能用的版本

然后我阅读了一个名为lists.asmx的Web服务,当调用和查询它时,它应该返回表的xml版本。。。太好了

我连接到webservice,我需要使用的一个方法(GETLISTITEMS)在所有教程中都不存在于SP2013中

有人可以给我一个例子,或链接到一个网站,显示连接和查询的例子,无论是我

A通过SSIS 13拉取数据 B如何连接到SP站点并提取表信息


请回复我的理智,谢谢你作为控制台应用我想你是指visual studio中的c#控制台应用?仅google for SharePoint 2013 CSOM-客户端对象模型。你可以找到大量关于这方面的信息。 它允许您从“远距离”/“客户端”管理SP环境(以及读取列表)。您需要托管API DLL


作为控制台应用程序,我想你是指visual studio中的c#控制台应用程序?仅google for SharePoint 2013 CSOM-客户端对象模型。你可以找到大量关于这方面的信息。 它允许您从“远距离”/“客户端”管理SP环境(以及读取列表)。您需要托管API DLL


感谢Verthosa为我指明了正确的方向,CSOM无疑是一条路,尽管它需要一些阅读和实验

我的类将列表数据转换成数据表,以便轻松调用。对于任何想找一个好的简单类来提取下面列表的人来说,我的类都是这样的

必须使用Microsoft.SharePoint.Client-下载SP2010/2013客户端SDK(如果不存在)添加,并在引用中包括程序集扩展名Microsoft.SharePoint.Client+Microsoft.SharePoint.Runtime

调用方法

DataTable dt = new DataTable();
dt = ClassName.GetList("http://SharepointSite", "Name of List Table");
获取和转换类方法

 public static DataTable GetList(string site, string listname)
    {
        ClientContext ctx = new ClientContext(site);

        List lst = ctx.Web.Lists.GetByTitle(listname);

        CamlQuery cq = CamlQuery.CreateAllItemsQuery();

        ListItemCollection lic = lst.GetItems(cq);

        ctx.Load(lic);

        ctx.ExecuteQuery();
        DataTable dt = new DataTable();

        foreach (var field in lic[0].FieldValues.Keys)
        {
            dt.Columns.Add(field);
        }

        foreach (var item in lic)
        {
            DataRow dr = dt.NewRow();

            foreach (var obj in item.FieldValues)
            {
                if (obj.Value != null)
                {
                    string type = obj.Value.GetType().FullName;

                    if (type == "Microsoft.SharePoint.Client.FieldLookupValue")
                    {
                        dr[obj.Key] = ((FieldLookupValue)obj.Value).LookupValue;
                    }
                    else if (type == "Microsoft.SharePoint.Client.FieldUserValue")
                    {
                        dr[obj.Key] = ((FieldUserValue)obj.Value).LookupValue;
                    }
                    else
                    {
                        dr[obj.Key] = obj.Value;
                    }
                }
                else
                {
                    dr[obj.Key] = null;
                }
            }

            dt.Rows.Add(dr);
        }

        return dt;
    }

感谢Verthosa为我指明了正确的方向,CSOM无疑是一条前进的道路,尽管它需要一些阅读和实验

我的类将列表数据转换成数据表,以便轻松调用。对于任何想找一个好的简单类来提取下面列表的人来说,我的类都是这样的

必须使用Microsoft.SharePoint.Client-下载SP2010/2013客户端SDK(如果不存在)添加,并在引用中包括程序集扩展名Microsoft.SharePoint.Client+Microsoft.SharePoint.Runtime

调用方法

DataTable dt = new DataTable();
dt = ClassName.GetList("http://SharepointSite", "Name of List Table");
获取和转换类方法

 public static DataTable GetList(string site, string listname)
    {
        ClientContext ctx = new ClientContext(site);

        List lst = ctx.Web.Lists.GetByTitle(listname);

        CamlQuery cq = CamlQuery.CreateAllItemsQuery();

        ListItemCollection lic = lst.GetItems(cq);

        ctx.Load(lic);

        ctx.ExecuteQuery();
        DataTable dt = new DataTable();

        foreach (var field in lic[0].FieldValues.Keys)
        {
            dt.Columns.Add(field);
        }

        foreach (var item in lic)
        {
            DataRow dr = dt.NewRow();

            foreach (var obj in item.FieldValues)
            {
                if (obj.Value != null)
                {
                    string type = obj.Value.GetType().FullName;

                    if (type == "Microsoft.SharePoint.Client.FieldLookupValue")
                    {
                        dr[obj.Key] = ((FieldLookupValue)obj.Value).LookupValue;
                    }
                    else if (type == "Microsoft.SharePoint.Client.FieldUserValue")
                    {
                        dr[obj.Key] = ((FieldUserValue)obj.Value).LookupValue;
                    }
                    else
                    {
                        dr[obj.Key] = obj.Value;
                    }
                }
                else
                {
                    dr[obj.Key] = null;
                }
            }

            dt.Rows.Add(dr);
        }

        return dt;
    }