|
@@ -1,19 +1,22 @@
|
|
|
using Aitex.Core.RT.Event;
|
|
|
using Aitex.Core.RT.Log;
|
|
|
using Aitex.Core.WCF;
|
|
|
+using CyberX8_MainPages.Roles;
|
|
|
+using CyberX8_MainPages.Unity;
|
|
|
+using CyberX8_MainPages.Views;
|
|
|
using MECF.Framework.Common.DataCenter;
|
|
|
+using OpenSEMI.ClientBase;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Mvvm;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Collections.ObjectModel;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
-using CyberX8_MainPages.Unity;
|
|
|
-using CyberX8_MainPages.Views;
|
|
|
|
|
|
namespace CyberX8_MainPages.ViewModels
|
|
|
{
|
|
@@ -21,6 +24,11 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
{
|
|
|
#region 私有字段
|
|
|
//private int MenuPermission;
|
|
|
+ private int m_Total;
|
|
|
+ private int m_PageCount;
|
|
|
+ private int m_CurrentPage = 1;
|
|
|
+
|
|
|
+ private int m_onePageCounts = 30;
|
|
|
#endregion
|
|
|
|
|
|
#region 属性
|
|
@@ -45,7 +53,7 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
public bool IsAuto
|
|
|
{
|
|
|
get { return m_IsAuto; }
|
|
|
- set
|
|
|
+ set
|
|
|
{
|
|
|
if (value == true)
|
|
|
{
|
|
@@ -74,6 +82,31 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
|
|
|
public Func<string, List<EventItem>> QueryDBEventFunc { get; set; }
|
|
|
public Func<List<string>> QueryEventList { get; set; }
|
|
|
+
|
|
|
+ public int Total
|
|
|
+ {
|
|
|
+ get { return m_Total; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref m_Total, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public int PageCount
|
|
|
+ {
|
|
|
+ get { return m_PageCount; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref m_PageCount, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public int CurrentPage
|
|
|
+ {
|
|
|
+ get { return m_CurrentPage; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref m_CurrentPage, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region 命令
|
|
@@ -130,6 +163,15 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
|
|
|
|
|
|
}
|
|
|
+ private void PopDialog(EventItem obj)
|
|
|
+ {
|
|
|
+ Application.Current.Dispatcher.Invoke(() =>
|
|
|
+ {
|
|
|
+ DialogBox.ShowInfo(obj.Explaination);
|
|
|
+
|
|
|
+ });
|
|
|
+ //MessageBox.Show(obj.Explaination,"Information",MessageBoxButton.OK,MessageBoxImage.Information);
|
|
|
+ }
|
|
|
private void Instance_OnEvent(EventItem eventItem)
|
|
|
{
|
|
|
switch (eventItem.Type)
|
|
@@ -137,13 +179,13 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
case EventType.EventUI_Notify:
|
|
|
Application.Current.Dispatcher.Invoke(delegate
|
|
|
{
|
|
|
- SearchedResult.Insert(0,new Aitex.Core.UI.View.Common.SystemLogItem()
|
|
|
- {
|
|
|
- ID=eventItem.Id.ToString(),
|
|
|
- LogType=eventItem.Level.ToString(),
|
|
|
- Time=eventItem.OccuringTime.ToString(),
|
|
|
- TargetChamber=eventItem.Source,
|
|
|
- Detail=eventItem.Description,
|
|
|
+ SearchedResult.Insert(0, new Aitex.Core.UI.View.Common.SystemLogItem()
|
|
|
+ {
|
|
|
+ ID = eventItem.Id.ToString(),
|
|
|
+ LogType = eventItem.Level.ToString(),
|
|
|
+ Time = eventItem.OccuringTime.ToString(),
|
|
|
+ TargetChamber = eventItem.Source,
|
|
|
+ Detail = eventItem.Description,
|
|
|
Icon = new BitmapImage(new Uri(string.Format("pack://application:,,,/MECF.Framework.Common;component/Resources/SystemLog/{0}.png", eventItem.Level.ToString()), UriKind.Absolute))
|
|
|
|
|
|
}
|
|
@@ -151,7 +193,7 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
});
|
|
|
break;
|
|
|
case EventType.Dialog_Nofity:
|
|
|
- //PopDialog(obj);
|
|
|
+ //PopDialog(eventItem);
|
|
|
break;
|
|
|
case EventType.KickOut_Notify:
|
|
|
break;
|
|
@@ -172,8 +214,13 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
this.view = (EventView)eventView;
|
|
|
this.view.wfTimeFrom.Value = this.SearchBeginTime;
|
|
|
this.view.wfTimeTo.Value = this.SearchEndTime;
|
|
|
+ this.view.pageControl.CurrentPageChanged += PageControl_CurrentPageChanged;
|
|
|
this.Preload();
|
|
|
}
|
|
|
+ private void PageControl_CurrentPageChanged(int currentPage)
|
|
|
+ {
|
|
|
+ PageChanged(currentPage);
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 预先载入数据
|
|
|
/// </summary>
|
|
@@ -198,7 +245,7 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
|
|
|
//第一次默认查询
|
|
|
//if (SearchedResult == null)
|
|
|
- //Search();
|
|
|
+ //Search();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -274,128 +321,135 @@ namespace CyberX8_MainPages.ViewModels
|
|
|
{
|
|
|
Task.Factory.StartNew(() =>
|
|
|
{
|
|
|
- try
|
|
|
+ this.view.Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
- SearchedResult = new ObservableCollection<Aitex.Core.UI.View.Common.SystemLogItem>();
|
|
|
- this.SearchBeginTime = this.view.wfTimeFrom.Value;
|
|
|
- this.SearchEndTime = this.view.wfTimeTo.Value;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ this.SearchBeginTime = this.view.wfTimeFrom.Value;
|
|
|
+ this.SearchEndTime = this.view.wfTimeTo.Value;
|
|
|
|
|
|
- string sqlEvent = "";
|
|
|
- string sqlOperationLog = "";
|
|
|
- string sql = "";
|
|
|
+ string test = $"SELECT COUNT(*) FROM \"event_data\" where \"occur_time\" >='{SearchBeginTime.ToString("yyyy/MM/dd HH:mm:ss")}' and \"occur_time\" <='{SearchEndTime.ToString("yyyy/MM/dd HH:mm:ss")}'";
|
|
|
|
|
|
- if (SearchAlarmEvent || SearchWarningEvent || SearchInfoEvent)
|
|
|
- {
|
|
|
- sqlEvent = string.Format("SELECT \"event_id\", \"event_enum\", \"type\", \"occur_time\", \"level\",\"source\" , \"description\" FROM \"event_data\" where \"occur_time\" >='{0}' and \"occur_time\" <='{1}' ", SearchBeginTime.ToString("yyyyMMdd HHmmss"), SearchEndTime.ToString("yyyyMMdd HHmmss"));
|
|
|
+ test += SearchSqlString();
|
|
|
|
|
|
- sqlEvent += GetSourceWhere();
|
|
|
+ Total = QueryDataClient.Instance.Service.GetDBEventAllCount(test);
|
|
|
|
|
|
- sqlEvent += " and (FALSE ";
|
|
|
- if (SearchAlarmEvent) sqlEvent += " OR \"level\"='Alarm' ";
|
|
|
- if (SearchWarningEvent) sqlEvent += " OR \"level\"='Warning' ";
|
|
|
- if (SearchInfoEvent) sqlEvent += " OR \"level\"='Information' ";
|
|
|
- sqlEvent += " ) ";
|
|
|
+ PageCount = (Total / m_onePageCounts) + 1;
|
|
|
|
|
|
- if (!string.IsNullOrWhiteSpace(SelectedEvent) && SelectedEvent != "All") sqlEvent += string.Format(" and lower(\"event_enum\")='{0}' ", SelectedEvent.ToLower());
|
|
|
|
|
|
- //if (!string.IsNullOrWhiteSpace(SearchKeyWords)) sqlEvent += string.Format(" and lower(\"description\") like '%{0}%' ", SearchKeyWords.ToLower());
|
|
|
- if (!string.IsNullOrWhiteSpace(SearchKeyWords)) sqlEvent += string.Format(" and lower(\"description\") like '%{0}%' or lower(\"type\") like '%{1}%'", SearchKeyWords.ToLower(), SearchKeyWords.ToLower());
|
|
|
+ SearchedResult = new ObservableCollection<Aitex.Core.UI.View.Common.SystemLogItem>();
|
|
|
+ PageQuery(CurrentPage);
|
|
|
}
|
|
|
-
|
|
|
- if (SearchOpeLog)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- //sqlOperationLog = string.Format(" SELECT \"UserName\" as \"Initiator\", 'UserOperation' as \"LogType\", \"Time\", \"ChamberId\" as \"TargetChamber\", \"Content\" as \"Description\" FROM \"OperationLog\" where \"Time\" >='{0}' and \"Time\" <='{1}' ", SearchBeginTime.ToString("yyyy/MM/dd HH:mm:ss"), SearchEndTime.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
|
-
|
|
|
- //if (!SearchPMA) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.ReactorA);
|
|
|
- //if (!SearchPMB) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.ReactorB);
|
|
|
- //if (!SearchPMC) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.ReactorC);
|
|
|
- //if (!SearchPMD) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.ReactorD);
|
|
|
- //if (!SearchSystem) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.System);
|
|
|
- //if (!SearchLL) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' ", ChamberSet.Loadlock);
|
|
|
- //if (!SearchTM) sqlOperationLog += string.Format(" and \"ChamberId\"<>'{0}' and \"ChamberId\"<>'{1}' and \"ChamberId\"<>'{2}' ",
|
|
|
- // ChamberSet.Loadlock, ChamberSet.Buffer1, ChamberSet.Cooldown);
|
|
|
- //if (!string.IsNullOrWhiteSpace(SelectedUser) && SelectedUser != "不限") sqlOperationLog += string.Format(" and lower(\"UserName\")='{0}' ", SelectedUser.ToLower());
|
|
|
-
|
|
|
- //if (!string.IsNullOrWhiteSpace(SearchKeyWords)) sqlOperationLog += string.Format(" and lower(\"Content\") like '%{0}%' ", SearchKeyWords.ToLower());
|
|
|
+ //LOG.Write(ex);
|
|
|
+ LOG.WriteExeption(ex);
|
|
|
}
|
|
|
+ });
|
|
|
|
|
|
- sql = sqlEvent;
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(sqlOperationLog))
|
|
|
- {
|
|
|
- if (string.IsNullOrEmpty(sql))
|
|
|
- {
|
|
|
- sql = sqlOperationLog;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql += " UNION ALL " + sqlOperationLog;
|
|
|
- }
|
|
|
- }
|
|
|
+ private void PageQuery(int pageIndex)
|
|
|
+ {
|
|
|
+ SearchedResult = new ObservableCollection<Aitex.Core.UI.View.Common.SystemLogItem>();
|
|
|
+ this.SearchBeginTime = this.view.wfTimeFrom.Value;
|
|
|
+ this.SearchEndTime = this.view.wfTimeTo.Value;
|
|
|
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(sql) && QueryDBEventFunc != null)
|
|
|
- {
|
|
|
- sql += " order by \"occur_time\" DESC limit 2000;";
|
|
|
+ string sqlEvent = "";
|
|
|
+ string sql = "";
|
|
|
+ sqlEvent = string.Format("SELECT \"event_id\", \"event_enum\", \"type\", \"occur_time\", \"level\",\"source\" , \"description\" FROM \"event_data\" where \"occur_time\" >='{0}' and \"occur_time\" <='{1}' ", SearchBeginTime.ToString("yyyy/MM/dd HH:mm:ss"), SearchEndTime.ToString("yyyy/MM/dd HH:mm:ss"));
|
|
|
+ sqlEvent += SearchSqlString();
|
|
|
|
|
|
- List<EventItem> lstEvent = QueryDBEventFunc(sql);
|
|
|
|
|
|
- if (lstEvent == null)
|
|
|
- return;
|
|
|
|
|
|
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
- string logTypeStr;
|
|
|
-
|
|
|
- foreach (EventItem ev in lstEvent)
|
|
|
- {
|
|
|
- switch (ev.Level)
|
|
|
- {
|
|
|
- case EventLevel.Information: logTypeStr = "Info"; break;
|
|
|
- case EventLevel.Warning: logTypeStr = "Warning"; break;
|
|
|
- case EventLevel.Alarm: logTypeStr = "Alarm"; break;
|
|
|
- default: logTypeStr = "Undefine"; break;
|
|
|
- }
|
|
|
-
|
|
|
- SearchedResult.Add(new Aitex.Core.UI.View.Common.SystemLogItem()
|
|
|
- {
|
|
|
- ID = ev.Id.ToString() ,
|
|
|
- Time = ((DateTime)ev.OccuringTime).ToString("yyyy/MM/dd HH:mm:ss.fff"),
|
|
|
- LogType = logTypeStr,
|
|
|
- Detail = ev.Description,
|
|
|
- TargetChamber = ev.Source,
|
|
|
- Initiator = "",
|
|
|
- Icon = new BitmapImage(new Uri(string.Format("pack://application:,,,/MECF.Framework.Common;component/Resources/SystemLog/{0}.png", ev.Level.ToString()), UriKind.Absolute))
|
|
|
- }); ;
|
|
|
- }
|
|
|
- RaisePropertyChanged("SearchedResult");
|
|
|
-
|
|
|
- if (SearchedResult.Count >= 2000)
|
|
|
- {
|
|
|
- //MessageBox.Show("Only display max 2000 items,reset the query condition", "query too many result", MessageBoxButton.OK, MessageBoxImage.Warning);
|
|
|
- }
|
|
|
-
|
|
|
- }));
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+ sql = sqlEvent;
|
|
|
+ sql += $" order by \"occur_time\" ASC limit {m_onePageCounts} offset {(pageIndex - 1) * m_onePageCounts};";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(sql) && QueryDBEventFunc != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ List<EventItem> lstEvent = QueryDBEventFunc(sql);
|
|
|
+
|
|
|
+ if (lstEvent == null)
|
|
|
+ return;
|
|
|
+ string logTypeStr;
|
|
|
+
|
|
|
+ foreach (EventItem ev in lstEvent)
|
|
|
+ {
|
|
|
+ switch (ev.Level)
|
|
|
{
|
|
|
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
|
- {
|
|
|
- SearchedResult = new ObservableCollection<Aitex.Core.UI.View.Common.SystemLogItem>();
|
|
|
- RaisePropertyChanged("SearchedResult");
|
|
|
- }));
|
|
|
+ case EventLevel.Information: logTypeStr = "Info"; break;
|
|
|
+ case EventLevel.Warning: logTypeStr = "Warning"; break;
|
|
|
+ case EventLevel.Alarm: logTypeStr = "Alarm"; break;
|
|
|
+ default: logTypeStr = "Undefine"; break;
|
|
|
}
|
|
|
+
|
|
|
+ SearchedResult.Add(new Aitex.Core.UI.View.Common.SystemLogItem()
|
|
|
+ {
|
|
|
+ ID = ev.Id.ToString(),
|
|
|
+ Time = ((DateTime)ev.OccuringTime).ToString("yyyy/MM/dd HH:mm:ss.fff"),
|
|
|
+ LogType = logTypeStr,
|
|
|
+ Detail = ev.Description,
|
|
|
+ TargetChamber = ev.Source,
|
|
|
+ Initiator = "",
|
|
|
+ Icon = new BitmapImage(new Uri(string.Format("pack://application:,,,/MECF.Framework.Common;component/Resources/SystemLog/{0}.png", ev.Level.ToString()), UriKind.Absolute))
|
|
|
+ }); ;
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ RaisePropertyChanged("SearchedResult");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SearchedResult = new ObservableCollection<Aitex.Core.UI.View.Common.SystemLogItem>();
|
|
|
+ RaisePropertyChanged("SearchedResult");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void PageChanged(int CurrentPage)
|
|
|
+ {
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ this.view.Dispatcher.Invoke(() =>
|
|
|
{
|
|
|
- //LOG.Write(ex);
|
|
|
- LOG.WriteExeption(ex);
|
|
|
- }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ PageQuery(CurrentPage);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LOG.WriteExeption(ex);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
+ public string SearchSqlString()
|
|
|
+ {
|
|
|
+ this.SearchBeginTime = this.view.wfTimeFrom.Value;
|
|
|
+ this.SearchEndTime = this.view.wfTimeTo.Value;
|
|
|
|
|
|
+ string sqlEvent = "";
|
|
|
+
|
|
|
+ string sql = "";
|
|
|
+
|
|
|
+
|
|
|
+ //sqlEvent = string.Format("SELECT \"event_id\", \"event_enum\", \"type\", \"occur_time\", \"level\",\"source\" , \"description\" FROM \"event_data\" where \"occur_time\" >='{0}' and \"occur_time\" <='{1}' ", SearchBeginTime.ToString("yyyyMMdd HHmmss"), SearchEndTime.ToString("yyyyMMdd HHmmss"));
|
|
|
+
|
|
|
+ sqlEvent += " and (FALSE ";
|
|
|
+ if (SearchAlarmEvent) sqlEvent += " OR \"level\"='Alarm' ";
|
|
|
+ if (SearchWarningEvent) sqlEvent += " OR \"level\"='Warning' ";
|
|
|
+ if (SearchInfoEvent) sqlEvent += " OR \"level\"='Information' ";
|
|
|
+
|
|
|
+ sqlEvent += " ) ";
|
|
|
+ sql = sqlEvent;
|
|
|
+
|
|
|
+
|
|
|
+ return sql;
|
|
|
+
|
|
|
+ }
|
|
|
private EventView view;
|
|
|
#endregion
|
|
|
}
|