Exemplo n.º 1
0
        private string GetColumnValue(ESHit esHit, EntitySchemaColumn column)
        {
            var columnAlias = GlobalSearchColumnUtils.GetAlias(column, _entitySchema);

            return(esHit.Source.FirstOrDefault(x => string.Equals(x.Key, columnAlias,
                                                                  StringComparison.InvariantCultureIgnoreCase)).Value);
        }
Exemplo n.º 2
0
        private void AddColumnValue(ESHit esHit, EntitySchemaColumn column, Dictionary <string, object> columnValues)
        {
            var value = GetColumnValue(esHit, column);

            if (!string.IsNullOrEmpty(value))
            {
                columnValues.Add(column.Name, value);
            }
        }
Exemplo n.º 3
0
        private void AddLookupColumnValue(ESHit esHit, EntitySchemaColumn column, Dictionary <string, object> columnValues)
        {
            var lookupValue = GetLookupColumnValue(esHit, column);

            if (lookupValue != null)
            {
                columnValues.Add(column.Name, lookupValue);
            }
        }
Exemplo n.º 4
0
        private int GetFilledColumnRowCount(UserConnection userConnection,
                                            EntitySchema entitySchema, EntitySchemaColumn column, IEntitySchemaQueryFilterItem filter)
        {
            EntitySchemaQuery query = new EntitySchemaQuery(entitySchema);

            query.AddColumn(query.RootSchema.GetPrimaryColumnName()).SummaryType = AggregationType.Count;
            query.Filters.Add(CreateEmptyColumnValueFilter(query, column));
            query.Filters.Add(filter);
            return(query.GetSummarySelectQuery(userConnection).ExecuteScalar <int>());
        }
Exemplo n.º 5
0
 private bool CanSkipColumn(EntitySchemaColumn column)
 {
     return
         (column.UsageType == EntitySchemaColumnUsageType.None ||
          column.UsageType == EntitySchemaColumnUsageType.Advanced ||
          (column.DataValueType is BooleanDataValueType) ||
          column.Name == "Photo16" ||
          column.Name == "Photo22" ||
          column.Name == "Photo32");
 }
Exemplo n.º 6
0
        private static string FindEntityColumnValueName(UserConnection userConnection, Guid rootSchemaUId,
                                                        Guid columnUId)
        {
            if (rootSchemaUId.IsEmpty() || columnUId.IsEmpty())
            {
                return(string.Empty);
            }
            var entitySchema          = userConnection.EntitySchemaManager.FindInstanceByUId(rootSchemaUId);
            EntitySchemaColumn column = entitySchema?.Columns.FindByUId(columnUId);

            return(column?.ColumnValueName);
        }
Exemplo n.º 7
0
        private static ExpandoObject GetClientLookupLinkValue(Entity entity, CoreEntitySchemaColumn pageTypeColumn)
        {
            var value = new ExpandoObject() as IDictionary <string, object>;

            value.Add("value", entity.PrimaryColumnValue.ToString());
            value.Add("displayValue", entity.PrimaryDisplayColumnValue);
            if (pageTypeColumn != null)
            {
                value.Add(pageTypeColumn.Name, new {
                    value = entity.GetTypedColumnValue <Guid>(pageTypeColumn.ColumnValueName)
                });
            }
            return((ExpandoObject)value);
        }
Exemplo n.º 8
0
        private void AddHighlights(ESHit esHit, EntitySchemaColumn column, Dictionary <string, string[]> foundColumns,
                                   Dictionary <string, object> columnValues)
        {
            var columnName = column.Name;
            var highlight  = GetColumnHighlight(esHit, column);

            if (highlight != null && highlight.Length > 0)
            {
                foundColumns.Add(columnName, highlight);
                if (!columnValues.ContainsKey(columnName))
                {
                    AppendAdditionalHighLightColumn(columnValues, esHit, column);
                }
            }
        }
Exemplo n.º 9
0
 private string[] GetColumnHighlight(ESHit esHit, EntitySchemaColumn column)
 {
     string[] result = new string[0];
     if (esHit.Highlight != null)
     {
         var columnAlias          = GlobalSearchColumnUtils.GetAlias(column, _entitySchema);
         var columnHighlightValue = esHit.Highlight.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value;
         if (columnHighlightValue == null)
         {
             return(result);
         }
         result = GetHighLightMathces(columnHighlightValue);
     }
     return(result);
 }
Exemplo n.º 10
0
        private object GetParameterLookupValue(ProcessSchemaParameter parameter,
                                               IReadOnlyDictionary <Guid, Guid> sysModuleEntityPageType)
        {
            object value = GetParameterValue(parameter);
            var    primaryColumnValue = (Guid?)value;

            if (primaryColumnValue?.IsEmpty() != false)
            {
                return(null);
            }
            if (parameter.ParentMetaSchema == null)
            {
                parameter.ParentMetaSchema = Owner.Schema;
                Log.Warn("[PreconfiguredPageUserTask]. Parameter metadata modified at runtime.");
            }
            EntitySchema referenceSchema = parameter.ReferenceSchema;

            if (referenceSchema.PrimaryDisplayColumn == null)
            {
                return(new {
                    value = primaryColumnValue.Value.ToString()
                });
            }
            Entity entity = referenceSchema.CreateEntity(UserConnection);

            entity.UseAdminRights = false;
            var columnsToFetch = new Collection <CoreEntitySchemaColumn>()
            {
                referenceSchema.PrimaryColumn,
                referenceSchema.PrimaryDisplayColumn,
            };
            var hasPageTypeColumn = sysModuleEntityPageType.ContainsKey(referenceSchema.UId);
            CoreEntitySchemaColumn pageTypeColumn = null;

            if (hasPageTypeColumn)
            {
                Guid typeColumnUId = sysModuleEntityPageType[referenceSchema.UId];
                pageTypeColumn = referenceSchema.Columns.FindByUId(typeColumnUId);
                if (pageTypeColumn != null)
                {
                    columnsToFetch.Add(pageTypeColumn);
                }
            }
            entity.FetchFromDB(referenceSchema.PrimaryColumn, primaryColumnValue.Value, columnsToFetch, false);
            ExpandoObject lookupValue = GetClientLookupLinkValue(entity, pageTypeColumn);

            return(lookupValue);
        }
        /// <summary>
        /// Returns type of the activity.
        /// </summary>
        /// <returns>Lookup value.</returns>
        public virtual Guid GetActivityType()
        {
            CoreEntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByUId(ObjectSchemaId);

            foreach (var columnValue in RecordColumnValues.Values)
            {
                CoreEntitySchemaColumn column = entitySchema.GetSchemaColumnByMetaPath(columnValue.Key);
                if (column.Name == "Type" && columnValue.Value != null)
                {
                    var typeId = (Guid)columnValue.Value;
                    if (typeId != Guid.Empty)
                    {
                        return(typeId);
                    }
                }
            }
            return(PageTypeUId);
        }
 /// <summary>
 /// Serializes value of the entity column.
 /// </summary>
 /// <param name="schemaColumn">Schema column.</param>
 /// <param name="columnValue">Column value.</param>
 /// <returns></returns>
 public virtual object SerializeEntityColumn(CoreEntitySchemaColumn schemaColumn, object columnValue)
 {
     if (schemaColumn == null || columnValue == null)
     {
         return(string.Empty);
     }
     if (schemaColumn.DataValueType is BooleanDataValueType)
     {
         return(DataTypeUtilities.ValueAsType <bool>(columnValue));
     }
     if (schemaColumn.IsLookupType)
     {
         var primaryColumnValue = Column.Parameter(DataTypeUtilities.ValueAsType <Guid>(columnValue));
         var referenceSchema    = schemaColumn.ReferenceSchema;
         var displayValueSelect =
             new Select(UserConnection)
             .Column(referenceSchema.PrimaryDisplayColumn.Name)
             .From(referenceSchema.Name)
             .Where(referenceSchema.PrimaryColumn.Name).IsEqual(primaryColumnValue) as Select;
         return(new {
             value = columnValue,
             displayValue = displayValueSelect?.ExecuteScalar <string>()
         });
     }
     if (schemaColumn.DataValueType is DateTimeDataValueType dateTimeDataValueType)
     {
         var dateTime = (DateTime)columnValue;
         if (dateTime == DateTime.MinValue)
         {
             return(null);
         }
         if (dateTime.Kind != DateTimeKind.Unspecified)
         {
             columnValue = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
         }
         string value = DateTimeDataValueType.Serialize(columnValue, TimeZoneInfo.Utc);
         return(new {
             dataValueType = (int)dateTimeDataValueType.ToEnum(),
             value
         });
     }
     return(DataTypeUtilities.ValueAsType <string>(columnValue));
 }
Exemplo n.º 13
0
        /// <summary>
        /// Returns unique identifier of the contact who created the feed.
        /// </summary>
        /// <param name="socialSubscriptionId">Subscription unique identifier.</param>
        /// <param name="entityId">Entity unique identifier.</param>
        private Guid GetSocialChannelOwnerId(Guid socialSubscriptionId, Guid entityId)
        {
            CoreEntitySchema schema = GetSchema(socialSubscriptionId);
            var esq = new EntitySchemaQuery(UserConnection.EntitySchemaManager, schema.Name);
            EntitySchemaQueryColumn ownerColumn;
            var ownerColumnExist = schema.Columns.Any(c => c.Name == "Owner");

            if (ownerColumnExist)
            {
                ownerColumn = esq.AddColumn("Owner");
            }
            else
            {
                ownerColumn = esq.AddColumn("CreatedBy");
            }
            Entity socialChannel = esq.GetEntity(UserConnection, entityId);
            CoreEntitySchemaColumn entitySchemaColumn = socialChannel.Schema.FindSchemaColumnByPath(ownerColumn.Name);
            Guid ownerId = socialChannel.GetTypedColumnValue <Guid>(entitySchemaColumn);

            return(ownerId);
        }
Exemplo n.º 14
0
        private static void FillLookupDisplayValue(UserConnection userConnection,
                                                   Dictionary <string, ColumnExpression> columnExpressionMapping, LocalizedFeatureWeight feature,
                                                   ModelSchemaInput input, EntitySchema schema)
        {
            if (!Guid.TryParse(feature?.Value, out Guid id))
            {
                return;
            }
            EntitySchema referenceSchema;

            if (input.ReferenceSchemaName.IsNullOrEmpty())
            {
                if (!columnExpressionMapping.TryGetValue(input.Name, out ColumnExpression columnExpression))
                {
                    return;
                }
                EntitySchemaColumn column = schema.FindSchemaColumnByPath(columnExpression.ColumnPath);
                if (column == null || !column.IsLookupType || column.ReferenceSchema == null)
                {
                    return;
                }
                referenceSchema = column.ReferenceSchema;
            }
            else
            {
                referenceSchema = userConnection.EntitySchemaManager.FindInstanceByName(input.ReferenceSchemaName);
            }
            if (referenceSchema == null)
            {
                return;
            }
            Entity lookupEntity = referenceSchema.CreateEntity(userConnection);

            if (!lookupEntity.FetchPrimaryInfoFromDB(referenceSchema.PrimaryColumn, id))
            {
                return;
            }
            feature.DisplayValue = lookupEntity.PrimaryDisplayColumnValue;
        }
        /// <summary>
        /// Creates entity of the Activity.
        /// </summary>
        /// <returns>A new instance of the entity.</returns>
        public virtual Entity CreateActivity()
        {
            CoreEntitySchema activitySchema = GetActivityEntitySchema();
            Entity           activity       = activitySchema.CreateEntity(UserConnection);

            activity.UseAdminRights = false;
            string activityTitle = GetActivityTitle();

            activity.SetColumnValue("Title", activityTitle);
            activity.SetDefColumnValues();
            foreach (KeyValuePair <string, object> columnValue in RecordColumnValues.Values)
            {
                CoreEntitySchemaColumn column = activitySchema.GetSchemaColumnByMetaPath(columnValue.Key);
                if ((column.DataValueType is LookupDataValueType || column.DataValueType is MultiLookupDataValueType) &&
                    ((Guid)columnValue.Value).IsEmpty())
                {
                    continue;
                }
                activity.SetColumnValue(column, columnValue.Value);
            }
            var columnDocument = activity.Schema.Columns.FindByName("Document");

            if (columnDocument != null)
            {
                object document = activity.GetColumnValue(columnDocument);
                if (document != null)
                {
                    Document = (Guid)document;
                }
            }
            SpecifyActivityColumnValues(activity);
            CurrentActivityId   = activity.PrimaryColumnValue;
            IsActivityCompleted = false;
            PageTypeUId         = GetActivityType();
            return(activity);
        }
Exemplo n.º 16
0
        private LookupColumnValue GetLookupColumnValue(ESHit esHit, EntitySchemaColumn column)
        {
            LookupColumnValue resultValue = null;
            var    columnAlias            = GlobalSearchColumnUtils.GetAlias(column, _entitySchema);
            string displayValue           = esHit.Source.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value;

            if (!string.IsNullOrEmpty(displayValue) ||
                GlobalSearchColumnUtils.GetIsSysImageLookupColumn(column))
            {
                var displayColumnAlias = GlobalSearchColumnUtils.GetPrimaryColumnAlias(column, _entityName);
                resultValue = new LookupColumnValue {
                    Value        = esHit.Source.FirstOrDefault(x => string.Equals(x.Key, displayColumnAlias)).Value,
                    DisplayValue = displayValue
                };
                var imageColumn = column.ReferenceSchema.PrimaryImageColumn;
                if (imageColumn != null && imageColumn.DataValueType is ImageLookupDataValueType)
                {
                    var priamaryImageColumnAlias = GlobalSearchColumnUtils.GetPrimaryImageColumnAlias(column, _entityName);
                    resultValue.PrimaryImageValue = esHit.Source
                                                    .FirstOrDefault(x => string.Equals(x.Key, priamaryImageColumnAlias)).Value;
                }
            }
            return(resultValue);
        }
Exemplo n.º 17
0
 private IEntitySchemaQueryFilterItem CreateEmptyColumnValueFilter(EntitySchemaQuery query, EntitySchemaColumn column)
 {
     return(column.DataValueType is TextDataValueType
                         ? query.CreateFilterWithParameters(FilterComparisonType.NotEqual, column.Name, string.Empty)
                         : query.CreateIsNotNullFilter(column.Name));
 }
Exemplo n.º 18
0
        private void AppendAdditionalHighLightColumn(Dictionary <string, object> columnValues, ESHit esHit, EntitySchemaColumn column)
        {
            var columnAlias          = GlobalSearchColumnUtils.GetAlias(column, _entitySchema);
            var columnHighlightValue = esHit.Highlight.FirstOrDefault(x => string.Equals(x.Key, columnAlias)).Value;

            if (columnHighlightValue != null)
            {
                columnValues.Add(column.Name, _replaceHighlightRegex.Replace(string.Join("...", columnHighlightValue), ""));
            }
        }