ParticleData.cs 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. using OTSCommon.DBOperate;
  2. using OTSCommon.DBOperate.Model;
  3. using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
  4. using OTSIncAReportGraph.Controls;
  5. using OTSPeriodicTable;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Data.SQLite;
  10. using System.IO;
  11. using System.Linq;
  12. using static OTSDataType.otsdataconst;
  13. using static OTSIncAReportApp.OTSReport_Export;
  14. namespace OTSIncAReportApp.DataOperation.DataAccess
  15. {
  16. public class ParticleData
  17. {
  18. private SqlHelper dbHelper;
  19. public ParticleData(string path)
  20. {
  21. dbHelper = new SqlHelper("data source='" + path + "\\FIELD_FILES\\Inclusion.db'");
  22. }
  23. /// <summary>
  24. /// 获取SegmentList
  25. /// </summary>
  26. /// <param name="model">Feature</param>
  27. /// <returns></returns>
  28. public List<Particle> GetParticleList(Particle model)
  29. {
  30. //存放查询数据的数据表
  31. SQLiteParameter[] Parameter = new SQLiteParameter[1]
  32. {
  33. new SQLiteParameter("@FieldId", model.FieldId)
  34. };
  35. string sql = "select * from IncAData where Fieldid=@FieldId";
  36. DataTable DT = dbHelper.ExecuteDataTable(sql, Parameter);
  37. var result = new List<Particle>();
  38. foreach (DataRow dr in DT.Rows)
  39. {
  40. Particle item = new Particle() { };
  41. result.Add(item);
  42. }
  43. return result;
  44. }
  45. /// <summary>
  46. /// 获取ParticleListBy
  47. /// </summary>
  48. /// <param name="model">Feature</param>
  49. /// <returns></returns>
  50. public List<Particle> GetParticleListByCon(string con, string max, string min, int display)
  51. {
  52. string sqlp = "select a.* from IncAData a ";
  53. string where = " where 1=1 ";
  54. if (display == 1)
  55. {
  56. where = where + " and a.XrayId >-1 ";
  57. }
  58. if (con != "")
  59. {
  60. where = where + " and a." + con + ">" + min + " and a." + con + "<" + max;
  61. }
  62. sqlp = sqlp + where;
  63. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  64. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  65. return listp;
  66. }
  67. /// <summary>
  68. /// 获取ParticleList
  69. /// </summary>
  70. /// <param name="model">Feature</param>
  71. /// <returns></returns>
  72. public DataTable GetParticleListAndEm()
  73. {
  74. string sqlp = @"select *,
  75. (select group_concat(name||'-'||Percentage,';')
  76. from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element
  77. from INcAData where xrayid>-1";
  78. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  79. return DT;
  80. }
  81. /// <summary>
  82. /// 获取ParticleList
  83. /// </summary>
  84. /// <param name="model">Feature</param>
  85. /// <returns></returns>
  86. public Particle GetMergedParticleInfo(int fieldid, int particleid, out uint[] Search_xray, out uint[] Analysis_xray)
  87. {
  88. string sqlp = @"select *,
  89. (select group_concat(name||'-'||Percentage,';')
  90. from ElementChemistry where XRayId =IncAData.XRayId and fieldid=IncAData.fieldid ) as Element
  91. from IncAData where FieldId=" + fieldid.ToString() + " and ParticleId="+ particleid.ToString();
  92. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  93. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  94. Particle pte = new Particle();
  95. Analysis_xray =new uint[2000];
  96. Search_xray= new uint[2000];
  97. if (listp.Count > 0)
  98. {
  99. pte = listp[0];
  100. List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
  101. string element = DT.Rows[0]["Element"].ToString();
  102. for (int i = 0; i < element.Split(';').Count(); i++)
  103. {
  104. string elestr = element.Split(';')[i];
  105. if (elestr != "")
  106. {
  107. OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = elestr.Split('-')[0], Percentage = Convert.ToDouble(elestr.Split('-')[1]) };
  108. ElementList.Add(ele);
  109. }
  110. }
  111. pte.ElementList = ElementList;
  112. string SubParticlesstr = DT.Rows[0]["SubParticles"].ToString();
  113. string[] SubParticlesstrG = SubParticlesstr.Split(',');
  114. foreach (string s in SubParticlesstrG)
  115. {
  116. string fieldid1 = s.Split(':')[0];
  117. string pid1 = s.Split(':')[1];
  118. Particle particle1 = GetParticleXrayDataByFidAndPid(fieldid1, pid1);
  119. byte[] bytes = particle1.XRayData;
  120. for (int i = 0; i < 2000; i++)
  121. {
  122. Analysis_xray[i] = Analysis_xray[i]+ BitConverter.ToUInt32(bytes, i * 4);
  123. }
  124. Search_xray = Analysis_xray;
  125. }
  126. }
  127. return pte;
  128. }
  129. /// <summary>
  130. /// 获取ParticleList
  131. /// </summary>
  132. /// <param name="model">Feature</param>
  133. /// <returns></returns>
  134. public DataTable GetParticleStatisticDataListByIncA(string con)
  135. {
  136. string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,sum(Area) as Area,avg(" + con
  137. + ") as av,max(" + con
  138. + ") as max ";
  139. sqlp = sqlp + "from IncAData where typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle' group by TypeId";
  140. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  141. return DT;
  142. }
  143. public DataTable GetParticleListForParticlSize(string con, string fieldAndPartic)
  144. {
  145. string sqlp = @"select TypeId,TypeName,GroupId ,TypeColor,count(1) as con,avg(" + con
  146. + ") as av,max(" + con
  147. + ") as max ,GroupName";
  148. sqlp = sqlp + " from IncAData where typeid !=-1 and typeid !=4 and ParticleId !=-1 and SubParticles is not 'IsSubParticle'";
  149. if (fieldAndPartic != "")
  150. {
  151. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  152. }
  153. sqlp = sqlp + " group by TypeId ";
  154. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  155. if (con == "area")
  156. {
  157. for (int i = 0; i < DT.Rows.Count; i++)
  158. {
  159. DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
  160. }
  161. }
  162. return DT;
  163. }
  164. /// <summary>
  165. /// 获取ParticleList
  166. /// </summary>
  167. /// <param name="model">Feature</param>
  168. /// <returns></returns>
  169. public DataTable GetParticleListForParticlSizeID(string con, string fieldAndPartic)
  170. {
  171. string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,avg(" + con
  172. + ") as av,max(" + con
  173. + ") as max ,GroupName ,GroupId,GroupColor";
  174. sqlp = sqlp + " from IncAData where typeid !=-1 and typeid !=4";
  175. if (fieldAndPartic != "")
  176. {
  177. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  178. }
  179. sqlp = sqlp + " group by TypeId ";
  180. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  181. if (con == "area")
  182. {
  183. for (int i = 0; i < DT.Rows.Count; i++)
  184. {
  185. DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
  186. }
  187. }
  188. return DT;
  189. }
  190. /// <summary>
  191. /// 获取element含量
  192. /// </summary>
  193. /// <returns></returns>
  194. public DataTable GetElementForArea(string fieldAndPartic)
  195. {
  196. string sqlp = @"select e.name,sum(e.percentage*p.area) as earea from ElementChemistry e
  197. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid from IncAData where typeid !=-1 and typeid !=4";
  198. if (fieldAndPartic != "")
  199. {
  200. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
  201. }
  202. sqlp = sqlp + " group by e.name order by sum(e.percentage*p.area) desc";
  203. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  204. return DT;
  205. }
  206. /// <summary>
  207. /// 获取element含量
  208. /// </summary>
  209. /// <returns></returns>
  210. public DataTable GetSmallElementForArea()
  211. {
  212. string sqlp = @"select e.name, sum(e.percentage*i.area) as earea from elementchemistry e inner join incadata i on e.xrayid = i.xrayid and e.fieldid = i.fieldid
  213. group by e.name order by sum(e.percentage*i.area) desc";
  214. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  215. return DT;
  216. }
  217. /// <summary>
  218. /// 获取所有Particle
  219. /// </summary>
  220. /// <returns></returns>
  221. public DataTable GetParticleAll(string fieldAndPartic)
  222. {
  223. string sqlp = @"select * from INcAData where typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle'";
  224. if (fieldAndPartic != "")
  225. {
  226. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  227. }
  228. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  229. DT.Columns.Add("ECD",typeof(double));
  230. for (int i = 0; i < DT.Rows.Count; i++)
  231. {
  232. DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  233. }
  234. DataTable data = DT.Clone();
  235. for (int i = 0; i < DT.Rows.Count; i++)
  236. {
  237. if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
  238. {
  239. data.Rows.Add(DT.Rows[i].ItemArray);
  240. }
  241. }
  242. return data;
  243. }
  244. public DataTable GetParticleAllForBig(string fieldAndPartic)
  245. {
  246. string sqlp = @"select * from INcAData where";
  247. if (fieldAndPartic != "")
  248. {
  249. sqlp = sqlp + " '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  250. }
  251. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  252. DT.Columns.Add("ECD", typeof(double));
  253. for (int i = 0; i < DT.Rows.Count; i++)
  254. {
  255. DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  256. }
  257. DataTable data = DT.Clone();
  258. for (int i = 0; i < DT.Rows.Count; i++)
  259. {
  260. if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
  261. {
  262. data.Rows.Add(DT.Rows[i].ItemArray);
  263. }
  264. }
  265. return data;
  266. }
  267. public DataTable GetParticleAllforparticlelist(string fieldAndPartic)
  268. {
  269. string sqlp = @"select * from INcAData where typeid !=-1 and SubParticles is not 'IsSubParticle' ";
  270. if (fieldAndPartic != "")
  271. {
  272. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  273. }
  274. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  275. return DT;
  276. }
  277. public DataTable GetMergedParticle(string fieldAndPartic)
  278. {
  279. string sqlp = @"select * from INcAData where typeid !=-1 and SubParticles is not 'IsSubParticle' and SubParticles is not null ";
  280. if (fieldAndPartic != "")
  281. {
  282. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  283. }
  284. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  285. return DT;
  286. }
  287. /// <summary>
  288. /// 查找所有颗粒的颜色、面积、种类名称信息
  289. /// </summary>
  290. /// <returns></returns>
  291. public DataTable GetParticleTypeInformation()
  292. {
  293. string sqlp = @"select Area,TypeName,TypeColor from IncAData";
  294. DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
  295. return dt;
  296. }
  297. /// <summary>
  298. /// 查找IncaData表中所有种类
  299. /// </summary>
  300. /// <returns></returns>
  301. public DataTable GetParticleClassAll()
  302. {
  303. string sqlp = @"SELECT DISTINCT TypeName FROM IncaData";
  304. DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
  305. return dt;
  306. }
  307. /// <summary>
  308. /// 获取所有Particle
  309. /// </summary>
  310. /// <returns></returns>
  311. public DataTable GetParticleAllHaveXray(string fieldAndPartic)
  312. {
  313. string incaSql = @"select * from IncAData where typeid !=-1 and typeid !=4";
  314. if (fieldAndPartic != "")
  315. {
  316. incaSql = incaSql + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  317. }
  318. DataTable incaDT = dbHelper.ExecuteDataTable(incaSql, null);
  319. incaDT.Columns.Add("Element");
  320. DataTable dt_element = GetElementChemistry();
  321. DataTable elementchemistry = dt_element.Clone();
  322. for (int i = 0; i < dt_element.Rows.Count; i++)
  323. {
  324. if (dt_element.Rows[i]["Name"].ToString() != "Fe")
  325. {
  326. elementchemistry.Rows.Add(dt_element.Rows[i].ItemArray);
  327. }
  328. }
  329. for (int i = 0; i < incaDT.Rows.Count; i++)
  330. {
  331. string str = "XRayId = " + incaDT.Rows[i]["particleId"].ToString() + " and fieldid = " + incaDT.Rows[i]["fieldid"].ToString();
  332. DataRow[] drs = elementchemistry.Select(str);
  333. string ConcatenatedString = "";
  334. for (int j = 0; j < drs.Length; j++)
  335. {
  336. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  337. }
  338. incaDT.Rows[i]["Element"] = ConcatenatedString;
  339. }
  340. return incaDT;
  341. }
  342. /// <summary>
  343. /// 获取所有Particle
  344. /// </summary>
  345. /// <returns></returns>
  346. public DataTable GetParticleHaveXray(string fieldAndPartic)
  347. {
  348. string sqlp = @"select *,
  349. (select group_concat(name||'-'||Percentage,';')
  350. from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element from INcAData where xrayid>-1 ";
  351. if (fieldAndPartic != "")
  352. {
  353. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  354. }
  355. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  356. for (int i = 0; i < DT.Rows.Count; i++)
  357. {
  358. DT.Rows[i]["Area"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  359. }
  360. return DT;
  361. }
  362. /// <summary>
  363. /// 获取所有Particle
  364. /// </summary>
  365. /// <returns></returns>
  366. public List<Particle> GetParticleAllList()
  367. {
  368. string sqlp = @"select * from IncAData";
  369. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  370. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  371. return listp;
  372. }
  373. /// <summary>
  374. /// 获取所有Particle
  375. /// </summary>
  376. /// <returns></returns>
  377. public DataTable GetParticleAllList_DataTable()
  378. {
  379. string sqlp = @"select * from INcAData";
  380. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  381. return DT;
  382. }
  383. /// <summary>
  384. /// 获取所有分类的面积
  385. /// </summary>
  386. /// <param name="fieldAndPartic">选择颗粒</param>
  387. /// <returns></returns>
  388. public DataTable GetAreaByAllIncA(string fieldAndPartic)
  389. {
  390. string sqlp = @"select TypeId,TypeName,GroupId,sum(area) as ar,count(1) as con ,GroupName from INcAData where typeid !=-1 and typeid !=4 and ParticleId > -1 and SubParticles is not 'IsSubParticle' ";
  391. if (fieldAndPartic != "")
  392. {
  393. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  394. }
  395. sqlp = sqlp + " group by TypeId";
  396. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  397. return DT;
  398. }
  399. /// <summary>
  400. /// 获取所有大颗粒没有的小颗粒分类
  401. /// </summary>
  402. /// <param name="fieldAndPartic">选择颗粒</param>
  403. /// <returns></returns>
  404. public DataTable GetSmallParticleInfo()
  405. {
  406. string sqlp = @"select TypeId,TypeName,TypeColor,sum(area) as area,sum(ParticleQuant) as ParticleQuant from SmallParticleInfo where TypeId not in(select TypeId from INcAData) group by TypeId";
  407. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  408. return DT;
  409. }
  410. /// <summary>
  411. /// 获取不同分类的面积
  412. /// </summary>
  413. /// <param name="fieldAndPartic">选择颗粒</param>
  414. /// <returns></returns>
  415. public DataTable GetAreaByIncA(string TypeId, string fieldAndPartic)
  416. {
  417. string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
  418. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid where p.TypeId=" + TypeId + " and SubParticles is not 'IsSubParticle' ";
  419. if (fieldAndPartic != "")
  420. {
  421. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
  422. }
  423. sqlp = sqlp + " group by e.name";
  424. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  425. return DT;
  426. }
  427. public DataTable GetAreaByIncA_All()
  428. {
  429. string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
  430. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid group by e.name where SubParticles is not 'IsSubParticle' ";
  431. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  432. return DT;
  433. }
  434. /// <summary>
  435. /// 获取全部的物质大类
  436. /// </summary>
  437. /// <returns></returns>
  438. public DataTable GetAllClass()
  439. {
  440. string sqlp = @"select GroupName from IncAData group by GroupName order by count(1) desc";
  441. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  442. return DT;
  443. }
  444. /// <summary>
  445. /// 获取所有元素
  446. /// </summary>
  447. /// <param name="model">Feature</param>
  448. /// <returns></returns>
  449. public DataTable GetAllElement()
  450. {
  451. string sqlp = @"select name from ElementChemistry group by name order by count(1) desc";
  452. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  453. return DT;
  454. }
  455. /// <summary>
  456. /// 获取常用夹杂物分类信息
  457. /// </summary>
  458. /// <returns></returns>
  459. public DataTable GetCommonlyUsedClassifyData()
  460. {
  461. string sqlp = @"select
  462. (select count(typeid) from incadata where typeid BETWEEN 10100 and 10199 and typeid BETWEEN 12200 and 12299 and typeid BETWEEN 11300 and 11299 ) as SPINEL ,
  463. (select count(typeid) from incadata where typeid BETWEEN 10000 and 10999 ) as OXIDE ,
  464. (select count(typeid) from incadata where typeid BETWEEN 11200 and 11299 and typeid BETWEEN 11400 and 11499 and typeid BETWEEN 11200 and 11599 ) as SULFIDE_OXIDE ,
  465. (select count(typeid) from incadata where typeid BETWEEN 12000 and 12999 ) as NITRIDE ,
  466. (select count(typeid) from incadata where typeid BETWEEN 11000 and 11999 ) as SULFIDE ";
  467. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  468. return DT;
  469. }
  470. public bool DeleteFromData(string fieldid, string particleid)
  471. {
  472. string sqlp = @"delete from IncAData where FieldId=" + fieldid + " and ParticleId="
  473. + particleid;
  474. if (dbHelper.ExecuteQuery_bool(sqlp))
  475. {
  476. return true;
  477. }
  478. else
  479. {
  480. return false;
  481. }
  482. }
  483. /// <summary>
  484. /// 获取颗粒信息
  485. /// </summary>
  486. /// <param name="model">Feature</param>
  487. /// <returns></returns>
  488. public Particle GetParticleByFidAndPid(string fieldid, string particleid)
  489. {
  490. string sqlp = @"select *,(select xraydata from xraydata where xrayindex=INcAData.xrayid and fieldid="
  491. + fieldid + ") as XRayData,(select group_concat(name || '_' || Percentage, ';')from ElementChemistry where XRayId = INcAData.XRayId and fieldid ="
  492. + fieldid + ") as Element from INcAData where fieldid="
  493. + fieldid + " and particleid= " + particleid;
  494. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  495. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  496. Particle particle = new Particle();
  497. if (listp.Count > 0)
  498. {
  499. particle = listp[0];
  500. List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
  501. string element = DT.Rows[0]["Element"].ToString();
  502. for (int i = 0; i < element.Split(';').Count(); i++)
  503. {
  504. if (element.Split(';')[i] != "")
  505. {
  506. OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = element.Split(';')[i].Split('_')[0], Percentage = Convert.ToDouble(element.Split(';')[i].Split('_')[1]) };
  507. ElementList.Add(ele);
  508. }
  509. }
  510. particle.ElementList = ElementList;
  511. }
  512. return particle;
  513. }
  514. public Particle GetParticleXrayDataByFidAndPid(string fieldid, string xrayid)
  515. {
  516. string sqlp = @"select xraydata from xraydata where xrayindex=" + xrayid + " and fieldid="
  517. + fieldid;
  518. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  519. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  520. if (listp.Count > 0)
  521. {
  522. return listp[0];
  523. }
  524. else
  525. {
  526. return null;
  527. }
  528. }
  529. public List<Segment> GetSegmentData(int fldId,int partId)
  530. {
  531. string strs = @"select * from Segment where FieldId=" + fldId.ToString() + " and ParticleId=" + partId.ToString();
  532. DataTable DTS = dbHelper.ExecuteDataTable(strs, null);
  533. DataRow[] dd = DTS.Select();
  534. List<Segment> flist = dbHelper.RowsToList<Segment>(dd);
  535. return flist;
  536. }
  537. public enum PARTCLE_TYPE
  538. {
  539. SMALL = 0,//过小颗粒
  540. OVERSIZE = 1,//过大颗粒
  541. AVE_GRAY_NOT_INRANRE = 2,//亮度不在分析范围内的颗粒
  542. SEARCH_X_RAY = 3,
  543. LOW_COUNT = 4,//低计数率颗粒
  544. NO_INTEREST_ELEMENTS = 5,
  545. NO_ANALYSIS_X_RAY = 6,//不含分析元素
  546. NOT_IDENTIFIED_SIC = 7,//非夹杂物颗粒SiC
  547. NOT_IDENTIFIED_FEO = 8,//非夹杂物颗粒FeO
  548. NOT_IDENTIFIED = 9,//未识别颗粒
  549. IDENTIFIED = 10,//分析颗粒,当为可识别类型时,可以被进一步识别为用户类型(1000以上),系统预定义类型(10000以上),所以最终颗粒类型不会为8,但可能为7
  550. USER_DEFINED_MIN = 1000,
  551. SYS_DEFINED_MIN = 10000
  552. }
  553. #region 分页添加读取数据库函数
  554. /// <summary>
  555. /// 获取分页查询所需信息
  556. /// </summary>
  557. /// <param name=""></param>
  558. /// <param name=""></param>
  559. /// <returns></returns>
  560. public DataTable GetInfoForPartucleDevidePage(int currentPage, int pagesize, string OrderFunction, string condition)
  561. {
  562. int p = (currentPage - 1) * pagesize;
  563. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX as 'SEMPosX',FieldPosY as 'SEMPosY',ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles, (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX,FieldPosY,ParticleId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,(select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = INcAData.XRayId and fieldid = INcAData.fieldid ) as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " + condition + " order by " + OrderFunction + " limit " + pagesize.ToString() + " offset " + p.ToString();
  564. DataTable DT = new DataTable();
  565. DT = dbHelper.ExecuteQuery(sqliteString);
  566. return DT;
  567. }
  568. public DataTable GetIncaSurfaceData( List<string> lst_str)
  569. {
  570. DataTable particlesAll = GetInfoForPartucleDevidePage2("");
  571. DataTable dt_element = GetElementChemistry();
  572. List<int> list_int = new List<int>();
  573. for (int a = 0; a < lst_str.Count; a++)
  574. {
  575. for (int i = 0; i < dt_element.Rows.Count; i++)
  576. {
  577. if (dt_element.Rows[i]["Name"].ToString() == lst_str[a].ToString())
  578. {
  579. list_int.Add(i);
  580. }
  581. }
  582. }
  583. for (int i = 0; i < list_int.Count; i++)
  584. {
  585. dt_element.Rows[list_int[i]].Delete();
  586. }
  587. dt_element.AcceptChanges();
  588. for (int i = 0; i < particlesAll.Rows.Count; i++)
  589. {
  590. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  591. DataRow[] drs = dt_element.Select(str);
  592. string ConcatenatedString = "";
  593. for (int j = 0; j < drs.Length; j++)
  594. {
  595. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  596. }
  597. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  598. }
  599. return particlesAll;
  600. }
  601. public DataTable AddElementColumn(DataTable particlesAll, c_TemplateClass m_mbszclass)
  602. {
  603. if (!particlesAll.Columns.Contains("Element"))
  604. {
  605. particlesAll.Columns.Add("Element");
  606. }
  607. DataTable dt_element = GetElementChemistry();
  608. for (int i = 0; i < particlesAll.Rows.Count; i++)
  609. {
  610. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  611. DataRow[] drs = dt_element.Select(str);
  612. string ConcatenatedString = "";
  613. for (int j = 0; j < drs.Length; j++)
  614. {
  615. //判断是否在处理元素表中
  616. bool bl = false;
  617. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_qcys.Count; a++)
  618. {
  619. if (drs[j]["name"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_qcys[a].ToString())
  620. {
  621. bl = true;
  622. }
  623. }
  624. if (!bl)
  625. {
  626. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  627. }
  628. }
  629. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  630. }
  631. return particlesAll;
  632. }
  633. /// <summary>
  634. /// 拼接颗粒
  635. /// </summary>
  636. /// <param name="lst_str"></param>
  637. /// <returns></returns>
  638. public DataTable GetSplicingParticlesData()
  639. {
  640. DataTable particlesAll = GetSplicingParticles();
  641. return particlesAll;
  642. }
  643. /// <summary>
  644. /// 保留两位小数
  645. /// </summary>
  646. /// <param name="strData"></param>
  647. /// <returns></returns>
  648. private string ChangeDataToD(string strData)
  649. {
  650. Decimal dData = 0.00M;
  651. if (strData.Contains("E"))
  652. {
  653. dData = Convert.ToDecimal(Decimal.Parse(strData.ToString(), System.Globalization.NumberStyles.Float));
  654. }
  655. else
  656. {
  657. return Convert.ToDouble(strData).ToString("0.00");
  658. }
  659. return Convert.ToDouble(dData).ToString("0.00");
  660. }
  661. public DataTable GetInfoForPartucleDevidePage2(string condition)
  662. {
  663. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
  664. "as 'SEMPosX',FieldPosY as 'SEMPosY',XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles," +
  665. " (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) " +
  666. "as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId," +
  667. "SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,'' " +
  668. "as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " +
  669. condition;
  670. DataTable DT = new DataTable();
  671. DT = dbHelper.ExecuteQuery(sqliteString);
  672. return DT;
  673. }
  674. public DataTable GetSplicingParticles()
  675. {
  676. string sqliteString1 = "select * from MergedParticleInfo";
  677. DataTable DT = new DataTable();
  678. DT = dbHelper.ExecuteQuery(sqliteString1);
  679. return DT;
  680. }
  681. public DataTable GetInfoForPartucleDevidePage_analyticalParticle(string condition)
  682. {
  683. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4 and SubParticles is not 'IsSubParticle') " +
  684. condition;
  685. DataTable DT = new DataTable();
  686. DT = dbHelper.ExecuteQuery(sqliteString);
  687. return DT;
  688. }
  689. public DataTable GetInfoForPartucleDevidePage_otherParticle(string condition)
  690. {
  691. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and SubParticles is not 'IsSubParticle' and (typeid =9 or typeid =-1 or typeid =4)) " +
  692. condition;
  693. DataTable DT = new DataTable();
  694. DT = dbHelper.ExecuteQuery(sqliteString);
  695. return DT;
  696. }
  697. /// <summary>
  698. /// 获取拼接颗粒
  699. /// </summary>
  700. /// <param name="condition">帅选条件</param>
  701. /// <returns></returns>
  702. public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
  703. {
  704. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where (SubParticles Is not null and SubParticles is not 'IsSubParticle' )" + condition;
  705. DataTable DT1 = new DataTable();
  706. try
  707. {
  708. DT1 = dbHelper.ExecuteQuery(sqliteString);
  709. }
  710. catch
  711. {
  712. }
  713. return DT1;
  714. }
  715. public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
  716. {
  717. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and SubParticles is not 'IsSubParticle' " +
  718. condition;
  719. DataTable DT = new DataTable();
  720. DT = dbHelper.ExecuteQuery(sqliteString);
  721. return DT;
  722. }
  723. public DataTable GetInfoForPartucleDevidePage_NotIdentifyParticle(string condition)
  724. {
  725. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =9 and SubParticles is not 'IsSubParticle' " +
  726. condition;
  727. DataTable DT = new DataTable();
  728. DT = dbHelper.ExecuteQuery(sqliteString);
  729. return DT;
  730. }
  731. public DataTable GetInfoForPartucleDevidePage_InvalidParticle(string condition)
  732. {
  733. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 and typeid =-1 and SubParticles is not 'IsSubParticle' " +
  734. condition;
  735. DataTable DT = dbHelper.ExecuteQuery(sqliteString);
  736. return DT;
  737. }
  738. public DataTable GetInfoForPartucleDevidePage_LowCountsParticle(string condition)
  739. {
  740. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,SubParticles,TypeName,TypeColor,'' as Element from INcAData where xrayid > -1 typeid =4 and SubParticles is not 'IsSubParticle' " +
  741. condition;
  742. DataTable DT = dbHelper.ExecuteQuery(sqliteString);
  743. return DT;
  744. }
  745. public DataTable GetClassificationOfAllParticles(string condition)
  746. {
  747. string sqliteString1 = "select distinct TypeName from INcAData " + condition;
  748. DataTable DT = dbHelper.ExecuteQuery(sqliteString1);
  749. return DT;
  750. }
  751. public DataTable GetXRayData()
  752. {
  753. string sqliteString = @"select * from xraydata";
  754. DataTable DT = new DataTable();
  755. DT = dbHelper.ExecuteQuery(sqliteString);
  756. return DT;
  757. }
  758. public DataTable GetElementChemistry()
  759. {
  760. string sqliteString = "select * from ElementChemistry";
  761. DataTable DT = new DataTable();
  762. DT = dbHelper.ExecuteQuery(sqliteString);
  763. return DT;
  764. }
  765. /// <summary>
  766. /// 得到图形形状
  767. /// </summary>
  768. /// <returns></returns>
  769. public DataTable GetSegment()
  770. {
  771. string sqliteString = "select * from Segment";
  772. DataTable DT = new DataTable();
  773. DT = dbHelper.ExecuteQuery(sqliteString);
  774. return DT;
  775. }
  776. /// <summary>
  777. /// 全部颗粒不带元素
  778. /// </summary>
  779. /// <param name="condition"></param>
  780. /// <returns></returns>
  781. public DataTable GetAllParticleWithMergeParticlesWithoutEle(string condition)
  782. {
  783. DataTable particlesAll = GetParticleAllforparticlelist(condition);
  784. return particlesAll;
  785. }
  786. /// <summary>
  787. /// 全部颗粒带元素
  788. /// </summary>
  789. /// <param name="condition"></param>
  790. /// <returns></returns>
  791. public DataTable GetAllParticleWithMergeParticles(string condition)
  792. {
  793. DataTable particlesAll=new DataTable();
  794. DataTable particlesAll1 = GetInfoForPartucleDevidePage_allParticles(condition);
  795. DataTable mergeParticles = GetInfoForPartucleDevidePage_mergeParticles(condition);
  796. if (mergeParticles != null && mergeParticles.Rows.Count > 0)
  797. {
  798. RemoveMergeParticles(ref particlesAll1, mergeParticles);
  799. }
  800. particlesAll = particlesAll1.Copy();
  801. foreach (DataRow item in mergeParticles.Rows)
  802. {
  803. particlesAll.ImportRow(item);
  804. }
  805. DataTable elementchemistry = GetElementChemistry();
  806. for (int i = 0; i < particlesAll.Rows.Count; i++)
  807. {
  808. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  809. DataRow[] drs = elementchemistry.Select(str);
  810. string ConcatenatedString = "";
  811. for (int j = 0; j < drs.Length; j++)
  812. {
  813. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  814. }
  815. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  816. }
  817. return particlesAll;
  818. }
  819. public void RemoveMergeParticles(ref DataTable dataTable_Particle, DataTable dataTable_MergeParticles)
  820. {
  821. foreach (DataRow row in dataTable_Particle.Rows)
  822. {
  823. foreach (DataRow MergeParticlesRow in dataTable_MergeParticles.Rows)
  824. {
  825. string subt = MergeParticlesRow["SubParticles"].ToString();
  826. string[] sub = subt.Split(',');
  827. if (row.RowState == DataRowState.Deleted)
  828. {
  829. break;
  830. }
  831. if (row["fieldid"].ToString() == Convert.ToString(sub[0]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[0]).Split(':')[1])
  832. {
  833. row.Delete();
  834. break;
  835. }
  836. if (row["fieldid"].ToString() == Convert.ToString(sub[1]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[1]).Split(':')[1])
  837. {
  838. row.Delete();
  839. break; ;
  840. }
  841. }
  842. }
  843. dataTable_Particle.AcceptChanges();
  844. }
  845. public void InsertUpdate(List<int> particleID, List<string> particleData)
  846. {
  847. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  848. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  849. cmdlist.Add(str);
  850. try
  851. {
  852. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  853. }
  854. catch (Exception e)
  855. {
  856. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  857. }
  858. }
  859. public KeyValuePair<string, SQLiteParameter[]> GetUpdataAIncACmd(List<int> particleID, List<string> particleData)
  860. {
  861. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  862. return str;
  863. }
  864. public void ExecuteNonQueryBatch(List<KeyValuePair<string, SQLiteParameter[]>> cmdlist)
  865. {
  866. try
  867. {
  868. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  869. }
  870. catch (Exception e)
  871. {
  872. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  873. }
  874. }
  875. /// <summary>
  876. /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
  877. /// </summary>
  878. /// <param name="in_clr_tagid">颗粒id</param>
  879. /// <param name="in_clr_fieldid"></param>
  880. /// <param name="Search_xray"></param>
  881. /// <param name="Analysis_xray"></param>
  882. public Particle GetXrayByParticleTagIDAndFieldID_ForMergeParticle(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray)
  883. {
  884. Search_xray = new uint[2000];
  885. Analysis_xray = new uint[2000];
  886. Particle particle = new Particle();
  887. particle = GetMergedParticleInfo(in_clr_fieldid, in_clr_tagid, out Search_xray, out Analysis_xray);
  888. return particle;
  889. }
  890. public List<ShowElementInfo> GetShowElementInfos_ForMergeParticle(List<Element> list_celementchemistryclr)
  891. {
  892. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  893. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  894. {
  895. ShowElementInfo ls_sei = new ShowElementInfo();
  896. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  897. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  898. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  899. double de_sx2 = 0;
  900. if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
  901. {
  902. de_sx2 = 0;
  903. }
  904. else
  905. {
  906. de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
  907. }
  908. ls_sei.dLF = de_sx2;
  909. list_showelementinfo.Add(ls_sei);
  910. }
  911. list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
  912. return list_showelementinfo;
  913. }
  914. //public Bitmap GetParticlescreenshot(string subt, ResultFile result)
  915. //{
  916. // Bitmap bmap = null;
  917. // KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
  918. // if (subt != null && subt != "" && subt != "IsSubParticle")
  919. // {
  920. // double ScanFieldSize = result.GetScanFieldSizeX();
  921. // string filePatht = result.FilePath + "\\FIELD_FILES\\";
  922. // string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
  923. // Bitmap tempbit = ReadImageFile(imagePatht);
  924. // int pixw = tempbit.Width;
  925. // double xs = pixw / ScanFieldSize;
  926. // OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
  927. // OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
  928. // bmap = GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
  929. // if (bmap != null)
  930. // {
  931. // string[] str = subt.Split(',');
  932. // bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1]};
  933. // }
  934. // }
  935. // else if (subt != "IsSubParticle")
  936. // {
  937. // if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
  938. // {
  939. // string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  940. // FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
  941. // }
  942. // Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(particles.Rows[i]["RectLeft"]), Y = Convert.ToInt32(particles.Rows[i]["RectTop"]), Width = Convert.ToInt32(particles.Rows[i]["RectWidth"]), Height = Convert.ToInt32(particles.Rows[i]["RectHeight"]) };
  943. // Bitmap bmap = GetBitmapByParticle(FieldImage.Value, rectangle);
  944. // bmap.Tag = new List<string>() { particles.Rows[i]["FieldId"].ToString(), particles.Rows[i]["ParticleId"].ToString(), particles.Rows[i]["TypeId"].ToString(), particles.Rows[i]["XrayId"].ToString() };
  945. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  946. // dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
  947. // }
  948. // return bmap;
  949. //}
  950. #endregion
  951. public ParticleData()
  952. {
  953. }
  954. }
  955. }