Sfoglia il codice sorgente

Merge branch 'GSP' of http://36.129.169.60:30080/gogsadmin/OTS into GSP

cxs 1 mese fa
parent
commit
7fc2f0bf3e

+ 241 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/DataAccess/UserSTDDbAccess.cs

@@ -0,0 +1,241 @@
+using OTSCommon.DBOperate;
+using OTSIncAReportApp._1_UI.OTSReportExport.DataIntegration;
+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 OTSDataType.otsdataconst;
+
+namespace OTSIncAReportApp._2_CommonFunction.CommonClass
+{
+    public class UserSTDDbAccess
+    {
+
+        private SqlHelper dbHelper;
+       
+        public UserSTDDbAccess(string STDDbName, string resultpath)
+        {
+            NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
+            if (!STDDbName.Contains(".db"))
+            {
+                STDDbName += ".db";
+            }
+            if (STDDbName.ToLower() == "nostddb.db")
+            {
+                dbHelper = null;
+                log.Error("Failed to load user-defined library" + "!");
+            }
+            string fullPath = resultpath + STDDbName;
+            string fullPath2 = System.IO.Directory.GetCurrentDirectory() + "\\Config\\SysData\\" + STDDbName;
+            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;
+        }
+        /// <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;
+        }
+        public SqlHelper GetSqlHelper() { return dbHelper; }
+    }
+}

+ 283 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/ImageAccess/FieldImage.cs

@@ -0,0 +1,283 @@
+using OTSCommon.DBOperate.Model;
+using OTSIncAReportApp.DataOperation.DataAccess;
+using OTSIncAReportApp.OTSRstMgrFunction;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing;
+using System.IO;
+
+namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
+{
+    public class FieldImage
+    {
+        string imagePath;
+        public FieldImage(string rstpath) 
+        { 
+        imagePath= rstpath + @"FIELD_FILES\";
+        }
+        /// <summary>
+        /// 拼接颗粒黑白图
+        /// </summary>
+        /// <param name="sub">拼接字符串</param>
+        /// <param name="xs">xs = pixw / ScanFieldSize</param>
+        /// <param name="path">报告文件路径</param>
+        /// <param name="picHeight">图像高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForBigBlackAndWhiteImage(string sub, double xs, string path, int picHeight, int picWidth,DataTable PartdataTable,List<Segment> segsData)
+        {
+            string vs = "," + sub.Replace(':', '-') + ",";
+            
+            if (PartdataTable.Rows.Count == 0)
+            {
+                return null;
+            }
+            //内接矩形
+            double max_Y = -1;
+            double max_X = -1;
+            double min_Y = 99999999;
+
+            double min_X = 99999999;
+            //拼接field矩形
+            double B_Y = Convert.ToInt64(PartdataTable.Rows[0]["FieldPosY"]) * xs;
+            double R_X = Convert.ToInt64(PartdataTable.Rows[0]["FieldPosX"]) * xs;
+            double T_Y = B_Y;
+            double L_X = R_X;
+            foreach (DataRow item in PartdataTable.Rows)
+            {
+                double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
+
+                if (lefttopXH > R_X)
+                {
+                    R_X = lefttopXH;
+                }
+                if (lefttopXH < L_X)
+                {
+                    L_X = lefttopXH;
+                }
+                double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
+
+                if (lrfttopYH < B_Y)
+                {
+                    B_Y = lrfttopYH;
+                }
+                if (lrfttopYH > T_Y)
+                {
+                    T_Y = lrfttopYH;
+                }
+            }
+            int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
+            int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
+            //构造最终的图片白板
+            Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
+            Graphics graph = Graphics.FromImage(tableChartImage);
+            graph.Clear(Color.White);
+            //初始化这个大图
+            graph.DrawImage(tableChartImage, 0, 0);
+            foreach (DataRow item in PartdataTable.Rows)
+            {
+               
+               
+                int x = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
+                int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
+                //颗粒外接矩形
+                double lefttopX = x + 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 = y + Convert.ToInt64(item["RectTop"]);
+                if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
+                {
+                    max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
+                }
+                if (lrfttopY < min_Y)
+                {
+                    min_Y = lrfttopY;
+                }
+                foreach (Segment seg in segsData)
+                {
+                    int f_length = seg.Length;
+                    for (int m = 0; m < f_length; m++)
+                    {
+                        int lsjs_x = seg.Start + m + x;
+                        int lsjs_y = seg.Height + y;
+                        tableChartImage.SetPixel(lsjs_x, lsjs_y, Color.Black);
+                    }
+                }
+            }
+            int width = Convert.ToInt32(max_X - min_X);
+            int height = Convert.ToInt32(max_Y - min_Y);
+            int X = Convert.ToInt32(min_X);
+            int Y = Convert.ToInt32(min_Y);
+            Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
+            Bitmap bmap = GetBitmapByParticle(tableChartImage, rectangle);
+            return bmap;
+        }
+
+        public Bitmap ReadImageFile(string filename)
+        {
+            if (!File.Exists(imagePath+filename))
+            {
+                return null;//文件不存在
+            }
+            FileStream fs = File.OpenRead(imagePath + filename); //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>
+        /// 拼接颗粒图
+        /// </summary>
+        /// <param name="sub">拼接字符串</param>
+        /// <param name="xs">xs = pixw / ScanFieldSize</param>
+        /// <param name="path">报告文件路径</param>
+        /// <param name="picHeight">图像高</param>
+        /// <param name="picWidth">帧图宽</param>
+        /// <param name="X_AXIS_DIRECTION">电镜x轴正方向</param>
+        /// <param name="Y_AXIS_DIRECTION">电镜y轴正方向</param>
+        /// <returns></returns>
+        public Bitmap GetBitmapForMergedParticle(string sub, double xs, string path, int picHeight, int picWidth,DataTable dataTable)
+        {
+            string vs = "," + sub.Replace(':', '-') + ",";
+
+           
+            if (dataTable.Rows.Count == 0)
+            {
+                return null;
+            }
+            //内接矩形
+            double max_Y = -1;
+            double max_X = -1;
+            double min_Y = 99999999;
+
+            double min_X = 99999999;
+            //拼接field矩形
+            double B_Y = Convert.ToInt64(dataTable.Rows[0]["FieldPosY"]) * xs;
+            double R_X = Convert.ToInt64(dataTable.Rows[0]["FieldPosX"]) * xs;
+            double T_Y = B_Y;
+            double L_X = R_X;
+            foreach (DataRow item in dataTable.Rows)
+            {
+                double lefttopXH = Convert.ToInt64(item["FieldPosX"]) * xs;
+
+                if (lefttopXH > R_X)
+                {
+                    R_X = lefttopXH;
+                }
+                if (lefttopXH < L_X)
+                {
+                    L_X = lefttopXH;
+                }
+                double lrfttopYH = Convert.ToInt64(item["FieldPosY"]) * xs;
+
+                if (lrfttopYH < B_Y)
+                {
+                    B_Y = lrfttopYH;
+                }
+                if (lrfttopYH > T_Y)
+                {
+                    T_Y = lrfttopYH;
+                }
+            }
+            int WIDTH = Math.Abs(Convert.ToInt32(R_X - L_X)) + picWidth;
+            int HEIGHT = Math.Abs(Convert.ToInt32(B_Y - T_Y)) + picHeight;
+            //构造最终的图片白板
+            Bitmap tableChartImage = new Bitmap(WIDTH, HEIGHT);
+            Graphics graph = Graphics.FromImage(tableChartImage);
+            graph.DrawImage(tableChartImage, 0, 0);
+            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 = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosX"]) * xs - L_X));
+                int y = Math.Abs(Convert.ToInt32(Convert.ToDouble(item["FieldPosY"]) * xs - T_Y));
+
+                graph.DrawImage(ls_bt, x, y);
+                //颗粒外接矩形
+                double lefttopX = x + 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 = y + Convert.ToInt64(item["RectTop"]);
+                if (lrfttopY + Convert.ToInt64(item["RectHeight"]) > max_Y)
+                {
+                    max_Y = lrfttopY + Convert.ToInt64(item["RectHeight"]);
+                }
+                if (lrfttopY < min_Y)
+                {
+                    min_Y = lrfttopY;
+                }
+            }
+            int width = Convert.ToInt32(max_X - min_X);
+            int height = Convert.ToInt32(max_Y - min_Y);
+            int X = Convert.ToInt32(min_X);
+            int Y = Convert.ToInt32(min_Y);
+            Rectangle rectangle = new Rectangle() { X = X, Y = Y, Width = width, Height = height };
+            Bitmap bmap = tableChartImage.Clone(rectangle, PixelFormat.Format8bppIndexed);
+            graph.DrawImage(tableChartImage, 0, 0);
+
+            return bmap;
+        }
+        /// <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;
+        }
+
+    }
+}

+ 15 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/IReport.cs

@@ -0,0 +1,15 @@
+using OTSIncAReportApp.OTSSampleReportInfo;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OTSIncAReportApp.OTSDataMgrFunction
+{
+    //报告项目,接口
+    public interface IReport
+    {
+
+    }
+}

+ 16 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/IReportBase.cs

@@ -0,0 +1,16 @@
+using OTSIncAReportApp.OTSSampleReportInfo;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+namespace OTSIncAReportApp.OTSDataMgrFunction
+{
+    //报告项目,共用接口类,基类,一起维护这个类,共同使用
+    public class IReportBase : IReport
+    {
+
+    }
+}

+ 399 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/ResultDataMgr.cs

@@ -0,0 +1,399 @@
+
+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.SetList_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);
+                }
+            }
+            ret_list.Add("AUTO.psf");
+            return ret_list;
+        }
+        public List<string> GetSTDIdList()
+        {
+            
+
+            HashSet<string> stdSet = new HashSet<string>();
+            stdSet.Add("All");
+            foreach (var f in CurResultFile.GetList_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()
+        {
+            string sizestr = "";
+            List<string> sizeList = new List<string>();
+            if (m_RptConfigFile.PartSizeFile != "AUTO.psf")
+            {
+                DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(m_RptConfigFile.PartSizeFileFolder + m_RptConfigFile.PartSizeFile);
+                sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+            }
+            else
+            {
+                double dn;
+                dn = m_curResultFile.GetParticleMINECD();
+                sizestr = dn.ToString() + ",";
+                for (double p = dn; p < 50; p = p * Math.Sqrt(2))
+                {
+                    if (p > dn && p <= 50.5)
+                    {
+                        double dd = Math.Round(p);
+                        sizestr += dd.ToString() + ",";
+                    }
+                }
+                sizestr = sizestr.Remove(sizestr.Length - 1, 1);
+            }
+            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","ECD" };
+            return strlist;
+        }
+        public List<string> getTableData_CleannessA()
+        {
+            List<string> strlist = new List<string>() { "Area", "DMAX", "Hardness", "AveGray","ECD" };
+            return strlist;
+        }
+
+        #endregion
+
+
+
+        #region 
+    
+        public string GetSampleName()
+        {
+            //获取样品名
+            String sWorkSampleName = ResultFilesList[GetWorkingResultId()].anotherFileName;
+
+            if (null == sWorkSampleName)
+            {
+                return "";
+            }
+            return sWorkSampleName;
+        }
+
+        #endregion
+
+ 
+
+
+    }
+}

+ 365 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/ResultFile.cs

@@ -0,0 +1,365 @@
+using System;
+using System.Collections.Generic;
+using OTSCommon.DBOperate.Model;
+using static OTSDataType.otsdataconst;
+
+namespace OTSIncAReportApp.OTSRstMgrFunction
+{
+
+    [Serializable]
+    public class ResultFile
+    {
+        /// <summary>
+        /// FileId
+        /// </summary>      
+        ///  //全局对象,为了能够快速的获取到xray数据,而做为一个临时变量进行保存,使用前应该判断是否为空
+        private List<Field> list_OTSField = null;
+  
+        public int GetTotalFields()
+        {
+            int all_FiledCount = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"])["SEMDataMsr"])["TotalFields"]);
+            return all_FiledCount;
+
+        }
+        public float GetScanFieldSizeX()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+            float ScanFieldSizeX = float.Parse(SEMDataMsr["ScanFieldSize"].ToString());
+            return ScanFieldSizeX;
+        }
+       
+        public float GetScanFieldSizeX100()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+            float ScanFieldSizeX100 = float.Parse(SEMDataMsr["ScanFieldSize100"].ToString());
+            return ScanFieldSizeX100;
+        }
+        public float GetMeasurementMagnification()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+            float ScanMagnification = 0;
+            try
+            {
+                ScanMagnification = float.Parse(SEMDataMsr["Magnification"].ToString());
+            }
+            catch
+            {
+                ScanMagnification = GetScanFieldSizeX100() * 100 / GetScanFieldSizeX();
+            }
+            return ScanMagnification;
+        }
+        public float GetScanFieldSizeY()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+            float ScanFieldSizeX = float.Parse(SEMDataMsr["ScanFieldSize"].ToString());
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+            int width = int.Parse(ImageResolution.Split('_')[1]);
+            int height = int.Parse(ImageResolution.Split('_')[2]);
+            float ScanFieldSizeY = ScanFieldSizeX * height / width;
+            return ScanFieldSizeY;
+        }
+
+        public string GetXAxisDir()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+
+            Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+      
+            string leftOrRight = SEMStageData["xAxisDir"].ToString().Split(':')[1];
+            return leftOrRight;
+        }
+        public OTS_X_AXIS_DIRECTION GetXAxisDirEnum()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+
+            Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            int leftOrRight = Convert.ToInt32(SEMStageData["xAxisDir"].ToString().Split(':')[0]);
+            return (OTS_X_AXIS_DIRECTION)leftOrRight;
+        }
+        public OTS_Y_AXIS_DIRECTION GetYAxisDirEnum()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+
+            Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            int dir = Convert.ToInt32(SEMStageData["yAxisDir"].ToString().Split(':')[0]);
+            return (OTS_Y_AXIS_DIRECTION)dir;
+        }
+
+        public string GetYAxisDir()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+
+            Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            string downOrUp = SEMStageData["yAxisDir"].ToString().Split(':')[1];
+            return downOrUp;
+        }
+        public int GetXAxisStart()
+        {
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+            int xStart = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["SEMStageData"])["Members"])["XAxis"])["start"]);
+            int xEnd = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["SEMStageData"])["Members"])["XAxis"])["end"]);
+            return xStart;
+        }
+        public int GetXAxisEnd()
+        {
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            int xEnd = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["SEMStageData"])["Members"])["XAxis"])["end"]);
+            return xEnd;
+        }
+        public int GetYAxisStart()
+        {
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            int yStart = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["SEMStageData"])["Members"])["YAxis"])["start"]);
+            return yStart;
+        }
+        public int GetYAxisEnd()
+        {
+            //Dictionary<string, object> SEMStageData = (Dictionary<string, object>)ResultInfo["SEMStageData"];
+
+            int yEnd = Convert.ToInt32(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["SEMStageData"])["Members"])["YAxis"])["end"]);
+            return yEnd;
+        }
+        public string GetImageResolution()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+            return ImageResolution;
+
+        }
+        public int GetImageWidth()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+          
+           
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+            int width = int.Parse(ImageResolution.Split('_')[1]);
+            return width;
+           
+        }
+        public int GetImageHeight()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+       
+
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+          
+          
+            int height = int.Parse(ImageResolution.Split('_')[2]);
+
+            return height;
+        }
+        public float GetPixelSize()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageScanParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageScanParam"];
+            Dictionary<string, object> SEMDataMsr = (Dictionary<string, object>)sampleMembers["SEMDataMsr"];
+          
+            float ScanFieldSizeX = float.Parse(SEMDataMsr["ScanFieldSize"].ToString());
+           
+            string ImageResolution = imageScanParam["ImageResolution"].ToString();
+            int width = int.Parse(ImageResolution.Split('_')[1]);
+            int height = int.Parse(ImageResolution.Split('_')[2]);
+           
+            float m_pixelSize = ScanFieldSizeX / width;
+            return m_pixelSize;
+
+        }
+      
+
+        public string GetSTDName()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            string STDName = ((Dictionary<string, object>)sampleMembers["MsrParams"])["STDName"].ToString();
+            return STDName;
+
+        }
+
+        public string GetSTDEngineType()
+        {
+            try
+            {
+				Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+				string STDEngineType = ((Dictionary<string, object>)sampleMembers["MsrParams"])["EngineType"].ToString();
+				return STDEngineType;
+			}
+            catch 
+            {
+                return "-1";
+
+			}
+
+			
+		}
+        public string GetSysType()
+        {
+            try
+            {
+                Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+                string STDEngineType = ((Dictionary<string, object>)sampleMembers["MsrParams"])["SysType"].ToString();
+                return STDEngineType;
+            }
+            catch
+            {
+                return "-1";
+
+            }
+
+
+        }
+
+        public bool GetUseSysSTD()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            string UseSysSTD = ((Dictionary<string, object>)sampleMembers["MsrParams"])["UseSysSTD"].ToString();
+            return Convert.ToBoolean(UseSysSTD);
+        }
+        public int GetOverlapParam()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> imageProcParam = (Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)sampleMembers["MsrParams"])["Members"])["ImageProcessParam"];
+            try
+            {
+                string overlap = imageProcParam["OverlapParam"].ToString();
+                return Convert.ToInt32(overlap);
+            }
+            catch 
+            {
+                return 0;
+            }
+           
+            
+        }
+        public double GetTotalArea()
+        {
+            try
+            {
+                double dTotalArea = -1;
+                Dictionary<string, object> valuePairs=(Dictionary<string, object>)ResultInfo["Sample"];
+                if (valuePairs.ContainsKey("TotalArea"))
+                {
+                    dTotalArea = Convert.ToDouble(valuePairs["TotalArea"]) /**1000000*/ ;
+                    return dTotalArea;
+                }
+                else
+                {
+                    return -1;
+                }
+            }
+            catch
+            {
+               return -1; 
+            }
+
+        }
+
+        public int GetIncASteeltech()
+        {
+            //--------the int number  meaning----------
+            //GeneralProcessMode = 0,
+            //CaProcessMode = 1,
+            //MgProcessMode = 2,
+            //RareEarthMode = 3
+            //------------------
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            int steeltech = Convert.ToInt32(((Dictionary<string, object>)sampleMembers["MsrParams"])["SteelTech"]);
+            return steeltech;
+
+        }
+        public string GetResultDBPath()
+        {
+            string ResultDbPath = FilePath + "\\FIELD_FILES\\Inclusion.db";
+            return ResultDbPath;
+        }
+        public double GetParticleMINECD()
+        {
+            Dictionary<string, object> sampleMembers = ((Dictionary<string, object>)((Dictionary<string, object>)ResultInfo["Sample"])["Members"]);
+            Dictionary<string, object> MsrParams = (Dictionary<string, object>)sampleMembers["MsrParams"];
+            Dictionary<string, object> ImageProcessParam = ((Dictionary<string, object>)((Dictionary<string, object>)MsrParams["Members"])["ImageProcessParam"]);
+            Dictionary<string, object> Members = (Dictionary<string, object>)MsrParams["Members"];
+            Dictionary<string, object> IPP = ((Dictionary<string, object>)((Dictionary<string, object>)MsrParams["Members"])["ImageProcessParam"]);
+            Dictionary<string, object> IncArea = ((Dictionary<string, object>)((Dictionary<string, object>)IPP["Members"])["IncArea"]);
+            double dparticleMINECD = float.Parse(IncArea["start"].ToString());
+            return dparticleMINECD;
+        }
+
+        public string FileId
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// FileName
+        /// </summary>       
+        public string anotherFileName
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// FileName
+        /// </summary>       
+        public string FileName_real
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// FilePath
+        /// </summary>       
+        public string FilePath
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// ResuitInfo
+        /// </summary>       
+        public Dictionary<string, object> ResultInfo
+        {
+            get;
+            set;
+        }
+        public void SetResultInfoDic(Dictionary<string, object> info)
+        {
+            ResultInfo = info;
+        }
+        public List<Field> GetList_OTSField()
+        {
+            return list_OTSField;
+        }
+
+        public void SetList_OTSField(List<Field> value)
+        {
+            list_OTSField = value;
+        }
+
+        //public OTS_SysType_ID GetResultSystype()
+        //{
+        //    var Systype = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)(Dictionary<string, object>)this.ResultInfo["Sample"])["Members"])["MsrParams"])["SysType"];
+
+        //    return (OTS_SysType_ID)(Convert.ToInt32( Systype.ToString().Split(':')[0]));
+        //}
+    }
+
+
+}

+ 137 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/RptConfigFile.cs

@@ -0,0 +1,137 @@
+using OTSCommon;
+using System;
+using System.Data;
+using System.Windows.Forms;
+using static OTSDataType.otsdataconst;
+
+namespace OTSIncAReportApp.OTSRstMgrFunction
+{
+ 
+    [Serializable]
+    public class RptConfigFile
+    {
+        private string path;
+        public const string ConfigFileFolder = @".\Config\ProData\";
+        private const string m_TriTempFile = "DefaultTriTemplateFile.tpf";
+
+        public static string m_ReportMgrParamFile = "\\Config\\SysData\\OTSReportMgrParam.rpf"; //报告对应使用的参数文件名
+        static RptConfigFile m_config=null;
+       public static RptConfigFile GetRptConfig()
+        {
+            if (m_config == null)
+            {
+                m_config = new RptConfigFile();
+            }
+            return m_config;
+        }
+        private RptConfigFile()
+        {
+
+            path = Application.StartupPath + RptConfigFile.m_ReportMgrParamFile;         //报表程序的配置文件
+
+            LoadDataFromFile();
+        }
+        public void LoadDataFromFile()
+        {
+            DataSet ds = XMLoperate.GetXml(path);
+
+          
+            var st= GetDataFromDataSetXml(ds, "systype");
+            if (st == "IncA")
+            {
+                this.Systype = OTS_SysType_ID.IncA;
+            }
+            else if(st == "TCCleannessA")
+            {
+                this.Systype = OTS_SysType_ID.TCCleannessA;
+            }
+            else if(st == "BatteryCleannessA")
+            {
+                this.Systype = OTS_SysType_ID.BatteryCleannessA;
+            }
+            else {this.Systype = OTS_SysType_ID.SteelMineral;}
+            this.PartSizeFile = GetDataFromDataSetXml(ds, "name", "PartSizeFile");//ds.Tables[1].Rows[2]["Name"].ToString();
+            this.TriTempFile = m_TriTempFile;
+        }
+
+
+        
+
+        public string GetDataFromDataSetXml(DataSet dataSrc, string propertyName,string memberName="XMLData")//the particular schema of OTS system.such as "<XMLData p1="aa" p2="bb"><Member RegName="cc" p1="dd"/>...</XMLData>
+        {
+            string v = "";
+            if (memberName == "XMLData")
+            {
+                v = dataSrc.Tables[memberName].Rows[0][propertyName].ToString();
+            }
+            else 
+            {
+                var rs = dataSrc.Tables["Member"].Select("RegName= '" + memberName+"'");
+                    
+                v=rs[0][propertyName].ToString();//find the first match row's corresponding property value.
+            }
+            return v;
+        }
+        /// <summary>
+        /// 粒级表目录
+        /// </summary>
+        public  string PartSizeFileFolder
+        {
+
+            get { return ConfigFileFolder; }
+        }
+        public OTS_SysType_ID Systype
+        {
+            get;
+            set;
+        }
+        /// <summary>
+        /// 三元相图目录
+        /// </summary>
+        public string TrigTemplateFileFolder
+        {
+            get { return ConfigFileFolder; }
+
+
+        }
+
+        public string ReportMgrParamFile
+        {
+            get { return m_ReportMgrParamFile; }
+
+
+        }
+
+        /// <summary>
+        /// 比例因子
+        /// </summary>
+        //public string Scale
+        //{
+        //    get;
+        //    set;
+        //}
+
+
+        /// <summary>
+        /// 默认使用的粒级文件
+        /// </summary>
+        public string PartSizeFile
+        {
+            get;
+            set;
+        }
+
+        /// <summary>
+        /// 默认使用的三元相图模板文件
+        /// </summary>
+        public string TriTempFile
+        {
+            get;
+            set;
+        }
+
+
+    }
+
+
+}

+ 7 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/SampleData.cs

@@ -0,0 +1,7 @@
+namespace OTSIncAReportApp.OTSDataMgrFunction
+{
+    public class SampleData
+    {
+
+    }
+}

+ 666 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/OTSRstXmlAccess/XMLoperate.cs

@@ -0,0 +1,666 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+using System.Xml;
+
+namespace OTSIncAReportApp.DataOperation.DataAccess
+{
+    public class XMLoperate
+    {
+
+        #region 读取XML到DataSet
+
+        /// <summary>
+        /// 功能:读取XML到DataSet中
+        /// </summary>
+        /// <param name="XmlPath">xml路径</param>
+        /// <returns>DataSet</returns>
+        public static DataSet GetXml(string XmlPath)
+        {
+            DataSet ds = new DataSet();
+            ds.ReadXml(@XmlPath);
+            return ds;
+        }
+        #endregion
+
+        #region 读取xml文档并返回一个节点
+
+        /// <summary>
+        /// 读取xml文档并返回一个节点:适用于一级节点
+        /// </summary>
+        /// <param name="XmlPath">xml路径</param>
+        /// <param name="NodeName">节点</param>
+        /// <returns></returns>
+        public static string ReadXmlReturnNode(string XmlPath, string Node)
+        {
+            XmlDocument docXml = new XmlDocument();
+            docXml.Load(@XmlPath);
+            XmlNodeList xn = docXml.GetElementsByTagName(Node);
+            return xn.Item(0).InnerText.ToString();
+        }
+        #endregion
+
+        #region 查找数据,返回一个DataSet
+
+        /// <summary>
+        /// 查找数据,返回当前节点的所有下级节点,填充到一个DataSet中
+        /// </summary>
+        /// <param name="xmlPath">xml文档路径</param>
+        /// <param name="XmlPathNode">节点的路径:根节点/父节点/当前节点</param>
+        /// <returns></returns>
+        public static DataSet GetXmlData(string xmlPath, string XmlPathNode)
+        {
+            XmlDocument objXmlDoc = new XmlDocument();
+            objXmlDoc.Load(xmlPath);
+            DataSet ds = new DataSet();
+            StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
+            ds.ReadXml(read);
+            return ds;
+        }
+        #endregion
+
+
+
+        //必须创建对象才能使用的类
+        private bool _alreadyDispose = false;
+        private XmlDocument xmlDoc = new XmlDocument();
+        //private XmlNode xmlNode;
+        //private XmlElement xmlElem;
+        private string _xmlPath;
+
+        #region 构造与释构
+        public XMLoperate()
+        {
+        }
+        public XMLoperate(string xmlPath)
+        {
+            _xmlPath = xmlPath;
+        }
+        ~XMLoperate()
+        {
+            Dispose();
+        }
+        protected virtual void Dispose(bool isDisposing)
+        {
+            if (_alreadyDispose) return;
+            if (isDisposing)
+            {
+                //
+            }
+            _alreadyDispose = true;
+        }
+        #endregion
+
+        #region IDisposable 成员
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+        #endregion
+
+        #region 根据父节点属性值读取子节点值
+
+        /// <summary>
+        /// 根据父节点属性读取字节点值
+        /// </summary>
+        /// <param name="XmlPath">xml路径</param>
+        /// <param name="FatherElenetName">父节点名</param>
+        /// <param name="AttributeName">属性值</param>
+        /// <param name="AttributeIndex">属性索引</param>
+        /// <param name="ArrayLength">要返回的节点数组长度</param>
+        /// <returns></returns>
+        public static System.Collections.ArrayList GetSubElementByAttribute(string XmlPath, string FatherElenetName, string AttributeName, int AttributeIndex, int ArrayLength)
+        {
+            System.Collections.ArrayList al = new System.Collections.ArrayList();
+            XmlDocument docXml = new XmlDocument();
+            docXml.Load(@XmlPath);
+            XmlNodeList xn = docXml.DocumentElement.ChildNodes;
+            //遍历第一层节点
+            foreach (XmlElement element in xn)
+            {
+                //判断父节点是否为指定节点
+                if (element.Name == FatherElenetName)
+                {
+                    //判断父节点属性的索引是否大于指定索引
+                    if (element.Attributes.Count < AttributeIndex)
+                        return null;
+                    //判断父节点的属性值是否等于指定属性
+                    if (element.Attributes[AttributeIndex].Value == AttributeName)
+                    {
+                        XmlNodeList xx = element.ChildNodes;
+                        if (xx.Count > 0)
+                        {
+                            for (int i = 0; i < ArrayLength & i < xx.Count; i++)
+                            {
+                                al.Add(xx[i].InnerText);
+                            }
+                        }
+                    }
+                }
+            }
+            return al;
+        }
+        #endregion
+
+        #region 根据节点属性读取子节点值(较省资源模式)
+
+        /// <summary>
+        /// 根据节点属性读取子节点值(较省资源模式)
+        /// </summary>
+        /// <param name="XmlPath">xml路径</param>
+        /// <param name="FatherElement">父节点值</param>
+        /// <param name="AttributeName">属性名称</param>
+        /// <param name="AttributeValue">属性值</param>
+        /// <param name="ArrayLength">返回的数组长度</param>
+        /// <returns></returns>
+        public static System.Collections.ArrayList GetSubElementByAttribute(string XmlPath, string FatherElement, string AttributeName, string AttributeValue, int ArrayLength)
+        {
+            System.Collections.ArrayList al = new System.Collections.ArrayList();
+            XmlDocument docXml = new XmlDocument();
+            docXml.Load(@XmlPath);
+            XmlNodeList xn;
+            xn = docXml.DocumentElement.SelectNodes("//" + FatherElement + "[" + @AttributeName + "='" + AttributeValue + "']");
+            XmlNodeList xx = xn.Item(0).ChildNodes;
+            for (int i = 0; i < ArrayLength & i < xx.Count; i++)
+            {
+                al.Add(xx.Item(i).InnerText);
+            }
+            return al;
+        }
+        #endregion
+
+        #region 根据父节点属性值读取子节点值
+
+        /// <summary>
+        /// 根据父节点属性读取字节点值
+        /// </summary>
+        /// <param name="XmlPath">xml路径</param>
+
+        /// <returns></returns>
+        public static Dictionary<string, object> GetXMLAllInfo(string XmlPath)
+        {
+            if (XmlPath == "")
+            {
+                return null;
+            }
+            Dictionary<string, object> suggestions = new Dictionary<string, object>();
+            XmlDocument docXml = new XmlDocument();
+            docXml.Load(@XmlPath);
+            XmlNodeList xn = docXml.DocumentElement.ChildNodes;
+            //遍历第一层节点
+            foreach (XmlElement element in xn)
+            {
+
+                string name = element.Name;
+                if ("Collection"!= name)
+                {
+                    int attributes = element.Attributes.Count;
+                    Dictionary<string, object> obj = new Dictionary<string, object>();
+                    string key = "";
+                    foreach (System.Xml.XmlAttribute item in element.Attributes)
+                    {
+                        if (item.Name == "RegName")
+                        {
+                            key = item.Value;
+                        }
+                        else
+                        {
+                            obj.Add(item.Name, item.Value);
+                        }
+                    }
+
+                    if (element.ChildNodes.Count > 0)
+                    {
+                        Dictionary<string, object> childList = GetChildInfo(element.ChildNodes);
+                        if (childList.Count > 0)
+                        {
+                            obj.Add("Members", childList);
+                        }
+                    }
+                    suggestions.Add(key, obj);
+                }
+               
+            }
+            return suggestions;
+        }
+        private static Dictionary<string, object> GetChildInfo(XmlNodeList childs)
+        {
+            Dictionary<string, object> child = new Dictionary<string, object>();
+            foreach (XmlElement element in childs)
+            {
+                if (element.Name != "Member")
+                    continue;
+                int attributes = element.Attributes.Count;
+                Dictionary<string, object> obj = new Dictionary<string, object>();
+                string key = "";
+                foreach (System.Xml.XmlAttribute item in element.Attributes)
+                {
+                    if (item.Name == "RegName")
+                    {
+                        key = item.Value;
+                    }
+                    else
+                    {
+                        obj.Add(item.Name, item.Value);
+                    }
+                }
+                if (element.ChildNodes.Count > 0)
+                {
+                    
+
+                    Dictionary<string, object> childList = GetChildInfo(element.ChildNodes);
+                    if (childList.Count > 0)
+                    {
+                        obj.Add("Members", childList);
+                    }
+                }
+                child.Add(key, obj);
+            }
+            return child;
+        }
+        #endregion
+
+        public static List<string> GetMember(string XmlPath, string tem)
+        {
+            if (XmlPath == "")
+            {
+                return null;
+            }
+            XmlDocument docXml = new XmlDocument();
+            docXml.Load(@XmlPath);
+            XmlNodeList xn = docXml.DocumentElement.ChildNodes[0].ChildNodes;
+            List<string> elem = new List<string>();
+            //遍历第一层节点
+            foreach (XmlElement element in xn)
+            {
+                foreach (System.Xml.XmlAttribute item in element.Attributes)
+                {
+                    if (item.Name == "TemplateName" && item.Value == tem)
+                    {
+                        elem.Add(element.ChildNodes[0].ChildNodes[0].Attributes["ElementName"].Value);
+                        elem.Add(element.ChildNodes[0].ChildNodes[1].Attributes["ElementName"].Value);
+                        elem.Add(element.ChildNodes[0].ChildNodes[2].Attributes["ElementName"].Value);
+                        return elem;
+                    }
+
+                }
+
+            }
+            return elem;
+        }
+        /// <summary>
+        /// 修改xml
+        /// </summary>
+        /// <param name="FilePath">文件地址</param>
+        /// <param name="RegName">节点名称</param>
+        /// <param name="Name">节点属性名称</param>
+        /// <param name="Value">节点属性值</param>
+        public static bool EditXmlInfo(string FilePath, string TagName, string Name, string Value)
+        {
+            try
+            {
+                XmlDocument xmlDoc = new XmlDocument();
+                xmlDoc.Load(FilePath);    //加载Xml文件  
+
+                XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Member");
+
+                foreach (XmlNode node in nodeList)
+                {
+                    XmlElement ele = (XmlElement)node;
+                    if (ele.GetAttribute("RegName") == TagName)
+                    {
+                        ele.SetAttribute(Name, Value);
+                    }
+
+                }
+                xmlDoc.Save(FilePath);
+                return true;
+            }
+            catch /*(Exception e)*/
+            {
+                return false;
+            }
+
+
+        }
+        public static bool EditMemberXmlInfo(string FilePath, string TagName, string Name, string Value)
+        {
+            try
+            {
+                XmlDocument xmlDoc = new XmlDocument();
+
+                xmlDoc.Load(FilePath);    //加载Xml文件  
+
+                XmlNodeList nodeList = xmlDoc.GetElementsByTagName("Member");
+
+                foreach (XmlNode node in nodeList)
+                {
+                    XmlElement ele = (XmlElement)node;
+                    if (ele.GetAttribute("RegName") == TagName)
+                    {
+                        ele.SetAttribute(Name, Value);
+                    }
+
+                   
+
+
+                }
+                xmlDoc.Save(FilePath);
+                return true;
+            }
+            catch /*(Exception e)*/
+            {
+                return false;
+            }
+
+
+        }
+
+        /// <summary>
+        /// 获取XML节点参数
+        /// </summary>
+        /// <param name="Name">节点参数名称</param>
+        /// <returns>节点参数</returns>
+        public static string GetXMLInformations(string xmlFilePath, string Name)
+        {
+            try
+            {
+                string value = string.Empty;
+                XmlDocument doc = new XmlDocument();
+
+                doc.Load(xmlFilePath);    //加载Xml文件  
+
+                XmlElement root = doc.DocumentElement;   //获取根节点  
+
+                XmlNodeList mainNodes = root.GetElementsByTagName("parameter"); //获取子节点集合  
+
+                foreach (XmlNode node in mainNodes)
+                {
+                    //获取Name属性值
+                    string name = ((XmlElement)node).GetAttribute("Name");
+                    if (name.Equals(Name))
+                    {
+                        value = ((XmlElement)node).GetAttribute("Value");
+                    }
+                }
+                return value;
+            }
+            catch (Exception)
+            {
+                return "";
+            }
+        }
+
+        /// <summary>
+        /// 修改第二层节点数据
+        /// </summary>
+        /// <param name="XmlPath">XML路径</param>
+        /// <param name="AttributeName">所有需要修改的属性名称</param>
+        /// <param name="Value">需要修改的值</param>
+        /// <returns></returns>
+        public static bool UpdateByAttribute(string XmlPath, string[] AttributeName, string[] Value)
+        {
+            try
+            {
+                XmlDocument docXml = new XmlDocument();
+                docXml.Load(@XmlPath);
+                XmlNodeList xn = docXml.DocumentElement.ChildNodes;
+                //遍历第一层节点
+                foreach (XmlElement element in xn)
+                {
+                    if (element.Attributes[0].Value == Value[0])
+                    {
+                        for (int i = 0; i < element.Attributes.Count; i++)
+                        {
+                            for (int j = 0; j < AttributeName.Count(); j++)
+                            {
+                                //判断父节点的属性值是否等于指定属性
+                                if (element.Attributes[i].Name == AttributeName[j])
+                                {
+                                    element.SetAttribute(AttributeName[j], Value[j]);
+                                    break;
+                                }
+                            }
+                        }
+                        break;
+                    }
+                }
+                docXml.Save(@XmlPath);
+                return true;
+            }
+            catch /*(Exception e)*/
+            {
+                return false;
+            }
+
+
+        }
+        public static int InsertAttribute(string XmlPath, string[] AttributeName, string[] Value, string nodeName)
+        {
+            try
+            {
+                XmlDocument docXml = new XmlDocument();
+                docXml.Load(@XmlPath);
+                XmlNodeList xn = docXml.DocumentElement.ChildNodes;
+                foreach (XmlElement element in xn)
+                {
+                    if (element.Attributes[0].Value == Value[0])
+                    {
+                        return -1;
+                    }
+                }
+                XmlElement xe = docXml.CreateElement(nodeName);
+                for (int i = 0; i < AttributeName.Count(); i++)
+                {
+                    xe.SetAttribute(AttributeName[i], Value[i]);
+                }
+                docXml.DocumentElement.AppendChild(xe);
+                docXml.Save(@XmlPath);
+                return 1;
+            }
+            catch /*(Exception e)*/
+            {
+                return 0;
+            }
+        }
+        public static int DeleteByAttribute(string XmlPath, string AttributeName, string Value)
+        {
+            try
+            {
+                XmlDocument docXml = new XmlDocument();
+                docXml.Load(@XmlPath);
+                XmlNodeList xn = docXml.DocumentElement.ChildNodes;
+                foreach (XmlElement element in xn)
+                {
+                    if (element.Attributes[AttributeName].Value == Value)
+                    {
+                        element.ParentNode.RemoveChild(element);
+                        docXml.Save(@XmlPath);
+                        return 1;
+                    }
+                }
+                return 2;
+            }
+            catch /*(Exception e)*/
+            {
+                return 0;
+            }
+        }
+
+        #region 报告模板
+
+        /// <summary>
+        /// 写入配置,也可以用来修改
+        /// </summary>
+        /// <param name="value">写入的值</param>
+        /// <param name="nodes">节点</param>
+        public void Write(string value, params string[] nodes)
+        {
+            //初始化xml
+            XmlDocument xmlDoc = new XmlDocument();
+            if (File.Exists(_xmlPath))
+                xmlDoc.Load(_xmlPath);
+            else
+                xmlDoc.LoadXml("<XmlConfig />");
+            XmlNode xmlRoot = xmlDoc.ChildNodes[0];
+
+            //新增、编辑 节点
+            string xpath = string.Join("/", nodes);
+            XmlNode node = xmlDoc.SelectSingleNode(xpath);
+            if (node == null)    //新增节点
+            {
+                node = makeXPath(xmlDoc, xmlRoot, xpath);
+            }
+            node.InnerText = value;
+
+            //保存
+            xmlDoc.Save(_xmlPath);
+        }
+
+        /// <summary>
+        /// 设置节点上属性的值
+        /// </summary>
+        /// <param name="AttributeName">属性名</param>
+        /// <param name="AttributeValue">属性值</param>
+        /// <param name="nodes">选择节点</param>
+        public void SetAttribute(string AttributeName, string AttributeValue, params string[] nodes)
+        {
+            //初始化xml
+            XmlDocument xmlDoc = new XmlDocument();
+            if (File.Exists(_xmlPath))
+                xmlDoc.Load(_xmlPath);
+            else
+                xmlDoc.LoadXml("<XmlConfig />");
+            XmlNode xmlRoot = xmlDoc.ChildNodes[0];
+
+            //新增、编辑 节点
+            string xpath = string.Join("/", nodes);
+            XmlElement element = (XmlElement)xmlDoc.SelectSingleNode(xpath);
+            if (element == null)    //新增节点
+            {
+                element = (XmlElement)makeXPath(xmlDoc, xmlRoot, xpath);
+            }
+
+            //设置节点上属性的值
+            element.SetAttribute(AttributeName, AttributeValue);
+            //保存
+            xmlDoc.Save(_xmlPath);
+        }
+
+        public string GetAttribute(string AttributeName, params string[] nodes)
+        {
+            //初始化xml
+            XmlDocument xmlDoc = new XmlDocument();
+            if (File.Exists(_xmlPath))
+                xmlDoc.Load(_xmlPath);
+            else
+                xmlDoc.LoadXml("<XmlConfig />");
+            XmlNode xmlRoot = xmlDoc.ChildNodes[0];
+
+            //新增、编辑 节点
+            string xpath = string.Join("/", nodes);
+            XmlElement element = (XmlElement)xmlDoc.SelectSingleNode(xpath);
+            if (element == null)    //新增节点
+            {
+                element = (XmlElement)makeXPath(xmlDoc, xmlRoot, xpath);
+            }
+
+            //设置节点上属性的值
+            string retstr = element.GetAttribute(AttributeName);
+            //保存
+            xmlDoc.Save(_xmlPath);
+
+            return retstr;
+        }
+
+
+        /// <summary>
+        /// 读取配置
+        /// </summary>
+        /// <param name="nodes">节点</param>
+        /// <returns></returns>
+        public string Read(params string[] nodes)
+        {
+            XmlDocument xmlDoc = new XmlDocument();
+            if (File.Exists(_xmlPath) == false)
+                return null;
+            else
+                xmlDoc.Load(_xmlPath);
+
+            string xpath = string.Join("/", nodes);
+            XmlNode node = xmlDoc.SelectSingleNode("/XmlConfig/" + xpath);
+            if (node == null)
+                return null;
+
+            return node.InnerText;
+        }
+
+        /// <summary>
+        /// 删除节点
+        /// </summary>
+        /// <param name="nodes"></param>
+        public void RemoveNode(params string[] nodes)
+        {
+            XmlDocument xmlDoc = new XmlDocument();
+            if (File.Exists(_xmlPath) == false)
+                return;
+            else
+                xmlDoc.Load(_xmlPath);
+
+            string xpath = string.Join("/", nodes);
+            XmlNode node = xmlDoc.SelectSingleNode("/XmlConfig/" + xpath);
+
+            //取得父节点
+            string[] father_nodes = new string[nodes.Count() - 1];
+
+            //对父节点进行初始化
+            for (int i = 0; i < nodes.Count() - 1; i++)
+            {
+                father_nodes[i] = (string)nodes[i].Clone();
+            }
+
+
+            string fast_xpath = string.Join("/", father_nodes);
+            XmlNode fastnode = xmlDoc.SelectSingleNode("/XmlConfig/" + fast_xpath);
+
+            if (node == null)
+                return;
+            if (fastnode == null)
+                return;
+
+            //使用父节点删除子节点
+            fastnode.RemoveChild(node);
+
+            //保存
+            xmlDoc.Save(_xmlPath);
+        }
+
+
+
+        //递归根据 xpath 的方式进行创建节点
+        static private XmlNode makeXPath(XmlDocument doc, XmlNode parent, string xpath)
+        {
+
+            // 在XPath抓住下一个节点的名称;父级如果是空的则返回
+            string[] partsOfXPath = xpath.Trim('/').Split('/');
+            string nextNodeInXPath = partsOfXPath.First();
+            if (string.IsNullOrEmpty(nextNodeInXPath))
+                return parent;
+
+            // 获取或从名称创建节点
+            XmlNode node = parent.SelectSingleNode(nextNodeInXPath);
+            if (node == null)
+                node = parent.AppendChild(doc.CreateElement(nextNodeInXPath));
+
+            // 加入的阵列作为一个XPath表达式和递归余数
+            string rest = String.Join("/", partsOfXPath.Skip(1).ToArray());
+            return makeXPath(doc, node, rest);
+        }
+        #endregion
+
+    }
+
+}