using Aitex.Core.RT.Event;
using Aitex.Core.RT.Log;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Utilities;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase.Command;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Sicentury.Core.Collections;
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.Event
{
public class EventViewModel : BaseModel
{
#region Variables
///
/// 首次查询。需要计算总页码等参数。
///
private const int QUERY_FIRST_TIME = -1;
///
/// 一次性查询所有数据,EXCEL导出使用。
///
private const int QUERY_FOR_EXCEL_EXPORT = 0;
///
/// 指示函数是否发生了重入。如果发生重入,说明“ALL”由
/// 后台程序勾选,此时不要进行任何逻辑操作,仅设置”ALL“的选择状态。
/// 重入的情况发生在:
/// 1. 所有选项全部被选中
/// 2. 此时将“ALL”以外的选项勾掉
/// 3. “ALL”自动取消选择
/// 上述2会触发3,引起函数重入。
///
private bool _isEventSourceFilterSelectionReentered = false;
private int _currentPage;
private int _totalPage;
private int _selectedPage;
private int _selectedPaginationCapacity;
private bool _isLoading;
private bool _isExporting;
private string _exportingMessage;
///
/// 显示查询到的事件日志列表。
///
private readonly IProgress> _progShowSearchingResult;
///
/// 构造Event Source列表。
///
private readonly IProgress> _progConstructEventSourcesList;
///
/// 更新分页信息。
/// Tuple.Item1: 当前页号
/// Tuple.Item2: 总页号;设置为-1时表示忽略更新总页号。
///
private readonly IProgress> _progUpdatePaginationInfo;
///
/// 更新查询状态。
///
private readonly IProgress _progUpdateQueryStatus;
///
/// 更新日志导出状态。
/// Tuple.Item1: 导出进度,0~100
/// Tuple.Item2: 消息
///
private readonly IProgress> _progUpdateExportingState;
#endregion
#region Constructors
public EventViewModel()
{
DisplayName = "Event";
QueryEventList = () =>
{
var result = new List();
foreach (var eventName in Enum.GetNames(typeof(EventEnum)))
result.Add(eventName);
return result;
};
SearchedResult = new ObservableRangeCollection();
FilterEventSources = new ObservableRangeCollection();
SelectedFilterEventSource = new ObservableRangeCollection();
PaginationSource = new ObservableRangeCollection();
SearchKeyWords = string.Empty;
SearchAlarmEvent = true;
SearchWarningEvent = true;
SearchInfoEvent = true;
SearchOpeLog = false;
SearchPMA = false;
SearchPMB = false;
SearchPMC = false;
SearchPMD = false;
SearchTM = false;
SearchLL = false;
SearchSystem = false;
tbLoadPort1SelectionChangedCommand = new BaseCommand