public virtual void LinkFactAndProperty(Structures.Module.IArioFact fact,
                                         string fieldName,
                                         string propertyName,
                                         object propertyValue)
 {
     this.LinkFactAndProperty(fact, fieldName, propertyName, propertyValue, null, null);
 }
        public virtual void LinkFactFieldsAndProperty(Structures.Module.IArioFact fact,
                                                      List <string> fieldNames,
                                                      string propertyName,
                                                      object propertyValue,
                                                      double?probability     = null,
                                                      int?collectionRecordId = null)
        {
            var propertyStringValue = PublicFunctions.Module.GetValueAsString(propertyValue);

            if (string.IsNullOrWhiteSpace(propertyStringValue))
            {
                return;
            }

            var hasFieldNames = fieldNames != null;

            if (hasFieldNames && !fieldNames.Any())
            {
                return;
            }

            // Если значение определилось не из фактов,
            // для подсветки заносим это свойство и результату не доверяем.
            if (fact == null)
            {
                var calculatedFact = _obj.Facts.AddNew();
                calculatedFact.PropertyName  = propertyName;
                calculatedFact.PropertyValue = propertyStringValue;
                calculatedFact.Probability   = probability;
            }
            else
            {
                var propertyRelatedFields = _obj.Facts.Where(f => f.FactId == fact.Id)
                                            .Where(f => !hasFieldNames || fieldNames.Contains(f.FieldName));

                foreach (var field in propertyRelatedFields)
                {
                    if (probability == null)
                    {
                        probability = PublicFunctions.Module.GetFieldProbability(fact, field.FieldName);
                    }

                    var factLabel = PublicFunctions.Module.GetFactLabel(fact, propertyName);

                    field.PropertyName       = propertyName;
                    field.PropertyValue      = propertyStringValue;
                    field.Probability        = probability;
                    field.FactLabel          = factLabel;
                    field.CollectionRecordId = collectionRecordId;
                }
            }
        }
        public virtual void LinkFactAndProperty(Structures.Module.IArioFact fact,
                                                string fieldName,
                                                string propertyName,
                                                object propertyValue,
                                                double?probability     = null,
                                                int?collectionRecordId = null)
        {
            var fieldNames = new List <string>()
            {
                fieldName
            };

            if (fieldName == null)
            {
                fieldNames = null;
            }
            this.LinkFactFieldsAndProperty(fact, fieldNames, propertyName, propertyValue, probability, collectionRecordId);
        }