Ejemplo n.º 1
0
        /// <summary>
        /// Gets all the components to make a single XREF record for the specified document.
        /// </summary>
        /// <param name="docIndex">The index of the current document in the collection to export.</param>
        /// <param name="imageIndex">The index of the current image of the current document.</param>
        /// <returns>Returns an array of XREF field values for the specified document.</returns>
        protected string[] getRecordComponents(int docIndex, int imageIndex)
        {
            Document       document    = this.docs[docIndex];
            Document       previousDoc = getPreviousDoc(docIndex);
            Representative imageRep    = document.Representatives
                                         .Where(r => r.Type.Equals(Representative.FileType.Image))
                                         .FirstOrDefault();
            List <KeyValuePair <string, string> > imageFiles = imageRep.Files.ToList();
            var         image  = imageFiles[imageIndex];
            BatesNumber bates  = new BatesNumber(image.Key);
            string      CDPath = image.Value;
            string      Prefix = bates.Prefix;
            string      Number = bates.NumberAsString;
            string      Suffix = (bates.HasSuffix) ? bates.SuffixAsString : String.Empty;
            bool        GS     = getGroupStartFlag(image.Key, docIndex, groupStartTrigger);

            if (GS)
            {
                this.waitingForGroupEnd = true;
            }
            bool GE = getGroupEndFlag(docIndex, imageIndex, groupStartTrigger);

            if (GE)
            {
                this.waitingForGroupEnd = false;
            }
            bool   Staple = image.Key.Equals(document.Key);
            string Loose  = "0";
            bool   CS     = getCodeStartFlag(document, previousDoc, codeStartTrigger);

            if (CS)
            {
                this.waitingForCodeEnd = true;
            }
            bool CE = getCodeEndFlag(docIndex, imageIndex, codeStartTrigger);

            if (CE)
            {
                this.waitingForCodeEnd = false;
            }
            string LabelBypass  = "******";
            string CustomerData = getCustomValue(image.Key, document, customerDataField);
            string NamedFolder  = getCustomValue(image.Key, document, namedFolderField);
            string NamedFiles   = getCustomValue(image.Key, document, namedFileField);

            string[] recordComponents = new string[] { CDPath, Prefix, Number, Suffix,
                                                       boolToString(GS), boolToString(GE), boolToString(Staple), Loose,
                                                       boolToString(CS), boolToString(CE), LabelBypass,
                                                       CustomerData, NamedFolder, NamedFiles };
            return(recordComponents);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the XREF record for a specific slipsheet.
        /// </summary>
        /// <param name="doc">The target document.</param>
        /// <param name="gs">The group start value for the record.</param>
        /// <param name="cs">The code start value for the record.</param>
        /// <param name="custData">The customer data value for the record.</param>
        /// <param name="namedFolder">The named folder value for the record.</param>
        /// <param name="namedFile">The named file value for the record.</param>
        /// <returns>Returns an XREF record.</returns>
        public string GetSlipSheetXrefLine(Document doc,
                                           string gs, string cs, string custData, string namedFolder, string namedFile)
        {
            string line = String.Empty;

            if (HasSlipSheet(doc.Key))
            {
                string      ssImageKey = String.Format("{0}.001", BatesNumber.PreviousNumber(doc.Key));
                BatesNumber ssBates    = new BatesNumber(ssImageKey);
                string      imagePath  = doc.Representatives
                                         .Where(r => r.Type == Representative.FileType.Image).First()
                                         .Files.First().Value;
                FileInfo imageFile = new FileInfo(imagePath);
                String   path      = (!String.IsNullOrWhiteSpace(slipsheetFolderName))
                    ? String.Format("\\{0}\\{1}.TIF", slipsheetFolderName, ssImageKey)
                    : Path.Combine(imageFile.Directory.FullName, String.Format("{0}.TIF", ssImageKey));

                line = String.Format(
                    "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}",
                    path,
                    ssBates.Prefix,
                    ssBates.NumberAsString,
                    ssBates.SuffixAsString,
                    gs,
                    0, // group end
                    1, // staple
                    0, // loose
                    cs,
                    0, // code end
                    1, // label bypass
                    custData,
                    namedFolder,
                    namedFile);

                writeSlipsheet(path, this.slipsheetLookup[doc.Key]);
                logger.Debug("Slipsheet {0} written to {1}.", doc.Key, path);
            }

            logger.Debug(line);
            return(line);
        }
Ejemplo n.º 3
0
        public void Core_BatesNumber()
        {
            BatesNumber bates = new BatesNumber("PREFIX000001.002");

            Assert.AreEqual("PREFIX", bates.Prefix);
            Assert.AreEqual(1, bates.Number);
            Assert.AreEqual(2, bates.Suffix);
            Assert.AreEqual(".", bates.SuffixDelimiter);
            Assert.AreEqual("PREFIX000001.002", bates.ToString());
            Assert.AreEqual(true, bates.HasDelim);
            Assert.AreEqual(true, bates.HasSuffix);
            bates = new BatesNumber("_3_000001.002");
            Assert.AreEqual("_3_", bates.Prefix);
            Assert.AreEqual(1, bates.Number);
            Assert.AreEqual(2, bates.Suffix);
            Assert.AreEqual(".", bates.SuffixDelimiter);
            Assert.AreEqual("_3_000001.002", bates.ToString());
            Assert.AreEqual(true, bates.HasDelim);
            Assert.AreEqual(true, bates.HasSuffix);
            bates = new BatesNumber("TEST000001");
            Assert.AreEqual("TEST", bates.Prefix);
            Assert.AreEqual(1, bates.Number);
            Assert.AreEqual(0, bates.Suffix);
            Assert.AreEqual(String.Empty, bates.SuffixDelimiter);
            Assert.AreEqual("TEST000001", bates.ToString());
            Assert.AreEqual(false, bates.HasDelim);
            Assert.AreEqual(false, bates.HasSuffix);
            bates = new BatesNumber("000001");
            Assert.AreEqual(String.Empty, bates.Prefix);
            Assert.AreEqual(1, bates.Number);
            Assert.AreEqual(0, bates.Suffix);
            Assert.AreEqual(String.Empty, bates.SuffixDelimiter);
            Assert.AreEqual("000001", bates.ToString());
            Assert.AreEqual(false, bates.HasDelim);
            Assert.AreEqual(false, bates.HasSuffix);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a list of lines that contain page records.
        /// </summary>
        /// <param name="document">The document being exported.</param>
        /// <param name="volName">The export volume name.</param>
        /// <returns>A series of formatted LFP image lines.</returns>
        protected List <string> getPageRecords(Document document, string volName)
        {
            List <string>  pageRecords = new List <string>();
            Representative imageRep    = null;
            Representative nativeRep   = null;

            // find representatives
            foreach (Representative rep in document.Representatives)
            {
                if (rep.Type.Equals(Representative.FileType.Image))
                {
                    imageRep = rep;
                }
                else if (rep.Type.Equals(Representative.FileType.Native))
                {
                    nativeRep = rep;
                }
            }
            // check if an image rep was found
            if (imageRep != null)
            {
                int counter    = 0;
                int iterations = getOffsetIterations(document, imageRep);

                foreach (var kvp in imageRep.Files)
                {
                    BatesNumber batesNumber = new BatesNumber(kvp.Key);
                    string      ext         = Path.GetExtension(kvp.Value).ToUpper();
                    int         i           = (iterations == 0) ? 0 : 1;

                    for (; i <= iterations; i++)
                    {
                        // IM,IMAGEKEY,DOCBREAK,OFFSET,@VOLUME;FILE\PATH;IMAGE.FILE;TYPE,ROTATION
                        int    offset     = i;
                        string docBreak   = (counter == 0) ? getDocBreakValue(document) : String.Empty;
                        string fileName   = Path.GetFileName(kvp.Value);
                        string directory  = kvp.Value.Substring(0, kvp.Value.Length - fileName.Length - 1);
                        string pageRecord = String.Format("IM,{0},{1},{2},@{3};{4};{5};{6},0",
                                                          batesNumber.ToString(),
                                                          docBreak,
                                                          offset,
                                                          volName,
                                                          directory,
                                                          fileName,
                                                          ImageFileTypes[ext]
                                                          );

                        pageRecords.Add(pageRecord);

                        if (nativeRep != null && counter == 0)
                        {
                            pageRecord = getNativeRecord(document, volName, nativeRep);
                            pageRecords.Add(pageRecord);
                        }

                        batesNumber.IterateNumber();
                        counter++;
                    }
                }
            }
            else if (nativeRep != null)
            {
                string pageRecord = getNativeRecord(document, volName, nativeRep);
                pageRecords.Add(pageRecord);
            }

            return(pageRecords);
        }