如何比较2个不同阵列的对象?

时间:2017-06-23 14:38:44

标签: android

@model ScheduleProcess.Process

@Html.HiddenFor(model => model.TriggerId)

@* Name *@
<div style="text-align:center">
    @Html.LabelFor(model => model.TriggerName, new { style = "color:#00FF00" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.TriggerName, new { style = "width:75%; font-size:90%" })
</div>

@* Description *@
<div style="text-align:center">
    @Html.LabelFor(model => model.Description, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.Description, new { style = "width:75%; font-size:90%" })
</div>

@* Category *@
<div style="text-align:center">
    @Html.LabelFor(model => model.Category, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.Category)
</div>

@* Enabled *@
<div style="text-align:center">
    @Html.LabelFor(model => model.Enabled, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.Enabled)
</div>

@* Disable After Failure *@
<div style="text-align:center">
    @Html.LabelFor(model => model.DisableAfterFailure, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.DisableAfterFailure)
</div>

@* Process Thread Type *@
<div style="text-align:center">
    @Html.LabelFor(model => model.ProcessThreadType, new { style = "color:#00FF00" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.ProcessThreadType)
</div>

@* Estimated Process Run Time *@
<div style="text-align:center">
    @Html.LabelFor(model => model.EstimatedProcessRunTime, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.EstimatedProcessRunTime)
</div>

@* Number of Tries *@
<div style="text-align:center">
    @Html.LabelFor(model => model.Retries, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.Retries)
</div>

@* Wait Time Until Retry *@
<div style="text-align:center">
    @Html.LabelFor(model => model.WaitTimeTillRetry, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.WaitTimeTillRetry)
</div>

@* Service Address *@
<div style="text-align:center">
    @Html.LabelFor(model => model.ServiceAddress, new { style = "color:#00FF00" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.ServiceAddress, new { style="width:75%; font-size:70%"})
</div>

@* Endpoint Name *@
<div style="text-align:center">
    @Html.LabelFor(model => model.SelectedEndpointName, new { style = "color:#00FF00" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.SelectedEndpointName, new { style = "width:75%; font-size:90%" })
</div>

@* Process Name *@
<div style="text-align:center">
    @Html.LabelFor(model => model.SelectedMethodName, new { style = "color:#00FF00" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.SelectedMethodName, new { style = "width:75%; font-size:90%" })
</div>

@* Process Parameters *@
<div style="text-align:center">
    @Html.LabelFor(model => model.MethodParameters, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.MethodParameters)
</div>

@* Process Parameters(| delimeter) *@
<div style="text-align:center">
    @Html.LabelFor(model => model.ProcessParameters, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.ProcessParameters, new { style = "width:75%; font-size:90%" })
</div>

@* Event Log ID *@
<div style="text-align:center">
    @Html.LabelFor(model => model.EventId, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.EventId)
</div>

@* Trigger Type *@
<div style="text-align:center">
    @Html.LabelFor(model => model.TriggerType, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.TriggerType)
</div>

@* Last Successful Run *@
<div style="text-align:center">
    @Html.LabelFor(model => model.LastRun, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @(Html.TextBoxFor(model => model.LastRun, "{0:MM/dd/yyyy hh:mm:ss tt}", new { type = "datetime-local" }))
</div>

@* Last Attempted Run *@
<div style="text-align:center">
    @Html.LabelFor(model => model.LastUnSuccessfulRun, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.TextBoxFor(model => model.LastUnSuccessfulRun, "{0:MM/dd/yyyy hh:mm:ss tt}", new { type = "datetime-local" })
</div>

@* Run Interval *@
<div style="text-align:center" id="RunIntervalDiv">
    @Html.LabelFor(model => model.RunInterval, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.Kendo().IntegerTextBoxFor(model => model.RunInterval.Hours).HtmlAttributes(new { style = "width: 30px;" }).Spinners(false).Max(23).Min(0).RestrictDecimals(true).Decimals(0).Format("00") :
    @Html.Kendo().IntegerTextBoxFor(model => model.RunInterval.Minutes).HtmlAttributes(new { style = "width: 30px;" }).Spinners(false).Max(59).Min(0).RestrictDecimals(true).Decimals(0).Format("00") :
    @Html.Kendo().IntegerTextBoxFor(model => model.RunInterval.Seconds).HtmlAttributes(new { style = "width: 30px;" }).Spinners(false).Max(59).Min(0).RestrictDecimals(true).Decimals(0).Format("00")
</div>

@* Start Date *@
<div style="text-align:center">
    @Html.LabelFor(model => model.StartDate, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @(Html.Kendo().DatePickerFor(model => model.StartDate))
</div>

@* Start Time *@
<div style="text-align:center">
    @Html.LabelFor(model => model.StartTime, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @(Html.Kendo().TimePickerFor(model => model.StartTime))
</div>

@* Run Only On Weekdays *@
<div style="text-align:center" id="RunOnlyOnWeekdaysDiv">
    @Html.LabelFor(model => model.RunOnlyOnWeekdays, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunOnlyOnWeekdays)
</div>

@* Run Every *@
<div style="text-align:center" id="RunEveryDiv">
    @Html.LabelFor(model => model.RunEvery, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunEvery)
</div>

@* Days *@
<div style="text-align:center" id="RunEveryDaysDiv">
    @Html.LabelFor(model => model.RunEveryDays, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunEveryDays)
</div>

@* Run Every Week *@
<div style="text-align:center" id="RunEveryWeeksDiv">
    @Html.LabelFor(model => model.RunEveryWeeks, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunEveryWeeks)
</div>

@* Run On *@
<div style="text-align:center" id="RunOnDayDiv">
    @Html.LabelFor(model => model.RunOnDay, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunOnDay)
</div>

@* Day *@
<div style="text-align:center" id="RunOnDayOfDiv">
    @Html.LabelFor(model => model.RunOnDayOf, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunOnDayOf)
</div>

@* Run On the *@
<div style="text-align:center" id="RunOnWeekDiv">
    @Html.LabelFor(model => model.RunOnWeek, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.RunOnWeek)
</div>

@* Week *@
<div style="text-align:center" id="WeekTypeDiv">
    @Html.LabelFor(model => model.WeekType, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.WeekType)
</div>

@* Day of Week *@
<div style="text-align:center" id="DayOfWeekDiv">
    @Html.LabelFor(model => model.DayOfWeek, new { style = "color:#ffff99; font-size:80%" })
    &nbsp;&nbsp;&nbsp;
    @Html.EditorFor(model => model.DayOfWeek)
</div>

我必须从2个不同的数组列表中比较mcategory_id和scategory_id的值。我如何比较这两个值?我应该用什么逻辑呢?

1 个答案:

答案 0 :(得分:0)

如果您关心订单,可以使用List的“等于”方法。

List mcategoryIdList = new ArrayList();
List scategoryIdList = new ArrayList();
for (int i = 0; i < jsonArray.length(); i++) {
    //retrieve json objects
    JSONObject Jasonobject = jsonArray.getJSONObject(i);
    JSONObject jsonObject1 = jsonArray1.getJSONObject(i);

    //add to lists
    mcategoryIdList.add(Jasonobject.getString("category_id"));
    scategoryIdList.add(jsonObject1.getString("category_id"))
}

//now you can compare both
if(mcategoryIdList.equals(scategoryIdList)){
    //they're equal
}else{
    //they're not equal
}

如果您不关心订单,请使用套装:

Set mcategoryIdSet = new HashSet();
Set scategoryIdSet = new HashSet();
for (int i = 0; i < jsonArray.length(); i++) {
    //retrieve json objects
    JSONObject Jasonobject = jsonArray.getJSONObject(i);
    JSONObject jsonObject1 = jsonArray1.getJSONObject(i);

    //add to sets
    mcategoryIdSet.add(Jasonobject.getString("category_id"));
    scategoryIdSet.add(jsonObject1.getString("category_id"))
}

//now you can compare both
if(mcategoryIdSet.equals(scategoryIdSet)){
    //they're equal
}else{
    //they're not equal
}