Exemplo n.º 1
0
 protected virtual void OnPoolChanged(PoolEvent evt)
 {
     if (this.PoolChanged != null)
     {
         this.PoolChanged(this, evt);
     }
 }
Exemplo n.º 2
0
        protected override void UpdateController(Controller controller)
        {
            UpdateCompletedEvent updateCompletedEvent = new UpdateCompletedEvent();
            SpacesController     spacesController     = new SpacesController(((SpacesController)controller).Id);
            StorApiStatus        storApiStatus        = spacesController.Update();

            if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR)
            {
                updateCompletedEvent.updateStatus = storApiStatus;
                updateCompletedEvent.controller   = controller;
                this.OnUpdateCompleted(updateCompletedEvent);
                return;
            }
            ListComparer <Drive> listComparer = new ListComparer <Drive>();

            listComparer.Compare(controller.Drives, spacesController.Drives, new Func <Drive, Drive, bool>(SpacesDrive.CompareAndPreserve));
            ListComparer <Volume> listComparer2 = new ListComparer <Volume>();

            listComparer2.Compare(controller.Volumes, spacesController.Volumes, new Func <Volume, Volume, bool>(SpacesVolume.CompareInfo));
            ListComparer <SpacesPool> listComparer3 = new ListComparer <SpacesPool>();

            listComparer3.Compare(((SpacesController)controller).Pools, spacesController.Pools, new Func <SpacesPool, SpacesPool, bool>(SpacesPool.CompareInfo));
            controller.Drives  = spacesController.Drives;
            controller.Volumes = spacesController.Volumes;
            ((SpacesController)controller).Pools = spacesController.Pools;
            if (listComparer.AnythingChanged)
            {
                listComparer.removedItems.ForEach(delegate(ListComparer <Drive> .ItemData d)
                {
                    DriveEvent driveEvent = new DriveEvent();
                    driveEvent.controller = controller;
                    driveEvent.drive      = d.newItem;
                    driveEvent.oldDrive   = d.oldItem;
                    driveEvent.type       = ControllerEventType.EVENT_TYPE_REMOVED;
                    this.OnDriveChanged(driveEvent);
                });
                listComparer.changedItems.ForEach(delegate(ListComparer <Drive> .ItemData d)
                {
                    DriveEvent driveEvent = new DriveEvent();
                    driveEvent.controller = controller;
                    driveEvent.drive      = d.newItem;
                    driveEvent.oldDrive   = d.oldItem;
                    driveEvent.type       = ControllerEventType.EVENT_TYPE_CHANGED;
                    this.OnDriveChanged(driveEvent);
                });
                listComparer.addedItems.ForEach(delegate(ListComparer <Drive> .ItemData d)
                {
                    DriveEvent driveEvent = new DriveEvent();
                    driveEvent.controller = controller;
                    driveEvent.drive      = d.newItem;
                    driveEvent.oldDrive   = d.oldItem;
                    driveEvent.type       = ControllerEventType.EVENT_TYPE_ADDED;
                    this.OnDriveChanged(driveEvent);
                });
            }
            if (listComparer2.AnythingChanged)
            {
                listComparer2.removedItems.ForEach(delegate(ListComparer <Volume> .ItemData d)
                {
                    VolumeEvent volumeEvent = new VolumeEvent();
                    volumeEvent.controller  = controller;
                    volumeEvent.volume      = d.newItem;
                    volumeEvent.oldVolume   = d.oldItem;
                    volumeEvent.type        = ControllerEventType.EVENT_TYPE_REMOVED;
                    this.OnVolumeChanged(volumeEvent);
                });
                listComparer2.changedItems.ForEach(delegate(ListComparer <Volume> .ItemData d)
                {
                    VolumeEvent volumeEvent = new VolumeEvent();
                    volumeEvent.controller  = controller;
                    volumeEvent.volume      = d.newItem;
                    volumeEvent.oldVolume   = d.oldItem;
                    volumeEvent.type        = ControllerEventType.EVENT_TYPE_CHANGED;
                    this.OnVolumeChanged(volumeEvent);
                });
                listComparer2.addedItems.ForEach(delegate(ListComparer <Volume> .ItemData d)
                {
                    VolumeEvent volumeEvent = new VolumeEvent();
                    volumeEvent.controller  = controller;
                    volumeEvent.volume      = d.newItem;
                    volumeEvent.oldVolume   = d.oldItem;
                    volumeEvent.type        = ControllerEventType.EVENT_TYPE_ADDED;
                    this.OnVolumeChanged(volumeEvent);
                });
            }
            if (listComparer3.AnythingChanged)
            {
                listComparer3.removedItems.ForEach(delegate(ListComparer <SpacesPool> .ItemData d)
                {
                    PoolEvent poolEvent  = new PoolEvent();
                    poolEvent.controller = controller;
                    poolEvent.pool       = d.newItem;
                    poolEvent.oldPool    = d.oldItem;
                    poolEvent.type       = ControllerEventType.EVENT_TYPE_REMOVED;
                    this.OnPoolChanged(poolEvent);
                });
                listComparer3.changedItems.ForEach(delegate(ListComparer <SpacesPool> .ItemData d)
                {
                    PoolEvent poolEvent  = new PoolEvent();
                    poolEvent.controller = controller;
                    poolEvent.pool       = d.newItem;
                    poolEvent.oldPool    = d.oldItem;
                    poolEvent.type       = ControllerEventType.EVENT_TYPE_CHANGED;
                    this.OnPoolChanged(poolEvent);
                });
                listComparer3.addedItems.ForEach(delegate(ListComparer <SpacesPool> .ItemData d)
                {
                    PoolEvent poolEvent  = new PoolEvent();
                    poolEvent.controller = controller;
                    poolEvent.pool       = d.newItem;
                    poolEvent.oldPool    = d.oldItem;
                    poolEvent.type       = ControllerEventType.EVENT_TYPE_ADDED;
                    this.OnPoolChanged(poolEvent);
                });
            }
            updateCompletedEvent.updateStatus = StorApiStatusEnum.STOR_NO_ERROR;
            updateCompletedEvent.controller   = controller;
            this.OnUpdateCompleted(updateCompletedEvent);
        }