Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            if (!SecurityHelper.CanRunApplication("PowerShell/PowerShell Console") ||
                ServiceAuthorizationManager.TerminateUnauthorizedRequest(WebServiceSettings.ServiceClient,
                                                                         Context.User?.Name))
            {
                PowerShellLog.Error($"User {Context.User?.Name} attempt to access PowerShell Console - denied.");
                return;
            }
            base.OnLoad(e);

            UpdateWarning();

            Settings = ApplicationSettings.GetInstance(ApplicationNames.Context, false);
            HttpContext.Current.Response.AddHeader("X-UA-Compatible", "IE=edge");
            var settings = ApplicationSettings.GetInstance(ApplicationNames.Console, false);

            if (!Context.ClientPage.IsEvent)
            {
                Options.Text = @"<script type='text/javascript'>" +
                               @"$ise(function() { cognifide.powershell.setOptions({ initialPoll: " +
                               WebServiceSettings.InitialPollMillis + @", maxPoll: " +
                               WebServiceSettings.MaxmimumPollMillis + @", fontSize: " +
                               settings.FontSize + $", fontFamily: '{settings.FontFamilyStyle}' }});}});</script>" +
                               @"<style>#terminal {" +
                               $"color: {OutputLine.ProcessHtmlColor(settings.ForegroundColor)};" +
                               $"background-color: {OutputLine.ProcessHtmlColor(settings.BackgroundColor)};" +
                               $"font-family: inherit;" + "}</style>";
            }
            SheerResponse.SetDialogValue("ok");
        }
        private bool DisableAssignSecurityButton(Item button)
        {
            var flag = button.ID == FieldButtonIDs.AssignSecurity &&
                       (!SecurityHelper.CanRunApplication("Content Editor/Ribbons/Chunks/Security/Assign") ||
                        !SecurityHelper.CanRunApplication("Security/Item Security Editor"));

            return(flag);
        }
        protected override void OnLoad(EventArgs e)
        {
            if (!SecurityHelper.CanRunApplication("Turbo Console/Turbo Console"))
            {
                return;
            }
            base.OnLoad(e);

            ContextWebsite = "website";    //TODO: Implement dynamic assignment
            if (this.Monitor.IsNull())
            {
                if (!Context.ClientPage.IsEvent)
                {
                    Monitor = new ConsoleJobMonitor {
                        ID = "Monitor"
                    };
                    Context.ClientPage.Controls.Add(Monitor);
                }
                else
                {
                    Monitor = (ConsoleJobMonitor)Context.ClientPage.FindControl("Monitor");
                }
            }
            Monitor.JobFinished += MonitorOnJobFinished;
            if (Sitecore.Context.ClientPage.IsEvent)
            {
                return;
            }

            var settings = ApplicationSettings.GetInstance(ApplicationNames.Console);

            if (settings.SaveLastScript)
            {
                Editor.Value = settings.LastScript;
            }

            CurrentSessionId = DefaultSessionName;
            ContextWebsite   = "website";  //TODO: Implement dynamic assignment
            UpdateRibbon();
        }
Exemple #4
0
        protected override void OnLoad(EventArgs e)
        {
            if (!SecurityHelper.CanRunApplication("PowerShell/PowerShellIse") ||
                ServiceAuthorizationManager.TerminateUnauthorizedRequest(WebServiceSettings.ServiceClient,
                                                                         Context.User.Name))
            {
                PowerShellLog.Error($"User {Context.User?.Name} attempt to access PowerShell ISE - denied.");
                return;
            }

            base.OnLoad(e);

            if (Monitor == null)
            {
                if (!Context.ClientPage.IsEvent)
                {
                    Monitor = new SpeJobMonitor {
                        ID = "Monitor"
                    };
                    Context.ClientPage.Controls.Add(Monitor);
                }
                else
                {
                    Monitor = (SpeJobMonitor)Context.ClientPage.FindControl("Monitor");
                }
            }
            Monitor.JobFinished += MonitorOnJobFinished;
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var settings = ApplicationSettings.GetInstance(ApplicationNames.ISE);

            if (settings.SaveLastScript)
            {
                Editor.Value = settings.LastScript;
            }

            var itemId = WebUtil.GetQueryString("id");
            var itemDb = WebUtil.GetQueryString("db");

            if (itemId.Length > 0)
            {
                ScriptItemId = itemId;
                ScriptItemDb = itemDb;
                LoadItem(itemDb, itemId);
            }

            ContextItemDb = Context.ContentDatabase.Name;
            var contextItem = Context.ContentDatabase.GetItem(Context.Site.ContentStartPath) ??
                              UIUtil.GetHomeItem(Context.User);

            ContextItemId = contextItem?.ID.ToString() ?? String.Empty;

            CurrentSessionId = DefaultSessionName;
            CurrentUser      = DefaultUser;
            CurrentLanguage  = DefaultLanguage;
            ParentFrameName  = WebUtil.GetQueryString("pfn");
            UpdateRibbon();
        }