/// <summary> /// 获取参数表数据转换成ListParaData /// </summary> /// <returns></returns> public static List <ParaData> GetListParaData() { List <ParaData> lstPara = null; if (PubSyswareCom.IsRuntimeServerStarted()) { //获取参数的值 object obj = null; PubSyswareCom.GetParameterNames(string.Empty, ref obj); //转换为字符串数组 if (obj is Object[]) { lstPara = new List <ParaData>(); object[] objName = obj as Object[]; for (int i = 0; i < objName.Count(); i++) { Object objValue = null; PubSyswareCom.mGetParameter(string.Empty, objName[i].ToString(), ref objValue); if (objValue != null) { //参数 if (objName[i].ToString() != "weightData" && objName[i].ToString() != "coreEnvelopeData") { ParaData data = new ParaData(); data.paraName = objName[i].ToString(); try { data.paraValue = Convert.ToDouble(objValue.ToString()); } catch (Exception e) { data.paraValue = 0; XLog.Write(e.Message); } lstPara.Add(data); } } } } } else { MessageBox.Show("TDE/IDE 没有启动成功"); } return(lstPara); }
/// <summary> /// 结构参数对象转xml文件公共方法 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="result"></param> /// <param name="title"></param> /// <param name="dataObjectMethod"></param> /// <returns></returns> public static string DataObjectToXml <T>(T result, string title, DataObjectToXmlDelegate <T> dataObjectMethod) { if (PubSyswareCom.IsRuntimeServerStarted()) { if (result != null) { object obj = null; string path = null; PubSyswareCom.GetParameterNames(null, ref obj); if (obj == null) { return("TDE/IDE 参数表没打开"); } object[] objs = obj as object[]; bool bl = false; foreach (object o in objs) { if (o.ToString() == title) { bl = true; break; } } path = dataObjectMethod(result, bl); if (path == null) { return("SyswareDataObject.xml 生成失败"); } bl = bl ? (PubSyswareCom.AddChildDataObject(title, path)) : (PubSyswareCom.AddDataObject(path)); if (!bl) { return("结构化参数表同步失败"); } return(""); } else { return("评估软件数据集为空"); } } else { return("TDE/IDE 没有启动成功"); } }
/// <summary> /// 获取参数表数据转换成ListParaData /// </summary> /// <returns></returns> public static List <ParaData> GetListParaData() { List <ParaData> lstPara = null; if (PubSyswareCom.IsRuntimeServerStarted()) { //获取参数的值 object obj = null; PubSyswareCom.GetParameterNames(string.Empty, ref obj); //转换为字符串数组 if (obj is Object[]) { lstPara = new List <ParaData>(); object[] objName = obj as Object[]; for (int i = 0; i < objName.Count(); i++) { Object objValue = null; PubSyswareCom.mGetParameter(string.Empty, objName[i].ToString(), ref objValue); if (objValue != null) { //参数 if (objName[i].ToString() != "weightData" && objName[i].ToString() != "coreEnvelopeData") { ParaData data = new ParaData(); data.paraName = objName[i].ToString(); data.paraValue = Convert.ToDouble(objValue.ToString()); lstPara.Add(data); } } } } } return(lstPara); }