You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
3.4 KiB
C#
112 lines
3.4 KiB
C#
using NPOI.SS.UserModel;
|
|
using NPOI.XSSF.UserModel;
|
|
using Rs.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.MotionPlat.Entitys
|
|
{
|
|
public static class AlarmCollection
|
|
{
|
|
private static Dictionary<int,AlarmEntity> alarmDic = new Dictionary<int,AlarmEntity>();
|
|
|
|
static AlarmCollection()
|
|
{
|
|
Load();
|
|
}
|
|
|
|
public static void Load()
|
|
{
|
|
alarmDic.Clear();
|
|
XSSFWorkbook book;
|
|
FileStream fs = File.Open("Dorxx 报警文本(中英韩).xlsx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
book = new XSSFWorkbook(fs);
|
|
fs.Close();
|
|
if(book!=null)
|
|
{
|
|
ISheet sheet = book.GetSheetAt(0);
|
|
if(sheet!=null)
|
|
{
|
|
int rowNum = sheet.LastRowNum;
|
|
if(rowNum>2)
|
|
{
|
|
for(int i=1;i<rowNum; i++)
|
|
{
|
|
AlarmEntity entity = new AlarmEntity();
|
|
IRow row = sheet.GetRow(i);
|
|
ICell cell = row.GetCell(0);
|
|
entity.AlartID = int.Parse(cell.NumericCellValue.ToString().Trim());
|
|
cell = row.GetCell(2);
|
|
if (cell != null)
|
|
entity.CN = cell.StringCellValue;
|
|
cell = row.GetCell(3);
|
|
if (cell != null)
|
|
entity.EN = cell.StringCellValue;
|
|
cell = row.GetCell(4);
|
|
if (cell != null)
|
|
entity.KO = cell.StringCellValue;
|
|
if(!alarmDic.ContainsKey(entity.AlartID))
|
|
{
|
|
alarmDic.Add(entity.AlartID, entity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static AlarmEntity Get(int _alarmID)
|
|
{
|
|
if(alarmDic.Count>0 && alarmDic.ContainsKey(_alarmID))
|
|
return alarmDic[_alarmID];
|
|
return null;
|
|
}
|
|
|
|
public static string GetAlarm(int _alarmID)
|
|
{
|
|
StringBuilder content = new StringBuilder();
|
|
AlarmEntity alarm = Get(_alarmID);
|
|
if(alarm!=null)
|
|
{
|
|
if(GlobalVar.MsgShowCn)
|
|
{
|
|
content.Append(alarm.CN).Append("\r\n\r\n");
|
|
}
|
|
if (GlobalVar.MsgShowEn)
|
|
{
|
|
content.Append(alarm.EN).Append("\r\n\r\n");
|
|
}
|
|
if (GlobalVar.MsgShowKo)
|
|
{
|
|
content.Append(alarm.KO);
|
|
}
|
|
return content.ToString();
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
public class AlarmEntity
|
|
{
|
|
/// <summary>
|
|
/// 报警编号
|
|
/// </summary>
|
|
public int AlartID { get; set; }
|
|
/// <summary>
|
|
/// 中文
|
|
/// </summary>
|
|
public string CN { get; set; }
|
|
/// <summary>
|
|
/// 英文
|
|
/// </summary>
|
|
public string EN { get; set; }
|
|
/// <summary>
|
|
/// 韩文
|
|
/// </summary>
|
|
public string KO { get; set; }
|
|
}
|
|
}
|