private XmlDbUpdateRecordedAction CorrectFormUniqueId(XmlDbUpdateRecordedAction action) { var uniqueIdFieldName = XmlDbUpdateQpActionHelpers.GetFieldName(vm => vm.Data.UniqueId); CorrectUniqueIdFormValues(action.Form, uniqueIdFieldName); return(action); }
private XmlDbUpdateRecordedAction CorrectEntryUniqueIdsValue(XmlDbUpdateRecordedAction action) { if (XmlDbUpdateQpActionHelpers.IsArticleAndStoreUniqueIdInForm(action.Code)) { action = CorrectFormUniqueId(action); } action.UniqueId = action.UniqueId.Select(g => CorrectUniqueIdValue(EntityTypeCode.Article, g)).ToArray(); return(action); }
private void AddResultIds(XmlDbUpdateRecordedAction action, HttpContextBase httpContext) { if (XmlDbUpdateQpActionHelpers.IsActionHasResultId(action.Code)) { var entityTypeCode = action.BackendAction.EntityType.Code != EntityTypeCode.VirtualContent ? action.BackendAction.EntityType.Code : EntityTypeCode.Content; var resultId = action.ResultId != default(int) ? action.ResultId : int.Parse(action.Ids.First()); AddIdToReplace(entityTypeCode, resultId, httpContext, HttpContextItems.ResultId); var resultUniqueId = action.ResultUniqueId != Guid.Empty ? action.ResultUniqueId : action.UniqueId.First(); AddUniqueIdToReplace(entityTypeCode, resultUniqueId, httpContext, HttpContextItems.ResultGuid); } }
private XmlDbUpdateRecordedAction SubstituteArticleIdsFromGuids(XmlDbUpdateRecordedAction action) { Ensure.Equal(action.UniqueId.Length, action.Ids.Length, "Amount of uniqueIds and ids should be equal"); if (XmlDbUpdateQpActionHelpers.IsActionHasResultId(action.Code)) { action.ResultId = GetArticleResultIdByGuidOrDefault(action); } if (!XmlDbUpdateQpActionHelpers.IsNewArticle(action.Code)) { action.Ids = _dbActionService.GetArticleIdsByGuids(action.UniqueId) .Select(g => g.ToString()) .ToArray(); } return(action); }
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); }