예제 #1
0
        public void SaveJobInfo(object sender, EventArgs args)
        {
            if (args == null)
            {
                return;
            }
            Sitecore.Events.SitecoreEventArgs  arguments = (Sitecore.Events.SitecoreEventArgs)(args);
            Sitecore.Publishing.PublishOptions options   = ((Sitecore.Publishing.Publisher)((arguments).Parameters[0])).Options;
            Item item = options.RootItem;

            if (item == null)
            {
                return;
            }

            //string spName = "dbo.SaveLastPublishLog";
            //String ConnectionString = Sitecore.Configuration.Settings.GetConnectionString("custom");
            //if (!String.IsNullOrWhiteSpace(ConnectionString))
            //{
            //    using (SqlConnection connection = new SqlConnection(ConnectionString))
            //    {
            //        using (SqlCommand command = new SqlCommand(spName, connection))
            //        {
            //            command.CommandType = CommandType.StoredProcedure;

            //            connection.Open();
            //            command.ExecuteNonQuery();
            //        }
            //    }
            //}
        }
        public void ItemDeleted(object sender, EventArgs args)
        {
            Sitecore.Events.SitecoreEventArgs eventArgs = args as Sitecore.Events.SitecoreEventArgs;
            Item item = eventArgs.Parameters[0] as Item;

            GetUserActivity.Log.Info("[" + (object)Context.User.Name + "] deleted item ::: " + item.Name);
        }
        public Item GetEventItem(EventArgs args)
        {
            Sitecore.Events.SitecoreEventArgs eventArgs = args as Sitecore.Events.SitecoreEventArgs;
            Item item = eventArgs.Parameters[0] as Item;

            return(item);
        }
        public void PublishEnd(object sender, EventArgs args)
        {
            Sitecore.Events.SitecoreEventArgs eventArgs = args as Sitecore.Events.SitecoreEventArgs;
            var publisher = eventArgs.Parameters[0] as Sitecore.Publishing.Publisher;
            var item      = publisher.Options.RootItem;

            GetUserActivity.Log.Info("[" + (object)Context.User.Name + "] finished publishing ::: " + item.Paths.FullPath);
        }
        public void ItemCopied(object sender, EventArgs args)
        {
            Sitecore.Events.SitecoreEventArgs eventArgs = args as Sitecore.Events.SitecoreEventArgs;
            Item orgItem   = eventArgs.Parameters[0] as Item;
            Item movedItem = eventArgs.Parameters[1] as Item;

            GetUserActivity.Log.Info("[" + (object)Context.User.Name + "] copied item from \"" + orgItem.Paths.FullPath + "\" to \"" + movedItem.Paths.FullPath + "\"");
        }
예제 #6
0
        public void OnItemSaved(object sender, EventArgs args)
        {
            this.Database = "master";

            Sitecore.Events.SitecoreEventArgs eventArgs = args as Sitecore.Events.SitecoreEventArgs;
            Sitecore.Diagnostics.Assert.IsNotNull(eventArgs, "eventArgs");
            Sitecore.Data.Items.Item item = eventArgs.Parameters[0] as Sitecore.Data.Items.Item;
            Sitecore.Diagnostics.Assert.IsNotNull(item, "item");

            //{22219A9A-27BB-4506-B8C8-70DDA639C7F2} -- is the id of Sitecore PowerShell Extensions admin item
            //sitecore/system/Modules/PowerShell/Settings/ISE/sitecore/admin
            //It autosave the script when we execute.
            //This item shouldn't be tracked at all.
            //It can be added in untracked item as well

            if (item.Database != null && item.ID != new Sitecore.Data.ID("{BECB151A-562F-4D0C-87A7-A3CBAC3220D9}") &&
                item.ID != new Data.ID("{22219A9A-27BB-4506-B8C8-70DDA639C7F2}"))
            {
                try
                {
                    var  trackingItem = Factory.GetDatabase("master").GetItem("{BECB151A-562F-4D0C-87A7-A3CBAC3220D9}");
                    var  newid        = item.ID.ToString();
                    bool doTrackItem  = true;

                    //Do not track if this ID is present in Untrack Items
                    var untrackItemsList = trackingItem["Untrack Items"];
                    if (untrackItemsList != null && !string.IsNullOrWhiteSpace(untrackItemsList) && untrackItemsList.Contains(newid))
                    {
                        doTrackItem = false;
                    }
                    if (doTrackItem)
                    {
                        var currentItemsList = trackingItem["Current Saved Items"];
                        if (string.IsNullOrWhiteSpace(currentItemsList))
                        {
                            trackingItem.Editing.BeginEdit();
                            trackingItem["Current Saved Items"] = newid;
                            trackingItem.Editing.EndEdit();
                        }
                        else
                        {
                            var currentString = trackingItem["Current Saved Items"];
                            if (currentString.Contains(newid))
                            {
                                //Do Nothing
                            }
                            else
                            {
                                trackingItem.Editing.BeginEdit();
                                trackingItem["Current Saved Items"] = currentString + "\r\n" + newid;
                                trackingItem.Editing.EndEdit();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //throw ex;
                    Sitecore.Diagnostics.Log("Sitecore Package Assistant. Error: " + ex.StackTrace);
                }
                finally
                {
                }
            }
        }