public static GenericSearchDocument Map(EventLog <List <ParameterOutput> > from, Dictionary <string, object> stateValues)
        {
            var searchDoc = new GenericSearchDocument();

            searchDoc[Fields.DocumentKey] = $"{from.Log.TransactionHash}_{from.Log.LogIndex.Value}";
            searchDoc[Fields.BlockNumber] = from.Log.BlockNumber?.Value.ToAzureFieldValue();
            searchDoc[Fields.TxHash]      = from.Log.TransactionHash;
            searchDoc[Fields.LogAddress]  = from.Log.Address;
            searchDoc[Fields.LogIndex]    = from.Log.LogIndex.Value.ToAzureFieldValue();

            if (stateValues != null)
            {
                int count = 0;
                foreach (var key in stateValues.Keys)
                {
                    count++;
                    searchDoc[Fields.StateValue(count)] = $"{key}:{stateValues[key]?.ToAzureFieldValue()}";
                }
            }

            foreach (var parameterOutput in from.Event.OrderBy(p => p.Parameter.Order))
            {
                var key    = Fields.EventParameter(parameterOutput.Parameter.Order);
                var prefix = string.IsNullOrEmpty(parameterOutput.Parameter.Name) ? parameterOutput.Parameter.Order.ToString() : parameterOutput.Parameter.Name;
                searchDoc[key] = $"{prefix}:{parameterOutput.Result?.ToAzureFieldValue()}";
            }

            return(searchDoc);
        }
예제 #2
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 <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 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(
            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);
        }