List<SecYearCareerMoniDangerDto> MoniUnitlst = JsonUtility.DeserializeByNewton<List<SecYearCareerMoniDangerDto>>
List<SecYearCareerMoniDangerDto> lstNew = new List<SecYearCareerMoniDangerDto>();
if (MoniUnitlst != null &&MoniUnitlst.Count>0)
{
foreach (SecYearCareerMoniDangerDto oldDdto in MoniUnitlst)
{
bool flag = true;
foreach (SecYearCareerMoniDangerDto dangerDto in lstNew)
{
if (dangerDto.careerDangerClass == oldDdto.careerDangerClass
{
flag = false;
break;
}
}
if (flag)
{
SecYearCareerMoniDangerDto newDto = new SecYearCareerMoniDangerDto();
newDto.CurrentYear = oldDdto.secYearCareerMoniUnit_currentYear;
newDto.careerDangerClass = oldDdto.careerDangerClass;
newDto.careerDangerClass_cnName = oldDdto.careerDangerClass_cnName;
newDto.careerDanger = oldDdto.careerDanger;
newDto.careerDanger_cnName = oldDdto.careerDanger_cnName;
newDto.monitorCount = oldDdto.monitorCount;
newDto.monitorUnit = oldDdto.secYearCareerMoniUnit_monitorUnit;
newDto.remark = oldDdto.secYearCareerMoniUnit_remark;
lstNew.Add(newDto);
}
}
}
这是在做stimulsoft report中的拼接报表中数据用到的一些代码,以上含义是从得到的一些集合中过滤掉危害类别和危害因素相同的数
foreach (SecYearCareerMoniDangerDto dangerDto in MoniUnitlst)
{
for (int i = 0; i < lstNew.Count; i++)
{
if (dangerDto.careerDangerClass == lstNew[i].careerDangerClass && dangerDto.careerDanger ==
{
SecYearCareerMoniDangerDto newDangerDto = null;
foreach (SecYearCareerMoniDangerDto newDto in lstData)
{
if (newDto.monitorUnit == dangerDto.secYearCareerMoniUnit_monitorUnit)
{
newDangerDto = newDto;
break;
}
if (newDangerDto == null)
{
newDangerDto = new SecYearCareerMoniDangerDto();
newDangerDto.monitorUnit = dangerDto.secYearCareerMoniUnit_monitorUnit;
newDangerDto.remark =dangerDto.secYearCareerMoniUnit_remark;
newDangerDto.GetType().GetProperty("udf" + (i + 1)).SetValue(newDangerDto,
lstData.Add(newDangerDto);
}
else
{
newDangerDto.GetType().GetProperty("udf" + (i + 1)).SetValue(newDangerDto,
}
break;
}
}
}
这个和上面的代码实现的功能差不多,在这里注意newDangerDto.GetType().GetProperty("udf" + (i + 1)).SetValue(newDangerDto,