private static void Test_Message() { HYS.Messaging.Objects.Message msg = new HYS.Messaging.Objects.Message(); msg.Reference = new MessageReference(); //msg.Reference.FileList = new XCollection<MessageReferenceFile>("File"); //msg.Reference.FileList = new XCollection<MessageReferenceFile>(); msg.Reference.FileList.Add(new ReferenceFile()); msg.Reference.FileList.Add(new ReferenceFile()); msg.Reference.FileList[0].Name = "name test"; msg.Reference.FileList[1].Location = "location test"; msg.Body = "aaaaa"; //msg.Body = "aa<aaa"; string xml = msg.ToXMLString(); MessageBox.Show(xml); HYS.Messaging.Objects.Message msg1 = XObjectManager.CreateObject <HYS.Messaging.Objects.Message>(xml); MessageBox.Show(msg1.ToXMLString()); xml = msg.Reference.FileList.ToXMLString(); MessageBox.Show(xml); //XCollection<MessageReferenceFile> list = XObjectManager.CreateObject<XCollection<MessageReferenceFile>>(xml); //MessageBox.Show(list.ToXMLString()); ReferenceFileCollection list = XObjectManager.CreateObject <ReferenceFileCollection>(xml); MessageBox.Show(list.ToXMLString()); }
private void buttonGenDS_Click(object sender, EventArgs e) { string xml = _ctrlCSBMsg.GetXmlString(); if (string.IsNullOrEmpty(xml)) { return; } MSG.Message msg = XObjectManager.CreateObject <MSG.Message>(xml); if (msg == null) { MessageBox.Show(this, "Deserialize CSB DataSet Message failed. See the log file for details.", this.Text); return; } try { DataSet ds = new DataSet(); XmlReadMode m = ds.ReadXml(XmlReader.Create(new StringReader(msg.Body))); //MessageBox.Show(this, string.Format( // "Data Set Name: {0}\r\n" + // "Table Count: {1}\r\n" + // "Row Count: {2}\r\n", // ds.DataSetName, // ds.Tables.Count, // (ds.Tables.Count > 0) ? ds.Tables[0].Rows.Count : 0), // m.ToString()); if (ds.Tables.Count > 0) { this.dataGridViewDS.DataSource = ds.Tables[0]; this.labelDSName.Text = ds.DataSetName + " (" + ds.Tables[0].Rows.Count + ")"; } else { this.dataGridViewDS.DataSource = null; this.labelDSName.Text = ds.DataSetName + " (0)"; } } catch (Exception err) { Program.Log.Write(err); MessageBox.Show(this, "Deserialize DataSet XML failed. See the log file for details.\r\n\r\nMessage: " + err.Message, this.Text); } }
private static void Test_Body() { //string xmlstring = "<a><b>hello</b></a>"; string xmlstring = XMLHeader + "<a><b>hello</b></a>"; //XmlTextReader r = new XmlTextReader(new StringReader(xmlstring)); //if(r.Read()) xmlstring = r.ReadOuterXml(); HYS.Messaging.Objects.Message msg = new HYS.Messaging.Objects.Message(); msg.Body = HYS.Messaging.Objects.Message.RemoveXmlHeader(xmlstring); string str = msg.ToXMLString(); MessageBox.Show(str); HYS.Messaging.Objects.Message newmsg = XObjectManager.CreateObject <HYS.Messaging.Objects.Message>(str); MessageBox.Show(newmsg.ToXMLString()); }