private XmlDbUpdateRecordedAction CorrectFormUniqueId(XmlDbUpdateRecordedAction action)
        {
            var uniqueIdFieldName = XmlDbUpdateQpActionHelpers.GetFieldName(vm => vm.Data.UniqueId);

            CorrectUniqueIdFormValues(action.Form, uniqueIdFieldName);
            return(action);
        }
Ejemplo n.º 2
0
        private XmlDbUpdateRecordedAction CorrectActionIds(XmlDbUpdateRecordedAction action, bool useGuidSubstitution)
        {
            // Guid substitution step-by-step:
            // 1. UniqueId Form Correction
            // 2. UniqueId Attribute Correction
            // 3. Result Guid -> Id Substitution
            // 4. Main Guids -> Ids Substitution
            // 5. Main Ids Correction
            // 6. Parent Id Correction

            if (XmlDbUpdateQpActionHelpers.IsArticleAndHasUniqueId(action.Code))
            {
                action = CorrectEntryUniqueIdsValue(action);
                if (useGuidSubstitution)
                {
                    action = SubstituteArticleIdsFromGuids(action);
                }
                else if (XmlDbUpdateQpActionHelpers.IsNewArticle(action.Code))
                {
                    action.UniqueId = new[] { Guid.NewGuid() };
                    var uniqueIdFieldName = XmlDbUpdateQpActionHelpers.GetFieldName(
                        _modelExpressionProvider, vm => vm.Data.UniqueId
                        );
                    action.Form[uniqueIdFieldName] = action.UniqueId.Single().ToString();
                }
            }

            var entityTypeCode = action.BackendAction.EntityType.Code == EntityTypeCode.ArchiveArticle
                ? EntityTypeCode.Article
                : action.BackendAction.EntityType.Code;

            entityTypeCode = action.BackendAction.EntityType.Code == EntityTypeCode.VirtualContent
                ? EntityTypeCode.Content
                : entityTypeCode;

            action.Ids = CorrectIdsValue(entityTypeCode, action.Ids).ToArray();
            if (!string.IsNullOrEmpty(action.BackendAction.EntityType.ParentCode))
            {
                action.ParentId = CorrectIdValue(action.BackendAction.EntityType.ParentCode, action.ParentId);
            }

            return(action);
        }