public static int GetMaxId() { //Session session = new Session(); //session.ConnectionString = XpoDefault.ConnectionString; // Obtain the persistent object class info required by the GetObjects method XPClassInfo dstnClass = XpoDefault.Session.GetClassInfo(typeof(DataStore)); // Create criteria to get objects CriteriaOperator criteria = null; // new BinaryOperator("Discontinued", true); // Create a sort list if objects must be processed in a specific order SortingCollection sortProps = null; // new SortingCollection(null); // sortProps.Add(new SortProperty("Price", DevExpress.Xpo.DB.SortingDirection.Ascending)); // Create criteria patcher to filter out the objects marked as "deleted" // and to support loading of inherited objects of a given base persistent class CollectionCriteriaPatcher patcher = new DevExpress.Xpo.Generators.CollectionCriteriaPatcher(false, XpoDefault.Session.TypesManager); // Call GetObjects ICollection collection = XpoDefault.Session.GetObjects(dstnClass, criteria, sortProps, 0, patcher, true); int max = int.MinValue; // Do processing foreach (DataStore dstn in collection) { max = Math.Max(max, dstn.Id); } return(max); }
static string Criteria(object obj, XPClassInfo classInfo) { var keyProperty = classInfo.KeyProperty; var keyValue = keyProperty.GetValue(obj); return(CriteriaOperator.Parse(keyProperty.Name + "=?", keyValue).ToString()); }
static Dictionary <string, object> RetrieveIndexedProperties(XPClassInfo classInfo, IXPSimpleObject source) { Dictionary <string, object> indexedProperties = new Dictionary <string, object>(); foreach (XPMemberInfo item in classInfo.PersistentProperties) { if (item.HasAttribute(typeof(IndexedAttribute))) { IndexedAttribute attribute = (IndexedAttribute)item.GetAttributeInfo(typeof(IndexedAttribute)); if (attribute.Unique) { indexedProperties.Add(item.Name, item.GetValue(source)); } else { continue; } if (attribute.AdditionalFields != null && attribute.AdditionalFields.Count > 0) { foreach (string fieldName in attribute.AdditionalFields) { indexedProperties.Add(fieldName, classInfo.GetMember(fieldName).GetValue(source)); } } } } return(indexedProperties); }
void CreateMemberCore(XPClassInfo inputClassInfo, string propertyName, XPMemberInfo xpMemberInfo, bool caseInSensitive) { var dbColumn = ColumnExists(propertyName, caseInSensitive); if (xpMemberInfo != null && dbColumn != null) { var referenceType = xpMemberInfo.ReferenceType; var dbColumnType = dbColumn.ColumnType; if (referenceType == null) { new InputMemberInfo(inputClassInfo, propertyName, dbColumnType, xpMemberInfo.MemberType, !xpMemberInfo.IsPersistent, xpMemberInfo, xpMemberInfo.Attributes); } else if (xpMemberInfo.IsPersistent) { var attributeInfo = (InitialDataAttribute)referenceType.FindAttributeInfo(typeof(InitialDataAttribute)); if (attributeInfo != null) { var classInfo = inputClassInfo.Dictionary.QueryClassInfo(null, attributeInfo.Name ?? referenceType.ClassType.Name); new InputMemberInfo(inputClassInfo, propertyName, classInfo, false, xpMemberInfo, xpMemberInfo.Attributes); } else { new InputMemberInfo(inputClassInfo, propertyName, dbColumnType, xpMemberInfo.ReferenceType.KeyProperty.MemberType, false, xpMemberInfo, xpMemberInfo.Attributes); } } } }
public InputMemberInfo(XPClassInfo owner, string propertyName, XPClassInfo referenceType, bool nonPersistent, XPMemberInfo outputMemberInfo, params Attribute[] attributes) : base(owner, propertyName, referenceType.ClassType, referenceType, nonPersistent, false) { Guard.ArgumentNotNull(outputMemberInfo, "outputMemberInfo"); _outputMemberInfo = outputMemberInfo; AddAttributes(attributes); }
public XPComplexCustomMemberInfo AddSubMember(string propertyName, XPClassInfo referenceType, params Attribute[] attributes) { XPComplexCustomMemberInfo memeberInfo = new XPComplexCustomMemberInfo(this.Owner, propertyName, referenceType, attributes); AddSubMember(memeberInfo); return(memeberInfo); }
static XpandCustomMemberInfo CreateCustomMember(XPClassInfo info, IModelMemberReminderInfo persistent) { var customMemberInfo = info.CreateCustomMember(persistent.Name, persistent.Type, false); ModifyModel(persistent, customMemberInfo); return(customMemberInfo); }
static object PopulateObject(JObject jobject, Session session, XPClassInfo classInfo) { object obj = classInfo.CreateObject(session); PopulateObject(jobject, session, classInfo, obj); return(obj); }
public static List <HelperClassMetadata> LeseMetadata(object obj) { List <HelperClassMetadata> liMetadata = new List <HelperClassMetadata>(); XPClassInfo kundClassInfo = Session.DefaultSession.GetClassInfo(obj); foreach (XPMemberInfo m in kundClassInfo.PersistentProperties) { if (!(m is ServiceField) && m.IsPersistent) { if (!(m.IsKey && m.IsIdentity)) { HelperClassMetadata md = new HelperClassMetadata(); md.Tabelle = m.Owner.TableName; md.Feldname = m.Name; md.IstSchlüsselfeld = m.IsKey ? true : false; md.Feldlänge = m.MappingFieldSize; md.GenerischerDatentyp = m.MemberType.Name; //md.SQLServerDatentyp = ""; //md.Beschreibung = m.???; liMetadata.Add(md); } } } return(liMetadata); }
static XpandCustomMemberInfo CreateMemberInfo(IModelMemberEx modelMemberEx, XPClassInfo xpClassInfo) { var calculatedMember = modelMemberEx as IModelMemberCalculated; if (calculatedMember != null) { return(xpClassInfo.CreateCalculabeMember(calculatedMember.Name, calculatedMember.Type, calculatedMember.AliasExpression)); } var modelMemberOrphanedColection = modelMemberEx as IModelMemberOrphanedColection; if (modelMemberOrphanedColection != null) { return(xpClassInfo.CreateCollection(modelMemberOrphanedColection.Name, modelMemberOrphanedColection.CollectionType.TypeInfo.Type, modelMemberOrphanedColection.Criteria)); } var modelMemberOneToManyCollection = modelMemberEx as IModelMemberOneToManyCollection; if (modelMemberOneToManyCollection != null) { var elementType = modelMemberOneToManyCollection.CollectionType.TypeInfo.Type; var associationAttribute = new AssociationAttribute(modelMemberOneToManyCollection.AssociationName, elementType); var xpandCollectionMemberInfo = xpClassInfo.CreateCollection(modelMemberOneToManyCollection.Name, elementType, null, associationAttribute); modelMemberOneToManyCollection.AssociatedMember.ModelClass.TypeInfo.FindMember(modelMemberOneToManyCollection.AssociatedMember.Name).AddAttribute(associationAttribute); return(xpandCollectionMemberInfo); } var modelMemberModelMember = modelMemberEx as IModelMemberModelMember; if (modelMemberModelMember != null) { var memberInfo = ModelMemberModelMemberDomainLogic.Get_MemberInfo(modelMemberModelMember); return((XpandCustomMemberInfo)xpClassInfo.FindMember(memberInfo.Name)); } return(xpClassInfo.CreateCustomMember(modelMemberEx.Name, modelMemberEx.Type, modelMemberEx is IModelMemberNonPersistent)); }
void AddTableNames(XPClassInfo xpClassInfo, string key) { List<string> list = _tables[key]; list.Add(xpClassInfo.TableName); foreach (var tableName in GetIntermediateTableNames(xpClassInfo).Where(tableName => !list.Contains(tableName))) { list.Add(tableName); } }
static void CreateXpandCustomMemberInfo(IModelMemberEx modelMemberEx, XPObjectSpace objectSpace) { try { Type classType = modelMemberEx.ModelClass.TypeInfo.Type; XPClassInfo xpClassInfo = XpandModuleBase.Dictiorary.GetClassInfo(classType); lock (xpClassInfo) { var customMemberInfo = xpClassInfo.FindMember(modelMemberEx.Name) as XPCustomMemberInfo; if (customMemberInfo == null) { customMemberInfo = CreateMemberInfo(modelMemberEx, xpClassInfo); ((IModelTypesInfoProvider)modelMemberEx.Application).TypesInfo.RefreshInfo(classType); AddAttributes(modelMemberEx, customMemberInfo); } var xpandCustomMemberInfo = customMemberInfo as XpandCustomMemberInfo; if (xpandCustomMemberInfo != null) { CreateColumn(modelMemberEx as IModelMemberPersistent, objectSpace, xpandCustomMemberInfo); CreateForeignKey(modelMemberEx as IModelMemberOneToManyCollection, objectSpace, xpandCustomMemberInfo); UpdateMember(modelMemberEx, customMemberInfo); } } } catch (Exception exception) { throw new Exception( ExceptionLocalizerTemplate <SystemExceptionResourceLocalizer, ExceptionId> .GetExceptionMessage( ExceptionId.ErrorOccursWhileAddingTheCustomProperty, modelMemberEx.MemberInfo.MemberType, ((IModelClass)modelMemberEx.Parent).Name, modelMemberEx.Name, exception.Message)); } }
public void LinkToDataLayout(DataLayoutControl _dataLayout, XPCollection ds) { XPClassInfo _classInfo = ds.ObjectClassInfo; var objectBaseLine = AppListSession.FindObject <UIObjectBase>(CriteriaOperator.Parse("[ObjectName] = ? ", _classInfo.FullName)); if (objectBaseLine == null) { return; } var ControlList = GetControlList(_dataLayout, objectBaseLine); foreach (var c in ControlList) { //Get Label c.Item.Text = c.FieldSettings.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldCaption); c.Item.OptionsToolTip.ToolTip = c.FieldSettings.ChooseValueForCurrentLang(CoreLib.MyEnums.UILabelType.FieldHelp); c.Item.Control.Enabled = !c.FieldSettings.IsDisabled; if (c.FieldSettings.LookupEditor != null) { if (c.Item.Control is LookUpEdit) { LinkListToColumn((LookUpEdit)c.Item.Control, c.FieldSettings.LookupEditor.ObjectType()); } else if (c.Item.Control is SearchLookUpEdit) { LinkListToColumn((SearchLookUpEdit)c.Item.Control, c.FieldSettings.LookupEditor.ObjectType()); } } } }
static XPClassInfo GetClassInfo(this IObjectSpace objectSpace, object currentObject, out XPMemberInfo optimisticLockFieldInfo) { XPClassInfo classInfo = FindObjectXPClassInfo(currentObject, ((XPObjectSpace)objectSpace).Session); optimisticLockFieldInfo = classInfo.OptimisticLockFieldInDataLayer; return(classInfo); }
private Type GetFieldType(DataMap map) { if (map.IsAssociation) { XPClassInfo classInfo = unitOfWork.GetClassInfo(this.Persistent); foreach (var item in classInfo.AssociationListProperties) { if (item is ReflectionPropertyInfo propertyInfo && propertyInfo.Name == map.PropertyName) { if (propertyInfo.IsManyToMany) { return(propertyInfo.CollectionElementType.ClassType); } foreach (var field in propertyInfo.CollectionElementType.PersistentProperties) { if (FieldIsOtherEndOfLinkingTable(field)) { return((field as ReflectionPropertyInfo).MemberType); } } } } } else { var info = unitOfWork.GetClassInfo(this.Persistent); return(info.FindMember(map.PropertyName).MemberType); } return(null); }
private void CreateMappingEntryForEachLinkingTable() { XPClassInfo classInfo = unitOfWork.GetClassInfo(this.Persistent); foreach (var info in classInfo.AssociationListProperties) { if (info is ReflectionPropertyInfo propertyInfo && propertyInfo.CollectionElementType != null) { if (propertyInfo.IsManyToMany) { AddToMap(info, true); continue; } foreach (var field in propertyInfo.CollectionElementType.PersistentProperties) { if (FieldIsOtherEndOfLinkingTable(field)) { AddToMap(info, true); } } } } }
public long GetNextSequence(XPClassInfo classInfo) { if (classInfo == null) { throw new ArgumentNullException("classInfo"); } XPClassInfo ci = classInfo; while (ci.BaseClass != null && ci.BaseClass.IsPersistent) { ci = ci.BaseClass; } CriteriaOperator criteria = CriteriaOperator.Parse("TypeName = ? ", ci.FullName); seq = euow.FindObject <Sequence>(criteria, true); if (seq == null) { throw new InvalidOperationException(string.Format("Sequence for the {0} type was not found.", ci.FullName)); } long nextSequence = seq.NextSequence; seq.NextSequence++; euow.FlushChanges(); return(nextSequence); }
public static bool NeedReload(this IObjectSpace objectSpace, object currentObject) { XPClassInfo classInfo = GetClassInfo(objectSpace, currentObject, out var optimisticLockFieldInfo); Boolean isObjectChangedByAnotherUser = false; if (!objectSpace.IsDisposedObject(currentObject) && !objectSpace.IsNewObject(currentObject) && (optimisticLockFieldInfo != null)) { Object keyPropertyValue = objectSpace.GetKeyValue(currentObject); Object lockFieldValue = optimisticLockFieldInfo.GetValue(currentObject); if (lockFieldValue != null) { if (((XPObjectSpace)objectSpace).Session.FindObject(currentObject.GetType(), new GroupOperator( new BinaryOperator(objectSpace.GetKeyPropertyName(currentObject.GetType()), keyPropertyValue), new BinaryOperator(classInfo.OptimisticLockFieldName, lockFieldValue)), true) == null) { isObjectChangedByAnotherUser = true; } } else { if (((XPObjectSpace)objectSpace).Session.FindObject(currentObject.GetType(), new GroupOperator( new BinaryOperator(objectSpace.GetKeyPropertyName(currentObject.GetType()), keyPropertyValue), new NullOperator(classInfo.OptimisticLockFieldName)), true) == null) { isObjectChangedByAnotherUser = true; } } } return(isObjectChangedByAnotherUser); }
public void LinkListToColumn(DevExpress.XtraGrid.Columns.GridColumn col, Type tableType, string _valueMember = "", string gridFilterString = "") { XPClassInfo classInfo = AppListSession.GetClassInfo(tableType); DataMemberXPCollection = new XPCollection(AppListSession, classInfo); var lookupGrd = new RepositoryItemSearchLookUpEdit(); var lookupGrdView = new GridView(); lookupGrd.BeginInit(); lookupGrdView.BeginInit(); SetupGridView(lookupGrdView, DataMemberXPCollection); lookupGrd.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo) }); lookupGrd.Name = "lookupGrd"; lookupGrd.View = lookupGrdView; lookupGrd.DataSource = DataMemberXPCollection; lookupGrd.DisplayMember = DisplayMember; lookupGrd.ValueMember = string.IsNullOrEmpty(_valueMember) ? ValueMember : _valueMember; //if (_valueMember.IsNotNull()) lookupGrd.KeyMember = _valueMember; col.ColumnEdit = lookupGrd; ActiveColumnLinks.Add(col); RetrieveRows(false); //Tell AppList to get its rows if it the first use }
public XPMemberInfo GetParentMember(XPClassInfo ci) { XPMemberInfo mi = null; parentMembers.TryGetValue(ci, out mi); return(mi); }
public void LinkLookupsToGrid(CoreLib.Grid.MyGridView _gridView, XPClassInfo _classInfo) { var objectBaseLine = AppListSession.FindObject <UIObjectBase>(CriteriaOperator.Parse("[ObjectName] = ? ", _classInfo.FullName)); if (objectBaseLine == null) { return; } foreach (var m in _classInfo.Members.Where(x => !string.IsNullOrEmpty(x.MappingField) || x.FindAttributeInfo("NonPersistentAttribute") == null)) { //if (x.FindAttributeInfo("NonPersistentAttribute") == null) continue; var c = _gridView.Columns.ColumnByFieldName(m.Name) == null? _gridView.Columns.ColumnByFieldName($"{m.Name}!Key") : null; if (c != null) { string fieldName = $"{m.Owner.FullName}.{m.Name}"; var labelLine = objectBaseLine.FindOrCreateUILabel(fieldName); if (labelLine != null && labelLine.LookupEditor != null) { Assembly a = CoreLib.GlobalMethods.GetAssemblyByName(objectBaseLine.AssemblyName); //Type lookupClass = a.GetType(objectBaseLine.ObjectName); Type lookupClass = a.GetType(labelLine.LookupEditor.ObjectName); LinkListToColumn(c, lookupClass); } } } }
bool IsMappedToParent(XPClassInfo xpClassInfo) { var attributeInfo = xpClassInfo.FindAttributeInfo(typeof(MapInheritanceAttribute)); return(attributeInfo != null && ((MapInheritanceAttribute)attributeInfo).MapType == MapInheritanceType.ParentTable); }
// private void createObjectTypeColumn(XPClassInfo xpClassInfo, UnitOfWork unitOfWork) // { // unitOfWork.CreateObjectTypeRecords(xpClassInfo); // var newObject = xpClassInfo.CreateNewObject(unitOfWork); // unitOfWork.CommitChanges(); // unitOfWork.Delete(newObject); // unitOfWork.CommitChanges(); // } private void updateObjectType(UnitOfWork unitOfWork, XPClassInfo xpClassInfo, XPClassInfo mergedXPClassInfo, IDbCommand command) { var propertyName = XPObject.Fields.ObjectType.PropertyName; command.CommandText = "UPDATE [" + getTableName(mergedXPClassInfo) + "] SET " + propertyName + "=" + unitOfWork.GetObjectType(xpClassInfo).Oid + " WHERE " + propertyName + " IS NULL OR " + propertyName + "=" +unitOfWork.GetObjectType(mergedXPClassInfo).Oid; command.ExecuteNonQuery(); }
static void AddRuntimeMembers(IModelApplication model, XPDictionary dictionary) { foreach (IModelRuntimeMember modelRuntimeMember in GetCustomFields(model)) { try { Type classType = modelRuntimeMember.ModelClass.TypeInfo.Type; XPClassInfo typeInfo = dictionary.GetClassInfo(classType); lock (typeInfo) { if (typeInfo.FindMember(modelRuntimeMember.Name) == null) { XpandCustomMemberInfo memberInfo = GetMemberInfo(modelRuntimeMember, typeInfo); AddAttributes(modelRuntimeMember, memberInfo); XafTypesInfo.Instance.RefreshInfo(classType); } } } catch (Exception exception) { throw new Exception( ExceptionLocalizerTemplate <SystemExceptionResourceLocalizer, ExceptionId> .GetExceptionMessage( ExceptionId.ErrorOccursWhileAddingTheCustomProperty, modelRuntimeMember.MemberInfo.MemberType, ((IModelClass)modelRuntimeMember.Parent).Name, modelRuntimeMember.Name, exception.Message)); } } }
public ManyToManyCollectionHelper(IXPSimpleObject owner, XPBaseCollection hiddenCollection, string hiddenCollectionName) { intermediateClassInfo = owner.ClassInfo.GetMember(hiddenCollectionName).IntermediateClass; this.owner = owner; this.hiddenCollection = hiddenCollection; }
static void Main(string[] args) { XpoDefault.DataLayer = new SimpleDataLayer(new DevExpress.Xpo.DB.InMemoryDataStore()); XpoDefault.Session = null; using (UnitOfWork uow = new UnitOfWork()) { uow.ClearDatabase(); TestClass c1 = new TestClass(uow); c1.Name = "aaa"; c1.Email = "*****@*****.**"; TestClass c2 = new TestClass(uow); c2.Name = "bbb"; c2.Email = "*****@*****.**"; c2.Master = c1; uow.CommitChanges(); } XPClassInfo ci = XpoDefault.DataLayer.Dictionary.GetClassInfo(typeof(TestClass)); ci.CreateAliasedMember("DisplayName", typeof(string), "concat([Name],' (',[Email],')',iif([Master] is null,'',Concat(' managed by ',[Master].Name)))"); using (UnitOfWork uow = new UnitOfWork()) { XPCollection <TestClass> xpc = new XPCollection <TestClass>(uow, CriteriaOperator.Parse("Contains([DisplayName],'w3')")); System.Diagnostics.Debug.Assert(xpc.Count == 1); System.Diagnostics.Debug.Assert(xpc[0].Name == "bbb"); XPMemberInfo mi = xpc[0].ClassInfo.FindMember("DisplayName"); System.Diagnostics.Debug.Assert(mi != null && mi.IsReadOnly && mi.IsAliased); System.Diagnostics.Debug.Assert(object.Equals(mi.GetValue(xpc[0]), "bbb ([email protected]) managed by aaa")); } }
public XPMemberInfo GetChildrenMember(XPClassInfo ci) { XPMemberInfo mi = null; childrenMembers.TryGetValue(ci, out mi); return(mi); }
IList CreateCollection(Object parent) { XPBaseCollection collection; if (parent == null) { collection = new XPCollection(session, root); XPMemberInfo parentMemberInfo = hdict.GetParentMember(root); if (parentMemberInfo != null) { collection.Criteria = new NullOperator(new OperandProperty(parentMemberInfo.Name)); } } else { XPClassInfo classInfo = session.GetClassInfo(parent); XPMemberInfo childrenMemberInfo = hdict.GetChildrenMember(classInfo); if (childrenMemberInfo == null) { return(new object[0]); } collection = new XPCollection(session, childrenMemberInfo.CollectionElementType); XPMemberInfo parentMemberInfo = hdict.GetParentMember(childrenMemberInfo.CollectionElementType); System.Diagnostics.Debug.Assert(parentMemberInfo != null); collection.Criteria = new BinaryOperator(new OperandProperty(parentMemberInfo.Name), new OperandValue(parent), BinaryOperatorType.Equal); } /* without a sotring the order of objects might differ */ collection.Sorting.Add(new SortProperty(root.KeyProperty.Name, DevExpress.Xpo.DB.SortingDirection.Ascending)); return(collection); }
IEnumerable<DCPropertyInfo> DCPropertyInfos(XPClassInfo classInfo) { if (classInfo != null){ var xpandCalcMemberInfos = classInfo.OwnMembers.OfType<XpandCustomMemberInfo>(); return xpandCalcMemberInfos.Select(info => DcPropertyInfo(classInfo, info)); } return Enumerable.Empty<DCPropertyInfo>(); }
public static bool IsProrpotyChanged(XPClassInfo ClassInfo, object Obj, string ProportName, out object OldValue) { XPMemberInfo memberInfo = ClassInfo.GetMember(ProportName); OldValue = PersistentBase.GetModificationsStore(Obj).GetPropertyOldValue(memberInfo); return(OldValue != null); }
public void LinkListToColumn(DevExpress.XtraEditors.SearchLookUpEdit col, Type tableType, string gridFilterString = "") { try { XPClassInfo classInfo = AppListSession.GetClassInfo(tableType); DataMemberXPCollection = new XPCollection(AppListSession, classInfo); col.Properties.DataSource = this.DataMemberXPCollection; RetrieveRows(false); col.Properties.View.GridControl.ForceInitialize(); SetupGridView(col.Properties.View, DataMemberXPCollection); col.Properties.ValueMember = ValueMember; col.Properties.DisplayMember = DisplayMember; if (gridFilterString != "") { col.Properties.View.ActiveFilterString = gridFilterString; } } catch (Exception ex) { XtraMessageBox.Show(ex.GetFullExceptionErrMessage()); } }
static XPMemberInfo CreateCollection(this ITypesInfo typeInfo, Type typeToCreateOn, Type typeOfCollection, string associationName, XPDictionary dictionary, string collectionName, bool refreshTypesInfo, bool isManyToMany) { XPMemberInfo member = null; if (TypeIsRegister(typeInfo, typeToCreateOn)) { XPClassInfo xpClassInfo = dictionary.GetClassInfo(typeToCreateOn); member = xpClassInfo.FindMember(collectionName); if (member == null) { member = xpClassInfo.CreateMember(collectionName, typeof(XPCollection), true); member.AddAttribute(new AssociationAttribute(associationName, typeOfCollection) { UseAssociationNameAsIntermediateTableName = isManyToMany }); if (refreshTypesInfo) { typeInfo.RefreshInfo(typeToCreateOn); } } } return(member); }
private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e) { Event suKien = (Event)View.CurrentObject;//Tro vào object hiện tại đang view lên XPClassInfo nguoiDungInfo = suKien.Session.GetClassInfo(typeof(NguoiDung)); NguoiDung nguoiDung = (NguoiDung)suKien.Session.GetObjectByKey(nguoiDungInfo, SecuritySystem.CurrentUserId); NguoiDung nguoiDung1 = suKien.Session.GetObjectByKey <NguoiDung>(SecuritySystem.CurrentUserId); //suKien.ThanhViens.Add(nguoiDung1.thanhVien); AttendedEvent thanhVienThamSuKien = ObjectSpace.CreateObject <AttendedEvent>(); bool checkThamGia = false; thanhVienThamSuKien.thanhVien = nguoiDung1.thanhVien; //thanhVienThamSuKien.thanhVien = nguoiDung1.thanhVien; foreach (AttendedEvent thanh in suKien.attendedEvent) { if (thanh.thanhVien == nguoiDung1.thanhVien) { checkThamGia = true; } } if (checkThamGia == false) { thanhVienThamSuKien.STT = suKien.attendedEvent.Count() + 1; suKien.attendedEvent.Add(thanhVienThamSuKien); } }
public ReflectionDictionary GetDictionary(XPClassInfo xpClassInfo) { string key = GetKey(xpClassInfo); var reflectionDictionary = GetDictionary(key); if (xpClassInfo.IsPersistent) AddTableNames(xpClassInfo, key); return reflectionDictionary; }
string getTableName(XPClassInfo mergedXPClassInfo) { string tableName = mergedXPClassInfo.TableName; while (mergedXPClassInfo.BaseClass != null && mergedXPClassInfo.BaseClass.IsPersistent) { mergedXPClassInfo = mergedXPClassInfo.BaseClass; tableName = mergedXPClassInfo.TableName; } return tableName; }
protected virtual void Synchonize(object persistentPivotOption, Type type, XPClassInfo classInfo) { var gridOptionInstances = GetGridOptionInstance(type); foreach (var gridOptionInstance in gridOptionInstances) { var propertyInfos = gridOptionInstance.GetType().GetProperties().Where(propertyInfo => propertyInfo.GetSetMethod() != null); foreach (var propertyInfo in propertyInfos) { classInfo.GetMember(propertyInfo.Name).SetValue(persistentPivotOption, propertyInfo.GetValue(gridOptionInstance, null)); } } }
public DCPropertyInfo(string name, Type propertyType, XPClassInfo declaringType, bool canRead, bool canWrite, XpandCustomMemberInfo xpandCustomMemberInfo) { _nameCore = name; _propertyTypeCore = propertyType; _declaringTypeCore = declaringType; _canReadCore = canRead; _canWriteCore = canWrite; _xpandCustomMemberInfo = xpandCustomMemberInfo; _attributesCore.AddRange(xpandCustomMemberInfo.Attributes); }
long GetNextSequence(XPClassInfo classInfo, string preFix) { if (classInfo == null) throw new ArgumentNullException("classInfo"); var objectByKey = _explicitUnitOfWork.GetObjectByKey(_sequenceObjectType, preFix + classInfo.FullName, true); _sequence = objectByKey != null ? (ISequenceObject)objectByKey : CreateSequenceObject(preFix + classInfo.FullName, _explicitUnitOfWork); long nextId = _sequence.NextSequence; _sequence.NextSequence++; _explicitUnitOfWork.FlushChanges(); return nextId; }
protected virtual void Synchonize(XPClassInfo classInfo, Type optionType, object currentObject) { var gridOptionInstances = GetGridOptionInstance(optionType); foreach (var gridOptionInstance in gridOptionInstances) { var propertyInfos = gridOptionInstance.GetType().GetProperties().Where(propertyInfo => propertyInfo.GetSetMethod() != null); foreach (var propertyInfo in propertyInfos) { var value = classInfo.GetMember(propertyInfo.Name).GetValue(currentObject); propertyInfo.SetValue(gridOptionInstance, value, null); } } }
static XpandCustomMemberInfo GetMemberInfo(IModelRuntimeMember modelMember, XPClassInfo xpClassInfo) { if (modelMember is IModelRuntimeCalculatedMember) return xpClassInfo.CreateCalculabeMember(modelMember.Name, modelMember.Type, new Attribute[] { new PersistentAliasAttribute(((IModelRuntimeCalculatedMember)modelMember).AliasExpression) }); if (modelMember is IModelRuntimeOrphanedColection) { var modelRuntimeOrphanedColection = ((IModelRuntimeOrphanedColection)modelMember); return xpClassInfo.CreateCollection(modelMember.Name, modelRuntimeOrphanedColection.CollectionType.TypeInfo.Type, modelRuntimeOrphanedColection.Criteria); } return xpClassInfo.CreateCustomMember(modelMember.Name, modelMember.Type, modelMember is IModelRuntimeNonPersistentMember); }
static XpandCustomMemberInfo GetMemberInfo(IModelRuntimeMember modelMember, XPClassInfo xpClassInfo) { var calculatedMember = modelMember as IModelRuntimeCalculatedMember; if (calculatedMember != null) return xpClassInfo.CreateCalculabeMember(calculatedMember.Name, calculatedMember.Type, calculatedMember.AliasExpression); var member = modelMember as IModelRuntimeOrphanedColection; if (member != null) { var modelRuntimeOrphanedColection = member; return xpClassInfo.CreateCollection(member.Name, modelRuntimeOrphanedColection.CollectionType.TypeInfo.Type, modelRuntimeOrphanedColection.Criteria); } return xpClassInfo.CreateCustomMember(modelMember.Name, modelMember.Type, modelMember is IModelRuntimeNonPersistentMember); }
/// <contentfrom cref="ISecurityRule.GetSelectFilterCriteria" /> public bool GetSelectFilterCriteria(DevExpress.Xpo.SecurityContext context, XPClassInfo classInfo, out CriteriaOperator criteria) { List<CriteriaOperator> subList = new List<CriteriaOperator>(); CriteriaOperator subCriteria; foreach (ISecurityRule rule in rules) if (rule.GetSelectFilterCriteria(context, classInfo, out subCriteria)) subList.Add(subCriteria); if (subList.Count == 0) criteria = null; else if (subList.Count == 1) criteria = subList[0]; else criteria = new GroupOperator(GroupOperatorType.And, subList.ToArray()); return subList.Count > 0; }
/// <contentfrom cref="ISecurityRule.GetSelectMemberExpression" /> public bool GetSelectMemberExpression(DevExpress.Xpo.SecurityContext context, XPClassInfo classInfo, XPMemberInfo memberInfo, out CriteriaOperator expression) { CriteriaOperator subExpression; expression = null; foreach (ISecurityRule rule in rules) if (rule.GetSelectMemberExpression(context, classInfo, memberInfo, out subExpression)) { if (ReferenceEquals(expression, null)) expression = subExpression; else if (!CriteriaOperator.CriterionEquals(expression, subExpression)) { expression = new OperandValue(null); return true; } } return !ReferenceEquals(expression, null); }
IEnumerable<XPMemberInfo> ManyToManyMemberInfos(XPClassInfo classInfo) { return classInfo.Members.Where(info => info.IsAssociationList && info.HasAttribute(typeof(InitialDataAttribute))); }
void CreateKey(XPClassInfo classInfo) { if (!HasKey(classInfo)) { classInfo.CreateMember("Oid_" + classInfo.TableName, typeof(int)).AddAttribute(new KeyAttribute(true)); } }
public InputObjectClassInfo(XPDictionary dictionary, string className, XPClassInfo outputClassInfo) : base(dictionary, null, className, GetAttributes()) { Guard.ArgumentNotNull(outputClassInfo, "outputClassInfo"); _outputClassInfo = outputClassInfo; }
void MapManyToMany(XPDictionary outputDictionary, XPDictionary inputDictionary, XPClassInfo classInfo) { foreach (var memberInfo in ManyToManyMemberInfos(classInfo)) { var initialDataAttribute = (InitialDataAttribute)memberInfo.FindAttributeInfo(typeof(InitialDataAttribute)); var className = initialDataAttribute.DataProviderTableName; if (initialDataAttribute.DataProvider && inputDictionary.QueryClassInfo(null, className) == null) { CreateIntermediateClassInfo(outputDictionary, inputDictionary, className, initialDataAttribute, memberInfo); } } }
bool AllOwnMembers(XPClassInfo classInfo) { return ((InitialDataAttribute)classInfo.FindAttributeInfo(typeof(InitialDataAttribute))).AllOwnMembers; }
void CreateAllOwnMembers(XPClassInfo outputClassInfo, XPClassInfo inputClassInfo) { foreach (var memberInfo in MemberInfos(outputClassInfo)) { if (memberInfo.HasAttribute(typeof(InitialDataAttribute))) { CreateMemberFromAttribute(inputClassInfo, memberInfo); } else { CreateMemberCore(inputClassInfo, memberInfo.Name, memberInfo); } } }
public InputMemberInfo(XPClassInfo owner, string propertyName, XPClassInfo referenceType, bool nonPersistent, XPMemberInfo outputMemberInfo, params Attribute[] attributes) : base(owner, propertyName, referenceType.ClassType, referenceType, nonPersistent, false) { Guard.ArgumentNotNull(outputMemberInfo, "outputMemberInfo"); _outputMemberInfo = outputMemberInfo; AddAttributes(attributes); }
void CreateMemberFromAttribute(XPClassInfo classInfo, XPMemberInfo memberInfo) { var initialDataAttribute = (InitialDataAttribute)memberInfo.FindAttributeInfo(typeof(InitialDataAttribute)); if (initialDataAttribute != null) { CreateMemberCore(classInfo, initialDataAttribute.Name ?? memberInfo.Name, memberInfo); } }
Dictionary<string, XPMemberInfo> BaseMemberInfos(XPClassInfo outputClassInfo) { var members = ((InitialDataAttribute)outputClassInfo.FindAttributeInfo(typeof(InitialDataAttribute))).BaseMembers; var xpMemberInfos = new Dictionary<string, XPMemberInfo>(); if (members != null) { var baseMembers = members.Split(','); foreach (var baseMember in baseMembers) { var strings = baseMember.Split('|'); var xpMemberInfo = outputClassInfo.FindMember(strings[0]); xpMemberInfos.Add(strings[strings.Length - 1], xpMemberInfo); } } return xpMemberInfos; }
bool IsMappedToParent(XPClassInfo xpClassInfo) { var attributeInfo = xpClassInfo.FindAttributeInfo(typeof(MapInheritanceAttribute)); return attributeInfo != null && ((MapInheritanceAttribute)attributeInfo).MapType == MapInheritanceType.ParentTable; }
void CreateMemberCore(XPClassInfo inputClassInfo, string propertyName, XPMemberInfo xpMemberInfo) { var dbColumn = ColumnExists(propertyName); if (xpMemberInfo != null && dbColumn != null) { var referenceType = xpMemberInfo.ReferenceType; var dbColumnType = dbColumn.ColumnType; if (referenceType == null) { new InputMemberInfo(inputClassInfo, propertyName, dbColumnType, xpMemberInfo.MemberType, !xpMemberInfo.IsPersistent, xpMemberInfo, xpMemberInfo.Attributes); } else if (xpMemberInfo.IsPersistent) { var attributeInfo = (InitialDataAttribute)referenceType.FindAttributeInfo(typeof(InitialDataAttribute)); if (attributeInfo != null) { var classInfo = inputClassInfo.Dictionary.QueryClassInfo(null, attributeInfo.Name ?? referenceType.ClassType.Name); new InputMemberInfo(inputClassInfo, propertyName, classInfo, !xpMemberInfo.IsPersistent, xpMemberInfo, xpMemberInfo.Attributes); } else { new InputMemberInfo(inputClassInfo, propertyName, dbColumnType, xpMemberInfo.ReferenceType.KeyProperty.MemberType, !xpMemberInfo.IsPersistent, xpMemberInfo, xpMemberInfo.Attributes); } } } }
void CreateBaseMembers(XPClassInfo outputClassInfo, XPClassInfo inputClassInfo) { foreach (var memberInfo in BaseMemberInfos(outputClassInfo)) { var xpMemberInfo = memberInfo.Value; var propertyName = memberInfo.Key; CreateMemberCore(inputClassInfo, propertyName, xpMemberInfo); } }
internal static IEnumerable<XPMemberInfo> MemberInfos(XPClassInfo classInfo) { return classInfo.Members.Where(info => info.IsPersistent && !(info is ServiceField) && !info.IsReadOnly); }
public void Map(XPClassInfo outputClassInfo, XPClassInfo inputClassInfo) { if (!AllOwnMembers(outputClassInfo)) { foreach (var memberInfo in MemberInfos(outputClassInfo)) { CreateMemberFromAttribute(inputClassInfo, memberInfo); } } else { CreateAllOwnMembers(outputClassInfo, inputClassInfo); } CreateBaseMembers(outputClassInfo, inputClassInfo); CreateKey(inputClassInfo); }
public InputMemberInfo(XPClassInfo owner, string propertyName, DBColumnType dbColumnType, Type propertyType, bool nonPersistent, XPMemberInfo outputMemberInfo, params Attribute[] attributes) : base(owner, propertyName, PropertyType(propertyType, dbColumnType), null, nonPersistent, false) { Guard.ArgumentNotNull(outputMemberInfo, "outputMemberInfo"); _outputMemberInfo = outputMemberInfo; _conversionType = propertyType; AddAttributes(attributes); }
public XpandCalcMemberInfo(XPClassInfo owner, string propertyName, Type propertyType, string aliasExpression) : base(owner, propertyName, propertyType, null, true, false,true) { AddAttribute(new PersistentAliasAttribute(aliasExpression)); }
bool HasKey(XPClassInfo classInfo) { XPMemberInfo xpMemberInfo; try { #pragma warning disable 168 xpMemberInfo = classInfo.KeyProperty; #pragma warning restore 168 } catch (KeyPropertyAbsentException) { return false; } return xpMemberInfo != null; }