示例#1
0
        public List <PageData> GetAllPages(DataProvider aProvider, Rendition rendition)
        {
            if (aProvider == null)
            {
                throw new ArgumentNullException("provider", "No DataProvider specified");
            }
            if (rendition == null)
            {
                throw new ArgumentNullException("rendition", "No document rendition specified");
            }
            List <PageData> pagesResults = new List <PageData>();

            PageRangeSet lRangeSet = aProvider.CreatePageRangeSet();

            lRangeSet.AddRange(1, rendition.NumberOfPages);
            MethodInfo GetPagesMethod = aProvider.GetType().GetMethod("GetPages", new Type[] { typeof(Rendition), typeof(PageRangeSet) });

            if (GetPagesMethod == null)
            {
                throw new Exception("Specified DataProvider does not define file access");
            }
            try
            {
                pagesResults.AddRange(GetPagesMethod.Invoke(aProvider, new object[] { rendition, lRangeSet }) as PageDataList);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }

            return(pagesResults);
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args=null)
        {
            try
            {
                // Initialize global settings
                IntializeScript(ref app, ref args);

                Rendition          objFormRendition  = _currentDocument.DefaultRenditionOfLatestRevision;
                NativeDataProvider objNativeProvider = app.Core.Retrieval.Native;
                PageData           objNativeData     = objNativeProvider.GetDocument(objFormRendition);

                gExtension = objNativeData.Extension.ToString();

                app.Diagnostics.Write(gExtension);

                switch (gExtension)
                {
                case ".docm":
                    args.ScriptResult = false;
                    break;

                case ".avi":
                    args.ScriptResult = false;
                    break;

                case ".msg":
                    args.ScriptResult = false;
                    break;

                case ".wav":
                    args.ScriptResult = false;
                    break;

                case ".zip":
                    args.ScriptResult = false;
                    break;

                default:
                    args.ScriptResult = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                // Handle exceptions and log to Diagnostics Console and document history
                HandleException(ex, ref app, ref args);
            }
            finally
            {
                // Log script execution end
                app.Diagnostics.Write(args.ScriptResult.ToString());
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info,
                                        string.Format("End Script - [{0}]", ScriptName));
            }
        }
示例#3
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            try
            {
                // Script name for diagnostics logging
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName));

                // Get the active document
                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                // Get the default rendition and verify it is an e-form
                Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;
                if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE)
                {
                    throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name));
                }

                // Validate the document type
                DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);
                if (objCrdDocType == null)
                {
                    throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE));
                }

                ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY);

                List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE), true);

                unityConverter.CleanupFiles();

                args.ScriptResult = true;
            }
            catch (InvalidProgramException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (Exception ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, ScriptName);
            }
        }
示例#4
0
 /**
  * <summary>Creates a new action within the given document context.</summary>
  */
 public Render(
     Screen screen,
     OperationEnum operation,
     Rendition rendition
     ) : base(screen.Document, PdfName.Rendition)
 {
     Operation = operation;
     Screen    = screen;
     Rendition = rendition;
 }
示例#5
0
        protected BaseItem CreateItem(ItemType type, XmlDocument document, string logTime)
        {
            BaseItem item = null;

            switch (type)
            {
            case ItemType.Unknown:
                item = new Unknown(document, logTime);
                break;

            case ItemType.Document:
                item = new Document(document, logTime);
                break;

            case ItemType.Rendition:
                item = new Rendition(document, logTime);
                break;

            case ItemType.LinkItem:
                item = new LinkItem(document, logTime);
                break;

            case ItemType.Folder:
                item = new Folder(document, logTime);
                break;

            case ItemType.DocumentSet:
                item = new DocumentSet(document, logTime);
                break;

            case ItemType.List:
                item = new List(document, logTime);
                break;

            case ItemType.Web:
                item = new Web(document, logTime);
                break;

            case ItemType.WebContentType:
                item = new WebContentType(document, logTime);
                break;

            case ItemType.Others:
                item = new Others(document, logTime);
                break;

            default:
                item = null;
                break;
            }
            return(item);
        }
示例#6
0
        public List <PageData> GetAllPages(string aProviderName, Rendition rendition)
        {
            if (string.IsNullOrWhiteSpace(aProviderName))
            {
                if (rendition.GetNativeFormatAllowed())
                {
                    aProviderName = "Native";
                }
                else
                {
                    aProviderName = "Default";
                }
            }
            DataProvider lProvider = GetDataProvider(aProviderName);

            return(GetAllPages(lProvider, rendition));
        }
示例#7
0
        public Screen(
            Page page,
            drawing::RectangleF box,
            String text,
            Rendition rendition
            ) : base(page, PdfName.Screen, box, text)
        {
            Render render = new Render(this, Render.OperationEnum.PlayResume, rendition);

            {
                // Adding preview and play/pause control...

                /*
                 * NOTE: Mouse-related actions don't work when the player is active; therefore, in order to let
                 * the user control the rendering of the media clip (play/pause) just by mouse-clicking on the
                 * player, we can only rely on the player's focus event. Furthermore, as the player's focus can
                 * only be altered setting it on another widget, we have to define an ancillary field on the
                 * same page (so convoluted!).
                 */
                string playerReference = "__player" + ((PdfReference)render.BaseObject).ObjectNumber;
                Document.Form.Fields.Add(new TextField(playerReference, new Widget(page, new drawing::RectangleF(box.X, box.Y, 0, 0)), "")); // Ancillary field.
                render.Script = RenderScript.Replace(PlayerPlaceholder, playerReference);
            }
            Actions.OnPageOpen = render;

            if (rendition is MediaRendition)
            {
                PdfObjectWrapper data = ((MediaRendition)rendition).Clip.Data;
                if (data is FileSpecification)
                {
                    // Adding fallback annotation...

                    /*
                     * NOTE: In case of viewers which don't support video rendering, this annotation gently
                     * degrades to a file attachment that can be opened on the same location of the corresponding
                     * screen annotation.
                     */
                    FileAttachment attachment = new FileAttachment(page, box, text, (FileSpecification)data);
                    BaseDataObject[PdfName.T] = PdfString.Get(((FileSpecification)data).Path);
                    // Force empty appearance to ensure no default icon is drawn on the canvas!
                    attachment.BaseDataObject[PdfName.AP] = new PdfDictionary(new PdfName[] { PdfName.D, PdfName.R, PdfName.N }, new PdfDirectObject[] { new PdfDictionary(), new PdfDictionary(), new PdfDictionary() });
                }
            }
        }
示例#8
0
        public static void Run()
        {
            // ExStart:GetResourceOfAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

            // Open document
            Document doc = new Document(dataDir + "AddAnnotation.pdf");
            //Create annotation
            ScreenAnnotation sa = new ScreenAnnotation(doc.Pages[1], new Rectangle(100, 400, 300, 600), dataDir + "AddSwfFileAsAnnotation.swf");

            doc.Pages[1].Annotations.Add(sa);
            // Save Doucument
            doc.Save(dataDir + "GetResourceOfAnnotation_Out.pdf");
            // Open document
            Document doc1 = new Document(dataDir + "GetResourceOfAnnotation_Out.pdf");
            //Get action of the annotation
            RenditionAction action = (doc.Pages[1].Annotations[1] as ScreenAnnotation).Action as RenditionAction;
            //Get rendition of the rendition action
            Rendition rendition = ((doc.Pages[1].Annotations[1] as ScreenAnnotation).Action as RenditionAction).Rendition;
            //Media Clip
            MediaClip         clip = (rendition as MediaRendition).MediaClip;
            FileSpecification data = (clip as MediaClipData).Data;
            MemoryStream      ms   = new MemoryStream();

            byte[] buffer = new byte[1024];
            int    read   = 0;
            //Data of media are accessible in FileSpecification.Contents
            Stream source = data.Contents;

            while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
            Console.WriteLine(rendition.Name);
            Console.WriteLine(action.RenditionOperation);
            // ExStart:GetResourceOfAnnotation
        }
        /// <summary>
        /// Implementation of <see cref="IClientWorkflowScript.OnClientWorkflowScriptExecute" />.
        /// <seealso cref="IClientWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnClientWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.ClientWorkflowEventArgs args)
        {
            app.Diagnostics.Level = Diagnostics.DiagnosticsLevel.Verbose;

            try
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Begin Script - Get File Type");

                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                //Get Current Rendition
                Rendition objDocRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;

                if (objDocRendition.FileType.ID == PDF_FILE_TYPE)
                {
                    args.ScriptResult = true;
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "PDF File Format");
                }
                else
                {
                    args.ScriptResult = false;
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Not PDF File Format");
                }
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "End Script - Get File Type");
            }
        }
示例#10
0
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            app.Diagnostics.Level = Diagnostics.DiagnosticsLevel.Verbose;

            try
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Begin Script - 274 - Convert Supporting Document to TIFF");

                // Get the active document
                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                // Get the default rendition and verify it is an e-form
                Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;
                if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE)
                {
                    throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name));
                }


                // Obtain the Image page data
                ImageDataProvider objImageProvider = app.Core.Retrieval.Image;
                PageData          objImageData     = objImageProvider.GetDocument(objFormRendition);
                string            fullPath         = String.Format("{0}.{1}", @"c:\Temp", objImageData.Extension);

                Stream stream = objImageData.Stream;
                Utility.WriteStreamToFile(stream, fullPath);

                DocumentType objNewDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);

                // Prepare to import the new document
                StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objNewDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                //Add all keywords
                foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                {
                    if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                    {
                        foreach (Keyword objKeyword in objKeyRecord.Keywords)
                        {
                            if (objNewDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                            {
                                objDocProps.AddKeyword(objKeyword);
                            }
                        }
                    }
                    else
                    {
                        EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                        objDocProps.AddKeywordRecord(objEditRecord);
                    }
                }

                List <string> lstImportFiles = new List <string>();
                lstImportFiles.Add(fullPath);

                // Store the new document
                Document objNewDoc = null;
                objNewDoc = app.Core.Storage.StoreNewDocument(lstImportFiles, objDocProps);
                if (objNewDoc == null)
                {
                    throw new InvalidProgramException("Failed to store new document");
                }

                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                // Clean up
                objImageData.Dispose();

                // If we got here, the script was successful
                args.ScriptResult = true;
            }
            catch (InvalidProgramException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (Exception ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "End Script - 274 - Convert HTML to TIFF");
            }
        }
示例#11
0
 private static void LoadConfig(Rendition.Site.SiteConfiguration baseConfig)
 {
     Main.TelnetServerPort = baseConfig.TelnetServerPort;
     Main.FileSystemAccess = baseConfig.FileSystemAccess;
     Main.LogVerbosity = baseConfig.LogVerbosity;
     Main.UseFormsBasedAuth = baseConfig.UseFormsBasedAuth;
     Main.CanUseSSL = baseConfig.CanUseSSL;
     if(baseConfig.Compression>0) {
         Main.Compression = baseConfig.Compression;
     }
     if(baseConfig.LocalizationFile != null) { Main.LocalizationFile = baseConfig.LocalizationFile; }
     if(baseConfig.AdminDirectory != null) { Main.AdminDirectory = baseConfig.AdminDirectory; }
     if(baseConfig.PluginDirectory != null) { Main.PluginDirectory = baseConfig.PluginDirectory; }
     if(baseConfig.TempDirectory != null) { Main.TempDirectory = baseConfig.TempDirectory; }
     if(baseConfig.ImageDirectory != null) { Main.ImageDirectory = baseConfig.ImageDirectory; }
     if(baseConfig.UserDirectory != null) { Main.UserDirectory = baseConfig.UserDirectory; }
     if(baseConfig.Responder != null) { Main.Responder = baseConfig.Responder; }
     if(baseConfig.ElevatedSecurityUser != null) { Main.ElevatedSecurityUser = baseConfig.ElevatedSecurityUser; }
     if(baseConfig.ElevatedSecurityPassword != null) { Main.ElevatedSecurityPassword = baseConfig.ElevatedSecurityPassword; }
     if(baseConfig.ElevatedSecurityDomain != null) { Main.ElevatedSecurityDomain = baseConfig.ElevatedSecurityDomain; }
     if(baseConfig.MethodKey != null) { Main.MethodKey = baseConfig.MethodKey; }
     if(baseConfig.CategoryRewrite != null) { Main.CategoryRewrite = baseConfig.CategoryRewrite; }
     if(baseConfig.PublicFiles != null) { Main.PublicFiles = baseConfig.PublicFiles; }
     if(baseConfig.CategoryRewriteReplace != null) { Main.CategoryRewriteReplace = baseConfig.CategoryRewriteReplace; }
     if(baseConfig.ItemRewrite != null) { Main.ItemRewrite = baseConfig.ItemRewrite; }
     if(baseConfig.ItemRewriteReplace != null) { Main.ItemRewriteReplace = baseConfig.ItemRewriteReplace; }
     if(baseConfig.PublicDirectory != null) { Main.PublicDirectory = baseConfig.PublicDirectory; }
     if(baseConfig.RequestCategory != null) { Main.RequestCategory = baseConfig.RequestCategory; }
     if(baseConfig.RequestItem != null) { Main.RequestItem = baseConfig.RequestItem; }
     if(baseConfig.MainJSScript != null) { Main.MainJSScript = baseConfig.MainJSScript; }
     if(baseConfig.ImageFormat != null) { Main.ImageFormat = baseConfig.ImageFormat; }
 }
        /***********************************************
        * USER/SE: PLEASE DO NOT EDIT BELOW THIS LINE *
        ***********************************************/

        #region IWorkflowScript

        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app">Unity Application object</param>
        /// <param name="args">Workflow event arguments</param>
        public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args)
        // public void OnWorkflowScriptExecute(Application app, WorkflowEventArgs args = null)
        {
            try
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("{0} - Start Script - [{1}]", DateTime.Now.ToString(DateTimeFormat), ScriptName));

                // Get the active document
                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                // Get the default rendition
                Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;

                DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);

                // Validate the document type
                //DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);
                if (objCrdDocType == null)
                {
                    throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE));
                }

                //If the doc is already an image, pull it in its default format and save the new copy
                if (objFormRendition.FileType.ID == IMAGE_FILE_TYPE)
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Document is an image, save copy to new Doc Type");

                    DefaultDataProvider objDefaultProvider  = app.Core.Retrieval.Default;
                    PageData            objDefaultImageData = objDefaultProvider.GetDocument(objFormRendition);

                    StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                    foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                    {
                        if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                        {
                            foreach (Keyword objKeyword in objKeyRecord.Keywords)
                            {
                                if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                                {
                                    objDocProps.AddKeyword(objKeyword);
                                }
                            }
                        }
                        else
                        {
                            EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                            objDocProps.AddKeywordRecord(objEditRecord);
                        }
                    }

                    // Store the new document
                    Document objNewDoc = null;
                    objNewDoc = app.Core.Storage.StoreNewDocument(objDefaultImageData, objDocProps);
                    if (objNewDoc == null)
                    {
                        throw new InvalidProgramException("Failed to store new document");
                    }
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                    // Clean up
                    objDefaultImageData.Dispose();

                    // If we got here, the script was successful
                    args.ScriptResult = true;
                }
                //If the Doc is Word or Excel, convert it with the conversion utility and save it
                else if (objFormRendition.FileType.ID == WORD_FILE_TYPE || objFormRendition.FileType.ID == PDF_FILE_TYPE)
                {
                    ConversionUtilities unityConverter = new ConversionUtilities(app, TEMP_DIRECTORY, CONVERTER_DIRECTORY);
                    app.Diagnostics.Write("Word/PDF file conversion");

                    List <FileDefinition> files = unityConverter.Convert(args.Document, UnityFileConversions.ImxFileType.Image, UnityFileConversions.ImportType.Document, app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE));

                    unityConverter.CleanupFiles();

                    args.ScriptResult = true;
                }
                else
                {
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Document is not image/Word/PDF, convert to new Doc Type");

                    ImageDataProvider objImageProvider = app.Core.Retrieval.Image;
                    PageData          objImageData     = objImageProvider.GetDocument(objFormRendition);

                    StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                    foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                    {
                        if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                        {
                            foreach (Keyword objKeyword in objKeyRecord.Keywords)
                            {
                                if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                                {
                                    objDocProps.AddKeyword(objKeyword);
                                }
                            }
                        }
                        else
                        {
                            EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                            objDocProps.AddKeywordRecord(objEditRecord);
                        }
                    }

                    // Store the new document
                    Document objNewDoc = null;
                    objNewDoc = app.Core.Storage.StoreNewDocument(objImageData, objDocProps);
                    if (objNewDoc == null)
                    {
                        throw new InvalidProgramException("Failed to store new document");
                    }
                    app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                    // Clean up
                    objImageData.Dispose();

                    // If we got here, the script was successful
                    args.ScriptResult = true;
                }
            }
            catch (InvalidProgramException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (Exception ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("End Script - [{0}]", ScriptName));
            }
        }
        /// <summary>
        /// Implementation of <see cref="IWorkflowScript.OnWorkflowScriptExecute" />.
        /// <seealso cref="IWorkflowScript" />
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        public void OnWorkflowScriptExecute(Hyland.Unity.Application app, Hyland.Unity.WorkflowEventArgs args)
        {
            app.Diagnostics.Level = Diagnostics.DiagnosticsLevel.Verbose;

            try
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "Begin Script - Convert HTML to TIFF");

                // Get the active document
                Document objCurrentDocument = args.Document;
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Processing document: {0}", objCurrentDocument.ID.ToString()));

                // Get the default rendition and verify it is an e-form
                Rendition objFormRendition = objCurrentDocument.DefaultRenditionOfLatestRevision;
                if (objFormRendition.FileType.ID != EFORM_FILE_TYPE && objFormRendition.FileType.ID != VFORM_FILE_TYPE)
                {
                    throw new InvalidProgramException(string.Format("File format ({0}) is invalid!", objFormRendition.FileType.Name));
                }

                // Validate the document type
                DocumentType objCrdDocType = app.Core.DocumentTypes.Find(CRD_DOCUMENT_TYPE);
                if (objCrdDocType == null)
                {
                    throw new InvalidProgramException(string.Format("Document type \"{0}\" does not exist!", CRD_DOCUMENT_TYPE));
                }

                // Obtain the Image page data
                ImageDataProvider objImageProvider = app.Core.Retrieval.Image;
                PageData          objImageData     = objImageProvider.GetDocument(objFormRendition);

                // Convert to Multi-Page TIFF
                using (ImageModifier imageMod = new ImageModifier(TEMP_DIRECTORY, PAGE_RATIO))
                {
                    strFilePath = imageMod.MakeMultiPage(objImageData, app);
                    if (strFilePath.StartsWith("ERROR:"))
                    {
                        throw new InvalidProgramException(string.Format("Error converting to multipage: ({0})", strFilePath.Replace("ERROR: ", "")));
                    }
                }

                // Prepare to import the new document
                StoreNewDocumentProperties objDocProps = app.Core.Storage.CreateStoreNewDocumentProperties(objCrdDocType, app.Core.FileTypes.Find(IMAGE_FILE_TYPE));

                // Add all keywords
                foreach (KeywordRecord objKeyRecord in objCurrentDocument.KeywordRecords)
                {
                    if (objKeyRecord.KeywordRecordType.RecordType == RecordType.StandAlone || objKeyRecord.KeywordRecordType.RecordType == RecordType.SingleInstance)
                    {
                        foreach (Keyword objKeyword in objKeyRecord.Keywords)
                        {
                            if (objCrdDocType.KeywordRecordTypes.FindKeywordType(objKeyword.KeywordType.ID) != null)
                            {
                                objDocProps.AddKeyword(objKeyword);
                            }
                        }
                    }
                    else
                    {
                        EditableKeywordRecord objEditRecord = objKeyRecord.CreateEditableKeywordRecord();
                        objDocProps.AddKeywordRecord(objEditRecord);
                    }
                }

                List <string> lstImportFiles = new List <string>();
                lstImportFiles.Add(strFilePath);

                // Store the new document
                Document objNewDoc = null;
                objNewDoc = app.Core.Storage.StoreNewDocument(lstImportFiles, objDocProps);
                if (objNewDoc == null)
                {
                    throw new InvalidProgramException("Failed to store new document");
                }
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, string.Format("Stored new document: {0}", objNewDoc.ID.ToString()));

                // Clean up
                objImageData.Dispose();

                // If we got here, the script was successful
                args.ScriptResult = true;
            }
            catch (InvalidProgramException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Invalid Program Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (UnityAPIException ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Unity API Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            catch (Exception ex)
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("General Exception: {0}", ex.Message));
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Error, string.Format("Stack Trace: {0}", ex.StackTrace));
                args.ScriptResult = false;
            }
            finally
            {
                app.Diagnostics.WriteIf(Diagnostics.DiagnosticsLevel.Info, "End Script - Convert HTML to TIFF");
            }
        }
示例#14
0
        private bool RunCQ(Application app, WorkflowEventArgs args, string strBusinessUnit, string strAGMeetingMonth, string strAGMeetingYear, string strAGAddendum, string strDocType, string strLicenseType, string strApplicationNumber, long lngDocHandle, string strCameraReady, string lngMstrDocHandle, bool bOkayToProcessWithoutError)

        {
            const long CIU_APPLICATION_MSTR_DTID              = 773;
            const long CIU_CRIMINAL_RESULTS_MSTR_DTID         = 771;
            const long CIU_SUPPORTING_DOCS_MSTR_DTID          = 770;
            const long CIU_CORRESPONDENCE_MSTR_DTID           = 772;
            const long CIU_CR_CAMERA_READY_DOCUMENT_MSTR_DTID = 2343;

            //String to hold output information
            string output = string.Empty;

            WriteLog(app, string.Format("[{0}][{1}][{2}][{3}][{4}][{5}][{6}][{7}]", strBusinessUnit, strAGMeetingYear, strAGMeetingMonth, strAGAddendum, strDocType, strLicenseType, strApplicationNumber, lngDocHandle.ToString(), strCameraReady));

            long gDocTypeID;
            long lngCurrentMSTRDTID;

            switch (strDocType)
            {
            case "CAMERA READY DOCUMENT":
            {
                gDocTypeID         = PCIU_CR_CAMERA_READY_DOCUMENT_DTID;
                lngCurrentMSTRDTID = CIU_CR_CAMERA_READY_DOCUMENT_MSTR_DTID;
                break;
            }

            case "APPLICATION":
            {
                gDocTypeID         = PCIU_APPLICATIONS_CR_DTID;
                lngCurrentMSTRDTID = CIU_APPLICATION_MSTR_DTID;
                break;
            }

            case "CRIMINAL RESULTS":
            {
                gDocTypeID         = PCIU_CRIMINAL_RESULTS_CR_DTID;
                lngCurrentMSTRDTID = CIU_CRIMINAL_RESULTS_MSTR_DTID;
                break;
            }

            case "SUPPORTING DOCS":
            {
                gDocTypeID         = PCIU_SUPPORTING_DOCS_CR_DTID;
                lngCurrentMSTRDTID = CIU_SUPPORTING_DOCS_MSTR_DTID;
                break;
            }

            case "CORRESPONDENCE":
            {
                gDocTypeID         = PCIU_CORRESPONDENCE_CR_DTID;
                lngCurrentMSTRDTID = CIU_CORRESPONDENCE_MSTR_DTID;
                break;
            }

            default:
            {
                gDocTypeID         = 0;
                lngCurrentMSTRDTID = 0;
                break;
            }
            }


            // Create document query
            WriteLog(app, string.Format("Setting up Document Query [{0} - {1}]", strDocType, gDocTypeID.ToString()));
            DocumentQuery documentQuery = app.Core.CreateDocumentQuery();

            // Ensure custom query was found
            if (documentQuery == null)
            {
                throw new Exception("Unable to create document query");
            }

            // Add custom query to document query
            DocumentType docType = app.Core.DocumentTypes.Find(gDocTypeID);

            if (docType == null)
            {
                throw new Exception(string.Format("Could not find document type with ID: {0}", gDocTypeID.ToString()));
            }
            documentQuery.AddDocumentType(docType);

            KeywordType kwdType = app.Core.KeywordTypes.Find(PAPPNUMBERKWID);

            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PAPPNUMBERKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, Convert.ToInt64(strApplicationNumber));

            kwdType = app.Core.KeywordTypes.Find(PLICTYPEKWID);
            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PLICTYPEKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, strLicenseType);

            kwdType = app.Core.KeywordTypes.Find(PDOCNUMBERCONSTKWID);
            if (kwdType == null)
            {
                throw new Exception(string.Format("Could not find keyword type with ID: {0}", PDOCNUMBERCONSTKWID.ToString()));
            }
            documentQuery.AddKeyword(kwdType.Name, Convert.ToInt64(lngMstrDocHandle));

            documentQuery.AddSort(DocumentQuery.SortAttribute.DocumentID, true);

            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", PAPPNUMBERKWID.ToString(), strApplicationNumber));
            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", KNLICTYPE, strLicenseType));
            WriteLog(app, string.Format("Running Document Query - Search KW [{0} = {1}]", KNDOCNUMBERCONSTKWID, lngMstrDocHandle.ToString()));

            // Execute query
            const int    MAX_DOCUMENTS = 1000;
            DocumentList documentList  = documentQuery.Execute(MAX_DOCUMENTS);

            if (documentList.Count == 0)
            {
                if (!bOkayToProcessWithoutError)
                {
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** ERROR: NO DOCUMENTS FOUND IN SEARCH **************");
                    WriteLog(app, "  ");
                    strProcessingErrors = string.Format("{0}{1}  Failed to locate any documents of type - {2}.  AN: {3} - LT: {4}", strProcessingErrors, DateTime.Now, strDocType, strApplicationNumber, strLicenseType);

                    return(false);
                }
                else
                {
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** ERROR BYPASSED: USER STATED TO PROCESS WITH MISSING DOCUMENTS **************");
                    WriteLog(app, "  ");
                    WriteLog(app, "TEST CAMERA READY");
                    WriteLog(app, "  ");
                    return(true);
                }
            }
            // Line 298 from VB script.
            // Iterate through documents returned from query
            bool   bIsFirstDocument = true;
            string ProcessedDocIDs  = "";
            //string ProcessedDoc = "";
            //string strDocID = "";
            string laststrPrimaryDocID = "0";

            //int intNumDocsProcessed = 0;
            //int gDocCount = 0;

            foreach (Document document in documentList)
            {
                if (bIsFirstDocument)
                {
                    DocumentType objDocType = document.DocumentType;
                    WriteLog(app, "  ");
                    WriteLog(app, "*************** SETTING DOCUMENT TYPE TO IT MASTER EQUIVALENT **************");
                    WriteLog(app, "  ");
                    WriteLog(app, String.Format("*************** CURRENT DOCUMENT TYPE : {0} **************", objDocType.Name.ToString().Trim()));
                    WriteLog(app, String.Format("*************** CURRENT DOCUMENT TYPE : {0} **************", objDocType.ID.ToString().Trim()));

                    DocumentType newdoctype = app.Core.DocumentTypes.Find(lngCurrentMSTRDTID);

                    if (newdoctype == null)
                    {
                        throw new ApplicationException(string.Format("Document Type {0} does not exist", lngCurrentMSTRDTID));
                    }
                    Storage           storage           = app.Core.Storage;
                    ReindexProperties reindexProperties = storage.CreateReindexProperties(document, newdoctype);
                    Document          newDocument       = storage.ReindexDocument(reindexProperties);

                    WriteLog(app, String.Format("*************** UPDATED DOCUMENT TYPE : {0} **************", newdoctype.Name));
                    WriteLog(app, String.Format("*************** UPDATED DOCUMENT TYPE ID (Should be: {0} : {1} **************", lngCurrentMSTRDTID.ToString(), document.ID.ToString()));

                    // Update the document AutoName
                    //WriteLog(app,"*************** UPDATED DOCUMENT AUTO NAME: " & Trim(CStr(objDoc.Name)) & " **************")
                    //objDoc.AutoName
                }
                app.Diagnostics.Write(string.Format("Document ID: {0} Document Name: {1}{2}", document.ID, document.Name, Environment.NewLine));
                //Line 349
                //int x = 1;
                // If there are multiple instances of a KW value on a document, we do not want to output the same doc again
                // as the result set will contain an document entry for each unique KW value of the same type.
                if (ProcessedDocIDs.Contains(document.ID.ToString().Trim()) || (document.ID.ToString() == laststrPrimaryDocID.Trim()))
                {
                    app.Diagnostics.Write("Made it into odd logic fork");
                }
                else
                {
                    //intNumDocsProcessed++;
                    ProcessedDocIDs = string.Format("{0}{1}", ProcessedDocIDs, document.ID.ToString().Trim());
                    //gDocCount++;
                    string fileTypeExt = "";

                    long      fileTypeID       = 2;
                    Rendition objFormRendition = document.DefaultRenditionOfLatestRevision;
                    fileTypeID = objFormRendition.FileType.ID;

                    switch (fileTypeID)
                    {
                    case 1:
                        fileTypeExt = "txt";
                        break;

                    case 2:
                        fileTypeExt = "tif";
                        break;

                    case 16:
                        fileTypeExt = "pdf";
                        break;

                    case 17:
                        fileTypeExt = "htm";
                        break;

                    case 13:
                        fileTypeExt = "xls";
                        break;

                    case 12:
                        fileTypeExt = "doc";
                        break;

                    case 14:
                        fileTypeExt = "ppt";
                        break;

                    case 15:
                        fileTypeExt = "rtf";
                        break;

                    case 24:
                        fileTypeExt = "htm";
                        break;

                    case 32:
                        fileTypeExt = "xml";
                        break;

                    default:
                        fileTypeExt = "unknown";
                        break;
                    }

                    KeywordType kwtDocConversionStatus = null;
                    Keyword     kwdDocConversionStatus = null;
                    if (fileTypeExt == "tif")
                    {
                        kwtDocConversionStatus = app.Core.KeywordTypes.Find(DOCUMENTCONVERSIONSTATUS);
                        if (kwtDocConversionStatus == null)
                        {
                            throw new Exception(String.Format("Keyword Type '{0}' not found", DOCUMENTCONVERSIONSTATUS));
                        }
                        kwdDocConversionStatus = CreateKeywordHelper(kwtDocConversionStatus, "CONV OK");
                        WriteLog(app, "Document file format is TIFF");
                    }
                    else
                    {
                        kwtDocConversionStatus = app.Core.KeywordTypes.Find(DOCUMENTCONVERSIONSTATUS);
                        if (kwtDocConversionStatus == null)
                        {
                            throw new Exception(String.Format("Keyword Type '{0}' not found", DOCUMENTCONVERSIONSTATUS));
                        }
                        kwdDocConversionStatus = CreateKeywordHelper(kwtDocConversionStatus, "NOT IMAGE FORMAT");
                        WriteLog(app, "Document file format is NOT TIFF - need to add logic to convert to TIFF");
                        strProcessingErrors = string.Format("{0}{1}{2}   " +
                                                            "Document is not Image File Format - {3}.  AN: {4} - LT: {5}", strProcessingErrors, Environment.NewLine, DateTime.Now.ToString(DateTimeFormat), strDocType, strApplicationNumber, strLicenseType);
                    }

                    using (DocumentLock documentLock = document.LockDocument())
                    {
                        // Ensure lock was obtained
                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                        {
                            throw new Exception("Document lock not obtained");
                        }
                        // Create keyword modifier object to hold keyword changes
                        KeywordModifier keyModifier = document.CreateKeywordModifier();

                        //Add update keyword call to keyword modifier object
                        //Note Overloads available for use
                        //(I.E.): keyModifier.AddKeyword(keywordTypeName,keywordValue)
                        keyModifier.AddKeyword(kwdDocConversionStatus);

                        // Apply keyword change to the document
                        keyModifier.ApplyChanges();

                        WriteLog(app, string.Format("Keyword: '{0}' added to Document .", DOCUMENTCONVERSIONSTATUS));
                    }
                    if (fileTypeExt != "tif")
                    {
                        return(false);
                    }

                    WriteLog(app, string.Format("  Processing DocID [{0}]", document.ID.ToString()));
                    // Set property bag for use by OnBase DocDataProvider object
                    args.PropertyBag.Set("docID", document.ID.ToString());

                    sourceDocHandle = document.ID;

                    // If the source file format is not image, we need to save it out and append to the current document.
                    // Otherwise, we need to append the current image file in the diskgroup
                    // If currentDocumentFileFormatIsImage Then
                    if (bIsFirstDocument)
                    {
                        app.Diagnostics.Write("in first doc logic");
                        destinationDocHandle = sourceDocHandle;
                        bIsFirstDocument     = false;
                    }
                    else
                    {
                        app.Diagnostics.Write("Made it in");
                        AppendToDocument(app, args, sourceDocHandle, destinationDocHandle);
                    }
                }
                laststrPrimaryDocID = document.ID.ToString();
            }
            return(true);
        }
示例#15
0
        /*
         * AppendToDocument() is the function that performs the operations designated for this script.
         * This sub will retrieve all of the pages from the source document and
         * append them to the destination document.
         * NOTE: This script uses IOBXDocumentArchiver and the IOBXFileManager.
         * Both objects are required to store a document in this fashion.
         * DocumentArchiver is used to retireve and append pages
         * FileManager is used to commit changes to document already stored in OnBase
         */

        private bool AppendToDocument(Application app, WorkflowEventArgs args, Int64 sourceDocHandle, Int64 destinationDocHandle)
        {
            try
            {
                Document destDocument = app.Core.GetDocumentByID(destinationDocHandle);
                if (destDocument == null)
                {
                    WriteLog(app, string.Format("No Destination document found with handle ( {0} ).", destinationDocHandle.ToString()));
                    strProcessingErrors = string.Format("{0}{1}{2}   No Destination document found with handle ( {4} ).", strProcessingErrors, Environment.NewLine, DateTime.Now, destinationDocHandle.ToString());
                    return(false);
                }
                Rendition         destRendition         = destDocument.DefaultRenditionOfLatestRevision;
                ImageDataProvider destImageDataProvider = app.Core.Retrieval.Image;
                PageData          destPageData          = destImageDataProvider.GetDocument(destRendition);

                Document sourceDocument = app.Core.GetDocumentByID(sourceDocHandle);
                if (sourceDocument == null)
                {
                    WriteLog(app, string.Format("No Source document found with handle ( {0}.", sourceDocHandle.ToString()));
                    strProcessingErrors = String.Format("{0}{1}{2}    No Source document found with handle ({3}).", strProcessingErrors, Environment.NewLine, DateTime.Now, sourceDocHandle.ToString());
                    return(false);
                }

                Rendition         sourceRendition         = sourceDocument.DefaultRenditionOfLatestRevision;
                ImageDataProvider sourceImageDataProvider = app.Core.Retrieval.Image;
                PageData          sourcePageData          = sourceImageDataProvider.GetDocument(sourceRendition);
                PageRangeSet      sourcePageRangeSet      = sourceImageDataProvider.CreatePageRangeSet();
                sourcePageRangeSet.AddRange(1, sourceRendition.NumberOfPages);
                PageDataList sourcePageDataList = sourceImageDataProvider.GetPages(sourceRendition, sourcePageRangeSet);

                if (sourcePageDataList == null)
                {
                    WriteLog(app, string.Format("No pages found in Source document  (ID: {0}.", sourceDocHandle.ToString()));
                    return(false);
                }
                else
                {
                    app.Diagnostics.Write(string.Format("Source Document Handle {0} has {1} pages.", sourceDocHandle.ToString()), sourcePageDataList.Count);
                    // Create a page range object

                    using (DocumentLock documentLock = destDocument.LockDocument())
                    {
                        // Ensure lock was obtained
                        if (documentLock.Status != DocumentLockStatus.LockObtained)
                        {
                            throw new Exception("Document lock not obtained");
                        }

                        long lngPageCount = destDocument.DefaultRenditionOfLatestRevision.NumberOfPages;
                        int  intPageLoc   = Convert.ToInt32(lngPageCount) + 1;

                        destDocument.DefaultRenditionOfLatestRevision.Imaging.AddPages(sourcePageDataList, intPageLoc);
                    }

                    app.Diagnostics.Write(string.Format("Pages added to document {0}", destinationDocHandle.ToString()));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Error in AppendDocument: {0}", ex.Message));
            }
            return(true);
        }