Exemplo n.º 1
0
        private static GenericSearchDocument CreateFieldWithValueDictionary <T>(T source, SearchField[] searchFields, Func <SearchField, object> getValue)
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in searchFields)
            {
                var azureField = field.ToAzureField(convertNameToLowercase: true);

                var val = getValue.Invoke(field)?.ToAzureFieldValue();
                if (val != null)
                {
                    dictionary.Add(azureField.Name, val);
                }
            }

            return(dictionary);
        }
        public static GenericSearchDocument ToGenericElasticSearchDoc <TFunctionMessage>(
            this TransactionForFunctionVO <TFunctionMessage> functionCall,
            FunctionIndexDefinition <TFunctionMessage> indexDefinition) where TFunctionMessage : FunctionMessage, new()
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in indexDefinition.Fields)
            {
                var val = field.GetTransactionForFunctionValue(functionCall)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = indexDefinition.KeyField().GetTransactionForFunctionValue(functionCall);

            dictionary.SetId(id.ToString());

            return(dictionary);
        }
        public static GenericSearchDocument ToGenericElasticSearchDoc(
            this FilterLog log,
            SearchField[] searchFields)
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in searchFields)
            {
                var val = field.GetFilterLogValue(log)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = log.Key();

            dictionary.SetId(id.ToString());

            return(dictionary);
        }
        public static GenericSearchDocument ToGenericElasticSearchDoc <TEvent>(
            this EventLog <TEvent> log,
            EventIndexDefinition <TEvent> indexDefinition) where TEvent : class
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in indexDefinition.Fields)
            {
                var val = field.GetEventLogValue(log)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = indexDefinition.KeyField().GetEventLogValue(log);

            dictionary.SetId(id.ToString());

            return(dictionary);
        }
        public static GenericSearchDocument ToGenericElasticSearchDoc(
            this TransactionReceiptVO transactionReceiptVO,
            TransactionReceiptVOIndexDefinition indexDefinition)
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in indexDefinition.Fields)
            {
                var val = field.GetTransactionReceiptValue(transactionReceiptVO)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = transactionReceiptVO.TransactionHash;

            dictionary.SetId(id.ToString());

            return(dictionary);
        }