1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231 |
- using OTSCommon.DBOperate;
- using OTSCommon.DBOperate.Model;
- using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SQLite;
- using System.Drawing;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Linq;
- using static DevExpress.XtraEditors.Mask.Design.MaskSettingsForm.DesignInfo.MaskManagerInfo;
- using static OTSDataType.otsdataconst;
- using static OTSIncAReportApp.OTSReport_Export;
- namespace OTSIncAReportApp.DataOperation.DataAccess
- {
- public class ParticleData
- {
- private SqlHelper dbHelper;
- public ParticleData(string path)
- {
- dbHelper = new SqlHelper("data source='" + path + "\\FIELD_FILES\\Inclusion.db'");
- }
- /// <summary>
- /// 获取SegmentList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public List<Particle> GetParticleList(Particle model)
- {
- //存放查询数据的数据表
- SQLiteParameter[] Parameter = new SQLiteParameter[1]
- {
- new SQLiteParameter("@FieldId", model.FieldId)
- };
- string sql = "select * from IncAData where Fieldid=@FieldId";
- DataTable DT = dbHelper.ExecuteDataTable(sql, Parameter);
- var result = new List<Particle>();
- foreach (DataRow dr in DT.Rows)
- {
- Particle item = new Particle() { };
- result.Add(item);
- }
- return result;
- }
- /// <summary>
- /// 获取ParticleListBy
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public List<Particle> GetParticleListByCon(string con, string max, string min, int display)
- {
- string sqlp = "select a.* from IncAData a ";
- string where = " where 1=1 ";
- if (display == 1)
- {
- where = where + " and a.XrayId >-1 ";
- }
- if (con != "")
- {
- where = where + " and a." + con + ">" + min + " and a." + con + "<" + max;
- }
- sqlp = sqlp + where;
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- List<Particle> listp = dbHelper.TableToList<Particle>(DT);
- return listp;
- }
- /// <summary>
- /// 获取ParticleList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetParticleListAndEm()
- {
- string sqlp = @"select *,
- (select group_concat(name||'-'||Percentage,';')
- from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element
- from INcAData where xrayid>-1";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取ParticleList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetMergedParticleInfo()
- {
- string sqlp = @"select *,
- (select group_concat(name||'-'||Percentage,';')
- from ElementChemistry where XRayId =MergedParticleInfo.XRayId and fieldid=MergedParticleInfo.fieldid ) as Element
- from MergedParticleInfo ";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取ParticleList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetParticleListByIncA(string con)
- {
- string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,sum(Area) as Area,avg(" + con
- + ") as av,max(" + con
- + ") as max ";
- sqlp = sqlp + "from IncAData where typeid !=-1 and typeid !=4 group by TypeId";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取ParticleList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetParticleListForParticlSize(string con, string fieldAndPartic)
- {
- string sqlp = @"select TypeId,TypeName,GroupId ,TypeColor,count(1) as con,avg(" + con
- + ") as av,max(" + con
- + ") as max ,GroupName";
- sqlp = sqlp + " from IncAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- sqlp = sqlp + " group by TypeId ";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- if (con == "area")
- {
- for (int i = 0; i < DT.Rows.Count; i++)
- {
- DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
- }
- }
- return DT;
- }
- /// <summary>
- /// 获取ParticleList
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetParticleListForParticlSizeID(string con, string fieldAndPartic)
- {
- string sqlp = @"select TypeId,TypeName,TypeColor,count(1) as con,avg(" + con
- + ") as av,max(" + con
- + ") as max ,GroupName ,GroupId";
- sqlp = sqlp + " from IncAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- sqlp = sqlp + " group by TypeId ";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- if (con == "area")
- {
- for (int i = 0; i < DT.Rows.Count; i++)
- {
- DT.Rows[i]["max"] = Math.Sqrt((double)DT.Rows[i]["max"] / Math.PI) * 2;
- }
- }
- return DT;
- }
- /// <summary>
- /// 获取element含量
- /// </summary>
- /// <returns></returns>
- public DataTable GetElementForArea(string fieldAndPartic)
- {
- string sqlp = @"select e.name,sum(e.percentage*p.area) as earea from ElementChemistry e
- inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid from IncAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
- }
- sqlp = sqlp + " group by e.name order by sum(e.percentage*p.area) desc";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取element含量
- /// </summary>
- /// <returns></returns>
- public DataTable GetSmallElementForArea()
- {
- 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
- group by e.name order by sum(e.percentage*i.area) desc";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取所有Particle
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleAll(string fieldAndPartic)
- {
- string sqlp = @"select * from INcAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- DT.Columns.Add("ECD");
- for (int i = 0; i < DT.Rows.Count; i++)
- {
- DT.Rows[i]["ECD"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
- }
- return DT;
- }
- public DataTable GetParticleAllforparticlelist(string fieldAndPartic)
- {
- string sqlp = @"select * from INcAData";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " where '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- for (int i = 0; i < DT.Rows.Count; i++)
- {
- DT.Rows[i]["Area"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
- }
- return DT;
- }
- /// <summary>
- /// 查找所有颗粒的颜色、面积、种类名称信息
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleTypeInformation()
- {
- string sqlp = @"select Area,TypeName,TypeColor from IncAData";
- DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
- return dt;
- }
- /// <summary>
- /// 查找IncaData表中所有种类
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleClassAll()
- {
- string sqlp = @"SELECT DISTINCT TypeName FROM IncaData";
- DataTable dt = dbHelper.ExecuteDataTable(sqlp, null);
- return dt;
- }
- /// <summary>
- /// 获取所有Particle
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleAllHaveXray(string fieldAndPartic)
- {
- string incaSql = @"select * from IncAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- incaSql = incaSql + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- DataTable incaDT = dbHelper.ExecuteDataTable(incaSql, null);
- incaDT.Columns.Add("Element");
- DataTable dt_element = GetElementChemistry();
- DataTable elementchemistry = dt_element.Clone();
- for (int i = 0; i < dt_element.Rows.Count; i++)
- {
- if (dt_element.Rows[i]["Name"].ToString() != "Fe")
- {
- elementchemistry.Rows.Add(dt_element.Rows[i].ItemArray);
- }
- }
- for (int i = 0; i < incaDT.Rows.Count; i++)
- {
- string str = "XRayId = " + incaDT.Rows[i]["particleId"].ToString() + " and fieldid = " + incaDT.Rows[i]["fieldid"].ToString();
- DataRow[] drs = elementchemistry.Select(str);
- string ConcatenatedString = "";
- for (int j = 0; j < drs.Length; j++)
- {
- ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
- }
- incaDT.Rows[i]["Element"] = ConcatenatedString;
- }
- return incaDT;
- }
- /// <summary>
- /// 获取所有Particle
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleHaveXray(string fieldAndPartic)
- {
- string sqlp = @"select *,
- (select group_concat(name||'-'||Percentage,';')
- from ElementChemistry where XRayId =INcAData.XRayId and fieldid=INcAData.fieldid ) as Element from INcAData where xrayid>-1 ";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- for (int i = 0; i < DT.Rows.Count; i++)
- {
- DT.Rows[i]["Area"] = Math.Sqrt((double)DT.Rows[i]["Area"] / Math.PI) * 2;
- }
- return DT;
- }
- /// <summary>
- /// 获取所有Particle
- /// </summary>
- /// <returns></returns>
- public List<Particle> GetParticleAllList()
- {
- string sqlp = @"select * from INcAData";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- List<Particle> listp = dbHelper.TableToList<Particle>(DT);
- return listp;
- }
- /// <summary>
- /// 获取所有Particle
- /// </summary>
- /// <returns></returns>
- public DataTable GetParticleAllList_DataTable()
- {
- string sqlp = @"select * from INcAData";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取所有分类的面积
- /// </summary>
- /// <param name="fieldAndPartic">选择颗粒</param>
- /// <returns></returns>
- public DataTable GetAreaByAllIncA(string fieldAndPartic)
- {
- string sqlp = @"select TypeId,TypeName,GroupId,sum(area) as ar,count(1) as con ,GroupName from INcAData where typeid !=-1 and typeid !=4";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||fieldid||'-'||particleid||',%')";
- }
- sqlp = sqlp + " group by TypeId";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取所有大颗粒没有的小颗粒分类
- /// </summary>
- /// <param name="fieldAndPartic">选择颗粒</param>
- /// <returns></returns>
- public DataTable GetSmallParticleInfo()
- {
- 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";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取不同分类的面积
- /// </summary>
- /// <param name="fieldAndPartic">选择颗粒</param>
- /// <returns></returns>
- public DataTable GetAreaByIncA(string TypeId, string fieldAndPartic)
- {
- string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
- inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid where p.TypeId=" + TypeId + " ";
- if (fieldAndPartic != "")
- {
- sqlp = sqlp + " and '" + fieldAndPartic + "' like ('%,'||p.fieldid||'-'||p.particleid||',%')";
- }
- sqlp = sqlp + " group by e.name";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- public DataTable GetAreaByIncA_All()
- {
- string sqlp = @"select e.name,sum(e.percentage*p.area) as pc,p.TypeId from ElementChemistry e
- inner join INcAData p on e.xrayid=p.xrayid and e.fieldid = p.fieldid group by e.name ";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取全部的物质大类
- /// </summary>
- /// <returns></returns>
- public DataTable GetAllClass()
- {
- string sqlp = @"select GroupName from IncAData group by GroupName order by count(1) desc";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取所有元素
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public DataTable GetAllElement()
- {
- string sqlp = @"select name from ElementChemistry group by name order by count(1) desc";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- /// <summary>
- /// 获取常用夹杂物分类信息
- /// </summary>
- /// <returns></returns>
- public DataTable GetCommonlyUsedClassifyData()
- {
- string sqlp = @"select
- (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 ,
- (select count(typeid) from incadata where typeid BETWEEN 10000 and 10999 ) as OXIDE ,
- (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 ,
- (select count(typeid) from incadata where typeid BETWEEN 12000 and 12999 ) as NITRIDE ,
- (select count(typeid) from incadata where typeid BETWEEN 11000 and 11999 ) as SULFIDE ";
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- return DT;
- }
- public bool DeleteFromData(string fieldid, string particleid)
- {
- string sqlp = @"delete from IncAData where FieldId=" + fieldid + " and ParticleId="
- + particleid;
- if (dbHelper.ExecuteQuery_bool(sqlp))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- /// <summary>
- /// 获取颗粒信息
- /// </summary>
- /// <param name="model">Feature</param>
- /// <returns></returns>
- public Particle GetParticleByFidAndPid(string fieldid, string particleid)
- {
- string sqlp = @"select *,(select xraydata from xraydata where xrayindex=INcAData.xrayid and fieldid="
- + fieldid + ") as XRayData,(select group_concat(name || '_' || Percentage, ';')from ElementChemistry where XRayId = INcAData.XRayId and fieldid ="
- + fieldid + ") as Element from INcAData where fieldid="
- + fieldid + " and particleid= " + particleid;
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- List<Particle> listp = dbHelper.TableToList<Particle>(DT);
- Particle particle = new Particle();
- if (listp.Count > 0)
- {
- particle = listp[0];
- List<OTSCommon.DBOperate.Model.Element> ElementList = new List<OTSCommon.DBOperate.Model.Element>();
- string element = DT.Rows[0]["Element"].ToString();
- for (int i = 0; i < element.Split(';').Count(); i++)
- {
- if (element.Split(';')[i] != "")
- {
- OTSCommon.DBOperate.Model.Element ele = new OTSCommon.DBOperate.Model.Element() { Name = element.Split(';')[i].Split('_')[0], Percentage = Convert.ToDouble(element.Split(';')[i].Split('_')[1]) };
- ElementList.Add(ele);
- }
- }
- particle.ElementList = ElementList;
- }
- return particle;
- }
- public Particle GetParticleXrayDataByFidAndPid(string fieldid, string xrayid)
- {
- string sqlp = @"select xraydata from xraydata where xrayindex=" + xrayid + " and fieldid="
- + fieldid;
- DataTable DT = dbHelper.ExecuteDataTable(sqlp, null);
- List<Particle> listp = dbHelper.TableToList<Particle>(DT);
- if (listp.Count > 0)
- {
- return listp[0];
- }
- else
- {
- return null;
- }
- }
- public enum PARTCLE_TYPE
- {
- SMALL = 0,//过小颗粒
- OVERSIZE = 1,//过大颗粒
- AVE_GRAY_NOT_INRANRE = 2,//亮度不在分析范围内的颗粒
- SEARCH_X_RAY = 3,
- LOW_COUNT = 4,//低计数率颗粒
- NO_INTEREST_ELEMENTS = 5,
- NO_ANALYSIS_X_RAY = 6,//不含分析元素
- NOT_IDENTIFIED_SIC = 7,//非夹杂物颗粒SiC
- NOT_IDENTIFIED_FEO = 8,//非夹杂物颗粒FeO
- NOT_IDENTIFIED = 9,//未识别颗粒
- IDENTIFIED = 10,//分析颗粒,当为可识别类型时,可以被进一步识别为用户类型(1000以上),系统预定义类型(10000以上),所以最终颗粒类型不会为8,但可能为7
- USER_DEFINED_MIN = 1000,
- SYS_DEFINED_MIN = 10000
- }
- #region 分页添加读取数据库函数
- /// <summary>
- /// 获取分页查询所需信息
- /// </summary>
- /// <param name=""></param>
- /// <param name=""></param>
- /// <returns></returns>
- public DataTable GetInfoForPartucleDevidePage(int currentPage, int pagesize, string OrderFunction, string condition)
- {
- int p = (currentPage - 1) * pagesize;
- 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();
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetIncaSurfaceData( List<string> lst_str)
- {
- DataTable particlesAll = GetInfoForPartucleDevidePage2("");
- DataTable dt_element = GetElementChemistry();
- List<int> list_int = new List<int>();
- for (int a = 0; a < lst_str.Count; a++)
- {
- for (int i = 0; i < dt_element.Rows.Count; i++)
- {
- if (dt_element.Rows[i]["Name"].ToString() == lst_str[a].ToString())
- {
- list_int.Add(i);
- }
- }
- }
- for (int i = 0; i < list_int.Count; i++)
- {
- dt_element.Rows[list_int[i]].Delete();
- }
- dt_element.AcceptChanges();
- for (int i = 0; i < particlesAll.Rows.Count; i++)
- {
- string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
- DataRow[] drs = dt_element.Select(str);
- string ConcatenatedString = "";
- for (int j = 0; j < drs.Length; j++)
- {
- ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
- }
- particlesAll.Rows[i]["Element"] = ConcatenatedString;
- }
- return particlesAll;
- }
- public DataTable AddElementColumn(DataTable particlesAll, c_TemplateClass m_mbszclass)
- {
- if (!particlesAll.Columns.Contains("Element"))
- {
- particlesAll.Columns.Add("Element");
- }
- DataTable dt_element = GetElementChemistry();
- for (int i = 0; i < particlesAll.Rows.Count; i++)
- {
- string str = "XRayId = " + particlesAll.Rows[i]["particleId"].ToString() + " and fieldid = " + particlesAll.Rows[i]["fieldid"].ToString();
- DataRow[] drs = dt_element.Select(str);
- string ConcatenatedString = "";
- for (int j = 0; j < drs.Length; j++)
- {
- //判断是否在处理元素表中
- bool bl = false;
- for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_qcys.Count; a++)
- {
- if (drs[j]["name"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_qcys[a].ToString())
- {
- bl = true;
- }
- }
- if (!bl)
- {
- ConcatenatedString += drs[j]["name"] + "-" + ChangeDataToD(drs[j]["Percentage"].ToString()) + ';';
- }
- }
- particlesAll.Rows[i]["Element"] = ConcatenatedString;
- }
- return particlesAll;
- }
- /// <summary>
- /// 拼接颗粒
- /// </summary>
- /// <param name="lst_str"></param>
- /// <returns></returns>
- public DataTable GetSplicingParticlesData()
- {
- DataTable particlesAll = GetSplicingParticles();
- return particlesAll;
- }
- /// <summary>
- /// 保留两位小数
- /// </summary>
- /// <param name="strData"></param>
- /// <returns></returns>
- private string ChangeDataToD(string strData)
- {
- Decimal dData = 0.00M;
- if (strData.Contains("E"))
- {
- dData = Convert.ToDecimal(Decimal.Parse(strData.ToString(), System.Globalization.NumberStyles.Float));
- }
- else
- {
- return Convert.ToDouble(strData).ToString("0.00");
- }
- return Convert.ToDouble(dData).ToString("0.00");
- }
- public DataTable GetInfoForPartucleDevidePage2(string condition)
- {
- string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
- "as 'SEMPosX',FieldPosY as 'SEMPosY',XrayId,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,SEMPosX,SEMPosY,XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,'' as SubParticles,'' " +
- "as Element from INcAData where xrayid > -1 and instr(','||(select ifnull(group_concat(SubParticles, ','),'') from MergedParticleInfo)|| ',',',' || fieldid || ':' || particleid || ',')= 0 " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetSplicingParticles()
- {
- string sqliteString1 = "select * from MergedParticleInfo";
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString1);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_analyticalParticle(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where (xrayid > -1 and typeid !=9 and typeid !=-1 and typeid !=4)" +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_otherParticle(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where (typeid =9 or typeid =-1 or typeid =4) " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_mergeParticles(string condition)
- {
- string sqliteString = "select fieldid,particleid,AveGray,RectLeft,RectTop,RectWidth,RectHeight,Area,PosX,PosY,TypeId,SegmentNum,FieldPosX " +
- "as 'SEMPosX',FieldPosY as 'SEMPosY',XrayId,DMAX,DMIN,DPERP,PERIMETER,ORIENTATION,DINSCR,DMEAN,DELONG,DFERET,TypeName,TypeColor,SubParticles,''as Element from MergedParticleInfo where 1=1 " + condition;
- DataTable DT1 = new DataTable();
- try
- {
- DT1 = dbHelper.ExecuteQuery(sqliteString);
- }
- catch
- {
-
- }
- return DT1;
- }
- public DataTable GetInfoForPartucleDevidePage_allParticles(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where 1=1 " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_NotIdentifyParticle(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where typeid =9 " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_InvalidParticle(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where typeid =-1 " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetInfoForPartucleDevidePage_LowCountsParticle(string condition)
- {
- 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,TypeName,TypeColor,'' as Element from INcAData where typeid =4 " +
- condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetClassificationOfAllParticles(string condition)
- {
- string sqliteString1 = "select distinct TypeName from INcAData "+ condition;
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString1);
- return DT;
- }
- public DataTable GetXRayData()
- {
- string sqliteString = @"select * from xraydata";
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public DataTable GetElementChemistry()
- {
- string sqliteString = "select * from ElementChemistry";
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- /// <summary>
- /// 得到图形形状
- /// </summary>
- /// <returns></returns>
- public DataTable GetSegment()
- {
- string sqliteString = "select * from Segment";
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public Bitmap GetBitmapForBig(string sub, double xs, string path, int picHeight, int picWidth)
- {
- string vs = "," + sub.Replace(':', '-') + ",";
- DataTable dataTable = GetParticleAll(vs);
- if (dataTable.Rows.Count == 0)
- {
- return null;
- }
- //内接矩形
- double max_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs - Convert.ToInt64(dataTable.Rows[0]["RectTop"]);
- double max_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs + Convert.ToInt64(dataTable.Rows[0]["RectLeft"]);
- double min_Y = max_Y;
- double min_X = max_X;
- //拼接field矩形
- double MAX_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
- double MAX_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
- double MIN_Y = MAX_Y;
- double MIN_X = MAX_X;
- foreach (DataRow item in dataTable.Rows)
- {
- //颗粒外接矩形
- double lefttopX = Convert.ToInt64(item["FieldPosX"]) * xs + Convert.ToInt64(item["RectLeft"]);
- if (lefttopX < min_X)
- {
- min_X = lefttopX;
- }
- if (lefttopX + Convert.ToInt64(item["RectWidth"]) > max_X)
- {
- max_X = lefttopX + Convert.ToInt64(item["RectWidth"]);
- }
- double lrfttopY = Convert.ToInt64(item["FieldPosY"]) * xs - Convert.ToInt64(item["RectTop"]);
- if (max_Y < lrfttopY)
- {
- max_Y = lrfttopY;
- }
- if (min_Y > lrfttopY - Convert.ToInt64(item["RectHeight"]))
- {
- min_Y = lrfttopY - Convert.ToInt64(item["RectHeight"]);
- }
- //画布
- double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
- if (lefttopXH > MAX_X)
- {
- MAX_X = lefttopXH;
- }
- if (lefttopXH < MIN_X)
- {
- MIN_X = lefttopXH;
- }
- double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
- if (MAX_Y < lrfttopYH)
- {
- MAX_Y = lrfttopYH;
- }
- if (MIN_Y > lrfttopYH)
- {
- MIN_Y = lrfttopYH;
- }
- }
- int WIDTH = Convert.ToInt32(MAX_X - MIN_X) + picWidth;
- int HEIGHT = Convert.ToInt32(MAX_Y - MIN_Y) + picHeight;
- //构造最终的图片白板
- Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
- Graphics graph = Graphics.FromImage(tableChartImage);
- //初始化这个大图
- graph.DrawImage(tableChartImage, 0, 0);
- int width = Convert.ToInt32(max_X - min_X);
- int height = Convert.ToInt32(max_Y - min_Y);
- int X = Convert.ToInt32(min_X - MIN_X);
- int Y = Convert.ToInt32(MAX_Y - max_Y);
- Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
- foreach (DataRow item in dataTable.Rows)
- {
- string filePath = path + "\\FIELD_FILES\\";
- string imagePath = filePath + "Field" + item["fieldid"].ToString() + ".bmp";
- //然后将取出的数据,转换成Bitmap对象
- Bitmap ls_bt = ReadImageFile(imagePath);
- int x = Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - MIN_X);
- int y = Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - MIN_Y);
- graph.DrawImage(ls_bt, x, y);
- }
- Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
- return bmap;
- }
- /// <summary>
- /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
- /// </summary>
- /// <param name="path"></param>
- /// <returns></returns>
- public Bitmap ReadImageFile(string path)
- {
- if (!File.Exists(path))
- {
- return null;//文件不存在
- }
- FileStream fs = File.OpenRead(path); //OpenRead
- int filelength = 0;
- filelength = (int)fs.Length; //获得文件长度
- Byte[] image = new Byte[filelength]; //建立一个字节数组
- fs.Read(image, 0, filelength); //按字节流读取
- System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
- fs.Close();
- Bitmap bit = new Bitmap(result);
- return bit;
- }
- /// <summary>
- /// 传入单颗颗粒的particle类对象,返回从field中抠取出的bitmap对象,抠取单颗颗粒
- /// </summary>
- /// <param name="in_cotsparticleclr"></param>
- /// <returns></returns>
- public Bitmap GetBitmapByParticle(Bitmap ls_bt, Rectangle offset_rect)
- {
- //为了能把整个颗粒显示完整
- offset_rect.X = offset_rect.X - 20;
- offset_rect.Y = offset_rect.Y - 20;
- offset_rect.Width = offset_rect.Width + 40;
- offset_rect.Height = offset_rect.Height + 40;
- //防止计算偏差后,有坐标溢出现象
- if (offset_rect.X < 0)
- offset_rect.X = 0;
- if (offset_rect.Y < 0)
- offset_rect.Y = 0;
- if (offset_rect.X + offset_rect.Width > ls_bt.Width)
- {
- offset_rect.Width = ls_bt.Width - offset_rect.X;
- }
- if (offset_rect.Y + offset_rect.Height > ls_bt.Height)
- {
- offset_rect.Height = ls_bt.Height - offset_rect.Y;
- }
- Bitmap new_ret_bp;
- //防止为0后面计算出错
- if (offset_rect.Width > 0 && offset_rect.Height > 0)
- {
- //最后通过list_showsegment组建成新的图片,进行返回
- new_ret_bp = ls_bt.Clone(offset_rect, ls_bt.PixelFormat);
- }
- else
- {
- new_ret_bp = new Bitmap(offset_rect.Width, offset_rect.Height);
- }
- return new_ret_bp;
- }
- public void InsertUpdate(List<int> particleID, List<string> particleData)
- {
- List<KeyValuePair<string, SQLiteParameter[]>> cmdlist = new List<KeyValuePair<string, SQLiteParameter[]>>();
- var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
- cmdlist.Add(str);
- try
- {
- dbHelper.ExecuteNonQueryBatch(ref cmdlist);
- }
- catch (Exception e)
- {
- //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- }
- public KeyValuePair<string, SQLiteParameter[]> GetUpdataAIncACmd(List<int> particleID, List<string> particleData)
- {
- var str = dbHelper.UpdateINCAEntryData(particleID, particleData);
- return str;
- }
- public void ExecuteNonQueryBatch(List<KeyValuePair<string, SQLiteParameter[]>> cmdlist)
- {
- try
- {
- dbHelper.ExecuteNonQueryBatch(ref cmdlist);
- }
- catch (Exception e)
- {
- //NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- }
- #endregion
- #region 清洁度
- public ParticleData()
- {
- }
- /// <summary>
- /// 获得颗粒类别
- /// </summary>
- /// <param name="StandardLibraryAddress">标准库地址</param>
- /// <returns></returns>
- public DataTable ObtainParticleCategory_start(string StandardLibraryAddress)
- {
- DataTable dataTable = new DataTable();
- dataTable.Columns.Add("GroupId");
- dataTable.Columns.Add("GroupName");
- dataTable.Columns.Add("inoId");
- dataTable.Columns.Add("display");
- DataTable get_dt = SelectStandardLibraryGrouping(StandardLibraryAddress);
- if (get_dt.Rows.Count==0)
- {
- DataRow data = dataTable.NewRow();
- data["inoId"] = 0;
- data["GroupId"] = 0;
- data["GroupName"] = "Default";
- data["display"] = "0";
- dataTable.Rows.Add(data);
- return dataTable;
- }
- DataRow[] dataRow = get_dt.Select("", "iorder ASC");
- int shul = 0;
- string DefaultGroupId = "";
- foreach (DataRow row in dataRow)
- {
- if (row.ItemArray[1].ToString() != "Default")
- {
- DataRow data = dataTable.NewRow();
- data["inoId"] = shul;
- data["GroupId"] = row.ItemArray[0].ToString();
- data["GroupName"] = row.ItemArray[1].ToString();
- data["display"] = "0";
- dataTable.Rows.Add(data);
- shul++;
- }
- else
- {
- DefaultGroupId = row.ItemArray[0].ToString();
- }
- }
- DataRow data2 = dataTable.NewRow();
- data2["inoId"] = shul;
- data2["GroupId"] = DefaultGroupId;
- data2["GroupName"] = "Default";
- data2["display"] = "0";
- dataTable.Rows.Add(data2);
- return dataTable;
- }
- /// <summary>
- /// 获取规则数据
- /// </summary>
- /// <param name="strings">组类别</param>
- /// <param name="a_SelectedIndex">标准库地址</param>
- /// <returns></returns>
- public List<DataTable> ObtainRuleData_start(DataTable strings, string a_SelectedIndex)
- {
- List<DataTable> List_data = new List<DataTable>();
- DataTable dt_stl = new DataTable();
- SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
- dt_stl = sh.ExecuteQuery("select * from ClassifySTD");
- dt_stl.Columns.Add("display");
- if (dt_stl == null)
- {
- List_data.Add(dt_stl);
- return List_data;
- }
-
- for (int i = 0; i < strings.Rows.Count; i++)
- {
- DataTable table = dt_stl.Clone();
- table.TableName = strings.Rows[i]["GroupId"].ToString();
- for (int a = 0; a < dt_stl.Rows.Count; a++)
- {
- if (strings.Rows[i]["GroupId"].ToString() == dt_stl.Rows[a]["GroupId"].ToString())
- {
- dt_stl.Rows[a]["display"] = 0;
- table.Rows.Add(dt_stl.Rows[a].ItemArray);
- }
- }
- DataView dvs = table.DefaultView;
- dvs.Sort = "ListNum ASC";
- DataTable TemporaryDataGroup = dvs.ToTable();
- List_data.Add(TemporaryDataGroup);
- }
- return List_data;
- }
- private DataTable SelectStandardLibraryGrouping(string a_SelectedIndex)
- {
- DataTable dt_stl = new DataTable();
- SqLiteHelper sh = new SqLiteHelper("data source='" + a_SelectedIndex + "'");
- dt_stl = sh.ExecuteQuery("select * from STDGroups");
- return dt_stl;
- }
- /// <summary>
- /// 获得颗粒类别
- /// </summary>
- /// <returns></returns>
- public List<string> ObtainParticleCategory(OTSReport_Export m_otsreport_export, BasicData basicData)
- {
- List<string> ClassName = new List<string>();
- if (m_otsreport_export.m_ReportApp.m_RptConfigFile.Systype != OTS_SysType_ID.IncA)
- {
- DataTable get_dt = ReadClassification(basicData);
- DataTable getClass_dt = get_dt.Clone();
- DataRow[] dataRow = get_dt.Select("", "iorder ASC");
- foreach (DataRow row in dataRow)
- {
- if (row.ItemArray[1].ToString() != "Default")
- {
- getClass_dt.ImportRow(row);
- }
- }
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- ClassName.Add(getClass_dt.Rows[i][1].ToString());
- }
- ClassName.Add("Default");
- }
- else
- {
- DataTable getClass_dt = ReadClassification(basicData);
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- ClassName.Add(getClass_dt.Rows[i][1].ToString());
- }
- bool bl = false;
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() != "NOT_INCLUTION" && getClass_dt.Rows[i]["GroupName"].ToString() != "Invalid"
- && getClass_dt.Rows[i]["GroupName"].ToString() != "Not Identified")
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
- {
- if (!bl)
- {
- ClassName.Add("Default");
- bl = true;
- }
- }
- else
- {
- bool isDefault = false;
- for (int a = 0; a < ClassName.Count; a++)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "Default")
- {
- isDefault = true;
- }
- }
- if (isDefault)
- {
- if (getClass_dt.Rows[i]["GroupName"].ToString() != "Default")
- {
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- }
- else
- {
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- }
- }
- }
- return ClassName;
- }
- public DataTable ReadClassification(BasicData basicData)
- {
- DataTable dt_stl = new DataTable();
- SqLiteHelper sh = new SqLiteHelper("data source='" + basicData.GetFilePath() + "\\" + basicData.GetResfile() + "'");
- dt_stl = sh.ExecuteQuery("select * from STDGroups");
- return dt_stl;
- }
- #endregion
- }
- public class UserLibraryData
- {
- private SqlHelper dbHelper;
- public UserLibraryData(string libraryName,string resultpath)
- {
- NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
- if (!libraryName.Contains(".db"))
- {
- libraryName += ".db";
- }
- if(libraryName.ToLower()== "nostddb.db")
- {
- dbHelper = null;
- log.Error("Failed to load user-defined library" + "!");
- }
- string fullPath = resultpath + libraryName;
- string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + libraryName;
- if (System.IO.File.Exists(fullPath))
- {
- dbHelper = new SqlHelper("data source='" + fullPath + "'");
- log.Warn("Loading the user standard library:" + fullPath + "!");
- }
- else if(System.IO.File.Exists(fullPath2))
- {
- dbHelper = new SqlHelper("data source='" + fullPath2 + "'");
- log.Warn("Loading the user standard library:" + fullPath2 + "!");
- }
- else
- {
- dbHelper = null;
- log.Error("Failed to load user-defined library"+ "!");
- }
- }
- public DataTable GetSubAttributeFromDatabase()
- {
- string sqliteString = "select STDId,Hardness,Density,Electrical_conductivity from ClassifySTD";
- DataTable DT = new DataTable();
- DT = dbHelper.ExecuteQuery(sqliteString);
- return DT;
- }
- public SqlHelper GetSqlHelper() { return dbHelper; }
-
- }
- }
|