Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Коррекция порядка обработки свойств для объекта с детейлом и мастером одного типа #259

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Removed

### Fixed
1. Fixed order of property processing for objects with details and masters of the same type.

### Security

Expand Down
80 changes: 47 additions & 33 deletions ICSSoft.STORMNET.Business/SQLDataService/SQLDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4171,57 +4171,71 @@ private void GetDependencies(DataObject currentObject, Type currentType, Diction
ObjectStatus? objectStatus = currentObject?.GetStatus();

// Смотрим мастера и детейлы для выявления зависимостей.
// Порядок важен. Сначала мастера, потом детейлы.
Anisimova2020 marked this conversation as resolved.
Show resolved Hide resolved
List<string> details = new List<string>();
Dictionary<string, Type> masters = new Dictionary<string, Type>();
foreach (string prop in props)
{
Type propType = Information.GetPropertyType(currentType, prop);
if (propType.IsSubclassOf(typeof(DetailArray)))
{
// Обрабатываем детейлы.
Type[] types = Information.GetCompatibleTypesForDetailProperty(currentType, prop);
foreach (Type type in types)
details.Add(prop);
}
else if (propType.IsSubclassOf(typeof(DataObject)))
{
masters.Add(prop, propType);
}
}

foreach (string detailCurrent in details)
{
// Обрабатываем детейлы.
Type[] types = Information.GetCompatibleTypesForDetailProperty(currentType, detailCurrent);
foreach (Type type in types)
{
// Если этот детейл еще не обходили.
if (!dependencies.ContainsKey(type))
{
// Если этот детейл еще не обходили.
if (!dependencies.ContainsKey(type))
{
AddDependencies(type, currentType, dependencies);
AddDependencies(type, currentType, dependencies);

// Для детейлов доформируем зависимости.
GetDependencies(null, type, dependencies, extraUpdateList);
}
// Для детейлов доформируем зависимости.
GetDependencies(null, type, dependencies, extraUpdateList);
}
}

if (objectStatus == ObjectStatus.Deleted)
if (objectStatus == ObjectStatus.Deleted)
{
foreach (DataObject detail in (DetailArray)Information.GetPropValueByName(currentObject, detailCurrent))
{
foreach (DataObject detail in (DetailArray)Information.GetPropValueByName(currentObject, prop))
if (detail.ContainsAlteredProps())
{
if (detail.ContainsAlteredProps())
{
extraUpdateList.Add(detail);
}
extraUpdateList.Add(detail);
}
}
}
else if (propType.IsSubclassOf(typeof(DataObject)))
}

foreach (string masterCurrent in masters.Keys)
{
// Проверяем, есть ли детейловое свойство с таким-же типом.
Type propType = masters[masterCurrent];
string detailProp = Information.GetDetailArrayPropertyName(currentType, propType);
if (detailProp == null || (currentObject != null && Information.GetPropValueByName(currentObject, masterCurrent) != null))
{
// Проверяем, есть ли детейловое свойство с таким-же типом.
string detailProp = Information.GetDetailArrayPropertyName(currentType, propType);
if (detailProp == null || (currentObject != null && Information.GetPropValueByName(currentObject, prop) != null))
{
// Обрабатываем мастера.
AddDependencies(currentType, propType, dependencies);
// Обрабатываем мастера.
AddDependencies(currentType, propType, dependencies);

// Обрабатываем наследников мастера.
Type[] propertyTypes = TypeUsageProvider.TypeUsage.GetUsageTypes(currentType, prop);
foreach (Type type in propertyTypes)
{
AddDependencies(currentType, type, dependencies);
}
}
else if (objectStatus == ObjectStatus.Deleted && currentObject.ContainsAlteredProps())
// Обрабатываем наследников мастера.
Type[] propertyTypes = TypeUsageProvider.TypeUsage.GetUsageTypes(currentType, masterCurrent);
foreach (Type type in propertyTypes)
{
extraUpdateList.Add(currentObject);
AddDependencies(currentType, type, dependencies);
}
}
else if (objectStatus == ObjectStatus.Deleted && currentObject.ContainsAlteredProps())
{
extraUpdateList.Add(currentObject);
}
}
}

Expand Down Expand Up @@ -4760,7 +4774,7 @@ public virtual void GenerateQueriesForUpdateObjects(

foreach (DataObject processingObject in processingObjects)
{
// Включем текущий объект в граф зависимостей.
// Включим текущий объект в граф зависимостей.
GetDependencies(processingObject, processingObject.GetType(), dependencies, extraUpdateList);
}

Expand Down
10 changes: 5 additions & 5 deletions NewPlatform.Flexberry.ORM.MSSQLDataService.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM.MSSQLDataService</id>
<version>7.1.1</version>
<version>7.2.0-beta01</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -13,18 +13,18 @@
<description>Flexberry ORM package.</description>
<releaseNotes>
Fixed
1. Error on loading with not stored attribute with inheritance.
1. Fixed order of property processing for objects with details and masters of the same type.
Changed
1. Updated NewPlatform.Flexberry.ORM up to 7.1.1.
1. Updated NewPlatform.Flexberry.ORM up to 7.2.0-beta01.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2023</copyright>
<tags>Flexberry ORM</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="NewPlatform.Flexberry.ORM" version="7.1.1" />
<dependency id="NewPlatform.Flexberry.ORM" version="7.2.0-beta01" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="NewPlatform.Flexberry.ORM" version="7.1.1" />
<dependency id="NewPlatform.Flexberry.ORM" version="7.2.0-beta01" />
<dependency id="System.Data.SqlClient" version="4.6.1" />
</group>
</dependencies>
Expand Down
10 changes: 5 additions & 5 deletions NewPlatform.Flexberry.ORM.OracleDataService.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM.OracleDataService</id>
<version>7.1.1</version>
<version>7.2.0-beta01</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -13,19 +13,19 @@
<description>Flexberry ORM package.</description>
<releaseNotes>
Fixed
1. Error on loading with not stored attribute with inheritance.
1. Fixed order of property processing for objects with details and masters of the same type.
Changed
1. Updated NewPlatform.Flexberry.ORM up to 7.1.1.
1. Updated NewPlatform.Flexberry.ORM up to 7.2.0-beta01.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2023</copyright>
<tags>Flexberry ORM</tags>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="NewPlatform.Flexberry.ORM" version="7.1.1" />
<dependency id="NewPlatform.Flexberry.ORM" version="7.2.0-beta01" />
<dependency id="Oracle.ManagedDataAccess" version="12.1.22" />
</group>
<group targetFramework=".NETStandard2.0">
<dependency id="NewPlatform.Flexberry.ORM" version="7.1.1" />
<dependency id="NewPlatform.Flexberry.ORM" version="7.2.0-beta01" />
<dependency id="Oracle.ManagedDataAccess.Core" version="2.19.3" />
</group>
</dependencies>
Expand Down
8 changes: 4 additions & 4 deletions NewPlatform.Flexberry.ORM.PostgresDataService.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM.PostgresDataService</id>
<version>7.1.1</version>
<version>7.2.0-beta01</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -13,14 +13,14 @@
<description>Flexberry ORM package.</description>
<releaseNotes>
Fixed
1. Error on loading with not stored attribute with inheritance.
1. Fixed order of property processing for objects with details and masters of the same type.
Changed
1. Updated NewPlatform.Flexberry.ORM up to 7.1.1.
1. Updated NewPlatform.Flexberry.ORM up to 7.2.0-beta01.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2023</copyright>
<tags>Flexberry ORM</tags>
<dependencies>
<dependency id="NewPlatform.Flexberry.ORM" version="7.1.1" />
<dependency id="NewPlatform.Flexberry.ORM" version="7.2.0-beta01" />
<dependency id="Npgsql" version="3.2.7" />
</dependencies>
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions NewPlatform.Flexberry.ORM.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>NewPlatform.Flexberry.ORM</id>
<version>7.1.1</version>
<version>7.2.0-beta01</version>
<title>Flexberry ORM</title>
<authors>New Platform Ltd</authors>
<owners>New Platform Ltd</owners>
Expand All @@ -13,7 +13,7 @@
<description>Flexberry ORM package.</description>
<releaseNotes>
Fixed
1. Error on loading with not stored attribute with inheritance.
1. Fixed order of property processing for objects with details and masters of the same type.
</releaseNotes>
<copyright>Copyright New Platform Ltd 2023</copyright>
<tags>Flexberry ORM</tags>
Expand Down
Loading