public override void Execute(object obj)
        {
            if (_architectCheck.IsInstalled())
            {
                var files = GetPaths(obj);

                string          architectPath = _architectCheck.GetInstallationPath();
                FileVersionInfo info          = FileVersionInfo.GetVersionInfo(architectPath);
                var             version       = new Version(info.ProductVersion);

                if (version >= MinimumArchitectPrintDialogVersion)
                {
                    foreach (var file in files)
                    {
                        PrintWithArchitect(file);
                    }
                }
                else
                {
                    _recommendArchitectUpgrade.Show();
                }
            }
            else
            {
                _recommendArchitectAssistant.Show();
            }
        }
        public void CreateViewModel_CallLaunchPDFArchitectCommand_ProcessStarterIsCalledWithApplicationPath()
        {
            var viewModel = BuildArchitectViewModel();
            var appPath   = "TestPath";

            _pdfArchitectCheck.GetInstallationPath().Returns(appPath);

            viewModel.LaunchPdfArchitectCommand.Execute(null);

            _processStarter.Received().Start(Arg.Is(appPath));
        }
Ejemplo n.º 3
0
        public ActionResult OpenWithArchitect(List <string> files)
        {
            var architectPath = _pdfArchitectCheck.GetInstallationPath();

            Logger.Debug("Open with PDF Architect");

            if (_pdfArchitectCheck.IsInstalled())
            {
                try
                {
                    foreach (var file in files)
                    {
                        _processStarter.Start(architectPath, "\"" + file + "\"");
                        Logger.Trace("Openend: " + file);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "PDF Architect could not open file(s):\r\n" + string.Join("\r\n", files));
                    return(new ActionResult(ErrorCode.Viewer_ArchitectCouldNotOpenOutput));
                }
            }
            else
            {
                _recommendArchitectAssistant.Show();
            }

            return(new ActionResult());
        }
Ejemplo n.º 4
0
 private string GetArchitectPath()
 {
     try
     {
         return(_architectCheck.GetInstallationPath());
     }
     catch (Exception ex)
     {
         Logger.Warn(ex, "There was an exception while checking the PDF Architect path");
         return(null);
     }
 }
Ejemplo n.º 5
0
        public ActionResult OpenWithArchitect(string filePath)
        {
            string architectPath = _pdfArchitectCheck.GetInstallationPath();

            Logger.Debug("Open with PDF Architect");
            try
            {
                _processStarter.Start(architectPath, "\"" + filePath + "\"");
                Logger.Trace("Openend: " + filePath);
            }
            catch
            {
                Logger.Error("PDF Architect could not open file: " + filePath);
                return(new ActionResult(ErrorCode.Viewer_ArchitectCouldNotOpenOutput));
            }
            return(new ActionResult());
        }
        public void SetUp()
        {
            _settings           = new PdfCreatorSettings();
            _fileAssoc          = Substitute.For <IFileAssoc>();
            _recommendArchitect = Substitute.For <IRecommendArchitect>();
            _pdfArchitectCheck  = Substitute.For <IPdfArchitectCheck>();
            _pdfArchitectCheck.GetInstallationPath().Returns(ArchitectPath);
            _settingsProvider = Substitute.For <ISettingsProvider>();
            _settingsProvider.Settings.Returns(_settings);
            _outputFormatHelper         = new OutputFormatHelper();
            _processStarter             = Substitute.For <IProcessStarter>();
            _defaultViewerCheck         = Substitute.For <IDefaultViewerCheck>();
            _defaultViewer              = new DefaultViewer();
            _defaultViewer.OutputFormat = OutputFormat.Pdf;
            _defaultViewer.Path         = DefaultViewerPath;
            _settings.DefaultViewers.Add(_defaultViewer);
            _job = new Job(new JobInfo(), new ConversionProfile(), new Accounts());

            _profile = new ConversionProfile();

            _defaultViewerAction = new DefaultViewerAction(_fileAssoc, _recommendArchitect, _pdfArchitectCheck, _settingsProvider, _outputFormatHelper, _processStarter, _defaultViewerCheck);
        }
        /// <summary>
        ///     Open all files in the default viewer
        /// </summary>
        /// <param name="job">Job information</param>
        /// <returns>An ActionResult to determine the success and a list of errors</returns>
        public ActionResult ProcessJob(Job job)
        {
            Logger.Debug("Launched Viewer-Action");

            var isPdfFile = job.Profile.OutputFormat == OutputFormat.Pdf ||
                            job.Profile.OutputFormat == OutputFormat.PdfA1B ||
                            job.Profile.OutputFormat == OutputFormat.PdfA2B ||
                            job.Profile.OutputFormat == OutputFormat.PdfX;

            if (!isPdfFile)
            {
                return(OpenJobOutput(job));
            }

            if (job.Profile.OpenWithPdfArchitect)
            {
                string architectPath = null;

                try
                {
                    architectPath = _architectCheck.GetInstallationPath();
                }
                catch (Exception ex)
                {
                    Logger.Warn(ex, "There was an exception while checking the PDF Architect path");
                }

                if (architectPath != null)
                {
                    Logger.Debug("Open with PDF Architect");
                    foreach (var file in job.OutputFiles)
                    {
                        try
                        {
                            var p = new Process();
                            p.StartInfo.FileName  = architectPath;
                            p.StartInfo.Arguments = "\"" + file + "\"";
                            p.Start();
                            Logger.Trace("Openend: " + file);
                        }
                        catch
                        {
                            Logger.Error("PDF Architect could not open file: " + file);
                            return(new ActionResult(ErrorCode.Viewer_ArchitectCouldNotOpenOutput));
                        }
                    }
                    return(new ActionResult());
                }
                Logger.Warn("Open with PDF Architect selected, but not installed");
            }

            if (!_fileAssoc.HasOpen(".pdf"))
            {
                Logger.Error("No program associated with pdf.");

                var displayed = _recommendArchitect.Show();
                if (displayed)
                {
                    return(new ActionResult()); //return true, to avoid another message window.
                }
            }

            return(OpenJobOutput(job));
        }