Exemplo n.º 1
0
        private async Task <DataView> GetClassifierForm(ClassifierType type, CancellationToken cancellationToken)
        {
            var metadata = await _metadataRepository.Search(new MetadataSearchRequest
            {
                EntityTypeCode = ClassifierType.TypeCode,
                EntityUid      = type.Uid,
                IsActive       = true
            }, cancellationToken);

            var result = new DataView {
                Fields = metadata.Rows
            };

            foreach (var field in result.Fields)
            {
                if (field.System == false)
                {
                    field.Key = FieldKey.FormatFullKey(field.Key);
                }
            }

            var commonFields = GetCommonFields(type);

            if (commonFields != null)
            {
                result.Fields = commonFields.Union(result.Fields).ToArray();
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task <DataView> Handle(GetCompanyMetadata request, CancellationToken cancellationToken)
        {
            var classifierRepository = _classifierRepositoryFactory.GetNamedOrDefaultService(ClassifierTypeCode.DocumentType);
            var documentType         = await classifierRepository.Get(ClassifierTypeCode.DocumentType, DocumentTypes.CompanyRegistrationRequest, cancellationToken);

            var metadata = await _metadataRepository.Search(new MetadataSearchRequest
            {
                EntityTypeCode = DocumentType.EntityTypeCode,
                EntityUid      = documentType.Uid.Value,
                IsActive       = true,
                SkipPaging     = true
            }, cancellationToken);

            var dbFields = new List <string>
            {
                nameof(Company.Name)
            };

            var result = new DataView {
                Fields = metadata.Rows
            };

            foreach (var field in result.Fields)
            {
                if (dbFields.Contains(field.Key, StringComparer.InvariantCultureIgnoreCase) == false)
                {
                    field.Key = FieldKey.FormatFullKey(field.Key);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public async Task <DataView> Handle(GetDocumentMetadata request, CancellationToken cancellationToken)
        {
            Guid documentTypeUid;

            // todo: why request by DocumentTypeUid or by TypeCode ?
            if (request.DocumentTypeUid == null)
            {
                var typeCode = request.TypeCode ?? throw new ArgumentNullException(nameof(request.TypeCode));

                var classifierRepository = _classifierRepositoryFactory.GetNamedOrDefaultService(ClassifierTypeCode.DocumentType);
                var documentType         = await classifierRepository.Get(ClassifierTypeCode.DocumentType, typeCode, cancellationToken);

                documentTypeUid = documentType.Uid.Value;
            }
            else
            {
                documentTypeUid = request.DocumentTypeUid.Value;
            }

            var metadata = await _metadataRepository.Search(new MetadataSearchRequest
            {
                EntityTypeCode = DocumentType.EntityTypeCode,
                EntityUid      = documentTypeUid,
                IsActive       = true,
                SkipPaging     = true
            }, cancellationToken);

            var dbFields = new List <string>
            {
                nameof(Document.DocumentDate),
                nameof(Document.DocumentNumber),
                nameof(Document.Name)
            };

            var result = new DataView {
                Fields = metadata.Rows
            };

            foreach (var field in result.Fields)
            {
                if (dbFields.Contains(field.Key, StringComparer.InvariantCultureIgnoreCase) == false)
                {
                    field.Key = FieldKey.FormatFullKey(field.Key);
                }
            }

            return(result);
        }