Exemplo n.º 1
0
 public InputEvents()
 {
     KeyUpData     = null;
     KeysDownData  = null;
     KeyPressData  = null;
     CopyEventArgs = null;
 }
        private void DocumentAfterCopy(Document sender, CopyEventArgs e)
        {
            if (sender.Level > 2 && sender.ContentType.Alias == Order.NodeAlias)
            {
                Guid currentGuid;
                var  orderGuid = sender.getProperty("orderGuid").Value.ToString();

                Guid.TryParse(orderGuid, out currentGuid);

                var order = OrderHelper.GetOrder(currentGuid);

                var newOrder = OrderHelper.CreateNewOrderFromExisting(order);

                IO.Container.Resolve <IOrderNumberService>().GenerateAndPersistOrderNumber(order);

                order.OrderNodeId = e.NewDocument.Id;
                order.Save();

                e.NewDocument.Text = order.OrderNumber;
                e.NewDocument.SetProperty("orderGuid", newOrder.UniqueOrderId.ToString());
                e.NewDocument.SetProperty("orderStatusPicker", newOrder.Status.ToString());

                e.NewDocument.Save();

                BasePage.Current.ClientTools.SyncTree(e.NewDocument.Parent.Path, false);
                BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("editContent.aspx?id=", e.NewDocument.Id));
            }
        }
Exemplo n.º 3
0
        private void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
        {
            var signature     = GetUserSignature(CurrentUser);
            var fromSignature = GetContentSignature(e.Original);
            var toSignature   = GetContentSignature(e.Copy);

            HistoryHelper.AddHistoryItem($"{signature} copied content from {fromSignature} to {toSignature}");
        }
Exemplo n.º 4
0
        private void ContentService_Copying(IContentService sender, CopyEventArgs <IContent> e)
        {
            // When a content node contains nested content property
            // Check if the copied node contains a nested content
            var nestedContentProps = e.Copy.Properties.Where(x => x.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.NestedContent);

            UpdateNestedContentProperties(nestedContentProps, false);
        }
Exemplo n.º 5
0
 private void Service_Copying(Tservice sender, CopyEventArgs <Tentity> e)
 {
     if (CodeFirstManager.Current.Features.EnableContentEvents)
     {
         lock (_onCopy)
         {
             HandleEvent(_onCopy, e.Copy, e, ModelEventDispatcher.OnCopyObject);
         }
     }
 }
#pragma warning restore 0649

            public bool OnBytesCopied(int p0, int p1)
            {
                var __h = Handler;

                if (__h == null)
                {
                    return(false);
                }
                var __e = new CopyEventArgs(true, p0, p1);

                __h(sender, __e);
                return(__e.Handled);
            }
Exemplo n.º 7
0
        /// <summary>
        /// Handles cache refreshing for when content is copied
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// When an entity is copied new permissions may be assigned to it based on it's parent, if that is the
        /// case then we need to clear all user permissions cache.
        /// </remarks>
        static void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
        {
            //check if permissions have changed
            var permissionsChanged = ((Content)e.Copy).WasPropertyDirty("PermissionsChanged");

            if (permissionsChanged)
            {
                DistributedCache.Instance.RefreshAllUserPermissionsCache();
            }

            //run the un-published cache refresher since copied content is not published
            DistributedCache.Instance.RefreshUnpublishedPageCache(e.Copy);
        }
        void ContentService_Copying( IContentService sender, CopyEventArgs<IContent> e )
        {
            Property masterRelationProperty = e.Copy.Properties.SingleOrDefault( p => p.Alias == Api.Constants.ProductPropertyAliases.MasterRelationPropertyAlias );

              if ( masterRelationProperty == null || ( masterRelationProperty.Value != null && !string.IsNullOrEmpty( masterRelationProperty.Value.ToString() ) ) ) {
            return;
              }

              //Delete all property data
              foreach ( Property property in e.Copy.Properties ) {
            property.Value = null;
              }

              masterRelationProperty.Value = e.Original.Id.ToString( CultureInfo.InvariantCulture );
        }
Exemplo n.º 9
0
    public bool Equals(CopyEventArgs <TEntity>?other)
    {
        if (ReferenceEquals(null, other))
        {
            return(false);
        }

        if (ReferenceEquals(this, other))
        {
            return(true);
        }

        return(base.Equals(other) && EqualityComparer <TEntity> .Default.Equals(Copy, other.Copy) &&
               ParentId == other.ParentId && RelateToOriginal == other.RelateToOriginal);
    }
Exemplo n.º 10
0
        void ContentService_Copying(IContentService sender, CopyEventArgs <IContent> e)
        {
            Property masterRelationProperty = e.Copy.Properties.SingleOrDefault(p => p.Alias == Api.Constants.ProductPropertyAliases.MasterRelationPropertyAlias);

            if (masterRelationProperty == null || (masterRelationProperty.Value != null && !string.IsNullOrEmpty(masterRelationProperty.Value.ToString())))
            {
                return;
            }

            //Delete all property data
            foreach (Property property in e.Copy.Properties)
            {
                property.Value = null;
            }

            masterRelationProperty.Value = e.Original.Id.ToString(CultureInfo.InvariantCulture);
        }
        private void _hostInterface_OnCopy(CopyEventArgs e)
        {
            EventArgs = new InputEvents()
            {
                CopyEventArgs = e
            };

            foreach (var filter in _filters.Values)
            {
                if (filter.IsEngaged)
                {
                    filter.HandleCopy(e);
                    if (e.Handled)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Copy relations to media items when a page is copied.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
 {
     try
     {
         if (_config.ReadBooleanSetting("moveMediaFilesStillInUse"))
         {
             var fileRelations = uMediaSyncHelper.relationService.GetByParent(e.Original).Where(r => r.RelationType.Alias == Constants.FileRelationTypeAlias);
             foreach (var relation in fileRelations)
             {
                 var media       = uMediaSyncHelper.mediaService.GetById(relation.ChildId);
                 var newRelation = uMediaSyncHelper.relationService.Relate(e.Copy, media, Constants.FileRelationTypeAlias);
                 uMediaSyncHelper.relationService.Save(newRelation);
             }
         }
     }
     catch (Exception ex)
     {
         ex.ToExceptionless().Submit();
         throw; // throw to the generic handler that writes to the Umbraco log
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// When a page is copied, copy its media folder and all its files too, then set up a relation between the two copies and publish the page
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
        {
            try
            {
                if (_config.SyncNode(e.Original))
                {
                    if (_config.ReadBooleanSetting("checkForMissingRelations"))
                    {
                        _folderService.EnsureRelatedMediaNodeExists(e.Original);
                    }

                    IContent content1 = uMediaSyncHelper.contentService.GetById(e.Original.Id);
                    IContent content2 = uMediaSyncHelper.contentService.GetById(e.Copy.Id);

                    IEnumerable <IRelation> uMediaSyncRelationsBefore = uMediaSyncHelper.relationService.GetByParentId(content1.Id).Where(r => r.RelationType.Alias == Constants.FolderRelationTypeAlias);
                    IRelation uMediaSyncRelation1 = uMediaSyncRelationsBefore.FirstOrDefault();
                    if (uMediaSyncRelation1 != null)
                    {
                        int media1Id = uMediaSyncRelation1.ChildId;

                        IMedia media1 = uMediaSyncHelper.mediaService.GetById(media1Id);

                        IEnumerable <IRelation> uMediaSyncRelations2 = uMediaSyncHelper.relationService.GetByParentId(content2.ParentId).Where(r => r.RelationType.Alias == Constants.FolderRelationTypeAlias);
                        IRelation uMediaSyncRelation2Parent          = uMediaSyncRelations2.FirstOrDefault();

                        if (uMediaSyncRelation2Parent == null && _config.ReadBooleanSetting("checkForMissingRelations"))
                        {
                            // parent node doesn't have a media folder yet, probably because uMediaSync was installed after the node was created
                            _folderService.CreateRelatedMediaNode(content2.Parent());

                            // get the new relation for the parent
                            IEnumerable <IRelation> uMediaSyncRelationsAfter = uMediaSyncHelper.relationService.GetByParentId(content2.ParentId).Where(r => r.RelationType.Alias == Constants.FolderRelationTypeAlias);
                            uMediaSyncRelation2Parent = uMediaSyncRelationsAfter.FirstOrDefault();
                        }


                        if (uMediaSyncRelation2Parent != null)
                        {
                            int media2ParentId = uMediaSyncRelation2Parent.ChildId;

                            IMedia media2Parent = uMediaSyncHelper.mediaService.GetById(media2ParentId);

                            IMedia media2 = uMediaSyncHelper.mediaService.CreateMedia(content1.Name, media2Parent, "Folder", uMediaSyncHelper.userId);

                            // Create a temp variable to store the original media name before saving.
                            var originalMediaName = content2.Name;

                            uMediaSyncHelper.mediaService.Save(media2, uMediaSyncHelper.userId);
                            // After saving, the media name and the saved folder name might not match, because the folder already existed.
                            // If they don't match, delete the folder, as it is an unnecesary duplicate.
                            if (media2.Name != originalMediaName)
                            {
                                uMediaSyncHelper.mediaService.Delete(media2);

                                // After deleting , recreate the media object, get the Id of the existing media folder, and set media2 to this id
                                // then copy any missing media
                                media2 = uMediaSyncHelper.mediaService.CreateMedia(content1.Name, media2Parent, "Folder", uMediaSyncHelper.userId);
                                var originalMedia = uMediaSyncHelper.mediaService.GetChildren(media2ParentId).LastOrDefault(media => media.Name == originalMediaName);
                                media2.Id   = originalMedia.Id;
                                media2.Name = originalMediaName;
                                CopyMedia(media1, media2);
                            }
                            // if they do match, then the media didn't exist already, so continue as normal.
                            else
                            {
                                CopyMedia(media1, media2);

                                IRelation relation = uMediaSyncHelper.relationService.Relate(content2, media2, Constants.FolderRelationTypeAlias);
                                uMediaSyncHelper.relationService.Save(relation);

                                uMediaSyncHelper.contentService.Save(content2, uMediaSyncHelper.userId);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
                throw; // throw to the generic handler that writes to the Umbraco log
            }
        }
 public void HandleCopy(CopyEventArgs e)
 {
     e.Handled = true;
 }
        /// <summary>
        /// <see cref="ContentService"/> Copying event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentService_Copying(IContentService sender, CopyEventArgs <IContent> e)
        {
            var props = e.Copy.GetPropertiesByEditor(_editorAlias);

            UpdatePropertyValues(props, false);
        }
 /// <summary>
 /// Handles cache refreshing for when content is copied
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// When an entity is copied new permissions may be assigned to it based on it's parent, if that is the
 /// case then we need to clear all user permissions cache.
 /// </remarks>
 private void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
 {
 }
Exemplo n.º 17
0
        /// <summary>
        /// Creates a new document of the same type and copies all data from the current onto it. Due to backwards compatibility we can't return
        /// the new Document, but it's included in the CopyEventArgs.Document if you subscribe to the AfterCopy event
        /// </summary>
        /// <param name="CopyTo"></param>
        /// <param name="u"></param>
        /// <param name="RelateToOrignal"></param>
        public Document Copy(int CopyTo, User u, bool RelateToOrignal)
        {
            CopyEventArgs e = new CopyEventArgs();
            e.CopyTo = CopyTo;
            FireBeforeCopy(e);
            Document newDoc = null;

            if (!e.Cancel)
            {
                // Make the new document
                newDoc = MakeNew(Text, new DocumentType(ContentType.Id), u, CopyTo);

                if (newDoc != null)
                {
                    // update template if a template is set
                    if (this.Template > 0)
                        newDoc.Template = Template;

                    //update the trashed property as it could be copied inside the recycle bin
                    newDoc.IsTrashed = this.IsTrashed;

                    // Copy the properties of the current document
                    var props = GenericProperties;
                    foreach (Property p in props)
                    {
                        //copy file if it's an upload property (so it doesn't get removed when original doc get's deleted)

                        IDataType uploadField = new Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));

                        if (p.PropertyType.DataTypeDefinition.DataType.Id == uploadField.Id
                        && p.Value.ToString() != ""
                        && File.Exists(IOHelper.MapPath(p.Value.ToString())))
                        {

                            int propId = newDoc.getProperty(p.PropertyType.Alias).Id;

                            System.IO.Directory.CreateDirectory(IOHelper.MapPath(SystemDirectories.Media + "/" + propId.ToString()));

                            string fileCopy = IOHelper.MapPath(
                                SystemDirectories.Media + "/" +
                                propId.ToString() + "/" +
                                new FileInfo(IOHelper.MapPath(p.Value.ToString())).Name);

                            File.Copy(IOHelper.MapPath(p.Value.ToString()), fileCopy);

                            string relFilePath =
                                SystemDirectories.Media + "/" +
                                propId.ToString() + "/" +
                                new FileInfo(IOHelper.MapPath(p.Value.ToString())).Name;

                            if (SystemDirectories.Root == string.Empty)
                                relFilePath = relFilePath.TrimStart('~');

                            newDoc.getProperty(p.PropertyType.Alias).Value = relFilePath;

                            //copy thumbs
                            FileInfo origFile = new FileInfo(IOHelper.MapPath(p.Value.ToString()));

                            foreach(FileInfo thumb in origFile.Directory.GetFiles("*_thumb*"))
                            {
                                if (!File.Exists(IOHelper.MapPath(
                                                     SystemDirectories.Media + "/" +
                                                     propId.ToString() + "/" +
                                                     thumb.Name)))
                                {
                                    thumb.CopyTo(IOHelper.MapPath(
                                    SystemDirectories.Media + "/" +
                                    propId.ToString() + "/" +
                                    thumb.Name));
                                }
                            }

                        }
                        else
                        {
                            newDoc.getProperty(p.PropertyType.Alias).Value = p.Value;
                        }

                    }

                    // Relate?
                    if (RelateToOrignal)
                    {
                        Relation.MakeNew(Id, newDoc.Id, RelationType.GetByAlias("relateDocumentOnCopy"), "");

                        // Add to audit trail
                        Log.Add(LogTypes.Copy, u, newDoc.Id, "Copied and related from " + Text + " (id: " + Id.ToString() + ")");
                    }

                    // Copy the children
                    //store children array here because iterating over an Array object is very inneficient.
                    var c = Children;
                    foreach (Document d in c)
                        d.Copy(newDoc.Id, u, RelateToOrignal);

                    e.NewDocument = newDoc;
                }

                FireAfterCopy(e);

            }

            return newDoc;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Event handler for the view's copy event.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void OnCopy(object sender, CopyEventArgs e)
 {
     this.explorerPresenter.SetClipboardText(e.Text, "CLIPBOARD");
 }
Exemplo n.º 19
0
        public Document Copy(int CopyTo, User u, bool RelateToOrignal)
        {
            var e = new CopyEventArgs();
            e.CopyTo = CopyTo;
            FireBeforeCopy(e);
            Document newDoc = null;

            if (!e.Cancel)
            {
                // Make the new document
                var content = ApplicationContext.Current.Services.ContentService.Copy(Content, CopyTo, RelateToOrignal, u.Id);
                newDoc = new Document(content);
                
                // Have to run the ActionNew handler to do umbEnsureUniqueName (for example)
                BusinessLogic.Actions.Action.RunActionHandlers(newDoc, ActionNew.Instance);
                // Then save to preserve any changes made by action handlers
                newDoc.Save();

                e.NewDocument = newDoc;
                FireAfterCopy(e);
            }

            return newDoc;
        }
 public virtual void Copied(IContentService contentService, CopyEventArgs <IContent> args)
 {
 }
Exemplo n.º 21
0
 public static void Copying(IContentService sender, CopyEventArgs <IContent> e)
 {
     int i = 0;
 }
Exemplo n.º 22
0
        public Document Copy(int CopyTo, User u, bool RelateToOrignal)
        {
            var e = new CopyEventArgs();
            e.CopyTo = CopyTo;
            FireBeforeCopy(e);
            Document newDoc = null;

            if (!e.Cancel)
            {
                // Make the new document
                var content = ApplicationContext.Current.Services.ContentService.Copy(Content, CopyTo, RelateToOrignal, u.Id);
                newDoc = new Document(content);
                
                // Then save to preserve any changes made by action handlers
                newDoc.Save();

                e.NewDocument = newDoc;
                FireAfterCopy(e);
            }

            return newDoc;
        }
 public void HandleCopy(CopyEventArgs e)
 {
 }
Exemplo n.º 24
0
 /// <summary>
 /// Raises the <see cref="E:BeforeCopy"/> event.
 /// </summary>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected virtual void FireBeforeCopy(CopyEventArgs e)
 {
     if (BeforeCopy != null)
         BeforeCopy(this, e);
 }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a new document of the same type and copies all data from the current onto it. Due to backwards compatibility we can't return
        /// the new Document, but it's included in the CopyEventArgs.Document if you subscribe to the AfterCopy event
        /// </summary>
        /// <param name="CopyTo"></param>
        /// <param name="u"></param>
        /// <param name="RelateToOrignal"></param>
        public Document Copy(int CopyTo, User u, bool RelateToOrignal)
        {
            var fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();

            CopyEventArgs e = new CopyEventArgs();
            e.CopyTo = CopyTo;
            FireBeforeCopy(e);
            Document newDoc = null;

            if (!e.Cancel)
            {
                // Make the new document
                newDoc = MakeNew(Text, new DocumentType(ContentType.Id), u, CopyTo);

                if (newDoc != null)
                {
                    // update template if a template is set
                    if (this.Template > 0)
                        newDoc.Template = Template;

                    //update the trashed property as it could be copied inside the recycle bin
                    newDoc.IsTrashed = this.IsTrashed;

                    // Copy the properties of the current document
                    var props = GenericProperties;
                    foreach (Property p in props)
                    {
                        //copy file if it's an upload property (so it doesn't get removed when original doc get's deleted)

                        IDataType uploadField = new Factory().GetNewObject(new Guid("5032a6e6-69e3-491d-bb28-cd31cd11086c"));

                        if (p.PropertyType.DataTypeDefinition.DataType.Id == uploadField.Id
                        && p.Value.ToString() != ""
                        && fs.FileExists(fs.GetRelativePath(p.Value.ToString())))
                        {
                            var currentPath = fs.GetRelativePath(p.Value.ToString());

                            var propId = newDoc.getProperty(p.PropertyType.Alias).Id;
                            var newPath = fs.GetRelativePath(propId, System.IO.Path.GetFileName(currentPath));

                            fs.CopyFile(currentPath, newPath);

                            newDoc.getProperty(p.PropertyType.Alias).Value = fs.GetUrl(newPath);

                            //copy thumbs
                            foreach (var thumbPath in fs.GetThumbnails(currentPath))
                            {
                                var newThumbPath = fs.GetRelativePath(propId, System.IO.Path.GetFileName(thumbPath));
                                fs.CopyFile(thumbPath, newThumbPath);
                            }

                        }
                        else
                        {
                            newDoc.getProperty(p.PropertyType.Alias).Value = p.Value;
                        }

                    }

                    // Relate?
                    if (RelateToOrignal)
                    {
                        Relation.MakeNew(Id, newDoc.Id, RelationType.GetByAlias("relateDocumentOnCopy"), "");

                        // Add to audit trail
                        Log.Add(LogTypes.Copy, u, newDoc.Id, "Copied and related from " + Text + " (id: " + Id.ToString() + ")");
                    }


                    // Copy the children
                    //store children array here because iterating over an Array object is very inneficient.
                    var c = Children;
                    foreach (Document d in c)
                        d.Copy(newDoc.Id, u, RelateToOrignal);

                    e.NewDocument = newDoc;
                }

                FireAfterCopy(e);

            }

            return newDoc;
        }
Exemplo n.º 26
0
 /// <summary>
 /// Raises the <see cref="E:AfterCopy"/> event.
 /// </summary>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected virtual void FireAfterCopy(CopyEventArgs e)
 {
     if (AfterCopy != null)
         AfterCopy(this, e);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Handles cache refreshing for when content is copied
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// When an entity is copied new permissions may be assigned to it based on it's parent, if that is the
 /// case then we need to clear all user permissions cache.
 /// </remarks>
 static void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e)
 {
     //run the un-published cache refresher since copied content is not published
     DistributedCache.Instance.RefreshUnpublishedPageCache(e.Copy);
 }
Exemplo n.º 28
0
 private void OnCopyStatusChanged(object sender, CopyEventArgs e)
 {
     dgInfo.Rows[_mapRows[e.Info]].Cells["Status"].Value = e.Info.GetStatusString();
 }