[11911] | 1 | using System; |
---|
| 2 | using System.Collections.Generic; |
---|
| 3 | using Com.Piwigo.Lib.IService; |
---|
| 4 | using Com.Piwigo.Wpf.DTO; |
---|
| 5 | using Com.Piwigo.Lib.DTO; |
---|
| 6 | using Com.Piwigo.Wpf.DTO.Helper; |
---|
| 7 | using Com.Piwigo.Wpf.Helper; |
---|
| 8 | using Com.Piwigo.Wpf.Service; |
---|
| 9 | |
---|
| 10 | namespace Com.Piwigo.Wpf.Command |
---|
| 11 | { |
---|
[11922] | 12 | public sealed class PwgCmdDisconnect : AsyncCommand |
---|
[11911] | 13 | { |
---|
[11922] | 14 | public override string Text { get { return "Disconnect from server"; } } |
---|
| 15 | |
---|
| 16 | protected override void OnExecute(object parameter) |
---|
[11911] | 17 | { |
---|
| 18 | try { |
---|
| 19 | PwgSessionWPF sesWPF = PwgModelManager.Instance.Session; |
---|
| 20 | |
---|
[11922] | 21 | SendUiInfo("Logging out ..."); |
---|
| 22 | |
---|
[11911] | 23 | PwgSession sess = null; |
---|
| 24 | sess = PwgServiceProvider.Instance.PwgSessionService.Logout(); |
---|
| 25 | |
---|
| 26 | PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF); |
---|
[11922] | 27 | |
---|
[12336] | 28 | SendUiInfo("Removing Image and Album ..."); |
---|
[11922] | 29 | if (PwgModelManager.Instance.ImageList != null) |
---|
| 30 | { |
---|
| 31 | PwgModelManager.Instance.ImageList.Clear(); |
---|
| 32 | } |
---|
| 33 | |
---|
[12336] | 34 | if ((PwgModelManager.Instance.AlbumList != null) |
---|
| 35 | && (PwgModelManager.Instance.RootAlbumList != null)) |
---|
[11935] | 36 | { |
---|
[12336] | 37 | PwgModelManager.Instance.RootAlbumList.Childrens.Clear(); |
---|
[11935] | 38 | } |
---|
| 39 | |
---|
[12336] | 40 | if (PwgModelManager.Instance.AlbumList != null) |
---|
[11911] | 41 | { |
---|
[12336] | 42 | PwgModelManager.Instance.AlbumList.Clear(); |
---|
[11911] | 43 | } |
---|
| 44 | |
---|
[11922] | 45 | SendUiInfo("Unset cache data ..."); |
---|
[11911] | 46 | ImageCacheManager.Instance.UnsetCurrentServer(); |
---|
| 47 | } |
---|
| 48 | catch (PwgServiceException ex) |
---|
| 49 | { |
---|
[11922] | 50 | SendUiInfo("Error " + ex.NumeroErr + " " + ex.MessageErr); |
---|
[11911] | 51 | } |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | } |
---|