Example #1
0
        /// <summary>
        /// Processes the documents of a batch
        /// </summary>
        /// <param name="batch">The batch to process</param>
        public void ProcessBatch(IBatch batch)
        {
            IACDataElement rootElement  = batch.ExtractRuntimeACDataElement(0);
            IACDataElement batchElement = rootElement.FindChildElementByName(BATCH);

            IACDataElementCollection currentDocuments = GetElementsByName(batchElement, DOCUMENTS, DOCUMENT);

            for (int i = 0; i < currentDocuments.Count; i++)
            {
                int            currentDocumentIndex = i + 1;
                IACDataElement currentDocument      = currentDocuments[currentDocumentIndex];

                Dictionary <string, string> batchFields = GetKofaxFields(batchElement, BATCH_FIELDS, BATCH_FIELD);
                Dictionary <string, string> indexFields = GetKofaxFields(currentDocument, INDEX_FIELDS, INDEX_FIELD);
                // Dictionary<string, string> batchVariables = GetKofaxFields(batchElement, ...);

                // access settings
                // batch.get_CustomStorageString("key");

                string documentFilePath = currentDocument[PDF_GENERATION_FILE_NAME];

                // ...
            }

            batch.BatchClose(KfxDbState.KfxDbBatchReady, KfxDbQueue.KfxDbQueueNext, 0, "");
        }
        public void ProcessBatch(IBatch batch)
        {
            IACDataElement           batchElement         = GetBatchElementFromBatch(batch);
            IACDataElementCollection currentDocuments     = GetDocumentsFromBatchElement(batchElement);
            IACDataElement           customStorageStrings = GetCustomStorageStringsFromBatch(batch);
            IACDataElementCollection batchFields          = GetElementsByName(batchElement, Resources.BATCH_FIELDS, Resources.BATCH_FIELD);

            for (int i = 0; i < currentDocuments.Count; i++)
            {
                IACDataElement           currentDocument = currentDocuments[i + 1];
                IACDataElementCollection indexFields     = GetElementsByName(currentDocument, Resources.INDEX_FIELDS, Resources.INDEX_FIELD);

                /*
                 *
                 ##############################################################################
                 #
                 # - Access Custom Storage String Values -
                 #
                 # IACDataElement customStorageItem = customStorageStrings.FindChildElementByAttribute(Resources.BATCH_CLASS_CUSTOM_STORAGE_STRING, Resources.NAME, "myCustomStorageStringName");
                 # string customStorageItemValue = customStorageItem[Resources.VALUE];
                 #
                 # // ...
                 #
                 ##############################################################################
                 #
                 # - Access Batchfield Values -
                 #
                 # foreach (IACDataElement batchField in batchFields)
                 # {
                 #  if (batchField[Resources.NAME] == "myBatchFieldName")
                 #  {
                 #      string batchFieldValue = batchField[Resources.VALUE];
                 #
                 #      // ...
                 #  }
                 # }
                 #
                 ##############################################################################
                 #
                 # - Access Indexfield Values -
                 #
                 # foreach (IACDataElement indexField in indexFields)
                 # {
                 #  if (indexField[Resources.NAME] == "myIndexFieldName")
                 #  {
                 #      string indexFieldValue = indexField[Resources.VALUE];
                 #
                 #      // ...
                 #  }
                 # }
                 #
                 ##############################################################################
                 #
                 # - Access Batch Variables -
                 #
                 # string batchVariableValue = batchElement["myBatchVariableName"];
                 #
                 # // ...
                 #
                 ##############################################################################
                 #
                 # - Access Document Variables -
                 #
                 # string documentVariableValue = currentDocument["myDocumentVariableName"];
                 #
                 # // ...
                 #
                 */

                string documentFilePath = currentDocument[Resources.PDF_GENERATION_FILE_NAME];

                // ...
            }

            batch.BatchClose(KfxDbState.KfxDbBatchReady, KfxDbQueue.KfxDbQueueNext, 0, string.Empty);
        }