Ejemplo n.º 1
0
        public void ExportDocument(ref IExportDocument docRef, ref IExportTools exportTools, ref IExportImageSavingOptions imageOptions, ref string ExportFolder)
        {
            try
            {
                //string exportFolder = @"C:\MyExport";

                int      val  = 0;
                Guid     guid = Guid.NewGuid();
                Sections SectionsContainer = new Sections();
                exportSections(docRef.Children, ExportFolder, guid, ref val, ref SectionsContainer);
                exportImages(ref docRef, ref imageOptions, ExportFolder, ref SectionsContainer);
            }
            catch (Exception e)
            {
                docRef.Action.Succeeded    = false;
                docRef.Action.ErrorMessage = e.ToString();
            }
        }
Ejemplo n.º 2
0
///////////////////////////////////////////////////////////////////////////////////////////////////
        //private void exportImages(IExportDocument docRef, IExportTools exportTools, string exportFolder, ref Sections SectionsContainer)
        private void exportImages(ref IExportDocument docRef, ref IExportImageSavingOptions imageOptions, string exportFolder, ref Sections SectionsContainer)
        {
            /*IExportImageSavingOptions imageOptions = exportTools.NewImageSavingOptions();
             * imageOptions.Format = "pdf";
             * imageOptions.ColorType = "FullColor";
             * imageOptions.Resolution = 300;*/
            //StreamWriter sw = File.CreateText(@"C:\MyExport\pages.txt");
            int k;

            /*try
             * {*/
            for (int i = 0; i < SectionsContainer.Count; i++)
            {
                //sw.WriteLine(SectionsContainer[i].FileName + " : " + SectionsContainer[i].StartInd);
                //sw.WriteLine(i);
                //sw.Flush();
                foreach (IExportPage curPage in docRef.Pages)
                {
                    curPage.ExcludedFromDocumentImage = true;
                }
                if (i == SectionsContainer.Count - 1)
                {
                    k = docRef.Pages.Count;
                }
                else
                {
                    k = SectionsContainer[i + 1].StartInd;
                }
                for (int j = SectionsContainer[i].StartInd; j < k; j++)
                {
                    docRef.Pages[j].ExcludedFromDocumentImage = false;
                }

                docRef.SaveAs(exportFolder + "\\" + SectionsContainer[i].FileName + ".pdf", imageOptions);
            }

            /*}
             * //finally
             * //{
             * //  sw.Close();
             * }*/
        }
Ejemplo n.º 3
0
        public void ExportDocument(ref IExportDocument docRef, ref IExportTools exportTools, string XMLfolder)
        {
            try
            {
                session = new Session();

                string templateFolder = createTemplateFolder( XMLfolder);
                UpdateLogFile(templateFolder);

                string templateXMLfile = createTemplateXML(docRef, exportTools, templateFolder, docRef.TemplateName);
            }

            catch (Exception e)
            {
                docRef.Action.Succeeded = false;

                docRef.Action.ErrorMessage = e.ToString();
                UpdateLogFile(e.Message);
                //throw new NoDescException("Interface not implemented for " + objName);
                            }
        }
Ejemplo n.º 4
0
        // Getting the specified field
        private void getField(IExportField field, IExportDocument docRef, string fieldName)
        {
            // saving the field name

            if (field.Children != null)
            {
                getFields(field.Children, docRef, fieldName);
            }

            else if (field.Items != null)
            {
                getFields(field.Items, docRef, fieldName);
            }
            else if (field.Value != null)
            {
                if (field.IsExportable == true && field.Name == fieldName)
                {
                    fieldValue = field.Value.ToString();
                    //MessageBox.Show(field.Value.ToString(), fieldValue.ToString());
                }
            }
        }
Ejemplo n.º 5
0
 //string indent
 // Getting field collection
 private void getFields(IExportFields fields, IExportDocument docRef, string fieldName)
 {
     foreach (IExportField curField in fields)
     {
         getField(curField, docRef, fieldName);
     }
 }
Ejemplo n.º 6
0
        // Image export function.
        private string exportImages(IExportDocument docRef, IExportTools exportTools, string exportFolder)
        {
            string baseFileName = exportFolder + "\\" + "bantran";
            string baseFileNameFullpath = "";
            IExportImageSavingOptions imageOptions = exportTools.NewImageSavingOptions();

            imageOptions.Format = "tif";
            imageOptions.ColorType = "BlackAndWhite";
            imageOptions.Resolution = 300;
            imageOptions.ShouldOverwrite = true;
            docRef.SaveAs(baseFileName + ".tif", imageOptions);
            baseFileNameFullpath = baseFileName + ".tif";
            return baseFileNameFullpath;
        }
Ejemplo n.º 7
0
 //string indent
 // Exporting field collection
 private void exportFields(IExportFields fields, IExportDocument docRef, StreamWriter sw)
 {
     foreach (IExportField curField in fields)
     {
         //exportField(curField, docRef, indent);
         exportField(curField, docRef, sw);
     }
 }
Ejemplo n.º 8
0
        // Exporting the specified field
        private void exportField(IExportField field, IExportDocument docRef, StreamWriter sw)
        {
            // saving the field value it can be accessed
            if (IsNullFieldValue(field))
            {
                sw.WriteLine();
                //fieldvalue = "";
            }
            else
            {
                //sw.WriteLine("    " + field.Text);
                //fieldvalue = field.Text;
            }

            if (field.Children != null)
            {
                // exporting child fields
                //exportFields(field.Children, docRef, indent + "    ");
                exportFields(field.Children, docRef, sw);
            }

            else
            {
                if (field.Items != null)
                {
                    // exporting field instances
                    //exportFields(field.Items, docRef, indent + "    ");
                    exportFields(field.Items, docRef, sw);
                }
                else
                {
                    if (field.IsExportable == true)
                    {
                       // fLayer.DataSource.Add(field);
                        sw.Write(" " + field.Name);
                        sw.WriteLine("    " + field.Text);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        // Exporting info about document
        private void exportDocInfo(IExportDocument docRef, StreamWriter sw)
        {
            sw.WriteLine("Doc info:");
            sw.WriteLine("DocumentId " + docRef.Id);
            sw.WriteLine("IsAssembled " + docRef.IsAssembled);
            sw.WriteLine("IsVerified " + docRef.IsVerified);
            sw.WriteLine("IsExported " + docRef.IsExported);

            sw.WriteLine("ProcessingErrors " + docRef.ProcessingErrors);
            sw.WriteLine("ProcessingWarnings " + docRef.ProcessingWarnings);

            sw.WriteLine("TotalSymbolsCount " + docRef.TotalSymbolsCount);
            sw.WriteLine("RecognizedSymbolsCount " + docRef.RecognizedSymbolsCount);
            sw.WriteLine("UncertainSymbolsCount " + docRef.UncertainSymbolsCount);

            sw.WriteLine();
        }
Ejemplo n.º 10
0
        private string createTemplateXML(IExportDocument docRef, IExportTools exportTools, string tempfolder, string tempName)
        {
            string templateFolder = tempfolder;
            string templateName = tempName.ToString() + ".xml";
            string temp = templateFolder + "\\" + templateName;

            NTAccount ntAccount = new NTAccount("Everyone");
            SecurityIdentifier sid = (SecurityIdentifier)ntAccount.Translate(typeof(SecurityIdentifier));
            byte[] sidArray = new byte[sid.BinaryLength];
            sid.GetBinaryForm(sidArray, 0);

            if (!File.Exists(temp))
            {
                fileCabinetForm = new DocuwareFileCabinet(docRef, exportTools, temp);
                fileCabinetForm.ShowDialog();
            }
            if (File.Exists(temp))
            {
                // create the XmlReader object
                XmlReaderSettings settings = new XmlReaderSettings();
                XmlReader reader = XmlReader.Create(temp.ToString(), settings);

                int depth = -1; // tree depth is -1, no indentation

                while (reader.Read()) // display each node's content
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element: // XML Element, display its name
                            depth++; // increase tab depth
                            TabOutput(depth); // insert tabs

                            if (reader.Name == "FileCabinetName")
                            {
                                depth++;
                                reader.Read();
                                xmlfilecabinetpath = reader.Value;
                                depth--;
                                reader.Read();
                            }
                            if (reader.Name == "FieldName")
                            {
                                depth++;
                                reader.Read();
                                xmlfieldname = reader.Value;
                                fieldnamelist.Add(reader.Value);
                                getFields(docRef.Children, docRef, xmlfieldname);
                                depth--;
                                reader.Read();
                            }
                            if (reader.Name == "FieldIndex")
                            {
                                depth++;
                                reader.Read();
                                xmlfieldindex = reader.Value;
                                fieldindexlist.Add(Convert.ToUInt32(reader.Value));
                                depth--;
                                reader.Read();
                                openWith.Add(Convert.ToInt32(xmlfieldindex), fieldValue);
                            }

                            // if empty element, decrease depth
                            if (reader.IsEmptyElement)
                                depth--;
                            break;
                        case XmlNodeType.Comment: // XML Comment, display it
                            TabOutput(depth); // insert tabs
                            break;
                        case XmlNodeType.Text: // XML Text, display it
                            TabOutput(depth); // insert tabs
                            break;

                        // XML XMLDeclaration, display it
                        case XmlNodeType.XmlDeclaration:
                            TabOutput(depth); // insert tabs
                            break;
                        case XmlNodeType.EndElement: // XML EndElement, display it
                            TabOutput(depth); // insert tabs
                            depth--; // decrement depth
                            break;
                    } // end switch
                } // end while

                //------------------- DocuWare -------------------
                string fullimportimagepath = exportImages(docRef, exportTools, templateFolder);
                UpdateLogFile("Full path of current working image: "+fullimportimagepath);

                //select filecabinet
                filecabinet = new FileCabinet(session, xmlfilecabinetpath);
                UpdateLogFile(filecabinet.FileCabinetPath);
                filecabinet.Open();
                abasket = new ActiveBasket(session);

                // open basket
                basket = session.GetActiveBasket();
                basket = new Basket(session, abasket.BasketPath);
                UpdateLogFile("Active Basket Path: " + abasket.BasketPath);
                basket = new ActiveBasket(session);
                basket.Open();
                basket.SetAsActive();
                UpdateLogFile("Basket: "+basket.BasketPath);

                //sending bantran.tif to current basket.
                docum = basket.ImportFile(fullimportimagepath);

                UpdateLogFile("FileName: "+docum.FileName);
                if (File.Exists(fullimportimagepath))
                {
                    File.Delete(fullimportimagepath);
                }

                int numberofdocuments = basket.GetNumberOfDocuments();

                docum = new Document(basket, docum.FileName);
                UpdateLogFile("Name: " + docum.Name);
                UpdateLogFile("FileName: " + docum.FileName);

                if (!File.Exists(docum.FileName))
                {
                    UpdateLogFile(docum.FileName + " path does not exist after import into basket.");
                }

                try
                {
                    filecabinet.Store(docum, false, true, openWith);
                }
                catch (Exception e)
                {
                    UpdateLogFile(filecabinet.LastException.Message+ " | " + e.Message);
                }
            }
            return templateName;
        }