string.Equals(varData_QCMH04.ST_NO.Trim(), tempSteelType, StringComparison.OrdinalIgnoreCase)
public void GetRemoteStandardToLocal()
{
try
{
//MyRegion读取数据库获取原始数据
using IDbConnection dbConnection = new OracleConnection(str_Conn_AusinL2);
dbConnection.Open();
string sqlstr = $"SELECT * FROM MHQC04_NORMLIZE WHERE ST_NO IS NOT NULL and ISNEW = 1 order by TimeCreated desc";
var varData_QCMH04 = dbConnection.Query<TbPlc7Mes2BY_MHQC04_Normlize>(sqlstr).FirstOrDefault();
if (varData_QCMH04 != null)
{
//MyRegion将远程数据库数据整理后,去重后,存入本地数据库
string tempSteelType = "";
string tempElementName = "";
double tempElementMax = 0.0;
double tempElementMin = 0.0;
double tempElementAim = 0.0;
if (varData_QCMH04.ST_NO != null)
{
if (!string.Equals(varData_QCMH04.ST_NO.Trim(), tempSteelType, StringComparison.OrdinalIgnoreCase))
{
tempSteelType = varData_QCMH04.ST_NO.Trim();
for (int i = 0; i < 20; i++)
{
tempElementName = varData_QCMH04.GetType().GetProperty($"ELM_NAME{i + 1}")?.GetValue(varData_QCMH04)?.ToString().Trim();
if (tempElementName != null)
{
tempElementMax = Convert.ToDouble(varData_QCMH04.GetType().GetProperty($"ELM_MAX{i + 1}")?.GetValue(varData_QCMH04));
tempElementMin = Convert.ToDouble(varData_QCMH04.GetType().GetProperty($"ELM_MIN{i + 1}")?.GetValue(varData_QCMH04));
tempElementAim = Convert.ToDouble(varData_QCMH04.GetType().GetProperty($"ELM_AIM{i + 1}")?.GetValue(varData_QCMH04));
var insert_Model2Main3 = new TbModel2Main3Normlize()
{
TimeCreated = DateTime.Now,
SeqNo = i + 1,
IsNew = 1,
Id = 0,
SteelName = tempSteelType,
SteelType = tempSteelType,
ElementName = tempElementName,
ElementType = tempElementName,
StandardMax = tempElementMax,
StandardMin = tempElementMin,
StandardAim = tempElementAim,
};
string insertSql = "INSERT INTO TB_MODE2_MAIN3_NORMLIZE " +
" (TimeCreated, SeqNo,IsNew,Id, SteelName,SteelType,ElementName,ElementType,StandardMax,StandardMin,StandardAim " +
" VALUES (:TimeCreated, :SeqNo, :IsNew, :Id,:SteelName, :SteelType,:ElementName,:ElementType,:StandardMax,:StandardMin,:StandardAim ";
int rowsAffected1 = dbConnection.Execute(insertSql, insert_Model2Main3);
}
}
}
}
varData_QCMH04.IsNew = 0;
string sqlStr_Update = "UPDATE MHQC04_NORMLIZE SET ISNEW = :ISNEW WHERE TimeCreated = :=TimeCreated and SeqNo = :SeqNo ";
int rowsAffected2 = dbConnection.Execute(sqlStr_Update, varData_QCMH04);
}
}
catch (Exception ex)
{
AppLog.Info("GetRemoteNormlize()出错,信息为: " + ex.Message);
}
}
标签:tempSteelType,string,TimeCreated,C#,varData,dbConnection,大小写,QCMH04,字符串
From: https://blog.csdn.net/AAA_li/article/details/136832928