100 행으로 나누어 보내 드리고 싶습니다. 절단 할 지식이 없습니다. C # 웹 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, 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에 이름이 필요한 경우 (또는에 여러 테이블이있는 경우 DataSet
) 이러한 요구 사항에 맞게 아래를 수정해야합니다.
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
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다