private async Task InsertImageAsync() {
     var filePath = HostingEnvironment.MapPath("~/Images/HT.jpg");
     var fileStream = new FileStream(filePath, FileMode.Open);
     var image = Image.FromStream(fileStream);
     var memoryStream = new MemoryStream();
     image.Save(memoryStream, ImageFormat.Jpeg);
     var imageDataProvider = new ImageDataProvider();
     await imageDataProvider.SaveImageAsync(memoryStream.ToArray());
 }
        public HttpResponseMessage Get(double lat, double lng)
        {
            var res = ImageDataProvider.FindNearby(lat, lng);

            if (res != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound));
        }
        // GET api/values
        public HttpResponseMessage Get()
        {
            var res = ImageDataProvider.GetAll();

            if (res != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound));
        }
        // PUT api/values/5
        public void Put(int NumberOfImages)
        {
            //TODO: MUST PROVIDE IMAGE ON BLOB
            Random r = new Random();

            for (int i = 0; i < NumberOfImages; i++)
            {
                double    lat = r.NextDouble() * (59.136236 - 59.113998) + 59.113998;
                double    lng = r.NextDouble() * (11.424700 - 11.339854) + 11.339854;
                ImageData d   = new ImageData(r.Next(1, 100000), DateTime.Now, lat, lng, "root");
                ImageDataProvider.InsertImage(d);
            }
        }
        // POST api/values
        public HttpResponseMessage Post(double lat, double lng)
        {
            IEnumerable <string> headerValues = Request.Headers.GetValues("Authorization");
            string accessToken = (string)headerValues.FirstOrDefault();
            string userId      = GraphProvider.getUserId(accessToken);

            if (userId == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
            string username = UserDataProvider.getUsername(Int64.Parse(userId));

            if (username == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }

            Random rnd       = new Random();
            string body      = Request.Content.ReadAsStringAsync().Result;
            string converted = body.Replace('-', '+');

            converted = converted.Replace('_', '/');
            //double lat, double lng, string user,
            int id;

            try
            {
                byte[]       imgByteArr = Convert.FromBase64String(converted);
                MemoryStream ms         = new MemoryStream(imgByteArr);
                BlobProvider provider   = new BlobProvider();
                //1 to max int32
                id = rnd.Next(1, 2147483647);
                provider.save(ms, id);
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            ImageData d = new ImageData(id, DateTime.Now, lat, lng, username);

            ImageDataProvider.InsertImage(d);
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #6
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var imageDataProvider = new ImageDataProvider();
            var imageFactory      = new ImageFactory();

            var convolutionFilter = new Bsuir.Misoi.Core.Images.Implementation.ConvolutionFilter();

            var binarizationFilter   = new BinarizationFilter();
            var segmentationAlogithm = new SegmentationAlgorithm(binarizationFilter);
            var findResultDrawer     = new FindResultDrawer();

            var _imageProcessorService = new ImageProcessorsService(convolutionFilter, segmentationAlogithm, findResultDrawer);

            var _imageRepository = new ImageRepository(imageDataProvider, imageFactory);

            var _imageUrlProvider = new ImageUrlProvider();

            var bitmap      = new Bitmap(pictureBox1.Image);
            var iimage      = new BitmapImage(bitmap);
            var result      = new ImageProcessorsResult();
            var sourceImage = iimage;

            var processResult = _imageProcessorService.ProcessImageAsync("Clip document", sourceImage).Result;

            if (processResult.Successful)
            {
                result.Successful = true;
                _imageRepository.SaveImageAsync(processResult.ProcessedImage).Wait();
                result.ProcessedImageUrl  = _imageUrlProvider.GetImageUrl(processResult.ProcessedImage.Name);
                result.ProcessedImageName = processResult.ProcessedImage.Name;
                result.SourceImageUrl     = _imageUrlProvider.GetImageUrl(sourceImage.Name);
                result.SourceImageName    = sourceImage.Name;
                pictureBox2.Image         = new Bitmap(processResult.ProcessedImage.Name + ".jpg");
            }
            else
            {
                result.Successful = false;
            }
            // return result;
        }
Пример #7
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");
            }
        }
        /***********************************************
        * 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));
            }
        }
 private async Task<byte[]> GetImageAsync() {
     var imageDataProvider = new ImageDataProvider();
     return await imageDataProvider.GetImageAsync();
 }
        /// <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");
            }
        }
Пример #11
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);
        }