Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.IO;
using System.Linq;
using PowerDocu.Common;

namespace PowerDocu.ClassicWorkflowDocumenter
{
public class ClassicWorkflowDocumentationContent
{
public string folderPath, filename;
public ClassicWorkflowEntity workflow;
public DocumentationContext context;

public string headerOverview = "Overview";
public string headerSteps = "Steps";
public string headerStepDetails = "Step Details";
public string headerTableRelationships = "Table Relationships";
public string headerProperties = "Properties";
public string headerDocumentationGenerated = "Documentation generated at";

public ClassicWorkflowDocumentationContent(ClassicWorkflowEntity workflow, string path, DocumentationContext context)
{
NotificationHelper.SendNotification("Preparing documentation content for Classic Workflow: " + workflow.GetDisplayName());
this.workflow = workflow;
this.context = context;
folderPath = path + CharsetHelper.GetSafeName(@"\WorkflowDoc " + workflow.GetDisplayName() + @"\");
Directory.CreateDirectory(folderPath);
filename = CharsetHelper.GetSafeName(workflow.GetDisplayName());
}

public string GetTableDisplayName(string schemaName)
{
if (string.IsNullOrEmpty(schemaName)) return schemaName;
string displayName = context?.GetTableDisplayName(schemaName) ?? schemaName;
// If display name differs from logical name, show both: "Display Name (logical_name)"
if (!string.IsNullOrEmpty(displayName) && !displayName.Equals(schemaName, System.StringComparison.OrdinalIgnoreCase))
return displayName + " (" + schemaName + ")";
return schemaName;
}

/// <summary>
/// Resolves a field logical name to "Display Name (logical_name)" by looking up
/// the column in the primary entity's table definition.
/// </summary>
public string GetFieldDisplayName(string fieldLogicalName, string entityLogicalName = null)
{
if (string.IsNullOrEmpty(fieldLogicalName)) return fieldLogicalName;

string tableName = entityLogicalName ?? workflow.PrimaryEntity;
if (string.IsNullOrEmpty(tableName) || context?.Tables == null) return fieldLogicalName;

var table = context.Tables.FirstOrDefault(t =>
t.getName().Equals(tableName, System.StringComparison.OrdinalIgnoreCase));
if (table == null) return fieldLogicalName;

var column = table.GetColumns().FirstOrDefault(c =>
c.getLogicalName().Equals(fieldLogicalName, System.StringComparison.OrdinalIgnoreCase));
if (column == null) return fieldLogicalName;

string displayName = column.getDisplayName();
if (!string.IsNullOrEmpty(displayName) && !displayName.Equals(fieldLogicalName, System.StringComparison.OrdinalIgnoreCase))
return displayName + " (" + fieldLogicalName + ")";
return fieldLogicalName;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.IO;
using PowerDocu.Common;

namespace PowerDocu.ClassicWorkflowDocumenter
{
public static class ClassicWorkflowDocumentationGenerator
{
public static void GenerateOutput(DocumentationContext context, string path)
{
if (context.ClassicWorkflows == null || context.ClassicWorkflows.Count == 0 || !context.Config.documentClassicWorkflows) return;

DateTime startDocGeneration = DateTime.Now;
NotificationHelper.SendNotification($"Found {context.ClassicWorkflows.Count} Classic Workflow(s) in the solution.");

if (context.FullDocumentation)
{
foreach (ClassicWorkflowEntity workflow in context.ClassicWorkflows)
{
ClassicWorkflowDocumentationContent content = new ClassicWorkflowDocumentationContent(workflow, path, context);

// Generate workflow flow diagram
if (workflow.Steps.Count > 0)
{
try
{
GraphBuilder graphBuilder = new GraphBuilder(workflow, content.folderPath);
graphBuilder.BuildGraph();
}
catch (Exception ex)
{
NotificationHelper.SendNotification(" - Warning: Could not generate workflow diagram: " + ex.Message);
}
}

string wordTemplate = (!String.IsNullOrEmpty(context.Config.wordTemplate) && File.Exists(context.Config.wordTemplate))
? context.Config.wordTemplate : null;
if (context.Config.outputFormat.Equals(OutputFormatHelper.Word) || context.Config.outputFormat.Equals(OutputFormatHelper.All))
{
NotificationHelper.SendNotification("Creating Word documentation for Classic Workflow: " + workflow.GetDisplayName());
ClassicWorkflowWordDocBuilder wordDoc = new ClassicWorkflowWordDocBuilder(content, wordTemplate);
}
if (context.Config.outputFormat.Equals(OutputFormatHelper.Markdown) || context.Config.outputFormat.Equals(OutputFormatHelper.All))
{
NotificationHelper.SendNotification("Creating Markdown documentation for Classic Workflow: " + workflow.GetDisplayName());
ClassicWorkflowMarkdownBuilder markdownDoc = new ClassicWorkflowMarkdownBuilder(content);
}
if (context.Config.outputFormat.Equals(OutputFormatHelper.Html) || context.Config.outputFormat.Equals(OutputFormatHelper.All))
{
NotificationHelper.SendNotification("Creating HTML documentation for Classic Workflow: " + workflow.GetDisplayName());
ClassicWorkflowHtmlBuilder htmlDoc = new ClassicWorkflowHtmlBuilder(content);
}
context.Progress?.Increment("Classic Workflows");
}
}
else
{
context.Progress?.Complete("ClassicWorkflows");
}

DateTime endDocGeneration = DateTime.Now;
NotificationHelper.SendNotification(
$"ClassicWorkflowDocumenter: Processed {context.ClassicWorkflows.Count} Classic Workflow(s) in {(endDocGeneration - startDocGeneration).TotalSeconds} seconds."
);
}
}
}
Loading