public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<ImageUploadEditorAttribute>(); if (attr == null || attr.DisableDefaultBehavior || attr.EditorType != "MultipleImageUpload") return false; if (!(Target is StringField)) throw new ArgumentException(String.Format( "Field '{0}' on row type '{1}' has a UploadEditor attribute but it is not a String field!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); if (!(row is IIdRow)) throw new ArgumentException(String.Format( "Field '{0}' on row type '{1}' has a UploadEditor attribute but Row type doesn't implement IIdRow!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); var format = attr.FilenameFormat; if (format == null) { format = row.GetType().Name; if (format.EndsWith("Row")) format = format.Substring(0, format.Length - 3); format += "/~"; } this.fileNameFormat = format.Replace("~", SplittedFormat); this.uploadHelper = new UploadHelper((attr.SubFolder.IsEmptyOrNull() ? "" : (attr.SubFolder + "/")) + (this.fileNameFormat)); return true; }
private void ToJson(JsonWriter writer, Row row, JsonSerializer serializer) { writer.WriteStartObject(); if (row.TrackAssignments) { var modified = row.assignedFields; if (modified != null) { var fields = row.fields; for (var i = 0; i < fields.Count; i++) if (modified[i]) { var f = fields[i]; if (!f.IsNull(row)) { writer.WritePropertyName(f.PropertyName ?? f.Name); f.ValueToJson(writer, row, serializer); } } } } else { var fields = row.fields; foreach (var f in fields) if (!f.IsNull(row)) { writer.WritePropertyName(f.PropertyName ?? f.Name); f.ValueToJson(writer, row, serializer); } } writer.WriteEndObject(); }
public void BeginEdit() { TrackAssignments = true; if (originalValues == null) originalValues = this.CloneRow(); }
public bool ActivateFor(Row row) { var mt = row as IMultiTenantRow; if (mt == null) return false; fldTenantId = mt.TenantIdField; return true; }
public bool ActivateFor(Row row) { if (row.GetType().GetCustomAttribute<CaptureLogAttribute>() == null) return false; captureLogHandler = (ICaptureLogHandler)Activator.CreateInstance( typeof(CaptureLogHandler<>).MakeGenericType(row.GetType())); return true; }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<MasterDetailRelationAttribute>(); if (attr == null) return false; var rowListType = Target.ValueType; if (!rowListType.IsGenericType || rowListType.GetGenericTypeDefinition() != typeof(List<>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic List (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var rowType = rowListType.GetGenericArguments()[0]; if (rowType.IsAbstract || !typeof(Row).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic list of rows (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } rowListFactory = FastReflection.DelegateForConstructor<IList>(rowListType); rowFactory = FastReflection.DelegateForConstructor<Row>(rowType); listHandlerFactory = FastReflection.DelegateForConstructor<IListRequestProcessor>( typeof(ListRequestHandler<>).MakeGenericType(rowType)); saveHandlerFactory = FastReflection.DelegateForConstructor<ISaveRequestProcessor>( typeof(SaveRequestHandler<>).MakeGenericType(rowType)); saveRequestFactory = FastReflection.DelegateForConstructor<ISaveRequest>( typeof(SaveRequest<>).MakeGenericType(rowType)); deleteHandlerFactory = FastReflection.DelegateForConstructor<IDeleteRequestProcessor>( typeof(DeleteRequestHandler<>).MakeGenericType(rowType)); var detailRow = rowFactory(); foreignKeyField = detailRow.FindFieldByPropertyName(attr.ForeignKey) ?? detailRow.FindField(attr.ForeignKey); if (ReferenceEquals(foreignKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a master detail relation in field '{2}' of row type '{3}'.", attr.ForeignKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); return true; }
public void CloneInto(Row clone, bool cloneHandlers) { clone.ignoreConstraints = ignoreConstraints; foreach (var field in GetFields()) field.Copy(this, clone); clone.tracking = tracking; if (tracking) { if (assignedFields != null) { clone.assignedFields = new bool[assignedFields.Length]; Array.Copy(assignedFields, clone.assignedFields, assignedFields.Length); } } else clone.assignedFields = null; clone.trackWithChecks = trackWithChecks; clone.originalValues = originalValues; if (dictionaryData != null) clone.dictionaryData = (Hashtable)this.dictionaryData.Clone(); else clone.dictionaryData = null; if (indexedData != null) { clone.indexedData = new object[indexedData.Length]; for (var i = 0; i < indexedData.Length; i++) clone.indexedData[i] = indexedData[i]; } else clone.indexedData = null; if (previousValues != null) clone.previousValues = previousValues.CloneRow(); else clone.previousValues = null; if (cloneHandlers) { clone.postHandler = this.postHandler; clone.propertyChanged = this.propertyChanged; if (this.validationErrors != null) clone.validationErrors = new Dictionary<string, string>(this.validationErrors); else clone.validationErrors = null; } }
public static List<PropertyItem> GetCustomFieldPropertyItems(IEnumerable<ICustomFieldDefinition> definitions, Row row, string fieldPrefix) { var list = new List<PropertyItem>(); foreach (var def in definitions) { string name = fieldPrefix + def.Name; var field = row.FindFieldByPropertyName(name) ?? row.FindField(name); list.Add(GetCustomFieldPropertyItem(def, field)); } return list; }
public bool ActivateFor(Row row) { var attr = row.GetType().GetCustomAttributes<UniqueConstraintAttribute>() .Where(x => x.CheckBeforeSave); if (!attr.Any()) return false; this.attrList = attr.ToArray(); return true; }
public static List<ReportColumn> EntityTypeToList(Row instance) { var list = new List<ReportColumn>(); foreach (var field in instance.GetFields()) { list.Add(FromField(field)); } return list; }
public static BaseCriteria GetDisplayOrderFilterFor(Row row) { var flt = Criteria.Empty; var parentIdRow = row as IParentIdRow; if (parentIdRow != null) flt = flt & (new Criteria((Field)parentIdRow.ParentIdField) == Convert.ToInt64(((Field)parentIdRow.ParentIdField).AsObject(row))); var activeRow = row as IIsActiveRow; if (activeRow != null) flt = flt & new Criteria((Field)activeRow.IsActiveField) >= 0; return flt; }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; if (!Target.Flags.HasFlag(FieldFlags.Unique)) return false; var attr = Target.GetAttribute<UniqueAttribute>(); if (attr != null && !attr.CheckBeforeSave) return false; this.attr = attr; return true; }
public void CancelEdit() { if (originalValues != null) { var original = originalValues; originalValues = null; for (int i = 0; i < fields.Count; i++) fields[i].CopyNoAssignment(original, this); assignedFields = original.assignedFields; ClearValidationErrors(); } }
internal static Dictionary<string, Field> ParseReplaceFields(string fileNameFormat, Row row, Field target) { if (fileNameFormat.IndexOf('|') < 0) return null; var replaceFields = new Dictionary<string, Field>(); int start = 0; while ((start = fileNameFormat.IndexOf('|', start)) >= 0) { var end = fileNameFormat.IndexOf('|', start + 1); if (end <= start + 1) throw new ArgumentException(String.Format( "Field '{0}' on row type '{1}' has a UploadEditor attribute " + "with invalid format string '{2}'!", target.PropertyName ?? target.Name, row.GetType().FullName, fileNameFormat)); var fieldName = fileNameFormat.Substring(start + 1, end - start - 1); var actualName = fieldName; var colon = fieldName.IndexOf(":"); if (colon >= 0) actualName = fieldName.Substring(0, colon); var replaceField = row.FindFieldByPropertyName(actualName) ?? row.FindField(actualName); if (ReferenceEquals(null, replaceField)) { throw new ArgumentException(String.Format( "Field '{0}' on row type '{1}' has a UploadEditor attribute that " + "references field '{2}', but no such field is found!'", target.PropertyName ?? target.Name, row.GetType().FullName, actualName)); } replaceFields['|' + fieldName + '|'] = replaceField; start = end + 1; } return replaceFields; }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; var attr = Target.GetAttribute<NotesEditorAttribute>(); if (attr == null) return false; if (Target.ValueType != typeof(List<NoteRow>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a NotesEditorAttribute " + "but its property type is not a List<NoteRow>!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } return true; }
private static void AddInstance(Dictionary<string, Dictionary<string, Row>> registry, Row row) { try { var connectionKey = GetConnectionKey(row.GetType()); Dictionary<string, Row> connectionRegistry; if (!registry.TryGetValue(connectionKey, out connectionRegistry)) registry[connectionKey] = connectionRegistry = new Dictionary<string, Row>(StringComparer.OrdinalIgnoreCase); string table = row.Table; connectionRegistry.Add(table, row); } catch (Exception ex) { new InvalidOperationException(String.Format("Can't register Row instance in DataSchema: {0}", row.GetType().FullName), ex).Log(); } }
public abstract object AsObject(Row row);
public CriteriaFieldExpressionReplacer(Row row) { this.Row = row; }
public bool ActivateFor(Row row) { return row is IUpdateLogRow || row is IInsertLogRow; }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<LinkingSetRelationAttribute>(); if (attr == null) return false; if (!(row is IIdRow)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but it doesn't implement IIdRow!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var listType = Target.ValueType; if (!listType.GetIsGenericType() || listType.GetGenericTypeDefinition() != typeof(List<>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but its property type is not a generic List (e.g. List<int>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var rowType = attr.RowType; if (rowType.GetIsAbstract() || !typeof(Row).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but specified row type is not valid row class!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } if (!typeof(IIdRow).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but specified row type doesn't implement IIdRow!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } listFactory = FastReflection.DelegateForConstructor<IList>(listType); rowFactory = FastReflection.DelegateForConstructor<Row>(rowType); listHandlerFactory = FastReflection.DelegateForConstructor<IListRequestProcessor>( typeof(ListRequestHandler<>).MakeGenericType(rowType)); saveHandlerFactory = FastReflection.DelegateForConstructor<ISaveRequestProcessor>( typeof(SaveRequestHandler<>).MakeGenericType(rowType)); saveRequestFactory = FastReflection.DelegateForConstructor<ISaveRequest>( typeof(SaveRequest<>).MakeGenericType(rowType)); deleteHandlerFactory = FastReflection.DelegateForConstructor<IDeleteRequestProcessor>( typeof(DeleteRequestHandler<>).MakeGenericType(rowType)); var detailRow = rowFactory(); thisKeyField = detailRow.FindFieldByPropertyName(attr.ThisKey) ?? detailRow.FindField(attr.ThisKey); if (ReferenceEquals(thisKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation in field '{2}' of row type '{3}'.", attr.ThisKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.thisKeyCriteria = new Criteria(thisKeyField.PropertyName ?? thisKeyField.Name); itemKeyField = detailRow.FindFieldByPropertyName(attr.ItemKey) ?? detailRow.FindField(attr.ItemKey); if (ReferenceEquals(itemKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation in field '{2}' of row type '{3}'.", attr.ItemKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); if (!string.IsNullOrEmpty(attr.FilterField)) { this.filterField = detailRow.FindFieldByPropertyName(attr.FilterField) ?? detailRow.FindField(attr.FilterField); if (ReferenceEquals(null, this.filterField)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation as FilterField in field '{2}' of row type '{3}'.", attr.FilterField, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.filterCriteria = new Criteria(filterField.PropertyName ?? filterField.Name); this.filterValue = filterField.ConvertValue(attr.FilterValue, CultureInfo.InvariantCulture); if (this.filterValue == null) { this.filterCriteria = this.filterCriteria.IsNull(); this.filterCriteriaT0 = this.filterField.IsNull(); } else { this.filterCriteria = this.filterCriteria == new ValueCriteria(this.filterValue); this.filterCriteriaT0 = this.filterField == new ValueCriteria(this.filterValue); } } return true; }
public abstract void ValueFromJson(JsonReader reader, Row row, JsonSerializer serializer);
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<MasterDetailRelationAttribute>(); if (attr == null) return false; var rowListType = Target.ValueType; if (!rowListType.GetIsGenericType() || rowListType.GetGenericTypeDefinition() != typeof(List<>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic List (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var rowType = rowListType.GetGenericArguments()[0]; if (rowType.GetIsAbstract() || !typeof(Row).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic list of rows (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } rowListFactory = FastReflection.DelegateForConstructor<IList>(rowListType); rowFactory = FastReflection.DelegateForConstructor<Row>(rowType); listHandlerFactory = FastReflection.DelegateForConstructor<IListRequestProcessor>( typeof(ListRequestHandler<>).MakeGenericType(rowType)); saveHandlerFactory = FastReflection.DelegateForConstructor<ISaveRequestProcessor>( typeof(SaveRequestHandler<>).MakeGenericType(rowType)); saveRequestFactory = FastReflection.DelegateForConstructor<ISaveRequest>( typeof(SaveRequest<>).MakeGenericType(rowType)); deleteHandlerFactory = FastReflection.DelegateForConstructor<IDeleteRequestProcessor>( typeof(DeleteRequestHandler<>).MakeGenericType(rowType)); var detailRow = rowFactory(); foreignKeyField = detailRow.FindFieldByPropertyName(attr.ForeignKey) ?? detailRow.FindField(attr.ForeignKey); if (ReferenceEquals(foreignKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a master detail relation in field '{2}' of row type '{3}'.", attr.ForeignKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.foreignKeyCriteria = new Criteria(foreignKeyField.PropertyName ?? foreignKeyField.Name); if (!string.IsNullOrEmpty(attr.FilterField)) { this.filterField = detailRow.FindFieldByPropertyName(attr.FilterField) ?? detailRow.FindField(attr.FilterField); if (ReferenceEquals(null, this.filterField)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a master detail relation as FilterField in field '{2}' of row type '{3}'.", attr.FilterField, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.filterCriteria = new Criteria(filterField.PropertyName ?? filterField.Name); this.filterValue = filterField.ConvertValue(attr.FilterValue, CultureInfo.InvariantCulture); if (this.filterValue == null) { this.filterCriteria = this.filterCriteria.IsNull(); this.filterCriteriaT0 = this.filterField.IsNull(); } else { this.filterCriteria = this.filterCriteria == new ValueCriteria(this.filterValue); this.filterCriteriaT0 = this.filterField == new ValueCriteria(this.filterValue); } } this.includeColumns = new HashSet<string>(); if (!string.IsNullOrEmpty(attr.IncludeColumns)) foreach (var s in attr.IncludeColumns.Split(',')) { var col = s.TrimToNull(); if (col != null) this.includeColumns.Add(col); } return true; }
public abstract void Copy(Row source, Row target);
private void SaveDetail(IUnitOfWork uow, Row detail, object masterId, object detailId) { detail = detail.Clone(); foreignKeyField.AsObject(detail, masterId); if (!ReferenceEquals(null, filterField)) filterField.AsObject(detail, filterValue); ((Field)((IIdRow)detail).IdField).AsObject(detail, detailId); var saveHandler = saveHandlerFactory(); var saveRequest = saveRequestFactory(); saveRequest.Entity = detail; saveHandler.Process(uow, saveRequest, detailId == null ? SaveRequestType.Create : SaveRequestType.Update); }
public bool IsNull(Row row) { CheckUnassignedRead(row); return GetIsNull(row); }
protected abstract bool GetIsNull(Row row);
public abstract void GetFromReader(IDataReader reader, int index, Row row);
public abstract int IndexCompare(Row row1, Row row2);
public void EndEdit() { if (postHandler != null && originalValues != null) { if (insidePostHandler > 0) return; // exception daha iyi olabilir mi? insidePostHandler++; try { ClearValidationErrors(); postHandler(this); if (HasErrors) throw new Exception("Lütfen satırdaki işaretli alanları düzeltiniz."); originalValues = null; } finally { insidePostHandler--; } if (PostEnded != null) PostEnded(this, new EventArgs()); } else { originalValues = null; ClearValidationErrors(); } }
public abstract void AsObject(Row row, object value);