protected override FascicleDocumentUnit BeforeDelete(FascicleDocumentUnit entity, FascicleDocumentUnit entityTransformed)
        {
            if (entityTransformed == null)
            {
                entityTransformed = GetByFascicle(entity.DocumentUnit, entity.Fascicle.UniqueId).FirstOrDefault();
                if (entityTransformed == null)
                {
                    throw new DSWException(DOCUMENT_UNIT_NOT_FOUND_MESSAGE, null, DSWExceptionCode.DB_Anomaly);
                }
            }

            if (entity.Fascicle != null)
            {
                entityTransformed.Fascicle = _unitOfWork.Repository <Fascicle>().Find(entity.Fascicle.UniqueId);
            }

            if (entity.DocumentUnit != null)
            {
                entityTransformed.DocumentUnit = _unitOfWork.Repository <DocumentUnit>().Find(entity.DocumentUnit.UniqueId);
            }

            entity.ReferenceType = entityTransformed.ReferenceType;

            _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entityTransformed.Fascicle, FascicleLogType.UDDelete,
                                                                                    $"Eliminazione {LogDocumentNameHelper.GetAttributeDescription(GetType())} n. { entityTransformed.DocumentUnit.GetTitle()} da fascicolo n. {entityTransformed.Fascicle.Title}",
                                                                                    CurrentDomainUser.Account));

            return(base.BeforeDelete(entity, entityTransformed));
        }
Ejemplo n.º 2
0
        protected override FascicleDocument BeforeCreate(FascicleDocument entity)
        {
            if (entity.Fascicle != null)
            {
                entity.Fascicle = _unitOfWork.Repository <Fascicle>().Find(entity.Fascicle.UniqueId);
            }

            _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entity.Fascicle, FascicleLogType.Modify, $"Modifica sulla tipologia documento (-{entity.ChainType}-{entity.IdArchiveChain}) del fascicolo", CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
Ejemplo n.º 3
0
        protected override FascicleFolder BeforeCreate(FascicleFolder entity)
        {
            if (entity.Fascicle != null)
            {
                entity.Fascicle = _unitOfWork.Repository <Fascicle>().Find(entity.Fascicle.UniqueId);
            }

            if (entity.Category != null)
            {
                entity.Category = _unitOfWork.Repository <Category>().Find(entity.Category.EntityShortId);
            }

            _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entity.Fascicle, FascicleLogType.FolderInsert, $"Creata nuovo cartella {entity.Name}({entity.UniqueId})", CurrentDomainUser.Account));
            return(base.BeforeCreate(entity));
        }
Ejemplo n.º 4
0
        protected override FascicleRole BeforeCreate(FascicleRole entity)
        {
            if (entity.Fascicle != null)
            {
                entity.Fascicle = _unitOfWork.Repository <Fascicle>().Find(entity.Fascicle.UniqueId);
            }

            if (entity.Role != null)
            {
                entity.Role = _unitOfWork.Repository <Role>().Find(entity.Role.EntityShortId);
            }
            _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entity.Fascicle, FascicleLogType.Authorize, $"Aggiunta autorizzazione '{entity.AuthorizationRoleType}' al settore {entity.Role.Name} ({entity.Role.EntityShortId})", CurrentDomainUser.Account));

            return(base.BeforeCreate(entity));
        }
Ejemplo n.º 5
0
        protected override FascicleFolder BeforeUpdate(FascicleFolder entity, FascicleFolder entityTransformed)
        {
            if (entity.Fascicle != null)
            {
                entityTransformed.Fascicle = _unitOfWork.Repository <Fascicle>().Find(entity.Fascicle.UniqueId);
            }

            if (entity.Category != null)
            {
                entityTransformed.Category = _unitOfWork.Repository <Category>().Find(entity.Category.EntityShortId);
            }

            if (CurrentUpdateActionType == Common.Infrastructures.UpdateActionType.FascicleMoveToFolder)
            {
                _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entityTransformed.Fascicle, FascicleLogType.Modify, $"Spostata cartella {entityTransformed.Name}({entityTransformed.UniqueId})", CurrentDomainUser.Account));
            }
            else
            {
                _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entityTransformed.Fascicle, FascicleLogType.Modify, $"Modificata la cartella {entityTransformed.Name}({entityTransformed.UniqueId}", CurrentDomainUser.Account));
            }

            return(base.BeforeUpdate(entity, entityTransformed));
        }
        protected override FascicleDocumentUnit BeforeUpdate(FascicleDocumentUnit entity, FascicleDocumentUnit entityTransformed)
        {
            if (CurrentUpdateActionType != Common.Infrastructures.UpdateActionType.FascicleMoveToFolder)
            {
                throw new DSWException(EXCEPTION_MESSAGE, null, DSWExceptionCode.SS_NotAllowedOperation);
            }

            short?idCategory = null;

            if (entity.Fascicle != null)
            {
                entity.Fascicle = _unitOfWork.Repository <Fascicle>().GetByUniqueId(entity.Fascicle.UniqueId, optimization: false);
                idCategory      = entity.Fascicle.Category.EntityShortId;
            }

            if (entity.FascicleFolder != null)
            {
                entityTransformed.FascicleFolder = _unitOfWork.Repository <FascicleFolder>().GetByFolderId(entity.FascicleFolder.UniqueId, false);
            }

            if (entity.FascicleFolder == null && idCategory.HasValue)
            {
                entityTransformed.FascicleFolder = _unitOfWork.Repository <FascicleFolder>().GetByCategoryAndFascicle(entity.Fascicle.UniqueId, idCategory.Value, optimization: false).FirstOrDefault();
            }

            if (entity.DocumentUnit != null)
            {
                entityTransformed.DocumentUnit = _unitOfWork.Repository <DocumentUnit>().GetByIdWithCategory(entity.DocumentUnit.UniqueId).SingleOrDefault();
            }

            entityTransformed = AutomaticFascicleDetection(entityTransformed);
            _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entityTransformed.Fascicle, FascicleLogType.Modify,
                                                                                    $"Spostato documento {entityTransformed.DocumentUnit.GetTitle()} nella cartella {entityTransformed.FascicleFolder.Name} ({entityTransformed.FascicleFolder.GetTitle()})",
                                                                                    CurrentDomainUser.Account));

            return(base.BeforeUpdate(entity, entityTransformed));
        }
Ejemplo n.º 7
0
 protected override FascicleRole BeforeDelete(FascicleRole entity, FascicleRole entityTransformed)
 {
     _unitOfWork.Repository <FascicleLog>().Insert(FascicleService.CreateLog(entityTransformed.Fascicle, FascicleLogType.Authorize, $"Rimossa autorizzazione '{entity.AuthorizationRoleType}' al settore {entity.Role.Name} ({entity.Role.EntityShortId})", CurrentDomainUser.Account));
     return(base.BeforeDelete(entity, entityTransformed));
 }
        protected override FascicleDocumentUnit BeforeCreate(FascicleDocumentUnit entity)
        {
            short?idCategory = null;

            if (entity.Fascicle != null)
            {
                entity.Fascicle = _unitOfWork.Repository <Fascicle>().GetByUniqueId(entity.Fascicle.UniqueId, optimization: false);
                idCategory      = entity.Fascicle.Category.EntityShortId;
            }

            if (entity.FascicleFolder != null)
            {
                entity.FascicleFolder = _unitOfWork.Repository <FascicleFolder>().Find(entity.FascicleFolder.UniqueId);
            }

            if (entity.FascicleFolder == null && idCategory.HasValue)
            {
                entity.FascicleFolder = _unitOfWork.Repository <FascicleFolder>().GetByCategoryAndFascicle(entity.Fascicle.UniqueId, idCategory.Value, optimization: false).FirstOrDefault();
            }

            if (entity.DocumentUnit != null)
            {
                entity.DocumentUnit = _unitOfWork.Repository <DocumentUnit>().GetByIdWithCategory(entity.DocumentUnit.UniqueId).SingleOrDefault();
            }

            entity.ReferenceType = ReferenceType.Reference;
            if (entity.Fascicle.FascicleType != FascicleType.Activity)
            {
                entity = AutomaticFascicleDetection(entity);
            }

            entity.Fascicle.LastChangedDate = DateTimeOffset.UtcNow;
            FascicleLog fascicleLog = FascicleService.CreateLog(entity.Fascicle, entity.ReferenceType.Equals(ReferenceType.Fascicle) ? FascicleLogType.UDInsert : FascicleLogType.UDReferenceInsert,
                                                                string.Format("Inserimento ({0}) {1} n. {2} in fascicolo n. {3}",
                                                                              entity.ReferenceType.Equals(ReferenceType.Fascicle) ? EnumHelper.GetDescription(ReferenceType.Fascicle) : EnumHelper.GetDescription(ReferenceType.Reference),
                                                                              LogDocumentNameHelper.GetAttributeDescription(GetType()),
                                                                              entity.UniqueId,
                                                                              entity.Fascicle == null ? string.Empty : entity.Fascicle.Title), CurrentDomainUser.Account);

            _unitOfWork.Repository <FascicleLog>().Insert(fascicleLog);
            PrepareDocumentUnitLog(entity, fascicleLog);

            if (entity.Fascicle != null)
            {
                ReferenceType          referenceType = (entity.ReferenceType == ReferenceType.Fascicle) ? ReferenceType.Reference : ReferenceType.Fascicle;
                IEnumerable <Fascicle> fascicles     = AssociatedFascicles(entity.DocumentUnit, referenceType);

                if (fascicles.Any())
                {
                    IEnumerable <Fascicle> fascicleToLinks = fascicles.Where(f => (!f.FascicleLinks.Any() || !f.FascicleLinks.Any(fl => fl.FascicleLinked.UniqueId == entity.Fascicle.UniqueId)));

                    ICollection <FascicleLink> fascicleLinks = new HashSet <FascicleLink>();
                    foreach (Fascicle item in fascicleToLinks)
                    {
                        fascicleLinks.Add(new FascicleLink()
                        {
                            Fascicle         = item,
                            FascicleLinked   = entity.Fascicle,
                            FascicleLinkType = FascicleLinkType.Automatic
                        });

                        fascicleLinks.Add(new FascicleLink()
                        {
                            Fascicle         = entity.Fascicle,
                            FascicleLinked   = item,
                            FascicleLinkType = FascicleLinkType.Automatic
                        });
                    }
                    _unitOfWork.Repository <FascicleLink>().InsertRange(fascicleLinks);
                }
            }
            return(base.BeforeCreate(entity));
        }