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

Send form output to sharepoint list

我们在 Azure 中托管了一个 Web 应用程序。我们想添加一个表单并将输出发送到 SharePoint 列表。我想我的问题是 what/where 是从 azure 应用程序、函数等到 SharePoint 的连接吗? Azure 是否有可用的简化流程,或者这是否涉及多条路线,从表单到 SQL、SQL 到外部服务器?

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

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

根据您的描述,您想将输出发送到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 Client Components SDK