Beispiel #1
0
        protected override void Process([NotNull] ProcessorArgs args)
        {
            Install9Args   arguments      = (Install9Args)args;
            Task           task           = arguments.Tasker.Tasks.FirstOrDefault(t => t.Name == this.taskName);
            PowerShellTask powershellTask = task as PowerShellTask;

            if (powershellTask != null)
            {
                string result = powershellTask.GetScript();
                if (task.State == TaskState.Failed)
                {
                    throw new AggregateException(string.Format("Failed to execute {0} task. \n{1}", task.Name, result));
                }

                string path = Path.Combine(arguments.Tasker.GlobalParams.First(p => p.Name == "FilesRoot").Value,
                                           string.Format("generated_scripts/{0}", task.UnInstall ? "Uninstall" : "Install"));
                Directory.CreateDirectory(path);

                using (StreamWriter writer = new StreamWriter(Path.Combine(path, string.Format("{0}.ps1", task.Name))))
                {
                    writer.Write(powershellTask.GetScript());
                }
            }
            else
            {
                this.Skip();
            }
        }
        public Wizard(WizardPipeline wizardPipeline, ProcessorArgs args, [NotNull] Func <WizardArgs> createWizardArgs)
        {
            using (new ProfileSection("Create wizard instance", this))
            {
                ProfileSection.Argument("wizardPipeline", wizardPipeline);
                ProfileSection.Argument("args", args);

                WizardArgs = createWizardArgs();
                if (WizardArgs != null)
                {
                    WizardArgs.WizardWindow = this;
                }

                WizardPipeline = wizardPipeline;
                Args           = args;
                InitializeComponent();
                ProgressBar1Foreground = progressBar1.Foreground;
                if (!WinAppSettings.AppSysIsSingleThreaded.Value)
                {
                    CancelButton.IsCancel = false;
                    ResizeMode            = ResizeMode.CanMinimize;
                }
            }

            Initialize();
        }
 public override void Process(ProcessorArgs args)
 {
     var notifyIconManager = Factory.ActualFactory.GetNotifyIconManager();
       args.CurrentNotifyIconChangerClient.SetIcon(
     args.ResolvedHandler != null ? args.ResolvedHandler.DefaultHandlerIcon : this.SuccessTrayIcon,
     1500);
 }
Beispiel #4
0
 public virtual void Process(ProcessorArgs args)
 {
     if (Context.Site?.Properties["enableDianoga"] == "false")
     {
         args.AbortPipeline();
     }
 }
        protected override void Process(ProcessorArgs args)
        {
            string         scriptFile = Path.Combine(Directory.GetCurrentDirectory(), "ContainerFiles/scripts/InstallDockerToolsModuleScript.txt");
            PSFileExecutor ps         = new PSFileExecutor(scriptFile, Directory.GetCurrentDirectory());

            ps.Execute();
        }
        protected override void Process([NotNull] ProcessorArgs args)
        {
            Install9Args arguments = (Install9Args)args;

            if (!arguments.Tasker.UnInstall || arguments.ScriptsOnly)
            {
                this.Skip();
                return;
            }

            InstallParam sqlDbPrefixParam = arguments.Tasker.GlobalParams.FirstOrDefault(p => p.Name == "SqlDbPrefix");

            if (sqlDbPrefixParam != null && !string.IsNullOrEmpty(sqlDbPrefixParam.Value))
            {
                foreach (SitecoreEnvironment sitecoreEnvironment in SitecoreEnvironmentHelper.SitecoreEnvironments)
                {
                    if (sitecoreEnvironment.Name == sqlDbPrefixParam.Value)
                    {
                        SitecoreEnvironmentHelper.SitecoreEnvironments.Remove(sitecoreEnvironment);
                        SitecoreEnvironmentHelper.SaveSitecoreEnvironmentData(SitecoreEnvironmentHelper.SitecoreEnvironments);
                        return;
                    }
                }
            }
        }
        public override long EvaluateStepsCount(ProcessorArgs args)
        {
            var download = (Download8Args)args;
            var count    = download._FileNames.Count(x => RequireDownloading(x.Value, download.LocalRepository));

            return(count * Scale);
        }
Beispiel #8
0
        protected override void ProcessOptimize(ProcessorArgs args)
        {
            if (_supportedExtensionsLookup.Contains(args.InputStream.Extension))
            {
                if (args.ResultStream == null)
                {
                    // MakeStreamSeekable will buffer the stream if its not seekable
                    args.InputStream.MakeStreamSeekable();
                    args.InputStream.Stream.Seek(0, SeekOrigin.Begin);
                }

                var sourceStream = args.ResultStream ?? args.InputStream.Stream;

                var optimizerArgs = new OptimizerArgs(sourceStream, args.MediaOptions);

                CorePipeline.Run(Pipeline, optimizerArgs);

                args.IsOptimized  = optimizerArgs.IsOptimized;
                args.Extension    = optimizerArgs.Extension;
                args.ResultStream = optimizerArgs.Stream;

                if (!string.IsNullOrEmpty(optimizerArgs.Message))
                {
                    args.AddMessage(optimizerArgs.Message);
                }

                if (optimizerArgs.Aborted)
                {
                    args.AbortPipeline();
                }
            }
        }
        public override void Process(ProcessorArgs args)
        {
            var notifyIconManager = Factory.ActualFactory.GetNotifyIconManager();

            args.CurrentNotifyIconChangerClient.SetIcon(
                args.ResolvedHandler != null ? args.ResolvedHandler.DefaultHandlerIcon : this.SuccessTrayIcon,
                1500);
        }
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            Assert.ArgumentNotNull(arguments, "arguments");

            InstallContainerArgs args = (InstallContainerArgs)arguments;

            args.EnvModel.TelerikKey = this._generator.Generate();
        }
            public PipelineStartInfo([NotNull] ProcessorArgs processorArgs, [NotNull] List <Step> steps, [CanBeNull] IPipelineController pipelineController = null)
            {
                Assert.ArgumentNotNull(processorArgs, nameof(processorArgs));
                Assert.ArgumentNotNull(steps, nameof(steps));

                ProcessorArgs      = processorArgs;
                PipelineController = pipelineController;
                _Steps             = steps;
            }
            public PipelineStartInfo([NotNull] ProcessorArgs processorArgs, [NotNull] List <Step> steps, [CanBeNull] IPipelineController pipelineController = null)
            {
                Assert.ArgumentNotNull(processorArgs, "processorArgs");
                Assert.ArgumentNotNull(steps, "steps");

                this.ProcessorArgs      = processorArgs;
                this.PipelineController = pipelineController;
                this.Steps = steps;
            }
Beispiel #13
0
        protected override void ProcessOptimize(ProcessorArgs args)
        {
            var mediaPath = args.InputStream.MediaItem.MediaPath;

            if (IsExcluded(mediaPath))
            {
                args.AbortPipeline();
            }
        }
        protected override void Process(ProcessorArgs args)
        {
            var download = (DownloadArgs)args;

            foreach (var link in download.Links)
            {
                download.FileNames[link] = WebRequestHelper.GetFileName(link, download.Cookies);
            }
        }
Beispiel #15
0
 public Processor(ProcessorArgs processorArgs)
 {
     ProcessorArgs = processorArgs;
     //
     ExternalTools   = new ExternalTools(ProcessorArgs.ConfigurationMain.Paths);
     FileExecution   = new FileExecution(ExternalTools);
     FilePreparation = new FilePreparation(ExternalTools);
     FileInformation = new FileInformation();
 }
Beispiel #16
0
        protected override void Process([NotNull] ProcessorArgs procArgs)
        {
            string command = GetCommand(procArgs);

            string executionFolder = GetExecutionFolder(procArgs);

            this._logger = GetLogger(procArgs);

            RunCommand(executionFolder, command);
        }
Beispiel #17
0
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            InstallContainerArgs args = (InstallContainerArgs)arguments;
            string licensePath        = Path.Combine(args.Destination, "license.xml");

            if (FileSystem.FileSystem.Local.File.Exists(licensePath))
            {
                args.EnvModel.SitecoreLicense = this.converter.Convert(licensePath);
            }
        }
        protected override void Process([NotNull] ProcessorArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            DeleteContainersArgs deleteArgs = (DeleteContainersArgs)args;

            Assert.ArgumentNotNull(deleteArgs, "deleteArgs");

            FileSystem.FileSystem.Local.Directory.DeleteIfExists(deleteArgs.DestinationFolder);
        }
Beispiel #19
0
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            Assert.ArgumentNotNull(arguments, "arguments");

            InstallContainerArgs args = (InstallContainerArgs)arguments;

            if (args.EnvModel.KeyExists(Key))
            {
                args.EnvModel[Key] = this._generator.Generate();
            }
        }
Beispiel #20
0
        /// <summary>
        /// Optimizes a media stream and returns the optimized result. The original stream is closed if processing is successful.
        /// Returns null if processing was unsuccessful.
        /// </summary>
        public virtual MediaStream Process(MediaStream stream, MediaOptions options)
        {
            Assert.ArgumentNotNull(stream, nameof(stream));
            Assert.ArgumentNotNull(options, nameof(options));

            if (!stream.AllowMemoryLoading)
            {
                Log.Error($"Dianoga: Could not resize image as it was larger than the maximum size allowed for memory processing. Media item: {stream.MediaItem.Path}", this);
                return(null);
            }

            //Run optimizer based on extension
            var sw = new Stopwatch();

            sw.Start();

            var result = new ProcessorArgs(stream, options);

            try
            {
                CorePipeline.Run("dianogaOptimize", result);
            }
            catch (Exception exception)
            {
                Log.Error($"Dianoga: Unable to optimize {stream.MediaItem.MediaPath} due to a processing error! It will be unchanged.", exception, this);
                return(null);
            }
            sw.Stop();

            if (result.ResultStream != null && result.ResultStream.CanRead)
            {
                if (result.Message.Length > 0)
                {
                    Log.Info($"Dianoga: messages occurred while optimizing {stream.MediaItem.MediaPath}: {result.Message.Trim()}", this);
                }

                var extension = result.Extension ?? stream.Extension;
                if (result.IsOptimized)
                {
                    Log.Info($"Dianoga: optimized {stream.MediaItem.MediaPath}.{stream.MediaItem.Extension} [original size: {GetDimensions(options)} {result.Statistics.SizeBefore} bytes] [final size: {result.Statistics.SizeAfter} bytes] [saved {result.Statistics.BytesSaved} bytes / {result.Statistics.PercentageSaved:p}] [Optimized in {sw.ElapsedMilliseconds}ms] [Extension {extension}]", this);
                }

                return(new MediaStream(result.ResultStream, extension, stream.MediaItem));
            }

            if (!string.IsNullOrWhiteSpace(result.Message))
            {
                Log.Warn($"Dianoga: unable to optimize {stream.MediaItem.MediaPath}.{stream.MediaItem.Extension} because {result.Message.Trim()}", this);
            }

            // if no message exists that implies that nothing in the dianogaOptimize pipeline acted to optimize - e.g. it's a media type we don't know how to optimize, like PDF.

            return(null);
        }
Beispiel #21
0
        public static void Start(string name, Window owner, ProcessorArgs args, bool?isAsync, Action <WizardArgs> action, Func <WizardArgs> createWizardArgs)
        {
            Log.Info($"Wizard pipeline '{name}' starts");
            using (new ProfileSection("Start wizard"))
            {
                ProfileSection.Argument("name", name);
                ProfileSection.Argument("owner", owner);
                ProfileSection.Argument("args", args);

                WizardPipeline wizardPipeline = Definitions[name];
                var            isSync         = !(isAsync ?? !WinAppSettings.AppSysIsSingleThreaded.Value);
                if (isSync)
                {
                    using (var wizard = CreateWizardWindow(wizardPipeline, args, createWizardArgs))
                    {
                        WindowHelper.ShowDialog(wizard, owner);
                        if (action != null)
                        {
                            var wizardArgs = wizard.WizardArgs;

                            action(wizardArgs);
                        }
                    }
                }
                else
                {
                    var wizard = CreateWizardWindow(wizardPipeline, args, createWizardArgs);
                    if (action != null && !flag)
                    {
                        flag           = true;
                        wizard.Closed += (o, e) =>
                        {
                            try
                            {
                                var wizardArgs = wizard.WizardArgs;

                                action(wizardArgs);
                                flag = false;
                            }
                            finally
                            {
                                wizard.Dispose();
                            }
                        };
                    }
                    else
                    {
                        wizard.Closed += (obj, e) => wizard.Dispose();
                    }

                    WindowHelper.ShowWindow(wizard, owner);
                }
            }
        }
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            Assert.ArgumentNotNull(arguments, "arguments");

            InstallContainerArgs args = (InstallContainerArgs)arguments;

            if (string.IsNullOrEmpty(args.EnvModel.SqlAdminPassword))
            {
                args.EnvModel.SqlAdminPassword = this._generator.Generate();
            }
        }
Beispiel #23
0
        protected override void Process(ProcessorArgs processorArgs)
        {
            var args    = (SetupArgs)processorArgs;
            var profile = ProfileManager.Profile ?? new Profile();

            profile.ConnectionString = args.ConnectionString;
            profile.InstancesFolder  = args.InstancesRootFolderPath;
            profile.License          = args.LicenseFilePath;
            profile.LocalRepository  = args.LocalRepositoryFolderPath;
            ProfileManager.SaveChanges(profile);
        }
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            InstallContainerArgs args = (InstallContainerArgs)arguments;

            SIM.FileSystem.FileSystem.Local.Directory.Copy(args.FilesRoot, args.Destination, true);
            if (FileSystem.FileSystem.Local.File.Exists(args.EnvModel.SitecoreLicense))
            {
                string licensePath = Path.Combine(args.Destination, "license.xml");
                FileSystem.FileSystem.Local.File.Copy(args.EnvModel.SitecoreLicense, licensePath);
            }
        }
        protected override void Process([NotNull] ProcessorArgs args)
        {
            Install9Args arguments = (Install9Args)args;

            if (arguments.Tasker.UnInstall || arguments.ScriptsOnly)
            {
                this.Skip();
                return;
            }
            arguments.UnInstallDataPath = arguments.Tasker.SaveUninstallData(ApplicationManager.UnInstallParamsFolder);
        }
Beispiel #26
0
        protected override void Process([CanBeNull] ProcessorArgs args)
        {
            var tempFolder = ApplicationManager.TempFolder;

            if (!Directory.Exists(tempFolder))
            {
                Directory.CreateDirectory(tempFolder);
            }

            File.WriteAllText(Path.Combine(tempFolder, "agreement-accepted.txt"), @"agreement accepted");
        }
Beispiel #27
0
        protected override void Process([NotNull] ProcessorArgs arguments)
        {
            Assert.ArgumentNotNull(arguments, nameof(arguments));

            InstallContainerArgs args = (InstallContainerArgs)arguments;

            Assert.ArgumentNotNull(args, nameof(args));

            IEnumerable <string> hosts = GetHostNames(args);

            DoUpdate(hosts);
        }
 public override void Process(ProcessorArgs args)
 {
     RequestHandler resolvedHandler = args.ResolvedHandler;
       if (resolvedHandler == null)
       {
     throw new ArgumentException("args.ResolvedHandler");
       }
       if (resolvedHandler.PostmortemRevertValue(args.ResultUrl, args.OriginalUrl, args.ClipboardEvent))
       {
     ClipboardManager.SetValue(args.OriginalUrl, true);
       }
 }
        internal static IRelease GetRelease(ProcessorArgs args)
        {
            args.WriteLine("Downloading metadata...");

            var kernelVersion = args.SitecoreVersion;
            var versionName   = GetVersionName(kernelVersion);
            var version       = GetVersion(versionName);
            var releaseName   = GetReleaseName(kernelVersion);
            var release       = GetRelease(version, releaseName);

            return(release);
        }
        public override void Process(ProcessorArgs args)
        {
            RequestHandler resolvedHandler = args.ResolvedHandler;

            if (resolvedHandler == null)
            {
                throw new ArgumentException("args.ResolvedHandler");
            }
            if (resolvedHandler.PostmortemRevertValue(args.ResultUrl, args.OriginalUrl, args.ClipboardEvent))
            {
                ClipboardManager.SetValue(args.OriginalUrl, true);
            }
        }
        public override void Process(ProcessorArgs args)
        {
            RequestHandler resolvedHandler = args.ResolvedHandler;
              if (resolvedHandler == null)
              {
            throw new ArgumentException("args.ResolvedHandler");
              }

              if (!resolvedHandler.PostExecute(args.ResultUrl, args.ClipboardEvent))
              {
            this.HandleErrorAndAbortPipeline(args, this.NotFoundTrayIcon);
              }
        }
        protected override string GetDestination(ProcessorArgs arguments)
        {
            DeleteContainersArgs args = (DeleteContainersArgs)arguments;

            string destinationFolder = args?.DestinationFolder;

            if (string.IsNullOrEmpty(destinationFolder))
            {
                throw new InvalidOperationException($"destinationFolder is null or empty in {this.GetType().Name}");
            }

            return(destinationFolder);
        }
        public Pipeline([NotNull] PipelineDefinition pipelineDefinition, [NotNull] ProcessorArgs args, [CanBeNull] IPipelineController controller = null, bool isAsync = true)
        {
            Assert.ArgumentNotNull(pipelineDefinition, nameof(pipelineDefinition));
            Assert.ArgumentNotNull(args, nameof(args));

            Controller         = controller;
            PipelineDefinition = pipelineDefinition;
            Title   = pipelineDefinition.Title;
            _Steps  = Step.CreateSteps(PipelineDefinition.Steps, args, controller);
            IsAsync = isAsync;

            // Storing args for restarting pipeline
            ProcessorArgs = args;
        }
 public override void Process(ProcessorArgs args)
 {
     NotifyIconManager notifyIconManager = NotifyIconManager.ActualManager;
       if (args.ClipboardEvent)
       {
     args.CurrentNotifyIconChangerClient = notifyIconManager.GlobalNotifyIconChangerClient;
       }
       else
       {
     args.CurrentNotifyIconChangerClient = args.OriginatorIsGlobalIcon
                                         ? notifyIconManager.GlobalNotifyIconChangerClient
                                         : notifyIconManager.NotifyIconChangerClient;
       }
 }
Beispiel #35
0
 public override void Process(ProcessorArgs args)
 {
     if (!args.ShouldBeShorted && !args.OnlyShorteningRequired)
       {
     return;
       }
       string outputString;
       if (!ShortenerManager.TryShorterUrl(args.ResultUrl, out outputString))
       {
     this.HandleErrorAndAbortPipeline(args, this.ErrorTrayIcon);
       }
       else
       {
     args.ResultUrl = outputString;
       }
 }
Beispiel #36
0
 public override void Process(ProcessorArgs args)
 {
     RequestHandler resolvedHandler;
       if (!RequestHandlerChief.TryToResolveHandler(args, out resolvedHandler))
       {
     if (!args.ClipboardEvent)
     {
       this.HandleErrorAndAbortPipeline(args, this.NotFoundTrayIcon);
     }
     else
     {
       args.Abort();
     }
     return;
       }
       args.ResolvedHandler = resolvedHandler;
 }
Beispiel #37
0
        public override void Process(ProcessorArgs args)
        {
            RequestHandler resolvedHandler = args.ResolvedHandler;
              if (resolvedHandler == null)
              {
            throw new ArgumentException("args.ResolvedHandler");
              }

              string result;
              var notifyIconManager = Factory.ActualFactory.GetNotifyIconManager();
              args.CurrentNotifyIconChangerClient.SetIcon(notifyIconManager.InProgressTrayIcon, 10000000);

              if (!resolvedHandler.TryProcess(args.ResultUrl, out result))
              {
            this.HandleErrorAndAbortPipeline(args, this.ErrorTrayIcon);
            return;
              }
              args.ShouldBeShorted = resolvedHandler.IsShorterEnabled;
              args.ResultUrl = result;
        }
 public override void Process(ProcessorArgs args)
 {
     if (args.ClipboardEvent)
       {
     if (args.PredefinedClipboardValue.IsNullOrEmpty())
     {
       args.Abort();
       return;
     }
     args.ResultUrl = args.PredefinedClipboardValue;
       }
       else
       {
     string currentValue = Factory.ActualFactory.GetClipboardProvider().GetValue();
     if (currentValue.IsNullOrEmpty())
     {
       this.HandleErrorAndAbortPipeline(args, this.NotFoundTrayIcon);
     }
     else
     {
       args.ResultUrl = currentValue;
     }
       }
 }
 public override void Process(ProcessorArgs args)
 {
     ClipboardManager.SetValue(args.ResultUrl, true);
 }
 public override void Process(ProcessorArgs args)
 {
     args.OriginalUrl = args.ResultUrl;
 }