Ejemplo n.º 1
0
        public void fillTheDictsTestOfDictsLength()
        {
            GameObject go = new GameObject();

            TextComparison tc = go.AddComponent <TextComparison>();

            string[] data  = { "Hello lille dog", "yow almighty cat" };
            var      dicts = tc.fillTheDictionaries(ref data);

            Assert.AreEqual(2, dicts.Length, "Dict has unexpected length");
            Assert.AreEqual(3, dicts[0].Count, "first dict has unexpected length");
            Assert.AreEqual(3, dicts[1].Count, "first dict has unexpected length");
        }
Ejemplo n.º 2
0
        public void calcDictSizeTest()
        {
            GameObject go = new GameObject();

            TextComparison           tc   = go.AddComponent <TextComparison>();
            Dictionary <string, int> dict = new Dictionary <string, int>();

            dict.Add("hello", 3);
            dict.Add("world", 4);
            float size = tc.calcDictSize(ref dict);

            Assert.AreEqual(5.0f, size);
        }
Ejemplo n.º 3
0
        public void calcDotProductTest()
        {
            GameObject go = new GameObject();

            TextComparison           tc    = go.AddComponent <TextComparison>();
            Dictionary <string, int> dict1 = new Dictionary <string, int>();

            dict1.Add("hello", 3);
            dict1.Add("world", 4);
            Dictionary <string, int> dict2 = new Dictionary <string, int>();

            dict2.Add("hello", 3);
            dict2.Add("nord", 4);
            Dictionary <string, int>[] dicts = { dict1, dict2 };
            float cos = tc.calcDotProduct(ref dicts);

            Assert.AreEqual(9.0f / 25.0f, cos);
        }
Ejemplo n.º 4
0
        public void calcDotNuminatorTest()
        {
            GameObject go = new GameObject();

            TextComparison           tc    = go.AddComponent <TextComparison>();
            Dictionary <string, int> dict1 = new Dictionary <string, int>();

            dict1.Add("hello", 3);
            dict1.Add("world", 4);
            Dictionary <string, int> dict2 = new Dictionary <string, int>();

            dict2.Add("hello", 1);
            dict2.Add("nord", 4);
            Dictionary <string, int>[] dicts = { dict1, dict2 };
            float numinator = tc.calcDotNuminator(ref dicts);

            Assert.AreEqual(3, numinator);
        }
Ejemplo n.º 5
0
        private static bool SatisfiesComparison(string actual, string reference, TextComparison comparison)
        {
            switch (comparison)
            {
            case TextComparison.Equal:
                return(actual == reference);

            case TextComparison.NotEqual:
                return(actual != reference);

            case TextComparison.Contains:
                return(actual.Contains(reference));

            case TextComparison.StartsWith:
                return(actual.StartsWith(reference));

            case TextComparison.EndsWith:
                return(actual.EndsWith(reference));
            }

            throw new ArgumentOutOfRangeException();
        }
Ejemplo n.º 6
0
    /// <summary>
    /// Compare DataSets.
    /// </summary>
    /// <param name="ds">Original DataSet</param>
    /// <param name="compareDs">DataSet to compare</param>
    private void CompareDataSets(DataSet ds, DataSet compareDs)
    {
        Table = new Table();
        SetTable(Table);
        Table.CssClass += " NoSideBorders";

        // Ensure same tables in DataSets
        EnsureSameTables(ds, compareDs);
        EnsureSameTables(compareDs, ds);

        // Prepare list of tables
        SortedDictionary <string, string> tables = new SortedDictionary <string, string>();

        foreach (DataTable dt in ds.Tables)
        {
            string excludedTableNames = (ExcludedTableNames != null) ? ";" + ExcludedTableNames.Trim(';').ToLowerCSafe() + ";" : "";
            string tableName          = dt.TableName;
            if (!DataHelper.DataSourceIsEmpty(ds.Tables[tableName]) || !DataHelper.DataSourceIsEmpty(CompareDataSet.Tables[tableName]))
            {
                if (!excludedTableNames.Contains(";" + tableName.ToLowerCSafe() + ";"))
                {
                    tables.Add(GetString("ObjectType." + tableName), tableName);
                }
            }
        }

        // Generate the tables
        foreach (string tableName in tables.Values)
        {
            DataTable dt        = ds.Tables[tableName].Copy();
            DataTable dtCompare = CompareDataSet.Tables[tableName].Copy();

            if (dt.PrimaryKey.Length <= 0)
            {
                continue;
            }

            // Add table heading
            if ((tables.Count > 1) || (ds.Tables.Count > 1))
            {
                AddTableHeaderRow(Table, GetTableHeaderText(dt), ((Table.Rows.Count > 0) ? "TableSeparator " : "") + "NoSideBorders");
            }

            while (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0)
            {
                // Add table header row
                TableCell labelCell = new TableHeaderCell();
                labelCell.Text = GetString("General.FieldName");
                TableCell valueCell = new TableHeaderCell();
                valueCell.Text = GetString("General.Value");
                TableCell valueCompare = new TableHeaderCell();
                valueCompare.Text = GetString("General.Value");

                AddRow(Table, labelCell, valueCell, valueCompare, "UniGridHead", false);

                DataRow srcDr = null;
                DataRow dstDr = null;

                if ((tables.Count == 1) && (dt.Rows.Count == 1) && (dtCompare.Rows.Count == 1))
                {
                    srcDr = dt.Rows[0];
                    dstDr = dtCompare.Rows[0];
                }
                else
                {
                    if (!DataHelper.DataSourceIsEmpty(dt))
                    {
                        srcDr = dt.Rows[0];
                        dstDr = dtCompare.Rows.Find(GetPrimaryColumnsValue(dt, srcDr));
                    }
                    else
                    {
                        dstDr = dtCompare.Rows[0];
                        srcDr = dt.Rows.Find(GetPrimaryColumnsValue(dtCompare, dstDr));
                    }

                    // If match not find, try to find in guid column
                    if ((srcDr == null) || (dstDr == null))
                    {
                        DataTable dtToSearch = null;
                        DataRow   drTocheck  = null;

                        if (srcDr == null)
                        {
                            dtToSearch = dt;
                            drTocheck  = dstDr;
                        }
                        else
                        {
                            dtToSearch = dtCompare;
                            drTocheck  = srcDr;
                        }


                        GeneralizedInfo infoObj = CMSObjectHelper.GetObject(drTocheck, dt.TableName.Replace("_", "."));
                        if ((infoObj != null) && ((infoObj.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN) || (infoObj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)))
                        {
                            DataRow[] rows = dtToSearch.Select(infoObj.CodeNameColumn + "='" + drTocheck[infoObj.CodeNameColumn] + "'");
                            if (rows.Length > 0)
                            {
                                if (srcDr == null)
                                {
                                    srcDr = rows[0];
                                }
                                else
                                {
                                    dstDr = rows[0];
                                }
                            }
                            else
                            {
                                rows = dtToSearch.Select(infoObj.GUIDColumn + "='" + drTocheck[infoObj.GUIDColumn] + "'");
                                if (rows.Length > 0)
                                {
                                    if (srcDr == null)
                                    {
                                        srcDr = rows[0];
                                    }
                                    else
                                    {
                                        dstDr = rows[0];
                                    }
                                }
                            }
                        }
                    }
                }

                // Add values
                bool even = false;
                foreach (DataColumn dc in dt.Columns)
                {
                    // Get content values
                    string fieldContent        = GetRowColumnContent(srcDr, dc, true);
                    string fieldCompareContent = GetRowColumnContent(dstDr, dc, true);

                    if (ShowAllFields || !String.IsNullOrEmpty(fieldContent) || !String.IsNullOrEmpty(fieldCompareContent))
                    {
                        // Initialize comparators
                        TextComparison comparefirst = new TextComparison();
                        comparefirst.SynchronizedScrolling = false;
                        comparefirst.ComparisonMode        = TextComparisonModeEnum.PlainTextWithoutFormating;
                        comparefirst.EnsureHTMLLineEndings = true;

                        TextComparison comparesecond = new TextComparison();
                        comparesecond.SynchronizedScrolling = false;
                        comparesecond.RenderingMode         = TextComparisonTypeEnum.DestinationText;
                        comparesecond.EnsureHTMLLineEndings = true;

                        comparefirst.PairedControl = comparesecond;

                        // Set comparator content
                        comparefirst.SourceText      = fieldContent;
                        comparefirst.DestinationText = fieldCompareContent;

                        // Create set of cells
                        labelCell      = new TableCell();
                        labelCell.Text = "<strong>" + dc.ColumnName + "</strong>";
                        valueCell      = new TableCell();
                        valueCell.Controls.Add(comparefirst);
                        valueCompare = new TableCell();
                        valueCompare.Controls.Add(comparesecond);

                        // Add comparison row
                        AddRow(Table, labelCell, valueCell, valueCompare, null, even);
                        even = !even;
                    }
                }

                // Remove rows from tables
                if (srcDr != null)
                {
                    dt.Rows.Remove(srcDr);
                }
                if (dstDr != null)
                {
                    dtCompare.Rows.Remove(dstDr);
                }

                if (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0)
                {
                    TableCell emptyCell = new TableCell();
                    emptyCell.Text = "&nbsp;";
                    AddRow(Table, emptyCell, null, null, "TableSeparator", false);
                    even = false;
                }
            }
        }
        plcContent.Controls.Add(Table);
    }
    /// <summary>
    /// Compare DataSets.
    /// </summary>
    /// <param name="ds">Original DataSet</param>
    /// <param name="compareDs">DataSet to compare</param>
    private void CompareDataSets(DataSet ds, DataSet compareDs)
    {
        Table = new Table();
        SetTable(Table);
        Table.CssClass += " NoSideBorders";

        // Ensure same tables in DataSets
        EnsureSameTables(ds, compareDs);
        EnsureSameTables(compareDs, ds);

        // Prepare list of tables
        SortedDictionary<string, string> tables = new SortedDictionary<string, string>();
        foreach (DataTable dt in ds.Tables)
        {
            string excludedTableNames = (ExcludedTableNames != null) ? ";" + ExcludedTableNames.Trim(';').ToLowerCSafe() + ";" : "";
            string tableName = dt.TableName;
            if (!DataHelper.DataSourceIsEmpty(ds.Tables[tableName]) || !DataHelper.DataSourceIsEmpty(CompareDataSet.Tables[tableName]))
            {
                if (!excludedTableNames.Contains(";" + tableName.ToLowerCSafe() + ";"))
                {
                    tables.Add(GetString("ObjectType." + tableName), tableName);
                }
            }
        }

        // Generate the tables
        foreach (string tableName in tables.Values)
        {
            DataTable dt = ds.Tables[tableName].Copy();
            DataTable dtCompare = CompareDataSet.Tables[tableName].Copy();

            if (dt.PrimaryKey.Length <= 0)
            {
                continue;
            }

            // Add table heading
            if ((tables.Count > 1) || (ds.Tables.Count > 1))
            {
                AddTableHeaderRow(Table, GetTableHeaderText(dt), ((Table.Rows.Count > 0) ? "TableSeparator " : "") + "NoSideBorders");
            }

            while (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0)
            {
                // Add table header row
                TableCell labelCell = new TableHeaderCell();
                labelCell.Text = GetString("General.FieldName");
                TableCell valueCell = new TableHeaderCell();
                valueCell.Text = GetString("General.Value");
                TableCell valueCompare = new TableHeaderCell();
                valueCompare.Text = GetString("General.Value");

                AddRow(Table, labelCell, valueCell, valueCompare, "UniGridHead", false);

                DataRow srcDr = null;
                DataRow dstDr = null;

                if ((tables.Count == 1) && (dt.Rows.Count == 1) && (dtCompare.Rows.Count == 1))
                {
                    srcDr = dt.Rows[0];
                    dstDr = dtCompare.Rows[0];
                }
                else
                {
                    if (!DataHelper.DataSourceIsEmpty(dt))
                    {
                        srcDr = dt.Rows[0];
                        dstDr = dtCompare.Rows.Find(GetPrimaryColumnsValue(dt, srcDr));
                    }
                    else
                    {
                        dstDr = dtCompare.Rows[0];
                        srcDr = dt.Rows.Find(GetPrimaryColumnsValue(dtCompare, dstDr));
                    }

                    // If match not find, try to find in guid column
                    if ((srcDr == null) || (dstDr == null))
                    {
                        DataTable dtToSearch = null;
                        DataRow drTocheck = null;

                        if (srcDr == null)
                        {
                            dtToSearch = dt;
                            drTocheck = dstDr;
                        }
                        else
                        {
                            dtToSearch = dtCompare;
                            drTocheck = srcDr;
                        }

                        GeneralizedInfo infoObj = CMSObjectHelper.GetObject(drTocheck, dt.TableName.Replace("_", "."));
                        if ((infoObj != null) && ((infoObj.CodeNameColumn != TypeInfo.COLUMN_NAME_UNKNOWN) || (infoObj.GUIDColumn != TypeInfo.COLUMN_NAME_UNKNOWN)))
                        {
                            DataRow[] rows = dtToSearch.Select(infoObj.CodeNameColumn + "='" + drTocheck[infoObj.CodeNameColumn] + "'");
                            if (rows.Length > 0)
                            {
                                if (srcDr == null)
                                {
                                    srcDr = rows[0];
                                }
                                else
                                {
                                    dstDr = rows[0];
                                }
                            }
                            else
                            {
                                rows = dtToSearch.Select(infoObj.GUIDColumn + "='" + drTocheck[infoObj.GUIDColumn] + "'");
                                if (rows.Length > 0)
                                {
                                    if (srcDr == null)
                                    {
                                        srcDr = rows[0];
                                    }
                                    else
                                    {
                                        dstDr = rows[0];
                                    }
                                }
                            }
                        }
                    }
                }

                // Add values
                bool even = false;
                foreach (DataColumn dc in dt.Columns)
                {
                    // Get content values
                    string fieldContent = GetRowColumnContent(srcDr, dc, true);
                    string fieldCompareContent = GetRowColumnContent(dstDr, dc, true);

                    if (ShowAllFields || !String.IsNullOrEmpty(fieldContent) || !String.IsNullOrEmpty(fieldCompareContent))
                    {
                        // Initialize comparators
                        TextComparison comparefirst = new TextComparison();
                        comparefirst.SynchronizedScrolling = false;
                        comparefirst.ComparisonMode = TextComparisonModeEnum.PlainTextWithoutFormating;
                        comparefirst.EnsureHTMLLineEndings = true;

                        TextComparison comparesecond = new TextComparison();
                        comparesecond.SynchronizedScrolling = false;
                        comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;
                        comparesecond.EnsureHTMLLineEndings = true;

                        comparefirst.PairedControl = comparesecond;

                        // Set comparator content
                        comparefirst.SourceText = fieldContent;
                        comparefirst.DestinationText = fieldCompareContent;

                        // Create set of cells
                        labelCell = new TableCell();
                        labelCell.Text = "<strong>" + dc.ColumnName + "</strong>";
                        valueCell = new TableCell();
                        valueCell.Controls.Add(comparefirst);
                        valueCompare = new TableCell();
                        valueCompare.Controls.Add(comparesecond);

                        // Add comparison row
                        AddRow(Table, labelCell, valueCell, valueCompare, null, even);
                        even = !even;
                    }
                }

                // Remove rows from tables
                if (srcDr != null)
                {
                    dt.Rows.Remove(srcDr);
                }
                if (dstDr != null)
                {
                    dtCompare.Rows.Remove(dstDr);
                }

                if (dt.Rows.Count > 0 || dtCompare.Rows.Count > 0)
                {
                    TableCell emptyCell = new TableCell();
                    emptyCell.Text = "&nbsp;";
                    AddRow(Table, emptyCell, null, null, "TableSeparator", false);
                    even = false;
                }
            }
        }
        plcContent.Controls.Add(Table);
    }
    /// <summary>
    /// Adds the field to the form.
    /// </summary>
    /// <param name="node">Document node</param>
    /// <param name="compareNode">Document compare node</param>
    /// <param name="columnName">Column name</param>
    private void AddField(TreeNode node, TreeNode compareNode, string columnName)
    {
        FormFieldInfo ffi = null;
        if (fi != null)
        {
            ffi = fi.GetFormField(columnName);
        }

        TableCell valueCell = new TableCell();
        valueCell.EnableViewState = false;
        TableCell valueCompare = new TableCell();
        valueCompare.EnableViewState = false;
        TableCell labelCell = new TableCell();
        labelCell.EnableViewState = false;
        TextComparison comparefirst;
        TextComparison comparesecond;
        bool loadValue = true;
        bool empty = true;
        bool allowLabel = true;

        // Get the caption
        if ((columnName == UNSORTED) || (ffi != null))
        {
            AttachmentInfo aiCompare = null;

            // Compare attachments
            if ((columnName == UNSORTED) || ((ffi != null) && (ffi.DataType == FieldDataType.DocAttachments)))
            {
                allowLabel = false;

                string title = String.Empty;
                if (columnName == UNSORTED)
                {
                    title = GetString("attach.unsorted") + ":";
                }
                else if (ffi != null)
                {
                    string caption = ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver);
                    title = (String.IsNullOrEmpty(caption) ? ffi.Name : caption) + ":";
                }

                // Prepare DataSource for original node
                loadValue = false;

                dsAttachments = new AttachmentsDataSource();
                dsAttachments.DocumentVersionHistoryID = versionHistoryId;
                if ((ffi != null) && (columnName != UNSORTED))
                {
                    dsAttachments.AttachmentGroupGUID = ffi.Guid;
                }
                dsAttachments.Path = node.NodeAliasPath;
                dsAttachments.CultureCode = LocalizationContext.PreferredCultureCode;
                SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID);
                dsAttachments.SiteName = si.SiteName;
                dsAttachments.OrderBy = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                dsAttachments.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                dsAttachments.IsLiveSite = false;
                dsAttachments.DataSource = null;
                dsAttachments.DataBind();

                // Get the attachments table
                attachments = GetAttachmentsTable((DataSet)dsAttachments.DataSource, versionHistoryId, node.DocumentID);

                // Prepare data source for compared node
                if (compareNode != null)
                {
                    dsAttachmentsCompare = new AttachmentsDataSource();
                    dsAttachmentsCompare.DocumentVersionHistoryID = versionCompare;
                    if ((ffi != null) && (columnName != UNSORTED))
                    {
                        dsAttachmentsCompare.AttachmentGroupGUID = ffi.Guid;
                    }
                    dsAttachmentsCompare.Path = compareNode.NodeAliasPath;
                    dsAttachmentsCompare.CultureCode = LocalizationContext.PreferredCultureCode;
                    dsAttachmentsCompare.SiteName = si.SiteName;
                    dsAttachmentsCompare.OrderBy = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                    dsAttachmentsCompare.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                    dsAttachmentsCompare.IsLiveSite = false;
                    dsAttachmentsCompare.DataSource = null;
                    dsAttachmentsCompare.DataBind();

                    // Get the table to compare
                    attachmentsCompare = GetAttachmentsTable((DataSet)dsAttachmentsCompare.DataSource, versionCompare, node.DocumentID);

                    // Switch the sides if older version is on the right
                    if (versionHistoryId > versionCompare)
                    {
                        Hashtable dummy = attachmentsCompare;
                        attachmentsCompare = attachments;
                        attachments = dummy;
                    }

                    // Add comparison
                    AddTableComparison(attachments, attachmentsCompare, "<strong>" + title + "</strong>", true, true);
                }
                else
                {
                    // Normal display
                    if (attachments.Count != 0)
                    {
                        bool first = true;

                        foreach (DictionaryEntry item in attachments)
                        {
                            string itemValue = ValidationHelper.GetString(item.Value, null);
                            if (!String.IsNullOrEmpty(itemValue))
                            {
                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                if (first)
                                {
                                    labelCell.Text = "<strong>" + String.Format(title, item.Key) + "</strong>";
                                    first = false;
                                }
                                valueCell.Text = itemValue;

                                AddRow(labelCell, valueCell);
                            }
                        }
                    }
                }
            }
            // Compare single file attachment
            else if ((ffi != null) && (ffi.DataType == FieldDataType.File))
            {
                // Get the attachment
                AttachmentInfo ai = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(node.GetValue(columnName), Guid.Empty), versionHistoryId, TreeProvider, false);

                if (compareNode != null)
                {
                    aiCompare = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(compareNode.GetValue(columnName), Guid.Empty), versionCompare, TreeProvider, false);
                }

                loadValue = false;

                // Prepare text comparison controls
                if ((ai != null) || (aiCompare != null))
                {
                    string textorig = null;
                    if (ai != null)
                    {
                        textorig = CreateAttachment(ai.Generalized.DataClass, versionHistoryId);
                    }
                    string textcompare = null;
                    if (aiCompare != null)
                    {
                        textcompare = CreateAttachment(aiCompare.Generalized.DataClass, versionCompare);
                    }

                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;
                    comparefirst.IgnoreHTMLTags = true;
                    comparefirst.ConsiderHTMLTagsEqual = true;
                    comparefirst.BalanceContent = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.IgnoreHTMLTags = true;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        comparefirst.SourceText = textorig;
                        comparefirst.DestinationText = textcompare;
                    }
                    else
                    {
                        comparefirst.SourceText = textcompare;
                        comparefirst.DestinationText = textorig;
                    }

                    comparefirst.PairedControl = comparesecond;
                    comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);

                    // Add both cells
                    if (compareNode != null)
                    {
                        AddRow(labelCell, valueCell, valueCompare);
                    }
                    // Add one cell only
                    else
                    {
                        valueCell.Controls.Clear();
                        Literal ltl = new Literal();
                        ltl.Text = textorig;
                        valueCell.Controls.Add(ltl);
                        AddRow(labelCell, valueCell);
                    }
                }
            }
        }

        if (allowLabel && String.IsNullOrEmpty(labelCell.Text))
        {
            labelCell.Text = "<strong>" + columnName + ":</strong>";
        }

        if (loadValue)
        {
            string textcompare = null;

            switch (columnName.ToLowerCSafe())
            {
                // Document content - display content of editable regions and editable web parts
                case "documentcontent":
                    EditableItems ei = new EditableItems();
                    ei.LoadContentXml(ValidationHelper.GetString(node.GetValue(columnName), String.Empty));

                    // Add text comparison control
                    if (compareNode != null)
                    {
                        EditableItems eiCompare = new EditableItems();
                        eiCompare.LoadContentXml(ValidationHelper.GetString(compareNode.GetValue(columnName), String.Empty));

                        // Create editable regions comparison
                        Hashtable hashtable;
                        Hashtable hashtableCompare;

                        // Source text must be older version
                        if (versionHistoryId < versionCompare)
                        {
                            hashtable = ei.EditableRegions;
                            hashtableCompare = eiCompare.EditableRegions;
                        }
                        else
                        {
                            hashtable = eiCompare.EditableRegions;
                            hashtableCompare = ei.EditableRegions;
                        }

                        // Add comparison
                        AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);

                        // Create editable webparts comparison
                        // Source text must be older version
                        if (versionHistoryId < versionCompare)
                        {
                            hashtable = ei.EditableWebParts;
                            hashtableCompare = eiCompare.EditableWebParts;
                        }
                        else
                        {
                            hashtable = eiCompare.EditableWebParts;
                            hashtableCompare = ei.EditableWebParts;
                        }

                        // Add comparison
                        AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);
                    }
                    // No compare node
                    else
                    {
                        // Editable regions
                        Hashtable hashtable = ei.EditableRegions;
                        if (hashtable.Count != 0)
                        {
                            foreach (DictionaryEntry region in hashtable)
                            {
                                string regionValue = ValidationHelper.GetString(region.Value, null);
                                if (!String.IsNullOrEmpty(regionValue))
                                {
                                    string regionKey = ValidationHelper.GetString(region.Key, null);

                                    valueCell = new TableCell();
                                    labelCell = new TableCell();

                                    labelCell.Text = "<strong>" + columnName + " (" + DictionaryHelper.GetFirstKey(regionKey) + "):</strong>";
                                    valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(regionValue, false));

                                    AddRow(labelCell, valueCell);
                                }
                            }
                        }

                        // Editable web parts
                        hashtable = ei.EditableWebParts;
                        if (hashtable.Count != 0)
                        {
                            foreach (DictionaryEntry part in hashtable)
                            {
                                string partValue = ValidationHelper.GetString(part.Value, null);
                                if (!String.IsNullOrEmpty(partValue))
                                {
                                    string partKey = ValidationHelper.GetString(part.Key, null);
                                    valueCell = new TableCell();
                                    labelCell = new TableCell();

                                    labelCell.Text = "<strong>" + columnName + " (" + DictionaryHelper.GetFirstKey(partKey) + "):</strong>";
                                    valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(partValue, false));

                                    AddRow(labelCell, valueCell);
                                }
                            }
                        }
                    }

                    break;

                case "documentwebparts":
                    StringBuilder sbOriginal = new StringBuilder();
                    StringBuilder sbCompared = new StringBuilder();

                    // Set original web parts
                    string originalWebParts = Convert.ToString(node.GetValue(columnName));
                    GenerateWebPartsMarkup(ref sbOriginal, originalWebParts, true);

                    // Add text comparison control
                    if (compareNode != null)
                    {
                        string compareWebParts = Convert.ToString(compareNode.GetValue(columnName));
                        GenerateWebPartsMarkup(ref sbCompared, compareWebParts, false);
                    }

                    // Set empty flag
                    empty = ((sbOriginal.Length == 0) && (sbCompared.Length == 0));

                    if (!empty)
                    {
                        valueCell.Text += sbOriginal.ToString();
                        valueCompare.Text = sbCompared.ToString();
                    }
                    break;

                // Others, display the string value
                default:
                    // Shift date time values to user time zone
                    object origobject = node.GetValue(columnName);
                    string textorig;
                    if (origobject is DateTime)
                    {
                        textorig = TimeZoneHelper.ConvertToUserTimeZone(ValidationHelper.GetDateTime(origobject, DateTimeHelper.ZERO_TIME), true, CurrentUser, SiteContext.CurrentSite);
                    }
                    else
                    {
                        textorig = ValidationHelper.GetString(origobject, String.Empty);
                    }

                    // Add text comparison control
                    if (compareNode != null)
                    {
                        // Shift date time values to user time zone
                        object compareobject = compareNode.GetValue(columnName);
                        if (compareobject is DateTime)
                        {
                            textcompare = TimeZoneHelper.ConvertToUserTimeZone(ValidationHelper.GetDateTime(compareobject, DateTimeHelper.ZERO_TIME), true, CurrentUser, SiteContext.CurrentSite);
                        }
                        else
                        {
                            textcompare = ValidationHelper.GetString(compareobject, String.Empty);
                        }

                        comparefirst = new TextComparison();
                        comparefirst.SynchronizedScrolling = false;

                        comparesecond = new TextComparison();
                        comparesecond.SynchronizedScrolling = false;
                        comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                        // Source text must be older version
                        if (versionHistoryId < versionCompare)
                        {
                            comparefirst.SourceText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                            comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                        }
                        else
                        {
                            comparefirst.SourceText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                            comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                        }

                        comparefirst.PairedControl = comparesecond;

                        if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                        {
                            comparefirst.BalanceContent = false;
                        }

                        valueCell.Controls.Add(comparefirst);
                        valueCompare.Controls.Add(comparesecond);
                    }
                    else
                    {
                        valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                    }

                    empty = (String.IsNullOrEmpty(textorig)) && (String.IsNullOrEmpty(textcompare));
                    break;
            }
        }

        if (!empty)
        {
            if (compareNode != null)
            {
                AddRow(labelCell, valueCell, valueCompare);
            }
            else
            {
                AddRow(labelCell, valueCell);
            }
        }
    }
    /// <summary>
    /// Adds the table comparison for matching objects.
    /// </summary>
    /// <param name="hashtable">Left side table</param>
    /// <param name="hashtableCompare">Right side table</param>
    /// <param name="titleFormat">Title format string</param>
    /// <param name="includeAttachments">If true, the HTML code is kept (attachment comparison)</param>
    /// <param name="renderOnlyFirstTitle">If true, only first title is rendered</param>
    protected void AddTableComparison(Hashtable hashtable, Hashtable hashtableCompare, string titleFormat, bool includeAttachments, bool renderOnlyFirstTitle)
    {
        TableCell valueCell;
        TableCell valueCompare;
        TableCell labelCell;
        TextComparison comparefirst;
        TextComparison comparesecond;

        bool firstTitle = true;

        // Go through left column regions
        if (hashtable != null)
        {
            foreach (DictionaryEntry entry in hashtable)
            {
                object value = entry.Value;
                if (value != null)
                {
                    // Initialize comparators
                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                    if (includeAttachments)
                    {
                        comparefirst.IgnoreHTMLTags = true;
                        comparefirst.ConsiderHTMLTagsEqual = true;

                        comparesecond.IgnoreHTMLTags = true;
                    }

                    comparefirst.PairedControl = comparesecond;

                    // Initialize cells
                    valueCell = new TableCell();
                    valueCompare = new TableCell();
                    labelCell = new TableCell();

                    string key = ValidationHelper.GetString(entry.Key, null);
                    string strValue = ValidationHelper.GetString(value, null);
                    if (firstTitle || !renderOnlyFirstTitle)
                    {
                        labelCell.Text = String.Format(titleFormat, DictionaryHelper.GetFirstKey(key));
                        firstTitle = false;
                    }

                    comparefirst.SourceText = includeAttachments ? strValue : HttpUtility.HtmlDecode(HTMLHelper.StripTags(strValue, false));

                    if ((hashtableCompare != null) && hashtableCompare.Contains(key))
                    {
                        // Compare to the existing other version
                        string compareKey = ValidationHelper.GetString(hashtableCompare[key], null);
                        comparefirst.DestinationText = includeAttachments ? compareKey : HttpUtility.HtmlDecode(HTMLHelper.StripTags(compareKey, false));
                        hashtableCompare.Remove(key);
                    }
                    else
                    {
                        // Compare to an empty string
                        comparefirst.DestinationText = String.Empty;
                    }

                    // Do not balance content if too short
                    if (includeAttachments)
                    {
                        comparefirst.BalanceContent = false;
                    }
                    else if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    // Create cell comparison
                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);

                    AddRow(labelCell, valueCell, valueCompare);
                }
            }
        }

        // Go through right column regions which left
        if (hashtableCompare != null)
        {
            foreach (DictionaryEntry entry in hashtableCompare)
            {
                object value = entry.Value;
                if (value != null)
                {
                    // Initialize comparators
                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                    comparefirst.PairedControl = comparesecond;

                    if (includeAttachments)
                    {
                        comparefirst.IgnoreHTMLTags = true;
                        comparefirst.ConsiderHTMLTagsEqual = true;

                        comparesecond.IgnoreHTMLTags = true;
                    }

                    // Initialize cells
                    valueCell = new TableCell();
                    valueCompare = new TableCell();
                    labelCell = new TableCell();

                    if (firstTitle || !renderOnlyFirstTitle)
                    {
                        labelCell.Text = String.Format(titleFormat, DictionaryHelper.GetFirstKey(ValidationHelper.GetString(entry.Key, null)));
                        firstTitle = false;
                    }

                    comparefirst.SourceText = String.Empty;
                    string strValue = ValidationHelper.GetString(value, null);
                    comparefirst.DestinationText = includeAttachments ? strValue : HttpUtility.HtmlDecode(HTMLHelper.StripTags(strValue, false));

                    if (includeAttachments)
                    {
                        comparefirst.BalanceContent = false;
                    }
                    else if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    // Create cell comparison
                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);

                    AddRow(labelCell, valueCell, valueCompare);
                }
            }
        }
    }
Ejemplo n.º 10
0
 public TextCriterion(string title, string propertyName, string reference, TextComparison comparison)
     : base(title, propertyName, reference)
 {
     Comparison = comparison;
 }
Ejemplo n.º 11
0
    /// <summary>
    /// Adds the table comparisson for matching objects.
    /// </summary>
    /// <param name="hashtable">Left side table</param>
    /// <param name="hashtableCompare">Right side table</param>
    /// <param name="titleFormat">Title format string</param>
    /// <param name="attachments">If true, the HTML code is kept (attachment comparison)</param>
    /// <param name="renderOnlyFirstTitle">If true, only first title is rendered</param>
    protected void AddTableComparison(Hashtable hashtable, Hashtable hashtableCompare, string titleFormat, bool attachments, bool renderOnlyFirstTitle)
    {
        TableCell      valueCell     = new TableCell();
        TableCell      valueCompare  = new TableCell();
        TableCell      labelCell     = new TableCell();
        TextComparison comparefirst  = null;
        TextComparison comparesecond = null;

        bool firstTitle = true;

        // Go through left column regions
        if (hashtable != null)
        {
            foreach (DictionaryEntry entry in hashtable)
            {
                object value = entry.Value;
                if (value != null)
                {
                    // Initialize comparators
                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode         = TextComparisonTypeEnum.DestinationText;

                    if (attachments)
                    {
                        comparefirst.IgnoreHTMLTags        = true;
                        comparefirst.ConsiderHTMLTagsEqual = true;

                        comparesecond.IgnoreHTMLTags = true;
                    }

                    comparefirst.PairedControl = comparesecond;

                    // Initialize cells
                    valueCell    = new TableCell();
                    valueCompare = new TableCell();
                    labelCell    = new TableCell();

                    string key      = ValidationHelper.GetString(entry.Key, null);
                    string strValue = ValidationHelper.GetString(value, null);
                    if (firstTitle || !renderOnlyFirstTitle)
                    {
                        labelCell.Text = String.Format(titleFormat, MultiKeyHashtable.GetFirstKey(key));
                        firstTitle     = false;
                    }

                    if (attachments)
                    {
                        comparefirst.SourceText = strValue;
                    }
                    else
                    {
                        comparefirst.SourceText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(strValue, false));
                    }

                    if ((hashtableCompare != null) && hashtableCompare.Contains(key))
                    {
                        // Compare to the existing other version
                        string compareKey = ValidationHelper.GetString(hashtableCompare[key], null);
                        if (attachments)
                        {
                            comparefirst.DestinationText = compareKey;
                        }
                        else
                        {
                            comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(compareKey, false));
                        }
                        hashtableCompare.Remove(key);
                    }
                    else
                    {
                        // Compare to an empty string
                        comparefirst.DestinationText = "";
                    }

                    // Do not balance content if too short
                    if (attachments)
                    {
                        comparefirst.BalanceContent = false;
                    }
                    else if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    // Create cell comparison
                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);

                    AddRow(labelCell, valueCell, valueCompare, false, null, even);
                    even = !even;
                }
            }
        }

        // Go through right column regions which left
        if (hashtableCompare != null)
        {
            foreach (DictionaryEntry entry in hashtableCompare)
            {
                object value = entry.Value;
                if (value != null)
                {
                    // Initialize comparators
                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode         = TextComparisonTypeEnum.DestinationText;

                    comparefirst.PairedControl = comparesecond;

                    if (attachments)
                    {
                        comparefirst.IgnoreHTMLTags        = true;
                        comparefirst.ConsiderHTMLTagsEqual = true;

                        comparesecond.IgnoreHTMLTags = true;
                    }

                    // Initialize cells
                    valueCell    = new TableCell();
                    valueCompare = new TableCell();
                    labelCell    = new TableCell();

                    if (firstTitle || !renderOnlyFirstTitle)
                    {
                        labelCell.Text = String.Format(titleFormat, MultiKeyHashtable.GetFirstKey(ValidationHelper.GetString(entry.Key, null)));
                        firstTitle     = false;
                    }

                    comparefirst.SourceText = "";
                    string strValue = ValidationHelper.GetString(value, null);
                    if (attachments)
                    {
                        comparefirst.DestinationText = strValue;
                    }
                    else
                    {
                        comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(strValue, false));
                    }

                    if (attachments)
                    {
                        comparefirst.BalanceContent = false;
                    }
                    else if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    // Create cell comparison
                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);

                    AddRow(labelCell, valueCell, valueCompare, false, null, even);
                    even = !even;
                }
            }
        }
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Adds the field to the form.
    /// </summary>
    /// <param name="node">Document node</param>
    /// <param name="compareNode">Document compare node</param>
    /// <param name="columnName">Column name</param>
    private void AddField(TreeNode node, TreeNode compareNode, string columnName)
    {
        FormFieldInfo ffi = null;

        if (fi != null)
        {
            ffi = fi.GetFormField(columnName);
        }

        TableCell valueCell = new TableCell();

        valueCell.EnableViewState = false;
        TableCell valueCompare = new TableCell();

        valueCompare.EnableViewState = false;
        TableCell labelCell = new TableCell();

        labelCell.EnableViewState = false;
        TextComparison comparefirst  = null;
        TextComparison comparesecond = null;
        bool           switchSides   = true;
        bool           loadValue     = true;
        bool           empty         = true;
        bool           allowLabel    = true;

        // Get the caption
        if ((columnName == UNSORTED) || (ffi != null))
        {
            AttachmentInfo aiCompare = null;

            // Compare attachments
            if ((columnName == UNSORTED) || (ffi.DataType == FormFieldDataTypeEnum.DocumentAttachments))
            {
                allowLabel = false;

                string title = null;
                if (columnName == UNSORTED)
                {
                    title = GetString("attach.unsorted") + ":";
                }
                else
                {
                    title = (String.IsNullOrEmpty(ffi.Caption) ? ffi.Name : ffi.Caption) + ":";
                }

                // Prepare DataSource for original node
                loadValue = false;

                dsAttachments = new AttachmentsDataSource();
                dsAttachments.DocumentVersionHistoryID = versionHistoryId;
                if (columnName != UNSORTED)
                {
                    dsAttachments.AttachmentGroupGUID = ffi.Guid;
                }
                dsAttachments.Path        = node.NodeAliasPath;
                dsAttachments.CultureCode = CMSContext.PreferredCultureCode;
                SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID);
                dsAttachments.SiteName        = si.SiteName;
                dsAttachments.OrderBy         = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                dsAttachments.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                dsAttachments.IsLiveSite      = false;
                dsAttachments.DataSource      = null;
                dsAttachments.DataBind();

                // Get the attachments table
                attachments = GetAttachmentsTable((DataSet)dsAttachments.DataSource, versionHistoryId, node.DocumentID);

                // Prepare datasource for compared node
                if (compareNode != null)
                {
                    dsAttachmentsCompare = new AttachmentsDataSource();
                    dsAttachmentsCompare.DocumentVersionHistoryID = versionCompare;
                    if (columnName != UNSORTED)
                    {
                        dsAttachmentsCompare.AttachmentGroupGUID = ffi.Guid;
                    }
                    dsAttachmentsCompare.Path            = compareNode.NodeAliasPath;
                    dsAttachmentsCompare.CultureCode     = CMSContext.PreferredCultureCode;
                    dsAttachmentsCompare.SiteName        = si.SiteName;
                    dsAttachmentsCompare.OrderBy         = "AttachmentOrder, AttachmentName, AttachmentHistoryID";
                    dsAttachmentsCompare.SelectedColumns = "AttachmentHistoryID, AttachmentGUID, AttachmentImageWidth, AttachmentImageHeight, AttachmentExtension, AttachmentName, AttachmentSize, AttachmentOrder, AttachmentTitle, AttachmentDescription";
                    dsAttachmentsCompare.IsLiveSite      = false;
                    dsAttachmentsCompare.DataSource      = null;
                    dsAttachmentsCompare.DataBind();

                    // Get the table to compare
                    attachmentsCompare = GetAttachmentsTable((DataSet)dsAttachmentsCompare.DataSource, versionCompare, node.DocumentID);

                    // Switch the sides if older version is on the right
                    if (versionHistoryId > versionCompare)
                    {
                        Hashtable dummy = attachmentsCompare;
                        attachmentsCompare = attachments;
                        attachments        = dummy;
                    }

                    // Add comparison
                    AddTableComparison(attachments, attachmentsCompare, "<strong>" + title + "</strong>", true, true);
                }
                else
                {
                    // Normal display
                    if (attachments.Count != 0)
                    {
                        bool   first     = true;
                        string itemValue = null;

                        foreach (DictionaryEntry item in attachments)
                        {
                            itemValue = ValidationHelper.GetString(item.Value, null);
                            if (!String.IsNullOrEmpty(itemValue))
                            {
                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                if (first)
                                {
                                    labelCell.Text = "<strong>" + String.Format(title, item.Key) + "</strong>";
                                    first          = false;
                                }
                                valueCell.Text = itemValue;

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }
                }
            }
            // Compare single file attachment
            else if (ffi.DataType == FormFieldDataTypeEnum.File)
            {
                // Get the attachment
                AttachmentInfo ai = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(node.GetValue(columnName), Guid.Empty), versionHistoryId, TreeProvider, false);

                if (compareNode != null)
                {
                    aiCompare = DocumentHelper.GetAttachment(ValidationHelper.GetGuid(compareNode.GetValue(columnName), Guid.Empty), versionCompare, TreeProvider, false);
                }

                loadValue = false;
                empty     = true;

                // Prepare text comparison controls
                if ((ai != null) || (aiCompare != null))
                {
                    string textorig = null;
                    if (ai != null)
                    {
                        textorig = CreateAttachment(ai.Generalized.DataClass, versionHistoryId);
                    }
                    string textcompare = null;
                    if (aiCompare != null)
                    {
                        textcompare = CreateAttachment(aiCompare.Generalized.DataClass, versionCompare);
                    }

                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;
                    comparefirst.IgnoreHTMLTags        = true;
                    comparefirst.ConsiderHTMLTagsEqual = true;
                    comparefirst.BalanceContent        = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.IgnoreHTMLTags        = true;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        comparefirst.SourceText      = textorig;
                        comparefirst.DestinationText = textcompare;
                    }
                    else
                    {
                        comparefirst.SourceText      = textcompare;
                        comparefirst.DestinationText = textorig;
                    }

                    comparefirst.PairedControl  = comparesecond;
                    comparesecond.RenderingMode = TextComparisonTypeEnum.DestinationText;

                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);
                    switchSides = false;

                    // Add both cells
                    if (compareNode != null)
                    {
                        AddRow(labelCell, valueCell, valueCompare, switchSides, null, even);
                    }
                    // Add one cell only
                    else
                    {
                        valueCell.Controls.Clear();
                        Literal ltl = new Literal();
                        ltl.Text = textorig;
                        valueCell.Controls.Add(ltl);
                        AddRow(labelCell, valueCell, null, even);
                    }
                    even = !even;
                }
            }
        }

        if (allowLabel && (labelCell.Text == ""))
        {
            labelCell.Text = "<strong>" + columnName + ":</strong>";
        }

        if (loadValue)
        {
            string textcompare = null;

            switch (columnName.ToLower())
            {
            // Document content - display content of editable regions and editable web parts
            case "documentcontent":
                EditableItems ei = new EditableItems();
                ei.LoadContentXml(ValidationHelper.GetString(node.GetValue(columnName), ""));

                // Add text comparison control
                if (compareNode != null)
                {
                    EditableItems eiCompare = new EditableItems();
                    eiCompare.LoadContentXml(ValidationHelper.GetString(compareNode.GetValue(columnName), ""));

                    // Create editable regions comparison
                    Hashtable hashtable;
                    Hashtable hashtableCompare;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        hashtable        = ei.EditableRegions;
                        hashtableCompare = eiCompare.EditableRegions;
                    }
                    else
                    {
                        hashtable        = eiCompare.EditableRegions;
                        hashtableCompare = ei.EditableRegions;
                    }

                    // Add comparison
                    AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);

                    // Create editable webparts comparison
                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        hashtable        = ei.EditableWebParts;
                        hashtableCompare = eiCompare.EditableWebParts;
                    }
                    else
                    {
                        hashtable        = eiCompare.EditableWebParts;
                        hashtableCompare = ei.EditableWebParts;
                    }

                    // Add comparison
                    AddTableComparison(hashtable, hashtableCompare, "<strong>" + columnName + " ({0}):</strong>", false, false);
                }
                // No compare node
                else
                {
                    // Editable regions
                    Hashtable hashtable = ei.EditableRegions;
                    if (hashtable.Count != 0)
                    {
                        string regionValue = null;
                        string regionKey   = null;

                        foreach (DictionaryEntry region in hashtable)
                        {
                            regionValue = ValidationHelper.GetString(region.Value, null);
                            if (!String.IsNullOrEmpty(regionValue))
                            {
                                regionKey = ValidationHelper.GetString(region.Key, null);

                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                labelCell.Text = "<strong>" + columnName + " (" + MultiKeyHashtable.GetFirstKey(regionKey) + "):</strong>";
                                valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(regionValue, false));

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }

                    // Editable web parts
                    hashtable = ei.EditableWebParts;
                    if (hashtable.Count != 0)
                    {
                        string partValue = null;
                        string partKey   = null;

                        foreach (DictionaryEntry part in hashtable)
                        {
                            partValue = ValidationHelper.GetString(part.Value, null);
                            if (!String.IsNullOrEmpty(partValue))
                            {
                                partKey   = ValidationHelper.GetString(part.Key, null);
                                valueCell = new TableCell();
                                labelCell = new TableCell();

                                labelCell.Text = "<strong>" + columnName + " (" + MultiKeyHashtable.GetFirstKey(partKey) + "):</strong>";
                                valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(partValue, false));

                                AddRow(labelCell, valueCell, null, even);
                                even = !even;
                            }
                        }
                    }
                }

                break;

            // Others, display the string value
            default:
                // Shift date time values to user time zone
                object origobject = node.GetValue(columnName);
                string textorig   = null;
                if (origobject is DateTime)
                {
                    TimeZoneInfo usedTimeZone = null;
                    textorig = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(ValidationHelper.GetDateTime(origobject, DateTimeHelper.ZERO_TIME), CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
                }
                else
                {
                    textorig = ValidationHelper.GetString(origobject, "");
                }

                // Add text comparison control
                if (compareNode != null)
                {
                    // Shift date time values to user time zone
                    object compareobject = compareNode.GetValue(columnName);
                    if (compareobject is DateTime)
                    {
                        TimeZoneInfo usedTimeZone = null;
                        textcompare = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(ValidationHelper.GetDateTime(compareobject, DateTimeHelper.ZERO_TIME), CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
                    }
                    else
                    {
                        textcompare = ValidationHelper.GetString(compareobject, "");
                    }

                    comparefirst = new TextComparison();
                    comparefirst.SynchronizedScrolling = false;

                    comparesecond = new TextComparison();
                    comparesecond.SynchronizedScrolling = false;
                    comparesecond.RenderingMode         = TextComparisonTypeEnum.DestinationText;

                    // Source text must be older version
                    if (versionHistoryId < versionCompare)
                    {
                        comparefirst.SourceText      = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                        comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                    }
                    else
                    {
                        comparefirst.SourceText      = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textcompare, false));
                        comparefirst.DestinationText = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                    }

                    comparefirst.PairedControl = comparesecond;

                    if (Math.Max(comparefirst.SourceText.Length, comparefirst.DestinationText.Length) < 100)
                    {
                        comparefirst.BalanceContent = false;
                    }

                    valueCell.Controls.Add(comparefirst);
                    valueCompare.Controls.Add(comparesecond);
                    switchSides = false;
                }
                else
                {
                    valueCell.Text = HttpUtility.HtmlDecode(HTMLHelper.StripTags(textorig, false));
                }

                empty = (String.IsNullOrEmpty(textorig)) && (String.IsNullOrEmpty(textcompare));
                break;
            }
        }

        if (!empty)
        {
            if (compareNode != null)
            {
                AddRow(labelCell, valueCell, valueCompare, switchSides, null, even);
                even = !even;
            }
            else
            {
                AddRow(labelCell, valueCell, null, even);
                even = !even;
            }
        }
    }