/// <summary> /// 获取Materials /// 已获取,保存数据即可 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GetMaterial() { //根据MRP_NAME 属性 去掉重复的 Material FOIL CORE PREPREG Dictionary <string, string> dictFoilMrpName = new Dictionary <string, string>(); Dictionary <string, string> dictPrepregMrpName = new Dictionary <string, string>(); Dictionary <string, string> dictCoreMrpName = new Dictionary <string, string>(); //根据MRP_NAME 属性 去掉重复的 Material FOIL CORE PREPREG Dictionary <string, string> dictFoilMrpName_N = new Dictionary <string, string>(); Dictionary <string, string> dictPrepregMrpName_N = new Dictionary <string, string>(); Dictionary <string, string> dictCoreMrpName_N = new Dictionary <string, string>(); int Total_Core = 0; int Total_Foil = 0; int Total_Prepreg = 0; stackup = theJob.Stackup();//job->stackup //1、获取数组的长度 {CORE}[X] [FOIL][X] <PREPREG>[X] foreach (IStackupSegment seg in stackup.BuildUpSegments()) //stackup->stksegements->stksegement { //***************生成stakupsegment seg.SegmentIndex(); seg.SegmentType(); //seg.JobMaterials(); //stackupsegement foreach (IJobMaterial jobmat in seg.JobMaterials()) //stksegement->jobmaterials { IMaterial mat = jobmat.Material(); //jobmaterials->jobmaterial //***************生成stakupsegment mat.MrpName(); if (mat.MtrType() == MtrType.CORE_MTR)//material->分类 material(CORE) { if (!dictCoreMrpName.Keys.Contains(mat.MrpName())) { dictCoreMrpName.Add(mat.MrpName(), "第" + (Total_Core + 1).ToString() + "种类别的" + mat.MtrType() + ": " + mat.MrpName()); Total_Core++; } } if (mat.MtrType() == MtrType.FOIL_MTR)//material->分类 material(CORE) { if (!dictFoilMrpName.Keys.Contains(mat.MrpName())) { dictFoilMrpName.Add(mat.MrpName(), "第" + (Total_Foil + 1).ToString() + "种类别的" + mat.MtrType() + ": " + mat.MrpName()); Total_Foil++; } } if (mat.MtrType() == MtrType.PREPREG_MTR)//material->分类 material(CORE) { if (!dictPrepregMrpName.Keys.Contains(mat.MrpName())) { dictPrepregMrpName.Add(mat.MrpName(), "第" + (Total_Prepreg + 1).ToString() + "种类别的" + mat.MtrType() + ": " + mat.MrpName()); Total_Prepreg++; } } } } //2 给键值对数组建立固定数组赋初值 Dictionary <string, dynamic> udaObj = new Dictionary <string, dynamic>(); Dictionary <string, string>[] dictFoil = new Dictionary <string, string> [Total_Foil]; Dictionary <string, string>[] dictCore = new Dictionary <string, string> [Total_Core]; Dictionary <string, string>[] dictPrepreg = new Dictionary <string, string> [Total_Prepreg]; for (int arrayLenth = 0; arrayLenth < dictFoil.Length; arrayLenth++) { dictFoil[arrayLenth] = new Dictionary <string, string>(); } for (int arrayLenth = 0; arrayLenth < dictCore.Length; arrayLenth++) { dictCore[arrayLenth] = new Dictionary <string, string>(); } for (int arrayLenth = 0; arrayLenth < dictPrepreg.Length; arrayLenth++) { dictPrepreg[arrayLenth] = new Dictionary <string, string>(); } //给键值对数组 添加指定属性的元素 //数组下标 int i, j, k; i = 0; j = 0; k = 0; try { foreach (IStackupSegment seg in stackup.BuildUpSegments()) //stackup->stksegements->stksegement { foreach (IJobMaterial jobmat in seg.JobMaterials()) //stksegement->jobmaterials { IMaterial mat = jobmat.Material(); //jobmaterials->jobmaterial //base_Material = mat.Family(); if (mat.MtrType() == MtrType.FOIL_MTR) //material->分类 material(CORE) { //针对CORE属性 1、CORE所有属性 2、属性筛选 3、添加键值对 IFoil foil = mat.Foil(); Dictionary <string, string> dictAllFoil = new Dictionary <string, string>(); XmlGenerate.AllAttrGetKeyValues(foil, dictAllFoil); XmlGenerate.AllAttrGetKeyValues(mat, dictAllFoil); //Base_Material = dictAllFoil["FAMILY"]; string[] a = attrsMaterialsFoil; string[] b = attrsMaterialsFoil_Inplan; int length = 0; if (a.Length == b.Length) { length = a.Length; } else { string str = "请检查是否数组长度定义一一对应"; } if (!dictFoilMrpName_N.Keys.Contains(dictAllFoil["MRP_NAME"])) { dictFoilMrpName_N.Add(dictAllFoil["MRP_NAME"], "第" + (i + 1).ToString() + "种类别的" + mat.MtrType() + ": " + dictAllFoil["MRP_NAME"]); for (int l = 0; l < length; l++) { dictFoil[i].Add(a[l], dictAllFoil[b[l]]); } i++; } string debug = ""; } if (mat.MtrType() == MtrType.PREPREG_MTR)//material->分类 material(CORE) { IPrepreg prepreg = mat.Prepreg(); Dictionary <string, string> dictAllPrepreg = new Dictionary <string, string>(); XmlGenerate.AllAttrGetKeyValues(prepreg, dictAllPrepreg); XmlGenerate.AllAttrGetKeyValues(mat, dictAllPrepreg); base_Material = dictAllPrepreg["FAMILY"]; string[] a = attrsMaterialsPrepreg; string[] b = attrsMaterialsPrepreg_Inplan; int length = 0; if (a.Length == b.Length) { length = a.Length; } else { string str = "请检查是否数组长度定义一一对应"; } if (!dictPrepregMrpName_N.Keys.Contains(dictAllPrepreg["MRP_NAME"])) { dictPrepregMrpName_N.Add(dictAllPrepreg["MRP_NAME"], "第" + (j + 1).ToString() + "种类别的" + mat.MtrType() + ": " + dictAllPrepreg["MRP_NAME"]); for (int l = 0; l < length; l++) { dictPrepreg[j].Add(a[l], dictAllPrepreg[b[l]]); } j++; } string debug = ""; } if (mat.MtrType() == MtrType.CORE_MTR)//material->分类 material(CORE) { ICore core = mat.Core(); Dictionary <string, string> dictAllCore = new Dictionary <string, string>(); XmlGenerate.AllAttrGetKeyValues(core, dictAllCore); XmlGenerate.AllAttrGetKeyValues(mat, dictAllCore); base_Material = dictAllCore["FAMILY"]; string[] a = attrsMaterialsCore; string[] b = attrsMaterialsCore_Inplan; int length = 0; if (a.Length == b.Length) { length = a.Length; } else { string str = "请检查是否数组长度定义一一对应"; } if (!dictCoreMrpName_N.Keys.Contains(dictAllCore["MRP_NAME"])) { dictCoreMrpName_N.Add(dictAllCore["MRP_NAME"], "第" + (k + 1).ToString() + "种类别的" + mat.MtrType() + ": " + dictAllCore["MRP_NAME"]); for (int l = 0; l < length; l++) { dictCore[k].Add(a[l], dictAllCore[b[l]]); } k++; } string debug = ""; } } } //对应XML子节点个数 jobNum_FOIL = Total_Foil; jobNum_PREPREG = Total_Prepreg; jobNum_CORE = Total_Core; jobNum_STACKUP_SEG = Total_Foil + Total_Prepreg + Total_Core; listFoilT = new List <Dictionary <string, string> >(); listPrepregT = new List <Dictionary <string, string> >(); listCoreT = new List <Dictionary <string, string> >(); foreach (var item in dictFoil) { listFoilT.Add(item); } foreach (var item in dictPrepreg) { listPrepregT.Add(item); } foreach (var item in dictCore) { listCoreT.Add(item); } dictFoilT = dictFoil; dictPrepregT = dictPrepreg; dictCoreT = dictCore; } catch (Exception ex) { string exmess = ex.ToString(); //throw; } }