Skip to content

Commit

Permalink
Added check-box control to hide default synchronization rules.
Browse files Browse the repository at this point in the history
Fix for System.IO.PathTooLongException.
  • Loading branch information
NileshGhodekar committed Aug 2, 2017
1 parent f47d0a7 commit 6773030
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 32 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to AADConnectConfigDocumenter project will be documented in
### Version [Unreleased]

* Support for adding report metadata to include section / concept contents.
------------

### Version 1.17.0802.0

#### Added
- Added check-box control to hide default synchronization rules.

------------

Expand Down
3 changes: 3 additions & 0 deletions src/AzureADConnectSyncDocumenter.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
AzureADConnectSyncDocumenterCmd.exe "Contoso\Pilot" "Contoso\Production"
ECHO OFF
ECHO ****************************************************************************************************
ECHO Execution complete. Please check any errors or warnings in the AADConnectSyncDocumenter-Error.log...
@pause
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,20 @@ orderby name
foreach (var connector in pilot)
{
var configEnvironment = production.Any(productionConnector => (string)productionConnector.Element("name") == (string)connector.Element("name")) ? ConfigEnvironment.PilotAndProduction : ConfigEnvironment.PilotOnly;
if (configEnvironment == ConfigEnvironment.PilotOnly)
{
Logger.Instance.WriteWarning("The connector '{0}' only exists in the first set of configuration files. If this is not expected, please edit the config files to match names of this connector in the two enviorments as instructed in the ReadMe wiki.", (string)connector.Element("name"));
}

this.ProcessConnectorConfiguration(connector, configEnvironment);
}

production = production.Where(productionConnector => !pilotConnectors.Contains((string)productionConnector.Element("name")));

foreach (var connector in production)
{
Logger.Instance.WriteWarning("The connector '{0}' only exists in the second set of configuration files and will be documented as a connector that is deleted from the configuration. If this is not intended, please edit the config files to match names of this connector in the two enviorments as instructed in the ReadMe wiki.", (string)connector.Element("name"));

this.ProcessConnectorConfiguration(connector, ConfigEnvironment.ProductionOnly);
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/AzureADConnectSyncDocumenter/Documenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,18 @@ protected void WriteDocumenterInfo()

this.WriteBreakTag();

this.ReportWriter.WriteFullBeginTag("strong");
this.ReportWriter.Write("Hide Default Sync Rules:");
this.ReportWriter.WriteEndTag("strong");

this.ReportWriter.WriteBeginTag("input");
this.ReportWriter.WriteAttribute("type", "checkbox");
this.ReportWriter.WriteAttribute("id", "HideDefaultSyncRules");
this.ReportWriter.WriteAttribute("onclick", "ToggleDefaultRuleVisibility();");
this.ReportWriter.WriteLine(HtmlTextWriter.SelfClosingTagEnd);

this.WriteBreakTag();

this.ReportWriter.WriteFullBeginTag("strong");
this.ReportWriter.Write("Legend:");
this.ReportWriter.WriteEndTag("strong");
Expand Down Expand Up @@ -2077,8 +2089,7 @@ protected void WriteTableHeader(DataTable headerTable)
{
this.ReportWriter.WriteBeginTag("col");
this.ReportWriter.WriteAttribute("style", "width:" + columnWidth + "%;");
this.ReportWriter.Write(HtmlTextWriter.TagRightChar);
this.ReportWriter.WriteEndTag("col");
this.ReportWriter.Write(HtmlTextWriter.SelfClosingTagEnd);
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/AzureADConnectSyncDocumenter/Scripts/Documenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
}
}

function ToggleDefaultRuleVisibility() {
var x = document.getElementById("HideDefaultSyncRules");
var elements = document.getElementsByClassName("DefaultRuleCanHide");
for (var i = 0; i < elements.length; ++i) {
if (x.checked == true) {
elements[i].style.display = "none";
}
else {
elements[i].style.display = "";
}
}
}

function DownloadScript(downloadLink) {
var scripts = document.getElementsByClassName("PowerShellScript");
var data = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<#
This script is generated by the Azure AD Connect Configuration Documenter tool.
The latest version of the tool can be downloaded from https://aka.ms/AADConnectConfigDocumenter.
NO WARRANTY OF ANY KIND IS PROVIDED. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SCRIPT REMAINS WITH THE USER.
When the script is executed, the sync rule configuration of the server is made same as what was provided as the "Pilot" configuration.
The "Pilot" configuration was the first argument passed when running the AAD Connect Config Documenter executable.
#>

#############################################################################################################################################
# This script is generated by the Azure AD Connect Configuration Documenter tool.
# The latest version of the tool can be downloaded from https://aka.ms/AADConnectConfigDocumenter.
#
# NO WARRANTY OF ANY KIND IS PROVIDED. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS SCRIPT REMAINS WITH THE USER.
#
# When the script is executed, the sync rule configuration of the server is made same as what was provided as the "Pilot" configuration.
# The "Pilot" configuration was the first argument passed when running the AAD Connect Config Documenter executable.
#############################################################################################################################################

function Get-CurrentLine {
Expand Down
10 changes: 5 additions & 5 deletions src/AzureADConnectSyncDocumenter/StyleCop.Cache
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
<timestamps>
<styleCop>2016/11/09 21:13:02.000</styleCop>
<settingsFile>2017/04/16 06:55:54.094</settingsFile>
<sourceFile>2017/06/17 07:02:06.124</sourceFile>
<sourceFile>2017/07/27 06:40:54.984</sourceFile>
<parser>2016/11/09 21:13:02.000</parser>
<StyleCop.CSharp.DocumentationRules>2016/11/09 21:13:02.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-277821146</StyleCop.CSharp.DocumentationRules.FilesHashCode>
Expand Down Expand Up @@ -223,7 +223,7 @@
<timestamps>
<styleCop>2016/11/09 21:13:02.000</styleCop>
<settingsFile>2017/04/16 06:55:54.094</settingsFile>
<sourceFile>2017/07/03 23:05:46.690</sourceFile>
<sourceFile>2017/07/27 13:03:47.893</sourceFile>
<parser>2016/11/09 21:13:02.000</parser>
<StyleCop.CSharp.DocumentationRules>2016/11/09 21:13:02.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-277821146</StyleCop.CSharp.DocumentationRules.FilesHashCode>
Expand Down Expand Up @@ -269,7 +269,7 @@
<timestamps>
<styleCop>2016/11/09 21:13:02.000</styleCop>
<settingsFile>2017/04/16 06:55:54.094</settingsFile>
<sourceFile>2017/07/03 23:09:48.706</sourceFile>
<sourceFile>2017/07/28 06:56:35.707</sourceFile>
<parser>2016/11/09 21:13:02.000</parser>
<StyleCop.CSharp.DocumentationRules>2016/11/09 21:13:02.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-277821146</StyleCop.CSharp.DocumentationRules.FilesHashCode>
Expand Down Expand Up @@ -499,7 +499,7 @@
<timestamps>
<styleCop>2016/11/09 21:13:02.000</styleCop>
<settingsFile>2017/04/16 06:55:54.094</settingsFile>
<sourceFile>2017/06/18 06:02:37.186</sourceFile>
<sourceFile>2017/07/28 07:19:20.934</sourceFile>
<parser>2016/11/09 21:13:02.000</parser>
<StyleCop.CSharp.DocumentationRules>2016/11/09 21:13:02.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-277821146</StyleCop.CSharp.DocumentationRules.FilesHashCode>
Expand All @@ -522,7 +522,7 @@
<timestamps>
<styleCop>2016/11/09 21:13:02.000</styleCop>
<settingsFile>2017/04/16 06:55:54.094</settingsFile>
<sourceFile>2017/07/03 21:30:13.063</sourceFile>
<sourceFile>2017/07/27 06:28:24.476</sourceFile>
<parser>2016/11/09 21:13:02.000</parser>
<StyleCop.CSharp.DocumentationRules>2016/11/09 21:13:02.000</StyleCop.CSharp.DocumentationRules>
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-277821146</StyleCop.CSharp.DocumentationRules.FilesHashCode>
Expand Down
57 changes: 50 additions & 7 deletions src/AzureADConnectSyncDocumenter/SyncRuleDocumenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ internal class SyncRuleDocumenter : ConnectorDocumenter
private const string LoggerContextItemSyncRuleReportType = "Sync Rule Report Type";

/// <summary>
/// The synchronize rule direction
/// The synchronization rule direction
/// </summary>
private SyncRuleDirection syncRuleDirection;

/// <summary>
/// The synchronize rule report type
/// The synchronization rule report type
/// </summary>
private SyncRuleReportType syncRuleReportType;

/// <summary>
/// Indicates if the the synchronization rule is inferred as a default sync rule can be made invisible
/// </summary>
private bool defaultSyncRuleVisibility;

/// <summary>
/// Initializes a new instance of the <see cref="SyncRuleDocumenter" /> class.
/// </summary>
Expand All @@ -71,8 +76,9 @@ public SyncRuleDocumenter(XElement pilotXml, XElement productionXml, string sync
{
this.SyncRuleName = syncRuleName;
this.SyncRuleGuid = syncRuleGuid;
this.ReportFileName = Documenter.GetTempFilePath(this.ConnectorName + "_" + this.SyncRuleName + "_" + this.SyncRuleGuid + ".tmp.html");
this.ReportToCFileName = Documenter.GetTempFilePath(this.ConnectorName + "_" + this.SyncRuleName + "_" + this.SyncRuleGuid + ".TOC.tmp.html");
this.defaultSyncRuleVisibility = false;
this.ReportFileName = Documenter.GetTempFilePath(this.SyncRuleGuid + ".tmp.html");
this.ReportToCFileName = Documenter.GetTempFilePath(this.SyncRuleGuid + ".TOC.tmp.html");

// Set Logger call context items
Logger.SetContextItem(SyncRuleDocumenter.LoggerContextItemSyncRuleName, this.SyncRuleName);
Expand Down Expand Up @@ -212,9 +218,10 @@ public Tuple<string, string> GetReport(SyncRuleReportType reportType)
}
}

this.WriteSyncRuleReportHeader();

try
{
this.WriteSyncRuleReportHeader();
this.PrintConnectorSyncRuleDescription();
this.PrintConnectorSyncRuleScopingFilter();
this.PrintConnectorSyncRuleJoinRules();
Expand All @@ -229,6 +236,12 @@ public Tuple<string, string> GetReport(SyncRuleReportType reportType)
}
finally
{
if (!this.defaultSyncRuleVisibility)
{
this.ReportWriter.WriteEndTag("div");
this.ReportToCWriter.WriteEndTag("div");
}

this.ResetDiffgram(); // reset the diffgram variables
}

Expand Down Expand Up @@ -259,13 +272,23 @@ private void WriteSyncRuleReportHeader()
if (this.syncRuleReportType != SyncRuleReportType.AllSections)
{
bookmark += this.syncRuleReportType.ToString();
this.ReportFileName = Documenter.GetTempFilePath(this.syncRuleReportType + "." + this.ConnectorName + "_" + this.SyncRuleName + "_" + this.SyncRuleGuid + ".tmp.html");
this.ReportToCFileName = Documenter.GetTempFilePath(this.syncRuleReportType + "." + this.ConnectorName + "_" + this.SyncRuleName + "_" + this.SyncRuleGuid + ".TOC.tmp.html");
this.ReportFileName = Documenter.GetTempFilePath(this.SyncRuleGuid + ".tmp.html");
this.ReportToCFileName = Documenter.GetTempFilePath(this.SyncRuleGuid + ".TOC.tmp.html");
}

this.ReportWriter = new XhtmlTextWriter(new StreamWriter(this.ReportFileName));
this.ReportToCWriter = new XhtmlTextWriter(new StreamWriter(this.ReportToCFileName));

if (!this.defaultSyncRuleVisibility)
{
this.ReportWriter.WriteBeginTag("div");
this.ReportWriter.WriteAttribute("class", "DefaultRuleCanHide");
this.ReportWriter.Write(HtmlTextWriter.TagRightChar);
this.ReportToCWriter.WriteBeginTag("div");
this.ReportToCWriter.WriteAttribute("class", "DefaultRuleCanHide");
this.ReportToCWriter.Write(HtmlTextWriter.TagRightChar);
}

this.WriteSectionHeader(this.SyncRuleName, 5, bookmark, this.SyncRuleGuid);
}
finally
Expand Down Expand Up @@ -366,6 +389,21 @@ private void FillConnectorSyncRuleDescriptionDataSet(bool pilotConfig)
var table = dataSet.Tables[0];

this.syncRuleDirection = (SyncRuleDirection)Enum.Parse(typeof(SyncRuleDirection), (string)syncRule.Element("direction"), true);
var defaultSyncRule = ((string)syncRule.Element("immutable-tag") ?? string.Empty).StartsWith("Microsoft.", StringComparison.OrdinalIgnoreCase);

// Only turn the visibility on and never off.
if (this.defaultSyncRuleVisibility == false)
{
this.defaultSyncRuleVisibility = !defaultSyncRule;
}

// Any disabled rule will also be always visible.
// Ideally we should have any unsupported customisation to default sync rule always visible
// as well but for now depend on the PowerShell script to flag that
if (((string)syncRule.Element("disabled") ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase))
{
this.defaultSyncRuleVisibility = true;
}

var setting = (string)syncRule.Element("name");
Documenter.AddRow(table, new object[] { 0, "Name", setting });
Expand Down Expand Up @@ -417,6 +455,11 @@ private void FillConnectorSyncRuleDescriptionDataSet(bool pilotConfig)

table.AcceptChanges();
}
else
{
// The missing rule in either of the environments will make the rule always visible
this.defaultSyncRuleVisibility = true;
}
}
}
finally
Expand Down
23 changes: 17 additions & 6 deletions src/AzureADConnectSyncDocumenterCmd/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@ public class Program
/// <param name="args">The command-line arguments.</param>
public static void Main(string[] args)
{
if (args == null || args.Length < 2)
try
{
string errorMsg = string.Format(CultureInfo.CurrentUICulture, "Usage: {0} {1} {2}.", new object[] { Assembly.GetExecutingAssembly().GetName().Name, "{Pilot / Target Config Folder}", "{Production / Reference / Baseline Config Folder}" });
throw new ArgumentException(errorMsg, "args");
}
if (args == null || args.Length < 2)
{
string errorMsg = string.Format(CultureInfo.CurrentUICulture, "Missing commnad-line arguments. Usage: {0} {1} {2}.", new object[] { Assembly.GetExecutingAssembly().GetName().Name, "{Pilot / Target Config Folder}", "{Production / Reference / Baseline Config Folder}" });
Console.Error.WriteLine(errorMsg);
Console.ReadKey();
return;
}

var documenter = new AzureADConnectSyncDocumenter(args[0], args[1]);
documenter.GenerateReport();
var documenter = new AzureADConnectSyncDocumenter(args[0], args[1]);
documenter.GenerateReport();
}
catch (Exception e)
{
Console.Error.WriteLine(e.ToString());
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
}
4 changes: 2 additions & 2 deletions src/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class VersionInfo
/// Build Number (MMDD)
/// Revision (if any on the same day)
/// </summary>
internal const string Version = "1.17.0703.0";
internal const string Version = "1.17.0802.0";

/// <summary>
/// File Version information for the assembly consists of the following four values:
Expand All @@ -31,6 +31,6 @@ internal static class VersionInfo
/// Build Number (MMDD)
/// Revision (if any on the same day)
/// </summary>
internal const string FileVersion = "1.17.0703.0";
internal const string FileVersion = "1.17.0802.0";
}
}

0 comments on commit 6773030

Please sign in to comment.