public string Post([FromBody] SqlCommunicatorConnection value) { XmlDocument returnVal = new XmlDocument(); string xmlString = ""; if (value != null && value is SqlCommunicatorConnection) { this._myConnection = value; this._myConnection.BuildSqlServerConnectionString(); returnVal = this._myConnection.ExecuteQuery(); if (returnVal != null && !string.IsNullOrWhiteSpace(returnVal.OuterXml)) { xmlString = returnVal.OuterXml; } else { xmlString = "<ERRORS><ERROR>No data was returned!</ERROR></ERRORS>"; } } else { xmlString = "<ROOT><ERRORS><ERROR>No data was returned!</ERROR></ERRORS></ROOT>"; } this._myConnection.Dispose(); return(xmlString); }
public string GeneratePrettyXml(SqlCommunicatorConnection connection) { XmlDocument xDoc = new XmlDocument(); // Set our output settings: XmlWriterSettings xmlSettings = new XmlWriterSettings(); xmlSettings.OmitXmlDeclaration = false; xmlSettings.Indent = true; xmlSettings.NewLineOnAttributes = true; if (connection != null) { XPathNavigator xNav = xDoc.CreateNavigator(); // Generate our Xml Document: using (XmlWriter xw = xNav.AppendChild()) { XmlSerializer xs = new XmlSerializer(connection.GetType()); xs.Serialize(xw, connection); } } return(xDoc.ToString()); }