public void ConvertDirectly(IList <string> files, AppStartParameters appStartParameters = null)
        {
            var infFile = "";

            if (appStartParameters != null && appStartParameters.Merge)
            {
                infFile = _directConversionInfFileHelper.TransformToInfFileWithMerge(files, appStartParameters);
            }
            else
            {
                infFile = appStartParameters != null?
                          _directConversionInfFileHelper.TransformToInfFile(files.First(), appStartParameters) :
                              _directConversionInfFileHelper.TransformToInfFile(files.First());
            }

            if (string.IsNullOrEmpty(infFile))
            {
                return;
            }

            Logger.Debug("Adding new job.");
            var jobInfo = _jobInfoManager.ReadFromInfFile(infFile);

            _jobInfoQueue.Add(jobInfo);
        }
Example #2
0
        public void ConvertDirectly(string file, AppStartParameters appStartParameters = null)
        {
            var infFile = appStartParameters != null?
                          _directConversionInfFileHelper.TransformToInfFile(file, appStartParameters) :
                              _directConversionInfFileHelper.TransformToInfFile(file);

            if (string.IsNullOrEmpty(infFile))
            {
                return;
            }

            Logger.Debug("Adding new job.");
            var jobInfo = _jobInfoManager.ReadFromInfFile(infFile);

            _jobInfoQueue.Add(jobInfo);
        }
Example #3
0
        private SourceFileInfo CreateSourceFileInfo(JobFolderFile jobFolderFile, AppStartParameters appStartParameters)
        {
            var sourceFileInfo = new SourceFileInfo();

            sourceFileInfo.Filename            = jobFolderFile.FileInJobFolder;
            sourceFileInfo.Author              = Environment.UserName;
            sourceFileInfo.ClientComputer      = Environment.MachineName.Replace("\\", "");
            sourceFileInfo.Copies              = 1;
            sourceFileInfo.DocumentTitle       = PathSafe.GetFileNameWithoutExtension(jobFolderFile.OriginalFilePath);
            sourceFileInfo.OriginalFilePath    = jobFolderFile.OriginalFilePath;
            sourceFileInfo.JobCounter          = 0;
            sourceFileInfo.JobId               = 0;
            sourceFileInfo.PrinterParameter    = appStartParameters.Printer;
            sourceFileInfo.ProfileParameter    = appStartParameters.Profile;
            sourceFileInfo.OutputFileParameter = appStartParameters.OutputFile;
            sourceFileInfo.SessionId           = Process.GetCurrentProcess().SessionId;
            sourceFileInfo.TotalPages          = _directConversionHelper.GetNumberOfPages(jobFolderFile.FileInJobFolder);
            sourceFileInfo.Type       = JobType.PsJob;
            sourceFileInfo.WinStation = Environment.GetEnvironmentVariable("SESSIONNAME");

            return(sourceFileInfo);
        }
Example #4
0
        /// <summary>
        ///     Create unique job folder in spool folder and copy ps file to it.
        ///     Create inf file from ps file.
        /// </summary>
        /// <returns>inf file in spool folder</returns>
        public string TransformToInfFileWithMerge(IList <string> directConversionFiles, AppStartParameters appStartParameters)
        {
            if (directConversionFiles.Count <= 0)
            {
                return("");
            }

            foreach (var file in directConversionFiles)
            {
                if (string.IsNullOrWhiteSpace(file))
                {
                    return("");
                }

                if (!_file.Exists(file))
                {
                    Logger.Error("The file \"" + file + "\" does not exist.");
                    return("");
                }
            }

            string jobFolder;

            try
            {
                jobFolder = CreateJobFolderInSpool(directConversionFiles[0]);
            }
            catch (Exception ex)
            {
                Logger.Error("Error while creating spool directory for ps-job:\r\n" + ex.Message);
                return("");
            }

            try
            {
                var jobFolderFile = CopyFilesToJobFolder(jobFolder, directConversionFiles);
                return(CreateInfFile(jobFolderFile, jobFolder, appStartParameters));
            }
            catch (Exception ex)
            {
                Logger.Error("Error while coping ps-file in spool folder:\r\n" + ex.Message);
                _directory.Delete(jobFolder, true); //Delete created folder and files
                return("");
            }
        }
Example #5
0
 public string TransformToInfFile(string directConversionFile, AppStartParameters appStartParameters)
 {
     return(TransformToInfFileWithMerge(new List <string> {
         directConversionFile
     }, appStartParameters));
 }
Example #6
0
        private string CreateInfFile(IList <JobFolderFile> jobFolderFiles, string jobFolder, AppStartParameters appStartParameters)
        {
            var firstDirectConversionFile = jobFolderFiles[0].OriginalFilePath;

            var fileName      = PathSafe.GetFileName(firstDirectConversionFile);
            var shortFileName = fileName;

            if (fileName.Length > 12)
            {
                shortFileName = fileName.Substring(0, 12);
            }

            var infFile = PathSafe.Combine(jobFolder, shortFileName + ".inf");

            var jobInfo = new JobInfo();

            foreach (var jobFolderFile in jobFolderFiles)
            {
                var sfi = CreateSourceFileInfo(jobFolderFile, appStartParameters);
                jobInfo.SourceFiles.Add(sfi);
            }

            _jobInfoManager.SaveToInfFile(jobInfo, infFile);
            Logger.Debug("Created inf-file for ps-file: " + infFile);

            return(infFile);
        }