static void Main(string[] args) { try { if (args.Count() == 0) { printhelp(); Console.ReadKey(); return; } else { if (args[0] == "-help") { printhelp(); Console.ReadKey(); return; } else { CCodeAnalyser.CCodeAnalyser Analyser = new CCodeAnalyser.CCodeAnalyser(); CXml xmi = Analyser.Analyse(args); CxmlIDDecorator decorator = new CxmlIDDecorator(xmi); ProjectModel model = Analyser.GetProjectModel(); decorator.Serialise(model.CodeXmlModel); } } } catch (Exception err) { Console.WriteLine(err.ToString()); } }
private void frmAbout_Load(object sender, EventArgs e) { CXml xml = new CXml(); lbServer.Text = xml.ReadXML("P2", "config.xml"); dview.DataSource = xml.ReadXML("config.xml").Tables[0]; }
public CConnection() { try { CXml xml = new CXml(); String_Connection = xml.ReadXML("P2", "config.xml"); }catch {} }
private void xml_write() { try { CXml xml_file = new CXml(); xml_file.WriteXML("AREA", cbkhu.SelectedValue.ToString(), "ConfigCDHA.xml"); } catch { } }
public CConnection(int item) { try { CXml xml = new CXml(); String_Connection = xml.ReadXML("P" + item.ToString(), "config.xml"); } catch { } }
private void xml_write() { try { CXml xml_file = new CXml(); xml_file.WriteXML("ROOM", cbarea.SelectedValue.ToString(), "ConfigCDHA.xml"); xml_file.WriteXML("TECH", cbCDHA_loai.SelectedValue.ToString(), "ConfigCDHA.xml"); } catch { } }
private void loadSysXml() { if (File.Exists(devXmlFile)) { treeView1.Nodes.Clear(); CXml.LoadXmlToTreeView(devXmlFile, treeView1); treeView1.ExpandAll(); this.Text = _title + devXmlFile; } }
private void xml_read() { try { CXml xml_file = new CXml(); string s_area = xml_file.ReadXML("AREA", "ConfigCDHA.xml"); f_set_ComboBox(cbkhu, s_area); } catch { } }
private void xml_read() { try { CXml xml_file = new CXml(); string s_room = xml_file.ReadXML("ROOM", "ConfigCDHA.xml"); string s_tech = xml_file.ReadXML("TECH", "ConfigCDHA.xml"); f_set_ComboBox(cbarea, s_room); f_set_ComboBox(cbCDHA_loai, s_tech); } catch { } }
private int f_getMucDongChiTra() { try { CXml cxml = new CXml(); string MucDongChiTra = cxml.ReadXML("P3", "config.xml"); return int.Parse(MucDongChiTra); } catch { return 0; } }
private bool KiemTraMaThe(string Ma) { CXml cxml = new CXml(); string sformat = cxml.ReadXML("P1", "config.xml"); if (sformat.IndexOf(Ma) >= 0) { return(true); } else { return(false); } }
public bool LoadSaveAll(bool _bLoad) { bool bRet = true; string sFilePath; if (_bLoad) { //sFilePath = m_sParaFolderPath + "MotrAxl.xml"; //object oParaMotrSub = ParaSub ; //if (!CXml.LoadXml(sFilePath, ref oParaMotrSub)) { bRet = false; } //ParaSub = (object [])oParaMotrSub; for (int i = 0; i < m_iMaxMotr; i++) { sFilePath = m_sParaFolderPath + "MotrPara" + i.ToString() + ".xml"; if (!CXml.LoadXml <CParaMotr>(sFilePath, ref Para[i])) { bRet = false; } if (!Mtr[i].LoadSave(_bLoad, m_sParaFolderPath, i)) { bRet = false; } } } else { //sFilePath = m_sParaFolderPath + "MotrAxl.xml"; //object oParaMotrSub = ParaSub; //if (!CXml.SaveXml(sFilePath, ref oParaMotrSub)) { bRet = false; } for (int i = 0; i < m_iMaxMotr; i++) { sFilePath = m_sParaFolderPath + "MotrPara" + i.ToString() + ".xml"; if (!CXml.SaveXml <CParaMotr>(sFilePath, ref Para[i])) { bRet = false; } if (!Mtr[i].LoadSave(_bLoad, m_sParaFolderPath, i)) { bRet = false; } } } return(bRet); }
private void save() { try { SaveFileDialog dlg = new SaveFileDialog(); dlg.InitialDirectory = Application.StartupPath; dlg.Filter = "xml files (*.xml)|*.xml"; if (dlg.ShowDialog() == DialogResult.OK) { CXml.SaveTreeViewToXml(treeView1, dlg.FileName); } } catch (Exception er) { MessageBox.Show(er.ToString()); } }
private static Control GetEditor(this CXml @this) { var editor = new Panel(); var exportbutton = new Button(); exportbutton.Text = "Export"; exportbutton.Click += (sender, args) => { using (var sf = new SaveFileDialog() { Filter = "XML Files | *.xml", Title = "Select a place to save the xml file!" }) { if (sf.ShowDialog() == DialogResult.OK) { @this.Data.Save(sf.FileName); } } }; editor.Controls.Add(exportbutton); var importbutton = new Button(); exportbutton.Text = "Import"; exportbutton.Click += (sender, args) => { using (var of = new OpenFileDialog() { Filter = "XML Files | *.xml", Title = "Please select the file you would like to import!" }) { if (of.ShowDialog() == DialogResult.OK) { @this.Data = new XDocument(File.ReadAllText(of.FileName)); } } }; editor.Controls.Add(exportbutton); editor.PerformLayout(); return(editor); }
/// <summary> /// 해당모터축의 서브파라미터를 LoadSave함. /// </summary> /// <param name="_bLoad">true=로드 false=세이브</param> /// <returns>성공여부</returns> public bool LoadSave(bool _bLoad, string _sParaFolderPath, int _iMotrNo) { string sFilePath = _sParaFolderPath + "MotrNmc2" + _iMotrNo.ToString() + ".xml"; //object oParaMotrSub = Para ; if (_bLoad) { if (!CXml.LoadXml(sFilePath, ref Para)) { return(false); } } else { if (!CXml.SaveXml(sFilePath, ref Para)) { return(false); } } return(true); }
private void open() { try { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = Application.StartupPath; dlg.Filter = "xml files (*.xml)|*.xml"; if (dlg.ShowDialog() == DialogResult.OK) { treeView1.Nodes.Clear(); CXml.LoadXmlToTreeView(dlg.FileName, treeView1); treeView1.ExpandAll(); this.Text = "调式工具(冠佳电子)--" + dlg.FileName; devXmlFile = dlg.FileName; saveIniFile(); } } catch (Exception er) { MessageBox.Show(er.ToString()); } }
public CXml PublishDataBase(string FilePath) { CXml Cxml = new CXml(); XmlSerializer serializer = new XmlSerializer(typeof(CXml)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ElementMap.Values.OrderBy(x => x.File); foreach (string key in ElementMap.Keys) { CElement element = ElementMap[key]; if (element is CFunction) { CFunction function = element as CFunction; //if (function.StorageClass != StorageClass.Static) { Function f = _factory.Fac_GetXmlFunctionType(function); if (function.IsDefinition == false) { IEnumerable <CElement> definition = ElementMap.Values.Where(x => x.ElementID == function.ElementID).ToList(); foreach (CElement e in definition) { if (e is CFunction) { CFunction def = e as CFunction; if (def.IsDefinition == true) { f.Definition = def.ID; } } } } f.PrototypeID = function.ElementID; f.Component = _factory.Fac_GetComponentName(function); f.Interface = _factory.Fac_GetInterfaceName(function); f.CalledFunctions.AddRange(function.Children); Cxml.Functions.Add(f); } } else if (element is CDataType) { Cxml.DataTypes.Add(_factory.Fac_GetXmlDataType(element as CDataType)); } else if (element is CVariable) { CVariable cv = element as CVariable; if (cv.VariableType == VariableType.GlobalVariable) { Variable v = _factory.Fac_GetXmlVariableType(element as CVariable); v.Component = _factory.Fac_GetComponentName(element); Cxml.Variables.Add(v); } } } try { using (var sww = new Utf8StringWriter()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; settings.Encoding = Encoding.ASCII; using (XmlWriter writer = XmlWriter.Create(sww, settings)) { serializer.Serialize(writer, Cxml, ns); string xml = sww.ToString(); StreamWriter w = new StreamWriter(new FileStream(FilePath, FileMode.Create, FileAccess.ReadWrite), Encoding.UTF8); w.Write(xml); w.Close(); } } } catch (Exception err) { Console.WriteLine(err.ToString()); } return(Cxml); }
public bool LoadSaveAll(bool _bLoad) { bool bRet = true; string sFilePath; if (_bLoad) { //sFilePath = m_sParaFolderPath + "MotrAxl.xml"; //object oParaMotrSub = ParaSub ; //if (!CXml.LoadXml(sFilePath, ref oParaMotrSub)) { bRet = false; } //ParaSub = (object [])oParaMotrSub; CAutoIniFile.LoadStruct <TParaAll>(m_sParaFolderPath + "MotrParaAll.ini", "TParaAll", ref ParaAll); for (int i = 0; i < m_iMaxMotr; i++) { sFilePath = m_sParaFolderPath + "MotrPara" + i.ToString() + ".xml"; if (!CXml.LoadXml <CParaMotr>(sFilePath, ref Para[i])) { bRet = false; } if (!Mtr[i].LoadSave(_bLoad, m_sParaFolderPath, i)) { bRet = false; } //Special Handling if (Para[i].dSpeedRatio == 0) { Para[i].dSpeedRatio = 100; } else if (Para[i].dSpeedRatio < 10) { Para[i].dSpeedRatio = 10; } else if (Para[i].dSpeedRatio > 100) { Para[i].dSpeedRatio = 100; } } } else { //sFilePath = m_sParaFolderPath + "MotrAxl.xml"; //object oParaMotrSub = ParaSub; //if (!CXml.SaveXml(sFilePath, ref oParaMotrSub)) { bRet = false; } CAutoIniFile.SaveStruct <TParaAll>(m_sParaFolderPath + "MotrParaAll.ini", "TParaAll", ref ParaAll); for (int i = 0; i < m_iMaxMotr; i++) { //Special Handling if (Para[i].dSpeedRatio == 0) { Para[i].dSpeedRatio = 100; } else if (Para[i].dSpeedRatio < 10) { Para[i].dSpeedRatio = 10; } else if (Para[i].dSpeedRatio > 100) { Para[i].dSpeedRatio = 100; } sFilePath = m_sParaFolderPath + "MotrPara" + i.ToString() + ".xml"; if (!CXml.SaveXml <CParaMotr>(sFilePath, ref Para[i])) { bRet = false; } if (!Mtr[i].LoadSave(_bLoad, m_sParaFolderPath, i)) { bRet = false; } } } return(bRet); }
/// <summary>Запись сообщения.</summary> /// <param name="x_sSource">имя источника сообщения.</param>> /// <param name="x_ulType">тип сообщения.</param>> /// <param name="x_ulForm">вид сообщения.</param>> /// <param name="x_sCategory">категория сообщения.</param>> /// <param name="x_sDescription">текст сообщения.</param>> /// <returns>True, если при записи сообщения не возникли ошибки.</returns> protected override bool WritingMessage( string x_sSource, MessageTypeEnum x_ulType, MessageFormEnum x_ulForm, string x_sCategory, string x_sDescription) { bool c_bSucceeded = true; // Текущие дата и время. DateTime c_dtCurrentTime = DateTime.Now; // Преобразование типа сообщения. string c_sType = "Unknown"; switch (x_ulType) { case MessageTypeEnum.ERROR_MESSAGE: c_sType = "Error"; break; case MessageTypeEnum.WARNING_MESSAGE: c_sType = "Warning"; break; case MessageTypeEnum.INFORMATION_MESSAGE: c_sType = "Information"; break; } XmlDocument c_xdXmlJournal = new XmlDocument(); try { // Создание файла, если он не существует. if (!File.Exists(m_sFileName)) { c_xdXmlJournal.LoadXml(n_sTemplate_EmptyJournal); c_xdXmlJournal.Save(m_sFileName); } // Открытие файла. c_xdXmlJournal.Load(m_sFileName); // Добавление нового сообщения в XML документ. if (x_ulForm == MessageFormEnum.RELEASE_MESSAGE) { CXml.AddElement( c_xdXmlJournal.SelectSingleNode(n_sTemplate_JournalNode), "message", ElementTypeEnum.ATTRIBUTE_ELEMENT, "date", String.Format("{0:d2}.{1:d2}.{2:d4}", c_dtCurrentTime.Day, c_dtCurrentTime.Month, c_dtCurrentTime.Year), "time", String.Format("{0:d2}:{1:d2}:{2:d2}.{3:d3}", c_dtCurrentTime.Hour, c_dtCurrentTime.Minute, c_dtCurrentTime.Second, c_dtCurrentTime.Millisecond), "source", x_sSource, "type", c_sType, "category", x_sCategory, "description", x_sDescription, "user", Environment.UserName, "computer", Environment.MachineName); } else { CXml.AddElement( c_xdXmlJournal.SelectSingleNode(n_sTemplate_JournalNode), "message", ElementTypeEnum.ATTRIBUTE_ELEMENT, "date", String.Format("{0:d2}.{1:d2}.{2:d4}", c_dtCurrentTime.Day, c_dtCurrentTime.Month, c_dtCurrentTime.Year), "time", String.Format("{0:d2}:{1:d2}:{2:d2}.{3:d3}", c_dtCurrentTime.Hour, c_dtCurrentTime.Minute, c_dtCurrentTime.Second, c_dtCurrentTime.Millisecond), "source", x_sSource, "type", c_sType, "category", x_sCategory, "description", x_sDescription, "user", Environment.UserName, "computer", Environment.MachineName, "thread", Thread.CurrentThread.ManagedThreadId.ToString(), "writer", CFormat.GetCaller(new StackFrame(2, true))); } // Сохранение файла. c_xdXmlJournal.Save(m_sFileName); } catch { c_bSucceeded = false; } return(c_bSucceeded); }
private bool LoadXmlPara(string filePath) { try { if (!File.Exists(filePath)) { MessageBox.Show("加载XML文件[" + filePath + "]不存在", "XML文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } packages.Clear(); StreamReader sr = new StreamReader(filePath, Encoding.UTF8); string strXml = sr.ReadToEnd(); sr.Close(); DataSet ds = CXml.ConvertXMLToDataSet(strXml); if (ds == null) { MessageBox.Show("加载XML文件参数错误", "XML文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } if (ds.DataSetName != "Socket") { MessageBox.Show("加载XML文件参数[Socket]错误", "XML文件", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string DeviceType = ds.Tables[0].Rows[i]["DeviceType"].ToString(); string CommandNo = ds.Tables[0].Rows[i]["CommandNo"].ToString(); string CmdWR = ds.Tables[0].Rows[i]["CmdWR"].ToString(); string DataValue = ds.Tables[0].Rows[i]["DataValue"].ToString(); CAPSocket.CPackage pack = new CAPSocket.CPackage(); pack.Name = System.Convert.ToByte(DeviceType, 16); pack.CmdNo = System.Convert.ToByte(CommandNo, 16); pack.WR = System.Convert.ToByte(CmdWR, 16); pack.Data = new List <string>(); string[] strArray = DataValue.Split(';'); for (int z = 0; z < strArray.Length; z++) { pack.Data.Add(strArray[z]); } packages.Add(DeviceType + CommandNo, pack); } return(true); } catch (Exception) { throw; } }