|
@@ -76,49 +76,46 @@ namespace OTSModelSharp.DTLBase
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public bool SaveElementChemistriesList(List<CPosXrayClr> a_xrayPointList)
|
|
|
+ public bool SaveElementChemistriesList_Batch(List<CPosXrayClr> a_xrayPointList)
|
|
|
{
|
|
|
-
|
|
|
- var tableInfoPtr = GetTableInfo();
|
|
|
-
|
|
|
- var datastorePtr = GetDatastore();
|
|
|
-
|
|
|
- String sInsertFormat = tableInfoPtr.GetInsertCommandFormatString();
|
|
|
- String sSQLCommand = "";
|
|
|
-
|
|
|
+ List<KeyValuePair<string, SQLiteParameter[]>> list = new List<KeyValuePair<string, SQLiteParameter[]>>();
|
|
|
foreach (var xrayPointInfo in a_xrayPointList)
|
|
|
{
|
|
|
List<CElementChemistryClr> listElemnentChemistries = xrayPointInfo.GetElementQuantifyData();
|
|
|
-
|
|
|
int nSize = (int)listElemnentChemistries.Count;
|
|
|
int nElementIndex = 0;
|
|
|
foreach (var pElementChemistry in listElemnentChemistries)
|
|
|
{
|
|
|
- sSQLCommand = String.Format(sInsertFormat,
|
|
|
- xrayPointInfo.GetIndex(),
|
|
|
- xrayPointInfo.GetScanFieldId(),
|
|
|
- nElementIndex,
|
|
|
- nSize,
|
|
|
- pElementChemistry.GetName(),
|
|
|
- pElementChemistry.GetPercentage());
|
|
|
- //var helper = new SQLiteHelper(datastorePtr);
|
|
|
- if (datastorePtr.RunCommand(sSQLCommand) != true)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- nElementIndex++;
|
|
|
+ //INSERT INTO ElementChemistry(XRayId, FieldId, ElementId, ElementNum, Name, Percentage) VALUES({ 0:G},{ 1:G},{ 2:G},{ 3:G},"{4:G}",{ 5:G})
|
|
|
+ string sSQLCommand = "INSERT INTO ElementChemistry(XRayId, FieldId, ElementId, ElementNum, Name, Percentage) VALUES(@XRayId,@FieldId,@ElementId,@ElementNum,@Name,@Percentage)";
|
|
|
+ var paras = new SQLiteParameter[6];
|
|
|
+ paras[0] = new SQLiteParameter("XRayId");
|
|
|
+ paras[0].Value = xrayPointInfo.GetIndex();
|
|
|
+ paras[1] = new SQLiteParameter("FieldId");
|
|
|
+ paras[1].Value = xrayPointInfo.GetScanFieldId();
|
|
|
+ paras[2] = new SQLiteParameter("ElementId");
|
|
|
+ paras[2].Value = nElementIndex;
|
|
|
+ paras[3] = new SQLiteParameter("ElementNum");
|
|
|
+ paras[3].Value = nSize;
|
|
|
+ paras[4] = new SQLiteParameter("Name");
|
|
|
+ paras[4].Value = pElementChemistry.GetName();
|
|
|
+ paras[5] = new SQLiteParameter("Percentage");
|
|
|
+ paras[5].Value = pElementChemistry.GetPercentage();
|
|
|
+ list.Add(new KeyValuePair<string, SQLiteParameter[]>(sSQLCommand, paras));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
+ var datastorePtr = GetDatastore();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ datastorePtr.ExecuteNonQueryBatch(ref list);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
public bool SaveElementChemistriesList(CPosXrayClr a_pxrayPoint)
|
|
|
{
|
|
|
|
|
@@ -184,12 +181,10 @@ namespace OTSModelSharp.DTLBase
|
|
|
paras[4].Value = pElementChemistry.GetName();
|
|
|
paras[5].Value = pElementChemistry.GetPercentage();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
nElementIndex++;
|
|
|
cmds.Add(new KeyValuePair<string, SQLiteParameter[]>(sInsertFormat.Key, paras));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return cmds;
|
|
|
}
|
|
|
|