// Token: 0x060000A7 RID: 167 RVA: 0x0000544C File Offset: 0x0000364C
public void WriteOperMess(int MessKod, string Message)
{
try
{
int num = 0;
int num2 = 1;
SqlDb sqlDb = new SqlDb();
sqlDb.Open();
sqlDb.GetFieldType("PLCMESSAGE", "DTIME");
sqlDb.CreateDbCommand("SELECT TOP(1) ID, isAck, Priority FROM Message Where Sysid = 250 AND Mess = " + MessKod + " ORDER BY ID DESC");
sqlDb.ExecuteReader();
while (sqlDb.Reader.Read())
{
num = Convert.ToInt32(sqlDb.Reader["isAck"]);
num2 = Convert.ToInt32(sqlDb.Reader["Priority"]);
}
sqlDb.Reader.Close();
sqlDb.CreateDbCommand("INSERT INTO PLCMessage (IDmess, Place, DTime, dTimeAck, SysID, SysNum, Mess, Message, IsAck, Priority, Value) VALUES (@IDmess, @Place, @DTime, @dTimeAck, @SysID, @SysNum, @Mess, @Message, @IsAck, @Priority, @Value)");
sqlDb.Command.Parameters.Add("@IDmess", SqlDbType.Int).Value = -1;
sqlDb.Command.Parameters.Add("@Place", SqlDbType.VarChar).Value = Environment.MachineName;
if (sqlDb.UseDateTimeInPlcMessage)
{
DateTime dateTime = DateTime.Now;
dateTime = dateTime.AddMilliseconds((double)(-(double)dateTime.Millisecond));
sqlDb.Command.Parameters.Add("@DTime", SqlDbType.DateTime2).Value = dateTime;
}
else
{
string text;
if (DateTime.Now.Second <= 9)
{
text = "0" + Convert.ToString(DateTime.Now.Second);
}
else
{
text = Convert.ToString(DateTime.Now.Second);
}
string text2;
if (DateTime.Now.Minute <= 9)
{
text2 = "0" + Convert.ToString(DateTime.Now.Minute);
}
else
{
text2 = Convert.ToString(DateTime.Now.Minute);
}
string text3;
if (DateTime.Now.Hour <= 9)
{
text3 = "0" + Convert.ToString(DateTime.Now.Hour);
}
else
{
text3 = Convert.ToString(DateTime.Now.Hour);
}
string text4 = Convert.ToString(DateTime.Now.Date);
string value = string.Concat(new string[]
{
text4.Substring(0, 10),
" ",
text3,
":",
text2,
":",
text
});
sqlDb.Command.Parameters.Add("@DTime", SqlDbType.VarChar).Value = value;
}
sqlDb.Command.Parameters.Add("@dTimeAck", SqlDbType.VarChar).Value = ((num == 1) ? "Квитировать" : "");
sqlDb.Command.Parameters.Add("@SysID", SqlDbType.Int).Value = 250;
sqlDb.Command.Parameters.Add("@SysNum", SqlDbType.Int).Value = 1;
sqlDb.Command.Parameters.Add("@Mess", SqlDbType.Int).Value = MessKod;
sqlDb.Command.Parameters.Add("@Message", SqlDbType.VarChar).Value = Message;
sqlDb.Command.Parameters.Add("@IsAck", SqlDbType.Int).Value = num;
sqlDb.Command.Parameters.Add("@Priority", SqlDbType.Int).Value = num2;
sqlDb.Command.Parameters.Add("@Value", SqlDbType.VarChar).Value = "";
sqlDb.Command.ExecuteNonQuery();
sqlDb.Close();
}
catch (Exception exception)
{
Log.WriteLogToFile(exception);
}
}