public async Task <dynamic> UpdateEditorAsync(ContentItem contentItem, IUpdateModel updater, string groupId, string htmlFieldPrefix)
        {
            if (contentItem == null)
            {
                throw new ArgumentNullException(nameof(contentItem));
            }

            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType);
            var stereotype            = contentTypeDefinition.Settings.ToObject <ContentTypeSettings>().Stereotype;
            var actualShapeType       = (stereotype ?? "Content") + "_Edit";

            dynamic itemShape = CreateContentShape(actualShapeType);

            itemShape.ContentItem = contentItem;

            // adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
            ((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + contentItem.ContentType);

            var context = new UpdateEditorContext(
                itemShape,
                groupId,
                htmlFieldPrefix,
                _shapeFactory,
                _layoutAccessor.GetLayout(),
                updater
                );

            await BindPlacementAsync(context);

            var updateContentContext = new UpdateContentContext(contentItem, updater);

            _contentHandlers.Invoke(handler => handler.Updating(updateContentContext), Logger);

            await _handlers.InvokeAsync(handler => handler.UpdateEditorAsync(contentItem, context), Logger);

            _contentHandlers.Reverse().Invoke(handler => handler.Updated(updateContentContext), Logger);

            return(context.Shape);
        }
        protected override void Updated(UpdateContentContext context)
        {
            var part = context.ContentItem.As <ConfigurationPart>();

            if (part == null)
            {
                return;
            }
            try {
                //test if configuration works
                var root = new TflRoot(
                    part.Configuration,
                    null,
                    new CfgNetNotifier(_notifier)
                    );
                CheckAddress(part.StartAddress);
                CheckAddress(part.EndAddress);
                Logger.Information("Loaded {0} with {1} warnings, and {2} errors.", part.Title(), root.Warnings().Length, root.Errors().Length);
            } catch (Exception ex) {
                _notifier.Add(NotifyType.Warning, T(ex.Message));
                Logger.Warning(ex.Message);
            }
        }
示例#3
0
        public override void Updated(UpdateContentContext context, AutoroutePart part)
        {
            // Compute the Path only if it's empty
            if (!String.IsNullOrWhiteSpace(part.Path))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                part.Path = _tokenizer.Tokenize(pattern, new Dictionary <string, object> {
                    ["Content"] = part.ContentItem
                });
                if (!IsPathUnique(part.Path, part))
                {
                    part.Path = GenerateUniquePath(part.Path, part);
                }

                part.Apply();
            }
        }
示例#4
0
        protected override void Updated(UpdateContentContext context)
        {
            var contentItem = context.ContentItem;

            if (contentItem.IsNew())
            {
                return;
            }

            if (_contentItemCreated)
            {
                RecordAuditTrailEvent(ContentAuditTrailEventProvider.Created, context.ContentItem);
            }
            else
            {
                _ignoreExportHandlerFor = contentItem;
                var newVersionXml = _contentManager.Export(contentItem);
                _ignoreExportHandlerFor = null;

                var diffGram = _analyzer.GenerateDiffGram(_previousVersionXml, newVersionXml);
                RecordAuditTrailEvent(ContentAuditTrailEventProvider.Saved, context.ContentItem, diffGram: diffGram, previousVersionXml: _previousVersionXml);
            }
        }
示例#5
0
        public async override Task UpdatedAsync(UpdateContentContext context, AliasPart part)
        {
            // Compute the Alias only if it's empty
            if (!String.IsNullOrEmpty(part.Alias))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var model = new AliasPartViewModel()
                {
                    Alias       = part.Alias,
                    AliasPart   = part,
                    ContentItem = part.ContentItem
                };

                part.Alias = await _liquidTemplateManager.RenderAsync(pattern, NullEncoder.Default, model,
                                                                      scope => scope.SetValue("ContentItem", model.ContentItem));

                part.Alias = part.Alias.Replace("\r", String.Empty).Replace("\n", String.Empty);

                if (part.Alias?.Length > AliasPartDisplayDriver.MaxAliasLength)
                {
                    part.Alias = part.Alias.Substring(0, AliasPartDisplayDriver.MaxAliasLength);
                }

                if (!await IsAliasUniqueAsync(part.Alias, part))
                {
                    part.Alias = await GenerateUniqueAliasAsync(part.Alias, part);
                }

                part.Apply();
            }
        }
示例#6
0
        public async override Task UpdatedAsync(UpdateContentContext context, AliasPart part)
        {
            // Compute the Alias only if it's empty
            if (!String.IsNullOrEmpty(part.Alias))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var model = new AliasPartViewModel()
                {
                    Alias       = part.Alias,
                    AliasPart   = part,
                    ContentItem = part.ContentItem
                };

                part.Alias = await _liquidTemplateManager.RenderStringAsync(pattern, NullEncoder.Default, model,
                                                                            new Dictionary <string, FluidValue>() { [nameof(ContentItem)] = new ObjectValue(model.ContentItem) });

                part.Alias = part.Alias.Replace("\r", String.Empty).Replace("\n", String.Empty);

                if (part.Alias?.Length > AliasPart.MaxAliasLength)
                {
                    part.Alias = part.Alias.Substring(0, AliasPart.MaxAliasLength);
                }

                if (!await part.IsAliasUniqueAsync(_session, part.Alias))
                {
                    part.Alias = await GenerateUniqueAliasAsync(part.Alias, part);
                }

                part.Apply();
            }
        }
示例#7
0
        public override async Task UpdatedAsync(UpdateContentContext context, AutoroutePart part)
        {
            // Compute the Path only if it's empty
            if (!String.IsNullOrWhiteSpace(part.Path))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var model = new AutoroutePartViewModel()
                {
                    Path          = part.Path,
                    AutoroutePart = part,
                    ContentItem   = part.ContentItem
                };

                part.Path = await _liquidTemplateManager.RenderAsync(pattern, NullEncoder.Default, model,
                                                                     scope => scope.SetValue("ContentItem", model.ContentItem));

                part.Path = part.Path.Replace("\r", String.Empty).Replace("\n", String.Empty);

                if (part.Path?.Length > AutoroutePartDisplay.MaxPathLength)
                {
                    part.Path = part.Path.Substring(0, AutoroutePartDisplay.MaxPathLength);
                }

                if (!await IsPathUniqueAsync(part.Path, part))
                {
                    part.Path = await GenerateUniquePathAsync(part.Path, part);
                }

                part.Apply();
            }
        }
示例#8
0
        public override async Task UpdatedAsync(UpdateContentContext context, AutoroutePart part)
        {
            // Compute the Path only if it's empty
            if (!String.IsNullOrWhiteSpace(part.Path))
            {
                return;
            }

            var pattern = GetPattern(part);

            if (!String.IsNullOrEmpty(pattern))
            {
                var model = new AutoroutePartViewModel()
                {
                    Path          = part.Path,
                    AutoroutePart = part,
                    ContentItem   = part.ContentItem
                };

                var templateContext = new TemplateContext();
                templateContext.SetValue("ContentItem", part.ContentItem);
                templateContext.MemberAccessStrategy.Register <AutoroutePartViewModel>();
                templateContext.SetValue("Model", model);

                part.Path = await _liquidTemplateManager.RenderAsync(pattern, NullEncoder.Default, templateContext);

                part.Path = part.Path.Replace("\r", String.Empty).Replace("\n", String.Empty);

                if (!await IsPathUniqueAsync(part.Path, part))
                {
                    part.Path = await GenerateUniquePathAsync(part.Path, part);
                }

                part.Apply();
            }
        }
示例#9
0
        //protected override void BuildEditorShape(BuildEditorContext context) {
        //    if (context.ContentItem.ContentType == "Site") {
        //        var model = context.ContentItem.As<UserRegistrationSettingsPart>();
        //        if (model.PolicyTextReferences != null && model.PolicyTextReferences.Length > 0) {
        //            context.ContentItem.As<UserRegistrationSettingsPart>().PolicyTextReferences = model.PolicyTextReferences[0].Split(',');
        //        }
        //        base.BuildEditorShape(context);
        //    }
        //}

        protected override void Updated(UpdateContentContext context)
        {
            if (context.ContentItem.ContentType == "Site")
            {
                var model = context.ContentItem.As <UserRegistrationSettingsPart>();
                if (model.PolicyTextReferences != null && model.PolicyTextReferences.Length > 0)   // rimouovo tutti i dati superflui
                {
                    if (model.PolicyTextReferences == null || model.PolicyTextReferences.Length == 0)
                    {
                        model.PolicyTextReferences = new string[] { "{All}" };
                    }
                    else if (model.PolicyTextReferences.Contains("{All}"))
                    {
                        model.PolicyTextReferences = new string[] { "{All}" };
                    }
                    else if (model.PolicyTextReferences.Contains("{DependsOnContent}"))
                    {
                        model.PolicyTextReferences = new string[] { "{DependsOnContent}" };
                    }
                    context.ContentItem.As <UserRegistrationSettingsPart>().PolicyTextReferences = model.PolicyTextReferences;
                }
            }
            base.Updated(context);
        }
        protected override void Updated(UpdateContentContext context)
        {
            base.Updated(context);

            InvalidateCachesAfteMenuItemChanges(context);
        }
        public override Task UpdatedAsync(UpdateContentContext context, GraphLookupPart part)
        {
            part.Apply();

            return(Task.CompletedTask);
        }
        /// <summary>
        /// Formato DateTimeField: 2009-06-15T13:45:30  yyyy-MM-ddThh:mm:ss NB: L’ora deve essere riferita all’ora di Greenwich
        /// </summary>
        /// <param name="eObj"></param>
        /// <param name="TheContentItem"></param>
        /// <returns></returns>
        private Response StoreNewContentItem(ExpandoObject eObj)
        {
            // Reasoning on permissions will require us to know the type
            // of the content.
            string tipoContent = ((dynamic)eObj).ContentType;
            // We will also need to know the content's Id in case we are
            // trying to edit an existing ContentItem.
            Int32 IdContentToModify = 0; // new content

            try {
                if ((Int32)(((dynamic)eObj).Id) > 0)
                {
                    IdContentToModify = (Int32)(((dynamic)eObj).Id);
                }
            } catch {
                // Fix per Username nullo
                if (tipoContent == "User")
                {
                    return(_utilsServices.GetResponse(ResponseType.Validation, "Missing user Id"));
                }
            }
            // We will be doing a first check on the ContentType, to validate what's coming
            // to the API. The call to the GetTypeDefinition method will also do null checks
            // on the type name for us.
            var typeDefinition = _contentDefinitionManager.GetTypeDefinition(tipoContent);

            if (typeDefinition == null)
            {
                // return an error of some sort here
                return(_utilsServices.GetResponse(ResponseType.Validation, "Invalid ContentType"));
            }
            // The ContentItem we will create/edit
            ContentItem NewOrModifiedContent;

            if (IdContentToModify == 0)
            {
                // We are going to be creating a new ContentItem
                NewOrModifiedContent = _contentManager.New(tipoContent);
                if (!_authorizer.Authorize(CorePermissions.CreateContent, NewOrModifiedContent))
                {
                    // the user cannot create content of the given type, so
                    // return an error
                    return(_utilsServices.GetResponse(ResponseType.UnAuthorized));
                }
                // since we may create, create
                _contentManager.Create(NewOrModifiedContent, VersionOptions.Draft);
            }
            else
            {
                // we are attempting to modify an existing items
                NewOrModifiedContent = _contentManager.Get(IdContentToModify, VersionOptions.DraftRequired);
            }
            if (NewOrModifiedContent == null)
            {
                // something went horribly wrong, so return an error
                return(_utilsServices.GetResponse(ResponseType.Validation, "No content with this Id"));
            }
            // If either of these validations fail, return an error because we cannot
            // edit the content
            // Validation 1: item should be of the given type
            if (NewOrModifiedContent.TypeDefinition.Name != tipoContent)
            {
                // return an error
                return(_utilsServices.GetResponse(ResponseType.UnAuthorized));
            }
            // Validation 2: check EditContent Permissions
            if (!_authorizer.Authorize(CorePermissions.EditContent, NewOrModifiedContent)
                // we also check permissions that may exist for this specific method
                && !_contentExtensionService.HasPermission(tipoContent, Methods.Post, NewOrModifiedContent))
            {
                // return an error
                return(_utilsServices.GetResponse(ResponseType.UnAuthorized));
            }
            // Validation 3: if we are also trying to publish, check PublishContent Permissions
            if (NewOrModifiedContent.Has <IPublishingControlAspect>() ||
                NewOrModifiedContent.TypeDefinition.Settings.GetModel <ContentTypeSettings>().Draftable)
            {
                // in this case, simply the EditContent permission is not enough because that
                // would only allow the user to create a draftable
                if (!_authorizer.Authorize(CorePermissions.PublishContent, NewOrModifiedContent))
                {
                    // return an error
                    return(_utilsServices.GetResponse(ResponseType.UnAuthorized));
                }
            }
            // To summarize, here we have a valid ContentItem that we are authorized to edit
            Response rsp = new Response();
            // do some further custom validation
            string validateMessage = ValidateMessage(NewOrModifiedContent, IdContentToModify == 0 ? "Created" : "Modified");

            if (string.IsNullOrEmpty(validateMessage))
            {
                // act like _contentManager.UpdateEditor
                var context = new UpdateContentContext(NewOrModifiedContent);
                // 1. invoke the Updating handlers
                Handlers.Invoke(handler => handler.Updating(context), Logger);
                // 2. do all the update operations
                rsp = _contentExtensionService.StoreInspectExpando(eObj, NewOrModifiedContent);
                if (rsp.Success)
                {
                    try {
                        string language = "";
                        try {
                            language = ((dynamic)eObj).Language;
                        } catch { }
                        if (NewOrModifiedContent.As <LocalizationPart>() != null)
                        {
                            if (!string.IsNullOrEmpty(language))
                            {
                                NewOrModifiedContent.As <LocalizationPart>().Culture = _cultureManager.GetCultureByName(language);
                            }
                            NewOrModifiedContent.As <LocalizationPart>().MasterContentItem = NewOrModifiedContent;
                        }
                        validateMessage = ValidateMessage(NewOrModifiedContent, "");
                        if (!string.IsNullOrEmpty(validateMessage))
                        {
                            rsp = _utilsServices.GetResponse(ResponseType.None, validateMessage);
                        }
                        // Have a validation actually return a response saying there
                        // was a validation error
                        validateMessage = ValidateMessage(NewOrModifiedContent, "Validation");
                        if (!string.IsNullOrEmpty(validateMessage))
                        {
                            rsp = _utilsServices.GetResponse(ResponseType.Validation, validateMessage);
                            // TODO: define better resolution actions depending
                            // error details?
                            rsp.ResolutionAction = ResolutionAction.AddParameter;
                        }
                        dynamic data = new ExpandoObject();
                        data.Id          = (Int32)(((dynamic)NewOrModifiedContent).Id);
                        data.ContentType = ((dynamic)NewOrModifiedContent).ContentType;
                        if (NewOrModifiedContent.As <AutoroutePart>() != null)
                        {
                            data.DisplayAlias = ((dynamic)NewOrModifiedContent).AutoroutePart.DisplayAlias;
                        }
                        rsp.Data = data;
                    }
                    catch (Exception ex) {
                        rsp = _utilsServices.GetResponse(ResponseType.None, ex.Message);
                    }
                }
                // 3. invoke the Updated handlers
                Handlers.Invoke(handler => handler.Updated(context), Logger);
                // Check whether any handler set some Error notifications (???)
                foreach (var notifi in _notifier.List())
                {
                    if (notifi.Type == NotifyType.Error)
                    {
                        // we'll cancel the transaction later
                        //_transactionManager.Cancel();
                        rsp.Success = false;
                        rsp.Message = "Error on update";
                        Logger.Error(notifi.Message.ToString());
                        break;
                    }
                }
            }
            else
            {
                // Custom validation failed
                // this one has by definition rsp.Success == false
                rsp = _utilsServices.GetResponse(ResponseType.None, validateMessage);
            }

            if (!rsp.Success)
            {
                // update failed
                _transactionManager.Cancel();
                // return an error
                return(rsp);
            }


            // we want the ContentItem to be published, so it can be "seen" by mobile
            // and the caches generated by the content will be evicted as well
            _contentManager.Publish(NewOrModifiedContent);
            return(rsp);
        }
 private void EvictCache(UpdateContentContext context, OutputCachePart part)
 {
     _signals.Trigger(OutputCachePart.ContentSignalName(part.Id));
 }
 private void BeginUpdateEvent(UpdateContentContext context, AuditTrailSettingsPart part)
 {
     _oldEventSettings = part.Retrieve <string>("Events");
 }
示例#15
0
 public override async Task UpdatedAsync(UpdateContentContext context, AutoroutePart part)
 {
     await GenerateContainerPathFromPattern(part);
     await GenerateContainedPathsFromPattern(context.UpdatingItem, part);
 }
示例#16
0
 public override Task UpdatedAsync(UpdateContentContext context, PartyPart part)
 {
     return(UpdateFullName(part));
 }
示例#17
0
 public void Updating(UpdateContentContext context)
 {
 }
示例#18
0
        public ActionResult QuickUpdate(TicketQuickUpdateViewModel model, string displyType)
        {
            if (!this.crmContentOwnershipService.IsCurrentUserOperator() && !this.crmContentOwnershipService.IsCurrentUserCustomer())
            {
                return(new HttpUnauthorizedResult());
            }

            if (model.Ids.Count == 0)
            {
                this.ModelState.AddModelError("Ids", "The model must contains minimum one contentItem.Id");
            }

            var tickets = this.contentManager.GetMany <TicketPart>(model.Ids, VersionOptions.DraftRequired, new QueryHints().ExpandRecords(new[] { "TicketPartRecord", "ContentItemPermissionPartRecord" })).ToList();

            if (tickets.Count != model.Ids.Count)
            {
                return(HttpNotFound());
            }

            bool afterUpdateUserStillCanChangeOwnership = true;

            if (ModelState.IsValid)
            {
                foreach (var ticket in tickets)
                {
                    var contentItem = ticket.ContentItem;

                    var context = new UpdateContentContext(contentItem);

                    this.Handlers.Invoke(handler => handler.Updating(context), Logger);

                    if (contentItem == null)
                    {
                        return(HttpNotFound());
                    }

                    if (!this.IsEditAuthorized(contentItem))
                    {
                        this.ModelState.AddModelError("Ids", T("You don't have right access to change these items").Text);
                        return(this.CreateActionResultBasedOnAjaxRequest(null, null));
                    }

                    dynamic snapshot = this.streamService.TakeSnapshot(contentItem);

                    if (model.UpdateBusinessUnitId || model.UpdateTeamId || model.UpdateUserId)
                    {
                        PostedEditOwnerViewModel postedEditOwnerViewModel = new PostedEditOwnerViewModel();
                        postedEditOwnerViewModel.UserId = model.UpdateUserId ? model.UserId : null;

                        if (model.BusinessUnitId.HasValue)
                        {
                            postedEditOwnerViewModel.GroupId = model.UpdateBusinessUnitId ?
                                                               "BusinessUnit:" + model.BusinessUnitId.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
                        }

                        if (model.UpdateTeamId && model.TeamId.HasValue)
                        {
                            postedEditOwnerViewModel.GroupId = "Team:" + model.TeamId.Value.ToString(CultureInfo.InvariantCulture);
                        }

                        this.EditOwner(contentItem, postedEditOwnerViewModel, false, false);
                        afterUpdateUserStillCanChangeOwnership = this.crmContentOwnershipService.CurrentUserIsContentItemAssignee(contentItem) || this.services.Authorizer.Authorize(Permissions.AdvancedOperatorPermission);
                    }

                    TicketPart ticketPart = contentItem.As <TicketPart>();

                    // Title
                    if (!string.IsNullOrEmpty(model.Title))
                    {
                        ticketPart.Record.Title = model.Title;
                    }

                    // Description
                    if (model.UpdateDescription)
                    {
                        ticketPart.Record.Description = model.Description;
                    }

                    // Priority
                    if (model.PriorityId.HasValue)
                    {
                        ticketPart.Record.PriorityRecord = new PriorityRecord {
                            Id = model.PriorityId.Value
                        };
                    }
                    else if (model.UpdatePriority)
                    {
                        ticketPart.Record.PriorityRecord = null;
                    }

                    // serviceId
                    if (model.ServiceId.HasValue)
                    {
                        ticketPart.Record.Service = new ServiceRecord {
                            Id = model.ServiceId.Value
                        };
                    }
                    else if (model.UpdateServiceId)
                    {
                        ticketPart.Record.Service = null;
                    }

                    // statusId
                    if (model.StatusId.HasValue)
                    {
                        ticketPart.Record.StatusRecord = new StatusRecord {
                            Id = model.StatusId.Value
                        };
                    }
                    else if (model.UpdateStatusId)
                    {
                        ticketPart.Record.StatusRecord = null;
                    }

                    // TicketTypeId
                    if (model.TypeId.HasValue)
                    {
                        ticketPart.Record.TicketType = new TicketTypeRecord {
                            Id = model.TypeId.Value
                        };
                    }
                    else if (model.UpdateTypeId)
                    {
                        ticketPart.Record.TicketType = null;
                    }

                    // DueDate
                    if (model.DueDate.HasValue)
                    {
                        ticketPart.Record.DueDate = model.DueDate.Value;
                    }
                    else if (model.UpdateDueDate)
                    {
                        ticketPart.Record.DueDate = null;
                    }

                    this.Handlers.Invoke(handler => handler.Updated(context), Logger);

                    contentManager.Publish(contentItem);

                    this.streamService.WriteChangesToStreamActivity(contentItem, snapshot, StreamWriters.TicketStreamWriter);
                    var documentIndex = this.indexProvider.New(contentItem.Id);
                    this.contentManager.Index(contentItem, documentIndex);
                    this.indexProvider.Store(TicketController.SearchIndexName, documentIndex);
                }
            }

            bool isAjaxRequest = Request.IsAjaxRequest();

            if (isAjaxRequest)
            {
                displyType = string.IsNullOrEmpty(displyType) ? "Summary" : displyType;
                List <dynamic> shapes = new List <dynamic>();

                foreach (var contentItem in tickets)
                {
                    var shape = this.contentManager.BuildDisplay(tickets[0].ContentItem, displayType: displyType);
                    shapes.Add(shape);
                }

                var data = new
                {
                    Tickets = Newtonsoft.Json.JsonConvert.SerializeObject(shapes),
                    ChangeOwnershipIsPossible = afterUpdateUserStillCanChangeOwnership
                };

                AjaxMessageViewModel ajaxMessageModel = new AjaxMessageViewModel {
                    Id = tickets[0].ContentItem.Id, IsDone = ModelState.IsValid, Data = data
                };

                foreach (var item in ModelState)
                {
                    ajaxMessageModel.Errors.AddRange(item.Value.Errors.Select(c => new KeyValuePair <string, string>(item.Key, c.Exception != null ? c.Exception.Message : c.ErrorMessage)).Where(c => !string.IsNullOrEmpty(c.Value)));
                }

                return(this.Json(ajaxMessageModel, JsonRequestBehavior.AllowGet));
            }
            else if (!string.IsNullOrEmpty(model.returnUrl))
            {
                return(this.Redirect(model.returnUrl));
            }
            else
            {
                return(this.RedirectToAction("Edit", new RouteValueDictionary {
                    { "Id", tickets[0].ContentItem.Id }
                }));
            }
        }
示例#19
0
 private void AssignUpdateUser(UpdateContentContext context, CoeveryCommonPart part)
 {
     part.Modifer = _authenticationService.GetAuthenticatedUser();
 }
示例#20
0
 public override Task UpdatedAsync(UpdateContentContext context)
 {
     return(TriggerWorkflowEventAsync(nameof(ContentUpdatedEvent), context.ContentItem));
 }
示例#21
0
 public override Task UpdatedAsync(UpdateContentContext context, ProductPart instance)
 {
     return(Task.CompletedTask);
 }
 public virtual void Updated(UpdateContentContext context) { }
 public override Task UpdatedAsync(UpdateContentContext context, ContentApprovalPart part)
 {
     return(HandleNotification(part));
 }
示例#24
0
 protected virtual void Updated(UpdateContentContext context, TPart instance)
 {
 }
 public virtual void Updated(UpdateContentContext context, TPart instance)
 {
 }
 private void BeginUpdateEvent(UpdateContentContext context, AuditTrailTrimmingSettingsPart part)
 {
     _oldRetentionPeriod    = part.RetentionPeriod;
     _oldMinimumRunInterval = part.MinimumRunInterval;
 }
示例#27
0
        protected override void Updated(UpdateContentContext context)
        {
            if (context.ContentItem.ContentType == "Site")
            {
                // we will be here even if we are not updating directly this setting, because site is
                // also being updated elsewhere.
                var model = context.ContentItem.As <UserRegistrationSettingsPart>();
                if (model != null)
                {
                    if (// if there is nothing selected
                        model.PolicyTextReferences == null ||
                        model.PolicyTextReferences.Length == 0
                        // or we  should show all policies
                        || model.PolicyTextReferences.Contains("{All}"))
                    {
                        // set a default for the array of policies to show
                        model.PolicyTextReferences = new string[] { "{All}" };
                    }
                    else if (model.PolicyTextReferences.Contains("{DependsOnContent}"))
                    {
                        model.PolicyTextReferences = new string[] { "{DependsOnContent}" };
                    }
                    context.ContentItem.As <UserRegistrationSettingsPart>().PolicyTextReferences = model.PolicyTextReferences;
                    // update options for policies
                    var policies = _policyServices.GetAllPublishedPolicyTexts();
                    switch (model.IncludePendingPolicy)
                    {
                    // these two cases fall on the Yes. This is the same behavior that used to
                    // be in place. Note that either case is actually a misconfiguration.
                    case Policy.IncludePendingPolicyOptions.DependsOnContent:
                    default:
                    case Policy.IncludePendingPolicyOptions.Yes:
                        if (model.PolicyTextReferences.Contains("{All}"))
                        {
                            // flag all policies to be shown
                            foreach (var p in policies)
                            {
                                p.AddPolicyToRegistration = true;
                            }
                        }
                        else
                        {
                            // mark all the policies that are selected in the setting so
                            // that they have the correct value for the flag
                            foreach (var p in policies)
                            {
                                p.AddPolicyToRegistration = model.PolicyTextReferences.Contains(string.Format("{{{0}}}", p.Id));
                            }
                        }
                        break;

                    case Policy.IncludePendingPolicyOptions.No:
                        // make sure each policy is flagged to not be shown
                        foreach (var p in policies)
                        {
                            p.AddPolicyToRegistration = false;
                        }
                        break;
                    }
                }
                base.Updated(context);
            }
        }
示例#28
0
 protected override void  Updating(UpdateContentContext context)
 {
     base.Updating(context);
 }
 public override Task UpdatedAsync(UpdateContentContext context) =>
 // The Document.Id of the child content items will always be 0. We don't need to log the children.
 // In this case we can prevent to log the items inside the FlowPart, BagPart, MenuItemLink, etc.
 context.ContentItem.Id != 0 ?
 RecordAuditTrailEventAsync(ContentAuditTrailEventProvider.Saved, context.ContentItem) :
 Task.CompletedTask;
示例#30
0
 public override Task UpdatedAsync(UpdateContentContext context) => AddContextAsync(context);
示例#31
0
 public virtual void Updated(UpdateContentContext context)
 {
 }