コード例 #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, "");
        }
        private IACDataElement GetCustomStorageStringsFromBatch(IBatch batch)
        {
            IACDataElement           setupElement = batch.ExtractSetupACDataElement(0);
            IACDataElementCollection batchClasses = GetElementsByName(setupElement, Resources.BATCH_CLASSES, Resources.BATCH_CLASS);
            IACDataElement           batchClass   = batchClasses[1];

            return(batchClass.FindChildElementByName(Resources.BATCH_CLASS_CUSTOM_STORAGE_STRINGS));
        }
コード例 #3
0
        /// <summary>
        /// Searches for specific fields like Indexfields, Batchfields or Batchvariables
        /// </summary>
        /// <param name="dataElement">The item containing the target fields as children</param>
        /// <param name="rootName">Top level name</param>
        /// <param name="targetName">Target level name</param>
        /// <returns>The target fields</returns>
        private Dictionary <string, string> GetKofaxFields(IACDataElement dataElement, string rootName, string targetName)
        {
            IACDataElementCollection    fields   = GetElementsByName(dataElement, rootName, targetName);
            Dictionary <string, string> fieldMap = new Dictionary <string, string>();

            foreach (IACDataElement field in fields)
            {
                string fieldKey   = field["Name"];
                string fieldValue = field["Value"];
                fieldMap.Add(fieldKey, fieldValue);
            }

            return(fieldMap);
        }
        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);
        }