private void GenerateContent() { try { sb.Append(Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".jquery-1.9.0.min.js"))); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-table-overview.htm")); fileContent = fileContent.Replace("$databasename$", _model.ProjectName); fileContent = fileContent.Replace("$pagetitle$", "Tables Documentation"); var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Columns</th>"); tsb.AppendLine("<th>Constraints</th>"); tsb.AppendLine("<th>Refers To</th>"); tsb.AppendLine("<th>Refers From</th>"); tsb.AppendLine("<th>Indexes</th>"); tsb.AppendLine("<th>Description</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var entity in _model.Database.Tables.Where(x => x.Generated).OrderBy(x => x.Name)) { var contraintColumn = new List <Column>(); contraintColumn.AddRange(entity.GetForeignKeyColumns()); contraintColumn.AddRange(entity.GeneratedColumns.Where(x => x.IsIndexed)); contraintColumn.AddRange(entity.GeneratedColumns.Where(x => x.IsUnique && !x.PrimaryKey)); tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"table." + entity.PascalName + ".html\">" + entity.Name + "</a></td>"); tsb.AppendLine("<td>" + entity.GeneratedColumns.Count() + "</td>"); tsb.AppendLine("<td>" + contraintColumn.Distinct().Count() + "</td>"); tsb.AppendLine("<td>" + entity.GetRelationsWhereChild().Count() + "</td>"); tsb.AppendLine("<td>" + entity.GetRelations().Count() + "</td>"); tsb.AppendLine("<td>" + entity.GeneratedColumns.Count(x => x.IsIndexed) + "</td>"); tsb.AppendLine("<td class=\"description\">" + entity.Description + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$listtable$", tsb.ToString()); fileContent = fileContent.Replace("$footertext$", "Powered by nHydrate © " + DateTime.Now.Year); sb.Append(fileContent); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-style.css")); sb.Append(fileContent); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-storedproc-overview.htm")); fileContent = fileContent.Replace("$databasename$", _model.ProjectName); fileContent = fileContent.Replace("$pagetitle$", "Tables Documentation"); var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Parameters</th>"); tsb.AppendLine("<th>Columns</th>"); tsb.AppendLine("<th>Code Length</th>"); tsb.AppendLine("<th>Description</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var entity in _model.Database.CustomStoredProcedures.Where(x => x.Generated).OrderBy(x => x.Name)) { tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"storedprocedure." + entity.PascalName + ".html\">" + entity.Name + "</a></td>"); tsb.AppendLine("<td>" + entity.GeneratedParameters.Count() + "</td>"); tsb.AppendLine("<td>" + entity.GeneratedColumns.Count() + "</td>"); tsb.AppendLine("<td>" + entity.SQL.Length.ToString("###,###,###,##0") + "</td>"); tsb.AppendLine("<td class=\"description\">" + entity.Description + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$listtable$", tsb.ToString()); fileContent = fileContent.Replace("$footertext$", "Powered by nHydrate © " + DateTime.Now.Year); sb.Append(fileContent); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-view-template.htm")); fileContent = fileContent.Replace("$databasename$", _model.ProjectName); fileContent = fileContent.Replace("$objectname$", _item.GetSQLSchema() + "." + _item.Name); var description = _item.Description; if (string.IsNullOrEmpty(description)) { description = "The " + _item.Name + " item"; } fileContent = fileContent.Replace("$objectdescription$", description); fileContent = fileContent.Replace("$pagetitle$", "[" + _item.Name + "] Documentation"); fileContent = fileContent.Replace("$footertext$", "Powered by nHydrate © " + DateTime.Now.Year); #region Column Table var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Data type</th>"); tsb.AppendLine("<th>Length</th>"); tsb.AppendLine("<th>Allow Null</th>"); tsb.AppendLine("<th>Comment</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var subItem in _item.GeneratedColumns) { tsb.AppendLine("<tr class=\"" + (((_item.GeneratedColumns.IndexOf(subItem) % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); tsb.AppendLine("<td>" + subItem.Name + "</td>"); tsb.AppendLine("<td>" + subItem.DatabaseType + "</td>"); tsb.AppendLine("<td>" + subItem.GetLengthString() + "</td>"); tsb.AppendLine("<td>" + subItem.AllowNull.ToString() + "</td>"); tsb.AppendLine("<td class=\"description\">" + subItem.Description + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$columntable$", tsb.ToString()); #endregion #region SQL var sql = nHydrate.Core.SQLGeneration.SQLEmit.GetSqlCreateView(_item, true); var lines = sql.Replace("\r", string.Empty).Split('\n'); var newCode = new StringBuilder(); sql = string.Join("\r\n", lines.Where(x => !x.StartsWith("--MODELID")).ToList()); sql = nHydrate.Core.SQLGeneration.HtmlEmit.FormatHTMLSQL(sql); fileContent = fileContent.Replace("$sql$", sql); #endregion sb.Append(fileContent); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-overview.htm")); fileContent = fileContent.Replace("$databasename$", _model.ProjectName); fileContent = fileContent.Replace("$pagetitle$", "Tables Documentation"); fileContent = fileContent.Replace("$time$", DateTime.Now.ToString("MMM dd yyyy HH:mm:ss")); #region Main { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Type</th>"); tsb.AppendLine("<th>Count</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"tables.html\">Tables</a></td>"); tsb.AppendLine("<td>" + _model.Database.Tables.Count(x => x.Generated) + "</td>"); tsb.AppendLine("</tr>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"views.html\">Views</a></td>"); tsb.AppendLine("<td>" + _model.Database.CustomViews.Count(x => x.Generated) + "</td>"); tsb.AppendLine("</tr>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"storedprocedures.html\">Stored Procedures</a></td>"); tsb.AppendLine("<td>" + _model.Database.CustomStoredProcedures.Count(x => x.Generated) + "</td>"); tsb.AppendLine("</tr>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<td><a href=\"functions.html\">Functions</a></td>"); tsb.AppendLine("<td>" + _model.Database.Functions.Count(x => x.Generated) + "</td>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$listtable$", tsb.ToString()); } #endregion #region Schemas { var schemas = _model.Database.Tables.Where(x => x.Generated).Select(x => x.GetSQLSchema()).ToList(); schemas.AddRange(_model.Database.CustomViews.Where(x => x.Generated).Select(x => x.GetSQLSchema()).ToList()); schemas.AddRange(_model.Database.CustomStoredProcedures.Where(x => x.Generated).Select(x => x.GetSQLSchema()).ToList()); schemas.AddRange(_model.Database.Functions.Where(x => x.Generated).Select(x => x.GetSQLSchema()).ToList()); var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Item Count</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var s in schemas.Distinct().OrderBy(x => x).ToList()) { tsb.AppendLine("<tr>"); tsb.AppendLine("<td>" + s + "</td>"); tsb.AppendLine("<td>" + schemas.Count(x => x == s) + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$schematable$", tsb.ToString()); } #endregion fileContent = fileContent.Replace("$footertext$", "Powered by nHydrate © " + DateTime.Now.Year); sb.Append(fileContent); } catch (Exception ex) { throw; } }
private void GenerateContent() { try { var fileContent = Helpers.GetFileContent(new EmbeddedResourceName(_templateLocation + ".datasite-table-template.htm")); fileContent = fileContent.Replace("$databasename$", _model.ProjectName); fileContent = fileContent.Replace("$objectname$", _item.GetSQLSchema() + "." + _item.Name); var description = _item.Description; if (string.IsNullOrEmpty(description)) { description = "The " + _item.Name + " item"; } fileContent = fileContent.Replace("$objectdescription$", description); fileContent = fileContent.Replace("$pagetitle$", "[" + _item.Name + "] Documentation"); fileContent = fileContent.Replace("$footertext$", "Powered by nHydrate © " + DateTime.Now.Year); var parentTables = _item.GetParentTables().Where(x => x.Generated).ToList(); var indexFieldIDs = _item.TableIndexList.SelectMany(x => x.IndexColumnList).ToList().Where(x => _item.GeneratedColumns.Count(z => new Guid(z.Key) == x.FieldID) > 0).Select(x => x.FieldID).ToList(); var indexedFields = _item.GeneratedColumns.Where(x => indexFieldIDs.Contains(new Guid(x.Key))).ToList(); #region Column Table { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th></th>"); //Icons tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Data type</th>"); tsb.AppendLine("<th>Length</th>"); tsb.AppendLine("<th>Default</th>"); tsb.AppendLine("<th>Allow Null</th>"); tsb.AppendLine("<th>PK</th>"); tsb.AppendLine("<th>FK</th>"); tsb.AppendLine("<th>UQ</th>"); tsb.AppendLine("<th>Computed</th>"); tsb.AppendLine("<th>Comment</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var subItem in _item.GeneratedColumns) { tsb.AppendLine("<tr class=\"" + (((_item.GeneratedColumns.IndexOf(subItem) % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); //Insert icons tsb.Append("<td>"); if (subItem.PrimaryKey) { tsb.Append("<img src=\"key.gif\" title=\"Primary Key\" class=\"icon-prefix\" />"); } if (parentTables.SelectMany(x => x.GeneratedColumns).Count(x => x.Key == subItem.Key) > 0) { tsb.Append("<img src=\"fk.gif\" title=\"Foreign Key\" class=\"icon-prefix\" />"); } if (!string.IsNullOrEmpty(subItem.GetSQLDefault())) { tsb.Append("<img src=\"constraint.gif\" title=\"Constraint\" class=\"icon-prefix\" />"); } if (indexedFields.Contains(subItem)) { tsb.Append("<img src=\"index.gif\" title=\"Index\" class=\"icon-prefix\" />"); } tsb.AppendLine("</td>"); tsb.AppendLine("<td>" + subItem.Name + "</td>"); tsb.AppendLine("<td>" + subItem.DatabaseType + "</td>"); tsb.AppendLine("<td>" + subItem.GetLengthString() + "</td>"); tsb.AppendLine("<td>" + subItem.GetSQLDefault() + "</td>"); tsb.AppendLine("<td>" + (subItem.AllowNull ? "<img src=\"yes.gif\" />" : "") + "</td>"); tsb.AppendLine("<td></td>"); tsb.AppendLine("<td></td>"); tsb.AppendLine("<td>" + (subItem.IsUnique ? "<img src=\"yes.gif\" />" : "") + "</td>"); tsb.AppendLine("<td>" + (subItem.ComputedColumn ? "<img src=\"yes.gif\" />" : "") + "</td>"); tsb.AppendLine("<td class=\"description\">" + subItem.Description + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$columntable$", tsb.ToString()); } #endregion #region Indexes Table var indexList = _item.TableIndexList.ToList(); if (indexList.Count > 0) { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th></th>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Columns</th>"); tsb.AppendLine("<th>Summary</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var index in indexList) { var summary = string.Empty; if (_item.PrimaryKeyColumns.Count == 0 && index.PrimaryKey) { summary += "clustered, "; } if (index.IsUnique) { summary += "unique, "; } if (index.PrimaryKey) { summary += "primary key, "; } if (index.Clustered) { summary += "clustered, "; } if (summary.EndsWith(", ")) { summary = summary.Substring(0, summary.Length - 2); } var indexName = nHydrate.Core.SQLGeneration.SQLEmit.GetIndexName(_item, index); var columnList = nHydrate.Core.SQLGeneration.SQLEmit.GetIndexColumns(_item, index); tsb.AppendLine("<tr class=\"" + (((indexList.IndexOf(index) % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); tsb.AppendLine("<td><img src=\"index.gif\" title=\"Index\" class=\"icon-prefix\" /></td>"); tsb.AppendLine("<td>" + indexName + "</td>"); tsb.AppendLine("<td>" + string.Join(", ", columnList.Values.Select(x => x.DatabaseName)) + "</td>"); tsb.AppendLine("<td>" + summary + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$indextable$", tsb.ToString()); } else { fileContent = fileContent.Replace("$indextable$", "N/A"); } #endregion #region Defaults Table var defaultColumns = _item.GeneratedColumns.Where(x => !string.IsNullOrEmpty(x.Default)).ToList(); if (defaultColumns.Count > 0) { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th>Name</th>"); tsb.AppendLine("<th>Column</th>"); tsb.AppendLine("<th>Data type</th>"); tsb.AppendLine("<th>Value</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); foreach (var subItem in defaultColumns) { tsb.AppendLine("<tr class=\"" + (((defaultColumns.IndexOf(subItem) % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); tsb.AppendLine("<td>" + "DF__" + _item.DatabaseName.ToUpper() + "_" + subItem.DatabaseName.ToUpper() + "</td>"); tsb.AppendLine("<td>" + subItem.Name + "</td>"); tsb.AppendLine("<td>" + subItem.DatabaseType + "</td>"); tsb.AppendLine("<td>" + subItem.Default + "</td>"); tsb.AppendLine("</tr>"); } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$defaulttable$", tsb.ToString()); } else { fileContent = fileContent.Replace("$defaulttable$", "N/A"); } #endregion #region References var referenceTables = _item.GetRelations().ToList(); if (referenceTables.Count > 0) { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th style=\"width:30%;\">Name</th>"); tsb.AppendLine("<th>Column Links</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); var index = 0; foreach (var relation in referenceTables) { tsb.AppendLine("<tr class=\"" + (((index % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); tsb.AppendLine("<td><a href=\"table." + relation.ChildTable.PascalName + ".html" + "\">" + relation.ChildTable.DatabaseName + "</a></td>"); tsb.Append("<td>"); var index2 = 0; foreach (var cr in relation.ColumnRelationships.AsEnumerable()) { if (index2 > 0) { tsb.Append(","); } tsb.Append(cr.ParentColumn.DatabaseName + "=" + cr.ChildColumn.DatabaseName); index2++; } tsb.AppendLine("</td>"); tsb.AppendLine("</tr>"); index++; } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$references$", tsb.ToString()); } else { fileContent = fileContent.Replace("$references$", "N/A"); } #endregion #region Referenced By var referencedByTables = _item.GetRelationsWhereChild().ToList(); if (referencedByTables.Count > 0) { var tsb = new StringBuilder(); tsb.AppendLine("<table class=\"subItem-item\">"); tsb.AppendLine("<thead>"); tsb.AppendLine("<tr>"); tsb.AppendLine("<th style=\"width:30%;\">Name</th>"); tsb.AppendLine("<th>Column Links</th>"); tsb.AppendLine("</tr>"); tsb.AppendLine("</thead>"); tsb.AppendLine("<tbody>"); var index = 0; foreach (var relation in referencedByTables) { tsb.AppendLine("<tr class=\"" + (((index % 2) == 1) ? "t-odd-color" : string.Empty) + "\">"); tsb.AppendLine("<td><a href=\"table." + relation.ParentTable.PascalName + ".html" + "\">" + relation.ParentTable.DatabaseName + "</a></td>"); tsb.Append("<td>"); var index2 = 0; foreach (var cr in relation.ColumnRelationships.AsEnumerable()) { if (index2 > 0) { tsb.Append(","); } tsb.Append(cr.ParentColumn.DatabaseName + "=" + cr.ChildColumn.DatabaseName); index2++; } tsb.AppendLine("</td>"); tsb.AppendLine("</tr>"); index++; } tsb.AppendLine("</tbody>"); tsb.AppendLine("</table>"); fileContent = fileContent.Replace("$referencedby$", tsb.ToString()); } else { fileContent = fileContent.Replace("$referencedby$", "N/A"); } #endregion #region Code var code = GetCode(); code = nHydrate.Core.SQLGeneration.HtmlEmit.FormatHTMLCode(code); fileContent = fileContent.Replace("$code$", code); #endregion #region SQL var sql = nHydrate.Core.SQLGeneration.SQLEmit.GetSQLCreateTable(_model, _item); sql = nHydrate.Core.SQLGeneration.HtmlEmit.FormatHTMLSQL(sql); fileContent = fileContent.Replace("$sql$", sql); #endregion sb.Append(fileContent); } catch (Exception ex) { throw; } }