ParticleData.cs 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634
  1. using DevExpress.Charts.Native;
  2. using DevExpress.XtraDiagram.Bars;
  3. using DevExpress.XtraEditors.Filtering;
  4. using OTSCommon.DBOperate;
  5. using OTSCommon.DBOperate.Model;
  6. using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
  7. using OTSIncAReportApp.OTSRstMgrFunction;
  8. using OTSIncAReportGraph.Controls;
  9. using OTSPeriodicTable;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Data.SQLite;
  14. using System.Drawing;
  15. using System.Drawing.Imaging;
  16. using System.IO;
  17. using System.Linq;
  18. using static OTSDataType.otsdataconst;
  19. using static OTSIncAReportApp.OTSReport_Export;
  20. namespace OTSIncAReportApp.DataOperation.DataAccess
  21. {
  22. public class ParticleData
  23. {
  24. private SqlHelper dbHelper;
  25. public ParticleData(string path)
  26. {
  27. dbHelper = new SqlHelper("data source='" + path + "\\FIELD_FILES\\Inclusion.db'");
  28. }
  29. /// <summary>
  30. /// 获取SegmentList
  31. /// </summary>
  32. /// <param name="model">Feature</param>
  33. /// <returns></returns>
  34. public List<Particle> GetParticleList(Particle model)
  35. {
  36. //存放查询数据的数据表
  37. SQLiteParameter[] Parameter = new SQLiteParameter[1]
  38. {
  39. new SQLiteParameter("@FieldId", model.FieldId)
  40. };
  41. string sql = "select * from IncAData where Fieldid=@FieldId";
  42. DataTable DT = dbHelper.ExecuteDataTable(sql, Parameter);
  43. var result = new List<Particle>();
  44. foreach (DataRow dr in DT.Rows)
  45. {
  46. Particle item = new Particle() { };
  47. result.Add(item);
  48. }
  49. return result;
  50. }
  51. /// <summary>
  52. /// 获取ParticleListBy
  53. /// </summary>
  54. /// <param name="model">Feature</param>
  55. /// <returns></returns>
  56. public List<Particle> GetParticleListByCon(string con, string max, string min, int display)
  57. {
  58. string sqlp = "select a.* from IncAData a ";
  59. string where = " where 1=1 ";
  60. if (display == 1)
  61. {
  62. where = where + " and a.XrayId >-1 ";
  63. }
  64. if (con != "")
  65. {
  66. where = where + " and a." + con + ">" + min + " and a." + con + "<" + max;
  67. }
  68. sqlp = sqlp + where;
  69. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  70. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  71. return listp;
  72. }
  73. /// <summary>
  74. /// 获取ParticleList
  75. /// </summary>
  76. /// <param name="model">Feature</param>
  77. /// <returns></returns>
  78. public DataTable GetParticleListAndEm()
  79. {
  80. string sqlp = @"select *,
  81. (select group_concat(name||'-'||Percentage,';')
  82. from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element
  83. from INcAData where xrayid>-1";
  84. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  85. return DT;
  86. }
  87. /// <summary>
  88. /// 获取ParticleList
  89. /// </summary>
  90. /// <param name="model">Feature</param>
  91. /// <returns></returns>
  92. public Particle GetMergedParticleInfo(int fieldid, int particleid, out uint[] Search_xray, out uint[] Analysis_xray)
  93. {
  94. string sqlp = @"select *,
  95. (select group_concat(name||'-'||Percentage,';')
  96. from ElementChemistry where XRayId =IncAData.XRayId and fieldid=IncAData.fieldid ) as Element
  97. from IncAData where FieldId=" + fieldid.ToString() + " and ParticleId="+ particleid.ToString();
  98. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  99. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  100. Particle pte = new Particle();
  101. Analysis_xray =new uint[2000];
  102. Search_xray= new uint[2000];
  103. if (listp.Count > 0)
  104. {
  105. pte = listp[0];
  106. List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
  107. string element = DT.Rows[0]["Element"].ToString();
  108. for (int i = 0; i < element.Split(';').Count(); i++)
  109. {
  110. string elestr = element.Split(';')[i];
  111. if (elestr != "")
  112. {
  113. OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = elestr.Split('-')[0], Percentage = Convert.ToDouble(elestr.Split('-')[1]) };
  114. ElementList.Add(ele);
  115. }
  116. }
  117. pte.ElementList = ElementList;
  118. string SubParticlesstr = DT.Rows[0]["SubParticles"].ToString();
  119. string[] SubParticlesstrG = SubParticlesstr.Split(',');
  120. foreach (string s in SubParticlesstrG)
  121. {
  122. string fieldid1 = s.Split(':')[0];
  123. string pid1 = s.Split(':')[1];
  124. Particle particle1 = GetParticleXrayDataByFidAndPid(fieldid1, pid1);
  125. byte[] bytes = particle1.XRayData;
  126. for (int i = 0; i < 2000; i++)
  127. {
  128. Analysis_xray[i] = Analysis_xray[i]+ BitConverter.ToUInt32(bytes, i * 4);
  129. }
  130. Search_xray = Analysis_xray;
  131. }
  132. }
  133. return pte;
  134. }
  135. /// <summary>
  136. /// 获取ParticleList
  137. /// </summary>
  138. /// <param name="model">Feature</param>
  139. /// <returns></returns>
  140. public DataTable GetParticleStatisticDataListByIncA(string con)
  141. {
  142. string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,sum(Area) as Area,avg(" + con
  143. + ") as av,max(" + con
  144. + ") as max ";
  145. sqlp = sqlp + "from IncAData where typeid !=-1 and typeid !=4 and fieldid !=-1 group by TypeId";
  146. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  147. return DT;
  148. }
  149. public DataTable GetParticleListForParticlSize(string con, string fieldAndPartic)
  150. {
  151. string sqlp = @"select TypeId,TypeName,GroupId ,TypeColor,count(1) as con,avg(" + con
  152. + ") as av,max(" + con
  153. + ") as max ,GroupName";
  154. sqlp = sqlp + " from IncAData where typeid !=-1 and fieldid!=-1 and typeid !=4 and ParticleId !=-1";
  155. if (fieldAndPartic != "")
  156. {
  157. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  158. }
  159. sqlp = sqlp + " group by TypeId ";
  160. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  161. if (con == "area")
  162. {
  163. for (int i = 0; i < DT.Rows.Count; i++)
  164. {
  165. DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
  166. }
  167. }
  168. return DT;
  169. }
  170. /// <summary>
  171. /// 获取ParticleList
  172. /// </summary>
  173. /// <param name="model">Feature</param>
  174. /// <returns></returns>
  175. public DataTable GetParticleListForParticlSizeID(string con, string fieldAndPartic)
  176. {
  177. string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,avg(" + con
  178. + ") as av,max(" + con
  179. + ") as max ,GroupName ,GroupId,GroupColor";
  180. sqlp = sqlp + " from IncAData where typeid !=-1 and typeid !=4";
  181. if (fieldAndPartic != "")
  182. {
  183. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  184. }
  185. sqlp = sqlp + " group by TypeId ";
  186. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  187. if (con == "area")
  188. {
  189. for (int i = 0; i < DT.Rows.Count; i++)
  190. {
  191. DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
  192. }
  193. }
  194. return DT;
  195. }
  196. /// <summary>
  197. /// 获取element含量
  198. /// </summary>
  199. /// <returns></returns>
  200. public DataTable GetElementForArea(string fieldAndPartic)
  201. {
  202. string sqlp = @"select e.name,sum(e.percentage*p.area) as earea from ElementChemistry e
  203. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid from IncAData where typeid !=-1 and typeid !=4";
  204. if (fieldAndPartic != "")
  205. {
  206. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
  207. }
  208. sqlp = sqlp + " group by e.name order by sum(e.percentage*p.area) desc";
  209. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  210. return DT;
  211. }
  212. /// <summary>
  213. /// 获取element含量
  214. /// </summary>
  215. /// <returns></returns>
  216. public DataTable GetSmallElementForArea()
  217. {
  218. 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
  219. group by e.name order by sum(e.percentage*i.area) desc";
  220. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  221. return DT;
  222. }
  223. /// <summary>
  224. /// 获取所有Particle
  225. /// </summary>
  226. /// <returns></returns>
  227. public DataTable GetParticleAll(string fieldAndPartic)
  228. {
  229. string sqlp = @"select * from INcAData where typeid !=-1 and typeid !=4";
  230. if (fieldAndPartic != "")
  231. {
  232. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  233. }
  234. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  235. DT.Columns.Add("ECD",typeof(double));
  236. for (int i = 0; i < DT.Rows.Count; i++)
  237. {
  238. DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  239. }
  240. DataTable data = DT.Clone();
  241. for (int i = 0; i < DT.Rows.Count; i++)
  242. {
  243. if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
  244. {
  245. data.Rows.Add(DT.Rows[i].ItemArray);
  246. }
  247. }
  248. return data;
  249. }
  250. public DataTable GetParticleAllForBig(string fieldAndPartic)
  251. {
  252. string sqlp = @"select * from INcAData where";
  253. if (fieldAndPartic != "")
  254. {
  255. sqlp = sqlp + " '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  256. }
  257. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  258. DT.Columns.Add("ECD", typeof(double));
  259. for (int i = 0; i < DT.Rows.Count; i++)
  260. {
  261. DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  262. }
  263. DataTable data = DT.Clone();
  264. for (int i = 0; i < DT.Rows.Count; i++)
  265. {
  266. if (Convert.ToInt32(DT.Rows[i]["ParticleId"]) > -1)
  267. {
  268. data.Rows.Add(DT.Rows[i].ItemArray);
  269. }
  270. }
  271. return data;
  272. }
  273. public DataTable GetParticleAllforparticlelist(string fieldAndPartic)
  274. {
  275. string sqlp = @"select * from INcAData where typeid !=-1 and SubParticles is not 'IsSubParticle' ";
  276. if (fieldAndPartic != "")
  277. {
  278. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  279. }
  280. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  281. return DT;
  282. }
  283. public DataTable GetMergedParticle(string fieldAndPartic)
  284. {
  285. string sqlp = @"select * from INcAData where typeid !=-1 and SubParticles is not 'IsSubParticle' and SubParticles is not null ";
  286. if (fieldAndPartic != "")
  287. {
  288. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  289. }
  290. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  291. return DT;
  292. }
  293. /// <summary>
  294. /// 查找所有颗粒的颜色、面积、种类名称信息
  295. /// </summary>
  296. /// <returns></returns>
  297. public DataTable GetParticleTypeInformation()
  298. {
  299. string sqlp = @"select Area,TypeName,TypeColor from IncAData";
  300. DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
  301. return dt;
  302. }
  303. /// <summary>
  304. /// 查找IncaData表中所有种类
  305. /// </summary>
  306. /// <returns></returns>
  307. public DataTable GetParticleClassAll()
  308. {
  309. string sqlp = @"SELECT DISTINCT TypeName FROM IncaData";
  310. DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
  311. return dt;
  312. }
  313. /// <summary>
  314. /// 获取所有Particle
  315. /// </summary>
  316. /// <returns></returns>
  317. public DataTable GetParticleAllHaveXray(string fieldAndPartic)
  318. {
  319. string incaSql = @"select * from IncAData where typeid !=-1 and typeid !=4";
  320. if (fieldAndPartic != "")
  321. {
  322. incaSql = incaSql + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  323. }
  324. DataTable incaDT = dbHelper.ExecuteDataTable(incaSql, null);
  325. incaDT.Columns.Add("Element");
  326. DataTable dt_element = GetElementChemistry();
  327. DataTable elementchemistry = dt_element.Clone();
  328. for (int i = 0; i < dt_element.Rows.Count; i++)
  329. {
  330. if (dt_element.Rows[i]["Name"].ToString() != "Fe")
  331. {
  332. elementchemistry.Rows.Add(dt_element.Rows[i].ItemArray);
  333. }
  334. }
  335. for (int i = 0; i < incaDT.Rows.Count; i++)
  336. {
  337. string str = "XRayId = " + incaDT.Rows[i]["particleId"].ToString() + " and fieldid = " + incaDT.Rows[i]["fieldid"].ToString();
  338. DataRow[] drs = elementchemistry.Select(str);
  339. string ConcatenatedString = "";
  340. for (int j = 0; j < drs.Length; j++)
  341. {
  342. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  343. }
  344. incaDT.Rows[i]["Element"] = ConcatenatedString;
  345. }
  346. return incaDT;
  347. }
  348. /// <summary>
  349. /// 获取所有Particle
  350. /// </summary>
  351. /// <returns></returns>
  352. public DataTable GetParticleHaveXray(string fieldAndPartic)
  353. {
  354. string sqlp = @"select *,
  355. (select group_concat(name||'-'||Percentage,';')
  356. from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element from INcAData where xrayid>-1 ";
  357. if (fieldAndPartic != "")
  358. {
  359. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  360. }
  361. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  362. for (int i = 0; i < DT.Rows.Count; i++)
  363. {
  364. DT.Rows[i]["Area"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
  365. }
  366. return DT;
  367. }
  368. /// <summary>
  369. /// 获取所有Particle
  370. /// </summary>
  371. /// <returns></returns>
  372. public List<Particle> GetParticleAllList()
  373. {
  374. string sqlp = @"select * from INcAData";
  375. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  376. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  377. return listp;
  378. }
  379. /// <summary>
  380. /// 获取所有Particle
  381. /// </summary>
  382. /// <returns></returns>
  383. public DataTable GetParticleAllList_DataTable()
  384. {
  385. string sqlp = @"select * from INcAData";
  386. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  387. return DT;
  388. }
  389. /// <summary>
  390. /// 获取所有分类的面积
  391. /// </summary>
  392. /// <param name="fieldAndPartic">选择颗粒</param>
  393. /// <returns></returns>
  394. public DataTable GetAreaByAllIncA(string fieldAndPartic)
  395. {
  396. 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";
  397. if (fieldAndPartic != "")
  398. {
  399. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
  400. }
  401. sqlp = sqlp + " group by TypeId";
  402. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  403. return DT;
  404. }
  405. /// <summary>
  406. /// 获取所有大颗粒没有的小颗粒分类
  407. /// </summary>
  408. /// <param name="fieldAndPartic">选择颗粒</param>
  409. /// <returns></returns>
  410. public DataTable GetSmallParticleInfo()
  411. {
  412. 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";
  413. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  414. return DT;
  415. }
  416. /// <summary>
  417. /// 获取不同分类的面积
  418. /// </summary>
  419. /// <param name="fieldAndPartic">选择颗粒</param>
  420. /// <returns></returns>
  421. public DataTable GetAreaByIncA(string TypeId, string fieldAndPartic)
  422. {
  423. string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
  424. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid where p.TypeId=" + TypeId + " ";
  425. if (fieldAndPartic != "")
  426. {
  427. sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
  428. }
  429. sqlp = sqlp + " group by e.name";
  430. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  431. return DT;
  432. }
  433. public DataTable GetAreaByIncA_All()
  434. {
  435. string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
  436. inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid group by e.name ";
  437. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  438. return DT;
  439. }
  440. /// <summary>
  441. /// 获取全部的物质大类
  442. /// </summary>
  443. /// <returns></returns>
  444. public DataTable GetAllClass()
  445. {
  446. string sqlp = @"select GroupName from IncAData group by GroupName order by count(1) desc";
  447. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  448. return DT;
  449. }
  450. /// <summary>
  451. /// 获取所有元素
  452. /// </summary>
  453. /// <param name="model">Feature</param>
  454. /// <returns></returns>
  455. public DataTable GetAllElement()
  456. {
  457. string sqlp = @"select name from ElementChemistry group by name order by count(1) desc";
  458. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  459. return DT;
  460. }
  461. /// <summary>
  462. /// 获取常用夹杂物分类信息
  463. /// </summary>
  464. /// <returns></returns>
  465. public DataTable GetCommonlyUsedClassifyData()
  466. {
  467. string sqlp = @"select
  468. (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 ,
  469. (select count(typeid) from incadata where typeid BETWEEN 10000 and 10999 ) as OXIDE ,
  470. (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 ,
  471. (select count(typeid) from incadata where typeid BETWEEN 12000 and 12999 ) as NITRIDE ,
  472. (select count(typeid) from incadata where typeid BETWEEN 11000 and 11999 ) as SULFIDE ";
  473. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  474. return DT;
  475. }
  476. public bool DeleteFromData(string fieldid, string particleid)
  477. {
  478. string sqlp = @"delete from IncAData where FieldId=" + fieldid + " and ParticleId="
  479. + particleid;
  480. if (dbHelper.ExecuteQuery_bool(sqlp))
  481. {
  482. return true;
  483. }
  484. else
  485. {
  486. return false;
  487. }
  488. }
  489. /// <summary>
  490. /// 获取颗粒信息
  491. /// </summary>
  492. /// <param name="model">Feature</param>
  493. /// <returns></returns>
  494. public Particle GetParticleByFidAndPid(string fieldid, string particleid)
  495. {
  496. string sqlp = @"select *,(select xraydata from xraydata where xrayindex=INcAData.xrayid and fieldid="
  497. + fieldid + ") as XRayData,(select group_concat(name || '_' || Percentage, ';')from ElementChemistry where XRayId = INcAData.XRayId and fieldid ="
  498. + fieldid + ") as Element from INcAData where fieldid="
  499. + fieldid + " and particleid= " + particleid;
  500. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  501. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  502. Particle particle = new Particle();
  503. if (listp.Count > 0)
  504. {
  505. particle = listp[0];
  506. List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
  507. string element = DT.Rows[0]["Element"].ToString();
  508. for (int i = 0; i < element.Split(';').Count(); i++)
  509. {
  510. if (element.Split(';')[i] != "")
  511. {
  512. OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = element.Split(';')[i].Split('_')[0], Percentage = Convert.ToDouble(element.Split(';')[i].Split('_')[1]) };
  513. ElementList.Add(ele);
  514. }
  515. }
  516. particle.ElementList = ElementList;
  517. }
  518. return particle;
  519. }
  520. public Particle GetParticleXrayDataByFidAndPid(string fieldid, string xrayid)
  521. {
  522. string sqlp = @"select xraydata from xraydata where xrayindex=" + xrayid + " and fieldid="
  523. + fieldid;
  524. DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
  525. List<Particle> listp = dbHelper.TableToList<Particle>(DT);
  526. if (listp.Count > 0)
  527. {
  528. return listp[0];
  529. }
  530. else
  531. {
  532. return null;
  533. }
  534. }
  535. public enum PARTCLE_TYPE
  536. {
  537. SMALL = 0,//过小颗粒
  538. OVERSIZE = 1,//过大颗粒
  539. AVE_GRAY_NOT_INRANRE = 2,//亮度不在分析范围内的颗粒
  540. SEARCH_X_RAY = 3,
  541. LOW_COUNT = 4,//低计数率颗粒
  542. NO_INTEREST_ELEMENTS = 5,
  543. NO_ANALYSIS_X_RAY = 6,//不含分析元素
  544. NOT_IDENTIFIED_SIC = 7,//非夹杂物颗粒SiC
  545. NOT_IDENTIFIED_FEO = 8,//非夹杂物颗粒FeO
  546. NOT_IDENTIFIED = 9,//未识别颗粒
  547. IDENTIFIED = 10,//分析颗粒,当为可识别类型时,可以被进一步识别为用户类型(1000以上),系统预定义类型(10000以上),所以最终颗粒类型不会为8,但可能为7
  548. USER_DEFINED_MIN = 1000,
  549. SYS_DEFINED_MIN = 10000
  550. }
  551. #region 分页添加读取数据库函数
  552. /// <summary>
  553. /// 获取分页查询所需信息
  554. /// </summary>
  555. /// <param name=""></param>
  556. /// <param name=""></param>
  557. /// <returns></returns>
  558. public DataTable GetInfoForPartucleDevidePage(int currentPage, int pagesize, string OrderFunction, string condition)
  559. {
  560. int p = (currentPage - 1) * pagesize;
  561. 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();
  562. DataTable DT = new DataTable();
  563. DT = dbHelper.ExecuteQuery(sqliteString);
  564. return DT;
  565. }
  566. public DataTable GetIncaSurfaceData( List<string> lst_str)
  567. {
  568. DataTable particlesAll = GetInfoForPartucleDevidePage2("");
  569. DataTable dt_element = GetElementChemistry();
  570. List<int> list_int = new List<int>();
  571. for (int a = 0; a < lst_str.Count; a++)
  572. {
  573. for (int i = 0; i < dt_element.Rows.Count; i++)
  574. {
  575. if (dt_element.Rows[i]["Name"].ToString() == lst_str[a].ToString())
  576. {
  577. list_int.Add(i);
  578. }
  579. }
  580. }
  581. for (int i = 0; i < list_int.Count; i++)
  582. {
  583. dt_element.Rows[list_int[i]].Delete();
  584. }
  585. dt_element.AcceptChanges();
  586. for (int i = 0; i < particlesAll.Rows.Count; i++)
  587. {
  588. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  589. DataRow[] drs = dt_element.Select(str);
  590. string ConcatenatedString = "";
  591. for (int j = 0; j < drs.Length; j++)
  592. {
  593. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  594. }
  595. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  596. }
  597. return particlesAll;
  598. }
  599. public DataTable AddElementColumn(DataTable particlesAll, c_TemplateClass m_mbszclass)
  600. {
  601. if (!particlesAll.Columns.Contains("Element"))
  602. {
  603. particlesAll.Columns.Add("Element");
  604. }
  605. DataTable dt_element = GetElementChemistry();
  606. for (int i = 0; i < particlesAll.Rows.Count; i++)
  607. {
  608. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  609. DataRow[] drs = dt_element.Select(str);
  610. string ConcatenatedString = "";
  611. for (int j = 0; j < drs.Length; j++)
  612. {
  613. //判断是否在处理元素表中
  614. bool bl = false;
  615. for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_qcys.Count; a++)
  616. {
  617. if (drs[j]["name"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_qcys[a].ToString())
  618. {
  619. bl = true;
  620. }
  621. }
  622. if (!bl)
  623. {
  624. ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
  625. }
  626. }
  627. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  628. }
  629. return particlesAll;
  630. }
  631. /// <summary>
  632. /// 拼接颗粒
  633. /// </summary>
  634. /// <param name="lst_str"></param>
  635. /// <returns></returns>
  636. public DataTable GetSplicingParticlesData()
  637. {
  638. DataTable particlesAll = GetSplicingParticles();
  639. return particlesAll;
  640. }
  641. /// <summary>
  642. /// 保留两位小数
  643. /// </summary>
  644. /// <param name="strData"></param>
  645. /// <returns></returns>
  646. private string ChangeDataToD(string strData)
  647. {
  648. Decimal dData = 0.00M;
  649. if (strData.Contains("E"))
  650. {
  651. dData = Convert.ToDecimal(Decimal.Parse(strData.ToString(), System.Globalization.NumberStyles.Float));
  652. }
  653. else
  654. {
  655. return Convert.ToDouble(strData).ToString("0.00");
  656. }
  657. return Convert.ToDouble(dData).ToString("0.00");
  658. }
  659. public DataTable GetInfoForPartucleDevidePage2(string condition)
  660. {
  661. string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
  662. "as 'SEMPosX',FieldPosY as 'SEMPosY',XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles," +
  663. " (select group_concat(name || '-' || Percentage, ';') from ElementChemistry where XRayId = MergedParticleInfo.XRayId and fieldid = MergedParticleInfo.fieldid) " +
  664. "as Element from MergedParticleInfo where 1=1 " + condition + " union select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId," +
  665. "SegmentNum,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,'' " +
  666. "as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " +
  667. condition;
  668. DataTable DT = new DataTable();
  669. DT = dbHelper.ExecuteQuery(sqliteString);
  670. return DT;
  671. }
  672. public DataTable GetSplicingParticles()
  673. {
  674. string sqliteString1 = "select * from MergedParticleInfo";
  675. DataTable DT = new DataTable();
  676. DT = dbHelper.ExecuteQuery(sqliteString1);
  677. return DT;
  678. }
  679. public DataTable GetInfoForPartucleDevidePage_analyticalParticle(string condition)
  680. {
  681. 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') " +
  682. condition;
  683. DataTable DT = new DataTable();
  684. DT = dbHelper.ExecuteQuery(sqliteString);
  685. return DT;
  686. }
  687. public DataTable GetInfoForPartucleDevidePage_otherParticle(string condition)
  688. {
  689. 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)) " +
  690. condition;
  691. DataTable DT = new DataTable();
  692. DT = dbHelper.ExecuteQuery(sqliteString);
  693. return DT;
  694. }
  695. /// <summary>
  696. /// 获取拼接颗粒
  697. /// </summary>
  698. /// <param name="condition">帅选条件</param>
  699. /// <returns></returns>
  700. public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
  701. {
  702. 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;
  703. DataTable DT1 = new DataTable();
  704. try
  705. {
  706. DT1 = dbHelper.ExecuteQuery(sqliteString);
  707. }
  708. catch
  709. {
  710. }
  711. return DT1;
  712. }
  713. public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
  714. {
  715. 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' " +
  716. condition;
  717. DataTable DT = new DataTable();
  718. DT = dbHelper.ExecuteQuery(sqliteString);
  719. return DT;
  720. }
  721. public DataTable GetInfoForPartucleDevidePage_NotIdentifyParticle(string condition)
  722. {
  723. 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 " +
  724. condition;
  725. DataTable DT = new DataTable();
  726. DT = dbHelper.ExecuteQuery(sqliteString);
  727. return DT;
  728. }
  729. public DataTable GetInfoForPartucleDevidePage_InvalidParticle(string condition)
  730. {
  731. 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 " +
  732. condition;
  733. DataTable DT = new DataTable();
  734. DT = dbHelper.ExecuteQuery(sqliteString);
  735. return DT;
  736. }
  737. public DataTable GetInfoForPartucleDevidePage_LowCountsParticle(string condition)
  738. {
  739. 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 " +
  740. condition;
  741. DataTable DT = new DataTable();
  742. 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 = new DataTable();
  749. DT = dbHelper.ExecuteQuery(sqliteString1);
  750. return DT;
  751. }
  752. public DataTable GetXRayData()
  753. {
  754. string sqliteString = @"select * from xraydata";
  755. DataTable DT = new DataTable();
  756. DT = dbHelper.ExecuteQuery(sqliteString);
  757. return DT;
  758. }
  759. public DataTable GetElementChemistry()
  760. {
  761. string sqliteString = "select * from ElementChemistry";
  762. DataTable DT = new DataTable();
  763. DT = dbHelper.ExecuteQuery(sqliteString);
  764. return DT;
  765. }
  766. /// <summary>
  767. /// 得到图形形状
  768. /// </summary>
  769. /// <returns></returns>
  770. public DataTable GetSegment()
  771. {
  772. string sqliteString = "select * from Segment";
  773. DataTable DT = new DataTable();
  774. DT = dbHelper.ExecuteQuery(sqliteString);
  775. return DT;
  776. }
  777. /// <summary>
  778. /// 全部颗粒不带元素
  779. /// </summary>
  780. /// <param name="condition"></param>
  781. /// <returns></returns>
  782. public DataTable GetAllParticleWithMergeParticlesWithoutEle(string condition)
  783. {
  784. DataTable particlesAll = GetParticleAllforparticlelist(condition);
  785. return particlesAll;
  786. }
  787. /// <summary>
  788. /// 全部颗粒带元素
  789. /// </summary>
  790. /// <param name="condition"></param>
  791. /// <returns></returns>
  792. public DataTable GetAllParticleWithMergeParticles(string condition)
  793. {
  794. DataTable particlesAll=new DataTable();
  795. DataTable particlesAll1 = GetInfoForPartucleDevidePage_allParticles(condition);
  796. DataTable mergeParticles = GetInfoForPartucleDevidePage_mergeParticles(condition);
  797. if (mergeParticles != null && mergeParticles.Rows.Count > 0)
  798. {
  799. RemoveMergeParticles(ref particlesAll1, mergeParticles);
  800. }
  801. particlesAll = particlesAll1.Copy();
  802. foreach (DataRow item in mergeParticles.Rows)
  803. {
  804. particlesAll.ImportRow(item);
  805. }
  806. DataTable elementchemistry = GetElementChemistry();
  807. for (int i = 0; i < particlesAll.Rows.Count; i++)
  808. {
  809. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  810. DataRow[] drs = elementchemistry.Select(str);
  811. string ConcatenatedString = "";
  812. for (int j = 0; j < drs.Length; j++)
  813. {
  814. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  815. }
  816. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  817. }
  818. return particlesAll;
  819. }
  820. public void RemoveMergeParticles(ref DataTable dataTable_Particle, DataTable dataTable_MergeParticles)
  821. {
  822. foreach (DataRow row in dataTable_Particle.Rows)
  823. {
  824. foreach (DataRow MergeParticlesRow in dataTable_MergeParticles.Rows)
  825. {
  826. string subt = MergeParticlesRow["SubParticles"].ToString();
  827. string[] sub = subt.Split(',');
  828. if (row.RowState == DataRowState.Deleted)
  829. {
  830. break;
  831. }
  832. if (row["fieldid"].ToString() == Convert.ToString(sub[0]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[0]).Split(':')[1])
  833. {
  834. row.Delete();
  835. break;
  836. }
  837. if (row["fieldid"].ToString() == Convert.ToString(sub[1]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[1]).Split(':')[1])
  838. {
  839. row.Delete();
  840. break; ;
  841. }
  842. }
  843. }
  844. dataTable_Particle.AcceptChanges();
  845. }
  846. /// <summary>
  847. /// 拼接颗粒图
  848. /// </summary>
  849. /// <param name="sub">拼接字符串</param>
  850. /// <param name="xs">xs = pixw / ScanFieldSize</param>
  851. /// <param name="path">报告文件路径</param>
  852. /// <param name="picHeight">图像高</param>
  853. /// <param name="picWidth">帧图宽</param>
  854. /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
  855. /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
  856. /// <returns></returns>
  857. public Bitmap GetBitmapForBig(string sub, double xs, string path, int picHeight, int picWidth, OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION, OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION)
  858. {
  859. string vs = "," + sub.Replace(':', '-') + ",";
  860. DataTable dataTable = GetParticleAllForBig(vs);
  861. if (dataTable.Rows.Count == 0)
  862. {
  863. return null;
  864. }
  865. //内接矩形
  866. double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
  867. double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
  868. double min_Y = max_Y;
  869. double min_X = max_X;
  870. //拼接field矩形
  871. double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
  872. double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
  873. double T_Y = B_Y;
  874. double L_X = R_X;
  875. foreach (DataRow item in dataTable.Rows)
  876. {
  877. double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
  878. if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  879. {
  880. if (lefttopXH > L_X)
  881. {
  882. L_X = lefttopXH;
  883. }
  884. if (lefttopXH < R_X)
  885. {
  886. R_X = lefttopXH;
  887. }
  888. }
  889. else
  890. {
  891. if (lefttopXH < R_X)
  892. {
  893. R_X = lefttopXH;
  894. }
  895. if (lefttopXH > L_X)
  896. {
  897. L_X = lefttopXH;
  898. }
  899. }
  900. double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
  901. if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  902. {
  903. if (lrfttopYH < B_Y)
  904. {
  905. B_Y = lrfttopYH;
  906. }
  907. if (lrfttopYH > T_Y)
  908. {
  909. T_Y = lrfttopYH;
  910. }
  911. }
  912. else
  913. {
  914. if (lrfttopYH > B_Y)
  915. {
  916. B_Y= lrfttopYH;
  917. }
  918. if (lrfttopYH < T_Y)
  919. {
  920. T_Y = lrfttopYH;
  921. }
  922. }
  923. }
  924. int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
  925. int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
  926. //构造最终的图片白板
  927. Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
  928. Graphics graph = Graphics.FromImage(tableChartImage);
  929. //初始化这个大图
  930. graph.DrawImage(tableChartImage, 0, 0);
  931. foreach (DataRow item in dataTable.Rows)
  932. {
  933. string filePath = path + "\\FIELD_FILES\\";
  934. string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
  935. //然后将取出的数据,转换成Bitmap对象
  936. Bitmap ls_bt = ReadImageFile(imagePath);
  937. int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
  938. int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
  939. graph.DrawImage(ls_bt, x, y);
  940. //颗粒外接矩形
  941. double lefttopX = x+Convert.ToInt64(item["RectLeft"]);
  942. if (lefttopX < min_X)
  943. {
  944. min_X = lefttopX;
  945. }
  946. if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
  947. {
  948. max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
  949. }
  950. double lrfttopY = y+ Convert.ToInt64(item["RectTop"]);
  951. if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
  952. {
  953. max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
  954. }
  955. if ( lrfttopY< min_Y)
  956. {
  957. min_Y = lrfttopY;
  958. }
  959. }
  960. int width = Convert.ToInt32(max_X - min_X);
  961. int height = Convert.ToInt32(max_Y - min_Y);
  962. int X = Convert.ToInt32(min_X);
  963. int Y = Convert.ToInt32(min_Y);
  964. Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
  965. Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
  966. return bmap;
  967. }
  968. /// <summary>
  969. /// 拼接颗粒黑白图
  970. /// </summary>
  971. /// <param name="sub">拼接字符串</param>
  972. /// <param name="xs">xs = pixw / ScanFieldSize</param>
  973. /// <param name="path">报告文件路径</param>
  974. /// <param name="picHeight">图像高</param>
  975. /// <param name="picWidth">帧图宽</param>
  976. /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
  977. /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
  978. /// <returns></returns>
  979. public Bitmap GetBitmapForBigBlackAndWhiteImage(string sub, double xs, string path, int picHeight, int picWidth, OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION, OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION)
  980. {
  981. string vs = "," + sub.Replace(':', '-') + ",";
  982. DataTable dataTable = GetParticleAllForBig(vs);
  983. if (dataTable.Rows.Count == 0)
  984. {
  985. return null;
  986. }
  987. //内接矩形
  988. double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
  989. double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
  990. double min_Y = max_Y;
  991. double min_X = max_X;
  992. //拼接field矩形
  993. double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
  994. double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
  995. double T_Y = B_Y;
  996. double L_X = R_X;
  997. foreach (DataRow item in dataTable.Rows)
  998. {
  999. double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
  1000. if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  1001. {
  1002. if (lefttopXH > L_X)
  1003. {
  1004. L_X = lefttopXH;
  1005. }
  1006. if (lefttopXH < R_X)
  1007. {
  1008. R_X = lefttopXH;
  1009. }
  1010. }
  1011. else
  1012. {
  1013. if (lefttopXH < R_X)
  1014. {
  1015. R_X = lefttopXH;
  1016. }
  1017. if (lefttopXH > L_X)
  1018. {
  1019. L_X = lefttopXH;
  1020. }
  1021. }
  1022. double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
  1023. if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  1024. {
  1025. if (lrfttopYH < B_Y)
  1026. {
  1027. B_Y = lrfttopYH;
  1028. }
  1029. if (lrfttopYH > T_Y)
  1030. {
  1031. T_Y = lrfttopYH;
  1032. }
  1033. }
  1034. else
  1035. {
  1036. if (lrfttopYH > B_Y)
  1037. {
  1038. B_Y = lrfttopYH;
  1039. }
  1040. if (lrfttopYH < T_Y)
  1041. {
  1042. T_Y = lrfttopYH;
  1043. }
  1044. }
  1045. }
  1046. int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
  1047. int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
  1048. //构造最终的图片白板
  1049. Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
  1050. Graphics graph = Graphics.FromImage(tableChartImage);
  1051. graph.Clear(Color.White);
  1052. //初始化这个大图
  1053. graph.DrawImage(tableChartImage, 0, 0);
  1054. foreach (DataRow item in dataTable.Rows)
  1055. {
  1056. string strs = @"select * from Segment where FieldId="+item["fieldid"].ToString()+" and ParticleId="+item["particleid"].ToString();
  1057. DataTable DTS = dbHelper.ExecuteDataTable(strs, null);
  1058. DataRow[] dd = DTS.Select();
  1059. List<Segment> flist = dbHelper.RowsToList<Segment>(dd);
  1060. int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
  1061. int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
  1062. //颗粒外接矩形
  1063. double lefttopX = x + Convert.ToInt64(item["RectLeft"]);
  1064. if (lefttopX < min_X)
  1065. {
  1066. min_X = lefttopX;
  1067. }
  1068. if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
  1069. {
  1070. max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
  1071. }
  1072. double lrfttopY = y + Convert.ToInt64(item["RectTop"]);
  1073. if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
  1074. {
  1075. max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
  1076. }
  1077. if (lrfttopY < min_Y)
  1078. {
  1079. min_Y = lrfttopY;
  1080. }
  1081. foreach (Segment seg in flist)
  1082. {
  1083. int f_length = seg.Length;
  1084. for (int m = 0; m < f_length; m++)
  1085. {
  1086. int lsjs_x = seg.Start + m+ x;
  1087. int lsjs_y = seg.Height+ y;
  1088. tableChartImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
  1089. }
  1090. }
  1091. }
  1092. int width = Convert.ToInt32(max_X - min_X);
  1093. int height = Convert.ToInt32(max_Y - min_Y);
  1094. int X = Convert.ToInt32(min_X);
  1095. int Y = Convert.ToInt32(min_Y);
  1096. Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
  1097. Bitmap bmap = GetBitmapByParticle(tableChartImage, rectangle);
  1098. return bmap;
  1099. }
  1100. /// <summary>
  1101. /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
  1102. /// </summary>
  1103. /// <param name="path"></param>
  1104. /// <returns></returns>
  1105. public Bitmap ReadImageFile(string path)
  1106. {
  1107. if (!File.Exists(path))
  1108. {
  1109. return null;//文件不存在
  1110. }
  1111. FileStream fs = File.OpenRead(path); //OpenRead
  1112. int filelength = 0;
  1113. filelength = (int)fs.Length; //获得文件长度
  1114. Byte[] image = new Byte[filelength]; //建立一个字节数组
  1115. fs.Read(image, 0, filelength); //按字节流读取
  1116. System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
  1117. fs.Close();
  1118. Bitmap bit = new Bitmap(result);
  1119. return bit;
  1120. }
  1121. /// <summary>
  1122. /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
  1123. /// </summary>
  1124. /// <param name="in_cotsparticleclr"></param>
  1125. /// <returns></returns>
  1126. public Bitmap GetBitmapByParticle(Bitmap ls_bt, Rectangle offset_rect)
  1127. {
  1128. //为了能把整个颗粒显示完整
  1129. offset_rect.X = offset_rect.X - 20;
  1130. offset_rect.Y = offset_rect.Y - 20;
  1131. offset_rect.Width = offset_rect.Width + 40;
  1132. offset_rect.Height = offset_rect.Height + 40;
  1133. //防止计算偏差后,有坐标溢出现象
  1134. if (offset_rect.X < 0)
  1135. offset_rect.X = 0;
  1136. if (offset_rect.Y < 0)
  1137. offset_rect.Y = 0;
  1138. if (offset_rect.X + offset_rect.Width > ls_bt.Width)
  1139. {
  1140. offset_rect.Width = ls_bt.Width - offset_rect.X;
  1141. }
  1142. if (offset_rect.Y + offset_rect.Height > ls_bt.Height)
  1143. {
  1144. offset_rect.Height = ls_bt.Height - offset_rect.Y;
  1145. }
  1146. Bitmap new_ret_bp;
  1147. //防止为0后面计算出错
  1148. if (offset_rect.Width > 0 && offset_rect.Height > 0)
  1149. {
  1150. //最后通过list_showsegment组建成新的图片,进行返回
  1151. new_ret_bp = ls_bt.Clone(offset_rect, ls_bt.PixelFormat);
  1152. }
  1153. else
  1154. {
  1155. new_ret_bp = new Bitmap(offset_rect.Width, offset_rect.Height);
  1156. }
  1157. return new_ret_bp;
  1158. }
  1159. public void InsertUpdate(List<int> particleID, List<string> particleData)
  1160. {
  1161. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  1162. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  1163. cmdlist.Add(str);
  1164. try
  1165. {
  1166. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  1167. }
  1168. catch (Exception e)
  1169. {
  1170. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  1171. }
  1172. }
  1173. public KeyValuePair<string, SQLiteParameter[]> GetUpdataAIncACmd(List<int> particleID, List<string> particleData)
  1174. {
  1175. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  1176. return str;
  1177. }
  1178. public void ExecuteNonQueryBatch(List<KeyValuePair<string, SQLiteParameter[]>> cmdlist)
  1179. {
  1180. try
  1181. {
  1182. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  1183. }
  1184. catch (Exception e)
  1185. {
  1186. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  1187. }
  1188. }
  1189. /// <summary>
  1190. /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
  1191. /// </summary>
  1192. /// <param name="in_clr_tagid">颗粒id</param>
  1193. /// <param name="in_clr_fieldid"></param>
  1194. /// <param name="Search_xray"></param>
  1195. /// <param name="Analysis_xray"></param>
  1196. public Particle GetXrayByParticleTagIDAndFieldID_ForMergeParticle(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray)
  1197. {
  1198. Search_xray = new uint[2000];
  1199. Analysis_xray = new uint[2000];
  1200. Particle particle = new Particle();
  1201. particle = GetMergedParticleInfo(in_clr_fieldid, in_clr_tagid, out Search_xray, out Analysis_xray);
  1202. return particle;
  1203. }
  1204. public List<ShowElementInfo> GetShowElementInfos_ForMergeParticle(List<Element> list_celementchemistryclr)
  1205. {
  1206. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  1207. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  1208. {
  1209. ShowElementInfo ls_sei = new ShowElementInfo();
  1210. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  1211. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  1212. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  1213. double de_sx2 = 0;
  1214. if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
  1215. {
  1216. de_sx2 = 0;
  1217. }
  1218. else
  1219. {
  1220. de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
  1221. }
  1222. ls_sei.dLF = de_sx2;
  1223. list_showelementinfo.Add(ls_sei);
  1224. }
  1225. list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
  1226. return list_showelementinfo;
  1227. }
  1228. //public Bitmap GetParticlescreenshot(string subt, ResultFile result)
  1229. //{
  1230. // Bitmap bmap = null;
  1231. // KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
  1232. // if (subt != null && subt != "" && subt != "IsSubParticle")
  1233. // {
  1234. // double ScanFieldSize = result.GetScanFieldSizeX();
  1235. // string filePatht = result.FilePath + "\\FIELD_FILES\\";
  1236. // string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
  1237. // Bitmap tempbit = ReadImageFile(imagePatht);
  1238. // int pixw = tempbit.Width;
  1239. // double xs = pixw / ScanFieldSize;
  1240. // OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
  1241. // OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
  1242. // bmap = GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
  1243. // if (bmap != null)
  1244. // {
  1245. // string[] str = subt.Split(',');
  1246. // bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1]};
  1247. // }
  1248. // }
  1249. // else if (subt != "IsSubParticle")
  1250. // {
  1251. // if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
  1252. // {
  1253. // string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  1254. // FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
  1255. // }
  1256. // 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"]) };
  1257. // Bitmap bmap = GetBitmapByParticle(FieldImage.Value, rectangle);
  1258. // 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() };
  1259. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  1260. // dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
  1261. // }
  1262. // return bmap;
  1263. //}
  1264. #endregion
  1265. #region 清洁度
  1266. public ParticleData()
  1267. {
  1268. }
  1269. /// <summary>
  1270. /// 获得颗粒类别
  1271. /// </summary>
  1272. /// <param name="StandardLibraryAddress">标准库地址</param>
  1273. /// <returns></returns>
  1274. public DataTable ObtainParticleCategory_start(string StandardLibraryAddress)
  1275. {
  1276. DataTable dataTable = new DataTable();
  1277. dataTable.Columns.Add("GroupId");
  1278. dataTable.Columns.Add("GroupName");
  1279. dataTable.Columns.Add("inoId");
  1280. dataTable.Columns.Add("display");
  1281. DataTable get_dt = SelectStandardLibraryGrouping(StandardLibraryAddress);
  1282. if (get_dt.Rows.Count==0)
  1283. {
  1284. DataRow data = dataTable.NewRow();
  1285. data["inoId"] = 0;
  1286. data["GroupId"] = 0;
  1287. data["GroupName"] = "Default";
  1288. data["display"] = "0";
  1289. dataTable.Rows.Add(data);
  1290. return dataTable;
  1291. }
  1292. DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  1293. int shul = 0;
  1294. string DefaultGroupId = "";
  1295. foreach (DataRow row in dataRow)
  1296. {
  1297. if (row.ItemArray[1].ToString() != "Default")
  1298. {
  1299. DataRow data = dataTable.NewRow();
  1300. data["inoId"] = shul;
  1301. data["GroupId"] = row.ItemArray[0].ToString();
  1302. data["GroupName"] = row.ItemArray[1].ToString();
  1303. data["display"] = "0";
  1304. dataTable.Rows.Add(data);
  1305. shul++;
  1306. }
  1307. else
  1308. {
  1309. DefaultGroupId = row.ItemArray[0].ToString();
  1310. }
  1311. }
  1312. DataRow data2 = dataTable.NewRow();
  1313. data2["inoId"] = shul;
  1314. data2["GroupId"] = DefaultGroupId;
  1315. data2["GroupName"] = "Default";
  1316. data2["display"] = "0";
  1317. dataTable.Rows.Add(data2);
  1318. return dataTable;
  1319. }
  1320. /// <summary>
  1321. /// 获取规则数据
  1322. /// </summary>
  1323. /// <param name="strings">组类别</param>
  1324. /// <param name="a_SelectedIndex">标准库地址</param>
  1325. /// <returns></returns>
  1326. public List<DataTable> ObtainRuleData_start(DataTable strings, string a_SelectedIndex)
  1327. {
  1328. List<DataTable> List_data = new List<DataTable>();
  1329. DataTable dt_stl = new DataTable();
  1330. SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
  1331. dt_stl = sh.ExecuteQuery("select * from ClassifySTD");
  1332. dt_stl.Columns.Add("display");
  1333. if (dt_stl == null)
  1334. {
  1335. List_data.Add(dt_stl);
  1336. return List_data;
  1337. }
  1338. for (int i = 0; i < strings.Rows.Count; i++)
  1339. {
  1340. DataTable table = dt_stl.Clone();
  1341. table.TableName = strings.Rows[i]["GroupId"].ToString();
  1342. for (int a = 0; a < dt_stl.Rows.Count; a++)
  1343. {
  1344. if (strings.Rows[i]["GroupId"].ToString() == dt_stl.Rows[a]["GroupId"].ToString())
  1345. {
  1346. dt_stl.Rows[a]["display"] = 0;
  1347. table.Rows.Add(dt_stl.Rows[a].ItemArray);
  1348. }
  1349. }
  1350. DataView dvs = table.DefaultView;
  1351. dvs.Sort = "ListNum ASC";
  1352. DataTable TemporaryDataGroup = dvs.ToTable();
  1353. List_data.Add(TemporaryDataGroup);
  1354. }
  1355. return List_data;
  1356. }
  1357. private DataTable SelectStandardLibraryGrouping(string a_SelectedIndex)
  1358. {
  1359. DataTable dt_stl = new DataTable();
  1360. SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
  1361. dt_stl = sh.ExecuteQuery("select * from STDGroups");
  1362. return dt_stl;
  1363. }
  1364. /// <summary>
  1365. /// 获得颗粒类别
  1366. /// </summary>
  1367. /// <returns></returns>
  1368. public List<string> ObtainParticleCategory(OTSReport_Export m_otsreport_export, BasicData basicData)
  1369. {
  1370. List<string> ClassName = new List<string>();
  1371. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype != OTS_SysType_ID.IncA)
  1372. {
  1373. DataTable get_dt = ReadClassification(basicData);
  1374. DataTable getClass_dt = get_dt.Clone();
  1375. DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  1376. foreach (DataRow row in dataRow)
  1377. {
  1378. if (row.ItemArray[1].ToString() != "Default")
  1379. {
  1380. getClass_dt.ImportRow(row);
  1381. }
  1382. }
  1383. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1384. {
  1385. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  1386. }
  1387. ClassName.Add("Default");
  1388. }
  1389. else
  1390. {
  1391. DataTable getClass_dt = ReadClassification(basicData);
  1392. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1393. {
  1394. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  1395. }
  1396. bool bl = false;
  1397. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1398. {
  1399. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  1400. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  1401. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  1402. {
  1403. if (!bl)
  1404. {
  1405. ClassName.Add("Default");
  1406. bl = true;
  1407. }
  1408. }
  1409. else
  1410. {
  1411. bool isDefault = false;
  1412. for (int a = 0; a < ClassName.Count; a++)
  1413. {
  1414. if (getClass_dt.Rows[i]["GroupName"].ToString() == "Default")
  1415. {
  1416. isDefault = true;
  1417. }
  1418. }
  1419. if (isDefault)
  1420. {
  1421. if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
  1422. {
  1423. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1424. }
  1425. }
  1426. else
  1427. {
  1428. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1429. }
  1430. }
  1431. }
  1432. }
  1433. return ClassName;
  1434. }
  1435. public DataTable ReadClassification(BasicData basicData)
  1436. {
  1437. DataTable dt_stl = new DataTable();
  1438. SqLiteHelper sh = new SqLiteHelper("data source='" + basicData.GetFilePath() + "\\" + basicData.GetResfile() + "'");
  1439. dt_stl = sh.ExecuteQuery("select * from STDGroups");
  1440. return dt_stl;
  1441. }
  1442. #endregion
  1443. }
  1444. }