Exemple #1
0
        public void SaveToInfFile(JobInfo jobInfo)
        {
            if (string.IsNullOrEmpty(jobInfo.InfFile))
            {
                throw new InvalidOperationException("The inf file must not be empty");
            }

            var infData = Data.CreateDataStorage();
            var ini     = new IniStorage(Encoding.GetEncoding("Unicode"));

            ini.SetData(infData);

            var sourceFileReader = new SourceFileInfoDataReader();

            var sectionId = 0;

            foreach (var sourceFileInfo in jobInfo.SourceFiles)
            {
                var section = sectionId.ToString(CultureInfo.InvariantCulture) + "\\";
                sourceFileReader.WriteSourceFileInfoToData(infData, section, sourceFileInfo);
                sectionId++;
            }

            ini.WriteData(jobInfo.InfFile);
        }
Exemple #2
0
        private JobInfo ReadFromInfFile(string infFile, TitleReplacer titleReplacer)
        {
            var jobInfo = new JobInfo();

            jobInfo.InfFile = infFile;
            var infData = Data.CreateDataStorage();
            var ini     = new IniStorage(jobInfo.InfFile, Encoding.GetEncoding("Unicode"));

            ini.ReadData(infData);

            var sourceFiles      = new ObservableCollection <SourceFileInfo>();
            var sourceFileReader = new SourceFileInfoDataReader();

            foreach (var section in infData.GetSections())
            {
                var sfi = sourceFileReader.ReadSourceFileInfoFromData(infFile, infData, section);
                if (sfi != null)
                {
                    sourceFiles.Add(sfi);
                }
            }
            jobInfo.SourceFiles = sourceFiles;

            var metadata = new Metadata();

            if (sourceFiles.Count > 0)
            {
                metadata.PrintJobAuthor = sourceFiles[0].Author;
                metadata.PrintJobName   = titleReplacer.Replace(sourceFiles[0].DocumentTitle);

                jobInfo.OriginalFilePath    = sourceFiles[0].OriginalFilePath;
                jobInfo.PrinterName         = sourceFiles[0].PrinterName;
                jobInfo.PrinterParameter    = sourceFiles[0].PrinterParameter;
                jobInfo.ProfileParameter    = sourceFiles[0].ProfileParameter;
                jobInfo.OutputFileParameter = sourceFiles[0].OutputFileParameter;

                jobInfo.JobType = sourceFiles[0].Type;
            }

            ConsiderStoredParameters(jobInfo);

            jobInfo.Metadata = metadata;

            jobInfo.PrintDateTime = File.GetCreationTime(infFile);

            return(jobInfo);
        }
        private JobInfo ReadFromInfFile(string infFile, TitleReplacer titleReplacer)
        {
            var jobInfo = new JobInfo();

            jobInfo.InfFile = infFile;
            var infData = Data.CreateDataStorage();
            var ini     = new IniStorage(Encoding.GetEncoding("Unicode"));

            ini.SetData(infData);
            ini.ReadData(infFile);

            var sourceFiles      = new List <SourceFileInfo>();
            var sourceFileReader = new SourceFileInfoDataReader();

            foreach (var section in infData.GetSections())
            {
                var sfi = sourceFileReader.ReadSourceFileInfoFromData(infFile, infData, section);
                if (sfi != null)
                {
                    sourceFiles.Add(sfi);
                }
            }
            jobInfo.SourceFiles = sourceFiles;

            var metadata = new Metadata();

            if (sourceFiles.Count > 0)
            {
                metadata.PrintJobAuthor = sourceFiles[0].Author;
                metadata.PrintJobName   = titleReplacer.Replace(sourceFiles[0].DocumentTitle);
                metadata.Title          = ""; //Set to avoid null exception when replacing tokens
                metadata.Author         = "";
                metadata.Subject        = "";
                metadata.Keywords       = "";

                jobInfo.JobType = sourceFiles[0].Type;
            }
            jobInfo.Metadata = metadata;

            return(jobInfo);
        }