@@ -1302,6 +1302,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1302
1302
1303
1303
// Parent
1304
1304
var profileTypes = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace && pt . Parent . Profile == existingProfile ) . ToList ( ) ;
1305
+ _logger . Info ( $ "Upgrade Info || Parent || profileTypes count: { profileTypes . Count ( ) } ") ;
1305
1306
foreach ( var profileType in profileTypes )
1306
1307
{
1307
1308
var newParent = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == profileType . Parent . OpcNodeId ) ;
@@ -1315,6 +1316,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1315
1316
1316
1317
// InstanceParent
1317
1318
profileTypes = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace && pt . InstanceParent . Profile == existingProfile ) . ToList ( ) ;
1319
+ _logger . Info ( $ "Upgrade Info || Instance Parent || profileTypes count: { profileTypes . Count ( ) } ") ;
1318
1320
foreach ( var profileType in profileTypes )
1319
1321
{
1320
1322
var newInstanceParent = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == profileType . InstanceParent . OpcNodeId ) ;
@@ -1328,6 +1330,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1328
1330
1329
1331
// VariableDataTypeId
1330
1332
profileTypes = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace && pt . VariableDataType . Profile == existingProfile ) . ToList ( ) ;
1333
+ _logger . Info ( $ "Upgrade Info || Variable Data Type || profileTypes count: { profileTypes . Count ( ) } ") ;
1331
1334
foreach ( var profileType in profileTypes )
1332
1335
{
1333
1336
var newVariableType = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == profileType . VariableDataType . OpcNodeId ) ;
@@ -1344,6 +1347,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1344
1347
// data type id
1345
1348
var attributes = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace )
1346
1349
. SelectMany ( pt => pt . Attributes ) . Where ( a => a . DataType . CustomType . Profile == existingProfile ) . ToList ( ) ;
1350
+ _logger . Info ( $ "Upgrade Info || Profile Attributes || count: { attributes . Count ( ) } ") ;
1347
1351
foreach ( var attribute in attributes )
1348
1352
{
1349
1353
var newCustomDataType = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == attribute . DataType . CustomType . OpcNodeId ) ;
@@ -1359,6 +1363,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1359
1363
// variable type definition id
1360
1364
attributes = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace )
1361
1365
. SelectMany ( pt => pt . Attributes ) . Where ( a => a . VariableTypeDefinition . Profile == existingProfile ) . ToList ( ) ;
1366
+ _logger . Info ( $ "Upgrade Info || Variable Type Definition Attributes || count: { attributes . Count ( ) } ") ;
1362
1367
foreach ( var attribute in attributes )
1363
1368
{
1364
1369
var newVariableType = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == attribute . VariableTypeDefinition . OpcNodeId ) ;
@@ -1374,6 +1379,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1374
1379
// composition
1375
1380
var compositions = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace )
1376
1381
. SelectMany ( pt => pt . Compositions ) . Where ( c => c . Composition . Profile == existingProfile ) . ToList ( ) ;
1382
+ _logger . Info ( $ "Upgrade Info || Compositions || count: { compositions . Count ( ) } ") ;
1377
1383
foreach ( var composition in compositions )
1378
1384
{
1379
1385
var newComposition = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == composition . Composition . OpcNodeId ) ;
@@ -1390,6 +1396,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1390
1396
// interface_id
1391
1397
var interfaces = _repo . GetAll ( ) . Where ( pt => pt . Profile . Namespace != existingProfile . Namespace )
1392
1398
. SelectMany ( pt => pt . Interfaces ) . Where ( itf => itf . Interface . Profile == existingProfile ) . ToList ( ) ;
1399
+ _logger . Info ( $ "Upgrade Info || Interfaces || count: { interfaces . Count ( ) } ") ;
1393
1400
foreach ( var itf in interfaces )
1394
1401
{
1395
1402
var newInterface = _repo . GetAll ( ) . FirstOrDefault ( pt => pt . Profile == profile && pt . OpcNodeId == itf . Interface . OpcNodeId ) ;
@@ -1404,6 +1411,7 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1404
1411
// Move over user analytics
1405
1412
{
1406
1413
var ptAnalyticsRecords = ptAnalyticsRepo . GetAll ( ) . Where ( pta => pta . ProfileTypeDefinition . Profile == existingProfile ) . ToList ( ) ;
1414
+ _logger . Info ( $ "Upgrade Info || Analytics || count: { ptAnalyticsRecords . Count ( ) } ") ;
1407
1415
foreach ( var ptAnalyticsRecord in ptAnalyticsRecords )
1408
1416
{
1409
1417
var ptaNew = ptAnalyticsRepo . GetAll ( ) . Where ( pta => pta . ProfileTypeDefinition . Profile == profile && pta . ProfileTypeDefinition . OpcNodeId == ptAnalyticsRecord . ProfileTypeDefinition . OpcNodeId ) . FirstOrDefault ( ) ;
@@ -1423,17 +1431,22 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1423
1431
// Move over user favorites
1424
1432
{
1425
1433
var ptFavoritesRecords = ptFavoritesRepo . GetAll ( ) . Where ( pta => pta . ProfileTypeDefinition . Profile == existingProfile ) . ToList ( ) ;
1434
+ _logger . Info ( $ "Upgrade Info || Favorites || count: { ptFavoritesRecords . Count ( ) } ") ;
1426
1435
foreach ( var ptFavoritesRecord in ptFavoritesRecords )
1427
1436
{
1428
1437
var ptfNew = ptFavoritesRepo . GetAll ( ) . Where ( pta => pta . ProfileTypeDefinition . Profile == profile && pta . ProfileTypeDefinition . OpcNodeId == ptFavoritesRecord . ProfileTypeDefinition . OpcNodeId ) . FirstOrDefault ( ) ;
1429
- ptfNew . IsFavorite = ptFavoritesRecord . IsFavorite ;
1430
- ptFavoritesRepo . Update ( ptfNew ) ;
1438
+ if ( ptfNew != null )
1439
+ {
1440
+ ptfNew . IsFavorite = ptFavoritesRecord . IsFavorite ;
1441
+ ptFavoritesRepo . Update ( ptfNew ) ;
1442
+ }
1431
1443
}
1432
1444
}
1433
1445
// Move over data type rank
1434
1446
// TODO actually migrate this: it is currently just a read-only view at the Repo/EF level so the Add/Update calls are commented out
1435
1447
{
1436
1448
var allDataTypeRanks = dtRankRepo . GetAll ( ) . ToList ( ) ;
1449
+ _logger . Info ( $ "Upgrade Info || Data Type Rank || count: { allDataTypeRanks . Count ( ) } ") ;
1437
1450
foreach ( var dtRank in allDataTypeRanks )
1438
1451
{
1439
1452
if ( dtRank . CustomTypeId == null )
@@ -1481,8 +1494,11 @@ public async Task UpgradeToProfileAsync(ProfileModel profileModel,
1481
1494
}
1482
1495
}
1483
1496
1497
+ _logger . Info ( $ "Upgrade Info || SaveChangesAsync...start") ;
1484
1498
await _repo . SaveChangesAsync ( ) ;
1499
+ _logger . Info ( $ "Upgrade Info || SaveChangesAsync...complete") ;
1485
1500
await _repo . CommitTransactionAsync ( ) ;
1501
+ _logger . Info ( $ "Upgrade Info || CommitTransactionAsync...complete") ;
1486
1502
}
1487
1503
if ( deleteUpgradedProfiles )
1488
1504
{
0 commit comments