层层退出
//JS
var isRelationalLoop = _this.isPrecedingCoseCodeLoop(coseCodePre, binIdPre);
this.isPrecedingCoseCodeLoop = function (coseCodePre, binIdPre) {
var _this = this;
var isRelationalLoop = false;
for (var i = 0; i < _this.routeDataList.length; i++) {
if (_this.routeDataList[i]._coseCode == coseCodePre && _this.routeDataList[i]._binId == binIdPre) {
if (_this.routeDataList[i]._coseCodePre != "" && _this.routeDataList[i]._binIdPre != "") {
if (_this.routeDataList[i]._coseCodePre == coseCodePre && _this.routeDataList[i]._binIdPre == binIdPre) {
isRelationalLoop = true;
break;
}
else {
isRelationalLoop = _this.isPrecedingCoseCodeLoop(_this.routeDataList[i]._coseCodePre, _this.routeDataList[i]._binIdPre);
break;
}
}
else {
isRelationalLoop = false;
break;
}
}
}
return isRelationalLoop;
};
// C#
plan.IsPrecedingCoseCodeRight = SelectPrecedingCoseCode(temp.PrecedingCoseCode, temp.RouteId);
public int SelectPrecedingCoseCode(int? precedingCoseCode, int routeID)
{
int isRelationalLoop = 0;
foreach (var route in routeMasterList)
{
if (precedingCoseCode == route.route_id)
{
if (route.preceding_cose_code_route_id != null)
{
if (route.preceding_cose_code_route_id == routeID)
{
isRelationalLoop = 2;
break;
}
else
{
isRelationalLoop = SelectPrecedingCoseCode(route.preceding_cose_code_route_id, routeID);
break;
}
}
else
{
isRelationalLoop = 0;
break;
}
}
}
return isRelationalLoop;
}