139 lines
5.8 KiB
C#
139 lines
5.8 KiB
C#
<Query Kind="Statements">
|
|
<Reference><RuntimeDirectory>\System.Web.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.DirectoryServices.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.EnterpriseServices.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Web.RegularExpressions.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Design.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Web.ApplicationServices.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.ComponentModel.DataAnnotations.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.DirectoryServices.Protocols.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Security.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Runtime.Caching.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.ServiceProcess.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Web.Services.dll</Reference>
|
|
<Reference><RuntimeDirectory>\Microsoft.Build.Utilities.v4.0.dll</Reference>
|
|
<Reference><RuntimeDirectory>\Microsoft.Build.Framework.dll</Reference>
|
|
<Reference><RuntimeDirectory>\Microsoft.Build.Tasks.v4.0.dll</Reference>
|
|
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference>
|
|
</Query>
|
|
|
|
var xmlPath = @"C:\Users\James\Projects\Standalone\LogParserPlus\LogParserPlus.Web\App_Data\queries.xml";
|
|
var mdPath = @"C:\Users\James\Projects\logparserplus.com\content\examples\";
|
|
|
|
var xmlItems = XDocument.Load(xmlPath).Descendants("query");
|
|
|
|
var filePath = "";
|
|
foreach (var xmlItem in xmlItems)
|
|
{
|
|
xmlItem.Dump();
|
|
|
|
filePath = mdPath + xmlItem.Attribute("id").Value + ".md";
|
|
|
|
if (File.Exists(filePath))
|
|
{
|
|
File.Delete(filePath);
|
|
}
|
|
|
|
var fileData = new StringBuilder();
|
|
fileData.AppendLine("+++");
|
|
fileData.AppendFormat("id = {0}" + Environment.NewLine, xmlItem.Attribute("id").Value);
|
|
fileData.AppendFormat("name = \"{0}\"" + Environment.NewLine, xmlItem.Element("name").Value);
|
|
fileData.AppendFormat("description = \"{0}\"" + Environment.NewLine, xmlItem.Element("description").Value);
|
|
// Keywords
|
|
var keywords = xmlItem.Element("keywords").Elements("keyword").Select(e => e.Value).Where(e => !string.IsNullOrWhiteSpace(e));
|
|
if (keywords.Any())
|
|
{
|
|
fileData.AppendFormat("keywords = [\"{0}\"]" + Environment.NewLine, string.Join("\", \"", keywords));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("parameters").Value))
|
|
{
|
|
fileData.AppendFormat("statementParameters = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("parameters").Value.Replace("\"", "\\\""));
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("select").Value))
|
|
{
|
|
fileData.AppendFormat("statementSelect = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("select").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("using").Value))
|
|
{
|
|
fileData.AppendFormat("statementUsing = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("using").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("into").Value))
|
|
{
|
|
fileData.AppendFormat("statementInto = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("into").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("from").Value))
|
|
{
|
|
fileData.AppendFormat("statementFrom = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("from").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("where").Value))
|
|
{
|
|
fileData.AppendFormat("statementWhere = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("where").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("groupBy").Value))
|
|
{
|
|
fileData.AppendFormat("statementGroupby = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("groupBy").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("having").Value))
|
|
{
|
|
fileData.AppendFormat("statementHaving = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("having").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("statement").Element("orderBy").Value))
|
|
{
|
|
fileData.AppendFormat("statementOrderby = \"{0}\"" + Environment.NewLine, xmlItem.Element("statement").Element("orderBy").Value);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(xmlItem.Element("notes").Value))
|
|
{
|
|
fileData.AppendFormat("notes = \"{0}\"" + Environment.NewLine, xmlItem.Element("notes").Value.Replace("\"", "\\\""));
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
var syntaxRaw = System.Web.HttpUtility.HtmlDecode(xmlItem.Element("syntax").Value);
|
|
fileData.AppendFormat("syntax = \"{0}\"" + Environment.NewLine, syntaxRaw);
|
|
fileData.AppendFormat("description = \"{0}\"" + Environment.NewLine, xmlItem.Element("description").Value);
|
|
fileData.AppendFormat("type = \"{0}\"" + Environment.NewLine, xmlItem.Element("type").Value);
|
|
|
|
// Related.
|
|
var relatedItems = xmlItem.Elements("related").Select(e => e.Value).Where(e => !string.IsNullOrWhiteSpace(e));
|
|
if (relatedItems.Any())
|
|
{
|
|
fileData.AppendFormat("related = [\"{0}\"]" + Environment.NewLine, string.Join("\", \"", relatedItems));
|
|
}
|
|
|
|
//fileData.AppendFormat(" = \"{0}\"" + Environment.NewLine, xmlItem.Element("").Value);
|
|
*/
|
|
fileData.AppendLine("+++");
|
|
fileData.AppendLine("");
|
|
/*
|
|
var examples = xmlItem.Element("examples").Descendants().Where(e => !string.IsNullOrWhiteSpace(e.Value));
|
|
if (examples.Any())
|
|
{
|
|
examples.Dump();
|
|
fileData.AppendLine("#### Examples");
|
|
foreach (var example in examples)
|
|
{
|
|
fileData.AppendFormat("- {0}{1}"
|
|
, example.Value
|
|
.Replace("<span>", "`")
|
|
.Replace("</span>", "` " + Environment.NewLine + " ")
|
|
, Environment.NewLine);
|
|
}
|
|
|
|
}
|
|
|
|
// Examples.
|
|
*/
|
|
|
|
fileData.ToString().Dump();
|
|
File.WriteAllText(filePath, fileData.ToString());
|
|
}
|
|
|
|
|
|
|
|
xmlItems.Dump();
|
|
|
|
|