|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Controls.Base;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using Mesnac.Action.Feeding.BasicInfo;
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.SynchroData
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 报警信息数据同步(导入旧版上辅机SCHEME.INI文件中[AlarmName]的数据)
|
|
|
/// </summary>
|
|
|
public class AlarmInfoSynchronous : FeedingAction, IAction
|
|
|
{
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
if (MessageBox.Show(Language(40), Language(1), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
|
{
|
|
|
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
|
|
|
ofd.Filter = "(*.INI)|*.INI";
|
|
|
DialogResult result = ofd.ShowDialog();
|
|
|
if (result == DialogResult.OK)
|
|
|
{
|
|
|
string iniFile = ofd.FileName;
|
|
|
bool returnFlag = false;
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
long lResult = 0;
|
|
|
try
|
|
|
{
|
|
|
StringBuilder strSql2 = new StringBuilder(@"truncate table Pmt_AlarmInfo;insert into Pmt_AlarmInfo(Alarm_address,Alarm_bit,Alarm_Name)");
|
|
|
int alarm_address1 = PlcData.Instance.AlarmData1.EquipData.Group.Start + PlcData.Instance.AlarmData1.EquipData.Start;
|
|
|
int alarm_address2 = PlcData.Instance.AlarmData2.EquipData.Group.Start + PlcData.Instance.AlarmData2.EquipData.Start;
|
|
|
int alarm_address3 = PlcData.Instance.AlarmData3.EquipData.Group.Start + PlcData.Instance.AlarmData3.EquipData.Start;
|
|
|
int alarm_address4 = PlcData.Instance.AlarmData4.EquipData.Group.Start + PlcData.Instance.AlarmData4.EquipData.Start;
|
|
|
|
|
|
for (int i = 0; i <= 15; i++)
|
|
|
{
|
|
|
lResult = Mesnac.Basic.Win32Tool.GetPrivateProfileString("AlarmName", i.ToString(), "END", sb, 100, iniFile);
|
|
|
if (sb.ToString() == "END")
|
|
|
{
|
|
|
returnFlag = true;
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (i == 0)
|
|
|
{
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address1, i, sb.ToString());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.AppendLine(" union all ");
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address1, i, sb.ToString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (returnFlag == false)
|
|
|
{
|
|
|
for (int i = 16; i <= 31; i++)
|
|
|
{
|
|
|
lResult = Mesnac.Basic.Win32Tool.GetPrivateProfileString("AlarmName", i.ToString(), "END", sb, 100, iniFile);
|
|
|
if (sb.ToString() == "END")
|
|
|
{
|
|
|
returnFlag = true;
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (i == 0)
|
|
|
{
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address2, i - 16, sb.ToString());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.AppendLine(" union all ");
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address2, i - 16, sb.ToString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (returnFlag == false)
|
|
|
{
|
|
|
for (int i = 32; i <= 47; i++)
|
|
|
{
|
|
|
lResult = Mesnac.Basic.Win32Tool.GetPrivateProfileString("AlarmName", i.ToString(), "END", sb, 100, iniFile);
|
|
|
if (sb.ToString() == "END")
|
|
|
{
|
|
|
returnFlag = true;
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (i == 0)
|
|
|
{
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address3, i - 32, sb.ToString());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.AppendLine(" union all ");
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address3, i - 32, sb.ToString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (returnFlag == false)
|
|
|
{
|
|
|
for (int i = 48; i <= 53; i++)
|
|
|
{
|
|
|
lResult = Mesnac.Basic.Win32Tool.GetPrivateProfileString("AlarmName", i.ToString(), "END", sb, 100, iniFile);
|
|
|
if (sb.ToString() == "END")
|
|
|
{
|
|
|
returnFlag = true;
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (i == 0)
|
|
|
{
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address4, i - 48, sb.ToString());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql2.AppendLine(" union all ");
|
|
|
strSql2.AppendFormat(" select {0},{1},'{2}' ", alarm_address4, i - 48, sb.ToString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DbHelper localHelper = base.NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
if (localHelper != null)
|
|
|
{
|
|
|
localHelper.CommandType = System.Data.CommandType.Text;
|
|
|
localHelper.ClearParameter();
|
|
|
localHelper.CommandText = strSql2.ToString();
|
|
|
localHelper.ExecuteNonQuery();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show(ex.Message, Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
runtime.IsReturn = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
runtime.IsReturn = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|