【发布时间】:2014-08-19 14:19:47
【问题描述】:
我有一个 ASP 网站,它使用 SSIS 读取共享点列表并将其显示在网格视图上。然后,单击一个按钮,SQL 数据库中的一个表就会更新为一些列表值。我想要的是,单击按钮以更新共享点列表上的列,以便在再次运行时 SSIS 包忽略该行。并且网站和共享点在不同的服务器上。哪种方法最好?
【问题讨论】:
标签: asp.net sql-server web-services sharepoint
我有一个 ASP 网站,它使用 SSIS 读取共享点列表并将其显示在网格视图上。然后,单击一个按钮,SQL 数据库中的一个表就会更新为一些列表值。我想要的是,单击按钮以更新共享点列表上的列,以便在再次运行时 SSIS 包忽略该行。并且网站和共享点在不同的服务器上。哪种方法最好?
【问题讨论】:
标签: asp.net sql-server web-services sharepoint
因为它在不同的服务器上,我建议使用 SharePoint Web Services 和 AJAX。下面是一个更新任务项的 AJAX 示例:
function updateTaskPercent(taskId, pctComplete, taskStatus) {
var targetUrl = "../_vti_bin/lists.asmx";
var listName = "Project Tasks";
var updateItemXml;
updateItemXml =
"<Batch OnError=\"Continue\" ListVersion=\"1\" ViewName=\"\">" +
"<Method ID=\"1\" Cmd=\"Update\">" +
"<Field Name=\"ID\">" + taskId + "</Field>" +
"<Field Name=\"Status\">" + taskStatus + "</Field>" +
"<Field Name=\"_x0025__x0020_Complete\">" + pctComplete + "</Field>" +
"</Method>" +
"</Batch>";
var soapEnv = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
" <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
" <soap:Body> <UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">" +
" <listName>" + listName + "</listName>" +
" <updates>" + updateItemXml + "</updates>" +
" </UpdateListItems> </soap:Body></soap:Envelope>";
$.ajax({
cache: false,
url: targetUrl,
type: "POST",
dataType: "xml",
data: soapEnv,
contentType: "text/xml; charset=utf-8",
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
},
complete: function(msg) {
if ($(msg.responseXML).find("ErrorText").text().length === 0) { // success
SP.UI.Status.removeAllStatus(true);
addNotification("Task Updated");
} else {
//Failure
var errorString = $(msg.responseXML).find("ErrorText").text();
if (errorString.length === 0) {
errorString = $(msg.responseXML).find("FaultString").text();
}
errorString = errorString.replace(/(\r\n|\n|\r)/gm, "");
}
}
});
}
【讨论】: