Beispiel #1
0
 public virtual void SetLanguage(string language)
 {
     if (CurrentVersion.IsAtLeast(SitecoreVersion.V71))
     {
         SetLanguageInternal(language);
     }
 }
Beispiel #2
0
        protected virtual void UpdateSettings(ClientPipelineArgs args)
        {
            var settings        = ApplicationSettings.GetInstance(ApplicationNames.ISE);
            var backgroundColor = OutputLine.ProcessHtmlColor(settings.BackgroundColor);
            var bottomPadding   = CurrentVersion.IsAtLeast(SitecoreVersion.V80) ? 0 : 10;

            SheerResponse.Eval(
                $"spe.changeSettings('{settings.FontFamilyStyle}', {settings.FontSize}, '{backgroundColor}', {bottomPadding}, {settings.LiveAutocompletion.ToString().ToLower()});");
        }
        public static string GetIcon(this Language language)
        {
            var db   = Factory.GetDatabase(ApplicationSettings.ScriptLibraryDb);
            var icon = db != null?language.GetIcon(db) : string.Empty;

            return(!string.IsNullOrEmpty(icon)
                ? icon
                : CurrentVersion.IsAtLeast(SitecoreVersion.V80)
                    ? "Office/32x32/flag_generic.png"
                    : "Flags/32x32/flag_generic.png");
        }
Beispiel #4
0
        protected virtual void UpdateSettings(ClientPipelineArgs args)
        {
            var settings        = ApplicationSettings.GetInstance(ApplicationNames.IseConsole);
            var db              = Factory.GetDatabase(ApplicationSettings.ScriptLibraryDb);
            var fonts           = db.GetItem(ApplicationSettings.FontNamesPath);
            var font            = string.IsNullOrEmpty(settings.FontFamily) ? "monospace" : settings.FontFamily;
            var fontItem        = fonts.Children[font];
            var backgroundColor = OutputLine.ProcessHtmlColor(settings.BackgroundColor);

            font = fontItem != null
                ? fontItem["Phrase"]
                : "Monaco, Menlo, \"Ubuntu Mono\", Consolas, source-code-pro, monospace";
            var bottomPadding = CurrentVersion.IsAtLeast(SitecoreVersion.V80) ? 0 : 10;

            SheerResponse.Eval(
                $"cognifide.powershell.changeSettings('{font}', {settings.FontSize}, '{backgroundColor}', {bottomPadding}, {settings.LiveAutocompletion.ToString().ToLower()});");
        }
Beispiel #5
0
        private static Assembly LoadVersionAssembly(string assemblyNamespace, string assemblyName)
        {
            var resourceName = CurrentVersion.IsAtLeast(SitecoreVersion.V92) ?
                               $"{assemblyNamespace}.Resources.Version92." + assemblyName + ".dll" :
                               $"{assemblyNamespace}.Resources.Version8." + assemblyName + ".dll";

            var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

            if (stream == null)
            {
                return(null);
            }

            using (stream)
            {
                var data = new byte[stream.Length];
                stream.Read(data, 0, data.Length);
                return(Assembly.Load(data));
            }
        }
        protected virtual void UpdateProgress(ClientPipelineArgs args)
        {
            var sb = new StringBuilder();

            var activity = args.Parameters["Activity"];

            Title.Text = string.IsNullOrEmpty(activity) ? Texts.PowerShellRunner_UpdateProgress_Running_script___ : activity;

            var status     = args.Parameters["StatusDescription"];
            var showStatus = !string.IsNullOrEmpty(status);

            bool isSitecore8 = CurrentVersion.IsAtLeast(SitecoreVersion.V80);

            PsProgressStatus.Visible = showStatus && isSitecore8;
            Subtitle.Visible         = showStatus && !isSitecore8;

            if (isSitecore8)
            {
                PsProgressStatus.Text = showStatus
                ? $"<span class='status'>{status}   </span><br/>"
                    : "<span class='status'> </span><br/>";
            }
            else
            {
                Subtitle.Text = showStatus
                ? string.Format("<span class='status'>" +
                                Texts.PowerShellRunner_UpdateProgress_Status_ +
                                " {0}</span>", status)
                : "<span class='status'> </span>";
            }
            if (args.Parameters["RecordType"] == ProgressRecordType.Completed.ToString())
            {
                PsProgress.Text = string.Empty;
                if (!string.IsNullOrEmpty(CurrentProgressValue.Text))
                {
                    SheerResponse.Eval(@"undeterminateProgress('#progressbar');");
                }
                CurrentProgressValue.Text  = "";
                PreviousProgressValue.Text = "";
            }
            else
            {
                if (!string.IsNullOrEmpty(args.Parameters["PercentComplete"]))
                {
                    CurrentProgressValue.Text = args.Parameters["PercentComplete"];
                }

                if (!string.IsNullOrEmpty(args.Parameters["SecondsRemaining"]))
                {
                    var secondsRemaining = Int32.Parse(args.Parameters["SecondsRemaining"]);
                    if (secondsRemaining > -1)
                    {
                        sb.AppendFormat(
                            "<span class='timeRemaining'><span class='label'>" +
                            Texts.PowerShellRunner_UpdateProgress_Time_remaining_ +
                            "</span> {0:c}</span><br/>",
                            new TimeSpan(0, 0, 0, secondsRemaining));
                    }
                }

                if (!string.IsNullOrEmpty(args.Parameters["CurrentOperation"]))
                {
                    sb.AppendFormat("<span class='operation'><span class='label'>" +
                                    Texts.PowerShellRunner_UpdateProgress_Operation_ +
                                    "</span> {0}</span>",
                                    args.Parameters["CurrentOperation"]);
                }

                PsProgress.Text = sb.ToString();
            }
        }