Exemplo n.º 1
0
        public void UpdateAttribute(DocumentAttribute Attribute)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.Attributes entityAttribute = Attribute.TryToConvertTo <Model.Attributes>(false);

                if (entityAttribute.EntityKey == null)
                {
                    entityAttribute.EntityKey = db.CreateEntityKey(entityAttribute.GetType().Name, entityAttribute);
                }

                var attachedEntity = db.GetObjectByKey(entityAttribute.EntityKey) as Model.Attributes;

                if (Attribute.Mode != null)
                {
                    entityAttribute.IdMode = Attribute.Mode.IdMode;
                }

                if (Attribute.Archive != null)
                {
                    entityAttribute.IdArchive = Attribute.Archive.IdArchive;
                }

                if (Attribute.AttributeGroup != null)
                {
                    entityAttribute.IdAttributeGroup = Attribute.AttributeGroup.IdAttributeGroup;
                }

                db.ApplyCurrentValues(entityAttribute.EntityKey.EntitySetName, entityAttribute);
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void AddAttribute(DocumentAttribute Attribute)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.Attributes entityAttribute = Attribute.TryToConvertTo <Model.Attributes>(false);

                if (Attribute.Mode != null)
                {
                    entityAttribute.IdMode = Attribute.Mode.IdMode;
                }

                if (Attribute.Archive != null)
                {
                    entityAttribute.IdArchive = Attribute.Archive.IdArchive;
                }

                if (Attribute.AttributeGroup != null)
                {
                    entityAttribute.IdAttributeGroup = Attribute.AttributeGroup.IdAttributeGroup;
                }

                db.AddToAttributes(entityAttribute);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public void AddArchiveStorage(BiblosDS.Library.Common.Objects.DocumentArchiveStorage ArchiveStorage)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.ArchiveStorage entityArchiveStorage = ArchiveStorage.TryToConvertTo <Model.ArchiveStorage>(db);

                if (ArchiveStorage.Storage != null)
                {
                    entityArchiveStorage.IdStorage = ArchiveStorage.Storage.IdStorage;
                    //entityArchiveStorage.StorageReference.TryToAttach(new Model.Storage { IdStorage = ArchiveStorage.Storage.IdStorage }, db);
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Storage non valorizzato");
                }

                if (ArchiveStorage.Archive != null)
                {
                    entityArchiveStorage.IdArchive = ArchiveStorage.Archive.IdArchive;
                    //entityArchiveStorage.ArchiveReference.TryToAttach(new Model.Archive { IdArchive = ArchiveStorage.Archive.IdArchive }, db);
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Archivio non valorizzato");
                }

                //if (ArchiveStorage. != null)
                //    entityStorage.StorageTypeReference.TryToAttach(new Model.StorageType { IdStorageType = ArchiveStorage.StorageType.IdStorageType }, db);

                db.AddToArchiveStorage(entityArchiveStorage);
                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public void UpdateStorageArea(DocumentStorageArea StorageArea)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.StorageArea entityAttribute = StorageArea.TryToConvertTo <Model.StorageArea>(false);

                if (entityAttribute.EntityKey == null)
                {
                    entityAttribute.EntityKey = db.CreateEntityKey(entityAttribute.GetType().Name, entityAttribute);
                }

                var attachedEntity = db.GetObjectByKey(entityAttribute.EntityKey) as Model.StorageArea;

                if (StorageArea.Status != null && StorageArea.Status.IdStatus > 0)
                {
                    entityAttribute.IdStorageStatus = StorageArea.Status.IdStatus;
                }

                if (StorageArea.Storage != null)
                {
                    entityAttribute.IdStorage = StorageArea.Storage.IdStorage;
                }

                if (StorageArea.Archive != null)
                {
                    entityAttribute.IdArchive = StorageArea.Archive.IdArchive;
                }

                db.ApplyCurrentValues(entityAttribute.EntityKey.EntitySetName, entityAttribute);

                db.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public void AddStorageAreaRule(BiblosDS.Library.Common.Objects.DocumentStorageAreaRule StorageAreaRule)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.StorageAreaRule entityStorageAreaRule = StorageAreaRule.TryToConvertTo <Model.StorageAreaRule>(db);

                if (StorageAreaRule.StorageArea != null)
                {
                    entityStorageAreaRule.IdStorageArea = StorageAreaRule.StorageArea.IdStorageArea;
                    //entityStorageAreaRule.StorageAreaReference.TryToAttach(new Model.StorageArea { IdStorageArea = StorageAreaRule.StorageArea.IdStorageArea }, db);
                }
                else
                {
                    throw new Exception("StorageArea non valorizzato");
                }

                if (StorageAreaRule.Attribute != null)
                {
                    entityStorageAreaRule.IdAttribute = StorageAreaRule.Attribute.IdAttribute;
                    //entityStorageAreaRule.AttributesReference.TryToAttach(new Model.Attributes { IdAttribute = StorageAreaRule.Attribute.IdAttribute }, db);
                }
                else
                {
                    throw new Exception("Attribute non valorizzato");
                }

                if (StorageAreaRule.RuleOperator != null)
                {
                    entityStorageAreaRule.IdRuleOperator = StorageAreaRule.RuleOperator.IdRuleOperator;
                }

                db.AddToStorageAreaRule(entityStorageAreaRule);
                db.SaveChanges();
            }
        }
Exemplo n.º 6
0
        public Guid AddStorageArea(DocumentStorageArea StorageArea)
        {
            StorageArea.IdStorageArea = Guid.NewGuid();

            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.StorageArea entityAttribute = StorageArea.TryToConvertTo <Model.StorageArea>(false);

                if (StorageArea.Status != null && StorageArea.Status.IdStatus > 0)
                {
                    entityAttribute.IdStorageStatus = StorageArea.Status.IdStatus;
                }

                if (StorageArea.Storage != null)
                {
                    entityAttribute.IdStorage = StorageArea.Storage.IdStorage;
                }

                if (StorageArea.Archive != null)
                {
                    entityAttribute.IdArchive = StorageArea.Archive.IdArchive;
                }

                db.AddToStorageArea(entityAttribute);
                db.SaveChanges();
            }

            return(StorageArea.IdStorageArea);
        }
Exemplo n.º 7
0
        public void UpdateStorage(BiblosDS.Library.Common.Objects.DocumentStorage Storage)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.Storage entityStorage = Storage.TryToConvertTo <Model.Storage>(false);

                if (entityStorage.EntityKey == null)
                {
                    entityStorage.EntityKey = db.CreateEntityKey(entityStorage.GetType().Name, entityStorage);
                }

                var attachedEntity = db.GetObjectByKey(entityStorage.EntityKey) as Model.Storage;

                if (Storage.StorageType != null)
                {
                    entityStorage.IdStorageType = Storage.StorageType.IdStorageType;
                }

                if (Storage.Server != null && Storage.Server.IdServer != Guid.Empty)
                {
                    entityStorage.IdServer = Storage.Server.IdServer;
                }

                db.ApplyCurrentValues(entityStorage.EntityKey.EntitySetName, entityStorage);
                db.SaveChanges();
            }
        }
Exemplo n.º 8
0
 public Guid AddArchive(BiblosDS.Library.Common.Objects.DocumentArchive Archive)
 {
     Archive.IdArchive = Guid.NewGuid();
     using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
     {
         Model.Archive entityArchive = Archive.TryToConvertTo <Model.Archive>(db);
         db.AddToArchive(entityArchive);
         db.SaveChanges();
     }
     return(Archive.IdArchive);
 }
Exemplo n.º 9
0
 internal void DeleteArchive(DocumentArchive archiveToClone)
 {
     using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
     {
         Model.Archive entityArchive = db.Archive.Where(x => x.IdArchive == archiveToClone.IdArchive).SingleOrDefault();
         if (entityArchive != null)
         {
             db.Archive.DeleteObject(entityArchive);
             db.SaveChanges();
         }
     }
 }
Exemplo n.º 10
0
 public void DeleteArchiveStorage(BiblosDS.Library.Common.Objects.DocumentArchiveStorage ArchiveStorage)
 {
     using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
     {
         var entity = db.ArchiveStorage.Where(x => x.Archive.IdArchive == ArchiveStorage.Archive.IdArchive && x.Storage.IdStorage == ArchiveStorage.Storage.IdStorage).FirstOrDefault();
         if (entity == null)
         {
             throw new Exceptions.ArchiveStorage_Exception();
         }
         db.DeleteObject(entity);
         db.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public void DeleteStorageArea(Guid IdStorageArea)
 {
     using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
     {
         var entity = db.StorageArea.Where(x => x.IdStorageArea == IdStorageArea).First();
         if (entity == null)
         {
             throw new Exception("Nessuna Storage Area individuata");
         }
         db.DeleteObject(entity);
         db.SaveChanges();
     }
 }
Exemplo n.º 12
0
        public void UpdateArchive(BiblosDS.Library.Common.Objects.DocumentArchive Archive)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.Archive entityArchive = Archive.TryToConvertTo <Model.Archive>(false);

                if (entityArchive.EntityKey == null)
                {
                    entityArchive.EntityKey = db.CreateEntityKey(entityArchive.GetType().Name, entityArchive);
                }

                var attachedEntity = db.GetObjectByKey(entityArchive.EntityKey) as Model.Archive;

                db.ApplyCurrentValues(entityArchive.EntityKey.EntitySetName, entityArchive);
                db.SaveChanges();
            }
        }
Exemplo n.º 13
0
 public void DeleteAttribute(Guid IdAttribute, bool logicalDelete = true)
 {
     using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
     {
         var entity = db.Attributes.Where(x => x.IdAttribute == IdAttribute).FirstOrDefault();
         if (entity == null)
         {
             throw new Exceptions.Attribute_Exception("Nessun attributo individuato");
         }
         if (logicalDelete)
         {
             entity.IsVisible = 0;
         }
         else
         {
             db.Attributes.DeleteObject(entity);
         }
         db.SaveChanges();
     }
 }
Exemplo n.º 14
0
        public void UpdateArchiveStorage(BiblosDS.Library.Common.Objects.DocumentArchiveStorage ArchiveStorage)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.ArchiveStorage entityArchiveStorage = ArchiveStorage.TryToConvertTo <Model.ArchiveStorage>(false);

                //var itemIndB = db.ArchiveStorage.Where(x => x.IdArchive == ArchiveStorage.Archive.IdArchive && x.IdStorage == ArchiveStorage.Storage.IdStorage).First();
                //itemIndB.Active = ArchiveStorage.Active ? (short)1 : (short)0;

                if (ArchiveStorage.Storage != null)
                {
                    entityArchiveStorage.IdStorage = ArchiveStorage.Storage.IdStorage;
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Storage non valorizzato");
                }

                if (ArchiveStorage.Archive != null)
                {
                    entityArchiveStorage.IdArchive = ArchiveStorage.Archive.IdArchive;
                }
                else
                {
                    throw new Exceptions.ArchiveStorage_Exception("Archivio non valorizzato");
                }

                if (entityArchiveStorage.EntityKey == null)
                {
                    entityArchiveStorage.EntityKey = db.CreateEntityKey(entityArchiveStorage.GetType().Name, entityArchiveStorage);
                }

                var attachedEntity = db.GetObjectByKey(entityArchiveStorage.EntityKey) as Model.ArchiveStorage;

                //if (ArchiveStorage.StorageType != null)
                //    entityStorage.StorageTypeReference.TryToAttach(new Model.StorageType { IdStorageType = ArchiveStorage.StorageType.IdStorageType }, attachedEntity.StorageTypeReference, db);

                db.ApplyCurrentValues(entityArchiveStorage.EntityKey.EntitySetName, entityArchiveStorage);
                db.SaveChanges();
            }
        }
Exemplo n.º 15
0
        public void UpdateStorageRule(BiblosDS.Library.Common.Objects.DocumentStorageRule StorageRule)
        {
            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.StorageRule entityStorageRule = StorageRule.TryToConvertTo <Model.StorageRule>(db);

                if (StorageRule.Storage != null)
                {
                    entityStorageRule.IdStorage = StorageRule.Storage.IdStorage;
                    //entityStorageRule.StorageReference.TryToAttach(new Model.Storage { IdStorage = StorageRule.Storage.IdStorage }, db);
                }
                else
                {
                    throw new Exception("Storage non valorizzato");
                }

                if (StorageRule.Attribute != null)
                {
                    entityStorageRule.IdAttribute = StorageRule.Attribute.IdAttribute;
                    //entityStorageRule.AttributesReference.TryToAttach(new Model.Archive { IdArchive = StorageRule.Attribute.IdAttribute }, db);
                }
                else
                {
                    throw new Exception("Attribute non valorizzato");
                }

                if (entityStorageRule.EntityKey == null)
                {
                    entityStorageRule.EntityKey = db.CreateEntityKey(entityStorageRule.GetType().Name, entityStorageRule);
                }
                var attachedEntity = db.GetObjectByKey(entityStorageRule.EntityKey) as Model.StorageRule;

                if (StorageRule.RuleOperator != null)
                {
                    entityStorageRule.IdRuleOperator = StorageRule.RuleOperator.IdRuleOperator;
                }

                db.ApplyCurrentValues(entityStorageRule.EntityKey.EntitySetName, entityStorageRule);
                db.SaveChanges();
            }
        }
Exemplo n.º 16
0
        public Guid AddStorage(BiblosDS.Library.Common.Objects.DocumentStorage Storage)
        {
            Storage.IdStorage = Guid.NewGuid();

            using (Model.BiblosDS2010Entities db = new Model.BiblosDS2010Entities(BiblosDSConnectionString))
            {
                Model.Storage entityStorage = Storage.TryToConvertTo <Model.Storage>(db);

                if (Storage.StorageType != null)
                {
                    entityStorage.IdStorageType = Storage.StorageType.IdStorageType;
                }

                if (Storage.Server != null && Storage.Server.IdServer != Guid.Empty)
                {
                    entityStorage.IdServer = Storage.Server.IdServer;
                }

                db.AddToStorage(entityStorage);
                db.SaveChanges();
            }
            return(Storage.IdStorage);
        }