public async Task Rollback() { while (!ReliableDictionariesInitialized) { await Task.Delay(1000); } try { await IncomingGidToPointItemMap.ClearAsync(); await IncomingAddressToGidMap.ClearAsync(); await ModelChanges.ClearAsync(); string message = $"{baseLogString} Rollback => Incoming SCADA model is rejected."; Logger.LogInformation(message); await LogAllReliableCollections(); } catch (Exception e) { string errorMessage = $"{baseLogString} Rollback => Exception: {e.Message}"; Logger.LogError(errorMessage, e); } }
public async Task Commit() { while (!ReliableDictionariesInitialized) { await Task.Delay(1000); } try { await reliableDictionaryHelper.TryCopyToReliableDictionary <long, IScadaModelPointItem>(ReliableDictionaryNames.IncomingGidToPointItemMap, ReliableDictionaryNames.GidToPointItemMap, this.stateManager); await reliableDictionaryHelper.TryCopyToReliableDictionary <short, Dictionary <ushort, long> >(ReliableDictionaryNames.IncomingAddressToGidMap, ReliableDictionaryNames.AddressToGidMap, this.stateManager); await IncomingGidToPointItemMap.ClearAsync(); await IncomingAddressToGidMap.ClearAsync(); await ModelChanges.ClearAsync(); await CommandDescriptionCache.ClearAsync(); await MeasurementsCache.ClearAsync(); string message = $"{baseLogString} Commit => Incoming SCADA model is confirmed."; Logger.LogInformation(message); await SendModelUpdateCommands(); await LogAllReliableCollections(); } catch (Exception e) { string errorMessage = $"{baseLogString} Commit => Exception: {e.Message}"; Logger.LogError(errorMessage, e); } }