91 lines
2.4 KiB
C#
91 lines
2.4 KiB
C#
using CMS_CORE_Library.Utils;
|
|
using Step.Model.DatabaseModels;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using static Step.Model.Constants;
|
|
|
|
namespace Step.Model.DTOModels.AlarmModels
|
|
{
|
|
public class DTOAlarmHistoricModel
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
public int AlarmId { get; set; }
|
|
|
|
public string Title { get; set; }
|
|
|
|
public string Description { get; set; }
|
|
|
|
public ALARM_SOURCE Source { get; set; }
|
|
|
|
public ALARM_TYPE Type { get; set; }
|
|
|
|
public List<int> Processes { get; set; }
|
|
|
|
public DateTime TimeStamp { get; set; }
|
|
|
|
public List<int> Users { get; set; }
|
|
|
|
public static explicit operator DTOAlarmHistoricModel(AlarmOccurrencesModel obj)
|
|
{
|
|
List<int> processes = new List<int>();
|
|
|
|
bool[] statusBits = new BitArray(new int[] { obj.Processes })
|
|
.Cast<bool>()
|
|
.ToArray();
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
if (statusBits[i])
|
|
processes.Add(i + 1);
|
|
}
|
|
|
|
return new DTOAlarmHistoricModel()
|
|
{
|
|
Id = obj.AlarmOccurrenceId,
|
|
AlarmId = obj.AlarmId,
|
|
Title = obj.AlarmDescription == null ? "" : obj.AlarmDescription.Title,
|
|
// Description = obj.AlarmDescription == null ? "" : obj.AlarmDescription.Description,
|
|
Processes = processes,
|
|
Source = obj.Source,
|
|
TimeStamp = obj.TimeStamp,
|
|
Type = obj.Type,
|
|
Users = obj.Users.Select(x => x.UserId).ToList()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class DTOAlarmsFilterModel
|
|
{
|
|
[Required, Range(0, int.MaxValue)]
|
|
public int Page { get; set; }
|
|
|
|
[Required, Range(0, int.MaxValue)]
|
|
public int PageSize { get; set; }
|
|
|
|
public string Title { get; set; }
|
|
|
|
[Required]
|
|
public List<ALARM_SOURCE> Sources { get; set; }
|
|
|
|
[Required]
|
|
public DateTime? StartDate { get; set; }
|
|
|
|
[Required]
|
|
public DateTime EndDate { get; set; }
|
|
|
|
[Required]
|
|
public List<int?> UserIds { get; set; }
|
|
|
|
public string Language { get; set; }
|
|
}
|
|
|
|
public struct DTOAlarmsData
|
|
{
|
|
public int Pages;
|
|
public DateTime FirstDate;
|
|
}
|
|
} |