Exemple #1
0
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            try
            {
                BindingList <DocumentAttributeValue> saveAttributes = new BindingList <DocumentAttributeValue>();
                FileTableModel foundAttributeDocument = DocumentService.GetAttributesByDocumentFromSQLStorage(Document);
                if (foundAttributeDocument == null)
                {
                    throw new Exception(string.Concat("LoadAttributes -> attributes for documentid '", Document.IdDocument, "' not found"));
                }

                using (MemoryStream ms = new MemoryStream(foundAttributeDocument.FileStream))
                {
                    var attr = XElement.Load(ms).Elements("DocumentAttributeValue").Select(s => s);
                    DocumentAttributeValue attributeItem;
                    foreach (XElement element in attr)
                    {
                        attributeItem           = new DocumentAttributeValue();
                        attributeItem.Value     = element.Element("Value").Value.TryConvert(Type.GetType(element.Element("Attribute").Element("AttributeType").Value));
                        attributeItem.Attribute = new DocumentAttribute()
                        {
                            IdAttribute = new Guid(element.Element("Attribute").Element("IdAttribute").Value),
                            Name        = element.Element("Attribute").Element("Name").Value
                        };
                        saveAttributes.Add(attributeItem);
                    }
                }
                return(saveAttributes);
            }
            catch (Exception ex)
            {
                throw new Common.Exceptions.Attribute_Exception("LoadAttributes -> attributes modified." + ex.Message);
            }
        }
Exemple #2
0
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            string storage = GetStorageDir(Document.Storage, Document.StorageArea);

            try
            {
                BindingList <DocumentAttributeValue> saveAttributes = new BindingList <DocumentAttributeValue>();
                //Gianni: Use linq to Xml because with the object type of value th deserialize fail
                var attr = from c in XElement.Load(Path.Combine(storage, string.Format("{0}{2}.{1}", Document.IdDocument, "xml", Path.GetExtension(Document.Name)))).Elements("DocumentAttributeValue")
                           select c;
                DocumentAttributeValue attributeItem;
                foreach (var item in attr)
                {
                    attributeItem           = new DocumentAttributeValue();
                    attributeItem.Value     = item.Element("Value").Value.TryConvert(Type.GetType(item.Element("Attribute").Element("AttributeType").Value));
                    attributeItem.Attribute = new DocumentAttribute {
                        IdAttribute = new Guid(item.Element("Attribute").Element("IdAttribute").Value),
                        Name        = item.Element("Attribute").Element("Name").Value
                    };
                    saveAttributes.Add(attributeItem);
                }
                //using (StreamReader objStreamReader = new StreamReader(Path.Combine(storage, string.Format("{0}{2}.{1}", Document.IdDocument, "xml", Path.GetExtension(Document.Name)))))
                //{
                //    XmlSerializer x = new XmlSerializer(saveAttributes.GetType());
                //    saveAttributes = (BindingList<DocumentAttributeValue>)x.Deserialize(objStreamReader);
                //}
                return(saveAttributes);
            }
            catch (Exception ex)
            {
                throw new BiblosDS.Library.Common.Exceptions.Attribute_Exception("Attributi modificati." + ex.Message);
            }
        }
Exemple #3
0
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            byte[] metadata = null;

            try
            {
                logger.InfoFormat("LoadAttributes " + Document.IdDocument);
                string[] pathAndPort = Document.Storage.MainPath.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                string   path        = pathAndPort.FirstOrDefault();
                string   port        = pathAndPort.LastOrDefault();

                logger.Debug(path + " (port" + port + ")");

                FTPFactory fact = new FTPFactory();
                fact.setRemoteUser(Document.Storage.AuthenticationKey);
                fact.setRemotePass(Document.Storage.AuthenticationPassword);
                fact.setRemoteHost(path);
                fact.setRemotePath(Document.StorageArea.Path);
                fact.setRemotePort(int.Parse(port));

                fact.login();
                string LocalFilePath = Path.GetTempFileName();
                fact.download(string.Format("{0}{2}.{1}", Document.IdDocument, "xml", Path.GetExtension(Document.Name)), LocalFilePath);

                metadata = File.ReadAllBytes(LocalFilePath);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                throw;
            }
            try
            {
                XmlTextReader reader = new XmlTextReader(new MemoryStream(metadata));

                BindingList <DocumentAttributeValue> saveAttributes = new BindingList <DocumentAttributeValue>();
                //Gianni: Use linq to Xml because with the object type of value th deserialize fail
                var attr = from c in XElement.Load(reader).Elements("DocumentAttributeValue")
                           select c;
                DocumentAttributeValue attributeItem;
                foreach (var item in attr)
                {
                    attributeItem           = new DocumentAttributeValue();
                    attributeItem.Value     = item.Element("Value").Value.TryConvert(Type.GetType(item.Element("Attribute").Element("AttributeType").Value));
                    attributeItem.Attribute = new DocumentAttribute
                    {
                        IdAttribute = new Guid(item.Element("Attribute").Element("IdAttribute").Value),
                        Name        = item.Element("Attribute").Element("Name").Value
                    };
                    saveAttributes.Add(attributeItem);
                }
                return(saveAttributes);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(Document.AttributeValues);
        }
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            BindingList <DocumentAttributeValue> attributeValues = new BindingList <DocumentAttributeValue>();
            ClientContext context = new ClientContext(Document.Storage.MainPath);

            context.Credentials = new NetworkCredential(Document.Storage.AuthenticationKey, Document.Storage.AuthenticationPassword);
            Web  web  = context.Web;
            List docs = web.Lists.GetByTitle(Document.Storage.Name);

            context.ExecuteQuery();
            Folder foolder = docs.RootFolder;

            if (!string.IsNullOrEmpty(Document.StorageArea.Path))
            {
                if ((foolder = docs.RootFolder.Folders.Where(x => x.Name == Document.StorageArea.Path).FirstOrDefault()) == null)
                {
                    throw new BiblosDS.Library.Common.Exceptions.StorageAreaConfiguration_Exception("StorageArea not found:" + Document.StorageArea.Path);
                }
            }
            context.ExecuteQuery();
            string             fileName    = GetIdDocuemnt(Document) + System.IO.Path.GetExtension(Document.Name);
            IEnumerable <File> resultFiles = context.LoadQuery(foolder.Files.Where(x => x.Name == fileName).Include(x => x.ListItemAllFields));

            context.ExecuteQuery();
            File file = resultFiles.FirstOrDefault();

            if (file == null)
            {
                throw new BiblosDS.Library.Common.Exceptions.FileNotFound_Exception();
            }
            //if (Document.StorageVersion.HasValue && file.Versions.Count > 0)
            //    file = file.Versions.Where(x => x.VersionLabel == Document.StorageVersion.Value.ToString()).First();
            BindingList <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(Document.Archive.IdArchive);
            ListItem listItem = file.ListItemAllFields;

            foreach (var item in listItem.FieldValues.Keys)
            {
                try
                {
                    DocumentAttribute attribute = attributes.Where(x => x.Name == item).Single();
                    if (attribute != null)
                    {
                        DocumentAttributeValue attr = new DocumentAttributeValue();
                        attr.Attribute = attribute;
                        attr.Value     = listItem.FieldValues[item];
                        attributeValues.Add(attr);
                    }
                }
                catch (Exception)
                {
                }
            }
            return(attributeValues);
        }
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            BindingList <DocumentAttributeValue> attributeValues = new BindingList <DocumentAttributeValue>();

            try
            {
                SPSite            site   = null;
                SPWeb             web    = null;
                SPDocumentLibrary doclib = null;
                SPFile            file   = null;
                using (site = new SPSite(Document.Storage.MainPath))
                {
                    using (web = site.OpenWeb())
                    {
                        //SPFolder Folder = web.GetFolder(Document.Storage.Name);
                        doclib = web.Lists[Document.Storage.Name] as SPDocumentLibrary;
                        if (!string.IsNullOrEmpty(Document.StorageArea.Path))
                        {
                            file = doclib.RootFolder.SubFolders[Document.StorageArea.Path].Files[GetIdDocuemnt(Document) + Path.GetExtension(Document.Name)];
                        }
                        else
                        {
                            file = doclib.RootFolder.Files[GetIdDocuemnt(Document) + Path.GetExtension(Document.Name)];
                        }
                        BindingList <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(Document.Archive.IdArchive);
                        foreach (var item in file.Properties.Keys)
                        {
                            try
                            {
                                DocumentAttribute attribute = attributes.Where(x => x.Name == item.ToString()).Single();
                                if (attribute != null)
                                {
                                    DocumentAttributeValue attr = new DocumentAttributeValue();
                                    attr.Attribute = attribute;
                                    attr.Value     = file.Properties[item].ToString();
                                    attributeValues.Add(attr);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Write the log
                throw new FileNotFound_Exception("File non trovato" + Environment.NewLine + ex.ToString());
            }
            return(attributeValues);
        }
        private string FormatAttributeValue(DocumentAttributeValue attributeValue)
        {
            if (attributeValue?.Value == null)
            {
                return(string.Empty);
            }

            if (attributeValue.Attribute.AttributeType == "System.DateTime")
            {
                return(DateTime.Parse(attributeValue.Value.ToString()).ToString("dd/MM/yyyy"));
            }
            return(attributeValue.Value.ToString());
        }
        protected override BindingList <DocumentAttributeValue> LoadAttributes(Document Document)
        {
            BindingList <DocumentAttributeValue> attributeValues = new BindingList <DocumentAttributeValue>();

            try
            {
                BasicHttpBinding binding = new BasicHttpBinding();
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.None;

                BiblosSvcClient client = new BiblosSvcClient(binding, new EndpointAddress(Document.Storage.MainPath));
                client.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(Document.Storage.AuthenticationKey, Document.Storage.AuthenticationPassword);
                client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
                string fileName     = GetIdDocuemnt(Document) + Path.GetExtension(Document.Name);
                var    attributesSP = client.GetFileAttributes(Document.Storage.Name, Document.StorageArea.Path, Document.DocumentParent.IdDocument.ToString(), fileName, Document.StorageVersion.HasValue ? (int)Document.StorageVersion.Value : 0);

                BindingList <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(Document.Archive.IdArchive);
                foreach (var item in attributes)
                {
                    try
                    {
                        if (attributesSP.ContainsKey(item.Name))
                        {
                            DocumentAttributeValue attr = new DocumentAttributeValue();
                            attr.Attribute = item;
                            attr.Value     = attributesSP[item.Name];
                            attributeValues.Add(attr);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                //Write the log
                Logging.WriteLogEvent(BiblosDS.Library.Common.Enums.LoggingSource.BiblosDS_Sharepoint,
                                      "LoadAttributes",
                                      ex.ToString(),
                                      BiblosDS.Library.Common.Enums.LoggingOperationType.BiblosDS_General,
                                      BiblosDS.Library.Common.Enums.LoggingLevel.BiblosDS_Errors);
                throw;
            }
            return(attributeValues);
        }
Exemple #8
0
    private BindingList <Document> getDocumentsByAttributeValue(string archiveName, string attributeName, string attributeValue, bool?stringContains, int?skip, int?take)
    {
        try
        {
            // Recupero l'archivio.
            DocumentArchive archive = ArchiveService.GetArchiveByName(archiveName);
            // Recupero l'attributo a partire dal suo nome.
            BindingList <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(archive.IdArchive);
            DocumentAttribute      attribute           = getAttributeByArchiveAndName(archive, attributeName);
            DocumentAttributeValue value = new DocumentAttributeValue {
                Attribute = attribute, Value = attributeValue
            };

            return(getDocumentsByAttributeValue(archive, value, stringContains, skip, take));
        }
        catch (Exception ex)
        {
            logger.Error(ex);
            throw;
        }
    }
        private FileGruppoFile[] GetIpdaFiles(Objects.Preservation preservation, IDictionary <Guid, BindingList <DocumentAttributeValue> > fullDocumentAttributes)
        {
            logger.Info("GetIpdaFiles - INIT");
            List <FileGruppoFile> files = new List <FileGruppoFile>();
            var attributes = DbProvider.GetAttributesFromArchive(preservation.IdArchive)
                             .Where(x => !x.ConservationPosition.HasValue || x.ConservationPosition.Value > 0)
                             .OrderBy(x => x.ConservationPosition);

            foreach (var doc in preservation.Documents.OrderBy(x => x.PreservationIndex))
            {
                BindingList <DocumentAttributeValue> docAttributes = fullDocumentAttributes[doc.IdDocument];
                List <FgAttributo> attrList = new List <FgAttributo>();
                foreach (var attr in attributes)
                {
                    FgAttributo fgAttr = new FgAttributo();

                    DocumentAttributeValue currAttributeValue = docAttributes.Where(x => x.IdAttribute == attr.IdAttribute).FirstOrDefault();
                    if (currAttributeValue == null)
                    {
                        continue;
                    }

                    if (currAttributeValue.Attribute == null)
                    {
                        currAttributeValue.Attribute = attr;
                    }

                    fgAttr.nome = string.IsNullOrEmpty(attr.Description) ? attr.Name : attr.Description;

                    //L'attributo va formattato in funzione della proprieta' "Format" dell'Attributo, se valorizzata.
                    string valoreAttr;
                    if (currAttributeValue.Attribute != null && !string.IsNullOrEmpty(currAttributeValue.Attribute.Format))
                    {
                        try
                        {
                            valoreAttr = string.Format(currAttributeValue.Attribute.Format, currAttributeValue.Value);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex);
                            valoreAttr = string.Empty;
                        }
                    }
                    else
                    {
                        valoreAttr = (currAttributeValue.Value != null) ? currAttributeValue.Value.ToString() : string.Empty;
                    }

                    fgAttr.valore = valoreAttr;
                    attrList.Add(fgAttr);
                }

                string fileName = string.Format("{0}{1}", PurgeFileName(docAttributes, string.IsNullOrEmpty(doc.PrimaryKeyValue) ? doc.PreservationIndex.GetValueOrDefault().ToString() : doc.PrimaryKeyValue), Path.GetExtension(doc.Name));

                attrList.Insert(0, new FgAttributo
                {
                    nome   = "NomeFileInArchivio",
                    valore = fileName
                });

                attrList.Add(new FgAttributo
                {
                    nome   = "ImprontaFileSHA256",
                    valore = doc.DocumentHash
                });

                files.Add(new FileGruppoFile
                {
                    id        = fileName,
                    impronta  = doc.DocumentHash,
                    extraInfo = new FgExtraInfo
                    {
                        metadati = new FgMetadati
                        {
                            attributoList = attrList.ToArray()
                        }
                    }
                });
            }
            logger.Info("GetIpdaFiles - END");
            return(files.ToArray());
        }
        private ICollection <UnZipReportViewModel> UnZipRDVSignedFile(string zipPath, Guid idArchive)
        {
            ICollection <UnZipReportViewModel> viewModel = new List <UnZipReportViewModel>();

            if (System.IO.File.Exists(zipPath))
            {
                using (Stream stream = System.IO.File.OpenRead(zipPath))
                    using (IReader reader = ReaderFactory.Open(stream))
                        using (DocumentsClient client = new DocumentsClient())
                        {
                            while (reader.MoveToNextEntry())
                            {
                                if (!reader.Entry.IsDirectory)
                                {
                                    string fileName = Path.GetFileName(reader.Entry.Key);
                                    _logger.InfoFormat("UnZipRDVSignedFile -> Lettura file {0}", fileName);

                                    string awardBatchIdStr = fileName.Split('_').FirstOrDefault();
                                    if (Guid.TryParse(awardBatchIdStr, out Guid idAwardBatch))
                                    {
                                        if (!Path.GetExtension(fileName).Equals(".p7m", StringComparison.InvariantCultureIgnoreCase) && !Path.GetExtension(fileName).Equals(".tsd", StringComparison.InvariantCultureIgnoreCase))
                                        {
                                            _logger.WarnFormat("UnZipRDVSignedFile -> Il file {0} non risulta firmato", fileName);
                                            viewModel.Add(new UnZipReportViewModel()
                                            {
                                                ReferenceId = idAwardBatch,
                                                Description = string.Format("Il file <b>{0}</b> non risulta firmato ed è stato scartato.", fileName),
                                                LogType     = UnZipReportViewModel.TYPE_WARN
                                            });
                                            continue;
                                        }

                                        AwardBatch awardBatch = _preservationService.GetAwardBatch(idAwardBatch);
                                        if (awardBatch == null)
                                        {
                                            _logger.WarnFormat("UnZipRDVSignedFile -> Nessun pacchetto di versamento trovato con id {0}", idAwardBatch);
                                            viewModel.Add(new UnZipReportViewModel()
                                            {
                                                ReferenceId = idAwardBatch,
                                                Description = string.Format("Nessun pacchetto di versamento trovato con id {0}", idAwardBatch),
                                                LogType     = UnZipReportViewModel.TYPE_ERROR
                                            });
                                            continue;
                                        }

                                        if (awardBatch.IdArchive != idArchive)
                                        {
                                            _logger.WarnFormat("UnZipRDVSignedFile -> Il pacchetto di versamento {0} non fa parte dell'archivio {0}", idAwardBatch, idArchive);
                                            viewModel.Add(new UnZipReportViewModel()
                                            {
                                                ReferenceId = idAwardBatch,
                                                Description = string.Format("Il pacchetto di versamento <b>{0}</b> non fa parte dell'archivio selezionato e verrà scartato.", awardBatch.Name),
                                                LogType     = UnZipReportViewModel.TYPE_ERROR
                                            });
                                            continue;
                                        }

                                        if (awardBatch.IsRDVSigned.HasValue && awardBatch.IsRDVSigned.Value)
                                        {
                                            _logger.WarnFormat("UnZipRDVSignedFile -> Il pacchetto di versamento con id {0} risulta già firmato.", idAwardBatch);
                                            viewModel.Add(new UnZipReportViewModel()
                                            {
                                                ReferenceId = idAwardBatch,
                                                Description = string.Format("Il pacchetto di versamento <b>{0}</b> risulta già firmato e verrà scartato.", awardBatch.Name),
                                                LogType     = UnZipReportViewModel.TYPE_WARN
                                            });
                                            continue;
                                        }

                                        if (!awardBatch.IdRDVDocument.HasValue)
                                        {
                                            _logger.WarnFormat("UnZipRDVSignedFile -> Nessun RDV presente per il pacchetto di versamento trovato con id {0}", idAwardBatch);
                                            viewModel.Add(new UnZipReportViewModel()
                                            {
                                                ReferenceId = idAwardBatch,
                                                Description = string.Format("Nessun RDV presente per il pacchetto di versamento <b>{0}</b>", awardBatch.Name),
                                                LogType     = UnZipReportViewModel.TYPE_ERROR
                                            });
                                            continue;
                                        }

                                        _logger.DebugFormat("UnZipRDVSignedFile -> CheckOut documento con id {0}", awardBatch.IdRDVDocument);
                                        Document document = client.CheckOutDocument(awardBatch.IdRDVDocument.Value, idAwardBatch.ToString(), Library.Common.Enums.DocumentContentFormat.Binary, false);
                                        using (MemoryStream ms = new MemoryStream())
                                        {
                                            reader.WriteEntryTo(ms);
                                            document.Content = new DocumentContent(ms.ToArray());
                                            document.Name    = UtilityService.GetSafeFileName(fileName.Substring(fileName.IndexOf('_') + 1));
                                            DocumentAttributeValue fileNameAttribute = document.AttributeValues.FirstOrDefault(x => x.Attribute.Name.Equals("Filename", StringComparison.InvariantCultureIgnoreCase));
                                            fileNameAttribute.Value = document.Name;
                                            _logger.DebugFormat("UnZipRDVSignedFile -> CheckIn documento firmato con id {0}", awardBatch.IdRDVDocument);
                                            client.CheckInDocument(document, idAwardBatch.ToString(), Library.Common.Enums.DocumentContentFormat.Binary, null);
                                        }

                                        awardBatch.IsRDVSigned = true;
                                        _preservationService.UpdateAwardBatch(awardBatch);
                                        viewModel.Add(new UnZipReportViewModel()
                                        {
                                            ReferenceId = idAwardBatch,
                                            Description = string.Format("Pacchetto di versamento <b>{0}</b> aggiornato correttamente", awardBatch.Name),
                                            LogType     = UnZipReportViewModel.TYPE_SUCCESS
                                        });
                                    }
                                }
                            }
                        }
            }
            return(viewModel);
        }
        private AwbBatchFile[] GetAwardBatchFiles(Objects.Preservation preservation, Guid idBatch, IDictionary <Guid, BindingList <DocumentAttributeValue> > fullDocumentAttributes)
        {
            List <AwbBatchFile> files = new List <AwbBatchFile>();
            var attributes            = DbProvider.GetAttributesFromArchive(preservation.IdArchive)
                                        .Where(x => !x.ConservationPosition.HasValue || x.ConservationPosition.Value > 0)
                                        .OrderBy(x => x.ConservationPosition);

            foreach (var doc in preservation.Documents.OrderBy(x => x.PreservationIndex))
            {
                //salta i documenti che non sono di questo lotto
                if (doc.IdAwardBatch != idBatch)
                {
                    continue;
                }

                BindingList <DocumentAttributeValue> docAttributes = fullDocumentAttributes[doc.IdDocument];
                List <AwbBatchFileAttribute>         attrList      = new List <AwbBatchFileAttribute>();
                foreach (var attr in attributes)
                {
                    AwbBatchFileAttribute awbAttr = new AwbBatchFileAttribute();

                    DocumentAttributeValue currAttributeValue = docAttributes.Where(x => x.IdAttribute == attr.IdAttribute).FirstOrDefault();
                    if (currAttributeValue == null)
                    {
                        continue;
                    }

                    if (currAttributeValue.Attribute == null)
                    {
                        currAttributeValue.Attribute = attr;
                    }

                    awbAttr.Nome = string.IsNullOrEmpty(attr.Description) ? attr.Name : attr.Description;

                    //L'attributo va formattato in funzione della proprieta' "Format" dell'Attributo, se valorizzata.
                    string valoreAttr;
                    if (currAttributeValue.Attribute != null && !string.IsNullOrEmpty(currAttributeValue.Attribute.Format))
                    {
                        try
                        {
                            valoreAttr = string.Format(currAttributeValue.Attribute.Format, currAttributeValue.Value);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex);
                            valoreAttr = string.Empty;
                        }
                    }
                    else
                    {
                        valoreAttr = (currAttributeValue.Value != null) ? currAttributeValue.Value.ToString() : string.Empty;
                    }

                    awbAttr.Valore = valoreAttr;
                    attrList.Add(awbAttr);
                }

                string fileName = string.Format("{0}{1}", PurgeFileName(docAttributes, string.IsNullOrEmpty(doc.PrimaryKeyValue) ? doc.PreservationIndex.GetValueOrDefault().ToString() : doc.PrimaryKeyValue), Path.GetExtension(doc.Name));

                attrList.Insert(0, new AwbBatchFileAttribute
                {
                    Nome   = "NomeFileInArchivio",
                    Valore = fileName
                });

                attrList.Add(new AwbBatchFileAttribute
                {
                    Nome   = "ImprontaFileSHA256",
                    Valore = doc.DocumentHash
                });

                files.Add(new AwbBatchFile
                {
                    Attributes = attrList.ToArray()
                });
            }

            return(files.ToArray());
        }
Exemple #12
0
    private BindingList <Document> getDocumentsByAttributeValue(DocumentArchive archive, DocumentAttributeValue attributeValue, bool?stringContains, int?skip, int?take)
    {
        try
        {
            logger.InfoFormat("getDocumentsByAttributeValue archive.IdArchive:{0} archive.Name:{1} attributeValue.Attribute.Name:{2} attributeValue.Value:{3}",
                              archive.IdArchive, archive.Name, attributeValue.Attribute.Name, attributeValue.Value);

            BindingList <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(archive.IdArchive);
            // Recupero la lista di documenti.
            BindingList <Document> documents = DocumentService.GetDocumentsByAttributeValue(archive, attributeValue, stringContains, skip, take);
            if (documents == null || documents.Count == 0)
            {
                throw new DocumentNotFound_Exception("Nessun documento trovato con attributo \"{0}\" e valore \"{1}\".",
                                                     attributeValue.Attribute.Name, attributeValue.Value);
            }

            logger.InfoFormat("getDocumentsByAttributeValue documenti trovati: {0}.", documents.Count);
            return(documents);
        }
        catch (Exception ex)
        {
            logger.Error(ex);
            throw;
        }
    }