private static void InformAffectedObjects(List <DependencyInfo> dependenciesInfo, string dependentTypeInfo) { if (dependenciesInfo == null || dependenciesInfo.Count == 0) { // Nothing to do. return; } foreach (var dependencyInfo in dependenciesInfo) { ObjectDto principalObj = OdCepManager.Versioning.GetHeadVersion(dependencyInfo.PrincipalObjectType, dependencyInfo.PrincipalObjectUuid); ObjectDto dependentObj = OdCepManager.Versioning.GetHeadVersion(dependencyInfo.DependentObjectType, dependencyInfo.DependentObjectUuid); dependentObj.VersionIndex++; dependentObj.SuspendNotifications = true; #if USE_ASYNC_FOR_DISPATCH Task <ObjectDto> task = DispatchToObject(dependentObj.OnPrincipalObjectUpdated, principalObj, dependencyInfo.OptionalArg); ObjectDto newDependentObj = task.Result; #else ObjectDto newDependentObj = dependentObj.OnPrincipalObjectUpdated(principalObj, effectInfo.OptionalArg); #endif dependentObj.SuspendNotifications = false; string c = string.Format(LocalConst.AUTO_SAVE_COMMENT_PRINCIPAL_MODF_TEMPLATE, dependentTypeInfo); ObjectStore.AutoSaveExistingObject(newDependentObj, c); } foreach (var dependencyInfo in dependenciesInfo) { ObjectDto objectDto = (ObjectDto)Activator.CreateInstance(dependencyInfo.PrincipalObjectType); InformAllDependents(dependencyInfo.DependentObjectUuid, objectDto.WhoAmI()); } }
public static bool AddObjectDependency(string principalObjUuid, string principalType, string dependentObjUuid, string dependentType, string optionalArg) { bool success = _persistentObj.AddObjectDependency(principalObjUuid, dependentObjUuid, principalType, dependentType, optionalArg); ObjectDto principalObj = OdCepManager.Versioning.GetHeadVersion(Type.GetType(principalType), principalObjUuid, out string comment); ObjectDto dependentObj = OdCepManager.Versioning.GetHeadVersion(Type.GetType(dependentType), dependentObjUuid, out comment); ObjectDto updatedObj = dependentObj.OnPrincipalObjectUpdated(principalObj, optionalArg); updatedObj.VersionIndex++; string c = string.Format(LocalConst.AUTO_SAVE_COMMENT_PRINCIPAL_MODF_TEMPLATE, principalObj.WhoAmI()); ObjectStore.AutoSaveExistingObject(updatedObj, c); return(success); }