//***************************************************************************// // Legenerálja a megadott entitás általános szekcióját // //***************************************************************************// template GenerateGeneralSection(MClass) #region General private [MClass.name]DA m_DA = new [MClass.name]DA(); protected static [MClass.name] Fake[MClass.name] { get; set; } [if (IsMasterEntity([MClass]) == "true")] public static [MClass.name] GiveAnInstance() [else] public static new [MClass.name] GiveAnInstance() [end if] { [MClass.name] result = Fake[MClass.name] == null ? new [MClass.name]() : ([MClass.name])Fake[MClass.name].MemberwiseClone(); result.Reset(); result.SetDefaultData(); return result; } [if (IsMasterEntity([MClass]) == "true")] protected void SetDefaultData() [else] protected new void SetDefaultData() [end if] { [if (HasIntezmeny([MClass]) == "true" || HasSubIntezmeny([MClass]) == "true")] if (UserContext.Instance != null) { if (UserContext.Instance.IntezmenyId > 0) { [if (HasIntezmeny([MClass]) == "true")] IntezmenyId = UserContext.Instance.IntezmenyId; [end if] [if(HasSubIntezmeny([MClass]) == "true")] AlIntezmenyId = UserContext.Instance.IntezmenyId; [end if] } [if (HasTanev([MClass]) == "true" || HasSubTanev([MClass]) == "true")] if (UserContext.Instance.AktivTanevId > 0) { [if (HasTanev([MClass]) == "true")] TanevId = UserContext.Instance.AktivTanevId; [end if] [if(HasSubTanev([MClass]) == "true")] AlTanevId = UserContext.Instance.AktivTanevId; [end if] } [end if] m_State = EntityState.Uninitialized; } [end if] } protected override IEntityDataAccessor GetDataAccessor() { return m_DA; } [if (IsMasterEntity([MClass]) == "true")] protected internal virtual IEntityDataAccessor InheritedDA { get { return null; } } [else] protected internal new IEntityDataAccessor InheritedDA { get { return base.GetDataAccessor(); } } [end if] \[Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")\] [if (IsMasterEntity([MClass]) == "true")] public static IEntityCollection<[MClass.name]> LoadAll() [else] public static new IEntityCollection<[MClass.name]> LoadAll() [end if] { return LoadWithFilter(""); } \[Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")\] [if (IsMasterEntity([MClass]) == "true")] public static IEntityCollection<[MClass.name]> LoadAll(ColumnFilterMode columnFilterMode, IEnumerable columns) [else] public static new IEntityCollection<[MClass.name]> LoadAll(ColumnFilterMode columnFilterMode, IEnumerable columns) [end if] { return LoadWithFilter("", columnFilterMode, columns); } \[Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")\] [if (IsMasterEntity([MClass]) == "true")] public static IEntityCollection<[MClass.name]> LoadWithFilter(string filter, Dictionary commandParameters = null) [else] public static new IEntityCollection<[MClass.name]> LoadWithFilter(string filter, Dictionary commandParameters = null) [end if] { var result = new EntityCollection<[MClass.name]>(); new [MClass.name]DA().LoadWithFilter(result, filter, commandParameters); return result; } \[Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")\] [if (IsMasterEntity([MClass]) == "true")] public static IEntityCollection<[MClass.name]> LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) [else] public static new IEntityCollection<[MClass.name]> LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) [end if] { var result = new EntityCollection<[MClass.name]>(); new [MClass.name]DA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters); return result; } protected override void StoreOriginalValues() { base.StoreOriginalValues(); [loop (MClass -> MAttribute as ATTRIBUTE)] [if (IsAttributeLoggable([ATTRIBUTE]) == "true")] [if (IsAttributeRequired([ATTRIBUTE]) == _True())] OriginalValues.Add("[ATTRIBUTE.name]", (object)m_[ATTRIBUTE.name]); [else] OriginalValues.Add("[ATTRIBUTE.name]", ([ATTRIBUTE.name] == null ? (object)DBNull.Value : (object)m_[ATTRIBUTE.name])); [end if] [else] // [ATTRIBUTE.name] ([ATTRIBUTE.type]) nem naplózandó attribútum, mert túl hosszú ([GetAttributeLength([ATTRIBUTE])]) [end if] [end loop] [loop (MClass -> Role as STARTROLE -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as PARTNERCLASS where (([STARTROLE.id] != [ENDROLE.id]) and GetStereoType([PARTNERCLASS]) == "Entity"))] [if (HasAssociationClass([CURRENTASSOCIATION]) == "")] [if ([ENDROLE.multiplicity] == "1" or [ENDROLE.multiplicity] == "0..1")] [if (([PARTNERCLASS.name] != [MClass.name]) or ([PARTNERCLASS.name] == [MClass.name] and [MClass.name] != DefineRoleName([ENDROLE])))] OriginalValues.Add("[ConvertRoleToName([ENDROLE])]", (m_[ConvertRoleToName([ENDROLE])] < 0 ? (object)DBNull.Value : (object)m_[ConvertRoleToName([ENDROLE])])); [end if] [end if] [end if] [end loop] [loop (MClass -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as STARTROLE -> MClass as STARTCLASS where (GetStereoType([STARTCLASS]) == "Entity"))] [loop (CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as ENDCLASS where([STARTROLE.id] < [ENDROLE.id] and GetStereoType([ENDCLASS]) == "Entity" ))] OriginalValues.Add("[ConvertRoleToName([STARTROLE])]", m_[ConvertRoleToName([STARTROLE])]); OriginalValues.Add("[ConvertRoleToName([ENDROLE])]", m_[ConvertRoleToName([ENDROLE])]); [end loop] [end loop] } #endregion end template //***************************************************************************// // Visszaadja egy attribútumról, hogy a megváltozása naplózandó-e, vagy sem. // // true, ha naplózni kell a változását; egyébként false. // //***************************************************************************// proc IsAttributeLoggable(MAttribute) if ([MAttribute.type] == "Binary") return "false"; end if local temp; [temp] = GetTaggedValue([MAttribute], "history"); if ([temp] != "") return ToLower([temp]); end if // if ([MAttribute.type] == "LongString") // return "false"; // end if // // if ([MAttribute.type] == "String" and GetAttributeLength([MAttribute]) > 200) // return "false"; // end if return "true"; end proc proc HasIntezmeny(MClass) local HasIntezmeny = "false"; loop (MClass->Role as StartRole ->MAssociation as CurentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id]!=[EndRole.id]) and GetStereoType([PartnerClass]) == "Entity")) if([PartnerClass.name] == "Intezmeny") [HasIntezmeny] = "true"; end if end loop if([MClass.name] == "Fenntarto" || [MClass.name] == "MobilDbInfo") [HasIntezmeny] = "false"; end if return [HasIntezmeny]; end proc proc HasSubIntezmeny(MClass) local HasIntezmeny = "false"; loop (MClass->Role as StartRole ->MAssociation as CurentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id]!=[EndRole.id]) and GetStereoType([PartnerClass]) == "Entity")) if([PartnerClass.name] == "Intezmeny" && [EndRole.name] == [StartRole.name] "AlIntezmeny") [HasIntezmeny] = "true"; end if end loop return [HasIntezmeny]; end proc proc HasTanev(MClass) local HasTanev = "false"; loop (MClass->Role as StartRole ->MAssociation as CurentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id]!=[EndRole.id]) and GetStereoType([PartnerClass]) == "Entity")) if([PartnerClass.name] == "Tanev") [HasTanev] = "true"; end if end loop if([MClass.name] == "MobilDbInfo") [HasTanev] = "false"; end if return [HasTanev]; end proc proc HasSubTanev(MClass) local HasTanev = "false"; loop (MClass->Role as StartRole ->MAssociation as CurentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id]!=[EndRole.id]) and GetStereoType([PartnerClass]) == "Entity")) if([PartnerClass.name] == "Tanev" && [EndRole.name] == [StartRole.name] "AlTanev") [HasTanev] = "true"; end if end loop return [HasTanev]; end proc