private void AddQueryColumns() { entityColumnsMap = new Dictionary <string, object>(); EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName(SchemaName); string primaryDisplayColumnName = entitySchema.FindPrimaryDisplayColumnName(); string primaryKeyColumnName = entitySchema.GetPrimaryColumnName(); string primaryColumnAlias = string.Empty; foreach (JObject columnItem in _columns) { string columnPath = DashboardDataUtils.GetColumnPath(columnItem); if (entityColumnsMap.ContainsKey(columnPath)) { continue; } EntitySchemaQueryColumn column = AddQueryColumn(columnItem, columnPath); Dictionary <string, object> map = MapColumn(column); entityColumnsMap[columnPath] = map; if (columnPath == primaryKeyColumnName) { primaryColumnAlias = (string)map["valueAlias"]; } } if (primaryColumnAlias.IsNullOrEmpty() && primaryKeyColumnName.IsNotNullOrEmpty()) { EntitySchemaQueryColumn primaryKeyColumn = Esq.AddColumn(primaryKeyColumnName); entityColumnsMap[primaryKeyColumnName] = MapColumn(primaryKeyColumn); } }
protected virtual Entity GetSourceEntity(EntitySchema sourceSchema, Dictionary <string, string> validColumnmap, Guid sourceRowId) { var entity = sourceSchema.CreateEntity(UserConnection); IEnumerable <string> columnsToFetch = validColumnmap.Values.Distinct(); entity.FetchFromDB(sourceSchema.GetPrimaryColumnName(), sourceRowId, columnsToFetch); return(entity); }
protected virtual string GetEntityPrimaryColumnDisplayName(EmailTemplateUserTask userTask, object parameterValue, ProcessSchemaParameter parameter) { string result = null; EntitySchema referenceSchema = parameter.ReferenceSchema; Entity entity = referenceSchema.CreateEntity(userTask.UserConnection); if (entity.FetchPrimaryInfoFromDB(referenceSchema.GetPrimaryColumnName(), parameterValue)) { result = entity.PrimaryDisplayColumnValue; } return(result); }
private QueryCondition GetRightsCondition(Select select, EntitySchema forecastEntitySchema) { var securityEngine = UserConnection.DBSecurityEngine; var rightsCondition = securityEngine.GetRecordsByRightCondition(new RecordsByRightOptions { EntitySchemaName = forecastEntitySchema.Name, EntitySchemaSourceAlias = select.SourceExpression.Alias, RightEntitySchemaName = securityEngine.GetRecordRightsSchemaName(forecastEntitySchema.Name), Operation = Core.Configuration.EntitySchemaRecordRightOperation.Read, PrimaryColumnName = forecastEntitySchema.GetPrimaryColumnName(), UserId = UserConnection.CurrentUser.Id, UseDenyRecordRights = forecastEntitySchema.UseDenyRecordRights }); return(rightsCondition); }
private JArray GetColumns() { var columns = new JArray(); JArray items = GetGridConfigColumns(); EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName(GetSchemaName()); string primaryDisplayColumnName = entitySchema.FindPrimaryDisplayColumnName(); string primaryKeyColumnName = entitySchema.GetPrimaryColumnName(); string primaryColumnAlias = string.Empty; foreach (JObject columnItem in items) { string columnPath = DashboardDataUtils.GetColumnPath(columnItem); string columnCaption = columnItem.Value <string>("caption"); if (string.IsNullOrEmpty(columnCaption)) { columnCaption = columnPath; } var columnConfig = new JObject(); columnConfig["name"] = columnPath; columnConfig["caption"] = columnCaption; columnConfig["type"] = columnItem.Value <string>("type"); columnConfig["position"] = columnItem["position"]; if (string.IsNullOrEmpty(columnItem.Value <string>("dataValueType"))) { Dictionary <string, object> map = (Dictionary <string, object>)selectBuilder.EntityColumnsMap[columnPath]; var type = (DataValueType)map["dataValueType"]; columnConfig["dataValueType"] = (int)Terrasoft.Nui.ServiceModel.Extensions.DataValueTypeExtension.ToEnum(type); } else { columnConfig["dataValueType"] = columnItem.Value <int>("dataValueType"); } if (columnPath != primaryDisplayColumnName) { columnConfig["referenceSchemaName"] = columnItem.Value <string>("referenceSchemaName"); } columns.Add(columnConfig); } return(columns); }
public static LocalizableString GetLocalizableValue(UserConnection userConnection, string schemaName, string columnName, Guid recordId) { EntitySchemaQuery esq; EntitySchemaQueryColumn column; var result = new LocalizableString(); EntitySchemaManager entitySchemaManager = userConnection.EntitySchemaManager; SysUserInfo currentUser = userConnection.CurrentUser; CultureInfo currentUserCulture = currentUser.Culture; EntitySchema schema = entitySchemaManager.GetInstanceByName(schemaName); if (UseMultilanguageData) { esq = new EntitySchemaQuery(entitySchemaManager, schemaName); column = esq.AddColumn(columnName); esq.Filters.Add(esq.CreateFilterWithParameters( FilterComparisonType.Equal, schema.GetPrimaryColumnName(), recordId)); } else { Guid columnUId = schema.Columns.GetByName(columnName).UId; string lczSchemaName = schema.GetLocalizableStringsSchemaName(); esq = new EntitySchemaQuery(entitySchemaManager, lczSchemaName); column = esq.AddColumn("Value"); esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "ColumnUId", columnUId)); esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Record", recordId)); esq.Filters.Add( esq.CreateFilterWithParameters(FilterComparisonType.Equal, "SysCulture", currentUser.SysCultureId)); } EntityCollection entities = esq.GetEntityCollection(userConnection); if (entities.Count > 0) { Entity entity = entities.First(); string lczValue = entity.GetTypedColumnValue <string>(column.Name); result.SetCultureValue(currentUserCulture, lczValue); } return(result); }