Пример #1
0
        /// <summary>
        ///     Determines the preselected profile for the printer that was used while creating the job
        /// </summary>
        /// <param name="jobInfo">The jobinfo used for the decision</param>
        /// <param name="settings">The settings used for the decision</param>
        /// <returns>The profile that is associated with the printer or the default profile</returns>
        private ConversionProfile PreselectedProfile(JobInfo jobInfo, PdfCreatorSettings settings)
        {
            foreach (var mapping in settings.ApplicationSettings.PrinterMappings)
            {
                if (mapping.PrinterName.Equals(jobInfo.SourceFiles[0].PrinterName, StringComparison.OrdinalIgnoreCase))
                {
                    var p = settings.GetProfileByGuid(mapping.ProfileGuid);
                    if (p != null)
                    {
                        return(p);
                    }
                    break;
                }
            }

            var lastUsedProfile = settings.GetLastUsedProfile();

            if (lastUsedProfile != null)
            {
                return(lastUsedProfile);
            }

            // try default profile
            var defaultProfile = GetDefaultProfile(settings.ConversionProfiles);

            if (defaultProfile != null)
            {
                return(defaultProfile);
            }

            // last resort: first profile from the list
            return(settings.ConversionProfiles[0]);
        }
Пример #2
0
        /// <summary>
        ///     Determines the preselected profile for the printer that was used while creating the job
        /// </summary>
        /// <param name="jobInfo">The jobinfo used for the decision</param>
        /// <param name="settings">The settings used for the decision</param>
        /// <returns>The profile that is associated with the printer or the default profile</returns>
        private ConversionProfile PreselectedProfile(JobInfo jobInfo, PdfCreatorSettings settings)
        {
            ConversionProfile profile = null;

            foreach (var mapping in settings.ApplicationSettings.PrinterMappings)
            {
                if (mapping.PrinterName.Equals(jobInfo.SourceFiles[0].PrinterName, StringComparison.OrdinalIgnoreCase))
                {
                    profile = settings.GetProfileByGuid(mapping.ProfileGuid);

                    if (mapping.ProfileGuid == ProfileGuids.LAST_USED_PROFILE_GUID)
                    {
                        profile = settings.GetLastUsedProfile();
                    }

                    if (profile != null)
                    {
                        break;
                    }
                }
            }

            //consider LastUsedProfile
            //todo: Do not relate to empty string and use own GUID to request LastUsedProfile (see above)
            if (jobInfo.SourceFiles.Count > 0 && string.IsNullOrEmpty(jobInfo.SourceFiles[0].PrinterName))
            {
                var lastUsedProfile = settings.GetLastUsedProfile();
                if (lastUsedProfile != null)
                {
                    profile = lastUsedProfile;
                }
            }

            //Consider commandline paramaters
            if (_parametersManager.HasPredefinedParameters())
            {
                var parameters       = _parametersManager.GetAndResetParameters();
                var profileParameter = parameters.Profile;
                if (!string.IsNullOrEmpty(profileParameter))
                {
                    profile = settings.GetProfileByName(profileParameter);
                    if (profile == null)
                    {
                        profile = settings.GetProfileByGuid(profileParameter);
                    }
                }

                var outputFile = parameters.Outputfile;
                if (outputFile != null)
                {
                    jobInfo.OutputFileParameter = outputFile;
                }
            }

            if (profile != null)
            {
                return(profile);
            }

            // try default profile
            var defaultProfile = GetDefaultProfile(settings.ConversionProfiles);

            if (defaultProfile != null)
            {
                return(defaultProfile);
            }

            // last resort: first profile from the list
            return(settings.ConversionProfiles[0]);
        }