1339 lines
57 KiB
C#
1339 lines
57 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using CRVM.Utility;
|
|||
|
|
using System.Xml;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Data;
|
|||
|
|
using CRVM.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace CRVM.CIDExcuter
|
|||
|
|
{
|
|||
|
|
public class DbHelper
|
|||
|
|
{
|
|||
|
|
private string _path;
|
|||
|
|
private LogicConnect DBlogicConn;
|
|||
|
|
private LogicConnect l2Connect;
|
|||
|
|
private LogicConnect localConnect;
|
|||
|
|
private EDBItem soudb;
|
|||
|
|
private EDBItem desdb;
|
|||
|
|
private int freq = 5;//频率(秒)
|
|||
|
|
private static DbHelper _instance = null;
|
|||
|
|
|
|||
|
|
private string coldid_before = "";
|
|||
|
|
|
|||
|
|
public EDBItem SouDB
|
|||
|
|
{
|
|||
|
|
get { return soudb; }
|
|||
|
|
set { soudb = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public EDBItem DesDB
|
|||
|
|
{
|
|||
|
|
get { return desdb; }
|
|||
|
|
set { desdb = value; }
|
|||
|
|
}
|
|||
|
|
public int Freq
|
|||
|
|
{
|
|||
|
|
get { return freq; }
|
|||
|
|
set { freq = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DbHelper(string path)
|
|||
|
|
{
|
|||
|
|
_path = path;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static DbHelper GetInstance(string path)
|
|||
|
|
{
|
|||
|
|
if (_instance == null)
|
|||
|
|
{
|
|||
|
|
_instance = new DbHelper(path);
|
|||
|
|
_instance.DesDB = new EDBItem();
|
|||
|
|
_instance.SouDB = new EDBItem();
|
|||
|
|
}
|
|||
|
|
return _instance;
|
|||
|
|
}
|
|||
|
|
public bool isStart { get; set; }
|
|||
|
|
|
|||
|
|
public bool LoadConfigData(DbHelper dbhelper)
|
|||
|
|
{
|
|||
|
|
XmlDocument xmldoc = new XmlDocument();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string ipath = _path + "\\dbaccess.conf";
|
|||
|
|
if (File.Exists(ipath))
|
|||
|
|
{
|
|||
|
|
xmldoc.Load(ipath);
|
|||
|
|
string systemName = "";
|
|||
|
|
if (xmldoc.DocumentElement.Attributes.Count > 0)
|
|||
|
|
systemName = xmldoc.DocumentElement.Attributes[0].InnerText;
|
|||
|
|
XmlNodeList nodes = xmldoc.SelectNodes("Schm/DB");
|
|||
|
|
int count = nodes.Count;
|
|||
|
|
string DbName = nodes[0].Attributes[0].InnerText;
|
|||
|
|
soudb.DataType = nodes[0].ChildNodes[0].Attributes[0].InnerText;
|
|||
|
|
soudb.Database = nodes[0].ChildNodes[0].Attributes[1].InnerText;
|
|||
|
|
soudb.Userid = nodes[0].ChildNodes[0].Attributes[2].InnerText;
|
|||
|
|
soudb.Password = nodes[0].ChildNodes[0].Attributes[3].InnerText;
|
|||
|
|
soudb.Ipaddress = nodes[0].ChildNodes[0].Attributes[4].InnerText;
|
|||
|
|
string DestDbName = nodes[1].Attributes[0].InnerText;
|
|||
|
|
desdb.DataType = nodes[1].ChildNodes[0].Attributes[0].InnerText;
|
|||
|
|
desdb.Database = nodes[1].ChildNodes[0].Attributes[1].InnerText;
|
|||
|
|
desdb.Userid = nodes[1].ChildNodes[0].Attributes[2].InnerText;
|
|||
|
|
desdb.Password = nodes[1].ChildNodes[0].Attributes[3].InnerText;
|
|||
|
|
desdb.Ipaddress = nodes[1].ChildNodes[0].Attributes[4].InnerText;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (XmlException)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重设L2数据库操作对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SetL2Connect()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
l2Connect = new LogicConnect(soudb, soudb.Userid);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重设本地数据库操作对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SetLocalConnect()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
localConnect = new LogicConnect(desdb, desdb.Userid);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 剪切时向t_coil_info_client表中插入一条新纪录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="alarmFlag"></param>
|
|||
|
|
/// <param name="endFlag"></param>
|
|||
|
|
/// <param name="OrigPath"></param>
|
|||
|
|
/// <param name="EnergyPath"></param>
|
|||
|
|
/// <param name="disLength"></param>
|
|||
|
|
public void AddNewCoilInfo(int alarmFlag, int endFlag, string OrigPath, string EnergyPath, string disLength, int defectflag)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//将本次记录之前的当前卷标记全部置为0,保证当前卷标记唯一性
|
|||
|
|
string update_sql = "update t_coil_info_client set nowflag = 0 where nowflag = 1";
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
|
|||
|
|
//插入新纪录,并将当前卷标记置为1
|
|||
|
|
string insert_sql = string.Format("insert into t_coil_info_client (createdate,endflag,origPath,energyPath,alarmflag,nowflag,defectflag,disLength) values('{0}',{1},'{2}','{3}',{4},1,{5},{6})",
|
|||
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), endFlag, OrigPath, EnergyPath, alarmFlag, defectflag, disLength);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddNewCoilInfo", insert_sql.ToString());
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddNewCoilInfo", ex.ToString());
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddNewCoilInfo", String.Format("|OrigPath:{0},EnergyPath:{1}|" + ex.ToString(), OrigPath, EnergyPath));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 从L2数据库获取钢卷信息,补充到本地t_coil_info_client表,并将冷卷号更新到t_alarm_info_client表中
|
|||
|
|
/// 梅钢项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
public void UpdateLocalCoilInfo()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//获取L2钢卷信息表中最新的一条记录
|
|||
|
|
string sql_l2 = "select excoilid,entcoilid,length,innerdiam,outdiam,alloycode,extthick,extwidth,hentry from app.fv_vibration_proddata where rownum = 1";
|
|||
|
|
DataTable l2data = l2Connect.DataBase(sql_l2);
|
|||
|
|
|
|||
|
|
if (l2data != null)
|
|||
|
|
{
|
|||
|
|
if (l2data.Rows.Count != 0)
|
|||
|
|
{
|
|||
|
|
//若本次从L2获取的最新第一条记录的卷号与上次记录的卷号一致,则表示L2新卷号还没有生成
|
|||
|
|
if (l2data.Rows[0]["excoilid"].ToString().Trim() == coldid_before)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//根据L2信息更新本地t_coil_info_client表中热卷号、冷卷号、钢种牌号、宽度、入口厚度、出口厚度、钢种等级信息
|
|||
|
|
string coilinfo_update_sql = string.Format("update t_coil_info_client set hotcoilid='{0}',coldcoilid='{1}',alloycode='{2}',width={3},entrythick={4},exitthick={5} where nowflag = 1 and endflag = 1",
|
|||
|
|
l2data.Rows[0]["entcoilid"], l2data.Rows[0]["excoilid"], l2data.Rows[0]["alloycode"], Convert.ToDouble(l2data.Rows[0]["extwidth"]), Convert.ToDouble(l2data.Rows[0]["hentry"]), Convert.ToDouble(l2data.Rows[0]["extthick"]));
|
|||
|
|
localConnect.DataBase(coilinfo_update_sql);
|
|||
|
|
|
|||
|
|
//更新t_alarm_info_client中的冷卷号信息
|
|||
|
|
string alarm_update_sql = string.Format("update t_alarm_info_client set coldcoilid= '{0}' where nowflag= 1", l2data.Rows[0]["excoilid"]);
|
|||
|
|
localConnect.DataBase(alarm_update_sql);
|
|||
|
|
coldid_before = l2data.Rows[0]["excoilid"].ToString().Trim();//记录上一卷的冷卷号
|
|||
|
|
|
|||
|
|
//更新缺陷表中的钢卷号
|
|||
|
|
updateLocalDefectCoilNo(l2data.Rows[0]["excoilid"].ToString().Trim());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateLocalCoilInfo", ex.ToString());
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存数据库配置
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SaveConfigData()
|
|||
|
|
{
|
|||
|
|
StreamWriter write = new StreamWriter(_path + "\\dbaccess.conf", false, Encoding.GetEncoding("gb2312"));
|
|||
|
|
StringBuilder str = new StringBuilder();
|
|||
|
|
str = str.AppendLine("<?xml version=\"1.0\" encoding=\"GB2312\" ?> ");
|
|||
|
|
str = str.AppendLine("<Schm BPLATURE=\"BPCSYSTEM\">");
|
|||
|
|
str = str.AppendLine(" <DB name=\"sourcedb\">");
|
|||
|
|
if (soudb != null)
|
|||
|
|
{
|
|||
|
|
str = str.AppendLine(" <item dbtype=\"" + soudb.DataType + "\" dbname=\"" + soudb.Database + "\" dbuser=\"" + soudb.Userid + "\" dbpwd=\"" + soudb.Password + "\" dbip=\"" + soudb.Ipaddress + "\" />");
|
|||
|
|
}
|
|||
|
|
str = str.AppendLine(" </DB>");
|
|||
|
|
str = str.AppendLine(" <DB name=\"destdb\">");
|
|||
|
|
if (desdb != null)
|
|||
|
|
{
|
|||
|
|
str = str.AppendLine(" <item dbtype=\"" + desdb.DataType + "\" dbname=\"" + desdb.Database + "\" dbuser=\"" + desdb.Userid + "\" dbpwd=\"" + desdb.Password + "\" dbip=\"" + desdb.Ipaddress + "\" />");
|
|||
|
|
}
|
|||
|
|
str = str.AppendLine(" </DB>");
|
|||
|
|
str = str.AppendLine("</Schm>");
|
|||
|
|
write.WriteLine(str.ToString());
|
|||
|
|
write.Close();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 测试数据库是否连接成功
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="item"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool IsConnected(EDBItem item)
|
|||
|
|
{
|
|||
|
|
DBlogicConn = new LogicConnect(item, item.Userid);
|
|||
|
|
DataTable dt = new DataTable();
|
|||
|
|
if (item.DataType == "oracle")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select * from all_tables");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (item.DataType == "postgres")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select * from pg_am");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (item.DataType == "db2")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select tabname from syscat.tables where tabschema = current schema");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 当前文件结束后在t_alarm_info_client表中插入本文件对应的报警信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="start"></param>
|
|||
|
|
/// <param name="end"></param>
|
|||
|
|
/// <param name="coilNo"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
/// <param name="alarmType"></param>
|
|||
|
|
/// <param name="energy"></param>
|
|||
|
|
public void InsertAlarmInfo(int[] start, int[] end, int[] standNo, int[] alarmType, double[] energy)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//将t_alarm_info_client表中当前卷标志全部置为0
|
|||
|
|
string update_sql = "update t_alarm_info_client set nowflag = 0 where nowflag = 1";
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
|
|||
|
|
//插入新纪录,并将新纪录的当前卷标志置为1
|
|||
|
|
DateTime nowtime = DateTime.Now;
|
|||
|
|
for (int i = 0; i < start.Length; i++)
|
|||
|
|
{
|
|||
|
|
string time = nowtime.AddMilliseconds(-i).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|||
|
|
string insert_sql = string.Format("insert into t_alarm_info_client (createdate,startpos,endpos,standno,alarmtype,energy,nowflag) values('{0}',{1},{2},{3},{4},{5},1)",
|
|||
|
|
time, start[i], end[i], standNo[i] + 1, alarmType[i], energy[i]);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("InsertAlarmInfo", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="mac"></param>
|
|||
|
|
/// <param name="rolldata"></param>
|
|||
|
|
public void RollDataInfo(Machine mac, DataTable rolldata)
|
|||
|
|
{
|
|||
|
|
if (mac == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
mac.Stand[i].rollDiameterBL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterBU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterML = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterMU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWU = 10000.0;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (rolldata != null)
|
|||
|
|
{
|
|||
|
|
if (rolldata.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
mac.Stand[i].rollDiameterWU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 0]);
|
|||
|
|
mac.Stand[i].rollDiameterWL = Convert.ToDouble(rolldata.Rows[0][i * 6 + 1]);
|
|||
|
|
//中间辊 c102机组轧机无中间辊
|
|||
|
|
mac.Stand[i].rollDiameterMU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 2]);
|
|||
|
|
mac.Stand[i].rollDiameterML = Convert.ToDouble(rolldata.Rows[0][i * 6 + 3]);
|
|||
|
|
mac.Stand[i].rollDiameterBU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 4]);
|
|||
|
|
mac.Stand[i].rollDiameterBL = Convert.ToDouble(rolldata.Rows[0][i * 6 + 5]);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
mac.Stand[i].rollDiameterBL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterBU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterML = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterMU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWU = 10000.0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据L2轧辊信息更新本地轧辊表
|
|||
|
|
/// 梅钢项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
public void UpdateLocalRollData(DataTable data)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string nowtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
string update_sql = string.Format("insert into T_ROLL_DATA (createdate,rollno,standno,rolltype,rollposition,DiameterMiddle) values('{0}','{1}',{2},'{3}','{4}',{5})", nowtime,
|
|||
|
|
data.Rows[i]["rollno"], data.Rows[i]["standno"], data.Rows[i]["rolltype"].ToString(), data.Rows[i]["rollposition"], data.Rows[i]["diametermiddle"]);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateLocalRollData", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_roll_data表中所有的时刻点
|
|||
|
|
/// /// 梅钢项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelCreateTimeRolData()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = "select distinct createdate from t_roll_data";
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_roll_data表中某个时刻点的轧辊数据
|
|||
|
|
/// 梅钢项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="createdate"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelRollDataByCreateDate(string createdate)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select rollno,diametermiddle,standno,rollposition,rolltype from t_roll_data where createdate='{0}'", createdate);
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取L2在线轧辊信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetL2OnlineRollInfo()
|
|||
|
|
{
|
|||
|
|
string std_sql = "select ";
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
std_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", (i + 1).ToString());
|
|||
|
|
}
|
|||
|
|
std_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", (SysParam.Instance.SpeedChannelCount).ToString());
|
|||
|
|
std_sql += " from t_roll_online where seqno=1";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string select_sql = "select standno,rollposition,to_char(diametermiddle/1000,'9999.99') as diametermiddle,rolltype,rollno from app.fv_vibration_rolldata where rollstatus='I'";
|
|||
|
|
//string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
//string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
//string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
//string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
//string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "5");
|
|||
|
|
//string stand6_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "6");
|
|||
|
|
//string select_sql = "select " + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + stand6_sql + " from t_roll_online where seqno=1";
|
|||
|
|
//return localConnect.DataBase(select_sql);
|
|||
|
|
return localConnect.DataBase(std_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 验证用户输入的密码是否正确
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="password"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool IsUser(string password)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select * from t_users where pswd='{0}' and name = 'tcm'", password);
|
|||
|
|
DataTable dt = localConnect.DataBase(select_sql);
|
|||
|
|
|
|||
|
|
if (dt.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_coil_info_client表中所有的冷卷号
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<string> SelAllCoilIDs()
|
|||
|
|
{
|
|||
|
|
List<string> coillist = new List<string>();
|
|||
|
|
string select_sql = "select coldcoilno from t_coil_info_client";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable data = localConnect.DataBase(select_sql);
|
|||
|
|
if (data != null)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
coillist.Add(data.Rows[i]["coldcoilno"].ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return coillist;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改用户密码
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="newpswd"></param>
|
|||
|
|
public void ChangePassWord(string newpswd)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string update_sql = string.Format("update t_users set pswd='{0}' where name='tcm'", newpswd);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_alarm_info_client表中根据冷卷号搜索钢卷报警信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="coldcoilid"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelAlarmInfoByColdId(string coldcoilid)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select startpos,endpos,standno,alarmtype,energy from t_alarm_info_client where coldcoilid='{0}'", coldcoilid);
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_client表中搜索时间范围内的钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="isAlarm"></param>
|
|||
|
|
/// <param name="startTime"></param>
|
|||
|
|
/// <param name="endTime"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByDate(bool isAlarm, DateTime startTime, DateTime endTime)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_client where createdate<='{0}'and createdate>='{1}'", endTime, startTime);
|
|||
|
|
if (isAlarm)
|
|||
|
|
{
|
|||
|
|
select_sql += " and alarmflag = 1";
|
|||
|
|
}
|
|||
|
|
select_sql += " order by createdate desc";
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_client表中根据冷卷号搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="coldcoilno"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByColdId(string coldcoilno)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = "";
|
|||
|
|
if (coldcoilno.Trim() == "")
|
|||
|
|
{
|
|||
|
|
select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_client where coldcoilno = 'xxxxxxxxxx'", coldcoilno);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_client where coldcoilno like '%{0}%' ", coldcoilno);
|
|||
|
|
}
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_client表中根据原始数据路径搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="originPath"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByOriginPath(string originPath, Machine macReview)
|
|||
|
|
{
|
|||
|
|
string select_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
select_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", (i + 1).ToString());
|
|||
|
|
}
|
|||
|
|
select_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", SysParam.Instance.SpeedChannelCount.ToString());
|
|||
|
|
select_sql += string.Format(" from t_coil_info_client where origpath='{0}'", originPath);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string coil_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
|
|||
|
|
//string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
//string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
//string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
//string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
//string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "5");
|
|||
|
|
|
|||
|
|
//string where_sql = string.Format(" from t_coil_info_client where origpath='{0}'", originPath);
|
|||
|
|
//string sql = coil_sql + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + where_sql;
|
|||
|
|
//DataTable dt = localConnect.DataBase(sql);
|
|||
|
|
DataTable dt = localConnect.DataBase(select_sql);
|
|||
|
|
if (dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
macReview.review_coldcoilno = dt.Rows[0]["coldcoilno"].ToString();
|
|||
|
|
macReview.review_extThick = dt.Rows[0]["coldcoil_extthick"].ToString();
|
|||
|
|
macReview.review_alloyCode = dt.Rows[0]["coldcoil_alloycode"].ToString();
|
|||
|
|
macReview.review_steelGrade = dt.Rows[0]["coldcoil_steegrade"].ToString();
|
|||
|
|
macReview.review_width = dt.Rows[0]["coldcoil_extwidth"].ToString();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = Convert.ToDouble(dt.Rows[0]["wrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterWL = Convert.ToDouble(dt.Rows[0]["wrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterMU = Convert.ToDouble(dt.Rows[0]["imrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterML = Convert.ToDouble(dt.Rows[0]["imrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBU = Convert.ToDouble(dt.Rows[0]["burdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBL = Convert.ToDouble(dt.Rows[0]["burdialow" + (i + 1).ToString()]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DataTable errordt = new DataTable();
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterWL = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterMU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterML = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBL = 0;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetCoilInfoByOriginPath", ex.ToString());
|
|||
|
|
return errordt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_client表中根据能量数据路径搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="energyPath"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByEnergyPath(string energyPath, Machine macReview)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string select_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
select_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", (i + 1).ToString());
|
|||
|
|
}
|
|||
|
|
select_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", SysParam.Instance.SpeedChannelCount.ToString());
|
|||
|
|
select_sql += string.Format(" from t_coil_info_client where energypath='{0}'", energyPath);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string coil_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
|
|||
|
|
//string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
//string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
//string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
//string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
//string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "5");
|
|||
|
|
|
|||
|
|
//string where_sql = string.Format(" from t_coil_info_client where energypath='{0}'", energyPath);
|
|||
|
|
//string sql = coil_sql + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + where_sql;
|
|||
|
|
//DataTable dt = localConnect.DataBase(sql);
|
|||
|
|
DataTable dt = localConnect.DataBase(select_sql);
|
|||
|
|
if (dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
macReview.review_coldcoilno = dt.Rows[0]["coldcoilno"].ToString();
|
|||
|
|
macReview.review_extThick = dt.Rows[0]["coldcoil_extthick"].ToString();
|
|||
|
|
macReview.review_alloyCode = dt.Rows[0]["coldcoil_alloycode"].ToString();
|
|||
|
|
macReview.review_steelGrade = dt.Rows[0]["coldcoil_steegrade"].ToString();
|
|||
|
|
macReview.review_width = dt.Rows[0]["coldcoil_extwidth"].ToString();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = Convert.ToDouble(dt.Rows[0]["wrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterWL = Convert.ToDouble(dt.Rows[0]["wrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterMU = Convert.ToDouble(dt.Rows[0]["imrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterML = Convert.ToDouble(dt.Rows[0]["imrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBU = Convert.ToDouble(dt.Rows[0]["burdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBL = Convert.ToDouble(dt.Rows[0]["burdialow" + (i + 1).ToString()]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DataTable errordt = new DataTable();
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterWL = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterMU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterML = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBL = 0;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetCoilInfoByEnergyPath", ex.ToString());
|
|||
|
|
return errordt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool recordLocalDefectData(Dictionary<int, int> defectList, Dictionary<int, double> defectMaxEnergyValue)//剪切时插入本地数据库缺陷表
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (defectList.Count >= 1)
|
|||
|
|
{
|
|||
|
|
string coil_sql = "select coldcoilno,coldcoil_muid from t_coil_online where seqno=1 ";
|
|||
|
|
DataTable coil_dt = localConnect.DataBase(coil_sql);
|
|||
|
|
if (coil_dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
string coldcoilno = coil_dt.Rows[0]["coldcoilno"].ToString();
|
|||
|
|
string coldcoil_muid = coil_dt.Rows[0]["coldcoil_muid"].ToString();
|
|||
|
|
|
|||
|
|
if (coldcoilno.Trim() != "")
|
|||
|
|
{
|
|||
|
|
string update_sql = "update t_defect_data set ";
|
|||
|
|
int count = 0;
|
|||
|
|
foreach (KeyValuePair<int, int> item in defectList)
|
|||
|
|
{
|
|||
|
|
count++;
|
|||
|
|
if (count == 21)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
string tmp = " defectstart" + count.ToString() + "=" + item.Key.ToString() + ",";
|
|||
|
|
tmp += "defectend" + count.ToString() + "=" + item.Value.ToString() + ",";
|
|||
|
|
if (defectMaxEnergyValue.ContainsKey(item.Key))
|
|||
|
|
{
|
|||
|
|
tmp += "maxenergy" + count.ToString() + "=" + defectMaxEnergyValue[item.Key] + ",";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
tmp += "maxenergy" + count.ToString() + "=" + "0.0" + ",";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
update_sql = update_sql + tmp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = count; i <= 20; i++)
|
|||
|
|
{
|
|||
|
|
string tmp = " defectstart" + count.ToString() + "=0,";
|
|||
|
|
tmp += "defectend" + count.ToString() + "=0,";
|
|||
|
|
tmp += "maxenergy" + count.ToString() + "=0.0,";
|
|||
|
|
update_sql = update_sql + tmp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
update_sql += "coldcoilid='" + coldcoilno + "', muid=" + coldcoil_muid + ",sndflag=0";
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("update t_defect_data:", update_sql);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("read online table failed, info recordocalDefectData:", coil_sql);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//string sql = "update t_defect_data set ";//将表内当前所有的当前卷标记都置为0
|
|||
|
|
//try
|
|||
|
|
//{
|
|||
|
|
// localConnect.DataBase(sql);
|
|||
|
|
|
|||
|
|
// sql = "";
|
|||
|
|
// DateTime nowtime = DateTime.Now;
|
|||
|
|
// int index = 1;
|
|||
|
|
// foreach (KeyValuePair<int, int> item in defectList)
|
|||
|
|
// {
|
|||
|
|
// string time = nowtime.AddMilliseconds(-index).ToString("yyyy/MM/dd HH:mm:ss.fff");
|
|||
|
|
// string maxEnergyValue = "0.0";
|
|||
|
|
// //if (defectMaxEnergyValue.ContainsKey(item.Key))
|
|||
|
|
// //{
|
|||
|
|
// // maxEnergyValue = defectMaxEnergyValue[item.Key].ToString();
|
|||
|
|
// //}
|
|||
|
|
// sql += string.Format("insert into t_defect_data (defectstart,defectend,nowFlag,inserttime,defectindex,maxenergy) values ('{0}','{1}','1','{2}','{3}','{4}');", item.Key, item.Value, time, index, maxEnergyValue);
|
|||
|
|
// index++;
|
|||
|
|
// }
|
|||
|
|
// DevelopLog.DeBug.WriteLogFile("info recordocalDefectData:", sql);
|
|||
|
|
// localConnect.DataBase(sql);
|
|||
|
|
//}
|
|||
|
|
//catch (Exception ex)
|
|||
|
|
//{
|
|||
|
|
// DevelopLog.DeBug.WriteLogFile("error recordocalDefectData:", sql);
|
|||
|
|
// return false;
|
|||
|
|
//}
|
|||
|
|
//return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool updateLocalDefectCoilNo(string coldcoilId)//获取钢卷号时,更新缺陷表中的钢卷号
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("updateLocalDefectCoilNo:", coldcoilId);
|
|||
|
|
string sql = string.Format("update t_defect_data set coldcoilid = '{0}' where nowFlag = '1';", coldcoilId);//将表内当前卷标记的钢卷号更新
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
localConnect.DataBase(sql);
|
|||
|
|
//if (GetDefectSndStatus() == 1)
|
|||
|
|
//{
|
|||
|
|
// return updateL2DefectData(coldcoilId);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("updateLocalDefectCoilNo:", sql);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool updateL2DefectData(string coldcoilId)//根据卷号更新L2缺陷表
|
|||
|
|
{
|
|||
|
|
/*DataTable dt = new DataTable();
|
|||
|
|
dt = getLoaclDefectData(coldcoilId);//获取本地缺陷数据包括卷号
|
|||
|
|
if (dt == null || dt.Rows.Count == 0)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
string updatesql = "";
|
|||
|
|
|
|||
|
|
string MECREATOR = "PC";
|
|||
|
|
string MESID = "2";
|
|||
|
|
string SOURCE = "1";
|
|||
|
|
string ACTION = "1";
|
|||
|
|
string DEFCREATOR = "C502";
|
|||
|
|
string DEFSIDE = "2";
|
|||
|
|
string DEFTYPE = "51B1";
|
|||
|
|
string DEFECTTEXT = "zhendong";
|
|||
|
|
string INTENSITY = "1";
|
|||
|
|
string TURNFLAG = "1";
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (dt.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
LogicConnect con = new LogicConnect(soudb, soudb.Userid);
|
|||
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
string MEID = dt.Rows[i][3].ToString();
|
|||
|
|
string SID = dt.Rows[i][2].ToString();
|
|||
|
|
string DEFEND = dt.Rows[i][1].ToString();
|
|||
|
|
string DEFSTART = dt.Rows[i][0].ToString();
|
|||
|
|
string INTENSITYVAL = dt.Rows[i][4].ToString();
|
|||
|
|
|
|||
|
|
updatesql = string.Format("insert into DEFECT (MEID,MECREATOR,MESID,SID,SOURCE,ACTION,DEFCREATOR,DEFEND,DEFSIDE,DEFSTART,DEFTYPE,DEFECTTEXT,INTENSITY,INTENSITYVAL,TURNFLAG) values ({0},'{1}',{2},{3},'{4}',{5},'{6}',{7},'{8}',{9},'{10}','{11}','{12}',{13},{14})",
|
|||
|
|
MEID, MECREATOR, MESID, SID, SOURCE, ACTION, DEFCREATOR, DEFEND, DEFSIDE, DEFSTART, DEFTYPE, DEFECTTEXT, INTENSITY, INTENSITYVAL, TURNFLAG);
|
|||
|
|
con.DataBase(updatesql);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("infoupdateL2DefectData:", updatesql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("error:updateL2DefectData:", updatesql);
|
|||
|
|
return false;
|
|||
|
|
}*/
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DataTable getLoaclDefectData(string coldcoilid)//根据卷号获取本地缺陷数据
|
|||
|
|
{
|
|||
|
|
/*DataTable dt = new DataTable();
|
|||
|
|
string muidSql = "";
|
|||
|
|
string maxSidSql = "";
|
|||
|
|
string localDefectSql = "";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//查询muid
|
|||
|
|
LogicConnect con = new LogicConnect(soudb, soudb.Userid);
|
|||
|
|
muidSql = string.Format("select MEID2PH from SV_MEID where coldcoilid='{0}'", coldcoilid);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("infomuidSql:", muidSql);
|
|||
|
|
|
|||
|
|
string muid = "";
|
|||
|
|
dt = con.SelTableData("SV_MEID", muidSql);
|
|||
|
|
if (dt.Rows.Count != 1)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
muid = dt.Rows[0][0].ToString();
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("getLoaclDefectData muid:", muid);
|
|||
|
|
|
|||
|
|
//查询最大SID
|
|||
|
|
maxSidSql = string.Format("select max(SID) from DEFECT where meid='{0}'", muid);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("infomaxSidSql:", maxSidSql);
|
|||
|
|
|
|||
|
|
int maxSID = 0;
|
|||
|
|
dt = con.SelTableData("DEFECT", maxSidSql);
|
|||
|
|
if (dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
if (dt.Rows[0][0].ToString().Trim() != "")
|
|||
|
|
{
|
|||
|
|
maxSID = Convert.ToInt32(dt.Rows[0][0]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("getLoaclDefectData muid:", maxSID.ToString());
|
|||
|
|
|
|||
|
|
con = new LogicConnect(desdb, desdb.Userid);
|
|||
|
|
dt = new DataTable();
|
|||
|
|
localDefectSql = string.Format("select defectstart,defectend,defectindex,muid,maxEnergy from t_defect_data where coldcoilid='{0}'", coldcoilid);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("infolocalDefectSql:", localDefectSql);
|
|||
|
|
|
|||
|
|
dt = con.SelTableData("t_defect_data", localDefectSql);
|
|||
|
|
if (dt.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
dt.Rows[i][3] = muid;
|
|||
|
|
dt.Rows[i][2] = Convert.ToInt32(dt.Rows[i][2]) + maxSID;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("getLoaclDefectData:", localDefectSql);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("muidSql:", muidSql);
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("maxSidSql:", maxSidSql);
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
return dt;*/
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void recordLogInfo(string userName, string logInfo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = string.Format("insert into t_log_info (seqno,username,loginfo) values((select max(seqno) + 1 from t_log_info),'{0}','{1}')",
|
|||
|
|
userName, logInfo);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("recordLogInfo", ex.ToString());
|
|||
|
|
recordLogInfoFirst(userName, logInfo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public void recordLogInfoFirst(string userName, string logInfo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = string.Format("insert into t_log_info (seqno,username,loginfo) values(1,'{0}','{1}')",
|
|||
|
|
userName, logInfo);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("recordLogInfoFirst", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DataTable GetLogInfoByDate(DateTime startTime, DateTime endTime)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select seqno,to_char(toc,'YYYY-MM-DD HH24:MI:SS'),loginfo,username from t_log_info where toc<='{0}'and toc>='{1}' and seqno >0", endTime, startTime);
|
|||
|
|
|
|||
|
|
select_sql += " order by seqno desc";
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取基本配置参数,包括报警次数,采样点数等
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetBaseConfig()
|
|||
|
|
{
|
|||
|
|
string sql_str = "select key,value from t_dict_data;";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetAlarmParam()
|
|||
|
|
{
|
|||
|
|
string sql_str = "select standno,alarmspeed,lowpassl,lowpassu,lowalarmvalue,lowdefectvalue,midpassl," +
|
|||
|
|
"midpassu,midalarmvalue,middefectvalue,highpassl,highpassu,highalarmvalue,highdefectvalue," +
|
|||
|
|
"alarmtimes_l,alarmtimes_m,alarmtimes_h from t_alarm_param order by standno ,alarmspeed ;";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取指定机架的报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetAlarmParamByStanNo(int standNo)
|
|||
|
|
{
|
|||
|
|
string sql_str = "select alarmspeed,lowpassl,lowpassu,lowalarmvalue,lowdefectvalue,midpassl," +
|
|||
|
|
"midpassu,midalarmvalue,middefectvalue,highpassl,highpassu,highalarmvalue,higdefectvalue from t_alarm_param" +
|
|||
|
|
String.Format(" where standno={};", standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增报警参数记录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void AddAlarmParamByStandNo(EntityAlarmSpeed data, int standNo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = "insert into t_alarm_param (standno,alarmspeed,lowpassl," +
|
|||
|
|
"lowpassu,lowalarmvalue,lowdefectvalue,midpassl,midpassu,midalarmvalue,middefectvalue,highpassl," + String.Format("highpassu,highalarmvalue,highdefectvalue) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13})", standNo,
|
|||
|
|
data.alarmSpeed, data.lowPassL, data.lowPassU, data.lowAlarmValue, data.lowDefectValue, data.midPassL, data.midPassU,
|
|||
|
|
data.midAlarmValue, data.midDefectValue, data.highPassL, data.highPassU, data.highAlarmValue, data.highDefectValue);
|
|||
|
|
;
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddAlarmParamByStandNo", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 单个机架报警参数更新
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void UpdateAlarmParamByStandNo(IList<EntityAlarmSpeed> data, int standNo)
|
|||
|
|
{
|
|||
|
|
if (data == null || data.Count == 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (standNo > 0 && standNo < SysParam.Instance.SpeedChannelCount + 1)
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
DeleteAlarmParamByStandNo(standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
foreach (EntityAlarmSpeed item in data)
|
|||
|
|
{
|
|||
|
|
AddAlarmParamByStandNo(item, standNo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("SaveAlarmParam", String.Format("standno:{0},Error:", standNo) + ex.ToString());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
UpdateAlarmTimes(standNo, SysParam.Instance.channel[standNo - 1].alarmTimes_l,
|
|||
|
|
SysParam.Instance.channel[standNo - 1].alarmTimes_m,
|
|||
|
|
SysParam.Instance.channel[standNo - 1].alarmTimes_h);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除指定机架的报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void DeleteAlarmParamByStandNo(int standNo)
|
|||
|
|
{
|
|||
|
|
string delete_sql = String.Format("delete from t_alarm_param where standno = {0};", standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
localConnect.DataBase(delete_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存有速度机架的整个报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="datas"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SaveAlarmParam(Dictionary<int, IList<EntityAlarmSpeed>> datas)
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
foreach (KeyValuePair<int, IList<EntityAlarmSpeed>> items in datas)
|
|||
|
|
{
|
|||
|
|
if (items.Value != null && items.Value.Count > 0)
|
|||
|
|
{
|
|||
|
|
int standNoi = items.Key + 1;
|
|||
|
|
if (standNoi > 0 && standNoi < SysParam.Instance.SpeedChannelCount + 1)
|
|||
|
|
{
|
|||
|
|
DeleteAlarmParamByStandNo(standNoi);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
foreach (EntityAlarmSpeed item in items.Value)
|
|||
|
|
{
|
|||
|
|
AddAlarmParamByStandNo(item, standNoi);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("SaveAlarmParam", String.Format("standno:{0},Error:", standNoi) + ex.ToString());
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
UpdateAlarmTimes(i + 1, SysParam.Instance.channel[i].alarmTimes_l,
|
|||
|
|
SysParam.Instance.channel[i].alarmTimes_m,
|
|||
|
|
SysParam.Instance.channel[i].alarmTimes_h);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将数据库报警参数更新到系统
|
|||
|
|
/// </summary>
|
|||
|
|
public void autoUpdateAlarmParam()
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
DataTable eas = GetAlarmParam();
|
|||
|
|
if (eas == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Dictionary<int, IList<EntityAlarmSpeed>> config_base = new Dictionary<int, IList<EntityAlarmSpeed>>();
|
|||
|
|
for (int i = 0; i < eas.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DataRow row = eas.Rows[i];
|
|||
|
|
EntityAlarmSpeed itemdata = new EntityAlarmSpeed();
|
|||
|
|
int standNo = Convert.ToInt32(row["standno"]);
|
|||
|
|
itemdata.alarmSpeed = Convert.ToInt32(row["alarmspeed"]);
|
|||
|
|
itemdata.lowPassL = Convert.ToInt32(row["lowpassl"]);
|
|||
|
|
itemdata.lowPassU = Convert.ToInt32(row["lowpassu"]);
|
|||
|
|
itemdata.lowAlarmValue = Convert.ToSingle(row["lowalarmvalue"]);
|
|||
|
|
itemdata.lowDefectValue = Convert.ToSingle(row["lowdefectvalue"]);
|
|||
|
|
itemdata.midPassL = Convert.ToInt32(row["midpassl"]);
|
|||
|
|
itemdata.midPassU = Convert.ToInt32(row["midpassu"]);
|
|||
|
|
itemdata.midAlarmValue = Convert.ToSingle(row["midalarmvalue"]);
|
|||
|
|
itemdata.midDefectValue = Convert.ToSingle(row["middefectvalue"]);
|
|||
|
|
itemdata.highPassL = Convert.ToInt32(row["highpassl"]);
|
|||
|
|
itemdata.highPassU = Convert.ToInt32(row["highpassu"]);
|
|||
|
|
itemdata.highAlarmValue = Convert.ToSingle(row["highalarmvalue"]);
|
|||
|
|
itemdata.highDefectValue = Convert.ToSingle(row["highdefectvalue"]);
|
|||
|
|
|
|||
|
|
if (!config_base.ContainsKey(standNo - 1))
|
|||
|
|
{
|
|||
|
|
IList<EntityAlarmSpeed> itemlist = new List<EntityAlarmSpeed>();
|
|||
|
|
config_base.Add(standNo - 1, itemlist);
|
|||
|
|
}
|
|||
|
|
config_base[standNo - 1].Add(itemdata);
|
|||
|
|
}
|
|||
|
|
for (int j = 0; j < config_base.Keys.Count; j++)
|
|||
|
|
{
|
|||
|
|
SysParam.Instance.channel[j].alarmConfig = config_base[j].ToArray();//报警参数
|
|||
|
|
//eas.Select(String.Format("standno={0}", j + 1));
|
|||
|
|
DataRow dr = eas.Select(String.Format("standno={0}", j + 1))[0];
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_l = Convert.ToInt32(dr["alarmtimes_l"]);//报警次数
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_m = Convert.ToInt32(dr["alarmtimes_m"]);//报警次数
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_h = Convert.ToInt32(dr["alarmtimes_h"]);//报警次数
|
|||
|
|
}
|
|||
|
|
Console.WriteLine("test");
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam", ex.Message);
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
//DataTable kv = GetBaseConfig();
|
|||
|
|
//if (kv == null)
|
|||
|
|
//{
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// for (int i = 0; i < kv.Rows.Count; i++)
|
|||
|
|
// {
|
|||
|
|
// string keyi = Convert.ToString(kv.Rows[i]["key"]);
|
|||
|
|
// if (keyi == "alarmTimes_l" || keyi == "alarmTimes_m" || keyi == "alarmTimes_h")
|
|||
|
|
// {
|
|||
|
|
// for (int j = 0; j < SysParam.Instance.SpeedChannelCount; j++)
|
|||
|
|
// {
|
|||
|
|
// if (keyi == "alarmTimes_l")
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_l = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// else if (keyi == "alarmTimes_m")
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_m = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_h = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// //else if(keyi == "vibSens")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.channel[j].vibSens = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.channel[j].speedSens = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else
|
|||
|
|
// //{
|
|||
|
|
// // DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam-BaseConfig", "Error:参数异常,key="+keyi);
|
|||
|
|
// //}
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// //else if (keyi == "samplePoint")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.samplePoint = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else if (keyi == "sampleFre")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.sampleFre = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// catch (Exception ex)
|
|||
|
|
// {
|
|||
|
|
// DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam-BaseConfig", ex.Message);
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public void UpdateAlarmTimes(int standNo, int l, int m, int h)
|
|||
|
|
{
|
|||
|
|
if (l < 0 || m < 0 || h < 0 || standNo < 0 || standNo > SysParam.Instance.SpeedChannelCount)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateAlarmTimes",
|
|||
|
|
String.Format("参数异常:standNo={0},l={1},m={2},h={3}", standNo, l, m, h));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string update_sql = String.Format("update t_alarm_param set alarmtimes_l={0},alarmtimes_m={1},alarmtimes_h={2} where standno={3};", l, m, h, standNo);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateAlarmTimes", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|