ParticleData.cs 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  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 GetParticleListByIncA(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 SubParticles is not 'IsSubParticle' 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 typeid !=4 and ParticleId !=-1 and SubParticles is not 'IsSubParticle'";
  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 and SubParticles is not 'IsSubParticle'";
  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 and SubParticles is not 'IsSubParticle' ";
  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 + " and SubParticles is not 'IsSubParticle' ";
  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 where SubParticles is not 'IsSubParticle' ";
  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 and SubParticles is not 'IsSubParticle' " +
  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 and SubParticles is not 'IsSubParticle' " +
  732. condition;
  733. DataTable DT = dbHelper.ExecuteQuery(sqliteString);
  734. return DT;
  735. }
  736. public DataTable GetInfoForPartucleDevidePage_LowCountsParticle(string condition)
  737. {
  738. 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' " +
  739. condition;
  740. DataTable DT = dbHelper.ExecuteQuery(sqliteString);
  741. return DT;
  742. }
  743. public DataTable GetClassificationOfAllParticles(string condition)
  744. {
  745. string sqliteString1 = "select distinct TypeName from INcAData " + condition;
  746. DataTable DT = dbHelper.ExecuteQuery(sqliteString1);
  747. return DT;
  748. }
  749. public DataTable GetXRayData()
  750. {
  751. string sqliteString = @"select * from xraydata";
  752. DataTable DT = new DataTable();
  753. DT = dbHelper.ExecuteQuery(sqliteString);
  754. return DT;
  755. }
  756. public DataTable GetElementChemistry()
  757. {
  758. string sqliteString = "select * from ElementChemistry";
  759. DataTable DT = new DataTable();
  760. DT = dbHelper.ExecuteQuery(sqliteString);
  761. return DT;
  762. }
  763. /// <summary>
  764. /// 得到图形形状
  765. /// </summary>
  766. /// <returns></returns>
  767. public DataTable GetSegment()
  768. {
  769. string sqliteString = "select * from Segment";
  770. DataTable DT = new DataTable();
  771. DT = dbHelper.ExecuteQuery(sqliteString);
  772. return DT;
  773. }
  774. /// <summary>
  775. /// 全部颗粒不带元素
  776. /// </summary>
  777. /// <param name="condition"></param>
  778. /// <returns></returns>
  779. public DataTable GetAllParticleWithMergeParticlesWithoutEle(string condition)
  780. {
  781. DataTable particlesAll = GetParticleAllforparticlelist(condition);
  782. return particlesAll;
  783. }
  784. /// <summary>
  785. /// 全部颗粒带元素
  786. /// </summary>
  787. /// <param name="condition"></param>
  788. /// <returns></returns>
  789. public DataTable GetAllParticleWithMergeParticles(string condition)
  790. {
  791. DataTable particlesAll=new DataTable();
  792. DataTable particlesAll1 = GetInfoForPartucleDevidePage_allParticles(condition);
  793. DataTable mergeParticles = GetInfoForPartucleDevidePage_mergeParticles(condition);
  794. if (mergeParticles != null && mergeParticles.Rows.Count > 0)
  795. {
  796. RemoveMergeParticles(ref particlesAll1, mergeParticles);
  797. }
  798. particlesAll = particlesAll1.Copy();
  799. foreach (DataRow item in mergeParticles.Rows)
  800. {
  801. particlesAll.ImportRow(item);
  802. }
  803. DataTable elementchemistry = GetElementChemistry();
  804. for (int i = 0; i < particlesAll.Rows.Count; i++)
  805. {
  806. string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
  807. DataRow[] drs = elementchemistry.Select(str);
  808. string ConcatenatedString = "";
  809. for (int j = 0; j < drs.Length; j++)
  810. {
  811. ConcatenatedString += drs[j]["name"] + "-" + drs[j]["Percentage"] + ';';
  812. }
  813. particlesAll.Rows[i]["Element"] = ConcatenatedString;
  814. }
  815. return particlesAll;
  816. }
  817. public void RemoveMergeParticles(ref DataTable dataTable_Particle, DataTable dataTable_MergeParticles)
  818. {
  819. foreach (DataRow row in dataTable_Particle.Rows)
  820. {
  821. foreach (DataRow MergeParticlesRow in dataTable_MergeParticles.Rows)
  822. {
  823. string subt = MergeParticlesRow["SubParticles"].ToString();
  824. string[] sub = subt.Split(',');
  825. if (row.RowState == DataRowState.Deleted)
  826. {
  827. break;
  828. }
  829. if (row["fieldid"].ToString() == Convert.ToString(sub[0]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[0]).Split(':')[1])
  830. {
  831. row.Delete();
  832. break;
  833. }
  834. if (row["fieldid"].ToString() == Convert.ToString(sub[1]).Split(':')[0] && row["ParticleId"].ToString() == Convert.ToString(sub[1]).Split(':')[1])
  835. {
  836. row.Delete();
  837. break; ;
  838. }
  839. }
  840. }
  841. dataTable_Particle.AcceptChanges();
  842. }
  843. /// <summary>
  844. /// 拼接颗粒图
  845. /// </summary>
  846. /// <param name="sub">拼接字符串</param>
  847. /// <param name="xs">xs = pixw / ScanFieldSize</param>
  848. /// <param name="path">报告文件路径</param>
  849. /// <param name="picHeight">图像高</param>
  850. /// <param name="picWidth">帧图宽</param>
  851. /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
  852. /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
  853. /// <returns></returns>
  854. 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)
  855. {
  856. string vs = "," + sub.Replace(':', '-') + ",";
  857. DataTable dataTable = GetParticleAllForBig(vs);
  858. if (dataTable.Rows.Count == 0)
  859. {
  860. return null;
  861. }
  862. //内接矩形
  863. double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
  864. double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
  865. double min_Y = max_Y;
  866. double min_X = max_X;
  867. //拼接field矩形
  868. double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
  869. double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
  870. double T_Y = B_Y;
  871. double L_X = R_X;
  872. foreach (DataRow item in dataTable.Rows)
  873. {
  874. double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
  875. if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  876. {
  877. if (lefttopXH > L_X)
  878. {
  879. L_X = lefttopXH;
  880. }
  881. if (lefttopXH < R_X)
  882. {
  883. R_X = lefttopXH;
  884. }
  885. }
  886. else
  887. {
  888. if (lefttopXH < R_X)
  889. {
  890. R_X = lefttopXH;
  891. }
  892. if (lefttopXH > L_X)
  893. {
  894. L_X = lefttopXH;
  895. }
  896. }
  897. double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
  898. if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  899. {
  900. if (lrfttopYH < B_Y)
  901. {
  902. B_Y = lrfttopYH;
  903. }
  904. if (lrfttopYH > T_Y)
  905. {
  906. T_Y = lrfttopYH;
  907. }
  908. }
  909. else
  910. {
  911. if (lrfttopYH > B_Y)
  912. {
  913. B_Y= lrfttopYH;
  914. }
  915. if (lrfttopYH < T_Y)
  916. {
  917. T_Y = lrfttopYH;
  918. }
  919. }
  920. }
  921. int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
  922. int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
  923. //构造最终的图片白板
  924. Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
  925. Graphics graph = Graphics.FromImage(tableChartImage);
  926. //初始化这个大图
  927. graph.DrawImage(tableChartImage, 0, 0);
  928. foreach (DataRow item in dataTable.Rows)
  929. {
  930. string filePath = path + "\\FIELD_FILES\\";
  931. string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
  932. //然后将取出的数据,转换成Bitmap对象
  933. Bitmap ls_bt = ReadImageFile(imagePath);
  934. int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
  935. int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
  936. graph.DrawImage(ls_bt, x, y);
  937. //颗粒外接矩形
  938. double lefttopX = x+Convert.ToInt64(item["RectLeft"]);
  939. if (lefttopX < min_X)
  940. {
  941. min_X = lefttopX;
  942. }
  943. if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
  944. {
  945. max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
  946. }
  947. double lrfttopY = y+ Convert.ToInt64(item["RectTop"]);
  948. if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
  949. {
  950. max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
  951. }
  952. if ( lrfttopY< min_Y)
  953. {
  954. min_Y = lrfttopY;
  955. }
  956. }
  957. int width = Convert.ToInt32(max_X - min_X);
  958. int height = Convert.ToInt32(max_Y - min_Y);
  959. int X = Convert.ToInt32(min_X);
  960. int Y = Convert.ToInt32(min_Y);
  961. Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
  962. Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
  963. return bmap;
  964. }
  965. /// <summary>
  966. /// 拼接颗粒黑白图
  967. /// </summary>
  968. /// <param name="sub">拼接字符串</param>
  969. /// <param name="xs">xs = pixw / ScanFieldSize</param>
  970. /// <param name="path">报告文件路径</param>
  971. /// <param name="picHeight">图像高</param>
  972. /// <param name="picWidth">帧图宽</param>
  973. /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
  974. /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
  975. /// <returns></returns>
  976. 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)
  977. {
  978. string vs = "," + sub.Replace(':', '-') + ",";
  979. DataTable dataTable = GetParticleAllForBig(vs);
  980. if (dataTable.Rows.Count == 0)
  981. {
  982. return null;
  983. }
  984. //内接矩形
  985. double max_Y = Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
  986. double max_X = Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
  987. double min_Y = max_Y;
  988. double min_X = max_X;
  989. //拼接field矩形
  990. double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
  991. double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
  992. double T_Y = B_Y;
  993. double L_X = R_X;
  994. foreach (DataRow item in dataTable.Rows)
  995. {
  996. double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
  997. if (X_AXIS_DIRECTION == OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  998. {
  999. if (lefttopXH > L_X)
  1000. {
  1001. L_X = lefttopXH;
  1002. }
  1003. if (lefttopXH < R_X)
  1004. {
  1005. R_X = lefttopXH;
  1006. }
  1007. }
  1008. else
  1009. {
  1010. if (lefttopXH < R_X)
  1011. {
  1012. R_X = lefttopXH;
  1013. }
  1014. if (lefttopXH > L_X)
  1015. {
  1016. L_X = lefttopXH;
  1017. }
  1018. }
  1019. double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
  1020. if (Y_AXIS_DIRECTION == OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  1021. {
  1022. if (lrfttopYH < B_Y)
  1023. {
  1024. B_Y = lrfttopYH;
  1025. }
  1026. if (lrfttopYH > T_Y)
  1027. {
  1028. T_Y = lrfttopYH;
  1029. }
  1030. }
  1031. else
  1032. {
  1033. if (lrfttopYH > B_Y)
  1034. {
  1035. B_Y = lrfttopYH;
  1036. }
  1037. if (lrfttopYH < T_Y)
  1038. {
  1039. T_Y = lrfttopYH;
  1040. }
  1041. }
  1042. }
  1043. int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
  1044. int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
  1045. //构造最终的图片白板
  1046. Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
  1047. Graphics graph = Graphics.FromImage(tableChartImage);
  1048. graph.Clear(Color.White);
  1049. //初始化这个大图
  1050. graph.DrawImage(tableChartImage, 0, 0);
  1051. foreach (DataRow item in dataTable.Rows)
  1052. {
  1053. string strs = @"select * from Segment where FieldId="+item["fieldid"].ToString()+" and ParticleId="+item["particleid"].ToString();
  1054. DataTable DTS = dbHelper.ExecuteDataTable(strs, null);
  1055. DataRow[] dd = DTS.Select();
  1056. List<Segment> flist = dbHelper.RowsToList<Segment>(dd);
  1057. int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
  1058. int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
  1059. //颗粒外接矩形
  1060. double lefttopX = x + Convert.ToInt64(item["RectLeft"]);
  1061. if (lefttopX < min_X)
  1062. {
  1063. min_X = lefttopX;
  1064. }
  1065. if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
  1066. {
  1067. max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
  1068. }
  1069. double lrfttopY = y + Convert.ToInt64(item["RectTop"]);
  1070. if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
  1071. {
  1072. max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
  1073. }
  1074. if (lrfttopY < min_Y)
  1075. {
  1076. min_Y = lrfttopY;
  1077. }
  1078. foreach (Segment seg in flist)
  1079. {
  1080. int f_length = seg.Length;
  1081. for (int m = 0; m < f_length; m++)
  1082. {
  1083. int lsjs_x = seg.Start + m+ x;
  1084. int lsjs_y = seg.Height+ y;
  1085. tableChartImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
  1086. }
  1087. }
  1088. }
  1089. int width = Convert.ToInt32(max_X - min_X);
  1090. int height = Convert.ToInt32(max_Y - min_Y);
  1091. int X = Convert.ToInt32(min_X);
  1092. int Y = Convert.ToInt32(min_Y);
  1093. Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
  1094. Bitmap bmap = GetBitmapByParticle(tableChartImage, rectangle);
  1095. return bmap;
  1096. }
  1097. /// <summary>
  1098. /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
  1099. /// </summary>
  1100. /// <param name="path"></param>
  1101. /// <returns></returns>
  1102. public Bitmap ReadImageFile(string path)
  1103. {
  1104. if (!File.Exists(path))
  1105. {
  1106. return null;//文件不存在
  1107. }
  1108. FileStream fs = File.OpenRead(path); //OpenRead
  1109. int filelength = 0;
  1110. filelength = (int)fs.Length; //获得文件长度
  1111. Byte[] image = new Byte[filelength]; //建立一个字节数组
  1112. fs.Read(image, 0, filelength); //按字节流读取
  1113. System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
  1114. fs.Close();
  1115. Bitmap bit = new Bitmap(result);
  1116. return bit;
  1117. }
  1118. /// <summary>
  1119. /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
  1120. /// </summary>
  1121. /// <param name="in_cotsparticleclr"></param>
  1122. /// <returns></returns>
  1123. public Bitmap GetBitmapByParticle(Bitmap ls_bt, Rectangle offset_rect)
  1124. {
  1125. //为了能把整个颗粒显示完整
  1126. offset_rect.X = offset_rect.X - 20;
  1127. offset_rect.Y = offset_rect.Y - 20;
  1128. offset_rect.Width = offset_rect.Width + 40;
  1129. offset_rect.Height = offset_rect.Height + 40;
  1130. //防止计算偏差后,有坐标溢出现象
  1131. if (offset_rect.X < 0)
  1132. offset_rect.X = 0;
  1133. if (offset_rect.Y < 0)
  1134. offset_rect.Y = 0;
  1135. if (offset_rect.X + offset_rect.Width > ls_bt.Width)
  1136. {
  1137. offset_rect.Width = ls_bt.Width - offset_rect.X;
  1138. }
  1139. if (offset_rect.Y + offset_rect.Height > ls_bt.Height)
  1140. {
  1141. offset_rect.Height = ls_bt.Height - offset_rect.Y;
  1142. }
  1143. Bitmap new_ret_bp;
  1144. //防止为0后面计算出错
  1145. if (offset_rect.Width > 0 && offset_rect.Height > 0)
  1146. {
  1147. //最后通过list_showsegment组建成新的图片,进行返回
  1148. new_ret_bp = ls_bt.Clone(offset_rect, ls_bt.PixelFormat);
  1149. }
  1150. else
  1151. {
  1152. new_ret_bp = new Bitmap(offset_rect.Width, offset_rect.Height);
  1153. }
  1154. return new_ret_bp;
  1155. }
  1156. public void InsertUpdate(List<int> particleID, List<string> particleData)
  1157. {
  1158. List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
  1159. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  1160. cmdlist.Add(str);
  1161. try
  1162. {
  1163. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  1164. }
  1165. catch (Exception e)
  1166. {
  1167. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  1168. }
  1169. }
  1170. public KeyValuePair<string, SQLiteParameter[]> GetUpdataAIncACmd(List<int> particleID, List<string> particleData)
  1171. {
  1172. var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
  1173. return str;
  1174. }
  1175. public void ExecuteNonQueryBatch(List<KeyValuePair<string, SQLiteParameter[]>> cmdlist)
  1176. {
  1177. try
  1178. {
  1179. dbHelper.ExecuteNonQueryBatch(ref cmdlist);
  1180. }
  1181. catch (Exception e)
  1182. {
  1183. //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
  1184. }
  1185. }
  1186. /// <summary>
  1187. /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
  1188. /// </summary>
  1189. /// <param name="in_clr_tagid">颗粒id</param>
  1190. /// <param name="in_clr_fieldid"></param>
  1191. /// <param name="Search_xray"></param>
  1192. /// <param name="Analysis_xray"></param>
  1193. public Particle GetXrayByParticleTagIDAndFieldID_ForMergeParticle(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray)
  1194. {
  1195. Search_xray = new uint[2000];
  1196. Analysis_xray = new uint[2000];
  1197. Particle particle = new Particle();
  1198. particle = GetMergedParticleInfo(in_clr_fieldid, in_clr_tagid, out Search_xray, out Analysis_xray);
  1199. return particle;
  1200. }
  1201. public List<ShowElementInfo> GetShowElementInfos_ForMergeParticle(List<Element> list_celementchemistryclr)
  1202. {
  1203. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  1204. for (int i = 0; i < list_celementchemistryclr.Count; i++)
  1205. {
  1206. ShowElementInfo ls_sei = new ShowElementInfo();
  1207. ls_sei.ElementName = list_celementchemistryclr[i].Name;
  1208. ls_sei.Percentage = list_celementchemistryclr[i].Percentage;
  1209. ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).K_Peak);
  1210. double de_sx2 = 0;
  1211. if (CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "" || CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak == "-")
  1212. {
  1213. de_sx2 = 0;
  1214. }
  1215. else
  1216. {
  1217. de_sx2 = Convert.ToDouble(CListPeriodic.GetPeriodicByEleName(ls_sei.ElementName).L_Peak);
  1218. }
  1219. ls_sei.dLF = de_sx2;
  1220. list_showelementinfo.Add(ls_sei);
  1221. }
  1222. list_showelementinfo.Sort((p1, p2) => p2.Percentage.CompareTo(p1.Percentage));
  1223. return list_showelementinfo;
  1224. }
  1225. //public Bitmap GetParticlescreenshot(string subt, ResultFile result)
  1226. //{
  1227. // Bitmap bmap = null;
  1228. // KeyValuePair<string, Bitmap> FieldImage = new KeyValuePair<string, Bitmap>();
  1229. // if (subt != null && subt != "" && subt != "IsSubParticle")
  1230. // {
  1231. // double ScanFieldSize = result.GetScanFieldSizeX();
  1232. // string filePatht = result.FilePath + "\\FIELD_FILES\\";
  1233. // string imagePatht = filePatht + "Field" + subt.Split(',')[0].Split(':')[0].ToString() + ".bmp";
  1234. // Bitmap tempbit = ReadImageFile(imagePatht);
  1235. // int pixw = tempbit.Width;
  1236. // double xs = pixw / ScanFieldSize;
  1237. // OTS_X_AXIS_DIRECTION X_AXIS_DIRECTION = result.GetXAxisDirEnum();
  1238. // OTS_Y_AXIS_DIRECTION Y_AXIS_DIRECTION = result.GetYAxisDirEnum();
  1239. // bmap = GetBitmapForBig(subt, xs, result.FilePath, tempbit.Height, tempbit.Width, X_AXIS_DIRECTION, Y_AXIS_DIRECTION);
  1240. // if (bmap != null)
  1241. // {
  1242. // string[] str = subt.Split(',');
  1243. // bmap.Tag = new List<string>() { str[0].Split(':')[0], str[0].Split(':')[1]};
  1244. // }
  1245. // }
  1246. // else if (subt != "IsSubParticle")
  1247. // {
  1248. // if (FieldImage.Key != particles.Rows[i]["fieldid"].ToString() || FieldImage.Value == null)
  1249. // {
  1250. // string imagePath = filePath + "Field" + particles.Rows[i]["fieldid"].ToString() + ".bmp";
  1251. // FieldImage = new KeyValuePair<string, Bitmap>(particles.Rows[i]["fieldid"].ToString(), Particledata.ReadImageFile(imagePath));
  1252. // }
  1253. // 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"]) };
  1254. // Bitmap bmap = GetBitmapByParticle(FieldImage.Value, rectangle);
  1255. // 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() };
  1256. // dgV_ParticlesDevidePage.Rows[add_rowindex].Cells[k].Value = bmap;
  1257. // dgV_ParticlesDevidePage.Rows[add_rowindex].Height = bmap.Height + 20;
  1258. // }
  1259. // return bmap;
  1260. //}
  1261. #endregion
  1262. #region 清洁度
  1263. public ParticleData()
  1264. {
  1265. }
  1266. /// <summary>
  1267. /// 获得颗粒类别
  1268. /// </summary>
  1269. /// <param name="StandardLibraryAddress">标准库地址</param>
  1270. /// <returns></returns>
  1271. public DataTable ObtainParticleCategory_start(string StandardLibraryAddress)
  1272. {
  1273. DataTable dataTable = new DataTable();
  1274. dataTable.Columns.Add("GroupId");
  1275. dataTable.Columns.Add("GroupName");
  1276. dataTable.Columns.Add("inoId");
  1277. dataTable.Columns.Add("display");
  1278. DataTable get_dt = SelectStandardLibraryGrouping(StandardLibraryAddress);
  1279. if (get_dt.Rows.Count==0)
  1280. {
  1281. DataRow data = dataTable.NewRow();
  1282. data["inoId"] = 0;
  1283. data["GroupId"] = 0;
  1284. data["GroupName"] = "Default";
  1285. data["display"] = "0";
  1286. dataTable.Rows.Add(data);
  1287. return dataTable;
  1288. }
  1289. DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  1290. int shul = 0;
  1291. string DefaultGroupId = "";
  1292. foreach (DataRow row in dataRow)
  1293. {
  1294. if (row.ItemArray[1].ToString() != "Default")
  1295. {
  1296. DataRow data = dataTable.NewRow();
  1297. data["inoId"] = shul;
  1298. data["GroupId"] = row.ItemArray[0].ToString();
  1299. data["GroupName"] = row.ItemArray[1].ToString();
  1300. data["display"] = "0";
  1301. dataTable.Rows.Add(data);
  1302. shul++;
  1303. }
  1304. else
  1305. {
  1306. DefaultGroupId = row.ItemArray[0].ToString();
  1307. }
  1308. }
  1309. DataRow data2 = dataTable.NewRow();
  1310. data2["inoId"] = shul;
  1311. data2["GroupId"] = DefaultGroupId;
  1312. data2["GroupName"] = "Default";
  1313. data2["display"] = "0";
  1314. dataTable.Rows.Add(data2);
  1315. return dataTable;
  1316. }
  1317. /// <summary>
  1318. /// 获取规则数据
  1319. /// </summary>
  1320. /// <param name="strings">组类别</param>
  1321. /// <param name="a_SelectedIndex">标准库地址</param>
  1322. /// <returns></returns>
  1323. public List<DataTable> ObtainRuleData_start(DataTable strings, string a_SelectedIndex)
  1324. {
  1325. List<DataTable> List_data = new List<DataTable>();
  1326. DataTable dt_stl = new DataTable();
  1327. SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
  1328. dt_stl = sh.ExecuteQuery("select * from ClassifySTD");
  1329. dt_stl.Columns.Add("display");
  1330. if (dt_stl == null)
  1331. {
  1332. List_data.Add(dt_stl);
  1333. return List_data;
  1334. }
  1335. for (int i = 0; i < strings.Rows.Count; i++)
  1336. {
  1337. DataTable table = dt_stl.Clone();
  1338. table.TableName = strings.Rows[i]["GroupId"].ToString();
  1339. for (int a = 0; a < dt_stl.Rows.Count; a++)
  1340. {
  1341. if (strings.Rows[i]["GroupId"].ToString() == dt_stl.Rows[a]["GroupId"].ToString())
  1342. {
  1343. dt_stl.Rows[a]["display"] = 0;
  1344. table.Rows.Add(dt_stl.Rows[a].ItemArray);
  1345. }
  1346. }
  1347. DataView dvs = table.DefaultView;
  1348. dvs.Sort = "ListNum ASC";
  1349. DataTable TemporaryDataGroup = dvs.ToTable();
  1350. List_data.Add(TemporaryDataGroup);
  1351. }
  1352. return List_data;
  1353. }
  1354. private DataTable SelectStandardLibraryGrouping(string a_SelectedIndex)
  1355. {
  1356. DataTable dt_stl = new DataTable();
  1357. SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
  1358. dt_stl = sh.ExecuteQuery("select * from STDGroups");
  1359. return dt_stl;
  1360. }
  1361. /// <summary>
  1362. /// 获得颗粒类别
  1363. /// </summary>
  1364. /// <returns></returns>
  1365. public List<string> ObtainParticleCategory(OTSReport_Export m_otsreport_export, BasicData basicData)
  1366. {
  1367. List<string> ClassName = new List<string>();
  1368. if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype != OTS_SysType_ID.IncA)
  1369. {
  1370. DataTable get_dt = ReadClassification(basicData);
  1371. DataTable getClass_dt = get_dt.Clone();
  1372. DataRow[] dataRow = get_dt.Select("", "iorder ASC");
  1373. foreach (DataRow row in dataRow)
  1374. {
  1375. if (row.ItemArray[1].ToString() != "Default")
  1376. {
  1377. getClass_dt.ImportRow(row);
  1378. }
  1379. }
  1380. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1381. {
  1382. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  1383. }
  1384. ClassName.Add("Default");
  1385. }
  1386. else
  1387. {
  1388. DataTable getClass_dt = ReadClassification(basicData);
  1389. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1390. {
  1391. ClassName.Add(getClass_dt.Rows[i][1].ToString());
  1392. }
  1393. bool bl = false;
  1394. for (int i = 0; i < getClass_dt.Rows.Count; i++)
  1395. {
  1396. if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
  1397. && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
  1398. if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
  1399. {
  1400. if (!bl)
  1401. {
  1402. ClassName.Add("Default");
  1403. bl = true;
  1404. }
  1405. }
  1406. else
  1407. {
  1408. bool isDefault = false;
  1409. for (int a = 0; a < ClassName.Count; a++)
  1410. {
  1411. if (getClass_dt.Rows[i]["GroupName"].ToString() == "Default")
  1412. {
  1413. isDefault = true;
  1414. }
  1415. }
  1416. if (isDefault)
  1417. {
  1418. if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
  1419. {
  1420. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1421. }
  1422. }
  1423. else
  1424. {
  1425. ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
  1426. }
  1427. }
  1428. }
  1429. }
  1430. return ClassName;
  1431. }
  1432. public DataTable ReadClassification(BasicData basicData)
  1433. {
  1434. DataTable dt_stl = new DataTable();
  1435. SqLiteHelper sh = new SqLiteHelper("data source='" + basicData.GetFilePath() + "\\" + basicData.GetResfile() + "'");
  1436. dt_stl = sh.ExecuteQuery("select * from STDGroups");
  1437. return dt_stl;
  1438. }
  1439. #endregion
  1440. }
  1441. }