Ignore:
Timestamp:
Oct 11, 2010, 8:04:34 PM (14 years ago)
Author:
bayral
Message:

Connection à partir de wpf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdConnect.cs

    r7150 r7160  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Windows.Input;
     3using Com.Piwigo.Lib.IService;
     4using Com.Piwigo.Wpf.DTO;
     5using Com.Piwigo.Lib.DTO;
     6using Com.Piwigo.Wpf.DTO.Helper;
     7using Com.Piwigo.Wpf.Helper;
    68
    79namespace Com.Piwigo.Wpf.Command
     
    1113        public override bool CanExecute(object parameter)
    1214        {
    13             return true;
     15            Boolean retVal = false;
     16            if ( AppHelper.IsInDesignModeStatic == true)
     17            {
     18                retVal = false;
     19            }
     20            else
     21            {
     22                if ((PwgModelManager.Instance.Session != null)
     23                    & (PwgModelManager.Instance.Session.ServeurName != null))
     24                {
     25                    retVal = !String.IsNullOrWhiteSpace(PwgModelManager.Instance.Session.ServeurName);
     26                }
     27            }
     28            return (retVal);
    1429        }
    1530
    1631        public override void Execute(object parameter)
    1732        {
    18             throw new NotImplementedException();
     33            try {
     34                Uri uriServer = new Uri(PwgModelManager.Instance.Session.ServeurName);
     35
     36                PwgServiceProvider.Instance.PwgSetupService.Setup(null, null, uriServer);
     37                PwgSession sess = PwgServiceProvider.Instance.PwgSessionService.GetPwgSession();
     38                sess = PwgServiceProvider.Instance.PwgSessionService.Login( PwgModelManager.Instance.Session.UserName,
     39                                                                            PwgModelManager.Instance.Session.Password);
     40
     41                PwgSessionWPF sesWPF = PwgModelManager.Instance.Session;
     42                PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF);
     43
     44                List<PwgCategory> lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfCategory(null, false, (PwgModelManager.Instance.Session.Status == PwgSessionStatusEnum.Guest));
     45                PwgCategoryListWPF lstCatWPF = PwgModelManager.Instance.CategoryList;
     46
     47                PwgCategoryListWPFHelper.ConvertPwgCategoryListToPwgCategoryListWPF(lstCat, ref lstCatWPF);
     48            }
     49            catch (PwgServiceException ex)
     50            {
     51                Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr);
     52                Console.WriteLine(ex.Message);
     53            }
     54
    1955        }
    2056    }
Note: See TracChangeset for help on using the changeset viewer.