123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
-
- using OTSIncAReportApp.DataOperation.DataAccess;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static OTSIncAReportApp.OTSReport_Export;
- namespace OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration
- {
- /// <summary>
- /// 颗粒分析
- /// </summary>
- class ParticleAnalysis
- {
- /// <summary>
- /// 大分类
- /// </summary>
- /// <returns></returns>
- public DataTable GetLargeClassification(BasicData basicData)
- {
- DataTable data = basicData.GetDBData();
- //获取粒级表
- List<string> colid = basicData.GetParticlesizeTable();
-
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for (int i = 0; i < colid.Count; i++)
- {
- ls_partsize_dt.Columns.Add("c" + (i + 1).ToString());
- }
-
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- DataRow dr = ls_partsize_dt.NewRow();
- int colidCount = 1;
- for (int i = 0; i < colid.Count; i++)
- {
- if (colid.Count < i)
- {
- dr["c" + (i + 1).ToString()] = "";
- }
- else
- {
- dr["c" + (i + 1).ToString()] = colid[i];
- ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
- colidCount++;
- }
- }
- ls_partsize_dt.Rows.Add(dr);
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total", typeof(double));
- ls_Particel_dt.Columns.Add("TypeId");
- ls_Particel_dt.Columns.Add("Class");
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = data.Rows[i]["TypeName"].ToString();
- dr2["Class"] = data.Rows[i]["Class"].ToString();
- dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = "0"; //求合
- double d_total = 0;
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
- }
- }
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = basicData.GetAllClass();
- 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")
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
- ClassName.Add("NULL");
- else
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //获取大分类信息
- DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
- return dt;
- }
- /// <summary>
- /// 小分类
- /// </summary>
- /// <returns></returns>
- public DataTable GetSubClassification(BasicData basicData)
- {
- DataTable data = basicData.GetDBData();
- //获取粒级表
- List<string> colid = new List<string>();
- colid = basicData.GetParticlesizeTable();
-
-
- //------------------------------------------------
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for (int i=0;i< colid.Count;i++)
- {
- ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
- }
- DataRow dr = ls_partsize_dt.NewRow();
-
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- int colidCount = 1;
- for (int i = 0; i < colid.Count; i++)
- {
- if (colid.Count < i)
- {
- dr["c" + (i + 1).ToString()] = "";
- }
- else
- {
- dr["c" + (i + 1).ToString()] = colid[i];
- ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
- colidCount++;
- }
- }
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total", typeof(double));
- ls_Particel_dt.Columns.Add("TypeId");
- ls_Particel_dt.Columns.Add("Class");
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = data.Rows[i]["TypeName"].ToString();
- dr2["Class"] = data.Rows[i]["Class"].ToString();
- dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = "0"; //求合
- double d_total = 0;
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
- }
- }
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- return ls_Particel_dt;
- }
- /// <summary>
- /// 分类整合大小分类都有
- /// </summary>
- /// <returns></returns>
- public List<DataTable> GetClassificationConsolidationTable(BasicData basicData)
- {
- List<DataTable> datas = new List<DataTable>();
- DataTable data = basicData.GetDBData();
- //获取粒级表
- List<string> colid = new List<string>();
- colid = basicData.GetParticlesizeTable();
-
- //------------------------------------------------
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for(int i=0;i< colid.Count;i++)
- {
- ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
- }
- DataRow dr = ls_partsize_dt.NewRow();
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- int colidCount = 1;
- for (int i = 0; i < colid.Count; i++)
- {
- if (colid.Count < i)
- {
- dr["c" + (i+1).ToString()] = "";
- }
- else
- {
- dr["c" + (i + 1).ToString()] = colid[i];
- ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
- colidCount++;
- }
- }
- ls_partsize_dt.Rows.Add(dr);
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total", typeof(double));
- ls_Particel_dt.Columns.Add("TypeId");
- ls_Particel_dt.Columns.Add("Class");
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = data.Rows[i]["TypeName"].ToString();
- dr2["Class"] = data.Rows[i]["Class"].ToString();
- dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = "0"; //求合
- double d_total = 0;
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
- }
- }
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = basicData.GetAllClass();
- 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
- {
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- }
- //获取大分类信息
- DataTable dt = QuantityOfIntegratedSubstances(ls_Particel_dt, ClassName);
- DataTable data2 = classIfIcationSort(ls_Particel_dt, ClassName, dt, colidCount);
- datas.Add(ls_partsize_dt.Copy());
- datas.Add(data2.Copy());
- return datas;
- }
- /// <summary>
- /// 大分类chart数据
- /// </summary>
- /// <param name="m_mbszclass"></param>
- /// <param name="m_otsreport_export"></param>
- /// <returns></returns>
- public DataTable GetChartDataCalss(BasicData basicData)
- {
- DataTable data =basicData.GetDBData();
- //获取粒级表
- List<string> colid = basicData.GetParticlesizeTable();
- //------------------------------------------------
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for (int i = 0; i < colid.Count; i++)
- {
- ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
- }
-
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- DataRow dr = ls_partsize_dt.NewRow();
- int colidCount = 1;
- for (int i = 0; i < colid.Count; i++)
- {
- if (colid.Count < i)
- {
- dr["c" + (i + 1).ToString()] = "";
- }
- else
- {
- dr["c" + (i + 1).ToString()] = colid[i];
- ls_Particel_dt.Columns.Add("c" + (i + 1).ToString(), typeof(double));
- colidCount++;
- }
- }
- ls_partsize_dt.Rows.Add(dr);
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total", typeof(double));
- ls_Particel_dt.Columns.Add("TypeId");
- ls_Particel_dt.Columns.Add("Class");
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = data.Rows[i]["TypeName"].ToString();
- dr2["Class"] = data.Rows[i]["Class"].ToString();
- dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- dr2["c" + j.ToString()] = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = "0"; //求合
- double d_total = 0;
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
- }
- }
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = basicData.GetAllClass();
- 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")
- if (getClass_dt.Rows[i]["GroupName"].ToString() == "")
- ClassName.Add("NULL");
- else
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- //颗粒尺寸数据(例 1.5有多少,2.0有多少)
- DataTable colid_data = new DataTable();
- colid_data.Columns.Add("name");
- colid_data.Columns.Add("quantity", typeof(double));
- for (int i = 0; i < ls_Particel_dt.Columns.Count; i++)
- {
- if (ls_Particel_dt.Columns[i].ColumnName == "c" + (i + 1).ToString())
- {
- if (i < colid.Count)
- {
- DataRow dr1 = colid_data.NewRow();
- dr1["name"] = colid[i].ToString();
- int quantity = 0;
- for (int a = 0; a < ls_Particel_dt.Rows.Count; a++)
- {
- quantity = quantity + Convert.ToInt32(ls_Particel_dt.Rows[a][i].ToString());
- }
- dr1["quantity"] = quantity.ToString();
- colid_data.Rows.Add(dr1);
- }
- }
- }
- return colid_data;
-
- }
- public DataTable ParticleResults(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export, string ComputeMode)
- {
- DataTable data = GetDBData(m_mbszclass, m_otsreport_export, ComputeMode);
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
- m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- for (int i = 0; i < sizestr.Split(',').Length; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- colid.Add("≥" + d1.ToString() );
- }
- }
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
- //------------------------------------------------
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for(int i=0;i< colid.Count;i++)
- {
- ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
- }
-
- DataRow dr = ls_partsize_dt.NewRow();
- DataTable ls_Particel_dt = new DataTable();
- ls_Particel_dt.TableName = "Particel";
- int colidCount = 1;
- for (int i = 0; i < colid.Count; i++)
- {
-
- dr["c" + (i+1).ToString()] = colid[i];
-
- ls_Particel_dt.Columns.Add("c"+ (i + 1).ToString());
- colidCount++;
- }
- ls_partsize_dt.Rows.Add(dr);
- ls_Particel_dt.Columns.Add("Name");
- ls_Particel_dt.Columns.Add("total");
- ls_Particel_dt.Columns.Add("TypeId");
- for (int i = 0; i < data.Rows.Count; i++)
- {
- DataRow dr2 = ls_Particel_dt.NewRow();
- dr2["Name"] = data.Rows[i]["TypeName"].ToString();
- dr2["TypeId"] = data.Rows[i]["TypeId"].ToString();//获取分类编号
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- double de = Convert.ToDouble(data.Rows[i][colid[j - 1]]);
- if (de == 0)
- dr2["c" + j.ToString()] = " ";
- else
- dr2["c" + j.ToString()] = de.ToString();
- }
- }
- if (dr2["Name"].ToString() != "" && dr2["Name"].ToString().IndexOf("number") < 0)
- {
- dr2["total"] = " "; //求合
- double d_total = 0;
- for (int j = 1; j < colidCount; j++)
- {
- if (colid.Count >= j)
- {
- d_total = d_total + Convert.ToInt64(data.Rows[i][colid[j - 1]]);
- }
- }
- if (d_total == 0)
- {
- continue;
- dr2["total"] = " ";
- }
- else
- dr2["total"] = d_total.ToString();
- }
- ls_Particel_dt.Rows.Add(dr2);
- }
- return ls_Particel_dt;
- }
- public DataTable TypeRange(c_TemplateClass m_mbszclass, OTSReport_Export m_otsreport_export)
- {
- List<string> colid = new List<string>();
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
- m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- for (int i = 0; i < sizestr.Split(',').Length; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
-
- colid.Add("≥" + d1.ToString());
- }
- }
-
- DataTable ls_partsize_dt = new DataTable();
- ls_partsize_dt.TableName = "PartSize";
- for (int i=0;i< colid.Count;i++)
- {
- ls_partsize_dt.Columns.Add("c"+(i+1).ToString());
- }
-
- DataRow dr = ls_partsize_dt.NewRow();
- for (int i = 0; i < colid.Count; i++)
- {
-
- dr["c" + (i+1).ToString()] = colid[i];
-
- }
- ls_partsize_dt.Rows.Add(dr);
- return ls_partsize_dt;
- }
- private DataTable QuantityOfIntegratedSubstances(DataTable dataTable, List<string> ClassName)
- {
- DataTable dt_Class = dataTable.Copy();
- dt_Class.Clear();
- dt_Class.TableName = "Particel";
- dt_Class.Columns.Remove("Name");
- for (int i = 0; i < ClassName.Count; i++)
- {
- //保留当前循环中大类物质,去除其他物质
- DataTable dt = dataTable.Copy();
- dt.Clear();
- for (int a = 0; a < dataTable.Rows.Count; a++)
- {
- if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(dataTable.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count == 0)
- continue;
- DataTable dt_2 = new DataTable();
- dt_2 = dataTable.Copy();
- dt_2.Clear();
- DataRow row = dt_2.NewRow();
- dt_2.Rows.Add(row);
- for (int a = 0; a < dt.Columns.Count; a++)
- {
- if (dt.Columns[a].ToString() != "Name" && dt.Columns[a].ToString() != "Class" && dt.Columns[a].ToString() != "TypeId")
- {
- bool bl = false;
- for (int b = 0; b < dt.Rows.Count; b++)
- {
- if (!dt.Rows[b].IsNull(dt.Columns[a].ToString()))
- {
- bl = true;
- }
- }
- if (bl)
- {
- dt_2.Rows[0][dt.Columns[a].ToString()] = decimal.Parse(dt.Compute("sum(" + dt.Columns[a].ToString() + ")", "").ToString());
- }
- }
-
- }
- dt_2.Columns.Remove("Name");
- dt_2.Rows[0]["Class"] = ClassName[i];
- dt_Class.Rows.Add(dt_2.Rows[0].ItemArray);
- }
- return dt_Class;
- }
- private DataTable classIfIcationSort(DataTable dataTable, List<string> ClassName, DataTable data,int colidCount)
- {
- DataTable dt = new DataTable();
- dt = dataTable.Copy();
- dt.Clear();
- dt.TableName = "Particel_subdivision";
- //循环list中每个类型
- for (int i = 0; i < ClassName.Count(); i++)
- {
- DataTable data1 = dt.Copy();
- data1.Clear();
- data1.Rows.Add();
- for (int a = 0; a < data.Rows.Count; a++)
- {
- if (data.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- for (int b = 1; b < colidCount; b++)
- {
- data1.Rows[0]["c" + b.ToString()] = data.Rows[a]["c" + b.ToString()];
- }
- data1.Rows[0]["total"] = data.Rows[a]["total"];
- data1.Rows[0]["Class"] = data.Rows[a]["Class"];
- dt.Rows.Add(data1.Rows[0].ItemArray);
- }
- }
- DataTable dt_1 = new DataTable();
- dt_1 = dt.Copy();
- dt_1.Clear();
- //循环DataTable中每个分类的数据
- for (int a = 0; a < dataTable.Rows.Count; a++)
- {
- if (!string.IsNullOrWhiteSpace(ClassName[i].ToString()))
- if (dataTable.Rows[a]["Class"].ToString() == ClassName[i].ToString())
- {
- dataTable.Rows[a]["Class"] = "";
- dt_1.Rows.Add(dataTable.Rows[a].ItemArray);
- }
- }
- //将颗粒数量排序(从大到小)
- DataView dv = dt_1.DefaultView;
- dv.Sort = "total DESC";
- DataTable dt_1_sort = dv.ToTable();
- for (int a = 0; a < dt_1_sort.Rows.Count; a++)
- {
- dt.Rows.Add(dt_1_sort.Rows[a].ItemArray);
- }
- }
-
- return dt;
- }
- private DataTable InvalidRemoval(DataTable dt)
- {
- DataTable dataTable = dt.Copy();
- dataTable.Clear();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"])>10 )
- {
- dataTable.Rows.Add(dt.Rows[i].ItemArray);
- }
- }
- return dataTable;
- }
- private string getWhere(string max, string min, string col, string partic)
- {
- return col + ">=" + min + " and " + col + "<" + max + " and TypeId=" + partic;
- }
- private DataTable GetDBData(c_TemplateClass m_mbszclass , OTSReport_Export m_otsreport_export,string ComputeMode)
- {
- DataTable m_bt_DBData = new DataTable();
- ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.GetWorkingResultId()].FilePath);
- List<string> colid = new List<string>() { "TypeName", "ar", "TypeId", "Largest", "Class", "con" };
- //获取粒级表
- string path1 = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder +
- m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXml(path1);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- for (int i = 0; i < sizestr.Split(',').Length ; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- colid.Add("≥" + d1.ToString() );
- }
- }
-
- for (int i = 0; i < colid.Count; i++)
- {
- m_bt_DBData.Columns.Add(colid[i].ToString());
- }
- DataTable dt = InvalidRemoval(fielddata.GetParticleListForParticlSize("area", ""));
- DataTable AreaInformationOfAllElements = InvalidRemoval(fielddata.GetAreaByAllIncA(""));
- DataTable dtp = InvalidRemoval(fielddata.GetParticleAll(""));
-
- string po = ComputeMode;
- switch (po)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow dr = m_bt_DBData.NewRow();
- dr["TypeName"] = dt.Rows[i]["TypeName"].ToString();
- dr["TypeId"] = dt.Rows[i]["TypeId"].ToString();
- dr["con"] = dt.Rows[i]["con"].ToString();
- if (dt.Rows[i]["GroupName"].ToString() == "")
- dr["Class"] = "Default";
- else
- dr["Class"] = dt.Rows[i]["GroupName"].ToString();
- //continue;
- dr["Largest"] = Math.Round(Convert.ToDouble(dt.Rows[i]["max"]), 2);
- for (int a = 6; a < colid.Count; a++)
- {
- string d2;
- if (a== colid.Count-1)
- {
- d2 = "999";
- }
- else
- {
- d2 = colid[a+1].Split('≥')[1];
- }
- string d1 = colid[a].Split('≥')[1];
-
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po, dt.Rows[i]["TypeId"].ToString()));
- dr[colid[a]] = datas.Count();
- }
- for (int a = 0; a < AreaInformationOfAllElements.Rows.Count; a++)
- {
- if (dt.Rows[i]["TypeId"].ToString() == AreaInformationOfAllElements.Rows[a]["TypeId"].ToString())
- {
- dr["ar"] = AreaInformationOfAllElements.Rows[a]["ar"];
- }
- }
- m_bt_DBData.Rows.Add(dr);
- }
- //去除物质分类(非夹杂物分类)
- for (int a = 0; a < m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial.Count; a++)
- {
- for (int i = m_bt_DBData.Rows.Count - 1; i >= 0; i--)
- {
- if (m_bt_DBData.Rows[i]["TypeId"].ToString() == m_mbszclass.M_KLLBXX.list_str_kllb_DeleteClass_Serial[a].ToString())
- {
- m_bt_DBData.Rows.RemoveAt(i);
- }
- }
- }
- if (m_mbszclass.list_str_MainPriority_Serial.Count==0)
- {
- return m_bt_DBData;
- }
- DataTable datass = m_bt_DBData.Clone();
- for (int i=0;i< m_mbszclass.list_str_MainPriority_Serial.Count;i++)
- {
- bool bl = false;
- for (int a = 0; a < m_bt_DBData.Rows.Count; a++)
- {
- if (m_bt_DBData.Rows[a]["TypeId"].ToString() == m_mbszclass.list_str_MainPriority_Serial[i])
- {
- datass.Rows.Add(m_bt_DBData.Rows[a].ItemArray);
- bl = true;
- continue;
- }
- }
- if(!bl)
- {
- DataTable dta= m_bt_DBData.Clone();
- if (m_bt_DBData.Rows.Count != 0)
- {
- dta.Rows.Add(m_bt_DBData.Rows[0].ItemArray);
- for (int b = 0; b < dta.Columns.Count; b++)
- {
- if (dta.Columns[b].ColumnName == "TypeName")
- {
- dta.Rows[0][b] = m_mbszclass.list_str_MainPriority[i];
- }
- else if (dta.Columns[b].ColumnName == "Class")
- {
- dta.Rows[0][b] = "Default";
- }
- else
- {
- dta.Rows[0][b] = 0;
- }
- }
- datass.Rows.Add(dta.Rows[0].ItemArray);
- }
-
- }
- }
- return datass;
- }
- }
- }
|