Add a functionality to the ACCEPT button such that whenever a particular alert is accepted the accept button for that particular alert should be disabled.
There are two files one is the alert.html file
@if (Model.AlertsVM != null)
{
foreach (var item in Model.AlertsVM)
{
<tr>
<td style="display: none">@Html.DisplayFor(modelItem => item.Id)
</td>
<td>@Html.DisplayFor(modelItem => item.InstallationId)
</td>
<td>@Html.DisplayFor(modelItem => item.InstallationName)
</td>
<td>@Html.DisplayFor(modelItem => item.AlertName)
</td>
<td>@Html.DisplayFor(modelItem => item.Status)
</td>
<td>@Html.DisplayFor(modelItem => item.GenerationTime)
</td>
<td>@Html.DisplayFor(modelItem => item.AcceptedBy)
</td>
<td>@Html.DisplayFor(modelItem => item.LastUpdated)
</td>
<td>@Html.ActionLink("Accept", "Accept", new
{
id = item.Id,
acceptedby = item.AcceptedBy,
installationid = item.InstallationId,
parameterid = item.ParameterId,
clientid = item.ClientId,
nodeId = item.NodeId,
alarmuserid = item.AlarmUserId,
alarmdetailuserid = item.AlarmDetailUserId,
alertstatus = item.AlertStatus
}, new { @class = "actionlink clsAccept", @id = "btnAccept" })
</td>
<td>@Html.ActionLink("Detail", "Details", new
{
id = item.Id
}, new { @class = "actionlink", @id = "btnDetail" })
</td>
</tr>
And another is the controller file for this accept button
[AjaxValidateAntiForgeryToken]
public ActionResult Accept(Int64 id, string acceptedby, int installationid, int parameterid, int? clientid, int alertstatus, string nodeid, Int32 alarmuserid, Int64 alarmdetailuserid)
{
LogWriter.WriteLog(new LogDTO() { FunctionName = "Accept", LogStringLevel = LoggingLevel.Detail, ClassName = this.GetType().Name, AdditionalInfo = "Start - " });
/* MERGED */
// Changes for FIX ALT - 854 - Nishchal Shrimali
string strTopic = string.Empty;
CallCenterBL callCenterBL = new CallCenterBL();
// SaveSnooze(id);
// Redirect to alert list page if alert is already closed
ReturnDTO returnDTOAlertDetail = callCenterBL.GetAlertDetails(id);
if (returnDTOAlertDetail.message == ReturnCodes.NO_DATA_FOUND)
{
TempData["error"] = rsCaption.ALERT_HAS_BEEN_CLOSED;
return Redirect("/CallCenter/Alerts");
}
// Changes for FIX ALT - 854 - Nishchal Shrimali
if (clientid != null && clientid > 0)
{
strTopic = clientid + "/cmd/alarm/" + parameterid;
}
else
{
List<AlertEventDetails> alertEventDetails = (List<AlertEventDetails>)returnDTOAlertDetail.Data;
AlertEventDetails alertEventDetailsfromdb = alertEventDetails.Find(x => x.InstallationId == installationid);
strTopic = alertEventDetailsfromdb.ClientId + "/cmd/alarm/" + parameterid;
LogWriter.WriteLog(new LogDTO() { FunctionName = "Accept", LogStringLevel = LoggingLevel.Detail, ClassName = this.GetType().Name, AdditionalInfo = "Accept else case Ln 372 alertEventDetailsfromdb.ClientId : " + alertEventDetailsfromdb.ClientId });
}
Alarm alarm = new Alarm
{
AlarmId = id,
InstallationId = installationid,
ParameterId = parameterid,
NodeId = nodeid,
AlarmUserId = alarmuserid,
AlarmDetailUserId = alarmdetailuserid,
AlarmStatus = AssistedLiving.BatchProcessor.Global.DataTypes.AlarmStatus.InProgress,//InProgress
AlarmDetail = new AlarmDetail
{
AcknowledgeType = AssistedLiving.BatchProcessor.Global.DataTypes.AcknowledgeType.Accept,//Accept
AlarmDetailUserId = GetAlertUserId(),
ReturnCode = AssistedLiving.BatchProcessor.Global.DataTypes.ReturnCodes.SUCCESS
}
};
string mqttMessage = GetJsonString(alarm);
try
{
sdkController = SDKController.GetSDKInstance(GetMqttInfo(), out client);
if (acceptedby == null)
{
//check if alarm status is Pending
if (alertstatus == 1)
{
//Publish MQTT topic for accept the alert
sdkController.SendCallCenterRequest(strTopic, mqttMessage);
}
}
//CallCenterBL callCenterBL = new CallCenterBL();
AcceptAlertDetails acceptAlertDetails = new AcceptAlertDetails();
acceptAlertDetails.AlertId = id;
acceptAlertDetails.UserId = CommonMethods.GetCurrentSession().userid;
acceptAlertDetails.LastUpdated = DateTime.Now;
acceptAlertDetails.Status = 2;//UnSent
//Save alert deails in database
ReturnDTO returnDTO = callCenterBL.SaveAlertDetails(acceptAlertDetails);
//Publish MQTT topic to refresh the page
sdkController.SendCallCenterRequest(clientid + "/cmd/alarm_refresh/" + parameterid, mqttMessage);
if (returnDTO.message == ReturnCodes.SUCCESS)
{
TempData["msg"] = rsCaption.ACCEPTED_SUCCESSFULLY;
}
}
catch (Exception ex)
{
LogWriter.WriteLog(new LogDTO() { FunctionName = "Accept", LogStringLevel = LoggingLevel.Exceptional, ExceptionString = ex.Message, StackTrace = Convert.ToString(ex.StackTrace), AdditionalInfo = "Exception -", ClassName = this.GetType().Name });
ModelState.AddModelError("", rsMessage.SERVICE_NOT_RESPONDING);
TempData["error"] = ex.Message;
return Redirect("/CallCenter/Alerts");
}
LogWriter.WriteLog(new LogDTO() { FunctionName = "Accept", LogStringLevel = LoggingLevel.Detail, ClassName = this.GetType().Name, AdditionalInfo = "End - " });
return Redirect("/CallCenter/Details/" + id);
}
Please provide possible solution to do this