示例#1
0
 public void Remove(ISection section, Action <OnCompleteEventArgs> onComplete)
 {
     if (!IsOpened)
     {
         _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, "Сперва необходимо открыть репозиторий!")));
     }
     else
     {
         _backWorker.AddWork(
             () => {
             try {
                 var devInfosToRemove = _deviceInformationStorage.DeviceInformations.Where(di => di.Id.ToString() == section.DeviceInformationId.ToString()).ToList();
                 foreach (var devInfo in devInfosToRemove)
                 {
                     IDeviceInformation info = devInfo;                                     // for closure
                     var idsToRemove         = _psnDataInformtationStorage.PsnDataInformations.Where(pdi => pdi.DeviceInformationId == info.Id).Select(pdi => pdi.Id).ToList();
                     foreach (var idToRemove in idsToRemove)
                     {
                         _psnDataStorage.Remove(idToRemove);
                         _psnDataInformtationStorage.Remove(idToRemove);
                         _psnDataCustomConfigurationsStorage.Remove(idToRemove);
                     }
                     // TODO: remove RPD logs
                     _deviceInformationStorage.Remove(devInfo.Id);
                 }
                 UpdateLocomotivesIfDeletedUnsafe();
                 _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Ok, "Секция удалена из репозитория")));
             }
             catch (Exception ex) {
                 _uiNotifier.Notify(() => onComplete(new OnCompleteEventArgs(OnCompleteEventArgs.CompleteResult.Error, ex.ToString())));
             }
         });
     }
 }
示例#2
0
        public void Remove(IIdentifier id)
        {
            _relayOnStorage.Remove(id);
            var devInfosToRemove = _deviceInformations.Where(di => di.Id.IdentyString == id.IdentyString).ToList();

            foreach (var deviceInformation in devInfosToRemove)
            {
                _deviceInformations.Remove(deviceInformation);
            }
        }
示例#3
0
        private static void ClearStorage(IPsnDataStorage storage, IDeviceInformationStorage devstorage)
        {
            var logs = storage.PsnDatas.ToList();

            foreach (var psnLog in logs)
            {
                storage.Remove(psnLog.Id);
                Log("Лог удален из хранилища");
            }

            var devInfos = devstorage.DeviceInformations.ToList();

            foreach (var deviceInformation in devInfos)
            {
                devstorage.Remove(deviceInformation.Id);
                Log("Информация об устройстве удалена из хранилища");
            }
        }