public WorkflowActivityModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <WorkflowActivity, WorkflowActivityModel>()
     .AfterMap((src, dest) =>
     {
         IQueryable <WorkflowProperty> properties = _unitOfWork.Repository <WorkflowProperty>().Queryable(true).Where(f => f.WorkflowActivity.UniqueId == src.UniqueId &&
                                                                                                                      (f.Name == WorkflowPropertyHelper.DSW_PROPERTY_PROPOSER_USER || f.Name == WorkflowPropertyHelper.DSW_PROPERTY_ACCOUNTS || f.Name == WorkflowPropertyHelper.DSW_FIELD_ACTIVITY_START_MOTIVATION ||
                                                                                                                       f.Name == WorkflowPropertyHelper.DSW_FIELD_ACTIVITY_END_MOTIVATION || f.Name == WorkflowPropertyHelper.DSW_FIELD_ACTIVITY_START_REFERENCE_MODEL || f.Name == WorkflowPropertyHelper.DSW_FIELD_ACTIVITY_END_REFERENCE_MODEL ||
                                                                                                                       f.Name == WorkflowPropertyHelper.DSW_FIELD_RECIPIENT_POSITION));
         src.WorkflowInstance = _unitOfWork.Repository <WorkflowInstance>()
                                .Query(x => x.WorkflowActivities.Any(xx => xx.UniqueId == src.UniqueId), true)
                                .Include(c => c.WorkflowRepository).Select().Single();
         dest.ActivityName                = src.Name;
         dest.IdDocumentUnit              = src.DocumentUnitReferenced?.UniqueId ?? null;
         dest.IdWorkflowActivity          = src.UniqueId;
         dest.IdWorkflowInstance          = src.WorkflowInstance.UniqueId;
         dest.Status                      = (WorkflowStatus)src.WorkflowInstance.Status;
         dest.WorkflowName                = src.WorkflowInstance.WorkflowRepository.Name;
         dest.RequestedDate               = src.RegistrationDate;
         dest.CategoryName                = src.DocumentUnitReferenced?.Category?.Name;
         dest.AuthorizationRole           = src.DocumentUnitReferenced?.Container?.Name;
         dest.RequestorUsername           = GetRequestorUsername(src, properties);
         dest.AuthorizationUser           = GetAuthorizationUser(properties);
         dest.RequestMotivation           = GetStartMotivation(properties);
         dest.WorkflowStartReferenceModel = GetStartReferenceModel(properties);
         DateTimeOffset?endMotivationDate;
         dest.EndMotivation             = GetEndMotivation(properties, out endMotivationDate);
         dest.EndMotivationDate         = endMotivationDate;
         dest.WorkflowEndReferenceModel = GetEndReferenceModel(properties);
     });
 }
 public ProtocolContactModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <ContactTableValuedModel, ProtocolContactModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("name", opt => opt.MapFrom(src => src.Description))
     .AfterMap((src, dest) => dest.Name = src.Description.Replace("|", " "));
 }
 public PECMailReceiptModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     //
     CreateMap <PECMailReceipt, PECMailReceiptModel>()
     .AfterMap((src, dest) => dest.Step = src.ReceiptType)
     .AfterMap((src, dest) => dest.Date = src.ReceiptDate);
 }
Exemplo n.º 4
0
 public DossierModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <Dossier, DossierModel>()
     .AfterMap((src, dest) => dest.DossierFolders   = GetDossierFolderModels(src.DossierFolders))
     .AfterMap((src, dest) => dest.Roles            = GetDossierRoleModels(src.DossierRoles))
     .AfterMap((src, dest) => dest.Title            = src.DossierFolders.First().Name.Replace("Dossier ", string.Empty))
     .AfterMap((src, dest) => dest.RegistrationUser = security.GetUser(src.RegistrationUser).DisplayName)
     .AfterMap((src, dest) => dest.LastChangedUser  = src.LastChangedUser != null ? security.GetUser(src.LastChangedUser).DisplayName : null);
 }
 public WorkflowStatusModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <Entities.Workflows.WorkflowInstance, WorkflowStatusModel>()
     .ForCtorParam("instanceId", opt => opt.MapFrom(src => src.InstanceId))
     .ForCtorParam("workflowName", opt => opt.MapFrom((src) => src.WorkflowRepository == null ? string.Empty : src.WorkflowRepository.Name))
     .AfterMap((src, dest) => dest.Date = src.RegistrationDate);
 }
Exemplo n.º 6
0
 public CategoryModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <Category, CategoryModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .BeforeMap((src, dest) => dest.HierarchyCode        = _unitOfWork.Repository <Category>().GetHierarcyCode(src.EntityShortId))
     .BeforeMap((src, dest) => dest.HierarchyDescription = _unitOfWork.Repository <Category>().GetHierarcyDescription(src.EntityShortId));
 }
Exemplo n.º 7
0
 public FascicleModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <Fascicle, FascicleModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .AfterMap((src, dest) => dest.FascicleName     = src.Name)
     .AfterMap((src, dest) => dest.Subject          = src.FascicleObject)
     .AfterMap((src, dest) => dest.Name             = "Fascicle")
     .AfterMap((src, dest) => dest.RegistrationUser = security.GetUser(src.RegistrationUser).DisplayName)
     .AfterMap((src, dest) => dest.LastChangedUser  = src.LastChangedUser != null ? security.GetUser(src.LastChangedUser).DisplayName : null);
 }
 public DocumentUnitReferenceModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <Protocol, DocumentUnitReferenceModel>()
     .ForCtorParam("referenceId", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("name", opt => opt.MapFrom(src => "Protocollo"))
     .ForCtorParam("year", opt => opt.MapFrom(src => src.Year))
     .ForCtorParam("number", opt => opt.MapFrom(src => src.Number.ToString()))
     .ForCtorParam("subject", opt => opt.MapFrom(src => src.Object));
 }
Exemplo n.º 9
0
 public PECMailModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     //
     CreateMap <PECMail, PECMailModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .AfterMap((src, dest) => dest.Subject    = src.MailSubject)
     .AfterMap((src, dest) => dest.Date       = src.MailDate)
     .AfterMap((src, dest) => dest.Body       = src.MailContent)
     .AfterMap((src, dest) => dest.Senders    = src.MailSenders)
     .AfterMap((src, dest) => dest.Recipients = src.MailRecipients)
     .AfterMap((src, dest) => dest.Step       = src.MailType);
 }
Exemplo n.º 10
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static IDependencyResolver RegisterTypes(IUnityContainer container)
        {
            IDependencyResolver resolver = container.Initialize <UnityConfig, WebAPICurrentIdentity>(string.Empty, string.Empty,
                                                                                                     WebApiConfiguration.ServiceBusConnectionString, HostingEnvironment.MapPath(WebApiConfiguration.MESSAGE_CONFIGURATION_FILE_PATH),
                                                                                                     WebApiConfiguration.CustomInstanceName,
                                                                                                     WebApiConfiguration.AutoDeleteOnIdle, WebApiConfiguration.DefaultMessageTimeToLive, WebApiConfiguration.LockDuration,
                                                                                                     WebApiConfiguration.MaxDeliveryCount);

            IDataUnitOfWork unitOfWork = (IDataUnitOfWork)resolver.BeginScope().GetService(typeof(IDataUnitOfWork));

            Security.ISecurity security = (Security.ISecurity)resolver.BeginScope().GetService(typeof(Security.ISecurity));
            container.RegisterInstance(AutoMapperConfig.RegisterMappings(unitOfWork, security));
            return(resolver);
        }
Exemplo n.º 11
0
 public ResolutionModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <Resolution, ResolutionModel>()
     .ForCtorParam("location", opt => opt.MapFrom(src => ""))
     .ForCtorParam("category", opt => opt.MapFrom((src) => new CategoryModel(Guid.Empty, "")))
     .ForCtorParam("container", opt => opt.MapFrom((src) => new ContainerModel(Guid.Empty, "")))
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("year", opt => opt.MapFrom(src => src.Year))
     .ForCtorParam("number", opt => opt.MapFrom(src => src.Number))
     .ForCtorParam("subject", opt => opt.MapFrom(src => src.Object))
     .AfterMap((src, dest) => dest.Proposer = MapProposer(src));
 }
 public GenericDocumentUnitProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <DocumentUnitTableValuedModel, GenericDocumentUnitModel>()
     .ForCtorParam("location", opt => opt.MapFrom(src => ""))
     .ForCtorParam("category", opt => opt.MapFrom((src) => new CategoryModel(Guid.Empty, "")))
     .ForCtorParam("container", opt => opt.MapFrom((src) => new ContainerModel(Guid.Empty, "")))
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("year", opt => opt.MapFrom(src => src.Year))
     .ForCtorParam("number", opt => opt.MapFrom(src => src.Number))
     .ForCtorParam("subject", opt => opt.MapFrom(src => src.Subject))
     .AfterMap((src, dest) => dest.DocumentUnitName = src.DocumentUnitName)
     .AfterMap((src, dest) => dest.Title            = src.Title)
     .AfterMap((src, dest) => dest.Name             = string.Concat(src.DocumentUnitName, " ", src.Title));
 }
Exemplo n.º 13
0
 public ProtocolModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <Protocol, ProtocolModel>()
     .ForCtorParam("location", opt => opt.MapFrom(src => src.Container != null && src.Container.ProtLocation != null ? src.Container.ProtLocation.Name : "location non definita"))
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("year", opt => opt.MapFrom(src => src.Year))
     .ForCtorParam("number", opt => opt.MapFrom(src => src.Number))
     .ForCtorParam("subject", opt => opt.MapFrom(src => src.Object))
     .AfterMap((src, dest) => dest.AnnulmentReason  = src.LastChangedReason)
     .AfterMap((src, dest) => dest.RegistrationUser = src.RegistrationUser)     //TODO:usare il metodo UsersFinder di ActiveDirectory per avere il DisplayName
     .AfterMap((src, dest) => dest.LastChangedUser  = src.LastChangedUser)
     .AfterMap((src, dest) => dest.Addressee        = src.ProtocolType?.EntityShortId == (short)ProtocolTypology.Outgoing ? src.AdvancedProtocol?.Subject : string.Empty)
     .AfterMap((src, dest) => dest.Assignee         = src.ProtocolType?.EntityShortId == (short)ProtocolTypology.Inbound ? src.AdvancedProtocol?.Subject : string.Empty)
     .AfterMap((src, dest) => dest.RegistrationUser = security.GetUser(src.RegistrationUser).DisplayName)
     .AfterMap((src, dest) => dest.LastChangedUser  = src.LastChangedUser != null ? security.GetUser(src.LastChangedUser).DisplayName : null);
 }
Exemplo n.º 14
0
 public GenericDocumentUnitModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <FascicleDocumentUnit, GenericDocumentUnitModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.DocumentUnit.UniqueId))
     .ForCtorParam("year", opt => opt.MapFrom(src => src.DocumentUnit.Year))
     .ForCtorParam("number", opt => opt.MapFrom(src => src.DocumentUnit.Number))
     .ForCtorParam("subject", opt => opt.MapFrom(src => src.DocumentUnit.Subject))
     .ForCtorParam("category", opt => opt.MapFrom(src => new CategoryModel(Guid.NewGuid(), string.Empty)))
     .ForCtorParam("container", opt => opt.MapFrom(src => new ContainerModel(Guid.NewGuid(), string.Empty)))
     .ForCtorParam("location", opt => opt.MapFrom(src => string.Empty))
     .AfterMap((src, dest) => dest.Title            = src.DocumentUnit.Title)
     .AfterMap((src, dest) => dest.Environment      = src.DocumentUnit.Environment)
     .AfterMap((src, dest) => dest.DocumentUnitName = src.DocumentUnit.DocumentUnitName)
     .AfterMap((src, dest) => dest.RegistrationUser = _security.GetUser(src.RegistrationUser).DisplayName)
     .AfterMap((src, dest) => dest.LastChangedUser  = src.LastChangedUser != null ? _security.GetUser(src.LastChangedUser).DisplayName : null);
 }
Exemplo n.º 15
0
        public static IMapper RegisterMappings(IDataUnitOfWork unitOfWork, Security.ISecurity security)
        {
            AppDomain myDomain = Thread.GetDomain();

            //Get all Profiles
            IEnumerable <Profile> profiles = System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
                                             .Where(t => typeof(Profile).IsAssignableFrom(t))
                                             .Select(t => (Profile)Activator.CreateInstance(t, unitOfWork, security));

            MapperConfiguration config = new MapperConfiguration(cfg =>
            {
                foreach (Profile profile in profiles)
                {
                    cfg.AddProfile(profile);
                }
                cfg.CreateMap <byte?, bool?>().ConvertUsing(new ByteToBooleanTypeConverter());
                cfg.CreateMap <Entities.Commons.ActiveType, bool>().ConvertUsing(new ActiveTypeTypeConverter());
                cfg.CreateMap <string, Domains.Commons.ContactType>().ConvertUsing(new ContactTypeTypeConverter());
                cfg.CreateMap <string, Domains.Protocols.ComunicationType>().ConvertUsing(new ComunicationTypeTypeConverter());
                cfg.CreateMap <short, Domains.Protocols.ProtocolStatusType>().ConvertUsing(new ProtocolStatusTypeConverter());
                cfg.CreateMap <Entities.Protocols.ProtocolType, Domains.Protocols.ProtocolType>().ConvertUsing(new ProtocolTypeTypeConverter());
                cfg.CreateMap <Entities.PECMails.PECType?, Domains.PECMails.PECType>().ConvertUsing(new PECTypeTypeConverter());
                cfg.CreateMap <byte, Domains.PECMails.PECActiveType>().ConvertUsing(new PECActiveTypeTypeConverter());
                cfg.CreateMap <ResolutionStatus, ResolutionStatusType>().ConvertUsing(new ResolutionStatusTypeConverter());
                cfg.CreateMap <byte, ResolutionType>().ConvertUsing(new ResolutionTypeConverter());
                cfg.CreateMap <Entities.Workflows.WorkflowStatus, WorkflowStatus>().ConvertUsing(new WorkflowStatusTypeConverter());
                cfg.CreateMap <ProtocolUserType, Domains.Protocols.ProtocolUserType>().ConvertUsing(new ProtocolUserTypeTypeConverter());
            });

            //Create a mapper that will be used by the DI container
            IMapper mapper = config.CreateMapper();

            return(mapper);
            //Register the DI interfaces with their implementation
            //For<IMapperConfiguration>().Use(config);
            //For<IMapper>().Use(mapper);
        }
 public WorkflowNotifyModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     _unitOfWork = unitOfWork;
     _security   = security;
     CreateMap <WorkflowActivity, WorkflowNotify>()
     .AfterMap((src, dest) =>
     {
         foreach (WorkflowProperty workflowProperty in src.WorkflowProperties)
         {
             WorkflowArgument workflowArgument = new WorkflowArgument
             {
                 Name         = workflowProperty.Name,
                 PropertyType = (ArgumentType)workflowProperty.PropertyType,
                 ValueBoolean = workflowProperty.ValueBoolean,
                 ValueDate    = workflowProperty.ValueDate,
                 ValueDouble  = workflowProperty.ValueDouble,
                 ValueGuid    = workflowProperty.ValueGuid,
                 ValueInt     = workflowProperty.ValueInt,
                 ValueString  = workflowProperty.ValueString
             };
             dest.OutputArguments.Add(workflowProperty.Name, workflowArgument);
         }
     });
 }
Exemplo n.º 17
0
 public DossierFolderModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <DossierFolder, DossierFolderModel>()
     .AfterMap((src, dest) => dest = GetDossierFolderModel(src));
 }
 public FascicleFoldersController(IDataUnitOfWork unitOfWork, ILogger logger, IMapper mapper, Security.ISecurity security, IMapperUnitOfWork mapperUnitOfWork)
 {
     _logger     = logger;
     _unitOfWork = unitOfWork;
     _mapper     = mapper;
 }
Exemplo n.º 19
0
 public ProtocolRoleModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <RoleTableValuedModel, ProtocolSectorModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId))
     .ForCtorParam("name", opt => opt.MapFrom(src => src.Name));
 }
 public FascicleFolderModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <FascicleFolder, FascicleFolderModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId));
 }
Exemplo n.º 21
0
 public ProtocolUserModelProfile(IDataUnitOfWork unitOfWork, Security.ISecurity security)
 {
     CreateMap <ProtocolUser, ProtocolUserModel>()
     .ForCtorParam("id", opt => opt.MapFrom(src => src.UniqueId));
 }