咨询在线共享点列表时出错

时间:2018-01-02 14:40:01

标签: c# sharepoint-online

我在c#vs 2013中有这个代码块

using System;
using Microsoft.SharePoint.Client;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;

namespace IndicadoresCartera
{
    public class SPQuery
    {
        public ClientContext clientContext;
        public Web site;
        public ListItemCreationInformation itemCreateInfo;
        static SPQuery queryService = new SPQuery();
        public SPQuery()
        {
            string url = ConfigurationManager.AppSettings["url"];
            string user = ConfigurationManager.AppSettings["user"];
            string password = ConfigurationManager.AppSettings["password"];

            SecureString securePassword = new SecureString();
            foreach (char c in password.ToCharArray()) securePassword.AppendChar(c);

            clientContext = new ClientContext(url);
            clientContext.Credentials = new SharePointOnlineCredentials(user, securePassword);
            site = clientContext.Web;

            itemCreateInfo = new ListItemCreationInformation();
        }

         public ListItemCollection queryList(string list, string queryString)
        {

            List queriedList = clientContext.Web.Lists.GetByTitle(list);
            CamlQuery query = new CamlQuery();
            query.ViewXml = queryString;

            ListItemCollection items = queriedList.GetItems(query);
            clientContext.Load(items);
            clientContext.ExecuteQuery();
            return items;
        }

        public bool createItem(string List, ListItem newListItem)
        {
            Clientes inCartera = new Clientes();
            List targetList = site.Lists.GetByTitle(List);

            newListItem.Update();
            clientContext.Load(newListItem);

            try
            {
                clientContext.ExecuteQuery();
                return true;

            }
            catch (Exception e)
            {
                Console.WriteLine("error creando item: " + e.Message);
                return false;
            }
        }


        public void getClientes()
        {

            List clientesGet = clientContext.Web.Lists.GetByTitle("clients");
            CamlQuery query = new CamlQuery();

            query.ViewXml = "<View><ViewFields><FieldRef Name='ID' /></ViewFields></View>";

            ListItemCollection ToDoClientes = clientesGet.GetItems(query);
            clientContext.Load(ToDoClientes);
            clientContext.ExecuteQuery();

            foreach (var cl in ToDoClientes.ToList())
            {
                if (cl["Title"] != null && cl["code"] != null && cl["name"] != null)
                {
                    List targetList = queryService.site.Lists.GetByTitle("Indi");
                    ListItem inCartera = targetList.AddItem(queryService.itemCreateInfo);

                    inCartera["Proceso"] = "Cliente";
                    inCartera["IdProceso"] = cl.Id;
                    inCartera["Responsable"] = "Cartera";
                    inCartera["Rol"] = "Cartera";
                    inCartera["Inicio"] = cl["FechaSolicitud"];
                    inCartera["Fin"] = cl["FechaAsignacionCodigo"];
                    inCartera["EstadoFinal"] = "Cliente Creado";


                    queryService.createItem("indicators", inCartera);
                }


            }


        }
    }
}

它的作用是咨询客户名单,然后告诉它在指标列表中插入哪一个。

问题是客户列表有超过2,000条记录以及在线sharepoint如何出错 信息:

  

尝试禁止的操作,因为它超出了管理员应用的列表视图阈值

如何查阅列表,以便将所有数据和if过滤器分开?

0 个答案:

没有答案