123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- using OTSCLRINTERFACE;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGraph.OTSIncAReportGraphFuncation;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- using OTSCommon.DBOperate.Model;
- namespace OTSIncAReportApp.OTSRstMgrFunction
- {
- /// <summary>
- /// 框架与底层进行交互的操作类
- /// </summary>
- public class ResultDataMgr
- {
- #region 变量定义
-
- /// <summary>
- /// 报告主进程框架对象
- /// </summary>
-
- public CReportMgrClr m_ReportMgr;
- private List<ResultFile> resultFilesList = new List<ResultFile>(); //测量结果列表
- private int workingResultId = -1;
-
- public RptConfigFile m_RptConfigFile = RptConfigFile.GetRptConfig(); //报表程序的配置文件
- #endregion
-
-
- private ResultFile m_curResultFile;
- public int GetWorkingResultId()
- {
- return workingResultId;
- }
- public void SetWorkingResultId(int value)
- {
- if (resultFilesList.Count > 0)
- {
- workingResultId = value;
- m_curResultFile = resultFilesList[value];
- }
-
- }
-
- public ResultFile GetResultFileObjByName(string rstName)
- {
- ResultFile rst = null;
- foreach (var r in resultFilesList)
- {
- if (r.FileName_real == rstName)
- {
- rst = r;
- }
- }
- return rst;
- }
- public List<ResultFile> ResultFilesList { get => resultFilesList; set => resultFilesList = value; }
- public ResultFile CurResultFile { get => m_curResultFile; set => m_curResultFile = value; }
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="ReportApp"></param>
- public ResultDataMgr()
- {
-
- if (null == m_ReportMgr)
- {
- //初始化相关变量
- m_ReportMgr = new CReportMgrClr();
- }
-
- }
- public bool AddDataResult(string str_path)
- {
- //加载测量结果文件
- Dictionary<string, object> suggestions = DataOperation.DataAccess.XMLoperate.GetXMLAllInfo(str_path);
- string name = System.IO.Path.GetFileName(str_path);
- int workingid = ResultFilesList.Count + 1;
- string path = System.IO.Path.GetDirectoryName(str_path);
- if (ResultFilesList.Find(s => s.FilePath == path) != null)
- {
- MessageBox.Show("Already have the same result!");
- return false;
- }
- string strname = UpdateName(name, ResultFilesList);
- if (strname == "")
- {
- MessageBox.Show("Already have the same result!");
- return false;
- }
- ResultFile result = new ResultFile()
- {
- FileId = workingid.ToString(),
- anotherFileName = strname,
- FileName_real=name,
- FilePath = path,
-
- };
- result.SetResultInfoDic(suggestions);
- ResultFilesList.Add(result);
- SetWorkingResultId(ResultFilesList.IndexOf(result));
- FieldData fieldData = new FieldData(path);
- List<Field> fieldlist = fieldData.GetFieldList();
- CurResultFile.List_OTSField = fieldlist;
-
- return true;
- }
- public void RemoveDataResult(string fileName)
- {
- ResultFile rst=null;
- foreach (var r in resultFilesList)
- {
- if (r.FileName_real == fileName)
- {
- rst = r;
- }
-
- }
- if (rst != null)
- {
- resultFilesList.Remove(rst);
- workingResultId = 0;
- }
- else
- {
- workingResultId =-1;
- }
-
-
- }
- private string UpdateName(string name, List<ResultFile> ResultFilesList)
- {
- int reg = 51;
- if (ResultFilesList.Find(s => s.anotherFileName == name) != null)
- {
- for (int i = 1; i < reg; i++)
- {
- string str = name.Split('.')[0].ToString() + "(" + i.ToString() + ")" + name.Split('.')[1].ToString();
- if (ResultFilesList.Find(s => s.anotherFileName == str) == null)
- {
- return name.Split('.')[0].ToString() + "(" + i.ToString() + ")" + name.Split('.')[1].ToString();
- }
- }
- }
- else
- {
- return name;
- }
- return "";
- }
- #endregion
- #region 获取组合项相关方法
- /// <summary>
- /// 根据系统设置的默认粒级表路径,获取所有的粒级表文件List
- /// </summary>
- /// <returns></returns>
- public List<string> GetPartSizeFileList()
- {
- List<string> ret_list = new List<string>();
- //遍历粒级文件夹
- DirectoryInfo theFolder = new DirectoryInfo(m_RptConfigFile.PartSizeFileFolder);
- if (!theFolder.Exists)
- return ret_list;
- //读取遍历粒级文件信息
- foreach (FileInfo nextifile in theFolder.GetFiles())
- {
- //找出粒级文件
- if (nextifile.Name.Contains(".psf") == true || nextifile.Name.Contains(".PSF") == true)
- {
- ret_list.Add(nextifile.Name);
- }
- }
- return ret_list;
- }
- public List<string> GetSTDIdList()
- {
-
- HashSet<string> stdSet = new HashSet<string>();
- stdSet.Add("All");
- foreach (var f in CurResultFile.List_OTSField)
- {
- foreach (var p in f.ParticleList)
- {
- if (!stdSet.Contains(p.TypeName))
- {
- stdSet.Add(p.TypeName);
-
- }
-
- }
-
- }
- return stdSet.ToList();
- }
- /// <summary>
- /// 根据系统设置默认的粒级表的路径,获取粒级表List
- /// </summary>
- /// <param name="path"></param>
- /// <returns></returns>
- public List<string> GetPartSizeList()
- {
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(m_RptConfigFile.PartSizeFileFolder + m_RptConfigFile.PartSizeFile);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- List<string> sizeList = new List<string>();
- for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
- sizeList.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- sizeList.Add(d.ToString() + "~MAX");
- return sizeList;
- }
- /// <summary>
- /// 根据传入的粒级表目录,获取粒级表List
- /// </summary>
- /// <returns></returns>
- public List<string> GetPartSizeList(string path)
- {
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(path);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- List<string> sizeList = new List<string>();
- for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
- {
- if (sizestr.Split(',')[i].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
- sizeList.Add(d1.ToString() + "~" + d2.ToString());
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- sizeList.Add(d.ToString() + "~MAX");
- return sizeList;
- }
- /// <summary>
- /// 获取三元相图模板名称列表
- /// </summary>
- /// <returns></returns>
- public List<string> GetTriTemplateNameList()
- {
- string pathtpf = m_RptConfigFile.TrigTemplateFileFolder + m_RptConfigFile.TriTempFile;
- List<string> ret_list = new List<string>();
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXmlData(pathtpf, "XMLData");
- DataTable dt = ds.Tables["Member"];
- foreach (DataRow item in dt.Rows)
- {
- if (item["TemplateName"].ToString() != "")
- {
- ret_list.Add(item["TemplateName"].ToString());
- }
- }
- return ret_list;
- }
- /// <summary>
- /// 获取测量结果名称列表
- /// </summary>
- /// <returns></returns>
-
- public string GetDefaultPartSize()
- {
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(Application.StartupPath + m_RptConfigFile.ReportMgrParamFile);
- string sizestr = ds.Tables[1].Rows[3]["name"].ToString();
- return sizestr;
- }
- public string GetDefaultTRIO_CHART_TYPE()
- {
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(Application.StartupPath + m_RptConfigFile.ReportMgrParamFile);
- string sizestr = ds.Tables[1].Rows[4]["strValue"].ToString();
- return sizestr;
- }
- public string GetDefaultSIZE_CAL_METHOD_TYPE()
- {
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(Application.StartupPath + m_RptConfigFile.ReportMgrParamFile);
- string sizestr = ds.Tables[1].Rows[5]["strValue"].ToString();
- return sizestr;
- }
- /// <summary>
- /// 获取计算方法列表
- /// </summary>
- /// <returns></returns>
- public List<string> GetSizeCalMethodTypeList()
- {
- List<string> ret_list = new List<string>() { "DMAX", "DMIN", "FERET", "ECD" };
- return ret_list;
- }
- public List<string> ParticleRange()
- {
- List<string> pr_str = new List<string>() { "全部颗粒","选择颗粒" };
- return pr_str;
- }
- public List<string> getTableData()
- {
- List<string> strlist = new List<string>() { "Area", "DMAX", "Hardness", "AveGray" };
- return strlist;
- }
- public List<string> getTableData_INCA()
- {
- List<string> strlist = new List<string>() { "Area", "DMAX", "AveGray" };
- return strlist;
- }
- public List<string> getTableData_CleannessA()
- {
- List<string> strlist = new List<string>() { "Area", "DMAX", "Hardness", "AveGray" };
- return strlist;
- }
- #endregion
- #region [测量结果treeview]相关封装方法
- /// <summary>
- /// 获取测量结果treeview树测量结果名
- /// </summary>
- /// <returns></returns>
- public string GetSampleName()
- {
- //获取样品名
- String sWorkSampleName = ResultFilesList[GetWorkingResultId()].anotherFileName;
- if (null == sWorkSampleName)
- {
- return "";
- }
- return sWorkSampleName;
- }
- #endregion
-
- }
- }
|