internal void UpdateTable(DataRow row, string targetConfigObject, bool isOnReading) { if (this.DataObjectStore.GetDataObject(targetConfigObject) == null) { return; } this.suppressColumnChanged = true; try { foreach (object obj in this.Table.Columns) { DataColumn dataColumn = (DataColumn)obj; ColumnProfile columnProfile = dataColumn.ExtendedProperties["ColumnProfile"] as ColumnProfile; if (columnProfile != null && columnProfile.DataObjectName != null && targetConfigObject.Equals(columnProfile.DataObjectName, StringComparison.InvariantCultureIgnoreCase)) { object obj2 = columnProfile.PersistWholeObject ? this.DataObjectStore.GetDataObject(columnProfile.DataObjectName) : this.DataObjectStore.GetValue(columnProfile.DataObjectName, columnProfile.MappingProperty); obj2 = (obj2 ?? DBNull.Value); this.Row[dataColumn] = obj2; } } } finally { this.suppressColumnChanged = false; if (isOnReading) { this.FillColumnsBasedOnOnceLambdaExpression(); } this.FillColumnsBasedOnLambdaExpression(null); } }
private string GetColumnNameThruMappingProperty(string mappingProperty, DataTable table, object dataObject) { string result = mappingProperty; foreach (object obj in table.Columns) { DataColumn dataColumn = (DataColumn)obj; ColumnProfile columnProfile = dataColumn.ExtendedProperties["ColumnProfile"] as ColumnProfile; if (mappingProperty.Equals(columnProfile.MappingProperty) && dataObject == this.GetDataObject(columnProfile.DataObjectName)) { result = dataColumn.ColumnName; } } return(result); }
private void SetConstraintsFromBinding(Binding binding) { if (binding.BindingManagerBase != null) { if (!this.IsFormatModeAndBindingCompatible(this.ownerControl.FormatMode, binding)) { throw new InvalidOperationException(); } PropertyDescriptorCollection itemProperties = binding.BindingManagerBase.GetItemProperties(); PropertyDescriptor propertyDescriptor = itemProperties.Find(binding.BindingMemberInfo.BindingField, true); if (propertyDescriptor != null) { FilterValuePropertyDescriptor filterValuePropertyDescriptor = propertyDescriptor as FilterValuePropertyDescriptor; Type propertyType; if (filterValuePropertyDescriptor != null) { propertyType = filterValuePropertyDescriptor.ValuePropertyType; } else { propertyType = propertyDescriptor.PropertyType; } object obj = (binding.DataSource is BindingSource) ? ((BindingSource)binding.DataSource).DataSource : binding.DataSource; DataTable dataTable = obj as DataTable; if (dataTable != null) { DataObjectStore dataObjectStore = dataTable.ExtendedProperties["DataSourceStore"] as DataObjectStore; if (dataObjectStore != null) { DataColumn dataColumn = dataTable.Columns[binding.BindingMemberInfo.BindingField]; ColumnProfile columnProfile = dataColumn.ExtendedProperties["ColumnProfile"] as ColumnProfile; if (!string.IsNullOrEmpty(columnProfile.DataObjectName)) { Type dataObjectType = dataObjectStore.GetDataObjectType(columnProfile.DataObjectName); if (null != dataObjectType) { obj = dataObjectType; propertyType = dataObjectType.GetProperty(columnProfile.MappingProperty).PropertyType; } } } } PropertyDefinitionConstraint[] propertyDefinitionConstraints = PropertyConstraintProvider.GetPropertyDefinitionConstraints(obj, binding.BindingMemberInfo.BindingField); this.SetConstraintsFromType(propertyType, propertyDefinitionConstraints); } } }
public List <string> GetModifiedPropertiesBasedOnDataObject(DataRow row, string dataObjectName) { List <string> list = new List <string>(); foreach (string name in this.ModifiedColumns) { if (row.Table.Columns.Contains(name)) { ColumnProfile columnProfile = row.Table.Columns[name].ExtendedProperties["ColumnProfile"] as ColumnProfile; if (columnProfile != null && string.Equals(columnProfile.DataObjectName, dataObjectName) && !columnProfile.IgnoreChangeTracking) { list.Add(columnProfile.MappingProperty); } } } return(list); }
protected void UpdateObject(DataColumn column) { ColumnProfile columnProfile = column.ExtendedProperties["ColumnProfile"] as ColumnProfile; if (!string.IsNullOrEmpty(columnProfile.DataObjectName)) { if (!columnProfile.PersistWholeObject) { this.dataObjectStore.SetValue(columnProfile.DataObjectName, columnProfile.MappingProperty, this.Row[column.ColumnName], columnProfile.PropertySetter); } else { this.dataObjectStore.UpdateDataObject(columnProfile.DataObjectName, this.Row[column.ColumnName]); } this.UpdateTable(this.Row, columnProfile.DataObjectName); } }
public override List <string> Validate(object target, PageConfigurableProfile profile) { List <string> list = new List <string>(); ColumnProfile columnProfile = target as ColumnProfile; if (columnProfile != null && !columnProfile.PersistWholeObject) { string mappingProperty = columnProfile.MappingProperty; string dataObjectName = columnProfile.DataObjectName; if (!string.IsNullOrEmpty(dataObjectName) && !string.IsNullOrEmpty(mappingProperty)) { if (profile.DataObjectProfiles.Any((DataObjectProfile dataobject) => dataObjectName.Equals(dataobject.Name))) { Type type = profile.DataObjectProfiles.First((DataObjectProfile dataobject) => dataObjectName.Equals(dataobject.Name)).Type; PropertyInfo property = type.GetProperty(mappingProperty, BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy); if (property == null) { list.Add(string.Format("{0} is not a valid property in data object {1}", mappingProperty, type.FullName)); } } } } return(list); }
internal override bool HasPermissionForProperty(string propertyName, bool canUpdate) { if (EnvironmentAnalyzer.IsWorkGroup() || !base.ProfileBuilder.CanEnableUICustomization()) { return(true); } ColumnProfile columnProfile = (from DataColumn c in base.Table.Columns where c.ColumnName == propertyName select c).First <DataColumn>().ExtendedProperties["ColumnProfile"] as ColumnProfile; string dataObjectName = columnProfile.DataObjectName; IEnumerable <ReaderTaskProfile> source = from c in this.readerTaskProfileList where c.DataObjectName == dataObjectName select c; ReaderTaskProfile readerTaskProfile = null; if (source.Count <ReaderTaskProfile>() > 0) { readerTaskProfile = source.First <ReaderTaskProfile>(); } if (readerTaskProfile != null && !readerTaskProfile.HasPermission()) { return(false); } if (canUpdate) { if (columnProfile.IgnoreChangeTracking) { return(true); } IEnumerable <SaverTaskProfile> source2 = from c in this.saverTaskProfileList where (c.Runner as Saver).GetConsumedDataObjectName() == dataObjectName && !string.IsNullOrEmpty(dataObjectName) select c; SaverTaskProfile saverTaskProfile = null; if (source2.Count <SaverTaskProfile>() > 0) { saverTaskProfile = source2.First <SaverTaskProfile>(); } if (saverTaskProfile == null) { IEnumerable <SaverTaskProfile> enumerable = from c in this.saverTaskProfileList where (from p in c.ParameterProfileList where p.Reference == propertyName select p).Count <ParameterProfile>() > 0 select c; using (IEnumerator <SaverTaskProfile> enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) { SaverTaskProfile saverTaskProfile2 = enumerator.Current; if (!saverTaskProfile2.HasPermission(columnProfile.MappingProperty)) { return(false); } } return(true); } } if (saverTaskProfile != null && !saverTaskProfile.HasPermission(columnProfile.MappingProperty)) { return(false); } } return(true); }