日志记录

dep
杨威 5 months ago
parent 6bec63679a
commit baace36f1d

@ -0,0 +1,31 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.FreeDb
{
[Table(Name = "WarnTable")]
public class WarnTable
{
/// <summary>
/// 主键
/// </summary>
[Column(IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
public int AlarmId { get; set; }
public string CnInfo { get; set; }
public string OtherInfo { get; set; }
public DateTime CreateTime { get; set; }
public DateTime UpdateTime { get; set; }
public int Num { get; set; }
public int Status { get; set; }
}
}

@ -30,6 +30,9 @@ using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
using Mesnac.Core.Service;
using Mesnac.Basic;
using Mesnac.Action.ChemicalWeighing.Util;
using DevExpress.XtraRichEdit.Import.Doc;
using System.Threading.Tasks;
using DevExpress.Utils.Filtering.Internal;
namespace Mesnac.Action.ChemicalWeighing.MainDetailControl
{
@ -277,7 +280,7 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl
conCurrentCache.Clear();
}
}
int bao = 0;
/// <summary>
/// Plc读数线程池定时器退出删除
/// </summary>
@ -510,7 +513,27 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl
ThreadPool.QueueUserWorkItem(new WaitCallback(NewThread));
AlarmControl();
if (bao > 2)
{
bao = 0;
try
{
ThreadPool.QueueUserWorkItem((ty) =>
{
AlarmControl();
});
}
catch (Exception)
{
bao = 0;
}
}
bao += 1;
//现有报警刷新
var db2110 = new Db2110Help();
@ -881,35 +904,92 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl
b3 = DB2103.bytes;
b7 = DB2107.bytes;
StringBuilder sb = new StringBuilder();
List<WarnTable> list = new List<WarnTable>();
StringBuilder sb = new StringBuilder();
//string nowtime = DateTime.Now.ToString();
//报警点位遍历
foreach (DataRow rows in AllAlarmTable.Rows)
{
int Alarm_ID = Convert.ToInt32(rows["Alarm_ID"]);
string otherInfo = rows["Alarm_Other_Info"].ToString();
string cnInfo = rows["Alarm_Cn_Info"].ToString();
WarnTable warnTable = new WarnTable();
warnTable.CnInfo = cnInfo;
warnTable.AlarmId = Alarm_ID;
warnTable.OtherInfo = otherInfo;
warnTable.CreateTime = DateTime.Now;
warnTable.UpdateTime = DateTime.Now;
if ((int)rows["Alarm_Block"] == 2102 && b2[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true)
{
sb.Append(rows["Alarm_Other_Info"].ToString());
sb.Append(" ");
sb.Append(rows["Alarm_Cn_Info"].ToString());
sb.Append(@" \ ");
warnTable.Status = 1;
}
else
{
warnTable.Status = 0;
}
else if ((int)rows["Alarm_Block"] == 2107 && b7[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true)
if ((int)rows["Alarm_Block"] == 2107 && b7[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true)
{
sb.Append(rows["Alarm_Other_Info"].ToString());
sb.Append(" ");
sb.Append(rows["Alarm_Cn_Info"].ToString());
sb.Append(@" \ ");
warnTable.Status = 1;
}
else
{
warnTable.Status = 0;
}
else if ((int)rows["Alarm_Block"] == 2103 && b3[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true)
if ((int)rows["Alarm_Block"] == 2103 && b3[(int)rows["Alarm_Word"]].GetBit((int)rows["Alarm_bit"]) == true)
{
sb.Append(rows["Alarm_Other_Info"].ToString());
sb.Append(" ");
sb.Append(rows["Alarm_Cn_Info"].ToString());
sb.Append(@" \ ");
warnTable.Status = 1;
}
else
{
warnTable.Status = 0;
}
list.Add(warnTable);
}
var Sql = FreeDb.FreeSqlUnit.Instance;
long cou = Sql.Queryable<WarnTable>().Count();
if (cou > 50000)
{
Sql.Delete<WarnTable>().Where(x => x.CreateTime < DateTime.Now).ExecuteAffrows();
}
//只记录等于1的
var ls=list.Where(x=>x.Status==1);
Sql.Insert<WarnTable>(ls).ExecuteInserted();
string str = sb.ToString();
if (string.IsNullOrWhiteSpace(str))
{
@ -928,6 +1008,9 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl
}
}
#endregion
#region 图像数据读取、控件赋值

@ -286,6 +286,7 @@
<Compile Include="FreeDb\DBEntity\WaterDownloadEntity.cs" />
<Compile Include="FreeDb\DryDownloadDetail.cs" />
<Compile Include="FreeDb\FreeSqlUnit.cs" />
<Compile Include="FreeDb\WarnTable.cs" />
<Compile Include="InterfaceDocking\DockingEntity\JsonReturnEntity.cs" />
<Compile Include="InterfaceDocking\DockingEntity\MaterialPlanSyncEntity.cs" />
<Compile Include="InterfaceDocking\DockingEntity\TankDeviceStateSyncEntity.cs" />

@ -1,3 +1,3 @@
<DataSources>
<DataSourceItem Name="DataSource1" Driver="MS SQL Server" Server="172.18.4.130" UserName="sa" Password="123456" DataBase="CWSSHG" ConnectionTimeout="10" DriverAssembly="ICSharpCode.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DriverClass="ICSharpCode.Data.Core.DatabaseDrivers.SQLServer.SQLServerDatabaseDriver" DataSourceClass="ICSharpCode.Data.Core.DatabaseObjects.Database" />
<DataSourceItem Name="DataSource1" Driver="MS SQL Server" Server="172.18.4.130" UserName="sa" Password="123456" DataBase="CWSSHG" ConnectionTimeout="20" DriverAssembly="ICSharpCode.Data.SQLServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" DriverClass="ICSharpCode.Data.Core.DatabaseDrivers.SQLServer.SQLServerDatabaseDriver" DataSourceClass="ICSharpCode.Data.Core.DatabaseObjects.Database" />
</DataSources>
Loading…
Cancel
Save