/// <summary> /// 添加或更新车型配置信息 /// </summary> /// <param name="pid"></param> /// <param name="table"></param> /// <param name="fileName"></param> /// <param name="cpremark"></param> /// <returns></returns> public bool InsertOrUpdateVehicleInfoByPID(string pid, DataTable table, string fileName, string cpremark) { var result = true; var vehicleIdList = new List <string>(); var insertTidList = new List <string>(); var updateTidList = new List <string>(); var deleteVehicleIdList = new List <string>(); var deleteTidList = new List <string>(); var batchCount = 1000; try { dbManager.CreateTransaction(conn => { var pidInfo = DalProductVehicleInfo.GetAllProductVehicleTypeConfigInfoByPid(conn, pid, fileName, cpremark); VerifyAndConvertData(pidInfo, table, fileName, cpremark, out vehicleIdList, out insertTidList, out updateTidList, out deleteVehicleIdList, out deleteTidList); if (deleteVehicleIdList.Any())//删除的二级车型信息 { while (deleteVehicleIdList.Any()) { if (deleteVehicleIdList.Count() < batchCount) { batchCount = deleteVehicleIdList.Count(); } DalProductVehicleInfo.BatchDeleteSecondVehicleTypeConfig(conn, deleteVehicleIdList.GetRange(0, batchCount), pid); deleteVehicleIdList.RemoveRange(0, batchCount); } } if (deleteTidList.Any())//删除的五级车型信息 { while (deleteTidList.Any()) { if (deleteTidList.Count() < batchCount) { batchCount = deleteTidList.Count(); } DalProductVehicleInfo.BatchDeleteFiveVehicleTypeConfig(conn, deleteTidList.GetRange(0, batchCount), pid); deleteTidList.RemoveRange(0, batchCount); } } if (vehicleIdList.Any())//增加的二级车型信息 { while (vehicleIdList.Any()) { if (vehicleIdList.Count() < batchCount) { batchCount = vehicleIdList.Count(); } DalProductVehicleInfo.BatchInsertSecondVehicleTypeConfig(conn, vehicleIdList.GetRange(0, batchCount), pid); vehicleIdList.RemoveRange(0, batchCount); } } if (insertTidList.Any())//增加的五级车型信息 { while (insertTidList.Any()) { if (insertTidList.Count() < batchCount) { batchCount = insertTidList.Count(); } DalProductVehicleInfo.BatchInsertFiveVehicleTypeConfig(conn, insertTidList.GetRange(0, batchCount), pid); insertTidList.RemoveRange(0, batchCount); } } if (updateTidList.Any())//需要更新的五级车型信息 { while (updateTidList.Any()) { if (updateTidList.Count() < batchCount) { batchCount = updateTidList.Count(); } DalProductVehicleInfo.BatchUpdateFiveVehicleTypeConfig(conn, updateTidList.GetRange(0, batchCount), pid); updateTidList.RemoveRange(0, batchCount); } } }); } catch (Exception ex) { result = false; logger.Error(ex); } return(result); }