繁体   English   中英

将表单输出发送到共享点列表

[英]Send form output to sharepoint list

我们在Azure中托管了一个Web应用程序。 我们想添加一个表单并将输出发送到SharePoint列表。 我想我的问题是,从天蓝色的应用程序,功能等到SharePoint的连接在哪里/在哪里? Azure是否提供了简化的流程,还是会涉及从Form到SQL,从SQL到外部服务器的几种路由?

有几种方法可以做到这一点。

因为您正在使用Web应用程序,所以我们可以使用SharePoint CSOM API创建列表项。

根据您的描述,您想将输出发送到SharePoint List,这是一个简单的演示供您参考:

    /// <summary>
    /// Create a List Item
    /// </summary>
    /// <param name="context"></param>
    /// <param name="listName"></param>
    public static void createItem(ClientContext context, string listName, FormEntity formEntity)
    {
        List list = context.Web.Lists.GetByTitle(listName);
        context.Load(list);
        context.ExecuteQuery();
        ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();            

        ListItem listItem = list.AddItem(itemCreateInfo);
        listItem["Title"] = formEntity.Title;
        listItem["Name"] = formEntity.Name;
        listItem["department"] = formEntity.department;
        listItem["Age"] = formEntity.Age;
        listItem.Update();
        context.Load(listItem);
        context.ExecuteQuery();
    }

    public class FormEntity
    {
        public string Title { get; set; }

        public string Name { get; set; }

        public string department { get; set; }

        public int Age { get; set; }
    }

对SharePoint进行身份验证,我们可以执行以下操作:

    #region do authentication of SharePoint
    /// <summary>
    /// do authentication of SharePoint Online
    /// </summary>
    /// <param name="clientContext"></param>
    /// <param name="userName"></param>
    /// <param name="password"></param>
    public static void setOnlineCredential(ClientContext clientContext,string userName,string password)
    {
        //set the user name and password
        SecureString secureString = new SecureString();
        foreach (char c in password.ToCharArray())
        {
            secureString.AppendChar(c);
        }
        clientContext.Credentials = new SharePointOnlineCredentials(userName, secureString);           
    }

    /// <summary>
    /// do authentication of SharePoint on-premise
    /// </summary>
    /// <param name="clientContext"></param>
    /// <param name="userName"></param>
    /// <param name="password"></param>
    /// <param name="domain"></param>
    public static void setClientCredential(ClientContext clientContext, string userName, string password, string domain)
    {
        clientContext.Credentials = new NetworkCredential(userName, password, domain);
    }
    #endregion

我们可以从以下位置下载CSOM API: SharePoint客户端组件SDK

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM