Ejemplo n.º 1
0
        protected override long SaveDocument(string localFilePath, DocumentStorage storage, DocumentStorageArea storageArea, Document document, BindingList <DocumentAttributeValue> attributeValue)
        {
            byte[] content  = File.ReadAllBytes(localFilePath);
            string fileName = GetFileName(document);

            //Save document
            DocumentService.AddDocumentToSQL(document, fileName, content, DocumentType.Default);

            //Save searchable document
            string searchableFileName;

            byte[] extractedContent = base.GetDocumentSignedContent(document, document.Content.Blob, out searchableFileName);
            searchableFileName = string.Concat(document.IdDocument, Path.GetExtension(searchableFileName));
            DocumentService.AddDocumentToSQL(document, searchableFileName, extractedContent, DocumentType.Searchable);

            //Write attributes on file system
            WriteAttributes(document);

            return(content.Length);
        }
Ejemplo n.º 2
0
        protected override void SaveAttributes(Document Document)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(Document.AttributeValues.GetType());

            using (MemoryStream stream = new MemoryStream())
            {
                XmlDocument doc = new XmlDocument();
                xmlSerializer.Serialize(stream, Document.AttributeValues);
                stream.Position = 0;
                doc.Load(stream);
                doc.DocumentElement.Attributes.RemoveAll();
                //Save attribute document
                string attributesFileName = string.Concat(Document.IdDocument, Path.GetExtension(Document.Name), ".xml");
                DocumentService.AddDocumentToSQL(Document, attributesFileName, stream.ToArray(), DocumentType.Attributes);
            }

            using (MemoryStream searchableStream = new MemoryStream())
            {
                XmlDocument doc = new XmlDocument();
                searchableStream.Position = 0;

                XmlElement rootElement = doc.CreateElement("Attributes");

                foreach (DocumentAttributeValue item in Document.AttributeValues)
                {
                    XmlElement element = doc.CreateElement(item.Attribute.Name);
                    element.InnerText = item.Value.ToString();
                    rootElement.AppendChild(element);
                }
                doc.AppendChild(rootElement);
                doc.Save(searchableStream);

                //Save searchable attribute document
                string attributesFileName = string.Concat(Document.IdDocument, Path.GetExtension(Document.Name), ".xml");
                DocumentService.AddDocumentToSQL(Document, attributesFileName, searchableStream.ToArray(), DocumentType.SearchableAttributes);
            }
        }
Ejemplo n.º 3
0
 protected override long WriteFile(string saveFileName, DocumentStorage storage, DocumentStorageArea storageArea, Document document, DocumentContent content)
 {
     DocumentService.AddDocumentToSQL(document, saveFileName, content.Blob, DocumentType.Attachment);
     return(content.Blob.Length);
 }