示例#1
0
        /// <summary>
        /// Inserisce un nuovo Archive
        /// </summary>
        /// <param name="Archive">DocumentArchive da inserire</param>
        public static Guid AddArchive(DocumentArchive Archive)
        {
            // IsLegal è sempre true o false e LastIdBiblos non è mai null
            if (String.IsNullOrEmpty(Archive.Name))
            {
                throw new Exception("Impossibile proseguire. Name deve essere valorizzato");
            }

            return(DbAdminProvider.AddArchive(Archive));
        }
示例#2
0
 public static void UpdateStorageAreaRule(DocumentStorageAreaRule StorageAreaRule)
 {
     if (StorageAreaRule.StorageArea == null ||
         StorageAreaRule.StorageArea.IdStorageArea == Guid.Empty ||
         StorageAreaRule.Attribute == null ||
         StorageAreaRule.Attribute.IdAttribute == Guid.Empty)
     {
         throw new Exception("Requisiti non sufficienti per l'operazione");
     }
     DbAdminProvider.UpdateStorageAreaRule(StorageAreaRule);
 }
示例#3
0
        public static Guid AddStorage(DocumentStorage Storage)
        {
            // EnableFulText è sempre valorizzato
            if (Storage.StorageType == null ||
                Storage.StorageType.IdStorageType == Guid.Empty)
            {
                throw new Exception("Impossibile proseguire. StorageType non assegnato.");
            }

            return(DbAdminProvider.AddStorage(Storage));
        }
示例#4
0
        public static Guid AddStorageArea(DocumentStorageArea StorageArea)
        {
            if (string.IsNullOrEmpty(StorageArea.Name) ||
                StorageArea.Storage == null ||
                StorageArea.Storage.IdStorage == Guid.Empty)
            {
                throw new Exception("Requisiti non sufficienti per l'operazione");
            }

            return(DbAdminProvider.AddStorageArea(StorageArea));
        }
示例#5
0
 /// <summary>
 /// Salva le modifiche a un DocumentAttribute
 /// </summary>
 /// <param name="DocumentAttribute">DocumentAttribute modificato</param>
 public static void UpdateAttribute(DocumentAttribute DocumentAttribute)
 {
     if (DocumentAttribute.IdAttribute == Guid.Empty ||
         string.IsNullOrEmpty(DocumentAttribute.Name) ||
         string.IsNullOrEmpty(DocumentAttribute.AttributeType) ||
         DocumentAttribute.Archive == null ||
         DocumentAttribute.Mode == null)
     {
         throw new Exception("Requisiti non sufficienti per l'operazione");
     }
     DbAdminProvider.UpdateAttribute(DocumentAttribute);
 }
示例#6
0
        /// <summary>
        /// Elimina permanentemente una relazione Archive-Storage
        /// </summary>
        /// <param name="ArchiveStorage">DocumentArchiveStorage da eliminare</param>
        public static void DeleteArchiveStorage(DocumentArchiveStorage ArchiveStorage)
        {
            if (ArchiveStorage.Archive == null ||
                ArchiveStorage.Archive.IdArchive == null ||
                ArchiveStorage.Storage == null ||
                ArchiveStorage.Storage.IdStorage == null)
            {
                throw new Exception("Impossibile proseguire. Archive e Storage devono essere valorizzati");
            }

            DbAdminProvider.DeleteArchiveStorage(ArchiveStorage);
        }
示例#7
0
        public static void UpdateStorage(DocumentStorage Storage)
        {
            // EnableFulText è sempre valorizzato
            if (Storage.IdStorage == Guid.Empty)
            {
                throw new Exception("Impossibile proseguire. IdStorage non valido.");
            }
            if (Storage.StorageType == null ||
                Storage.StorageType.IdStorageType == Guid.Empty)
            {
                throw new Exception("Impossibile proseguire. StorageType non assegnato.");
            }

            DbAdminProvider.UpdateStorage(Storage);
        }
示例#8
0
        public static void UpdateStorageArea(DocumentStorageArea StorageArea)
        {
            if (StorageArea.IdStorageArea == Guid.Empty)
            {
                throw new Exception("Impossibile proseguire. IdStorageArea non valido.");
            }
            if (string.IsNullOrEmpty(StorageArea.Name) ||
                StorageArea.Storage == null ||
                StorageArea.Storage.IdStorage == Guid.Empty)
            {
                throw new Exception("Requisiti non sufficienti per l'operazione");
            }

            DbAdminProvider.UpdateStorageArea(StorageArea);
        }
示例#9
0
 /// <summary>
 /// Restituisce l'elenco di tutti i DocumentAttributeMode disponibili
 /// </summary>
 /// <returns>BindingList<DocumentAttributeMode> </returns>
 public static BindingList <DocumentAttributeMode> GetAttributeModes()
 {
     try
     {
         return(DbAdminProvider.GetAttributeModes());
     }
     catch (Exception e)
     {
         Logging.WriteLogEvent(BiblosDS.Library.Common.Enums.LoggingSource.BiblosDS_General,
                               "AttributeService." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                               e.ToString(),
                               BiblosDS.Library.Common.Enums.LoggingOperationType.BiblosDS_General,
                               BiblosDS.Library.Common.Enums.LoggingLevel.BiblosDS_Errors);
         throw e;
     }
 }
示例#10
0
 public static void AddStorageToArchive(Guid IdStorage, Guid IdArchive, bool Enable)
 {
     try
     {
         DbAdminProvider.AddStorageToArchive(IdStorage, IdArchive, Enable);
     }
     catch (Exception e)
     {
         Logging.WriteLogEvent(LoggingSource.BiblosDS_General,
                               "StorageService." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                               e.ToString(),
                               LoggingOperationType.BiblosDS_General,
                               LoggingLevel.BiblosDS_Errors);
         throw e;
     }
 }
示例#11
0
 public static DocumentStorageAreaRule GetStorageAreaRule(Guid IdStorageArea, Guid IdAttribute)
 {
     try
     {
         return(DbAdminProvider.GetStorageAreaRule(IdStorageArea, IdAttribute));
     }
     catch (Exception e)
     {
         Logging.WriteLogEvent(BiblosDS.Library.Common.Enums.LoggingSource.BiblosDS_General,
                               "StorageService." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                               e.ToString(),
                               BiblosDS.Library.Common.Enums.LoggingOperationType.BiblosDS_General,
                               BiblosDS.Library.Common.Enums.LoggingLevel.BiblosDS_Errors);
         throw e;
     }
 }
示例#12
0
 /// <summary>
 /// Restituisce l'elenco di tutte le relazioni storage-archive per lo storage selezionato
 /// </summary>
 /// <param name="Storage">DocumentStorage di cui ottenere le relazioni con gli archives</param>
 /// <returns>BindingList<DocumentArchiveStorage></returns>
 public static BindingList <DocumentArchiveStorage> GetStorageArchiveRelationsFromStorage(DocumentStorage Storage)
 {
     try
     {
         return(DbAdminProvider.GetStorageArchiveRelationsFromStorage(Storage.IdStorage));
     }
     catch (Exception e)
     {
         Logging.WriteLogEvent(BiblosDS.Library.Common.Enums.LoggingSource.BiblosDS_General,
                               "ArchiveStorageService." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                               e.ToString(),
                               BiblosDS.Library.Common.Enums.LoggingOperationType.BiblosDS_General,
                               BiblosDS.Library.Common.Enums.LoggingLevel.BiblosDS_Errors);
         throw e;
     }
 }
示例#13
0
 public static void InitializeFullTextStorage(DocumentStorage storage)
 {
     try
     {
         string safeStorageName = UtilityService.SafeSQLName(storage.Name);
         DbAdminProvider.InitializeFullTextStorage(safeStorageName, storage.MainPath);
     }
     catch (Exception ex)
     {
         Logging.WriteLogEvent(LoggingSource.BiblosDS_General,
                               "StorageService.InitializeFullTextStorage",
                               ex.ToString(),
                               LoggingOperationType.BiblosDS_General,
                               LoggingLevel.BiblosDS_Errors);
         throw;
     }
 }
示例#14
0
        /// <summary>
        /// Salva le modifiche a un DocumentArchive
        /// </summary>
        /// <param name="Archive">DocumentArchive modificato</param>
        public static void UpdateArchive(DocumentArchive Archive, bool convertDateMain = true)
        {
            // IsLegal è sempre true o false e LastIdBiblos non è mai null
            DocumentArchive dbArchive = DbProvider.GetArchive(Archive.IdArchive);

            if (Archive.IdArchive == Guid.Empty ||
                String.IsNullOrEmpty(Archive.Name))
            {
                throw new Exception("Impossibile proseguire. IdArchive e Name devono essere valorizzati");
            }

            DbAdminProvider.UpdateArchive(Archive);

            if (convertDateMain && dbArchive.IsLegal != Archive.IsLegal && Archive.IsLegal && DbProvider.ExistMainDateAttribute(Archive.IdArchive))
            {
                ConvertArchiveConservationEnabled(Archive);
            }
        }
示例#15
0
 /// <summary>
 /// Elimina permanentemente un DocumentAttribute
 /// </summary>
 /// <param name="IdAttribute">Guid del DocumentAttribute da eliminare</param>
 public static void DeleteAttribute(Guid IdAttribute)
 {
     DbAdminProvider.DeleteAttribute(IdAttribute);
 }
示例#16
0
        public static Guid CloneArchive(string templateName, string archiveName)
        {
            DocumentArchive            archiveToClone = null, existingArchive;
            List <DocumentAttribute>   attributesAdded   = new List <DocumentAttribute>();
            List <DocumentStorageArea> storageAreasAdded = new List <DocumentStorageArea>();
            List <DocumentStorage>     storagesAdded     = new List <DocumentStorage>();

            try
            {
                if (string.IsNullOrWhiteSpace(archiveName))
                {
                    throw new BiblosDS.Library.Common.Exceptions.Archive_Exception(string.Format("Destination archive name is null or empty for source archive {0}.", templateName));
                }

                archiveToClone = ArchiveService.GetArchiveByName(templateName);
                if (archiveToClone == null)
                {
                    throw new BiblosDS.Library.Common.Exceptions.Archive_Exception(string.Format("Archive with name {0} not found.", templateName));
                }
                //Il nome può essere lungo al massimo 63 caratteri.
                if (archiveName.Length > 63)
                {
                    archiveName = archiveName.Remove(63);
                }
                //Controlla se per caso l'archivio che si desidera clonare è già presente in banca dati.
                existingArchive = ArchiveService.GetArchiveByName(archiveName);

                if (existingArchive != null)
                {
                    return(existingArchive.IdArchive);
                }

                Guid idArchiveToClone = archiveToClone.IdArchive;
                archiveToClone.IdArchive = Guid.NewGuid();
                archiveToClone.Name      = Regex.Replace(archiveName, @"[^a-zA-Z0-9]", "-");
                if (!string.IsNullOrEmpty(archiveToClone.PathTransito) && archiveToClone.PathTransito.LastIndexOf('\\') > 0)
                {
                    archiveToClone.PathTransito = Path.Combine(archiveToClone.PathTransito.Substring(0, archiveToClone.PathTransito.LastIndexOf('\\')), archiveToClone.Name);
                }

                if (!string.IsNullOrEmpty(archiveToClone.PathPreservation) && archiveToClone.PathPreservation.LastIndexOf('\\') > 0)
                {
                    archiveToClone.PathPreservation = Path.Combine(archiveToClone.PathPreservation.Substring(0, archiveToClone.PathPreservation.LastIndexOf('\\')), archiveToClone.Name);
                }

                DbAdminProvider.AddArchive(archiveToClone);
                //Clone attributes
                var attributes = AttributeService.GetAttributesFromArchive(idArchiveToClone);
                foreach (var attributeItem in attributes)
                {
                    var attribute = new DocumentAttribute {
                        IdAttribute = Guid.NewGuid(), Archive = archiveToClone, AttributeType = attributeItem.AttributeType, ConservationPosition = attributeItem.ConservationPosition, DefaultValue = attributeItem.DefaultValue, Description = attributeItem.Description, Disabled = attributeItem.Disabled, Format = attributeItem.Format, IsAutoInc = attributeItem.IsAutoInc, IsChainAttribute = attributeItem.IsChainAttribute, IsEnumerator = attributeItem.IsEnumerator, IsMainDate = attributeItem.IsMainDate, IsRequired = attributeItem.IsRequired, IsRequiredForPreservation = attributeItem.IsRequiredForPreservation, IsSectional = attributeItem.IsSectional, IsUnique = attributeItem.IsUnique, IsVisible = attributeItem.IsVisible, IsVisibleForUser = attributeItem.IsVisibleForUser, KeyFilter = attributeItem.KeyFilter, KeyFormat = attributeItem.KeyFormat, KeyOrder = attributeItem.KeyOrder, MaxLenght = attributeItem.MaxLenght, Mode = attributeItem.Mode, Name = attributeItem.Name, Validation = attributeItem.Validation
                    };
                    DbAdminProvider.AddAttribute(attribute);
                    attributesAdded.Add(attribute);
                }
                //Retrive storage
                var storage = DbProvider.GetStoragesActiveFromArchive(idArchiveToClone);
                foreach (var storageItem in storage)
                {
                    var storageArea = DbProvider.GetStorageAreaActiveFromStorage(storageItem.IdStorage);
                    if (storageArea.Any(x => x.Archive != null && x.Archive.IdArchive == idArchiveToClone))
                    {
                        storageArea = new BindingList <DocumentStorageArea>(storageArea.Where(x => x.Archive != null && x.Archive.IdArchive == idArchiveToClone).ToList());
                    }

                    foreach (var storageAreaItem in storageArea)
                    {
                        var newStorageArea = new DocumentStorageArea {
                            IdStorageArea = Guid.NewGuid(), Archive = archiveToClone, Storage = storageItem, Enable = true, MaxFileNumber = storageAreaItem.MaxFileNumber, MaxSize = storageAreaItem.MaxSize, Name = archiveToClone.Name, Path = archiveToClone.Name, Priority = storageAreaItem.Priority, Status = storageAreaItem.Status
                        };
                        DbAdminProvider.AddStorageArea(newStorageArea);
                        storageAreasAdded.Add(newStorageArea);
                    }
                    DbAdminProvider.AddArchiveStorage(new DocumentArchiveStorage {
                        Storage = storageItem, Archive = archiveToClone, Active = true
                    });
                    storagesAdded.Add(storageItem);
                }
                return(archiveToClone.IdArchive);
            }
            catch (Exception)
            {
                try
                {
                    if (archiveToClone != null)
                    {
                        foreach (var item in storagesAdded)
                        {
                            DbAdminProvider.DeleteArchiveStorage(new DocumentArchiveStorage {
                                Archive = archiveToClone, Storage = item
                            });;
                        }
                        foreach (var item in storageAreasAdded)
                        {
                            DbAdminProvider.DeleteStorageArea(item.IdStorageArea);
                        }
                        foreach (var item in attributesAdded)
                        {
                            DbAdminProvider.DeleteAttribute(item.IdAttribute, false);
                        }
                        DbAdminProvider.DeleteArchive(archiveToClone);
                    }
                }
                catch (Exception ex)
                {
                    logger.Warn(ex);
                    throw;
                }
                throw;
            }
        }
示例#17
0
 public static void EnableDisableStorageToArchive(Guid IdStorage, Guid IdArchive, bool Enable)
 {
     DbAdminProvider.UpdateStorageToArchive(IdStorage, IdArchive, Enable);
 }
示例#18
0
 public static void UpdateStorageRule(DocumentStorageRule StorageRule)
 {
     DbAdminProvider.UpdateStorageRule(StorageRule);
 }