public static void CompareXmlFile(string xml, string xmlRight, bool ignoreNote = true) { XmlVisitor node1 = XmlFileHelper.CreateFromFile(xml).GetRoot(); XmlVisitor rightnode = XmlFileHelper.CreateFromFile(xmlRight).GetRoot(); Console.WriteLine($"now lack implement of CompareXmlFile {xml} {xmlRight}"); }
private bool GenLEUGlobalFile(LEURF leurf, LEUGlobal leugb, GID gid, string filename) { try { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); //根据LEU Result Filtered Values文件的内容修改可变部分的值 leugb.leuName = leurf.leuName; leugb.inBoard.gid = gid.ibGid; leugb.outBoard.gid = gid.ouGid; //5.2.1生成Output_balise,TBD foreach (LEUBeacon beacon in leurf.beaconList) { OutBalise ob = new OutBalise(); ob.id = beacon.outNum; ob.telegram = "LONG"; leugb.obList.Add(ob); } leugb.encoder.netGid = gid.netGid; //根据模板文件格式写入LEU文件 XmlVisitor leuNode = leugb.Write(); xmlFile.SetRoot(leuNode); xmlFile.Save2File(filename); return(true); } catch (System.Exception ex) { return(false); } }
public virtual int Salvar(NotaFiscalEntity notaFiscalEntity, string xml) { try { if (notaFiscalEntity.Status != (int)Status.CANCELADA) { notaFiscalEntity.XmlPath = XmlFileHelper.SaveXmlFile(notaFiscalEntity, xml); } return(Salvar(notaFiscalEntity)); } catch (Exception e) { log.Error(e); try { XmlFileHelper.DeleteXmlFile(notaFiscalEntity); throw; } catch (Exception ex) { log.Error(ex); throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message); } } }
/// <summary> /// /// </summary> /// <returns></returns> public static Dictionary <string, string> GetWebChatCfg() { string releative = ConfigurationManager.AppSettings["WebChatConfigDir"]; string rootName = ConfigurationManager.AppSettings["WebChatConfigRootName"]; return(XmlFileHelper.ReadAppsettingSimulateConfig(NowAppDirHelper.GetNowAppDir(AppCategory.WinApp) + "/" + releative, rootName, "key", "value")); }
void ReadAppCfg() { string cfgDir = NowAppDirHelper.GetNowAppDir(AppCategory.WinApp); string file = TicketAppConfig.Ticket12306CfgReletive;//相对路径名称 configDict = XmlFileHelper.ReadAppsettingSimulateConfig(cfgDir + "/" + file, "configuration/appSettings", "key", "value"); Dictionary<string, string> brushCfg = XmlFileHelper.ReadXmlNodeItemInText(cfgDir + "/" + TicketAppConfig.BrushTicketCfg, "ticket"); }
static APPConfig() { try { XmlFileHelper xmlfilehelper = new XmlFileHelper(); //_fileName = gcsl.AppG.GetAppPath() + CONFIG_FILE; //不再使用gcsl封装,改为系统函数 _fileName = System.Environment.CurrentDirectory + CONFIG_FILE; //Console.WriteLine(_fileName); //通用配置信息 //IntervalCalculate = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/common", "interval_calculate").Value) * 1000; IntervalDisplay = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/common", "interval_calculate").Value) * 1000; app_mode = xmlfilehelper.GetXmlAttribute(_fileName, "/config/common", "appmode").Value; app_debug_password = xmlfilehelper.GetXmlAttribute(_fileName, "/config/common", "password").Value; try { log_validperiod = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/common", "log_validperiod").Value); } catch { log_validperiod = 60; } //实时计算引擎相关配置 realcalcu_calcunode = xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "calcunode").Value; realcalcu_period = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "period").Value); realcalcu_periodwritepslcalcuitem = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "periodwritepslcalcuitem").Value); //配置文件中是小时 realcalcu_autorun = xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "autorun").Value; realcalcu_maxreadrtdb = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "maxreadrtdb").Value); realcalcu_recordcalcutime = xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "recordcalcutime").Value; realcalcu_recordsavenumber = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/realcalcu", "recordsavenumber").Value); //历史计算引擎相关配置 historycalcu_period4RTD = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/historycalcu", "historycalcu_period4RTD").Value); historycalcu_period4PSL = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/historycalcu", "historycalcu_period4PSL").Value); //实时数据库配置信息 rtdb_Type = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rtdb", "type").Value; rtdb_connString = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rtdb", "connstring").Value; rtdb_maxrepeatonerror = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/rtdb", "maxrepeatonerror").Value); rtdb_waitsecondonerror = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/rtdb", "waitsecondonerror").Value); //关系数据库配置信息 rdb_Type = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdb", "type").Value; rdb_connString = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdb", "connstring").Value; //Console.WriteLine(rdb_connString); //关系库数据表设置 rdbtable_resulttagauto = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdbtable", "resulttagauto").Value; rdbtable_resulttagincludeinterval = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdbtable", "resulttagincludeinterval").Value; rdbtable_tag2idalwaysreset = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdbtable", "tag2idalwaysreset").Value; rdbtable_iniTableIncludePsldata = xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdbtable", "iniTableIncludePsldata").Value; rdbtable_constmaxnumber = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/rdbtable", "constmaxnumber").Value); //关系库psldata数据表设置 psldata_startyear = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/psldata", "startyear").Value); psldata_endyear = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/psldata", "endyear").Value); psldata_intervalmonth = int.Parse(xmlfilehelper.GetXmlAttribute(_fileName, "/config/psldata", "intervalmonth").Value); } catch (Exception e) { string messageStr = String.Format(e.Message + "{0}!", CONFIG_FILE); MessageBox.Show(messageStr, "读入计算引擎xml文件"); } }
void ReadSql(Type table) { string xml = AppSettingItem.AppDataSqlXml;//xml 文件 //读取进行操作的SQL语句 string nodeName = BaseCfgItem.AppCfgXmlNodeFormat + "/" + table.Name; //读取节点项 string addSqlCmd = XmlFileHelper.ReadXmlItemValue(xml, nodeName, "key", "value", "Insert"); }
private void SaveAllNotes() { if (!System.IO.File.Exists(ContentFilePath)) { System.IO.File.CreateText(ContentFilePath); } XmlFileHelper.SaveDataToFile(_allNotes, ContentFilePath); }
protected void CreateTable(ColumnTypeName type, int length, int prec, int scale, bool isNullable, string def, string collation) { IAXmlReader xmlReader = new AXmlReader(DbContext); ITableDefinition tableDefinition = xmlReader.ReadSchema( DbContext.ColumnTypeConverterForRead, XmlFileHelper.CreateSchemaXmlOneColumn(TableName, type.ConvertToString(), length, prec, scale, isNullable, def, collation)); DbSchema.CreateTable(tableDefinition); }
//todo will delete public void AddLogHead(ref XmlFileHelper xmlFile) { //增加注释头 List <string> comments = new List <string>(); comments.Add(string.Format("Input SYDB file: {0}", sydbFile)); comments.Add(string.Format("Data of generation: {0}", toolVer)); xmlFile.InsertFirstComment(comments); }
private void setTextBox(TextBox textBox, string name) { XmlVisitor root = XmlFileHelper.CreateFromFile(configFile).GetRoot(); XmlVisitor node = root.FirstChildByPath(name); if (null != node) { textBox.Text = node.Value; } }
private UserNotes GetAllNotes() { if (!System.IO.File.Exists(ContentFilePath)) { System.IO.File.CreateText(ContentFilePath); } var data = XmlFileHelper.GetDataFromFile <UserNotes>(ContentFilePath); return(data); }
private void GenTJFormatFileHead(string path) { string logMsg = ""; XmlVisitor allFileRoot = null; string filename = string.Format("{0}\\all_beacons.xml", path); XmlFileHelper allxmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref allxmlFile); allxmlFile.SetRoot("Beacons", null); allxmlFile.Save2File(filename); allFileRoot = allxmlFile.GetRoot(); allFileRoot.UpdateAttribute("NUMBERS", sydb.GetBeacons().Count()); foreach (IBeaconInfo beacon in sydb.GetBeacons()) { string telValue = ""; if (isITC) {//BMGR-0004 TraceMethod.RecordInfo("iTC not support now!"); telValue = "iTC not support"; } else { BeaconMessage bm = new BeaconMessage(); telValue = bm.GenerateMessage(beacon, sydb.LineID); } byte[] urstel = DataOpr.String2byte(telValue); XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); beaconNode.UpdateAttribute("ID", beacon.ID); beaconNode.UpdateAttribute("NAME", beacon.Name); byte[] content = new byte[128]; bool result = DataOpr.PackCallScram_Tel(urstel, content); if (result) { string tel1 = DataOpr.Byte2string(content); beaconNode.AppendChild("Telegram0", telValue); beaconNode.AppendChild("Telegram1", tel1); } else { logMsg = string.Format("Encoding Error!"); TraceMethod.RecordInfo(logMsg); continue; } allFileRoot.AppendChild(beaconNode); } allxmlFile.Save2File(filename); logMsg = "Generate basic_beacons.xml file successfully!"; TraceMethod.RecordInfo(logMsg); }
private void Init() { logFile = currentRunDir + "\\Log\\BMGen.log"; logMsg = "BMGen started."; TraceMethod.RecordInfo(logMsg); //deal the config.xml which used to save the configuration configFile = currentRunDir + "\\Config\\config.xml"; if (!File.Exists(configFile)) {//create a new config file, which is empty XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); xmlFile.SetRoot("config", null); if (!Directory.Exists(currentRunDir + "\\Config\\")) { Directory.CreateDirectory(currentRunDir + "\\Config\\"); } xmlFile.Save2File(configFile); } else { //set the input file path setTextBox(textBoxSyDB, "BeaconLayout_SYDB"); setTextBox(textBoxLayout, "Layout_beacons"); setTextBox(textBoxBoundaryBeacon, "Boundary_beacons"); //set the output path setTextBox(textBoxOutput, "Output"); setTextBox(textBox_UpstreamFile, "Upstream_File"); } if (BMGenTest.Program.GenerateTJFormat) { Assembly ass = Assembly.LoadFile(Path.GetFullPath(".//MetaFly.dll")); Version ver = ass.GetName().Version; TraceMethod.RecordInfo("MetaFly.dll " + ver.ToString()); } { this.Text = "Bcode_iTRNV-BMGenTool2_V1.0.2_Build_20200409_debug"; //set the project radioButtoniTC.Checked = false; Upstream_path_considered.Checked = false; radioButtonInteroperable.Checked = true; //set if choose generate bin files checkBoxGenBin.Checked = false; UpdateUpstreamPage(); } if (Program.AUTOTEST) { object nullobj = new object(); EventArgs nulle = new EventArgs(); progressBar1_Click(nullobj, nulle); } }
public bool Save(T obj) { try { XmlFileHelper.SaveDataToFile(obj, FullPath); } catch (Exception) { return(false); } return(true); }
public T Get() { var result = XmlFileHelper.GetDataFromFile <T>(FullPath); if (result == null) { return(DefaultValue); } SetCacheFileLength(); return(result); }
public void ExcluirNota(string chave, Ambiente ambiente) { var notaFiscalEntity = GetNotaFiscalByChave(chave, (int)ambiente + 1); ExcluirNota(notaFiscalEntity.Numero, notaFiscalEntity.Serie, notaFiscalEntity.Modelo); try { XmlFileHelper.DeleteXmlFile(notaFiscalEntity); } catch (Exception e) { log.Error(e); throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message); } }
public static void SaveConfig(string node, string property, string value) { //参数说明 node:节点 property:属性 value:值 //示例 //xml的写入方法,如下:写入config/calcu 的属性auto //Hashtable autorun = new Hashtable(); //autorun.Add("autorun", "auto1"); //xmlfilehelper.UpdateNode(_fileName, "/config", autorun, autorun); //注意,本方法要求在xml文件中不能有<!--注释列,否则会出错。 XmlFileHelper xmlfilehelper = new XmlFileHelper(); Hashtable nodeproperty = new Hashtable(); nodeproperty.Add(property, value); xmlfilehelper.UpdateNode(_fileName, node, nodeproperty, nodeproperty); }
private bool Save2Config(TextBox textBox, string nodeName) { XmlFileHelper configInfo = XmlFileHelper.CreateFromFile(configFile); XmlVisitor root = configInfo.GetRoot(); XmlVisitor compiler = root.FirstChildByPath(nodeName); if (null == compiler) { root.AppendChild(nodeName, textBox.Text); } else { compiler.Value = textBox.Text; } configInfo.Save2File(configFile); return(true); }
//BMRG-0037 private Dictionary <string, List <PathInfo> > GetConfigBeacon(string filename) { Dictionary <string, List <PathInfo> > allBeacons = new Dictionary <string, List <PathInfo> >(); XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(filename); if (null != xmlfile) { XmlVisitor root = xmlfile.GetRoot(); List <XmlVisitor> beacons = root.Children().ToList(); foreach (XmlVisitor node in beacons) { string beaconName = node.GetAttribute("name"); List <PathInfo> list = new List <PathInfo>(); List <XmlVisitor> pathList = node.Children().ToList(); foreach (XmlVisitor up in pathList) { string pathName = up.GetAttribute("name"); List <PointInfo> pointList = new List <PointInfo>(); List <XmlVisitor> pnList = up.Children().ToList(); foreach (XmlVisitor pn in pnList) { string ptName = pn.GetAttribute("name"); int id = DataOpr.Xmlvalue2Int(pn, "id"); Point point = (Point)Sys.GetNode(id, Sydb.pointInfoList.Cast <Basic>().ToList()); string pos = pn.FirstChildByPath("position").Value; string orit = pn.FirstChildByPath("orientation_in_route").Value; if (orit == Sys.Convergent || orit == Sys.Divergent) { PointInfo info = new PointInfo(point, pos, orit, true); pointList.Add(info); } else { //log error } } PathInfo path = new PathInfo(pathName, pointList); list.Add(path); } allBeacons.Add(beaconName, list); } } return(allBeacons); }
public virtual void Salvar(NotaInutilizadaTO notaInutilizada, string xml) { try { notaInutilizada.XmlPath = XmlFileHelper.SaveXmlFile(notaInutilizada, xml); _notaInutilizadaRepository.Salvar((NotaInutilizadaEntity)notaInutilizada); } catch (Exception e) { log.Error(e); try { XmlFileHelper.DeleteXmlFile(notaInutilizada); } catch (Exception ex) { log.Error(ex); throw new Exception("Não foi possível remover o xml de nota fiscal: " + e.Message); } } }
public virtual void Salvar(EventoEntity eventoEntity) { try { eventoEntity.XmlPath = XmlFileHelper.SaveXmlFile(eventoEntity, eventoEntity.Xml); _eventoRepository.Salvar(eventoEntity); } catch (Exception e) { log.Error(e); try { XmlFileHelper.DeleteXmlFile(eventoEntity); } catch (Exception ex) { log.Error(ex); throw new Exception("Não foi possível remover o xml de evento: " + e.Message); } } }
public bool Init(string bmvFile) { if (Option.LEURF == this.option) { try { XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(bmvFile); xmlBMVInfo = xmlfile.GetRoot(); } catch (System.Exception ex) { logMsg = "Read block mode variant file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } return(true); } else { return(false); } }
private bool GenerateBMVFile(string filename) { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); xmlFile.SetRoot("Block_mode_beacons", null); XmlVisitor root = xmlFile.GetRoot(); root.UpdateAttribute("LINE_ID", sydb.LineID);//BMGR-0014 log lineID foreach (BEACON beacon in GetValidBeaconList()) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null); if (false == beacon.SetBeaconInfoNode_BMVF(ref beaconNode) || false == GenerateLEUInfoNode(beacon.m_ibbmInfo, ref beaconNode) || false == GenerateBMBSDDBDisInfoNode(beacon, ref beaconNode)) { //log error TraceMethod.RecordInfo($"Warning:GenerateBMVFile base info[Beacon][LEU][BMBSDDB_Distance] faild for {beacon.Info}."); } //then all reopen sig and the approach sig foreach (OriginSignal orgSig in beacon.GetOrgSignalList()) { beaconNode.AppendChild(orgSig.GetXmlNode(beacon.Name)); } beaconNode.AppendChild(CalBMVariantNode(beacon)); root.AppendChild(beaconNode); } xmlFile.Save2File(filename); return(true); }
private bool GenerateLEUResultFilterFile(string filename) { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); //BMGR-0044 xmlFile.SetRoot("LEU_filtered_values", null); xmlFile.Save2File(filename); XmlVisitor root = xmlFile.GetRoot(); //BMGR-0044 root.UpdateAttribute("LINE_ID", sydb.LineID); //BMGR-0045 List <LEU> orderLEULst = m_LEULst.OrderBy(o => o.ID).ToList(); foreach (LEU leu in orderLEULst) { XmlVisitor LEUnode = XmlVisitor.Create("LEU", null); //set LEU info if (false == GenerateLEUInfoNode(leu, ref LEUnode)) { return(false); } string[] bNames = leu.GetBeaconNames(); //BMGR-0046 for (int i = 0; i < bNames.Count(); ++i) { string bName = bNames[i]; if ("" == bName) { continue; } int Bidx = m_BeaconLst.FindIndex(x => (x.Name == bName)); if (-1 == Bidx) { TraceMethod.RecordInfo($"Warning:LEU[{leu.Name}] contain beacon[{bName}] which not in valid beacon List, this beacon will be ignore!"); continue; } XmlVisitor beaconnode = XmlVisitor.Create("Beacon", null); if (false == GenerateBeaconInfoNode(m_BeaconLst[Bidx], ref beaconnode, i + 1)) { // } m_BeaconLst[Bidx].m_MsgLst = GenerateMessage(m_BeaconLst[Bidx]); if (m_BeaconLst[Bidx].m_MsgLst.Count() > 128) {//BMGR-0050 TraceMethod.RecordInfo($"LEU[{leu.Info} {m_BeaconLst[Bidx].Info}] generate messages {m_BeaconLst[Bidx].m_MsgLst.Count()} > 128"); } foreach (Message msg in m_BeaconLst[Bidx].m_MsgLst) { //mes and combine_sections XmlVisitor msgNode = msg.GetXmlNode(); //BMGR-0051 Variant_state string varstate = GetMsgVar(msg, m_BeaconLst[Bidx]); if (BEACON.MAXVARNUM != varstate.Length) { TraceMethod.RecordInfo($"Beacon[{m_BeaconLst[Bidx].Name}] Variant_state[{varstate}] length != {BEACON.MAXVARNUM}"); } msgNode.AppendChild("Variant_state", varstate); string msgBuff = ""; //Urbalis_iTC if (0 == msg.GetRank()) {//BMGR-0004 leu default msg for input beacon varstate = ""; } //don't output Urbalis_iTC for BMGen tool this time #if itcsupport msgBuff = m_BeaconLst[Bidx].GenMsgItc(varstate); if (86 != msgBuff.Length) { TraceMethod.RecordInfo(string.Format("Beacon[{0}] Urbalis_iTC message length != 16", m_BeaconLst[Bidx].Name)); return(false); } msgNode.AppendChild("Urbalis_iTC", msgBuff); #endif //Interoperable BeaconMessage bm = new BeaconMessage(); msgBuff = bm.GenerateMessage(m_BeaconLst[Bidx], sydb.LineID, msg); if (311 != msgBuff.Length) { TraceMethod.RecordInfo($"{m_BeaconLst[Bidx].Info} Interoperable message length != 311"); } msgNode.AppendChild("Interoperable", msgBuff); beaconnode.AppendChild(msgNode); } LEUnode.AppendChild(beaconnode); } root.AppendChild(LEUnode); } xmlFile.Save2File(filename); return(true); }
public string GetXml(string xmlFile, string sqlNodeKeyName, string sqlNodeValueName, string nodeSqlKey) {//读取xml中节点数据 return(XmlFileHelper.ReadXmlItemValue(xmlFile, sqlNodeKeyName, sqlNodeKeyName, sqlNodeValueName, nodeSqlKey)); }
public bool Init(string file1, string file2) { if (Option.BEACON == this.option) { try { XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(file1); XmlVisitor root = xmlfile.GetRoot(); xmlBeaconInfo = root.FirstChildByPath("Beacons"); } catch (System.Exception ex) { logMsg = "Read beacon layout file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } this.balComPath = file2; return(true); } else if (Option.BMV == this.option) { XmlFileHelper xmlfile = null; try { xmlfile = XmlFileHelper.CreateFromFile(file1); XmlVisitor root = xmlfile.GetRoot(); xmlBeaconInfo = root.FirstChildByPath("Beacons"); } catch (System.Exception ex) { logMsg = "Read beacon layout file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } try { xmlfile = XmlFileHelper.CreateFromFile(file2); xmlSyDBInfo = xmlfile.GetRoot(); } catch (System.Exception ex) { logMsg = "Read system database file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } return(true); } else if (Option.LEUXML == this.option) { XmlFileHelper xmlfile = null; try { xmlfile = XmlFileHelper.CreateFromFile(file1); xmlLEURFInfo = xmlfile.GetRoot(); } catch (System.Exception ex) { logMsg = "Read LEU Result Filtered Value file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } try { xmlfile = XmlFileHelper.CreateFromFile(file2); xmlLEUTFInfo = xmlfile.GetRoot(); } catch (System.Exception ex) { logMsg = "Read LEU XML Template file error, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } return(true); } else if (Option.LEUBIN == this.option) { this.leuFilesDir = file1; this.leuComPath = file2; return(true); } else { logMsg = "The option does not match the input files, please check!"; WriteLog(logMsg, LogManager.Level.Error); return(false); } }
private bool GenLEUXmlFile(LEU_filtered_values.leu leurf, GID gid, string filename) { try { XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref xmlFile); //根据LEU Result Filtered Values文件的内容修改可变部分的值 leuXmlTemplate.name = leurf.NAME; //5.2.1生成Output_balise leuXmlTemplate.Output_balise.Clear();//先清掉已有数据 //calculate leugb.obList by leurf.beaconList #region [cal oblist] foreach (LEU_filtered_values.leu.BEACON beacon in leurf.beaconList) { LEUXML.LEU.OUTPUT_BALISE ob = new LEUXML.LEU.OUTPUT_BALISE(beacon.NAME, beacon.NUM); string[] varInputs = beacon.Variants_inputs.ToString().Split(' '); int index = 0; //BMGR-0064 foreach (string varInput in varInputs) { if (varInput != "0") { LEUXML.LEU.OUTPUT_BALISE.INPUT input = new LEUXML.LEU.OUTPUT_BALISE.INPUT(); input.Channel = new StringData("00"); input.Number = new StringData(varInput.PadLeft(2, '0')); input.index = index; ob.Input.Add(input); } ++index;//BMGR-0072 this is the pos index in variant_input and varait_state } ob.Input.Sort((x, y) => { return(x.Number.ToString().CompareTo(y.Number.ToString())); //根据intNum重新排序,这个排序影响mask的值 }); foreach (LEU_filtered_values.leu.BEACON.MESSAGE msg in beacon.msgList) { if (0 != msg.RANK)//BMGR-0071 { LEUXML.LEU.OUTPUT_BALISE.ASPECT asp = new LEUXML.LEU.OUTPUT_BALISE.ASPECT(); string mask = ""; //BMGR-0072 //根据Input的顺序确定其在MASK中的位置,根据其num找到其在Variants_inputs中的索引 //根据其在Variants_inputs中索引,确定此码位在Variant_state中的索引.[两个索引相等] //判断此索引位置的值,为0则取0,为1则取1,为P或S则取X,然后将MASK不足X至30位 foreach (var inNode in ob.Input) { string value = msg.VarState.Substring(inNode.index, 1); if (value == "0") { mask += '0'; } else if (value == "1") { mask += '1'; } else if (value == "P" || value == "S") { mask += 'X'; } } //补足30位 for (int i = mask.Length; i < 30; i++) { mask += 'X'; } asp.Mask = new StringData(mask); //BMGR-0073 if (isITC) { throw new NotImplementedException(); } else { asp.Telegram = msg.Interoperable; } ob.CheckAspect(asp); ob.Aspect.Add(asp); } } //BMGR-0074 LEU_filtered_values.leu.BEACON.MESSAGE dftMsg = beacon.msgList.Find(x => (int)x.RANK == 0); if (isITC) { throw new NotImplementedException(); } else { ob.Default_telegram = dftMsg.Interoperable; } leuXmlTemplate.Output_balise.Add(ob); } #endregion //GMBR-0060 leuXmlTemplate.updateGid(gid); FileSerializer.Serialize(leuXmlTemplate, filename, AddLogHead()); return(true); } catch (System.Exception ex) { TraceMethod.Record(TraceMethod.TraceKind.ERROR, ex.Message); return(false); } }
public Restriction(string xmlfullname) { XmlFileHelper f = XmlFileHelper.CreateFromFile(xmlfullname); root = f.GetRoot(); }
//for tj format private bool GenBasciXml(string leuFile, string outputPath) { LEU_filtered_values leurfxml = FileLoader.Load <LEU_filtered_values>(leuFile); List <BasicBeacon> BeaconInfoList = new List <BasicBeacon>(); foreach (LEU_filtered_values.leu leurf in leurfxml.LEU) { foreach (LEU_filtered_values.leu.BEACON leuBeacon in leurf.Beacon) { BasicBeacon baBeacon = new BasicBeacon(leuBeacon); var signal = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)Sys.GetNode((string)leuBeacon.LINKED_SIGNAL,sydb.signalInfoList.Cast <Node>().ToList()); if (null == signal) { continue; } baBeacon.SignalId = signal.ID; baBeacon.SignalName = signal.Name; baBeacon.MsgList = new List <MsgRank>(); foreach (LEU_filtered_values.leu.BEACON.MESSAGE msg in leuBeacon.msgList) { MsgRank msgRk = new MsgRank(); msgRk.routeInfo = new List <string>(); //按照Upstream_section,Reopening_section,Approach_section,Overlap_section的顺序将进路上的道岔和信号机依次取出 //先算道岔,再算信号机 List <string> ptList = new List <string>(); List <string> sigList = new List <string>(); if (null != msg.Combined_sections) { JudgeSection(msg.Combined_sections.Upstream_section,ptList,sigList); JudgeSection(msg.Combined_sections.Reopening_section,ptList,sigList); JudgeSection(msg.Combined_sections.Approach_section,ptList,sigList); JudgeSection(msg.Combined_sections.Overlap_section,ptList,sigList); } msgRk.routeInfo.AddRange(ptList); msgRk.routeInfo.AddRange(sigList); //计算tel0和tel1 msgRk.Tel0 = msg.Interoperable; byte[] content = new byte[128]; byte[] telValue = DataOpr.String2byte(msgRk.Tel0); bool result = ScrambleTel(telValue,content); if (result) { msgRk.Tel1 = DataOpr.Byte2string(content); } else { TraceMethod.RecordInfo("Encoding Error!"); continue; } baBeacon.MsgList.Add(msgRk); } BeaconInfoList.Add(baBeacon); } } //写入可变报文配置文件 string allFileName = string.Format("{0}\\basic_beacons.xml",outputPath); XmlFileHelper allxmlFile = XmlFileHelper.CreateFromString(null); AddLogHead(ref allxmlFile); allxmlFile.SetRoot("Beacons",null); allxmlFile.Save2File(allFileName); XmlVisitor allFileRoot = allxmlFile.GetRoot(); allFileRoot.UpdateAttribute("NUMBERS",BeaconInfoList.Count); foreach (BasicBeacon basBeacon in BeaconInfoList) { XmlVisitor beaconNode = XmlVisitor.Create("Beacon",null); beaconNode.UpdateAttribute("ID",basBeacon.ID); beaconNode.UpdateAttribute("NAME",basBeacon.Name); beaconNode.UpdateAttribute("RANKS",basBeacon.MsgList.Count()); beaconNode.UpdateAttribute("TYPE",basBeacon.Type); beaconNode.UpdateAttribute("LINKED_SIGNALID",basBeacon.SignalId); beaconNode.UpdateAttribute("LINKED_SIGNALName",basBeacon.SignalName); for (int i = 0; i < basBeacon.MsgList.Count(); i++) { XmlVisitor rankNode = XmlVisitor.Create("Message",null); rankNode.UpdateAttribute("Rank",i); string route = ""; foreach (string info in basBeacon.MsgList[i].routeInfo) { route += info + "|"; } if (route.EndsWith('|'.ToString())) { route = route.Remove(route.LastIndexOf('|')); } if ("" != route) { rankNode.AppendChild("Route", route); } rankNode.AppendChild("Telegram0", basBeacon.MsgList[i].Tel0); rankNode.AppendChild("Telegram1", basBeacon.MsgList[i].Tel1); beaconNode.AppendChild(rankNode); } allFileRoot.AppendChild(beaconNode); } allxmlFile.Save2File(allFileName); return(true); }