C# 我向web api发送了超过900个数据集行的数据,导致超时。使用Asp.NETMVC
我想把它分成100行一行发送。我不知道要被截肢。C# 这是我用来调用web api的代码C# 我向web api发送了超过900个数据集行的数据,导致超时。使用Asp.NETMVC,c#,asp.net-mvc,C#,Asp.net Mvc,我想把它分成100行一行发送。我不知道要被截肢。C# 这是我用来调用web api的代码 public static string AddPlanningAPI(string planNo, string jobNo, string bDate, string eDate, string progId, string timeGroup, string userId, string stationId) { DataSet ds = dsConfirmBookingAPI(planNo,
public static string AddPlanningAPI(string planNo, string jobNo, string bDate, string eDate, string progId, string timeGroup, string userId, string stationId)
{
DataSet ds = dsConfirmBookingAPI(planNo, jobNo, bDate, eDate, progId, timeGroup, userId, stationId);
RSWSJobOrder.DataJobOrderSoapClient rsWsJobOrder = new RSWSJobOrder.DataJobOrderSoapClient();
try
{
string iResult = rsWsJobOrder.AddPlaning_Return_JsonString(ds, userId);
return iResult;
}
catch (Exception tmp_ex) { throw tmp_ex; }
}
public string AddPlaning_Return_JsonString(System.Data.DataSet SendDs, string createBy) {
return base.Channel.AddPlaning_Return_JsonString(SendDs, createBy);
}
所以你基本上想批量上传你的行。下面将实现这一点,您将定义每个“批次”的项目数量,并将它们上载到这些组中 请参考代码中的注释以了解每一行的说明 注意:如果您的DataTable需要一个名称(或者您在
数据集中有多个表)
,则需要修改以下内容以满足这些要求
public void BatchUpload(DataSet ds)
{
int numberPerBatch = 100; // Define the number per batch
for (int skip = 0; skip < ds.Tables[0].Rows.Count; skip += numberPerBatch) // Group the batches
{
DataTable batchDT = new DataTable(); // Create a new DataTable for the batch
var batch = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Skip(skip).Take(numberPerBatch); // LINQ to create the batch off existing set.
foreach (var row in batch) // Import rows to new datatable
{
batchDT.Rows.Add(row);
}
DataSet batchDS = new DataSet(); // Create a new DataSet
batchDS.Tables.Add(batchDT); // Add datatable to dataset
string iResult = rsWsJobOrder.AddPlaning_Return_JsonString(batchDS, userId); // send the batch off
}
}
public void批上载(数据集ds)
{
int numberPerBatch=100;//定义每批的数量
for(int skip=0;skip
不清楚你在问什么。请花点时间写下您的问题或详细说明问题所在。我们也不知道AddPlaning\u Return\u JsonString在做什么。我提交的数据是941行。我想一次除以100行。见下文。如果我理解正确,您希望“批量”分组上传项目。