Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public virtual string GenerateParameterConfigs(StringBuilder sb)
        {
            DataValueTypeManager dataValueTypeManager = UserConnection.DataValueTypeManager;

            sb.Append("{");
            bool isNotFirstProperty = false;
            var  processSchema      = Owner.Schema;
            var  schemaElement      = (ProcessSchemaUserTask)GetSchemaElement();

            foreach (ProcessSchemaParameter parameter in schemaElement.Parameters)
            {
                if (parameter.CreatedInSchemaUId != processSchema.UId)
                {
                    continue;
                }
                var    dataValueTypeItem = dataValueTypeManager.GetItemByUId(parameter.DataValueTypeUId);
                object parameterValue    = GetParameterValue(parameter);
                if (parameter.DataValueType.IsLookup)
                {
                    Guid guidPropertyValue = Guid.Empty;
                    if (parameterValue != null)
                    {
                        guidPropertyValue = (Guid)parameterValue;
                    }
                    if (guidPropertyValue == Guid.Empty)
                    {
                        AppendJSonProperty(sb, parameter.Name, null, 0, ref isNotFirstProperty);
                        continue;
                    }
                    string displayValue = string.Empty;
                    if (parameter.ParentMetaSchema == null)
                    {
                        parameter.ParentMetaSchema = processSchema;
                        Log.Warn("[AutoGeneratedPageUserTask]. Parameter metadata modified at runtime.");
                    }
                    if (parameter.ReferenceSchema.PrimaryDisplayColumn != null)
                    {
                        if (guidPropertyValue != Guid.Empty)
                        {
                            var entity = parameter.ReferenceSchema.CreateEntity(UserConnection);
                            entity.UseAdminRights = false;
                            entity.FetchFromDB(parameter.ReferenceSchema.PrimaryColumn, guidPropertyValue,
                                               new Collection <CoreEntitySchemaColumn> {
                                parameter.ReferenceSchema.PrimaryDisplayColumn
                            });
                            displayValue = entity.PrimaryDisplayColumnValue;
                        }
                    }
                    var value = new LookupColumnValue {
                        Value        = parameterValue?.ToString(),
                        DisplayValue = displayValue
                    };
                    AppendJSonProperty(sb, parameter.Name, value, 1, ref isNotFirstProperty);
                }
                else if (dataValueTypeItem.GroupName == "Dates")
                {
                    if (parameterValue == null)
                    {
                        AppendJSonProperty(sb, parameter.Name, parameterValue, 0, ref isNotFirstProperty);
                        continue;
                    }
                    var dateTime = (DateTime)parameterValue;
                    if (dateTime == DateTime.MinValue)
                    {
                        AppendJSonProperty(sb, parameter.Name, parameterValue, 0, ref isNotFirstProperty);
                        continue;
                    }
                    if (dateTime.Kind == DateTimeKind.Local)
                    {
                        parameterValue = DateTime.SpecifyKind(dateTime, DateTimeKind.Unspecified);
                    }
                    string value = DateTimeDataValueType.Serialize(parameterValue, TimeZoneInfo.Utc);
                    string dateTimeObjectValue =
                        $"{{\"dataValueType\":{(int)parameter.DataValueType.ToEnum()}, \"value\":\"{value}\"}}";
                    AppendJSonProperty(sb, parameter.Name, dateTimeObjectValue, 3, ref isNotFirstProperty);
                }
                else if (dataValueTypeItem.Name == "Boolean")
                {
                    AppendJSonProperty(sb, parameter.Name, parameterValue, 2, ref isNotFirstProperty);
                }
                else
                {
                    byte type = parameterValue == null ? (byte)0 : (byte)1;
                    AppendJSonProperty(sb, parameter.Name, parameterValue, type, ref isNotFirstProperty);
                }
            }
            sb.Append("}");
            return(sb.ToString());
        }