private XmlDbUpdateRecordedAction CorrectFormUniqueId(XmlDbUpdateRecordedAction action) { var uniqueIdFieldName = XmlDbUpdateQpActionHelpers.GetFieldName(vm => vm.Data.UniqueId); CorrectUniqueIdFormValues(action.Form, uniqueIdFieldName); return(action); }
private void CorrectVirtualContentForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataJoinRootId); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataUnionSourceContentIds); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.JoinFields, true, true); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.ItemValue, true, true); }
public XmlDbUpdateRecordedAction PreActionCorrections(XmlDbUpdateRecordedAction action, bool useGuidSubstitution) { action = CorrectActionIds(action, useGuidSubstitution); switch (action.BackendAction.EntityType.Code) { case EntityTypeCode.Content: CorrectContentForm(action); break; case EntityTypeCode.VirtualContent: CorrectVirtualContentForm(action); break; case EntityTypeCode.Field: CorrectFieldForm(action, useGuidSubstitution); break; case EntityTypeCode.Article: CorrectArticleForm(action, useGuidSubstitution); break; case EntityTypeCode.User: CorrectUserForm(action, useGuidSubstitution); break; case EntityTypeCode.UserGroup: CorrectUserGroupForm(action); break; case EntityTypeCode.Site: CorrectSiteForm(action); break; case EntityTypeCode.CustomAction: CorrectCustomActionForm(action); break; case EntityTypeCode.VisualEditorPlugin: CorrectVePluginForm(action); break; case EntityTypeCode.Workflow: CorrectWorkflowForm(action); break; case EntityTypeCode.PageObject: CorrectObjectForm(action, true); break; case EntityTypeCode.TemplateObject: CorrectObjectForm(action, false); break; case EntityTypeCode.Notification: CorrectNotificationForm(action); break; } return(action); }
public XmlDbUpdateRecordedAction PostActionCorrections(XmlDbUpdateRecordedAction action, HttpContextBase httpContext) { AddResultIds(action, httpContext); switch (action.BackendAction.Code) { case ActionCode.AddNewVirtualContents: case ActionCode.VirtualContentProperties: case ActionCode.VirtualFieldProperties: AddIdsToReplace(action.VirtualFieldIds, httpContext, HttpContextItems.NewVirtualFieldIds); break; case ActionCode.AddNewContent: case ActionCode.CreateLikeContent: AddIdsToReplace(action.ChildIds, httpContext, HttpContextItems.FieldIds); AddIdsToReplace(action.ChildLinkIds, httpContext, HttpContextItems.LinkIds); break; case ActionCode.AddNewField: case ActionCode.FieldProperties: case ActionCode.CreateLikeField: AddIdToReplace(EntityTypeCode.ContentLink, action.ChildId, httpContext, HttpContextItems.NewLinkId); AddIdToReplace(EntityTypeCode.Field, action.BackwardId, httpContext, HttpContextItems.NewBackwardId); AddIdsToReplace(action.VirtualFieldIds, httpContext, HttpContextItems.NewVirtualFieldIds); AddIdsToReplace(action.ChildIds, httpContext, HttpContextItems.NewChildFieldIds); AddIdsToReplace(action.ChildLinkIds, httpContext, HttpContextItems.NewChildLinkIds); break; case ActionCode.AddNewCustomAction: AddIdToReplace(EntityTypeCode.BackendAction, action.ChildId, httpContext, HttpContextItems.ActionId); break; case ActionCode.AddNewVisualEditorPlugin: case ActionCode.VisualEditorPluginProperties: AddIdsToReplace(action.ChildIds, httpContext, HttpContextItems.NewCommandIds); break; case ActionCode.AddNewWorkflow: case ActionCode.WorkflowProperties: AddIdsToReplace(action.ChildIds, httpContext, HttpContextItems.NewRulesIds); break; case ActionCode.AddNewNotification: case ActionCode.NotificationProperties: AddIdToReplace(EntityTypeCode.TemplateObjectFormat, action.ChildId, httpContext, HttpContextItems.NotificationFormatId); break; case ActionCode.AddNewPageObject: AddIdToReplace(EntityTypeCode.PageObjectFormat, action.ChildId, httpContext, HttpContextItems.DefaultFormatId); break; case ActionCode.AddNewTemplateObject: AddIdToReplace(EntityTypeCode.TemplateObjectFormat, action.ChildId, httpContext, HttpContextItems.DefaultFormatId); break; } return(action); }
private void CorrectNotificationForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.TemplateObjectFormat, action.Form, HttpContextFormConstants.DataFormatId); CorrectFormValue(EntityTypeCode.User, action.Form, HttpContextFormConstants.DataUserId); CorrectFormValue(EntityTypeCode.UserGroup, action.Form, HttpContextFormConstants.DataGroupId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataEmailFieldId); CorrectFormValue(EntityTypeCode.User, action.Form, HttpContextFormConstants.DataFromBackenduserId); CorrectFormValue(EntityTypeCode.StatusType, action.Form, HttpContextFormConstants.DataNotifyOnStatusTypeId); }
private void CorrectObjectForm(XmlDbUpdateRecordedAction action, bool isPageObject) { CorrectFormValue(EntityTypeCode.TemplateObject, action.Form, HttpContextFormConstants.DataParentObjectId); CorrectFormValue(isPageObject ? EntityTypeCode.PageObjectFormat : EntityTypeCode.TemplateObjectFormat, action.Form, HttpContextFormConstants.DataDefaultFormatId); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataContainerContentId); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataContentFormContentId); CorrectFormValue(EntityTypeCode.Page, action.Form, HttpContextFormConstants.DataContentFormThankYouPageId); CorrectFormValue(EntityTypeCode.StatusType, action.Form, HttpContextFormConstants.ActiveStatusTypeIds, true); }
private void CorrectUserForm(XmlDbUpdateRecordedAction action, bool useGuidSubstitution) { CorrectFormValue(EntityTypeCode.UserGroup, action.Form, HttpContextFormConstants.SelectedGroups, true); CorrectFormValue(EntityTypeCode.Site, action.Form, HttpContextFormConstants.ContentDefaultFilterSiteId); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.ContentDefaultFilterContentId); CorrectAndSubstituteArticleIdFormValues(action.Form, HttpContextFormConstants.ContentDefaultFilterArticleIds, HttpContextFormConstants.ContentDefaultFilterArticleUniqueIds, useGuidSubstitution); CorrectFormValue(EntityTypeCode.Article, action.Form, HttpContextFormConstants.ContentDefaultFilterArticleIds); }
private void CorrectWorkflowForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.StatusType, action.Form, HttpContextFormConstants.ActiveStatuses, true); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.ActiveContentIds, true); CorrectFormValue(EntityTypeCode.WorkflowRule, action.Form, HttpContextFormConstants.WorkflowsWorkflowRulesDisplay, "Id"); CorrectFormValue(EntityTypeCode.StatusType, action.Form, HttpContextFormConstants.WorkflowsWorkflowRulesDisplay, "StId"); CorrectFormValue(EntityTypeCode.User, action.Form, HttpContextFormConstants.WorkflowsWorkflowRulesDisplay, "UserId"); CorrectFormValue(EntityTypeCode.UserGroup, action.Form, HttpContextFormConstants.WorkflowsWorkflowRulesDisplay, "GroupId"); }
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); }
internal static HttpContext BuildHttpContext(XmlDbUpdateRecordedAction action, string backendUrl, int userId, bool useGuidSubstitution) { var httpContext = new DefaultHttpContext(); FillHttpRequest(httpContext.Request, action); httpContext.User = GetPrincipal(userId); var guid = useGuidSubstitution ? action.ResultUniqueId : (Guid?)null; AddGlobalHttpContextVariables(httpContext, backendUrl, guid); return(httpContext); }
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); } }
internal static RouteData GetRouteData(XmlDbUpdateRecordedAction action, string controllerName, string controllerAction) { var data = new RouteData(); data.Values[HttpRouteData.Id] = int.Parse(action.Ids.First()); data.Values[HttpRouteData.Ids] = action.Ids.Select(int.Parse).ToArray(); data.Values[HttpRouteData.TabId] = "tab_virtual"; data.Values[HttpRouteData.Action] = controllerAction; data.Values[HttpRouteData.ParentId] = action.ParentId; data.Values[HttpRouteData.Controller] = controllerName; return(data); }
public HttpContextBase PostAction(XmlDbUpdateRecordedAction recordedAction, string backendUrl, int userId, bool useGuidSubstitution) { Ensure.NotNull(QPConnectionScope.Current.DbConnection, "QPConnection scope should be initialized to use fake mvc context"); var urlParts = recordedAction.BackendAction.ControllerActionUrl.Split(@"/".ToCharArray()).Where(n => !string.IsNullOrEmpty(n) && n != "~").ToArray(); var controllerName = urlParts[0]; var controllerAction = urlParts[1]; var requestContext = new RequestContext( XmlDbUpdateHttpContextHelpers.BuildHttpContextBase(recordedAction, backendUrl, userId, useGuidSubstitution), XmlDbUpdateHttpContextHelpers.GetRouteData(recordedAction, controllerName, controllerAction) ); BackendActionContext.ResetCurrent(); XmlDbUpdateHttpContextHelpers.BuildController(requestContext, controllerName, CultureHelpers.GetCultureByLcid(recordedAction.Lcid)).Execute(requestContext); return(requestContext.HttpContext); }
private XmlDbUpdateRecordedAction ReplayAction(XmlDbUpdateRecordedAction xmlAction, string backendUrl) { try { var correctedAction = _actionsCorrecterService.PreActionCorrections(xmlAction, _useGuidSubstitution); var httpContext = _httpContextProcessor.PostAction(correctedAction, backendUrl, _userId, _useGuidSubstitution, _serviceProvider); return(_actionsCorrecterService.PostActionCorrections(correctedAction, httpContext)); } catch (Exception ex) { var throwEx = new XmlDbUpdateReplayActionException("Error while replaying xml action.", ex); throwEx.Data.Add(LoggerData.XmlDbUpdateExceptionActionToReplayData, xmlAction.ToJsonLog()); throw throwEx; } }
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); }
internal static XmlDbUpdateRecordedAction CreateXmlDbUpdateActionFromHttpContext(HttpContextBase httpContext, string actionCode, bool ignoreForm) { var action = new XmlDbUpdateRecordedAction { Code = actionCode, ParentId = Current.ParentEntityId ?? 0, Lcid = CultureInfo.CurrentCulture.LCID, Executed = DateTime.Now, ExecutedBy = (httpContext.User.Identity as QpIdentity)?.Name, Ids = httpContext.Items.Contains(HttpContextItems.FromId) ? new[] { httpContext.Items[HttpContextItems.FromId].ToString() } : Current.Entities.Select(n => n.StringId).ToArray(), ResultId = GetContextData <int>(httpContext, HttpContextItems.ResultId), UniqueId = GetGuidsContextData(httpContext, HttpContextItems.FromGuid), ResultUniqueId = GetGuidContextData(httpContext, HttpContextItems.ResultGuid), VirtualFieldIds = GetContextData <string>(httpContext, HttpContextItems.NewVirtualFieldIds), FieldIds = GetContextData <string>(httpContext, HttpContextItems.FieldIds), LinkIds = GetContextData <string>(httpContext, HttpContextItems.LinkIds), NewLinkId = GetContextData <int>(httpContext, HttpContextItems.NewLinkId), BackwardId = GetContextData <int>(httpContext, HttpContextItems.NewBackwardId), NewChildFieldIds = GetContextData <string>(httpContext, HttpContextItems.NewChildFieldIds), NewChildLinkIds = GetContextData <string>(httpContext, HttpContextItems.NewChildLinkIds), ActionId = GetContextData <int>(httpContext, HttpContextItems.ActionId), ActionCode = GetContextData <string>(httpContext, HttpContextItems.ActionCode), NewCommandIds = GetContextData <string>(httpContext, HttpContextItems.NewCommandIds), NewRulesIds = GetContextData <string>(httpContext, HttpContextItems.NewRulesIds), NotificationFormatId = GetContextData <int>(httpContext, HttpContextItems.NotificationFormatId), DefaultFormatId = GetContextData <int>(httpContext, HttpContextItems.DefaultFormatId) }; if (!ignoreForm) { action.Form = new NameValueCollection { httpContext.Request.Form, GetDynamicFieldValuesFromHttpContext(httpContext, HttpContextItems.FieldUniqueIdPrefix), GetStringValuesFromHttpContext(httpContext, HttpContextItems.DefaultArticleUniqueIds), GetStringValuesFromHttpContext(httpContext, HttpContextItems.DataO2MUniqueIdDefaultValue), GetStringValuesFromHttpContext(httpContext, HttpContextItems.ContentDefaultFilterArticleUniqueIDs) }; } 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); }
public HttpContext PostAction(XmlDbUpdateRecordedAction recordedAction, string backendUrl, int userId, bool useGuidSubstitution, IServiceProvider provider = null) { Ensure.NotNull(QPConnectionScope.Current.DbConnection, "QPConnection scope should be initialized to use fake mvc context"); var urlParts = recordedAction.BackendAction.ControllerActionUrl.Split(@"/".ToCharArray()) .Where(n => !string.IsNullOrEmpty(n) && n != "~").ToArray(); var controller = urlParts[0]; var action = urlParts[1]; BackendActionContext.ResetCurrent(); var cultureInfo = CultureHelpers.GetCultureByLcid(recordedAction.Lcid); CultureInfo.CurrentCulture = cultureInfo; var httpContext = XmlDbUpdateHttpContextHelpers.BuildHttpContext(recordedAction, backendUrl, userId, useGuidSubstitution); var routeData = XmlDbUpdateHttpContextHelpers.GetRouteData(recordedAction, controller, action); httpContext.Features[typeof(IRoutingFeature)] = new RoutingFeature { RouteData = routeData }; var routeContext = new RouteContext(httpContext) { RouteData = routeData }; var serviceProvider = provider ?? new HttpContextAccessor().HttpContext.RequestServices; httpContext.RequestServices = serviceProvider; var m = typeof(DynamicRouteValueTransformer).Assembly.GetType("Microsoft.AspNetCore.Mvc.Routing.MvcRouteHandler"); var handler = (IRouter)serviceProvider.GetRequiredService(m); QPContext.CurrentUserId = userId; Task.Run(async() => { await handler.RouteAsync(routeContext); await routeContext.Handler(routeContext.HttpContext); }).Wait(); QPContext.CurrentUserId = 0; return(httpContext); }
internal static XDocument SerializeAction(XmlDbUpdateRecordedAction action, string currentDbVersion, string backendUrl, bool withoutRoot) { var actionAlement = new XElement(XmlDbUpdateXDocumentConstants.ActionElement, new XAttribute(XmlDbUpdateXDocumentConstants.ActionCodeAttribute, action.Code), new XAttribute(XmlDbUpdateXDocumentConstants.ActionIdsAttribute, string.Join(",", action.Ids)), new XAttribute(XmlDbUpdateXDocumentConstants.ActionParentIdAttribute, action.ParentId), new XAttribute(XmlDbUpdateXDocumentConstants.ActionLcidAttribute, action.Lcid), new XAttribute(XmlDbUpdateXDocumentConstants.ActionExecutedAttribute, action.Executed.ToString(CultureHelpers.GetCultureByLcid(action.Lcid))), new XAttribute(XmlDbUpdateXDocumentConstants.ActionExecutedByAttribute, action.ExecutedBy), GetEntitySpecificAttributesForPersisting(action), GetActionChildElements(action.Form)); if (!withoutRoot) { var root = GetOrCreateRoot(backendUrl, currentDbVersion); root.Add(actionAlement); return(root.Document); } return(new XDocument(actionAlement).Document); }
internal static HttpContextBase BuildHttpContextBase(XmlDbUpdateRecordedAction action, string backendUrl, int userId, bool useGuidSubstitution) { HttpContext.Current = new HttpContext( new HttpRequest(string.Empty, backendUrl, string.Empty), new HttpResponse(new StringWriter())); var principal = GetQpPrincipal(userId); var httpContext = new Mock <HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(GetHttpRequestMock(action)); httpContext.Setup(c => c.Session).Returns(new HttpSessionMock()); httpContext.Setup(c => c.Response).Returns(new Mock <HttpResponseBase>().Object); httpContext.Setup(c => c.Response.Cookies).Returns(new HttpCookieCollection()); httpContext.Setup(c => c.Items).Returns(new Hashtable()); httpContext.Setup(c => c.Cache).Returns(HttpRuntime.Cache); httpContext.Setup(c => c.User).Returns(principal); HttpContext.Current.User = principal; return(useGuidSubstitution ? AddGlobalHttpContextVariables(httpContext.Object, backendUrl, action.ResultUniqueId) : AddGlobalHttpContextVariables(httpContext.Object, backendUrl)); }
private void CorrectFieldForm(XmlDbUpdateRecordedAction action, bool useGuidSubstitution) { CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.InCombinationWith, true); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataRelateToContentId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataRelationId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataBackRelationId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataClassifierId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataBaseImageId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataListOrderFieldId); CorrectFormValue(EntityTypeCode.Field, action.Form, HttpContextFormConstants.DataTreeOrderFieldId); CorrectFormValue(EntityTypeCode.ContentLink, action.Form, HttpContextFormConstants.DataContentLinkLinkId); CorrectAndSubstituteArticleIdFormValues(action.Form, HttpContextFormConstants.DataO2MDefaultValue, HttpContextFormConstants.DataO2MUniqueIdDefaultValue, useGuidSubstitution); CorrectFormValue(EntityTypeCode.Article, action.Form, HttpContextFormConstants.DataO2MDefaultValue); CorrectAndSubstituteArticleIdFormValues(action.Form, HttpContextFormConstants.DefaultArticleIds, HttpContextFormConstants.DefaultArticleUniqueIds, useGuidSubstitution); CorrectFormValue(EntityTypeCode.Article, action.Form, HttpContextFormConstants.DefaultArticleIds, true); CorrectFormValue(EntityTypeCode.VisualEditorCommand, action.Form, HttpContextFormConstants.ActiveVeCommands, true); CorrectFormValue(EntityTypeCode.VisualEditorStyle, action.Form, HttpContextFormConstants.ActiveVeStyles, true); CorrectFormValue(EntityTypeCode.VisualEditorStyle, action.Form, HttpContextFormConstants.ActiveVeFormats, true); }
private void CorrectCustomActionForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.Site, action.Form, HttpContextFormConstants.SelectedSiteIDs, true); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.SelectedContentIDs, true); CorrectFormValue(EntityTypeCode.BackendAction, action.Form, HttpContextFormConstants.SelectedActions, true); }
private static IEnumerable <XAttribute> GetEntitySpecificAttributesForPersisting(XmlDbUpdateRecordedAction action) { var result = new Dictionary <string, object>(); if (XmlDbUpdateQpActionHelpers.IsArticleAndHasUniqueId(action.Code)) { result.Add(XmlDbUpdateXDocumentConstants.ActionUniqueIdAttribute, string.Join(",", action.UniqueId)); } if (XmlDbUpdateQpActionHelpers.IsActionHasResultId(action.Code)) { result.Add(XmlDbUpdateXDocumentConstants.ActionResultIdAttribute, action.ResultId); if (XmlDbUpdateQpActionHelpers.IsArticleAndHasUniqueId(action.Code)) { result.Add(XmlDbUpdateXDocumentConstants.ActionResultUniqueIdAttribute, action.ResultUniqueId); } } switch (action.Code) { case ActionCode.AddNewVirtualContents: case ActionCode.VirtualContentProperties: case ActionCode.VirtualFieldProperties: result.Add(XmlDbUpdateXDocumentConstants.ActionNewVirtualFieldIdsAttribute, action.VirtualFieldIds); break; case ActionCode.AddNewContent: case ActionCode.CreateLikeContent: result.Add(XmlDbUpdateXDocumentConstants.ActionFieldIdsAttribute, action.FieldIds); result.Add(XmlDbUpdateXDocumentConstants.ActionLinkIdsAttribute, action.LinkIds); break; case ActionCode.AddNewField: case ActionCode.FieldProperties: case ActionCode.CreateLikeField: result.Add(XmlDbUpdateXDocumentConstants.ActionNewVirtualFieldIdsAttribute, action.VirtualFieldIds); result.Add(XmlDbUpdateXDocumentConstants.ActionNewLinkIdAttribute, action.NewLinkId); result.Add(XmlDbUpdateXDocumentConstants.ActionNewBackwardIdAttribute, action.BackwardId); result.Add(XmlDbUpdateXDocumentConstants.ActionNewChildFieldIdsAttribute, action.NewChildFieldIds); result.Add(XmlDbUpdateXDocumentConstants.ActionNewChildLinkIdsAttribute, action.NewChildLinkIds); break; case ActionCode.AddNewCustomAction: result.Add(XmlDbUpdateXDocumentConstants.ActionActionId, action.ActionId); result.Add(XmlDbUpdateXDocumentConstants.ActionActionCode, action.ActionCode); break; case ActionCode.AddNewVisualEditorPlugin: case ActionCode.VisualEditorPluginProperties: result.Add(XmlDbUpdateXDocumentConstants.ActionCommandIdsAttribute, action.NewCommandIds); break; case ActionCode.AddNewWorkflow: case ActionCode.WorkflowProperties: result.Add(XmlDbUpdateXDocumentConstants.ActionRulesIdsAttribute, action.NewRulesIds); break; case ActionCode.AddNewNotification: case ActionCode.NotificationProperties: result.Add(XmlDbUpdateXDocumentConstants.ActionFormatIdAttribute, action.NotificationFormatId); break; case ActionCode.AddNewPageObject: case ActionCode.AddNewTemplateObject: result.Add(XmlDbUpdateXDocumentConstants.ActionFormatIdAttribute, action.DefaultFormatId); break; } return(result.Where(r => r.Value != null).Select(r => new XAttribute(r.Key, r.Value))); }
private static HttpRequestMock GetHttpRequestMock(XmlDbUpdateRecordedAction action) { var httpRequest = new HttpRequestMock(); var options = QPConnectionScope.Current.IdentityInsertOptions; var entityTypeCode = action.BackendAction.EntityType.Code; if (entityTypeCode == EntityTypeCode.VirtualContent) { entityTypeCode = EntityTypeCode.Content; } var actionTypeCode = action.BackendAction.ActionType.Code; httpRequest.SetForm(action.Form); httpRequest.Form.Add(HttpContextFormConstants.Ids, string.Join(",", action.Ids)); if (actionTypeCode == ActionTypeCode.AddNew && options.Contains(entityTypeCode)) { httpRequest.Form.Add(HttpContextFormConstants.DataForceId, action.Ids.First()); } switch (action.Code) { case ActionCode.AddNewContent: if (options.Contains(EntityTypeCode.Field)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceFieldIds, action.ChildIds); } if (options.Contains(EntityTypeCode.ContentLink)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceLinkIds, action.ChildLinkIds); } break; case ActionCode.CreateLikeContent: if (options.Contains(EntityTypeCode.Content)) { httpRequest.Form.Add(HttpContextFormConstants.ForceId, action.ResultId.ToString()); } if (options.Contains(EntityTypeCode.Field)) { httpRequest.Form.Add(HttpContextFormConstants.ForceFieldIds, action.ChildIds); } if (options.Contains(EntityTypeCode.ContentLink)) { httpRequest.Form.Add(HttpContextFormConstants.ForceLinkIds, action.ChildLinkIds); } break; case ActionCode.CreateLikeField: if (options.Contains(EntityTypeCode.Field)) { httpRequest.Form.Add(HttpContextFormConstants.ForceId, action.ResultId.ToString()); } if (options.Contains(EntityTypeCode.Field)) { httpRequest.Form.Add(HttpContextFormConstants.ForceVirtualFieldIds, action.VirtualFieldIds); } if (options.Contains(EntityTypeCode.Field)) { httpRequest.Form.Add(HttpContextFormConstants.ForceChildFieldIds, action.ChildIds); } if (options.Contains(EntityTypeCode.ContentLink)) { httpRequest.Form.Add(HttpContextFormConstants.ForceLinkId, action.ChildId.ToString()); } if (options.Contains(EntityTypeCode.ContentLink)) { httpRequest.Form.Add(HttpContextFormConstants.ForceChildLinkIds, action.ChildLinkIds); } break; case ActionCode.AddNewVirtualContents: case ActionCode.VirtualContentProperties: case ActionCode.VirtualFieldProperties: if (options.Contains(EntityTypeCode.Field)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceVirtualFieldIds, action.VirtualFieldIds); } break; case ActionCode.AddNewField: case ActionCode.FieldProperties: if (options.Contains(EntityTypeCode.ContentLink)) { httpRequest.Form.Add(HttpContextFormConstants.DataContentLinkForceLinkId, action.ChildId.ToString()); AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceChildLinkIds, action.ChildIds); } if (options.Contains(EntityTypeCode.Field)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceVirtualFieldIds, action.VirtualFieldIds); httpRequest.Form.Add(HttpContextFormConstants.DataForceBackwardId, action.BackwardId.ToString()); AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceChildFieldIds, action.ChildIds); } break; case ActionCode.AddNewCustomAction: httpRequest.Form.Add(HttpContextFormConstants.DataForceActionCode, action.CustomActionCode); if (options.Contains(EntityTypeCode.BackendAction)) { httpRequest.Form.Add(HttpContextFormConstants.DataForceActionId, action.ChildId.ToString()); } break; case ActionCode.AddNewVisualEditorPlugin: case ActionCode.VisualEditorPluginProperties: if (options.Contains(EntityTypeCode.VisualEditorCommand)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceCommandIds, action.ChildIds); } break; case ActionCode.AddNewWorkflow: case ActionCode.WorkflowProperties: if (options.Contains(EntityTypeCode.WorkflowRule)) { AddListItem(httpRequest.Form, HttpContextFormConstants.DataForceRulesIds, action.ChildIds); } break; } httpRequest.SetPath(action.BackendAction.ControllerActionUrl.Replace("~", string.Empty)); return(httpRequest); }
private void CorrectContentForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.Workflow, action.Form, HttpContextFormConstants.DataWorkflowBindingWorkflowId); CorrectFormValue(EntityTypeCode.Content, action.Form, HttpContextFormConstants.DataParentContentId); CorrectFormValue(EntityTypeCode.ContentGroup, action.Form, HttpContextFormConstants.DataGroupId); }
private int GetArticleResultIdByGuidOrDefault(XmlDbUpdateRecordedAction action) { var articleIdByGuid = action.ResultUniqueId == Guid.Empty ? 0 : _dbActionService.GetArticleIdByGuidOrDefault(action.ResultUniqueId); return(articleIdByGuid == 0 ? action.ResultId : articleIdByGuid); }
private void CorrectUserGroupForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.User, action.Form, HttpContextFormConstants.BindedUserIds, true); CorrectFormValue(EntityTypeCode.UserGroup, action.Form, HttpContextFormConstants.ParentGroupId); }
private void CorrectArticleForm(XmlDbUpdateRecordedAction action, bool useGuidSubstitution) { CorrectDynamicArticleFormGuidValues(action.Form, useGuidSubstitution); CorrectDynamicArticleFormIdValues(action.Form, action.ParentId); }
private void CorrectSiteForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.VisualEditorCommand, action.Form, HttpContextFormConstants.ActiveVeCommands, true); CorrectFormValue(EntityTypeCode.VisualEditorStyle, action.Form, HttpContextFormConstants.ActiveVeStyles, true); CorrectFormValue(EntityTypeCode.VisualEditorStyle, action.Form, HttpContextFormConstants.ActiveVeFormats, true); }
private void CorrectVePluginForm(XmlDbUpdateRecordedAction action) { CorrectFormValue(EntityTypeCode.VisualEditorCommand, action.Form, HttpContextFormConstants.AggregationListItemsVeCommandsDisplay, "Id"); }