/// <summary>
 /// Registers a Save handler which works out the date of expiry for a rights of way Section 31 deposit
 /// </summary>
 private void ContentService_Saving(IContentService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IContent> e)
 {
     foreach (var entity in e.SavedEntities)
     {
         // Work out the date the deposit expires and put that into another property.
         // It needs to go into an Umbraco property so that Examine will index it and sort on it, because sorting dates
         // when using UmbracoContentIndexer only works when configured in ExamineIndex.config and that only supports Umbraco properties
         if (entity.ContentType.Alias == "RightsOfWayDeposit")
         {
             var dateDeposited = entity.GetValue <DateTime>("DateDeposited_Content");
             if (dateDeposited == DateTime.MinValue)
             {
                 entity.SetValue("DateExpires_Content", null);
             }
             else
             {
                 // IMPORTANT: Converting to yyyy-MM-dd must not be done using an extension method, because that breaks the sort
                 // function in Umbraco. It must be a compilation issue since it happens even when there are no document types called
                 // "RightsOfWayDeposit" meaning this code should never run, and in any case it is the same code as the failing version.
                 var depositExpires = new RightsOfWayDepositExpiryCalculator().CalculateExpiry(dateDeposited);
                 entity.SetValue("DateExpires_Content", depositExpires.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
             }
         }
     }
 }
コード例 #2
0
        private void ContentService_Saving(IContentService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IContent> e)
        {
            foreach (var node in e.SavedEntities)
            {
                foreach (var property in node.Properties)
                {
                    if (property.Value != null)
                    {
                        // Parse the property value for HTML
                        var html = new HtmlDocument();
                        html.LoadHtml(property.Value.ToString());

                        // Check for and update pasted links
                        var updated = UpdateLinksToContentNodes(html, UmbracoContext.Current);
                        updated = updated || UpdateLinksToMediaNodes(html);

                        // If a link was found and updated, update the property value
                        if (updated)
                        {
                            using (var writer = new StringWriter())
                            {
                                html.Save(writer);
                                property.Value = writer.ToString();
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void MemberService_Saved(IMemberService sender, global::Umbraco.Core.Events.SaveEventArgs <IMember> e)
        {
            foreach (var member in e.SavedEntities)
            {
                if (string.IsNullOrEmpty(member.GetValue <string>(GlobalSettings.UmbracoSettings.MemberIdPropertyAlias)))
                {
                    var customer = new Customer.Customer()
                    {
                        roles = new List <int>()
                        {
                            3
                        },
                        FirstName = member.Name,
                        LastName  = "",
                        Password  = Guid.NewGuid().ToString(),
                        Email     = member.Email
                    };

                    string customerId;

                    if (string.IsNullOrEmpty(_userContext.CustomerId()))
                    {
                        customerId = _nopService.CreateCustomer(customer);
                        _userContext.SetCustomerId(int.Parse(customerId));
                    }
                    else
                    {
                        var nopCustomerId = _userContext.CustomerId();
                        customerId = _nopService.UpdateCustomer(customer, nopCustomerId);
                    }

                    member.SetValue(GlobalSettings.UmbracoSettings.MemberIdPropertyAlias, customerId);
                }
            }
        }
コード例 #4
0
ファイル: ExpireCache.cs プロジェクト: stevenshlin/Archetype
 /// <summary>
 /// Expires the pre value cache when a datatype is saved.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="Umbraco.Core.Events.SaveEventArgs{IDataTypeDefinition}"/> instance containing the event data.</param>
 void ExpirePreValueCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs <IDataTypeDefinition> e)
 {
     foreach (var dataType in e.SavedEntities)
     {
         ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(Constants.CacheKey_PreValueFromDataTypeId + dataType.Id);
         ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(Constants.CacheKey_DataTypeByGuid + dataType.Key);
     }
 }
コード例 #5
0
 private void ExpireCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IDataTypeDefinition> e)
 {
     foreach (var dataType in e.SavedEntities)
     {
         ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
             string.Concat("Our.Umbraco.DocTypeGridEditor.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", dataType.Key));
     }
 }
コード例 #6
0
 private void ExpireVortoCache(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IDataTypeDefinition> e)
 {
     foreach (var dataType in e.SavedEntities)
     {
         ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(
             Constants.CacheKey_GetTargetDataTypeDefinition + dataType.Id);
     }
 }
コード例 #7
0
        private void MemberService_Saved(IMemberService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IMember> e)
        {
            var memberService = ApplicationContext.Current.Services.MemberService;

            foreach (var member in e.SavedEntities)
            {
                // this is a brand new member object
                if (member.IsNewEntity())
                {
                    // add member group for example:
                    memberService.AssignRole(member.Id, "Authenticated");
                }
            }
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MediaService_Saved(IMediaService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IMedia> e)
        {
            // the Umbraco method allows for multiple saves
            // in testing I've only been able to generate a single save at any time
            // however, the code honours the possibility of multiple media elements being saved

            foreach (var eachMediaEntity in e.SavedEntities)
            {
                if (folderNeedsAutoChildren(eachMediaEntity) && folderHasNoChildren(eachMediaEntity))
                {
                    createAllowedFolders(eachMediaEntity);
                }
            }
        }
コード例 #9
0
        void DataTypeService_Saved(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs<global::Umbraco.Core.Models.IDataTypeDefinition> e)
        {
            var excludedDataTypes = Enumerable.Empty<Guid>();

            var cropHealerConfig = ConfigurationManager.GetSection("CropHealer") as CropHealerConfigSection;
            if (cropHealerConfig != null)
            {
                 excludedDataTypes = cropHealerConfig.Exclusions.DataTypes.Select(g => g.Key);
            }

            foreach (var dataType in e.SavedEntities)
            {
                var propertyEditor = dataType.PropertyEditorAlias;
                if (propertyEditor == Constants.PropertyEditors.ImageCropperAlias && !excludedDataTypes.Contains(dataType.Key))
                {
                    CropHealer.SeekAndHeal(dataType, sender);
                }
            }
        }
        void ContentService_Saved(IContentService sender, global::Umbraco.Core.Events.SaveEventArgs <IContent> e)
        {
            try
            {
                foreach (var node in e.SavedEntities)
                {
                    if (node.ContentType.Alias != "Rating")
                    {
                        continue;
                    }

                    RemoveExistingRelations(node);

                    AddNewRelations(node);
                }
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }
 private void LocalizationService_SavedDictionaryItem(ILocalizationService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IDictionaryItem> e)
 {
     if (ModelMetadataProviders.Current is Mvc.DictionaryMetadataProvider provider)
     {
         foreach (var item in e.SavedEntities)
         {
             provider.UpdateCache(item);
         }
     }
 }
コード例 #12
0
 private void DataTypeService_Saved(IDataTypeService sender, global::Umbraco.Core.Events.SaveEventArgs <global::Umbraco.Core.Models.IDataTypeDefinition> e)
 {
     ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch("OPTEN.GetListViewPropertyEditors");
 }