static void MediaServiceSaved(IMediaService sender, SaveEventArgs<IMedia> e) { foreach (var item in e.SavedEntities) { library.ClearLibraryCacheForMedia(item.Id); } }
/// <summary> /// Set auto-properties on content saving /// We can't do these properties on create as the source values will not exist /// </summary> /// <param name="sender">The content service</param> /// <param name="e">The save event arguments</param> protected void ContentServiceOnSaving(IContentService sender, SaveEventArgs<IContent> e) { foreach (IContent entity in e.SavedEntities) { entity.SetDefaultValue("headTitle", entity.Name); } }
/// <summary> /// User saving event. /// </summary> /// <remarks> /// User is already saved but the object itself is not updated yet. /// </remarks> void User_Saving(IUserService service, SaveEventArgs<IUser> e) { foreach (var savedEntity in e.SavedEntities) { if (savedEntity != null) { if (!savedEntity.IsNewEntity()) { // Update permissions for old users if the user type changes. IUser savedUser = service.GetUserById(savedEntity.Id); if (savedEntity.UserType.Alias != savedUser.UserType.Alias) { _userTypePermissionsService.CopyPermissionsForSingleUser(savedUser); } } else { // Set permissions for new users. _userTypePermissionsService.CopyPermissionsForSingleUser(savedEntity); } } } }
private void Album_saved(IContentService sender, SaveEventArgs<IContent> e) { foreach (IContent node in e.SavedEntities) { if (node.ContentType.ContentTypeCompositionExists("Album") || node.ContentType.Alias == "Album") { IMediaService ms = UmbracoContext.Current.Application.Services.MediaService; IContent parent = node.Parent(); int media_parentId; if (parent.ContentType.ContentTypeCompositionExists("Album") || parent.ContentType.Alias == "Album") { IMedia media_parent = ms.GetRootMedia().Where(x => x.Name == parent.Name).First(x => x.ContentType.Alias == "Folder"); if (media_parent == null) { media_parent = ms.CreateMedia(parent.Name, -1, "Folder"); ms.Save(media_parent); } media_parentId = media_parent.Id; } else media_parentId = -1; IMedia media_album = ms.CreateMedia(node.Name, media_parentId, "Folder"); ms.Save(media_album); } } }
static void SetIsApproved(IMemberService sender, SaveEventArgs<IMember> e) { // Automatically approve all members, as we don't have an approval process now // This is needed as we added new membership after upgrading so IsApproved is // currently empty. First time a member gets saved now (login also saves the member) // IsApproved would turn false (default value of bool) so we want to prevent that // Note: Since July 23rd 2015 we need people to activate their accounts! Don't // approve automatically. var nonApprovedMembers = e.SavedEntities.Where( member => member.CreateDate < DateTime.Parse("2015-07-23") && member.Properties.Contains(Constants.Conventions.Member.IsApproved) && member.IsApproved == false); var memberService = ApplicationContext.Current.Services.MemberService; foreach (var member in nonApprovedMembers) { // Adds test for member having an Id, if they don't then it's a NEW member, // new members don't automatically get approved any more, only existing // member before July 23rd 2015 if (member.HasIdentity) { member.IsApproved = true; memberService.Save(member, false); } } }
private static void OnTemplateBuildingBlockSave(TemplateBuildingBlock subject, SaveEventArgs e, EventPhases phase) { if (!subject.IsAssemblyTemplateBuildingBlock()) return; using (var session = subject.Session) { var templatingAssembly = new TemplatingAssembly(subject); foreach (var embeddedParameterSchema in templatingAssembly.EmbeddedParameterSchemas) { if (session.IsExistingObject(String.Concat(subject.OrganizationalItem.WebDavUrl, "/", embeddedParameterSchema.Title, ".xsd"))) continue; var parameterSchema = new Schema(session, subject.OrganizationalItem.Id) { Title = embeddedParameterSchema.Title, Description = embeddedParameterSchema.Title, Purpose = SchemaPurpose.TemplateParameters, RootElementName = "Parameters", Xsd = embeddedParameterSchema.Xsd }; parameterSchema.Save(true); } foreach (var cSharpTemplateBuildingBlock in templatingAssembly.CSharpTemplateBuildingBlocks) { //If a TBB already exists if (session.IsExistingObject(String.Concat(subject.OrganizationalItem.WebDavUrl, "/", cSharpTemplateBuildingBlock.Title, ".tbbcs"))) continue; //Create a new C# TBB var templateBuildingBlock = new TemplateBuildingBlock(session, subject.OrganizationalItem.Id) { Title = cSharpTemplateBuildingBlock.Title, TemplateType = TemplateTypes.CSharpTemplate, Content = String.Format(CSharpTemplateBuildingBlockContent, templatingAssembly.Id, cSharpTemplateBuildingBlock.ClassName) }; if (cSharpTemplateBuildingBlock.ParameterSchema != null) { if (cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("/webdav/") || cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("tcm:")) { var parameterSchema = (Schema) session.GetObject(cSharpTemplateBuildingBlock.ParameterSchema); templateBuildingBlock.ParameterSchema = parameterSchema; } else if (cSharpTemplateBuildingBlock.ParameterSchema.ToLower().StartsWith("resource:")) { var parameterSchemaUrl = String.Concat(subject.OrganizationalItem.WebDavUrl, "/", Regex.Match(cSharpTemplateBuildingBlock.ParameterSchema, @"[\w ]*(?=\.xsd$)").Value, ".xsd"); var parameterSchema = (Schema)session.GetObject(parameterSchemaUrl); templateBuildingBlock.ParameterSchema = parameterSchema; } } templateBuildingBlock.Save(true); } } }
private void Member_AfterSave(Member sender, SaveEventArgs e) { //ensure that only the providers are flagged to listen execute var xml = sender.ToXml(new System.Xml.XmlDocument(), false).ToXElement(); var providers = ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>() .Where(x => x.EnableDefaultEventHandler); ExamineManager.Instance.ReIndexNode(xml, IndexTypes.Member, providers); }
private static void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid("15C87B6F-7987-49D9-8444-A2B4406941A8"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProcessorSettings(new StripeProcessorSettings()); }
private static void GatewayProviderServiceOnSaved(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProcessorSettings(new AuthorizeNetProcessorSettings()); }
private void ExpireCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e) { foreach (var dataType in e.SavedEntities) { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem( string.Concat("Our.Umbraco.NestedContent.GetPreValuesCollectionByDataTypeId_", dataType.Id)); } }
private void GatewayProviderServiceOnSaved(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid(Constants.GatewayProviderSettingsKey); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; MappingExtensions.SaveProcessorSettings(provider.ExtendedData, new SagePayProcessorSettings()); }
private void GatewayProviderServiceOnSaved(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid("5F2E88D1-6D07-4809-B9AB-D4D6036473E9"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveSmtpProviderSettings(new SmtpNotificationGatewayProviderSettings()); }
/// <summary> /// The entity collection service on saved. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void EntityCollectionServiceOnSaved(IEntityCollectionService sender, SaveEventArgs<IEntityCollection> e) { if (!EntityCollectionProviderResolver.HasCurrent) return; foreach (var collection in e.SavedEntities) { EntityCollectionProviderResolver.Current.AddOrUpdateCache(collection); } }
void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e) { var ContentService = sender; IContent content = ContentService.GetById(e.SavedEntities.First().Id); var pubDate = (e.SavedEntities.First().ReleaseDate != null) ? e.SavedEntities.First().ReleaseDate : e.SavedEntities.First().UpdateDate; content.SetValue("publishedDate", pubDate); ContentService.Save(content, raiseEvents: false); }
private void ContentService_Saving(IContentService sender, SaveEventArgs<IContent> e) { foreach (var doc in e.SavedEntities) { var mapping = MapProvider.Mappings.SingleOrDefault(n => n.DocumentType.Equals(doc.ContentType.Alias, StringComparison.CurrentCultureIgnoreCase)); if (mapping != null) SaveDocument(mapping, sender, doc); } }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> saveEventArgs) { var key = new Guid("ddb4b1e5-75ec-4c3f-9a05-a51dbad34b4a"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProviderSettings(new TaxJarProviderSettings()); }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> saveEventArgs) { var key = new Guid("D143E0F6-98BB-4E0A-8B8C-CE9AD91B0969"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProviderSettings(new BraintreeProviderSettings()); }
public void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { data.Save(this.Data, IOHelper.MapPath(Settings.CreatedPackagesSettings)); FireAfterSave(e); } }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> saveEventArgs) { var key = new Guid("DBC48C38-0617-44EA-989A-18AAD8D5DE52"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProviderSettings(new AvaTaxProviderSettings()); }
private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> saveEventArgs) { var key = new Guid(Constants.ProviderId); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProviderSettings(new QuickPayProviderSettings()); }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public override void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if(!e.Cancel){ FireAfterSave(e); } }
/// <summary> /// The gateway provider service on saved. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="args"> /// The args. /// </param> private static void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid("A5C2BFE1-CC2E-4809-9334-2C215E9E20E0"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProcessorSettings(new PurchaseOrderProcessorSettings()); }
/// <summary> /// The gateway provider service on saved. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="args"> /// The args. /// </param> private static void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs<IGatewayProviderSettings> args) { var key = new Guid("D584F356-454B-4D14-BE44-13D9D25D6A74"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) return; provider.ExtendedData.SaveProcessorSettings(new ChaseProcessorSettings()); }
private void ExpireMortarCache(IDataTypeService sender, SaveEventArgs<IDataTypeDefinition> e) { foreach (var dataType in e.SavedEntities) { ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem( string.Concat("Our.Umbraco.Mortar.Web.Extensions.ContentTypeServiceExtensions.GetAliasById_", dataType.Key)); ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem( string.Concat("Our.Umbraco.Mortar.Helpers.MortarHelper.GetRowOptionsDocType_GetPreValuesCollectionByDataTypeId_", dataType.Id)); } }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public override void Save() { var e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { ApplicationContext.Current.Services.FileService.SaveStylesheet(StylesheetEntity); FireAfterSave(e); } }
private void ComponentSaveInitiatedHandler(Component component, SaveEventArgs args, EventPhases phase) { string[] interestingMimeTypes = new string[] { "image/jpeg", "image/gif", "image/png", "image/x-bmp" }; if (interestingMimeTypes.Contains(component.BinaryContent.MultimediaType.MimeType)) { string title = component.Schema.Title; Regex re = new Regex(@" \[\s* # first '[' and some whitespace (?<width>\d*) # um.. the width \s*x\s* # the 'x' (?<height>\d*) # height \s*\] # finish off with another squaredy-bracket ", RegexOptions.IgnorePatternWhitespace); Match match = re.Match(title); if (!match.Success) { return; } int expectedWidth = int.Parse(match.Groups["width"].Value); int expectedHeight = int.Parse(match.Groups["height"].Value); if (component.BinaryContent != null) { using (MemoryStream mem = new MemoryStream()) { component.BinaryContent.WriteToStream(mem); Bitmap bitmap = null; try { bitmap = new Bitmap(mem); if (expectedWidth != bitmap.Width || expectedHeight != bitmap.Height) { throw new WrongSizeImageException(string.Format("You can only save a MM component of type {0} if it is {1}x{2}px. This image is {3}x{4}px" , title, expectedWidth, expectedHeight, bitmap.Width, bitmap.Height)); } } catch (System.ArgumentException) { if (mem.Length > 1) { throw new WrongSizeImageException("Unable to process this image, probably because it is too large, or not in a recognised image format."); } else throw; } finally { if (bitmap != null) { bitmap.Dispose(); } } } } } }
public void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { data.Save(this.Data, IOHelper.MapPath(Settings.CreatedPackagesSettings)); FireAfterSave(e); } }
private static void ProcessMediaSaved( IMediaService sender, SaveEventArgs <IMedia> e) { var services = DependencyResolver.Current.GetServices <IUmbracoMediaSavedEventService>(); foreach (var service in services) { service.ProcessMediaSaved(sender, e); } }
private void GatewayProviderServiceOnSaved(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> args) { var key = new Guid("5F2E88D1-6D07-4809-B9AB-D4D6036473E9"); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } provider.ExtendedData.SaveSmtpProviderSettings(new SmtpNotificationGatewayProviderSettings()); }
private void GatewayProviderServiceOnSaved(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> args) { var key = new Guid(Constants.GatewayProviderSettingsKey); var provider = args.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } MappingExtensions.SaveProcessorSettings(provider.ExtendedData, new SagePayProcessorSettings()); }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> saveEventArgs) { var key = new Guid("DBC48C38-0617-44EA-989A-18AAD8D5DE52"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } provider.ExtendedData.SaveProviderSettings(new AvaTaxProviderSettings()); }
/// <summary> /// Ensures that node name is the same as post title. /// </summary> void ContentService_Saved(IContentService sender, SaveEventArgs <IContent> e) { foreach (var entity in e.SavedEntities) { if (entity.ContentType.Alias == "uBlogsyPost" && entity.ParentId != -20) { PostService.Instance.EnsureCorrectPostTitle(entity); PostService.Instance.EnsureCorrectPostNodeName(entity); PostService.Instance.EnsureNavigationTitle(entity); } } }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public override void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { base.Save(); FireAfterSave(e); } }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> saveEventArgs) { var key = new Guid("ddb4b1e5-75ec-4c3f-9a05-a51dbad34b4a"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } provider.ExtendedData.SaveProviderSettings(new TaxJarProviderSettings()); }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public virtual void Save() { var e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { InvalidateCache(); FireAfterSave(e); } }
public void ProcessContentSaving(IContentService sender, SaveEventArgs <IContent> args) { var gridValidation = GridValidation(args.SavedEntities); var globalPanelValidation = GlobalPanelsValidation(args.SavedEntities); var validationResult = gridValidation.Disjunction(globalPanelValidation); validationResult.IfFail(errors => errors .Select(error => new EventMessage("Panel error", error, EventMessageType.Error)) .Iter(args.CancelOperation)); }
protected void EventContainerSaved(IService service, SaveEventArgs <EntityContainer> e) { if (uSync8BackOffice.eventsPaused) { return; } foreach (var folder in e.SavedEntities) { UpdateFolder(folder.Id, Path.Combine(rootFolder, this.DefaultFolder), DefaultConfig); } }
/// <summary> /// Ensures that node name is the same as post title. /// </summary> void ContentService_Saved(IContentService sender, SaveEventArgs<IContent> e) { foreach (var entity in e.SavedEntities) { if (entity.ContentType.Alias == "uBlogsyPost" && entity.ParentId != -20) { PostService.Instance.EnsureCorrectPostTitle(entity); PostService.Instance.EnsureCorrectPostNodeName(entity); PostService.Instance.EnsureNavigationTitle(entity); } } }
/// <summary> /// The gateway provider service on saving. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> saveEventArgs) { var key = new Guid("D143E0F6-98BB-4E0A-8B8C-CE9AD91B0969"); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } provider.ExtendedData.SaveProviderSettings(new BraintreeProviderSettings()); }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public virtual void Save() { //event var e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { FireAfterSave(e); } }
private void RefreshImageCropsCache(IDataTypeService sender, SaveEventArgs <IDataType> e) { //A data type has saved, see if it was a IEnumerable <IDataType> imageCroppers = imageCropperManager.GetImageCropperDataTypes(true); if (imageCroppers.Intersect(e.SavedEntities).Any()) { //There were some freshly saved Image cropper data types so refresh the image crop cache. //We can do that by simply getting the crops imageCropperManager.GetAllCrops(true); //true to bypass the cache & refresh it. } }
/// <summary> /// Clears messages from NotificationMonitors cache. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="saveEventArgs"> /// The save event args. /// </param> private static void NotificationMessageServiceOnSaved(INotificationMessageService sender, SaveEventArgs<INotificationMessage> saveEventArgs) { var resolver = MonitorResolver.HasCurrent ? MonitorResolver.Current : null; if (resolver == null) return; var monitors = resolver.GetAllMonitors(); foreach (var implements in monitors.OfType<INotificationMonitorBase>()) { implements.RebuildCache(); } }
public void Save() { var e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { //Add save method here at some point so this actually does something besides fire events... FireAfterSave(e); } }
void ContentService_Saving(IContentService sender, SaveEventArgs <IContent> args) { try { foreach (var entity in args.SavedEntities) { if (entity.ContentType.Alias != "standardLandingPage") { continue; } var descriptionsProperty = entity.Properties["descriptions"]; if (descriptionsProperty == null) { continue; } string descriptionsValue = null; if (descriptionsProperty.Value != null && !String.IsNullOrWhiteSpace(descriptionsProperty.Value.ToString())) { descriptionsValue = umbraco.library.GetPreValueAsString(Int32.Parse(descriptionsProperty.Value.ToString(), CultureInfo.InvariantCulture)); } var useLinks = Views.StandardLandingPage.DisplayAsListsOfLinks(descriptionsValue, entity.Level); for (var i = 1; i <= 15; i++) { var propertyAlias = "defDesc" + i.ToString("00", CultureInfo.InvariantCulture) + "_Content"; var html = entity.GetValue <string>(propertyAlias); if (html != null) { if (useLinks) { // Strip text outside links, and put links into a list html = CmsUtilities.ShouldBeUnorderedList(html); } else { // Otherwise just strip any HTML from the placeholder, which will be there if pasted from Word - it should be a text description html = new HtmlTagSanitiser().StripTags(html); } entity.SetValue(propertyAlias, html); } } } } catch (Exception e) { e.ToExceptionless().Submit(); } }
void editForm_ImageSaved(object sender, SaveEventArgs e) { if (editFormOpen) { editingClip.FormattedData = e.Image; editingClip.PluginData = e.Image; editingClip.MessageText = "Size: " + e.Image.Width + "x" + e.Image.Height + " - Color Depth: " + Image.GetPixelFormatSize(e.Image.PixelFormat).ToString(); clipEntryListBox.Invalidate(); } }
void MediaService_Saved(IMediaService sender, SaveEventArgs<IMedia> e) { foreach (IMedia entity in e.SavedEntities.Where(entity => entity.ContentType.Alias == PPC_2010.Data.Constants.SermonAlias)) { if (entity.ContentType.Alias == PPC_2010.Data.Constants.SermonAlias && entity.IsValid()) { var repository = ServiceLocator.Instance.Locate<ISermonRepository>(); repository.RefreshSermon(entity.Id, entity.Trashed); repository.UpdateSermonSort(); } } }
public static void CreateChildNodes(IContentService cs, SaveEventArgs<IContent> e) { var savedEnts = e.SavedEntities; var parentID = savedEnts.Select(x => x.Id).FirstOrDefault(); var folderName = savedEnts.Select(x => x.Name).FirstOrDefault(); var templateType = savedEnts.Select(x => x.ContentType).FirstOrDefault(); var IsNew = savedEnts.Select(x => x.IsNewEntity()).FirstOrDefault(); if (templateType.Alias == "Page" && IsNew) { CreatePageTemplateNodes(cs, parentID); } }
/// <summary> /// If the user creates a starConfiguration node, create some default child nodes to save the user some time. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ContentService_Saved(IContentService sender, SaveEventArgs <IContent> e) { foreach (var entity in e.SavedEntities) { if (entity.ContentType.Alias.Equals("eLearningAsset", StringComparison.InvariantCultureIgnoreCase)) { if (!AssetFolderAction(entity, "CREATE")) { e.Messages.Add(new EventMessage("uSCORM", "Error creating uSCORM asset folder", EventMessageType.Error)); } } } }
public void saveStock(DateTime dateTime, string stockName, int initialValue, int currentValue) { if (saveEvent != null) { SaveEventArgs e = new SaveEventArgs(); e.dateTime = dateTime; e.stockName = stockName; e.initialValue = initialValue; e.currentValue = currentValue; // raises event when saveStock is called saveEvent?.Invoke(this, e); } }
private void ContentServiceSaved(IContentService sender, SaveEventArgs <IContent> args) { foreach (var node in args.SavedEntities) { if ((node.ContentType.Alias == "home" || node.ContentType.Alias == "componentsLandingPage" || node.ContentType.Alias == "componentsTextPage" || node.ContentType.Alias == "showDetailPage" || node.ContentType.Alias == "searchPage") && node.Children().Where(x => x.ContentType.Alias == "pcFolder").FirstOrDefault() == null) { var contentService = ApplicationContext.Current.Services.ContentService; var pageComponentsFolder = contentService.CreateContent("Page Components", node.Id, "pcFolder"); contentService.Save(pageComponentsFolder); } } }
//NOTE: This is purely here for backwards compat for events private static void Save() { var e = new SaveEventArgs(); new Access().FireBeforeSave(e); if (e.Cancel) { return; } new Access().FireAfterSave(e); }
/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public override void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { ApplicationContext.Current.Services.FileService.SaveTemplate(TemplateEntity); //base.Save(); FireAfterSave(e); } }
private void Service_Saving(Tservice sender, SaveEventArgs <Tentity> e) { if (CodeFirstManager.Current.Features.EnableContentEvents) { lock (_onSave) { foreach (var entity in e.SavedEntities) { HandleEvent(_onSave, entity, e, ModelEventDispatcher.OnSaveObject); } } } }
private void GatewayProviderServiceOnSaving(IGatewayProviderService sender, SaveEventArgs <IGatewayProviderSettings> saveEventArgs) { var key = new Guid(Constants.ProviderId); var provider = saveEventArgs.SavedEntities.FirstOrDefault(x => key == x.Key && !x.HasIdentity); if (provider == null) { return; } provider.ExtendedData.SaveProviderSettings(new QuickPayProviderSettings()); }
/// <summary> /// Ensure list view is enabled for certain doc types when created /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ContentTypeService_SavingContentType(IContentTypeService sender, SaveEventArgs <Umbraco.Core.Models.IContentType> e) { foreach (var c in e.SavedEntities) { if (c.Alias.InvariantEquals("ArticulateArchive") || c.Alias.InvariantEquals("ArticulateAuthors")) { if (c.IsNewEntity()) { c.IsContainer = true; } } } }
private void NotificationMessageServiceOnSaved(INotificationMessageService sender, SaveEventArgs<INotificationMessage> saveEventArgs) { // TODO target this a bit better if (!MonitorResolver.HasCurrent) LogHelper.Info<NotificationMonitorEvents>("MonitorResolver singleton has not be set"); var monitors = MonitorResolver.Current.GetAllMonitors().Where(x => x is INotificationMonitorBase); foreach (var monitor in monitors) { // TODO - this will need to be a distributed call ((INotificationMonitorBase)monitor).RebuildCache(); } }
/// <summary> /// Used to persist object changes to the database /// </summary> public override void Save() { var e = new SaveEventArgs(); FireBeforeSave(e); if (e.Cancel == false) { ApplicationContext.Current.Services.MemberTypeService.Save(MemberTypeItem); base.Save(); FireAfterSave(e); } }
private void ContentServiceSaved(IContentService sender, SaveEventArgs <IContent> e) { var azureSearchServiceClient = AzureSearchContext.Instance.SearchIndexClient; foreach (var entity in e.SavedEntities) { if (HttpContext.Current == null) { SetARequestVariableIfScheduledPublishing(entity.Id.ToString()); } azureSearchServiceClient.ReIndexContent(entity); } }
public void ProcessMediaSaved(IMediaService sender, SaveEventArgs <IMedia> args) { //var actualMedia = args // .SavedEntities // .Where(m => !m.IsNewEntity()); //foreach (var media in actualMedia) //{ // if (IsAllowedForSearch(media)) // _documentIndexer.Index(media.Id); // else _documentIndexer.DeleteFromIndex(media.Id); //} }
/// <summary> /// When a new root Articulate node is created, then create the required 2 sub nodes /// </summary> private void ContentService_Saved(IContentService contentService, SaveEventArgs <IContent> e) { foreach (var c in e.SavedEntities) { if (!c.WasPropertyDirty("Id") || !c.ContentType.Alias.InvariantEquals(ArticulateContentTypeAlias)) { continue; } //it's a root blog node, set up the required sub nodes (archive , authors) if they don't exist var defaultLang = _languageService.GetDefaultLanguageIsoCode(); var children = contentService.GetPagedChildren(c.Id, 0, 10, out var total).ToList(); if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateArchive")) { var archiveContentType = _contentTypeService.Get("ArticulateArchive"); if (archiveContentType != null) { if (archiveContentType.VariesByCulture()) { var articles = contentService.Create("", c, "ArticulateArchive"); articles.SetCultureName("Archive", defaultLang); contentService.Save(articles); } else { var articles = contentService.CreateAndSave("Archive", c, "ArticulateArchive"); } } } if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateAuthors")) { var authorContentType = _contentTypeService.Get("ArticulateAuthors"); if (authorContentType != null) { if (authorContentType.VariesByCulture()) { var authors = contentService.Create("", c, "ArticulateAuthors"); authors.SetCultureName("Authors", defaultLang); contentService.Save(authors); } else { var authors = contentService.CreateAndSave("Authors", c, "ArticulateAuthors"); } } } } }