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 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.º 3
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.º 4
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.º 5
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.º 6
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();
            }
        }