コード例 #1
0
ファイル: StorageService.cs プロジェクト: maurbone/DocSuitePA
        private IStorage InitializeStorageInstance(Document document)
        {
            if (document == null)
            {
                throw new ArgumentNullException("Non è stato definito il parametro document");
            }

            if (document.Storage == null)
            {
                throw new StorageNotFound_Exception($"Il documento {document.IdDocument} non è stato trovato nello storage");
            }

            DocumentStorageType storageType = document.Storage.StorageType;

            if (storageType == null)
            {
                storageType = CommonServices.StorageService.GetStorageTypeByStorage(document.Storage.IdStorage);
            }

            IStorage storageInstance = new StorageInstanceBuilder($"{storageType.StorageAssembly}.{storageType.StorageClassName}").BuildStorage();

            if (storageInstance == null)
            {
                throw new Generic_Exception($"Nessuna tipologia di storage trovata per il documento {document.IdDocument}");
            }
            return(storageInstance);
        }
コード例 #2
0
ファイル: StorageService.cs プロジェクト: maurbone/DocSuitePA
        public void DeleteDocument(Document document, bool includeAttributes = true)
        {
            if (document == null)
            {
                throw new ArgumentNullException("Non è stato definito il parametro document");
            }

            DocumentStorageType storageType = document.Storage.StorageType;

            if (storageType == null)
            {
                storageType = CommonServices.StorageService.GetStorageTypeByStorage(document.Storage.IdStorage);
            }

            IStorage storageInstance = new StorageInstanceBuilder($"{storageType.StorageAssembly}.{storageType.StorageClassName}").BuildStorage();

            if (includeAttributes)
            {
                storageInstance.DeleteDocument(document);
                return;
            }
            storageInstance.DeleteDocumentWithoutAttributes(document);
        }