/// <summary>
        /// Determine the Destination Folder of the item if it is to be automatically categorized.
        /// </summary>
        /// <returns>The newly created Item.</returns>
        protected override Item DoExecute()
        {
            if (this.CanAddToBucket() && this.TemplateId != Config.BucketTemplateId)
            {
                Item newDestination = BucketManager.CreateAndReturnDateFolderDestination(this.Destination, DateTime.Now);
                newDestination = newDestination.Database.GetItem(newDestination.ID, this.Destination.Language);

                if (newDestination != null && !newDestination.Uri.Equals(this.Destination.Uri))
                {
                    EventResult eventResult = Event.RaiseEvent("item:bucketing:adding", new object[] { this.NewId, this.ItemName, this.TemplateId, newDestination }, this);
                    if (eventResult.Cancel)
                    {
                        Log.Info(string.Format("Event {0} was cancelled", "item:bucketing:adding"), this);
                        return(null);
                    }

                    Item item = Nexus.DataApi.AddFromTemplate(this.TemplateId, newDestination, this.ItemName, this.NewId);

                    if (item.IsNotNull())
                    {
                        item.Editing.BeginEdit();
                        item["__BucketParentRef"] = this.Destination.ID.ToString();
                        item.Editing.EndEdit();
                        this.SetLocation(item);
                    }

                    Event.RaiseEvent("item:bucketing:added", new object[] { item }, this);
                    return(item);
                }
            }

            return(base.DoExecute());
        }
Esempio n. 2
0
        // Methods
        public new void Execute(CopyItemsArgs args)
        {
            Event.RaiseEvent("item:bucketing:cloning", args, this);
            Assert.ArgumentNotNull(args, "args");
            var items = GetItems(args);

            if (args.IsNotNull())
            {
                var itemId = args.Parameters["destination"];
                if (itemId.IsNotNull())
                {
                    var database = GetDatabase(args);
                    if (database.GetItem(itemId).IsBucketItemCheck())
                    {
                        var list = new ArrayList();
                        foreach (var item3 in from item2 in items
                                 where item2.IsNotNull()
                                 let item = BucketManager.CreateAndReturnDateFolderDestination(database.GetItem(itemId), item2)
                                            let copyOfName = ItemUtil.GetCopyOfName(item, item2.Name)
                                                             select item2.CloneTo(item, copyOfName, true))
                        {
                            list.Add(item3);
                        }

                        args.Copies = list.ToArray(typeof(Item)) as Item[];
                        Event.RaiseEvent("item:bucketing:cloned", args, this);
                        args.AbortPipeline();
                    }
                }
            }
        }
        public new void Execute(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            var database = Factory.GetDatabase(args.Parameters["database"]);

            Assert.IsNotNull(database, args.Parameters["database"]);
            var str  = args.Parameters["id"];
            var item = database.Items[str];

            if (item.IsNull())
            {
                SheerResponse.Alert("Item not found.", new string[0]);
                args.AbortPipeline();
            }
            else
            {
                var parent = item.Parent;
                if (parent.IsNull())
                {
                    SheerResponse.Alert("Cannot duplicate the root item.", new string[0]);
                    args.AbortPipeline();
                }
                else if (parent.Access.CanCreate())
                {
                    Log.Audit(this, "Duplicate item: {0}", new[] { AuditFormatter.FormatItem(item) });

                    var parentBucketOfItem = item.GetParentBucketItemOrSiteRoot();
                    if (BucketManager.IsBucket(parentBucketOfItem))
                    {
                        var duplicatedItem = Context.Workflow.DuplicateItem(item, args.Parameters["name"]);
                        var newDestination = BucketManager.CreateAndReturnDateFolderDestination(parentBucketOfItem, DateTime.Now);
                        if (!item.Template.IsBucketTemplateCheck())
                        {
                            newDestination = parentBucketOfItem;
                        }
                        Event.RaiseEvent("item:bucketing:duplicating", args, this);
                        ItemManager.MoveItem(duplicatedItem, newDestination);
                        Event.RaiseEvent("item:bucketing:duplicated", args, this);
                        Log.Info("Item " + duplicatedItem.ID + " has been duplicated to another bucket", this);
                    }
                    else
                    {
                        Context.Workflow.DuplicateItem(item, args.Parameters["name"]);
                    }
                }
                else
                {
                    SheerResponse.Alert(Translate.Text("You do not have permission to duplicate \"{0}\".", new object[] { item.DisplayName }), new string[0]);
                    args.AbortPipeline();
                }
            }

            args.AbortPipeline();
        }
Esempio n. 4
0
        private void StartProcess(params object[] parameters)
        {
            var contextItem = (Item)parameters[0];
            var topParent   = (Item)parameters[1];
            var recurse     = (bool)parameters[2];

            using (new EditContext(contextItem, SecurityCheck.Disable))
            {
                ItemManager.CopyItem(contextItem, BucketManager.CreateAndReturnDateFolderDestination(topParent, DateTime.Now), recurse);
            }
        }
        /// <summary>
        /// Determine the Destination Folder of the item if it is to be automatically categorised
        /// </summary>
        /// <returns>The newly created Item</returns>
        protected override Item DoExecute()
        {
            if (this.CanAddToBucket())
            {
                var newDestination = BucketManager.CreateAndReturnDateFolderDestination(Destination, DateTime.Now);
                if (newDestination.IsNotNull() && !newDestination.Uri.Equals(Destination.Uri))
                {
                    Event.RaiseEvent("item:bucketing:adding", new object[] { this.NewId, this.ItemName, this.TemplateId, newDestination }, this);

                    var item = Nexus.DataApi.AddFromTemplate(TemplateId, newDestination, ItemName, NewId);

                    if (newDestination.IsNotNull())
                    {
                        this.SetLocation(item);
                    }

                    Event.RaiseEvent("item:bucketing:added", new object[] { item }, this);
                    return(item);
                }
            }

            return(base.DoExecute());
        }
        public new void Execute(ClientPipelineArgs args)
        {
            Event.RaiseEvent("item:bucketing:dragInto", args, this);
            Assert.ArgumentNotNull(args, "args");
            Database database = GetDatabase(args);
            Item     source   = GetSource(args, database);
            Item     target   = GetTarget(args);

            if (args.Parameters["copy"] == "1")
            {
                if (BucketManager.IsBucket(target))
                {
                    Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute("Copying Items", "Copying Items",
                                                                                 Images.GetThemedImageSource(
                                                                                     "Business/16x16/chest_add.png"),
                                                                                 this.StartProcess,
                                                                                 new object[]
                    {
                        source,
                        BucketManager.
                        CreateAndReturnDateFolderDestination
                            (target, DateTime.Now), true, args
                    });

                    if (source.IsNotNull())
                    {
                        Log.Info("Item " + source.ID + " has been copied to another bucket", this);
                    }
                }
            }
            else
            {
                if (BucketManager.IsBucket(target))
                {
                    Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute("Moving Items", "Moving Items",
                                                                                 Images.GetThemedImageSource(
                                                                                     "Business/16x16/chest_add.png"),
                                                                                 this.StartMoveProcess,
                                                                                 new object[]
                    {
                        source,
                        BucketManager.
                        CreateAndReturnDateFolderDestination
                            (target, DateTime.Now), args
                    });
                }
            }


            Event.RaiseEvent("item:bucketing:dragged", args, this);

            //Assert.ArgumentNotNull(args, "args");
            //var items = GetItems(args);
            //Item currentItem = null;
            //if (items[0].IsNotNull())
            //{
            //    currentItem = items[0];
            //}

            //Error.AssertItem(items[0], "Item");
            //var database = GetDatabase(args);
            //var topParent = database.GetItem(args.Parameters["destination"]);
            //if (BucketManager.IsBucket(topParent))
            //{
            //    Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute("Copying Items", "Copying Items", Images.GetThemedImageSource("Business/16x16/chest_add.png"), this.StartProcess, new object[] { currentItem, BucketManager.CreateAndReturnDateFolderDestination(topParent, DateTime.Now), true });

            //    if (currentItem.IsNotNull())
            //    {
            //        Log.Info("Item " + currentItem.ID + " has been copied to another bucket", this);
            //    }

            //    Event.RaiseEvent("item:bucketing:copied", args, this);
            //    args.AbortPipeline();
            //}
        }
Esempio n. 7
0
        public new void Execute(CopyItemsArgs args)
        {
            Event.RaiseEvent("item:bucketing:copying", args, this);
            Assert.ArgumentNotNull(args, "args");
            var  items       = GetItems(args);
            Item currentItem = null;

            if (items[0].IsNotNull())
            {
                currentItem = items[0];
            }

            Error.AssertItem(items[0], "Item");
            var database  = GetDatabase(args);
            var topParent = database.GetItem(args.Parameters["destination"]);

            if (BucketManager.IsBucket(topParent))
            {
                Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute("Copying Items", "Copying Items", Images.GetThemedImageSource("Business/16x16/chest_add.png"), this.StartProcess, new object[] { currentItem, BucketManager.CreateAndReturnDateFolderDestination(topParent, DateTime.Now), true });

                if (currentItem.IsNotNull())
                {
                    Log.Info("Item " + currentItem.ID + " has been copied to another bucket", this);
                }

                Event.RaiseEvent("item:bucketing:copied", args, this);
                args.AbortPipeline();
            }
        }
        public new void Execute(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            var contentDatabase = Context.ContentDatabase;

            if (BucketManager.IsBucket(contentDatabase.GetItem(args.Parameters["target"])))
            {
                var item = contentDatabase.GetItem(args.Parameters["items"]);
                Event.RaiseEvent("item:bucketing:moving", args, this);
                Shell.Applications.Dialogs.ProgressBoxes.ProgressBox.Execute("Moving Items", "Moving Items", Images.GetThemedImageSource("Business/16x16/chest_add.png"), this.StartProcess, new object[] { item, BucketManager.CreateAndReturnDateFolderDestination(contentDatabase.GetItem(args.Parameters["target"]), DateTime.Now) });
                Event.RaiseEvent("item:bucketing:moved", args, this);
                Log.Info("Item " + item.ID + " has been moved to another bucket", this);
                Context.ClientPage.SendMessage(this, "item:refreshchildren(id=" + item.Parent.ID + ")");
                args.AbortPipeline();
            }
        }